Mercurial > pidgin.yaz
annotate src/util.h @ 8401:c13a4913a071
[gaim-migrate @ 9130]
better error processing for jabber
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Fri, 05 Mar 2004 23:42:34 +0000 |
parents | fec4c1fb2ac8 |
children | 33cc36f5a7a6 |
rev | line source |
---|---|
4890 | 1 /** |
2 * @file util.h Utility Functions | |
5034
4691c5936c01
[gaim-migrate @ 5377]
Christian Hammond <chipx86@chipx86.com>
parents:
4890
diff
changeset
|
3 * @ingroup core |
4890 | 4 * |
5 * gaim | |
6 * | |
8046 | 7 * Gaim is the legal property of its developers, whose names are too numerous |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
7094
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
10 * |
4890 | 11 * This program is free software; you can redistribute it and/or modify |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 * | |
25 * @todo Rename the functions so that they live somewhere in the gaim | |
26 * namespace. | |
27 */ | |
28 #ifndef _GAIM_UTIL_H_ | |
29 #define _GAIM_UTIL_H_ | |
30 | |
6474
2fed50891afa
[gaim-migrate @ 6983]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
31 #include <stdio.h> |
2fed50891afa
[gaim-migrate @ 6983]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
32 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5532
diff
changeset
|
33 #include "account.h" |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5532
diff
changeset
|
34 |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
35 #ifdef __cplusplus |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
36 extern "C" { |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
37 #endif |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
38 |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
39 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
40 /** @name Base16 Functions */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
41 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
42 /*@{*/ |
4890 | 43 |
44 /** | |
45 * Converts a string to its base-16 equivalent. | |
46 * | |
47 * @param str The string to convert. | |
48 * @param len The length of the string. | |
49 * | |
50 * @return The base-16 string. | |
51 * | |
7123
d40966338ea6
[gaim-migrate @ 7690]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
52 * @see gaim_base16_decode() |
4890 | 53 */ |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7105
diff
changeset
|
54 unsigned char *gaim_base16_encode(const unsigned char *str, int len); |
4890 | 55 |
56 /** | |
57 * Converts a string back from its base-16 equivalent. | |
58 * | |
59 * @param str The string to convert back. | |
60 * @param ret_str The returned, non-base-16 string. | |
5451 | 61 * |
4890 | 62 * @return The length of the returned string. |
63 * | |
7123
d40966338ea6
[gaim-migrate @ 7690]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
64 * @see gaim_base16_encode() |
4890 | 65 */ |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7105
diff
changeset
|
66 int gaim_base16_decode(const char *str, unsigned char **ret_str); |
4890 | 67 |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
68 /*@}*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
69 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
70 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
71 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
72 /** @name Base64 Functions */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
73 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
74 /*@{*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
75 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
76 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
77 * Converts a string to its base-64 equivalent. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
78 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
79 * @param buf The data to convert. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
80 * @param len The length of the data. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
81 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
82 * @return The base-64 version of @a str. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
83 * |
7123
d40966338ea6
[gaim-migrate @ 7690]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
84 * @see gaim_base64_decode() |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
85 */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
86 unsigned char *gaim_base64_encode(const unsigned char *buf, size_t len); |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
87 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
88 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
89 * Converts a string back from its base-64 equivalent. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
90 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
91 * @param str The string to convert back. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
92 * @param ret_str The returned, non-base-64 string. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
93 * @param ret_len The returned string length. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
94 * |
7123
d40966338ea6
[gaim-migrate @ 7690]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
95 * @see gaim_base64_encode() |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
96 */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
97 void gaim_base64_decode(const char *str, char **ret_str, int *ret_len); |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
98 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
99 /*@}*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
100 |
7679 | 101 /**************************************************************************/ |
102 /** @name Quoted Printable Functions */ | |
103 /**************************************************************************/ | |
104 /*@{*/ | |
105 | |
106 /** | |
107 * Converts a quoted printable string back to its readable equivalent. | |
108 * | |
109 * @param str The string to convert back. | |
110 * @param ret_str The returned, readable string. | |
111 * @param ret_len The returned string length. | |
112 */ | |
113 void gaim_quotedp_decode (const char *str, char **ret_str, int *ret_len); | |
114 | |
115 /*@}*/ | |
116 | |
117 /**************************************************************************/ | |
118 /** @name MIME Functions */ | |
119 /**************************************************************************/ | |
120 /*@{*/ | |
121 | |
122 /** | |
123 * Converts a MIME header field string back to its readable equivalent | |
7821 | 124 * according to RFC 2047. Basically, a header is plain ASCII and can |
125 * contain any number of sections called "encoded-words." The format | |
126 * of an encoded word is =?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= | |
127 * =? designates the beginning of the encoded-word | |
128 * ?= designates the end of the encoded-word | |
129 * ? segments the encoded word into three pieces. The first piece is | |
130 * the character set, the second peice is the encoding, and the | |
131 * third piece is the encoded text. | |
7679 | 132 * |
133 * @param str The string to convert back. | |
134 * | |
135 * @return The readble string. | |
136 */ | |
137 char *gaim_mime_decode_field (const char *str); | |
138 | |
139 /*@}*/ | |
140 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
141 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
142 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
143 /** @name Date/Time Functions */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
144 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
145 /*@{*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
146 |
4890 | 147 /** |
148 * Returns the current local time in hour:minute:second form. | |
149 * | |
150 * The returned string is stored in a static buffer, so the result | |
151 * should be g_strdup()'d if it's intended to be used for long. | |
152 * | |
153 * @return The current local time. | |
154 * | |
7123
d40966338ea6
[gaim-migrate @ 7690]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
155 * @see gaim_date_full() |
4890 | 156 */ |
7162 | 157 const char *gaim_date(void); |
4890 | 158 |
159 /** | |
160 * Returns the date and time in human-readable form. | |
161 * | |
162 * The returned string is stored in a static buffer, so the result | |
163 * should be g_strdup()'d if it's intended to be used for long. | |
164 * | |
165 * @return The date and time in human-readable form. | |
166 * | |
7123
d40966338ea6
[gaim-migrate @ 7690]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
167 * @see gaim_date() |
4890 | 168 */ |
7162 | 169 const char *gaim_date_full(void); |
4890 | 170 |
171 /** | |
172 * Builds a time_t from the supplied information. | |
173 * | |
174 * @param year The year. | |
175 * @param month The month. | |
176 * @param day The day. | |
177 * @param hour The hour. | |
178 * @param min The minute. | |
179 * @param sec The second. | |
180 * | |
181 * @return A time_t. | |
182 */ | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
183 time_t gaim_time_build(int year, int month, int day, int hour, |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
184 int min, int sec); |
4890 | 185 |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
186 /*@}*/ |
4890 | 187 |
188 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
189 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
190 /** @name Markup Functions */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
191 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
192 /*@{*/ |
5826 | 193 |
6982 | 194 /** |
7094
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
195 * Finds a HTML tag matching the given name. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
196 * |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
197 * This locates an HTML tag's start and end, and stores its attributes |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
198 * in a GData hash table. The names of the attributes are lower-cased |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
199 * in the hash table, and the name of the tag is case insensitive. |
6982 | 200 * |
201 * @param needle the name of the tag | |
202 * @param haystack the null-delimited string to search in | |
203 * @param start a pointer to the start of the tag if found | |
204 * @param end a pointer to the end of the tag if found | |
205 * @param attributes the attributes, if the tag was found | |
206 * @return TRUE if the tag was found | |
207 */ | |
7094
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
208 gboolean gaim_markup_find_tag(const char *needle, const char *haystack, |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
209 const char **start, const char **end, |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
210 GData **attributes); |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
211 |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
212 /** |
7095
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
213 * Extracts a field of data from HTML. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
214 * |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
215 * This is a scary function. See protocols/msn/msn.c and |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
216 * protocols/yahoo/yahoo.c for example usage. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
217 * |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
218 * @param str The string to parse. |
7675 | 219 * @param len The size of str. |
220 * @param dest The destination GString to append the new | |
7095
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
221 * field info to. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
222 * @param start_token The beginning token. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
223 * @param skip The number of characters to skip after the |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
224 * start token. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
225 * @param end_token The ending token. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
226 * @param check_value The value that the last character must meet. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
227 * @param no_value_token The token indicating no value is given. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
228 * @param display_name The short descriptive name to display for this token. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
229 * @param is_link TRUE if this should be a link, or FALSE otherwise. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
230 * @param link_prefix The prefix for the link. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
231 * |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
232 * @return TRUE if successful, or FALSE otherwise. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
233 */ |
7675 | 234 gboolean gaim_markup_extract_info_field(const char *str, int len, GString *dest, |
235 const char *start_token, int skip, | |
236 const char *end_token, char check_value, | |
237 const char *no_value_token, | |
238 const char *display_name, gboolean is_link, | |
239 const char *link_prefix); | |
7095
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
240 |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
241 /** |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
242 * Converts HTML markup to XHTML. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
243 * |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
244 * @param html The HTML markup. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
245 * @param dest_xhtml The destination XHTML output. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
246 * @param dest_plain The destination plain-text output. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
247 */ |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
248 void gaim_markup_html_to_xhtml(const char *html, char **dest_xhtml, |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
249 char **dest_plain); |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
250 |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
251 /** |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
252 * Strips HTML tags from a string. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
253 * |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
254 * @param str The string to strip HTML from. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
255 * |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
256 * @return The new string without HTML. This must be freed. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
257 */ |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
258 char *gaim_markup_strip_html(const char *str); |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
259 |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
260 /** |
7107
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
261 * Adds the necessary HTML code to turn URIs into HTML links in a string. |
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
262 * |
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
263 * @param str The string to linkify. |
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
264 * |
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
265 * @return The linkified text. |
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
266 */ |
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
267 char *gaim_markup_linkify(const char *str); |
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
268 |
8163 | 269 /** |
270 * Escapes HTML special characters to be displayed literally. | |
271 * For example '&' is replaced by "&" and so on | |
272 * | |
273 * @param html The string in which to escape any HTML special characters | |
274 * | |
275 * @return the text with HTML special characters escaped | |
276 */ | |
277 char *gaim_escape_html(const char *html); | |
278 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
279 /*@}*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
280 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
281 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
282 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
283 /** @name Path/Filename Functions */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
284 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
285 /*@{*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
286 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
287 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
288 * Returns the user's home directory. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
289 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
290 * @return The user's home directory. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
291 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
292 * @see gaim_user_dir() |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
293 */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
294 const gchar *gaim_home_dir(void); |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
295 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
296 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
297 * Returns the gaim settings directory in the user's home directory. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
298 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
299 * @return The gaim settings directory. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
300 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
301 * @see gaim_home_dir() |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
302 */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
303 char *gaim_user_dir(void); |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
304 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
305 /** |
7612 | 306 * Builds a complete path from the root, making any directories along |
307 * the path which do not already exist. | |
7622 | 308 * |
7612 | 309 * @param path The path you wish to create. Note that it must start |
310 * from the root or this function will fail. | |
311 * @param mode Unix-style permissions for this directory. | |
7622 | 312 * |
7612 | 313 * @return 0 for success, nonzero on any error. |
314 */ | |
7622 | 315 int gaim_build_dir(const char *path, int mode); |
7612 | 316 |
317 /** | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
318 * Creates a temporary file and returns a file pointer to it. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
319 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
320 * This is like mkstemp(), but returns a file pointer and uses a |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
321 * pre-set template. It uses the semantics of tempnam() for the |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
322 * directory to use and allocates the space for the file path. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
323 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
324 * The caller is responsible for closing the file and removing it when |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
325 * done, as well as freeing the space pointed to by @a path with |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
326 * g_free(). |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
327 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
328 * @param path The returned path to the temp file. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
329 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
330 * @return A file pointer to the temporary file, or @c NULL on failure. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
331 */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
332 FILE *gaim_mkstemp(char **path); |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
333 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
334 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
335 * Checks if the given program name is valid and executable. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
336 * |
7303
3ec38f08b0b2
[gaim-migrate @ 7887]
Christian Hammond <chipx86@chipx86.com>
parents:
7261
diff
changeset
|
337 * @param program The file name of the application. |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
338 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
339 * @return True if the program is runable. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
340 */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
341 gboolean gaim_program_is_valid(const char *program); |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
342 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
343 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
344 * Returns the IP address from a socket file descriptor. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
345 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
346 * @param fd The socket file descriptor. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
347 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
348 * @return The IP address, or @c NULL on error. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
349 */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
350 char *gaim_fd_get_ip(int fd); |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
351 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
352 /*@}*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
353 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
354 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
355 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
356 /** @name String Functions */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
357 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
358 /*@{*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
359 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
360 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
361 * Normalizes a string, so that it is suitable for comparison. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
362 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
363 * The returned string will point to a static buffer, so if the |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
364 * string is intended to be kept long-term, you <i>must</i> |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
365 * g_strdup() it. Also, calling normalize() twice in the same line |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
366 * will lead to problems. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
367 * |
7261 | 368 * @param account The account the string belongs to. |
369 * @param str The string to normalize. | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
370 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
371 * @return A pointer to the normalized version stored in a static buffer. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
372 */ |
7261 | 373 const char *gaim_normalize(const GaimAccount *account, const char *str); |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
374 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
375 /** |
7628 | 376 * Compares two strings to see if the first contains the second as |
377 * a proper prefix. | |
378 * | |
379 * @param s The string to check. | |
380 * @param p The prefix in question. | |
381 * | |
382 * @return TRUE if p is a prefix of s, otherwise FALSE. | |
383 */ | |
384 gboolean gaim_str_has_prefix(const char *s, const char *p); | |
385 | |
386 /** | |
387 * Compares two strings to see if the second is a proper suffix | |
388 * of the first. | |
389 * | |
390 * @param s The string to check. | |
391 * @param x The suffix in question. | |
392 * | |
393 * @return TRUE if x is a a suffix of s, otherwise FALSE. | |
394 */ | |
395 gboolean gaim_str_has_suffix(const char *s, const char *x); | |
396 | |
397 /** | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
398 * Looks for %n, %d, or %t in a string, and replaces them with the |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
399 * specified name, date, and time, respectively. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
400 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
401 * The returned string is stored in a static buffer, so the result |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
402 * should be g_strdup()'d if it's intended to be used for long. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
403 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
404 * @param str The string that may contain the special variables. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
405 * @param name The sender name. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
406 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
407 * @return A new string where the special variables are expanded. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
408 */ |
7162 | 409 const char *gaim_str_sub_away_formatters(const char *str, const char *name); |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
410 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
411 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
412 * Duplicates a string and replaces all newline characters from the |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
413 * source string with HTML linebreaks. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
414 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
415 * @param src The source string. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
416 * |
8341 | 417 * @return The new string. Must be g_free'd by the caller. |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
418 */ |
8341 | 419 gchar *gaim_strdup_withhtml(const gchar *src); |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
420 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
421 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
422 * Ensures that all linefeeds have a matching carriage return. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
423 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
424 * @param str The source string. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
425 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
426 * @return The string with carriage returns. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
427 */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
428 char *gaim_str_add_cr(const char *str); |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
429 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
430 /** |
7478
3c21f3084ff0
[gaim-migrate @ 8091]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7303
diff
changeset
|
431 * Strips all carriage returns from a string. |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
432 * |
7478
3c21f3084ff0
[gaim-migrate @ 8091]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7303
diff
changeset
|
433 * @param str The string to strip carriage returns from. |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
434 */ |
7478
3c21f3084ff0
[gaim-migrate @ 8091]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7303
diff
changeset
|
435 void gaim_str_strip_cr(char *str); |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
436 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
437 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
438 * Given a string, this replaces one substring with another |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
439 * and returns a newly allocated string. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
440 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
441 * @param string The string from which to replace stuff. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
442 * @param delimiter The substring you want replaced. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
443 * @param replacement The substring you want inserted in place |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
444 * of the delimiting substring. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
445 */ |
8341 | 446 gchar *gaim_strreplace(const char *string, const char *delimiter, |
447 const char *replacement); | |
448 | |
449 /** | |
450 * Given a string, this replaces one substring with another | |
451 * ignoring case and returns a newly allocated string. | |
452 * | |
453 * @param string The string from which to replace stuff. | |
454 * @param delimiter The substring you want replaced. | |
455 * @param replacement The substring you want inserted in place | |
456 * of the delimiting substring. | |
457 */ | |
458 gchar *gaim_strcasereplace(const char *string, const char *delimiter, | |
459 const char *replacement); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
460 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
461 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
462 * This is like strstr, except that it ignores ASCII case in |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
463 * searching for the substring. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
464 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
465 * @param haystack The string to search in. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
466 * @param needle The substring to find. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
467 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
468 * @return the location of the substring if found, or NULL if not |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
469 */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
470 const char *gaim_strcasestr(const char *haystack, const char *needle); |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
471 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
472 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
473 * Returns a string representing a filesize in the appropriate |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
474 * units (MB, KB, GB, etc.) |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
475 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
476 * @param size The size |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
477 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
478 * @return The string in units form. This must be freed. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
479 */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
480 char *gaim_str_size_to_units(size_t size); |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
481 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
482 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
483 * Converts seconds into a human-readable form. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
484 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
485 * @param sec The seconds. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
486 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
487 * @return A human-readable form, containing days, hours, minutes, and |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
488 * seconds. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
489 */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
490 char *gaim_str_seconds_to_string(guint sec); |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
491 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
492 /*@}*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
493 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
494 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
495 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
496 /** @name URI/URL Functions */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
497 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
498 /*@{*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
499 |
7107
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
500 /** |
7094
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
501 * Parses a URL, returning its host, port, and file path. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
502 * |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
503 * The returned data must be freed. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
504 * |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
505 * @param url The URL to parse. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
506 * @param ret_host The returned host. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
507 * @param ret_port The returned port. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
508 * @param ret_path The returned path. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
509 */ |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
510 gboolean gaim_url_parse(const char *url, char **ret_host, int *ret_port, |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
511 char **ret_path); |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
512 |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
513 /** |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
514 * Fetches the data from a URL, and passes it to a callback function. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
515 * |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
516 * @param url The URL. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
517 * @param full TRUE if this is the full URL, or FALSE if it's a |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
518 * partial URL. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
519 * @param cb The callback function. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
520 * @param data The user data to pass to the callback function. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
521 * @param user_agent The user agent field to use, or NULL. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
522 * @param http11 TRUE if HTTP/1.1 should be used to download the file. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
523 */ |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
524 void gaim_url_fetch(const char *url, gboolean full, |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
525 const char *user_agent, gboolean http11, |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
526 void (*cb)(void *, const char *, size_t), |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
527 void *data); |
7134 | 528 /** |
529 * Decodes a URL into a plain string. | |
530 * | |
531 * This will change hex codes and such to their ascii equivalents. | |
532 * | |
533 * @param str The string to translate. | |
534 * | |
535 * @return The resulting string. | |
7162 | 536 */ |
537 const char *gaim_url_decode(const char *str); | |
7134 | 538 |
539 /** | |
540 * Encodes a URL into an escaped string. | |
541 * | |
542 * This will change non-alphanumeric characters to hex codes. | |
543 * | |
544 * @param str The string to translate. | |
545 * | |
546 * @return The resulting string. | |
547 */ | |
7162 | 548 const char *gaim_url_encode(const char *str); |
6982 | 549 |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
550 /*@}*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
551 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
552 /************************************************************************** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
553 * UTF8 String Functions |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
554 **************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
555 /*@{*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
556 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
557 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
558 * Attempts to convert a string to UTF-8 from an unknown encoding. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
559 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
560 * This function checks the locale and tries sane defaults. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
561 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
562 * @param str The source string. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
563 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
564 * @return The UTF-8 string, or @c NULL if it could not be converted. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
565 */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
566 char *gaim_utf8_try_convert(const char *str); |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
567 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
568 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
569 * Compares two UTF-8 strings. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
570 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
571 * @param a The first string. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
572 * @param b The second string. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
573 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
574 * @return -1 if @a is less than @a b. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
575 * 0 if @a is equal to @a b. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
576 * 1 if @a is greater than @a b. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
577 */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
578 int gaim_utf8_strcasecmp(const char *a, const char *b); |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
579 |
7564 | 580 /** |
581 * Checks for messages starting with "/me " | |
582 * | |
583 * @param message The message to check | |
584 * @param len The message length, or -1 | |
585 * | |
586 * @return TRUE if it starts with /me, and it has been removed, otherwise FALSE | |
587 */ | |
588 gboolean gaim_message_meify(char *message, size_t len); | |
589 | |
7889 | 590 /** |
591 * Removes the underscore characters from a string used identify the mnemonic | |
592 * character. | |
593 * | |
594 * @param in The string to strip | |
595 * | |
596 * @return The stripped string | |
597 */ | |
598 char * gaim_text_strip_mnemonic(const char *in); | |
599 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
600 /*@}*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
601 |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
602 #ifdef __cplusplus |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
603 } |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
604 #endif |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
605 |
4890 | 606 #endif /* _GAIM_UTIL_H_ */ |