Mercurial > pidgin.yaz
annotate src/protocols/oscar/util.c @ 13234:f2431a7e33aa
[gaim-migrate @ 15600]
Massive oscar shuffling. No change in functionality.
I renamed each of the files that contains stuff for a SNAC family.
I started splitting the file transfer/direct connect stuff into
peer.c and peer.h. I stopped using fu8_t, fu16_t and fu32_t and
switched to guint8, guint16 and guint32 instead. I changed the
SNAC family and subtype defines so they are more meaningful.
Added LGPL copyright header to each file. Added myself to the
AUTHORS file.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sat, 11 Feb 2006 21:45:18 +0000 |
parents | bdb8d7beb5a7 |
children | f260d319bbbc |
rev | line source |
---|---|
13234 | 1 /* |
2 * Gaim's oscar protocol plugin | |
3 * This file is the legal property of its developers. | |
4 * Please see the AUTHORS file distributed alongside this file. | |
5 * | |
6 * This library is free software; you can redistribute it and/or | |
7 * modify it under the terms of the GNU Lesser General Public | |
8 * License as published by the Free Software Foundation; either | |
9 * version 2 of the License, or (at your option) any later version. | |
10 * | |
11 * This library is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 * Lesser General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU Lesser General Public | |
17 * License along with this library; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 */ | |
20 | |
2086 | 21 /* |
4246 | 22 * A little bit of this |
23 * A little bit of that | |
24 * It started with a kiss | |
25 * Now we're up to bat | |
2086 | 26 */ |
27 | |
13234 | 28 #include "oscar.h" |
2086 | 29 #include <ctype.h> |
30 | |
4246 | 31 #ifdef _WIN32 |
32 #include "win32dep.h" | |
33 #endif | |
34 | |
5927 | 35 faim_export int aimutil_putstr(char *dest, const char *src, int len) |
2086 | 36 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
37 memcpy(dest, src, len); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
38 return len; |
2086 | 39 } |
40 | |
41 /* | |
42 * Tokenizing functions. Used to portably replace strtok/sep. | |
43 * -- DMP. | |
44 * | |
45 */ | |
6323 | 46 faim_export int aimutil_tokslen(char *toSearch, int theindex, char dl) |
2086 | 47 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
48 int curCount = 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
49 char *next; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
50 char *last; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
51 int toReturn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
52 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
53 last = toSearch; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
54 next = strchr(toSearch, dl); |
2086 | 55 |
6323 | 56 while(curCount < theindex && next != NULL) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
57 curCount++; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
58 last = next + 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
59 next = strchr(last, dl); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
60 } |
2086 | 61 |
6323 | 62 if ((curCount < theindex) || (next == NULL)) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
63 toReturn = strlen(toSearch) - (curCount - 1); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
64 else |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
65 toReturn = next - toSearch - (curCount - 1); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
66 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
67 return toReturn; |
2086 | 68 } |
69 | |
70 faim_export int aimutil_itemcnt(char *toSearch, char dl) | |
71 { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
72 int curCount; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
73 char *next; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
74 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
75 curCount = 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
76 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
77 next = strchr(toSearch, dl); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
78 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
79 while(next != NULL) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
80 curCount++; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
81 next = strchr(next + 1, dl); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
82 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
83 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
84 return curCount; |
2086 | 85 } |
86 | |
6323 | 87 faim_export char *aimutil_itemindex(char *toSearch, int theindex, char dl) |
2086 | 88 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
89 int curCount; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
90 char *next; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
91 char *last; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
92 char *toReturn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
93 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
94 curCount = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
95 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
96 last = toSearch; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
97 next = strchr(toSearch, dl); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
98 |
6323 | 99 while (curCount < theindex && next != NULL) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
100 curCount++; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
101 last = next + 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
102 next = strchr(last, dl); |
2086 | 103 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
104 |
6323 | 105 if (curCount < theindex) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
106 toReturn = malloc(sizeof(char)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
107 *toReturn = '\0'; |
2086 | 108 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
109 next = strchr(last, dl); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
110 |
6323 | 111 if (curCount < theindex) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
112 toReturn = malloc(sizeof(char)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
113 *toReturn = '\0'; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
114 } else { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
115 if (next == NULL) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
116 toReturn = malloc((strlen(last) + 1) * sizeof(char)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
117 strcpy(toReturn, last); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
118 } else { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
119 toReturn = malloc((next - last + 1) * sizeof(char)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
120 memcpy(toReturn, last, (next - last)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
121 toReturn[next - last] = '\0'; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
122 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
123 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
124 return toReturn; |
2086 | 125 } |
126 | |
4617 | 127 /** |
128 * Calculate the checksum of a given icon. | |
129 * | |
130 */ | |
13234 | 131 faim_export guint16 aimutil_iconsum(const guint8 *buf, int buflen) |
4617 | 132 { |
13234 | 133 guint32 sum; |
4617 | 134 int i; |
135 | |
136 for (i=0, sum=0; i+1<buflen; i+=2) | |
137 sum += (buf[i+1] << 8) + buf[i]; | |
138 if (i < buflen) | |
139 sum += buf[i]; | |
140 sum = ((sum & 0xffff0000) >> 16) + (sum & 0x0000ffff); | |
141 | |
142 return sum; | |
143 } | |
144 | |
8092 | 145 /** |
8972 | 146 * Check if the given screen name is a valid AIM screen name. |
147 * Example: BobDole | |
9681 | 148 * Example: Henry_Ford@mac.com |
8972 | 149 * |
150 * @return 1 if the screen name is valid, 0 if not. | |
151 */ | |
152 static int aim_snvalid_aim(const char *sn) | |
153 { | |
154 int i; | |
155 | |
156 for (i = 0; sn[i] != '\0'; i++) { | |
9681 | 157 if (!isalnum(sn[i]) && (sn[i] != ' ') && |
158 (sn[i] != '@') && (sn[i] != '.') && | |
159 (sn[i] != '_') && (sn[i] != '-')) | |
8972 | 160 return 0; |
161 } | |
162 | |
163 return 1; | |
164 } | |
165 | |
166 /** | |
167 * Check if the given screen name is a valid ICQ screen name. | |
168 * Example: 1234567 | |
169 * | |
170 * @return 1 if the screen name is valid, 0 if not. | |
171 */ | |
172 static int aim_snvalid_icq(const char *sn) | |
173 { | |
174 int i; | |
175 | |
176 for (i = 0; sn[i] != '\0'; i++) { | |
177 if (!isdigit(sn[i])) | |
178 return 0; | |
179 } | |
180 | |
181 return 1; | |
182 } | |
183 | |
184 /** | |
185 * Check if the given screen name is a valid SMS screen name. | |
186 * Example: +19195551234 | |
187 * | |
188 * @return 1 if the screen name is valid, 0 if not. | |
189 */ | |
190 static int aim_snvalid_sms(const char *sn) | |
191 { | |
192 int i; | |
193 | |
194 if (sn[0] != '+') | |
195 return 0; | |
196 | |
197 for (i = 1; sn[i] != '\0'; i++) { | |
198 if (!isdigit(sn[i])) | |
199 return 0; | |
200 } | |
201 | |
202 return 1; | |
203 } | |
204 | |
205 /** | |
206 * Check if the given screen name is a valid oscar screen name. | |
8092 | 207 * |
208 * @return 1 if the screen name is valid, 0 if not. | |
209 */ | |
210 faim_export int aim_snvalid(const char *sn) | |
211 { | |
8972 | 212 if ((sn == NULL) || (*sn == '\0')) |
8092 | 213 return 0; |
214 | |
8972 | 215 if (isalpha(sn[0])) |
216 return aim_snvalid_aim(sn); | |
217 else if (isdigit(sn[0])) | |
218 return aim_snvalid_icq(sn); | |
219 else if (sn[0] == '+') | |
220 return aim_snvalid_sms(sn); | |
8092 | 221 |
8972 | 222 return 0; |
8092 | 223 } |
224 | |
9975 | 225 /** |
226 * Determine if a given screen name is an ICQ screen name | |
227 * (i.e. it begins with a number). | |
228 * | |
229 * @sn A valid AIM or ICQ screen name. | |
230 * @return 1 if the screen name is an ICQ screen name. Otherwise 0 | |
231 * is returned. | |
232 */ | |
233 faim_export int aim_sn_is_icq(const char *sn) | |
234 { | |
235 if (isalpha(sn[0])) | |
236 return 0; | |
237 return 1; | |
238 } | |
239 | |
13168
bdb8d7beb5a7
[gaim-migrate @ 15531]
Evan Schoenberg <evan.s@dreskin.net>
parents:
11253
diff
changeset
|
240 /** |
bdb8d7beb5a7
[gaim-migrate @ 15531]
Evan Schoenberg <evan.s@dreskin.net>
parents:
11253
diff
changeset
|
241 * Determine if a given screen name is an SMS number |
bdb8d7beb5a7
[gaim-migrate @ 15531]
Evan Schoenberg <evan.s@dreskin.net>
parents:
11253
diff
changeset
|
242 * (i.e. it begins with a +). |
bdb8d7beb5a7
[gaim-migrate @ 15531]
Evan Schoenberg <evan.s@dreskin.net>
parents:
11253
diff
changeset
|
243 * |
bdb8d7beb5a7
[gaim-migrate @ 15531]
Evan Schoenberg <evan.s@dreskin.net>
parents:
11253
diff
changeset
|
244 * @sn A valid AIM or ICQ screen name. |
bdb8d7beb5a7
[gaim-migrate @ 15531]
Evan Schoenberg <evan.s@dreskin.net>
parents:
11253
diff
changeset
|
245 * @return 1 if the screen name is an SMS number. Otherwise 0 |
bdb8d7beb5a7
[gaim-migrate @ 15531]
Evan Schoenberg <evan.s@dreskin.net>
parents:
11253
diff
changeset
|
246 * is returned. |
bdb8d7beb5a7
[gaim-migrate @ 15531]
Evan Schoenberg <evan.s@dreskin.net>
parents:
11253
diff
changeset
|
247 */ |
bdb8d7beb5a7
[gaim-migrate @ 15531]
Evan Schoenberg <evan.s@dreskin.net>
parents:
11253
diff
changeset
|
248 faim_export int aim_sn_is_sms(const char *sn) |
bdb8d7beb5a7
[gaim-migrate @ 15531]
Evan Schoenberg <evan.s@dreskin.net>
parents:
11253
diff
changeset
|
249 { |
bdb8d7beb5a7
[gaim-migrate @ 15531]
Evan Schoenberg <evan.s@dreskin.net>
parents:
11253
diff
changeset
|
250 if (sn[0] != '+') |
bdb8d7beb5a7
[gaim-migrate @ 15531]
Evan Schoenberg <evan.s@dreskin.net>
parents:
11253
diff
changeset
|
251 return 0; |
bdb8d7beb5a7
[gaim-migrate @ 15531]
Evan Schoenberg <evan.s@dreskin.net>
parents:
11253
diff
changeset
|
252 return 1; |
bdb8d7beb5a7
[gaim-migrate @ 15531]
Evan Schoenberg <evan.s@dreskin.net>
parents:
11253
diff
changeset
|
253 } |
bdb8d7beb5a7
[gaim-migrate @ 15531]
Evan Schoenberg <evan.s@dreskin.net>
parents:
11253
diff
changeset
|
254 |
2086 | 255 /* |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
256 * int snlen(const char *) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
257 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
258 * This takes a screen name and returns its length without |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
259 * spaces. If there are no spaces in the SN, then the |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
260 * return is equal to that of strlen(). |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
261 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
262 */ |
2086 | 263 faim_export int aim_snlen(const char *sn) |
264 { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
265 int i = 0; |
2086 | 266 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
267 if (!sn) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
268 return 0; |
2086 | 269 |
5556 | 270 while (*sn != '\0') { |
271 if (*sn != ' ') | |
272 i++; | |
273 sn++; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
274 } |
2086 | 275 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
276 return i; |
2086 | 277 } |
278 | |
279 /* | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
280 * int sncmp(const char *, const char *) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
281 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
282 * This takes two screen names and compares them using the rules |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
283 * on screen names for AIM/AOL. Mainly, this means case and space |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
284 * insensitivity (all case differences and spacing differences are |
5628 | 285 * ignored, with the exception that screen names can not start with |
286 * a space). | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
287 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
288 * Return: 0 if equal |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
289 * non-0 if different |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
290 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
291 */ |
2086 | 292 faim_export int aim_sncmp(const char *sn1, const char *sn2) |
293 { | |
294 | |
10116 | 295 if ((sn1 == NULL) || (sn2 == NULL)) |
296 return -1; | |
297 | |
5928 | 298 do { |
5556 | 299 while (*sn2 == ' ') |
5724 | 300 sn2++; |
5556 | 301 while (*sn1 == ' ') |
5724 | 302 sn1++; |
5928 | 303 if (toupper(*sn1) != toupper(*sn2)) |
304 return 1; | |
305 } while ((*sn1 != '\0') && sn1++ && sn2++); | |
2086 | 306 |
5928 | 307 return 0; |
2086 | 308 } |