107
107
return g_strdup_printf("%s/%s", name, version);;
111
* Tokenizing functions. Used to portably replace strtok/sep.
115
/* TODO: Get rid of this and use glib functions */
117
aimutil_tokslen(char *toSearch, int theindex, char dl)
125
next = strchr(toSearch, dl);
127
while(curCount < theindex && next != NULL) {
130
next = strchr(last, dl);
133
if ((curCount < theindex) || (next == NULL))
134
toReturn = strlen(toSearch) - (curCount - 1);
136
toReturn = next - toSearch - (curCount - 1);
142
aimutil_itemcnt(char *toSearch, char dl)
149
next = strchr(toSearch, dl);
151
while(next != NULL) {
153
next = strchr(next + 1, dl);
160
aimutil_itemindex(char *toSearch, int theindex, char dl)
170
next = strchr(toSearch, dl);
172
while (curCount < theindex && next != NULL) {
175
next = strchr(last, dl);
177
next = strchr(last, dl);
179
if (curCount < theindex) {
180
toReturn = g_malloc(sizeof(char));
184
toReturn = g_malloc((strlen(last) + 1) * sizeof(char));
185
strcpy(toReturn, last);
187
toReturn = g_malloc((next - last + 1) * sizeof(char));
188
memcpy(toReturn, last, (next - last));
189
toReturn[next - last] = '\0';
196
111
* Calculate the checksum of a given icon.
243
* Looks for %n, %d, or %t in a string, and replaces them with the
244
* specified name, date, and time, respectively.
246
* @param str The string that may contain the special variables.
247
* @param name The sender name.
249
* @return A newly allocated string where the special variables are
250
* expanded. This should be g_free'd by the caller.
253
oscar_util_format_string(const char *str, const char *name)
260
g_return_val_if_fail(str != NULL, NULL);
261
g_return_val_if_fail(name != NULL, NULL);
263
/* Create an empty GString that is hopefully big enough for most messages */
264
cpy = g_string_sized_new(1024);
277
g_string_append(cpy, name);
282
g_string_append(cpy, purple_date_format_short(tme));
287
g_string_append(cpy, purple_time_format(tme));
291
g_string_append_c(cpy, *c);
294
g_string_append_c(cpy, *c);
298
g_string_append_c(cpy, *c);
303
return g_string_free(cpy, FALSE);
307
oscar_format_buddies(GSList *buddies, const gchar *no_buddies_message)
312
return g_strdup_printf("<i>%s</i>", no_buddies_message);
314
result = g_string_new("");
315
for (cur = buddies; cur != NULL; cur = cur->next) {
316
PurpleBuddy *buddy = cur->data;
317
const gchar *bname = purple_buddy_get_name(buddy);
318
const gchar *alias = purple_buddy_get_alias_only(buddy);
319
g_string_append(result, bname);
321
g_string_append_printf(result, " (%s)", alias);
323
g_string_append(result, "<br>");
325
return g_string_free(result, FALSE);