Last change
on this file since 9698fc0 was
5ebff60,
checked in by dequis <dx@…>, at 2015-02-20T22:50:54Z
|
Reindent everything to K&R style with tabs
Used uncrustify, with the configuration file in ./doc/uncrustify.cfg
Commit author set to "Indent <please@…>" so that it's easier to
skip while doing git blame.
|
-
Property mode set to
100644
|
File size:
1.3 KB
|
Line | |
---|
1 | #include <aim.h> |
---|
2 | #include <ctype.h> |
---|
3 | |
---|
4 | /* |
---|
5 | * int snlen(const char *) |
---|
6 | * |
---|
7 | * This takes a screen name and returns its length without |
---|
8 | * spaces. If there are no spaces in the SN, then the |
---|
9 | * return is equal to that of strlen(). |
---|
10 | * |
---|
11 | */ |
---|
12 | static int aim_snlen(const char *sn) |
---|
13 | { |
---|
14 | int i = 0; |
---|
15 | const char *curPtr = NULL; |
---|
16 | |
---|
17 | if (!sn) { |
---|
18 | return 0; |
---|
19 | } |
---|
20 | |
---|
21 | curPtr = sn; |
---|
22 | while ((*curPtr) != (char) '\0') { |
---|
23 | if ((*curPtr) != ' ') { |
---|
24 | i++; |
---|
25 | } |
---|
26 | curPtr++; |
---|
27 | } |
---|
28 | |
---|
29 | return i; |
---|
30 | } |
---|
31 | |
---|
32 | /* |
---|
33 | * int sncmp(const char *, const char *) |
---|
34 | * |
---|
35 | * This takes two screen names and compares them using the rules |
---|
36 | * on screen names for AIM/AOL. Mainly, this means case and space |
---|
37 | * insensitivity (all case differences and spacing differences are |
---|
38 | * ignored). |
---|
39 | * |
---|
40 | * Return: 0 if equal |
---|
41 | * non-0 if different |
---|
42 | * |
---|
43 | */ |
---|
44 | |
---|
45 | int aim_sncmp(const char *sn1, const char *sn2) |
---|
46 | { |
---|
47 | const char *curPtr1 = NULL, *curPtr2 = NULL; |
---|
48 | |
---|
49 | if (aim_snlen(sn1) != aim_snlen(sn2)) { |
---|
50 | return 1; |
---|
51 | } |
---|
52 | |
---|
53 | curPtr1 = sn1; |
---|
54 | curPtr2 = sn2; |
---|
55 | while ((*curPtr1 != (char) '\0') && (*curPtr2 != (char) '\0')) { |
---|
56 | if ((*curPtr1 == ' ') || (*curPtr2 == ' ')) { |
---|
57 | if (*curPtr1 == ' ') { |
---|
58 | curPtr1++; |
---|
59 | } |
---|
60 | if (*curPtr2 == ' ') { |
---|
61 | curPtr2++; |
---|
62 | } |
---|
63 | } else { |
---|
64 | if (g_ascii_toupper(*curPtr1) != g_ascii_toupper(*curPtr2)) { |
---|
65 | return 1; |
---|
66 | } |
---|
67 | curPtr1++; |
---|
68 | curPtr2++; |
---|
69 | } |
---|
70 | } |
---|
71 | |
---|
72 | /* Should both be NULL */ |
---|
73 | if (*curPtr1 != *curPtr2) { |
---|
74 | return 1; |
---|
75 | } |
---|
76 | |
---|
77 | return 0; |
---|
78 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.