Mercurial > pidgin
comparison src/util.c @ 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 |
comparison
equal
deleted
inserted
replaced
| 7105:9d0e74b6ca68 | 7106:db6bd3e794d8 |
|---|---|
| 349 | 349 |
| 350 static const char alphabet[] = | 350 static const char alphabet[] = |
| 351 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" | 351 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" |
| 352 "0123456789+/"; | 352 "0123456789+/"; |
| 353 | 353 |
| 354 char *tobase64(const unsigned char *in, size_t inlen) | 354 char *gaim_base64_encode(const unsigned char *in, size_t inlen) |
| 355 { | 355 { |
| 356 char *out, *rv; | 356 char *out, *rv; |
| 357 | 357 |
| 358 rv = out = g_malloc((4 * (inlen + 1)) / 3 + 1); | 358 rv = out = g_malloc((4 * (inlen + 1)) / 3 + 1); |
| 359 | 359 |
| 381 | 381 |
| 382 return rv; | 382 return rv; |
| 383 } | 383 } |
| 384 | 384 |
| 385 | 385 |
| 386 void frombase64(const char *text, char **data, int *size) | 386 void gaim_base64_decode(const char *text, char **data, int *size) |
| 387 { | 387 { |
| 388 char *out = NULL; | 388 char *out = NULL; |
| 389 char tmp = 0; | 389 char tmp = 0; |
| 390 const char *c; | 390 const char *c; |
| 391 gint32 tmp2 = 0; | 391 gint32 tmp2 = 0; |
| 449 } | 449 } |
| 450 | 450 |
| 451 /* | 451 /* |
| 452 * Converts raw data to a pretty, null-terminated base16 string. | 452 * Converts raw data to a pretty, null-terminated base16 string. |
| 453 */ | 453 */ |
| 454 unsigned char *tobase16(const unsigned char *data, int length) | 454 unsigned char *gaim_base16_encode(const unsigned char *data, int length) |
| 455 { | 455 { |
| 456 int i; | 456 int i; |
| 457 unsigned char *ascii = NULL; | 457 unsigned char *ascii = NULL; |
| 458 | 458 |
| 459 if (!data || !length) | 459 if (!data || !length) |
| 468 } | 468 } |
| 469 | 469 |
| 470 /* | 470 /* |
| 471 * Converts a null-terminated string of hexidecimal to raw data. | 471 * Converts a null-terminated string of hexidecimal to raw data. |
| 472 */ | 472 */ |
| 473 int frombase16(const char *ascii, unsigned char **raw) | 473 int gaim_base16_decode(const char *ascii, unsigned char **raw) |
| 474 { | 474 { |
| 475 int len, i, accumulator=0; | 475 int len, i, accumulator=0; |
| 476 unsigned char *data; | 476 unsigned char *data; |
| 477 | 477 |
| 478 if (!ascii || !(len = strlen(ascii)) || (len % 2)) | 478 if (!ascii || !(len = strlen(ascii)) || (len % 2)) |
