Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #111 from crab2313/dev

billzt的build fix
  • Loading branch information...
commit 19ce0a8ac64ece94b9f58c6995fb23cd36232a38 2 parents 7d806cb + 51ac40e
@mathslinux mathslinux authored
Showing with 14 additions and 39 deletions.
  1. +11 −7 src/libqq/qq-login.c
  2. +3 −32 src/libqq/qqpoll.c
View
18 src/libqq/qq-login.c
@@ -113,7 +113,11 @@ static gint check_verify_code(QQInfo *info)
g_debug("check vc return: %s(%s, %d)", s, __FILE__, __LINE__);
- char **result = g_strsplit(s, "'", -1);
+ gchar **result = g_strsplit(s, "'", -1);
+ if (result == NULL) {
+ g_warning("Parse error (%s, %d)", __FILE__, __LINE__);
+ goto error;
+ }
if (*result[1] == '0') { /* we needn't get a image */
info->need_vcimage = FALSE;
info->verify_code = g_string_new(result[3]);
@@ -134,13 +138,14 @@ static gint check_verify_code(QQInfo *info)
} else {
g_warning("Unknown return value!(%s, %d)", __FILE__, __LINE__);
ret = NETWORK_ERR;
+ g_strfreev(result);
goto error;
}
+ g_strfreev(result);
error:
request_del(req);
response_del(rps);
- g_strfreev(result);
return ret;
}
@@ -302,7 +307,6 @@ static gint get_version(QQInfo *info)
* Compute the chekc sum of the new string.
*/
-/* TODO: complete this function */
GString* get_pwvc_md5(GString *passwd, GString *vc, GString *uin)
{
@@ -353,16 +357,17 @@ GString* get_pwvc_md5(GString *passwd, GString *vc, GString *uin)
snprintf(buf, 100, "%s%s", c, vc->str);
char *a = g_ascii_strup(buf, strlen(buf));
- printf("%s\n", a);
g_checksum_free(cs);
-
cs = g_checksum_new(G_CHECKSUM_MD5);
g_checksum_update(cs, (const guchar *)a, strlen(a));
const char *d = g_checksum_get_string(cs);
char *e = g_ascii_strup(d, strlen(d));
- return g_string_new(e);
+ g_checksum_free(cs);
+ GString *ret = g_string_new(e);
+ g_free(e);
+ return ret;
}
@@ -749,7 +754,6 @@ static gint do_login(QQInfo *info, const gchar *uin, const gchar *passwd
g_debug("Login...(%s, %d)", __FILE__, __LINE__);
- /* TODO : complete and test this function */
GString *md5 = get_pwvc_md5(
g_string_new(passwd), info -> verify_code, info->hex_uin);
View
35 src/libqq/qqpoll.c
@@ -30,8 +30,6 @@ static void parase_content(QQRecvMsg *msg, json_t *json)
{
json_t *tmp = NULL;
GString *utf8 = g_string_new("");
- GString *tmpstring = g_string_new("");
- gint i;
tmp = json_find_first_label_all(json, "content");
if(tmp == NULL){
g_warning("No conent found!(%s, %d)", __FILE__, __LINE__);
@@ -45,36 +43,10 @@ static void parase_content(QQRecvMsg *msg, json_t *json)
if(ctent -> type == JSON_STRING){
//String
g_string_truncate(utf8, 0);
- g_string_truncate(tmpstring, 0);
ucs4toutf8(utf8, ctent -> text);
- for(i = 0; i < utf8 -> len; ++i){
- if(utf8 -> str[i] == '\\' && i + 1 < utf8 -> len){
- switch(utf8 -> str[i + 1])
- {
- case '\\':
- g_string_append_c(tmpstring, '\\');
- break;
- case 'n':
- g_string_append_c(tmpstring, '\n');
- break;
- case 'r':
- g_string_append_c(tmpstring, '\r');
- break;
- case 't':
- g_string_append_c(tmpstring, '\t');
- break;
- case '"':
- g_string_append_c(tmpstring, '"');
- break;
- default:
- break;
- }
- ++i;
- }else{
- g_string_append_c(tmpstring, utf8 -> str[i]);
- }
- }
- ct = qq_msgcontent_new(QQ_MSG_CONTENT_STRING_T, tmpstring -> str);
+ gchar *tmpstring = g_strcompress(utf8->str);
+ ct = qq_msgcontent_new(QQ_MSG_CONTENT_STRING_T, tmpstring);
+ g_free(tmpstring);
qq_recvmsg_add_content(msg, ct);
g_debug("Msg Content: string %s(%s, %d)", utf8 -> str
, __FILE__, __LINE__);
@@ -145,7 +117,6 @@ static void parase_content(QQRecvMsg *msg, json_t *json)
}
}
g_string_free(utf8, TRUE);
- g_string_free(tmpstring, TRUE);
}
Please sign in to comment.
Something went wrong with that request. Please try again.