Mercurial > pidgin
comparison libpurple/protocols/oscar/util.c @ 30361:9881f18b95b1
Got rid of family_icq.c -> oscar.c callbacks. Now it will be possible
to add an error handler for SNAC_FAMILY_ICQ right inside family_icq.c,
since all the necessary functions are there.
I made a pretty large refactoring along the way, moving the
authorization- and userinfo-related functions to separate files and
renaming some of them. Hopefully, this will make oscar.c less of mess.
author | ivan.komarov@soc.pidgin.im |
---|---|
date | Sun, 30 May 2010 13:53:45 +0000 |
parents | f18b6eb0ed02 |
children | a1043e95aa13 |
comparison
equal
deleted
inserted
replaced
30360:2f25002c9464 | 30361:9881f18b95b1 |
---|---|
321 return 1; | 321 return 1; |
322 } while ((*name1 != '\0') && name1++ && name2++); | 322 } while ((*name1 != '\0') && name1++ && name2++); |
323 | 323 |
324 return 0; | 324 return 0; |
325 } | 325 } |
326 | |
327 /** | |
328 * Looks for %n, %d, or %t in a string, and replaces them with the | |
329 * specified name, date, and time, respectively. | |
330 * | |
331 * @param str The string that may contain the special variables. | |
332 * @param name The sender name. | |
333 * | |
334 * @return A newly allocated string where the special variables are | |
335 * expanded. This should be g_free'd by the caller. | |
336 */ | |
337 gchar * | |
338 oscar_util_format_string(const char *str, const char *name) | |
339 { | |
340 char *c; | |
341 GString *cpy; | |
342 time_t t; | |
343 struct tm *tme; | |
344 | |
345 g_return_val_if_fail(str != NULL, NULL); | |
346 g_return_val_if_fail(name != NULL, NULL); | |
347 | |
348 /* Create an empty GString that is hopefully big enough for most messages */ | |
349 cpy = g_string_sized_new(1024); | |
350 | |
351 t = time(NULL); | |
352 tme = localtime(&t); | |
353 | |
354 c = (char *)str; | |
355 while (*c) { | |
356 switch (*c) { | |
357 case '%': | |
358 if (*(c + 1)) { | |
359 switch (*(c + 1)) { | |
360 case 'n': | |
361 /* append name */ | |
362 g_string_append(cpy, name); | |
363 c++; | |
364 break; | |
365 case 'd': | |
366 /* append date */ | |
367 g_string_append(cpy, purple_date_format_short(tme)); | |
368 c++; | |
369 break; | |
370 case 't': | |
371 /* append time */ | |
372 g_string_append(cpy, purple_time_format(tme)); | |
373 c++; | |
374 break; | |
375 default: | |
376 g_string_append_c(cpy, *c); | |
377 } | |
378 } else { | |
379 g_string_append_c(cpy, *c); | |
380 } | |
381 break; | |
382 default: | |
383 g_string_append_c(cpy, *c); | |
384 } | |
385 c++; | |
386 } | |
387 | |
388 return g_string_free(cpy, FALSE); | |
389 } |