Mercurial > pidgin.yaz
changeset 7106:db6bd3e794d8
[gaim-migrate @ 7671]
tobase16(), frombase16(), tobase64(), frombase64() -> gaim_base16_encode(),
gaim_base16_decode(), gaim_base64_encode(), gaim_base64_decode().
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Wed, 01 Oct 2003 05:56:58 +0000 |
parents | 9d0e74b6ca68 |
children | 9220c7490cd1 |
files | src/protocols/jabber/auth.c src/protocols/jabber/buddy.c src/protocols/msn/msnslp.c src/protocols/oscar/oscar.c src/protocols/trepia/trepia.c src/proxy.c src/util.c src/util.h |
diffstat | 8 files changed, 21 insertions(+), 62 deletions(-) [+] |
line wrap: on
line diff
--- a/src/protocols/jabber/auth.c Wed Oct 01 05:43:14 2003 +0000 +++ b/src/protocols/jabber/auth.c Wed Oct 01 05:56:58 2003 +0000 @@ -215,13 +215,13 @@ md5_append(&ctx, a1, strlen(a1)); md5_finish(&ctx, result); - ha1 = tobase16(result, 16); + ha1 = gaim_base16_encode(result, 16); md5_init(&ctx); md5_append(&ctx, a2, strlen(a2)); md5_finish(&ctx, result); - ha2 = tobase16(result, 16); + ha2 = gaim_base16_encode(result, 16); kd = g_strdup_printf("%s:%s:00000001:%s:auth:%s", ha1, nonce, cnonce, ha2); @@ -229,7 +229,7 @@ md5_append(&ctx, kd, strlen(kd)); md5_finish(&ctx, result); - z = tobase16(result, 16); + z = gaim_base16_encode(result, 16); g_free(x); g_free(y); @@ -249,7 +249,7 @@ char *enc_out; GHashTable *parts; - frombase64(enc_in, &dec_in, NULL); + gaim_base64_decode(enc_in, &dec_in, NULL); parts = parse_challenge(dec_in); @@ -299,7 +299,7 @@ g_free(auth_resp); g_free(cnonce); - enc_out = tobase64(response->str, response->len); + enc_out = gaim_base64_encode(response->str, response->len); gaim_debug(GAIM_DEBUG_MISC, "jabber", "decoded response (%d): %s\n", response->len, response->str);
--- a/src/protocols/jabber/buddy.c Wed Oct 01 05:43:14 2003 +0000 +++ b/src/protocols/jabber/buddy.c Wed Oct 01 05:56:58 2003 +0000 @@ -721,7 +721,7 @@ char *data, *text2; int size, imgid; if((text2 = xmlnode_get_data(child2))) { - frombase64(text2, &data, &size); + gaim_base64_decode(text2, &data, &size); imgid = gaim_imgstore_add(data, size, "logo.png"); g_string_append_printf(info_text,
--- a/src/protocols/msn/msnslp.c Wed Oct 01 05:43:14 2003 +0000 +++ b/src/protocols/msn/msnslp.c Wed Oct 01 05:56:58 2003 +0000 @@ -221,7 +221,7 @@ g_return_if_fail(obj != NULL); msnobj_data = msn_object_to_string(obj); - msnobj_base64 = tobase64(msnobj_data, strlen(msnobj_data)); + msnobj_base64 = gaim_base64_encode(msnobj_data, strlen(msnobj_data)); g_free(msnobj_data); #if 0
--- a/src/protocols/oscar/oscar.c Wed Oct 01 05:43:14 2003 +0000 +++ b/src/protocols/oscar/oscar.c Wed Oct 01 05:56:58 2003 +0000 @@ -1820,7 +1820,7 @@ char *filename = NULL, *b16 = NULL, *saved_b16 = NULL; GaimBuddy *b = NULL; - b16 = tobase16(info->iconcsum, info->iconcsumlen); + b16 = gaim_base16_encode(info->iconcsum, info->iconcsumlen); b = gaim_find_buddy(gc->account, info->sn); /* * If for some reason the checksum is valid, but cached file is not.. @@ -3441,7 +3441,7 @@ GaimBuddy *b = gaim_find_buddy(gc->account, sn); gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), sn, icon, iconlen); - b16 = tobase16(iconcsum, iconcsumlen); + b16 = gaim_base16_encode(iconcsum, iconcsumlen); if (b16) { gaim_buddy_set_setting(b, "icon_checksum", b16); gaim_blist_save();
--- a/src/protocols/trepia/trepia.c Wed Oct 01 05:43:14 2003 +0000 +++ b/src/protocols/trepia/trepia.c Wed Oct 01 05:56:58 2003 +0000 @@ -4,7 +4,7 @@ * gaim * * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org> - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -97,47 +97,6 @@ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" "0123456789+/"; -static char * -base64_enc(const char *data, int len) -{ - char *dest; - char *buf; - - buf = dest = g_malloc(4 * len / 3 + 4); - - /* Encode 3 bytes at a time */ - while (len >= 3) { - buf[0] = alphabet[(data[0] >> 2) & 0x3F]; - buf[1] = alphabet[((data[0] << 4) & 0x30) | ((data[1] >> 4) & 0x0F)]; - buf[2] = alphabet[((data[1] << 2) & 0x3C) | ((data[2] >> 6) & 0x03)]; - buf[3] = alphabet[data[2] & 0x3F]; - data += 3; - buf += 4; - len -= 3; - } - - if (len > 0) { - buf[0] = alphabet[(data[0] >> 2) & 0x3F]; - buf[1] = alphabet[(data[0] << 4) & 0x30]; - - if (len > 1) { - buf[1] += (data[1] >> 4) & 0x0F; - buf[2] = alphabet[(data[1] << 2) & 0x3C]; - } - - else - buf[2] = '='; - - buf[3] = '='; - buf += 4; - } - - *buf = '\0'; - - return dest; -} - - static int trepia_write(int fd, const char *data, size_t len) { @@ -933,7 +892,7 @@ char *icon; int icon_len; - frombase64(value, &icon, &icon_len); + gaim_base64_decode(value, &icon, &icon_len); set_icon_data(session->gc, username, icon, icon_len); @@ -1250,7 +1209,7 @@ buf[sb.st_size] = '\0'; - temp = base64_enc(buf, sb.st_size); + temp = gaim_base64_encode(buf, sb.st_size); out_buf = g_strdup_printf("<K><m>%s</m></K>", temp);
--- a/src/proxy.c Wed Oct 01 05:43:14 2003 +0000 +++ b/src/proxy.c Wed Oct 01 05:56:58 2003 +0000 @@ -1032,7 +1032,7 @@ gaim_proxy_info_get_username(phb->gpi), gaim_proxy_info_get_password(phb->gpi) ? gaim_proxy_info_get_password(phb->gpi) : ""); - t2 = tobase64(t1, strlen(t1)); + t2 = gaim_base64_encode(t1, strlen(t1)); g_free(t1); g_return_if_fail(request_len < sizeof(request)); request_len += g_snprintf(request + request_len,
--- a/src/util.c Wed Oct 01 05:43:14 2003 +0000 +++ b/src/util.c Wed Oct 01 05:56:58 2003 +0000 @@ -351,7 +351,7 @@ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" "0123456789+/"; -char *tobase64(const unsigned char *in, size_t inlen) +char *gaim_base64_encode(const unsigned char *in, size_t inlen) { char *out, *rv; @@ -383,7 +383,7 @@ } -void frombase64(const char *text, char **data, int *size) +void gaim_base64_decode(const char *text, char **data, int *size) { char *out = NULL; char tmp = 0; @@ -451,7 +451,7 @@ /* * Converts raw data to a pretty, null-terminated base16 string. */ -unsigned char *tobase16(const unsigned char *data, int length) +unsigned char *gaim_base16_encode(const unsigned char *data, int length) { int i; unsigned char *ascii = NULL; @@ -470,7 +470,7 @@ /* * Converts a null-terminated string of hexidecimal to raw data. */ -int frombase16(const char *ascii, unsigned char **raw) +int gaim_base16_decode(const char *ascii, unsigned char **raw) { int len, i, accumulator=0; unsigned char *data;
--- a/src/util.h Wed Oct 01 05:43:14 2003 +0000 +++ b/src/util.h Wed Oct 01 05:56:58 2003 +0000 @@ -58,7 +58,7 @@ * * @see frombase64() */ -char *tobase64(const unsigned char *buf, size_t len); +char *gaim_base64_encode(const unsigned char *buf, size_t len); /** * Converts a string back from its base-64 equivalent. @@ -69,7 +69,7 @@ * * @see tobase64() */ -void frombase64(const char *str, char **ret_str, int *ret_len); +void gaim_base64_decode(const char *str, char **ret_str, int *ret_len); /** * Converts a string to its base-16 equivalent. @@ -81,7 +81,7 @@ * * @see frombase16() */ -unsigned char *tobase16(const unsigned char *str, int len); +unsigned char *gaim_base16_encode(const unsigned char *str, int len); /** * Converts a string back from its base-16 equivalent. @@ -93,7 +93,7 @@ * * @see tobase16() */ -int frombase16(const char *str, unsigned char **ret_str); +int gaim_base16_decode(const char *str, unsigned char **ret_str); /** * Waits for all child processes to terminate.