Mercurial > pidgin
comparison libpurple/protocols/qq/utils.c @ 24653:fecedf6d9ee1
propagate from branch 'im.pidgin.pidgin' (head 97d295a04f3a9852a3b29cf0df43d56d1ddcc672)
to branch 'im.pidgin.pidgin.openq' (head a0d99396d1603b53838d74cad4391ece34f3ebbf)
author | SHiNE CsyFeK <csyfek@gmail.com> |
---|---|
date | Fri, 05 Dec 2008 14:51:36 +0000 |
parents | 0320b4a33432 4f0e1c738ce5 |
children | 1300601041ac |
comparison
equal
deleted
inserted
replaced
24590:c457c635eb8f | 24653:fecedf6d9ee1 |
---|---|
36 #include "debug.h" | 36 #include "debug.h" |
37 #include "prefs.h" | 37 #include "prefs.h" |
38 #include "qq.h" | 38 #include "qq.h" |
39 #include "util.h" | 39 #include "util.h" |
40 #include "utils.h" | 40 #include "utils.h" |
41 | |
42 #define QQ_NAME_FORMAT "%d" | |
43 | 41 |
44 /* These functions are used only in development phase */ | 42 /* These functions are used only in development phase */ |
45 /* | 43 /* |
46 static void _qq_show_socket(gchar *desc, gint fd) { | 44 static void _qq_show_socket(gchar *desc, gint fd) { |
47 struct sockaddr_in sin; | 45 struct sockaddr_in sin; |
133 guint32 purple_name_to_uid(const gchar *const name) | 131 guint32 purple_name_to_uid(const gchar *const name) |
134 { | 132 { |
135 guint32 ret; | 133 guint32 ret; |
136 g_return_val_if_fail(name != NULL, 0); | 134 g_return_val_if_fail(name != NULL, 0); |
137 | 135 |
138 ret = strtol(name, NULL, 10); | 136 ret = strtoul(name, NULL, 10); |
139 if (errno == ERANGE) | 137 if (errno == ERANGE) |
140 return 0; | 138 return 0; |
141 else | 139 else |
142 return ret; | 140 return ret; |
143 } | 141 } |
167 | 165 |
168 /* convert a QQ UID to a unique name of Purple | 166 /* convert a QQ UID to a unique name of Purple |
169 * the return needs to be freed */ | 167 * the return needs to be freed */ |
170 gchar *uid_to_purple_name(guint32 uid) | 168 gchar *uid_to_purple_name(guint32 uid) |
171 { | 169 { |
172 return g_strdup_printf(QQ_NAME_FORMAT, uid); | 170 return g_strdup_printf("%u", uid); |
173 } | 171 } |
174 | 172 |
175 /* try to dump the data as GBK */ | 173 /* try to dump the data as GBK */ |
176 gchar* try_dump_as_gbk(const guint8 *const data, gint len) | 174 gchar* try_dump_as_gbk(const guint8 *const data, gint len) |
177 { | 175 { |
337 void qq_show_packet(const gchar *desc, const guint8 *buf, gint len) | 335 void qq_show_packet(const gchar *desc, const guint8 *buf, gint len) |
338 { | 336 { |
339 qq_hex_dump(PURPLE_DEBUG_WARNING, "QQ", buf, len, desc); | 337 qq_hex_dump(PURPLE_DEBUG_WARNING, "QQ", buf, len, desc); |
340 } | 338 } |
341 | 339 |
340 void qq_filter_str(gchar *str) { | |
341 gchar *temp; | |
342 if (str == NULL) { | |
343 return; | |
344 } | |
345 | |
346 for (temp = str; *temp != 0; temp++) { | |
347 /*if (*temp == '\r' || *temp == '\n') *temp = ' ';*/ | |
348 if (*temp > 0 && *temp < 0x20) *temp = ' '; | |
349 } | |
350 g_strstrip(str); | |
351 } |