comparison 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
comparison
equal deleted inserted replaced
11126:2a3568cbd8a6 11127:719779387f96
41 /** @name Base16 Functions */ 41 /** @name Base16 Functions */
42 /**************************************************************************/ 42 /**************************************************************************/
43 /*@{*/ 43 /*@{*/
44 44
45 /** 45 /**
46 * Converts a string to its base-16 equivalent. 46 * Converts a chunk of binary data to its base-16 equivalent.
47 * 47 *
48 * @param str The string to convert. 48 * @param data The data to convert.
49 * @param len The length of the string. 49 * @param len The length of the data.
50 * 50 *
51 * @return The base-16 string. 51 * @return The base-16 string in the ASCII encoding. Must be
52 * g_free'd when no longer needed.
52 * 53 *
53 * @see gaim_base16_decode() 54 * @see gaim_base16_decode()
54 */ 55 */
55 unsigned char *gaim_base16_encode(const unsigned char *str, int len); 56 gchar *gaim_base16_encode(const guint8 *data, gsize len);
56 57
57 /** 58 /**
58 * Converts a string back from its base-16 equivalent. 59 * Converts an ASCII string of base-16 encoded data to
59 * 60 * the binary equivalent.
60 * @param str The string to convert back. 61 *
61 * @param ret_str The returned, non-base-16 string. 62 * @param str The base-16 string to convert to raw data.
62 * 63 * @param ret_len The length of the returned data. You can
63 * @return The length of the returned string. 64 * pass in NULL if you're sure that you know
65 * the length of the decoded data, or if you
66 * know you'll be able to use strlen to
67 * determine the length, etc.
68 *
69 * @return The raw data. Must be g_free'd when no longer needed.
64 * 70 *
65 * @see gaim_base16_encode() 71 * @see gaim_base16_encode()
66 */ 72 */
67 int gaim_base16_decode(const char *str, unsigned char **ret_str); 73 guint8 *gaim_base16_decode(const char *str, gsize *ret_len);
68 74
69 /*@}*/ 75 /*@}*/
70 76
71 77
72 /**************************************************************************/ 78 /**************************************************************************/
73 /** @name Base64 Functions */ 79 /** @name Base64 Functions */
74 /**************************************************************************/ 80 /**************************************************************************/
75 /*@{*/ 81 /*@{*/
76 82
77 /** 83 /**
78 * Converts a string to its base-64 equivalent. 84 * Converts a chunk of binary data to its base-64 equivalent.
79 * 85 *
80 * @param buf The data to convert. 86 * @param data The data to convert.
81 * @param len The length of the data. 87 * @param len The length of the data.
82 * 88 *
83 * @return The base-64 version of @a str. 89 * @return The base-64 string in the ASCII encoding. Must be
90 * g_free'd when no longer needed.
84 * 91 *
85 * @see gaim_base64_decode() 92 * @see gaim_base64_decode()
86 */ 93 */
87 unsigned char *gaim_base64_encode(const unsigned char *buf, size_t len); 94 gchar *gaim_base64_encode(const guint8 *data, gsize len);
88 95
89 /** 96 /**
90 * Converts a string back from its base-64 equivalent. 97 * Converts an ASCII string of base-64 encoded data to
91 * 98 * the binary equivalent.
92 * @param str The string to convert back. 99 *
93 * @param ret_str The returned, non-base-64 string. 100 * @param str The base-64 string to convert to raw data.
94 * @param ret_len The returned string length. 101 * @param ret_len The length of the returned data. You can
102 * pass in NULL if you're sure that you know
103 * the length of the decoded data, or if you
104 * know you'll be able to use strlen to
105 * determine the length, etc.
106 *
107 * @return The raw data. Must be g_free'd when no longer needed.
95 * 108 *
96 * @see gaim_base64_encode() 109 * @see gaim_base64_encode()
97 */ 110 */
98 void gaim_base64_decode(const char *str, char **ret_str, int *ret_len); 111 guint8 *gaim_base64_decode(const char *str, gsize *ret_len);
99 112
100 /*@}*/ 113 /*@}*/
101 114
102 /**************************************************************************/ 115 /**************************************************************************/
103 /** @name Quoted Printable Functions */ 116 /** @name Quoted Printable Functions */