32
35
#include "win32dep.h"
38
int oscar_get_ui_info_int(const char *str, int default_value)
42
ui_info = purple_core_get_ui_info();
43
if (ui_info != NULL) {
45
if (g_hash_table_lookup_extended(ui_info, str, NULL, &value))
46
return GPOINTER_TO_INT(value);
52
const char *oscar_get_ui_info_string(const char *str, const char *default_value)
55
const char *value = NULL;
57
ui_info = purple_core_get_ui_info();
59
value = g_hash_table_lookup(ui_info, str);
61
value = default_value;
66
gchar *oscar_get_clientstring(void)
68
const char *name, *version;
70
name = oscar_get_ui_info_string("name", "Purple");
71
version = oscar_get_ui_info_string("version", VERSION);
73
return g_strdup_printf("%s/%s", name, version);;
36
77
* Tokenizing functions. Used to portably replace strtok/sep.
139
* Check if the given screen name is a valid AIM screen name.
180
* Check if the given name is a valid AIM username.
140
181
* Example: BobDole
141
182
* Example: Henry_Ford@mac.com
142
183
* Example: 1KrazyKat@example.com
144
* @return TRUE if the screen name is valid, FALSE if not.
185
* @return TRUE if the name is valid, FALSE if not.
147
aim_snvalid_aim(const char *sn)
188
oscar_util_valid_name_aim(const char *name)
151
if (purple_email_is_valid(sn))
192
if (purple_email_is_valid(name))
154
/* Normal AIM screen names can't start with a number */
195
/* Normal AIM usernames can't start with a number */
196
if (isdigit(name[0]))
158
for (i = 0; sn[i] != '\0'; i++) {
159
if (!isalnum(sn[i]) && (sn[i] != ' '))
199
for (i = 0; name[i] != '\0'; i++) {
200
if (!isalnum(name[i]) && (name[i] != ' '))
167
* Check if the given screen name is a valid ICQ screen name.
208
* Check if the given name is a valid ICQ username.
168
209
* Example: 1234567
170
* @return TRUE if the screen name is valid, FALSE if not.
211
* @return TRUE if the name is valid, FALSE if not.
173
aim_snvalid_icq(const char *sn)
214
oscar_util_valid_name_icq(const char *name)
177
for (i = 0; sn[i] != '\0'; i++) {
218
for (i = 0; name[i] != '\0'; i++) {
219
if (!isdigit(name[i]))
186
* Check if the given screen name is a valid SMS screen name.
227
* Check if the given name is a valid SMS username.
187
228
* Example: +19195551234
189
* @return TRUE if the screen name is valid, FALSE if not.
230
* @return TRUE if the name is valid, FALSE if not.
192
aim_snvalid_sms(const char *sn)
233
oscar_util_valid_name_sms(const char *name)
199
for (i = 1; sn[i] != '\0'; i++) {
240
for (i = 1; name[i] != '\0'; i++) {
241
if (!isdigit(name[i]))
208
* Check if the given screen name is a valid oscar screen name.
249
* Check if the given name is a valid oscar username.
210
* @return TRUE if the screen name is valid, FALSE if not.
251
* @return TRUE if the name is valid, FALSE if not.
213
aim_snvalid(const char *sn)
254
oscar_util_valid_name(const char *name)
215
if ((sn == NULL) || (*sn == '\0'))
256
if ((name == NULL) || (*name == '\0'))
218
return aim_snvalid_icq(sn) || aim_snvalid_sms(sn) || aim_snvalid_aim(sn);
259
return oscar_util_valid_name_icq(name)
260
|| oscar_util_valid_name_sms(name)
261
|| oscar_util_valid_name_aim(name);
222
* This takes two screen names and compares them using the rules
223
* on screen names for AIM/AOL. Mainly, this means case and space
265
* This takes two names and compares them using the rules
266
* on usernames for AIM/AOL. Mainly, this means case and space
224
267
* insensitivity (all case differences and spacing differences are
225
* ignored, with the exception that screen names can not start with
268
* ignored, with the exception that usernames can not start with
228
271
* @return 0 if equal, non-0 if different
230
273
/* TODO: Do something different for email addresses. */
232
aim_sncmp(const char *sn1, const char *sn2)
275
oscar_util_name_compare(const char *name1, const char *name2)
235
if ((sn1 == NULL) || (sn2 == NULL))
278
if ((name1 == NULL) || (name2 == NULL))
243
if (toupper(*sn1) != toupper(*sn2))
282
while (*name2 == ' ')
284
while (*name1 == ' ')
286
if (toupper(*name1) != toupper(*name2))
245
} while ((*sn1 != '\0') && sn1++ && sn2++);
288
} while ((*name1 != '\0') && name1++ && name2++);