Mercurial > pidgin
diff src/util.h @ 11127:719779387f96
[gaim-migrate @ 13183]
Change the base16 and base64 functions to use better data types,
and make appropriate changes to other parts of the Gaim code
to get rid of a few warnings and hopefully make things more
correct.
In other news, why is CVS HEAD crashing for me on exit?
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Tue, 19 Jul 2005 05:15:45 +0000 |
parents | 6240d7fd5b2c |
children | a4611130e3eb |
line wrap: on
line diff
--- a/src/util.h Tue Jul 19 03:51:54 2005 +0000 +++ b/src/util.h Tue Jul 19 05:15:45 2005 +0000 @@ -43,28 +43,34 @@ /*@{*/ /** - * Converts a string to its base-16 equivalent. + * Converts a chunk of binary data to its base-16 equivalent. * - * @param str The string to convert. - * @param len The length of the string. + * @param data The data to convert. + * @param len The length of the data. * - * @return The base-16 string. + * @return The base-16 string in the ASCII encoding. Must be + * g_free'd when no longer needed. * * @see gaim_base16_decode() */ -unsigned char *gaim_base16_encode(const unsigned char *str, int len); +gchar *gaim_base16_encode(const guint8 *data, gsize len); /** - * Converts a string back from its base-16 equivalent. + * Converts an ASCII string of base-16 encoded data to + * the binary equivalent. * - * @param str The string to convert back. - * @param ret_str The returned, non-base-16 string. + * @param str The base-16 string to convert to raw data. + * @param ret_len The length of the returned data. You can + * pass in NULL if you're sure that you know + * the length of the decoded data, or if you + * know you'll be able to use strlen to + * determine the length, etc. * - * @return The length of the returned string. + * @return The raw data. Must be g_free'd when no longer needed. * * @see gaim_base16_encode() */ -int gaim_base16_decode(const char *str, unsigned char **ret_str); +guint8 *gaim_base16_decode(const char *str, gsize *ret_len); /*@}*/ @@ -75,27 +81,34 @@ /*@{*/ /** - * Converts a string to its base-64 equivalent. + * Converts a chunk of binary data to its base-64 equivalent. * - * @param buf The data to convert. - * @param len The length of the data. + * @param data The data to convert. + * @param len The length of the data. * - * @return The base-64 version of @a str. + * @return The base-64 string in the ASCII encoding. Must be + * g_free'd when no longer needed. * * @see gaim_base64_decode() */ -unsigned char *gaim_base64_encode(const unsigned char *buf, size_t len); +gchar *gaim_base64_encode(const guint8 *data, gsize len); /** - * Converts a string back from its base-64 equivalent. + * Converts an ASCII string of base-64 encoded data to + * the binary equivalent. * - * @param str The string to convert back. - * @param ret_str The returned, non-base-64 string. - * @param ret_len The returned string length. + * @param str The base-64 string to convert to raw data. + * @param ret_len The length of the returned data. You can + * pass in NULL if you're sure that you know + * the length of the decoded data, or if you + * know you'll be able to use strlen to + * determine the length, etc. + * + * @return The raw data. Must be g_free'd when no longer needed. * * @see gaim_base64_encode() */ -void gaim_base64_decode(const char *str, char **ret_str, int *ret_len); +guint8 *gaim_base64_decode(const char *str, gsize *ret_len); /*@}*/