comparison libpurple/protocols/qq/utils.c @ 24085:237e5a94e11c

2008.10.08 - ccpaging <ccpaging(at)gmail.com> * Update group part * Delete some meaningless functions and data * Added 'change my icon' 2008.10.08 - lonicerae <lonicerae(at)gmail.com> * Merge 20081008 patch into trunk
author SHiNE CsyFeK <csyfek@gmail.com>
date Wed, 22 Oct 2008 15:08:30 +0000
parents 119d85c40d75
children 7c0a56c5fea0
comparison
equal deleted inserted replaced
24084:340fc40fe4ef 24085:237e5a94e11c
87 break; 87 break;
88 88
89 if (index >= amount) 89 if (index >= amount)
90 index = 0; /* meaning no match */ 90 index = 0; /* meaning no match */
91 return g_strdup_printf("%d", index); 91 return g_strdup_printf("%d", index);
92 }
93
94 gint qq_string_to_dec_value(const gchar *str)
95 {
96 g_return_val_if_fail(str != NULL, 0);
97 return strtol(str, NULL, 10);
98 } 92 }
99 93
100 /* split the given data(len) with delimit, 94 /* split the given data(len) with delimit,
101 * check the number of field matches the expected_fields (<=0 means all) 95 * check the number of field matches the expected_fields (<=0 means all)
102 * return gchar* array (needs to be freed by g_strfreev later), or NULL */ 96 * return gchar* array (needs to be freed by g_strfreev later), or NULL */
174 /* convert a QQ UID to a unique name of Purple 168 /* convert a QQ UID to a unique name of Purple
175 * the return needs to be freed */ 169 * the return needs to be freed */
176 gchar *uid_to_purple_name(guint32 uid) 170 gchar *uid_to_purple_name(guint32 uid)
177 { 171 {
178 return g_strdup_printf(QQ_NAME_FORMAT, uid); 172 return g_strdup_printf(QQ_NAME_FORMAT, uid);
179 }
180
181 /* convert name displayed in a chat channel to original QQ UID */
182 gchar *chat_name_to_purple_name(const gchar *const name)
183 {
184 const char *start;
185 const char *end;
186 gchar *ret;
187
188 g_return_val_if_fail(name != NULL, NULL);
189
190 /* Sample: (1234567)*/
191 start = strchr(name, '(');
192 g_return_val_if_fail(start != NULL, NULL);
193 end = strchr(start, ')');
194 g_return_val_if_fail(end != NULL && (end - start) > 1, NULL);
195
196 ret = g_strndup(start + 1, end - start - 1);
197
198 return ret;
199 } 173 }
200 174
201 /* try to dump the data as GBK */ 175 /* try to dump the data as GBK */
202 gchar* try_dump_as_gbk(const guint8 *const data, gint len) 176 gchar* try_dump_as_gbk(const guint8 *const data, gint len)
203 { 177 {