Mercurial > pidgin
annotate src/util.h @ 12502:9c562c0316d8
[gaim-migrate @ 14814]
I hate autotools
committer: Tailor Script <tailor@pidgin.im>
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Fri, 16 Dec 2005 18:37:08 +0000 |
parents | 54448bd2ccc7 |
children | 547c199072c8 |
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" |
10425 | 34 #include "xmlnode.h" |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5532
diff
changeset
|
35 |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
36 #ifdef __cplusplus |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
37 extern "C" { |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
38 #endif |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
39 |
12106 | 40 |
41 /** | |
42 * A key-value pair. | |
43 * | |
44 * This is used by, among other things, gaim_gtk_combo* functions to pass in a | |
45 * list of key-value pairs so it can display a user-friendly value. | |
46 */ | |
47 typedef struct _GaimKeyValuePair | |
48 { | |
49 gchar *key; | |
50 void *value; | |
51 | |
52 } GaimKeyValuePair; | |
53 | |
54 | |
55 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
56 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
57 /** @name Base16 Functions */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
58 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
59 /*@{*/ |
4890 | 60 |
61 /** | |
11127 | 62 * Converts a chunk of binary data to its base-16 equivalent. |
4890 | 63 * |
11127 | 64 * @param data The data to convert. |
65 * @param len The length of the data. | |
4890 | 66 * |
11127 | 67 * @return The base-16 string in the ASCII encoding. Must be |
68 * g_free'd when no longer needed. | |
4890 | 69 * |
7123
d40966338ea6
[gaim-migrate @ 7690]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
70 * @see gaim_base16_decode() |
4890 | 71 */ |
11137 | 72 gchar *gaim_base16_encode(const guchar *data, gsize len); |
4890 | 73 |
74 /** | |
11127 | 75 * Converts an ASCII string of base-16 encoded data to |
76 * the binary equivalent. | |
4890 | 77 * |
11127 | 78 * @param str The base-16 string to convert to raw data. |
79 * @param ret_len The length of the returned data. You can | |
80 * pass in NULL if you're sure that you know | |
81 * the length of the decoded data, or if you | |
82 * know you'll be able to use strlen to | |
83 * determine the length, etc. | |
5451 | 84 * |
11127 | 85 * @return The raw data. Must be g_free'd when no longer needed. |
4890 | 86 * |
7123
d40966338ea6
[gaim-migrate @ 7690]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
87 * @see gaim_base16_encode() |
4890 | 88 */ |
11137 | 89 guchar *gaim_base16_decode(const char *str, gsize *ret_len); |
4890 | 90 |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
91 /*@}*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
92 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
93 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
94 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
95 /** @name Base64 Functions */ |
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 /*@{*/ |
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 /** |
11127 | 100 * Converts a chunk of binary data to its base-64 equivalent. |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
101 * |
11127 | 102 * @param data The data to convert. |
103 * @param len The length of the data. | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
104 * |
11127 | 105 * @return The base-64 string in the ASCII encoding. Must be |
106 * g_free'd when no longer needed. | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
107 * |
7123
d40966338ea6
[gaim-migrate @ 7690]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
108 * @see gaim_base64_decode() |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
109 */ |
11137 | 110 gchar *gaim_base64_encode(const guchar *data, gsize len); |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
111 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
112 /** |
11127 | 113 * Converts an ASCII string of base-64 encoded data to |
114 * the binary equivalent. | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
115 * |
11127 | 116 * @param str The base-64 string to convert to raw data. |
117 * @param ret_len The length of the returned data. You can | |
118 * pass in NULL if you're sure that you know | |
119 * the length of the decoded data, or if you | |
120 * know you'll be able to use strlen to | |
121 * determine the length, etc. | |
122 * | |
123 * @return The raw data. Must be g_free'd when no longer needed. | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
124 * |
7123
d40966338ea6
[gaim-migrate @ 7690]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
125 * @see gaim_base64_encode() |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
126 */ |
11137 | 127 guchar *gaim_base64_decode(const char *str, gsize *ret_len); |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
128 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
129 /*@}*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
130 |
7679 | 131 /**************************************************************************/ |
132 /** @name Quoted Printable Functions */ | |
133 /**************************************************************************/ | |
134 /*@{*/ | |
135 | |
136 /** | |
137 * Converts a quoted printable string back to its readable equivalent. | |
11132 | 138 * What is a quoted printable string, you ask? It's an encoding used |
139 * to transmit binary data as ASCII. It's intended purpose is to send | |
140 * e-mails containing non-ASCII characters. Wikipedia has a pretty good | |
141 * explanation. Also see RFC 2045. | |
7679 | 142 * |
11132 | 143 * @param str The quoted printable ASCII string to convert to raw data. |
11501
9563b768e8e2
[gaim-migrate @ 13746]
Richard Laager <rlaager@wiktel.com>
parents:
11153
diff
changeset
|
144 * @param ret_len The length of the returned data. |
11132 | 145 * |
11501
9563b768e8e2
[gaim-migrate @ 13746]
Richard Laager <rlaager@wiktel.com>
parents:
11153
diff
changeset
|
146 * @return The readable string. Must be g_free'd when no longer needed. |
7679 | 147 */ |
11137 | 148 guchar *gaim_quotedp_decode(const char *str, gsize *ret_len); |
7679 | 149 |
150 /*@}*/ | |
151 | |
152 /**************************************************************************/ | |
153 /** @name MIME Functions */ | |
154 /**************************************************************************/ | |
155 /*@{*/ | |
156 | |
157 /** | |
158 * Converts a MIME header field string back to its readable equivalent | |
8432
33cc36f5a7a6
[gaim-migrate @ 9162]
Christian Hammond <chipx86@chipx86.com>
parents:
8341
diff
changeset
|
159 * according to RFC 2047. Basically, a header is plain ASCII and can |
33cc36f5a7a6
[gaim-migrate @ 9162]
Christian Hammond <chipx86@chipx86.com>
parents:
8341
diff
changeset
|
160 * contain any number of sections called "encoded-words." The format |
7821 | 161 * of an encoded word is =?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= |
162 * =? designates the beginning of the encoded-word | |
163 * ?= designates the end of the encoded-word | |
11135 | 164 * |
165 * An encoded word is segmented into three pieces by the use of a | |
166 * question mark. The first piece is the character set, the second | |
167 * piece is the encoding, and the third piece is the encoded text. | |
7679 | 168 * |
11135 | 169 * @param str The ASCII string, possibly containing any number of |
170 * encoded-word sections. | |
7679 | 171 * |
11135 | 172 * @return The string, with any encoded-word sections decoded and |
173 * converted to UTF-8. Must be g_free'd when no longer | |
174 * needed. | |
7679 | 175 */ |
11135 | 176 char *gaim_mime_decode_field(const char *str); |
7679 | 177 |
178 /*@}*/ | |
179 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
180 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
181 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
182 /** @name Date/Time Functions */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
183 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
184 /*@{*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
185 |
4890 | 186 /** |
187 * Returns the current local time in hour:minute:second form. | |
188 * | |
189 * The returned string is stored in a static buffer, so the result | |
190 * should be g_strdup()'d if it's intended to be used for long. | |
191 * | |
192 * @return The current local time. | |
193 * | |
7123
d40966338ea6
[gaim-migrate @ 7690]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
194 * @see gaim_date_full() |
4890 | 195 */ |
7162 | 196 const char *gaim_date(void); |
4890 | 197 |
198 /** | |
199 * Returns the date and time in human-readable form. | |
200 * | |
201 * The returned string is stored in a static buffer, so the result | |
202 * should be g_strdup()'d if it's intended to be used for long. | |
203 * | |
204 * @return The date and time in human-readable form. | |
205 * | |
7123
d40966338ea6
[gaim-migrate @ 7690]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
206 * @see gaim_date() |
4890 | 207 */ |
7162 | 208 const char *gaim_date_full(void); |
4890 | 209 |
210 /** | |
211 * Builds a time_t from the supplied information. | |
212 * | |
213 * @param year The year. | |
214 * @param month The month. | |
215 * @param day The day. | |
216 * @param hour The hour. | |
217 * @param min The minute. | |
218 * @param sec The second. | |
219 * | |
220 * @return A time_t. | |
221 */ | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
222 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
|
223 int min, int sec); |
4890 | 224 |
8577 | 225 /** |
226 * Parses a timestamp in jabber or ISO8601 format and returns a time_t. | |
227 * | |
228 * @param timestamp The timestamp | |
229 * @param utc Assume UTC if no timezone specified | |
230 * | |
231 * @return A time_t. | |
232 */ | |
233 time_t gaim_str_to_time(const char *timestamp, gboolean utc); | |
234 | |
10636 | 235 /** |
236 * Creates a string according to a time and format string | |
237 * | |
238 * This function just calls strftime. The only advantage to using it | |
239 * is that gcc won't give a warning if you use %c | |
11135 | 240 * |
241 * TODO: The warning is gone in gcc4, and this function can | |
242 * eventually be removed. | |
10636 | 243 */ |
244 size_t gaim_strftime(char *s, size_t max, const char *format, const struct tm *tm); | |
245 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
246 /*@}*/ |
4890 | 247 |
248 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
249 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
250 /** @name Markup Functions */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
251 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
252 /*@{*/ |
5826 | 253 |
6982 | 254 /** |
11135 | 255 * Finds an HTML tag matching the given name. |
7094
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
256 * |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
257 * 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
|
258 * 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
|
259 * in the hash table, and the name of the tag is case insensitive. |
6982 | 260 * |
261 * @param needle the name of the tag | |
262 * @param haystack the null-delimited string to search in | |
263 * @param start a pointer to the start of the tag if found | |
264 * @param end a pointer to the end of the tag if found | |
265 * @param attributes the attributes, if the tag was found | |
266 * @return TRUE if the tag was found | |
267 */ | |
7094
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
268 gboolean gaim_markup_find_tag(const char *needle, const char *haystack, |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
269 const char **start, const char **end, |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
270 GData **attributes); |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
271 |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
272 /** |
7095
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
273 * Extracts a field of data from HTML. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
274 * |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
275 * This is a scary function. See protocols/msn/msn.c and |
9175 | 276 * protocols/yahoo/yahoo_profile.c for example usage. |
7095
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
277 * |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
278 * @param str The string to parse. |
7675 | 279 * @param len The size of str. |
280 * @param dest The destination GString to append the new | |
7095
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
281 * field info to. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
282 * @param start_token The beginning token. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
283 * @param skip The number of characters to skip after the |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
284 * start token. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
285 * @param end_token The ending token. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
286 * @param check_value The value that the last character must meet. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
287 * @param no_value_token The token indicating no value is given. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
288 * @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
|
289 * @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
|
290 * @param link_prefix The prefix for the link. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
291 * |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
292 * @return TRUE if successful, or FALSE otherwise. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
293 */ |
7675 | 294 gboolean gaim_markup_extract_info_field(const char *str, int len, GString *dest, |
295 const char *start_token, int skip, | |
296 const char *end_token, char check_value, | |
297 const char *no_value_token, | |
298 const char *display_name, gboolean is_link, | |
299 const char *link_prefix); | |
7095
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
300 |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
301 /** |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
302 * Converts HTML markup to XHTML. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
303 * |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
304 * @param html The HTML markup. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
305 * @param dest_xhtml The destination XHTML output. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
306 * @param dest_plain The destination plain-text output. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
307 */ |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
308 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
|
309 char **dest_plain); |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
310 |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
311 /** |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
312 * Strips HTML tags from a string. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
313 * |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
314 * @param str The string to strip HTML from. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
315 * |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
316 * @return The new string without HTML. This must be freed. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
317 */ |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
318 char *gaim_markup_strip_html(const char *str); |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
319 |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
320 /** |
7107
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
321 * 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
|
322 * |
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
323 * @param str The string to linkify. |
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
324 * |
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
325 * @return The linkified text. |
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
326 */ |
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
327 char *gaim_markup_linkify(const char *str); |
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
328 |
8163 | 329 /** |
8442 | 330 * Unescapes HTML entities to their literal characters. |
331 * For example "&" is replaced by '&' and so on. | |
332 * Actually only "&", """, "<" and ">" are currently | |
333 * supported. | |
334 * | |
335 * @param html The string in which to unescape any HTML entities | |
336 * | |
337 * @return the text with HTML entities literalized | |
338 */ | |
339 char *gaim_unescape_html(const char *html); | |
340 | |
9175 | 341 /** |
342 * Returns a newly allocated substring of the HTML UTF-8 string "str". | |
343 * The markup is preserved such that the substring will have the same | |
344 * formatting as original string, even though some tags may have been | |
345 * opened before "x", or may close after "y". All open tags are closed | |
346 * at the end of the returned string, in the proper order. | |
347 * | |
348 * Note that x and y are in character offsets, not byte offsets, and | |
349 * are offsets into an unformatted version of str. Because of this, | |
350 * this function may be sensitive to changes in GtkIMHtml and may break | |
351 * when used with other UI's. libgaim users are encouraged to report and | |
352 * work out any problems encountered. | |
353 * | |
354 * @param str The input NUL terminated, HTML, UTF-8 (or ASCII) string. | |
355 * @param x The character offset into an unformatted version of str to | |
356 * begin at. | |
357 * @param y The character offset (into an unformatted vesion of str) of | |
358 * one past the last character to include in the slice. | |
359 * | |
360 * @return The HTML slice of string, with all formatting retained. | |
361 */ | |
362 char *gaim_markup_slice(const char *str, guint x, guint y); | |
363 | |
364 /** | |
365 * Returns a newly allocated string containing the name of the tag | |
366 * located at "tag". Tag is expected to point to a '<', and contain | |
367 * a '>' sometime after that. If there is no '>' and the string is | |
368 * not NUL terminated, this function can be expected to segfault. | |
369 * | |
370 * @param tag The string starting a HTML tag. | |
371 * @return A string containing the name of the tag. | |
372 */ | |
373 char *gaim_markup_get_tag_name(const char *tag); | |
374 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
375 /*@}*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
376 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
377 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
378 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
379 /** @name Path/Filename Functions */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
380 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
381 /*@{*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
382 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
383 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
384 * Returns the user's home directory. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
385 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
386 * @return The user's home directory. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
387 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
388 * @see gaim_user_dir() |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
389 */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
390 const gchar *gaim_home_dir(void); |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
391 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
392 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
393 * Returns the gaim settings directory in the user's home directory. |
10869 | 394 * This is usually ~/.gaim |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
395 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
396 * @return The gaim settings directory. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
397 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
398 * @see gaim_home_dir() |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
399 */ |
10332 | 400 const char *gaim_user_dir(void); |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
401 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
402 /** |
8596 | 403 * Define a custom gaim settings directory, overriding the default (user's home directory/.gaim) |
404 * @param dir The custom settings directory | |
405 */ | |
10871 | 406 void gaim_util_set_user_dir(const char *dir); |
8596 | 407 |
408 /** | |
7612 | 409 * Builds a complete path from the root, making any directories along |
410 * the path which do not already exist. | |
7622 | 411 * |
7612 | 412 * @param path The path you wish to create. Note that it must start |
413 * from the root or this function will fail. | |
414 * @param mode Unix-style permissions for this directory. | |
7622 | 415 * |
7612 | 416 * @return 0 for success, nonzero on any error. |
417 */ | |
7622 | 418 int gaim_build_dir(const char *path, int mode); |
7612 | 419 |
420 /** | |
10415 | 421 * Write a string of data to a file of the given name in the Gaim |
422 * user directory ($HOME/.gaim by default). The data is typically | |
423 * a serialized version of one of Gaim's config files, such as | |
424 * prefs.xml, accounts.xml, etc. And the string is typically | |
425 * obtained using xmlnode_to_formatted_str. However, this function | |
426 * should work fine for saving binary files as well. | |
10414 | 427 * |
428 * @param filename The basename of the file to write in the gaim_user_dir. | |
429 * @param data A null-terminated string of data to write. | |
10415 | 430 * @param size The size of the data to save. If data is |
431 * null-terminated you can pass in -1. | |
10414 | 432 * |
433 * @return TRUE if the file was written successfully. FALSE otherwise. | |
434 */ | |
10415 | 435 gboolean gaim_util_write_data_to_file(const char *filename, const char *data, |
436 size_t size); | |
10414 | 437 |
438 /** | |
10425 | 439 * Read the contents of a given file and parse the results into an |
440 * xmlnode tree structure. This is intended to be used to read | |
441 * Gaim's configuration xml files (prefs.xml, pounces.xml, etc.) | |
442 * | |
443 * @param filename The basename of the file to open in the gaim_user_dir. | |
444 * @param description A very short description of the contents of this | |
445 * file. This is used in error messages shown to the | |
446 * user when the file can not be opened. For example, | |
447 * "preferences," or "buddy pounces." | |
448 * | |
449 * @return An xmlnode tree of the contents of the given file. Or NULL, if | |
450 * the file does not exist or there was an error reading the file. | |
451 */ | |
452 xmlnode *gaim_util_read_xml_from_file(const char *filename, | |
453 const char *description); | |
454 | |
455 /** | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
456 * Creates a temporary file and returns a file pointer to it. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
457 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
458 * 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
|
459 * pre-set template. It uses the semantics of tempnam() for the |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
460 * directory to use and allocates the space for the file path. |
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 * 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
|
463 * 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
|
464 * g_free(). |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
465 * |
10203
7ff9b8b22e7d
[gaim-migrate @ 11324]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
9926
diff
changeset
|
466 * @param path The returned path to the temp file. |
7ff9b8b22e7d
[gaim-migrate @ 11324]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
9926
diff
changeset
|
467 * @param binary Text or binary, for platforms where it matters. |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
468 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
469 * @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
|
470 */ |
10203
7ff9b8b22e7d
[gaim-migrate @ 11324]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
9926
diff
changeset
|
471 FILE *gaim_mkstemp(char **path, gboolean binary); |
7108
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 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
474 * Checks if the given program name is valid and executable. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
475 * |
7303
3ec38f08b0b2
[gaim-migrate @ 7887]
Christian Hammond <chipx86@chipx86.com>
parents:
7261
diff
changeset
|
476 * @param program The file name of the application. |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
477 * |
12483
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12106
diff
changeset
|
478 * @return TRUE if the program is runable. |
7108
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 gboolean gaim_program_is_valid(const char *program); |
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 /** |
12483
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12106
diff
changeset
|
483 * Check if running GNOME. |
11878 | 484 * |
12483
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12106
diff
changeset
|
485 * @return TRUE if running GNOME, FALSE otherwise. |
11878 | 486 */ |
487 gboolean gaim_running_gnome(void); | |
488 | |
489 /** | |
12483
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12106
diff
changeset
|
490 * Check if running KDE. |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12106
diff
changeset
|
491 * |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12106
diff
changeset
|
492 * @return TRUE if running KDE, FALSE otherwise. |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12106
diff
changeset
|
493 */ |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12106
diff
changeset
|
494 gboolean gaim_running_kde(void); |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12106
diff
changeset
|
495 |
54448bd2ccc7
[gaim-migrate @ 14795]
Richard Laager <rlaager@wiktel.com>
parents:
12106
diff
changeset
|
496 /** |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
497 * Returns the IP address from a socket file descriptor. |
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 * @param fd The socket file descriptor. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
500 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
501 * @return The IP address, or @c NULL on error. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
502 */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
503 char *gaim_fd_get_ip(int fd); |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
504 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
505 /*@}*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
506 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
507 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
508 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
509 /** @name String Functions */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
510 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
511 /*@{*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
512 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
513 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
514 * Normalizes a string, so that it is suitable for comparison. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
515 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
516 * 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
|
517 * 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
|
518 * g_strdup() it. Also, calling normalize() twice in the same line |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
519 * will lead to problems. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
520 * |
10433 | 521 * @param account The account the string belongs to, or NULL if you do |
522 * not know the account. If you use NULL, the string | |
523 * will still be normalized, but if the PRPL uses a | |
524 * custom normalization function then the string may | |
525 * not be normalized correctly. | |
7261 | 526 * @param str The string to normalize. |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
527 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
528 * @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
|
529 */ |
7261 | 530 const char *gaim_normalize(const GaimAccount *account, const char *str); |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
531 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
532 /** |
11153 | 533 * Normalizes a string, so that it is suitable for comparison. |
534 * | |
535 * This is one possible implementation for the PRPL callback | |
536 * function "normalize." It returns a lowercase and UTF-8 | |
537 * normalized version of the string. | |
538 * | |
539 * @param account The account the string belongs to. | |
540 * @param str The string to normalize. | |
541 * | |
542 * @return A pointer to the normalized version stored in a static buffer. | |
543 */ | |
544 const char *gaim_normalize_nocase(const GaimAccount *account, const char *str); | |
545 | |
546 /** | |
7628 | 547 * Compares two strings to see if the first contains the second as |
548 * a proper prefix. | |
8432
33cc36f5a7a6
[gaim-migrate @ 9162]
Christian Hammond <chipx86@chipx86.com>
parents:
8341
diff
changeset
|
549 * |
7628 | 550 * @param s The string to check. |
551 * @param p The prefix in question. | |
8432
33cc36f5a7a6
[gaim-migrate @ 9162]
Christian Hammond <chipx86@chipx86.com>
parents:
8341
diff
changeset
|
552 * |
7628 | 553 * @return TRUE if p is a prefix of s, otherwise FALSE. |
554 */ | |
555 gboolean gaim_str_has_prefix(const char *s, const char *p); | |
556 | |
557 /** | |
558 * Compares two strings to see if the second is a proper suffix | |
559 * of the first. | |
8432
33cc36f5a7a6
[gaim-migrate @ 9162]
Christian Hammond <chipx86@chipx86.com>
parents:
8341
diff
changeset
|
560 * |
7628 | 561 * @param s The string to check. |
562 * @param x The suffix in question. | |
8432
33cc36f5a7a6
[gaim-migrate @ 9162]
Christian Hammond <chipx86@chipx86.com>
parents:
8341
diff
changeset
|
563 * |
7628 | 564 * @return TRUE if x is a a suffix of s, otherwise FALSE. |
565 */ | |
566 gboolean gaim_str_has_suffix(const char *s, const char *x); | |
567 | |
568 /** | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
569 * 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
|
570 * specified name, date, and time, respectively. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
571 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
572 * @param str The string that may contain the special variables. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
573 * @param name The sender name. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
574 * |
8700 | 575 * @return A newly allocated string where the special variables are |
576 * expanded. This should be g_free'd by the caller. | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
577 */ |
8700 | 578 gchar *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
|
579 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
580 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
581 * Duplicates a string and replaces all newline characters from the |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
582 * source string with HTML linebreaks. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
583 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
584 * @param src The source string. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
585 * |
8341 | 586 * @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
|
587 */ |
8341 | 588 gchar *gaim_strdup_withhtml(const gchar *src); |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
589 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
590 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
591 * Ensures that all linefeeds have a matching carriage return. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
592 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
593 * @param str The source string. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
594 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
595 * @return The string with carriage returns. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
596 */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
597 char *gaim_str_add_cr(const char *str); |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
598 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
599 /** |
11920 | 600 * Strips all instances of the given character from the |
601 * given string. The string is modified in place. This | |
602 * is useful for stripping new line characters, for example. | |
603 * | |
604 * Example usage: | |
605 * gaim_str_strip_char(my_dumb_string, '\n'); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
606 * |
11920 | 607 * @param str The string to strip characters from. |
608 * @param thechar The character to strip from the given string. | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
609 */ |
11920 | 610 void gaim_str_strip_char(char *str, char thechar); |
611 | |
612 /** | |
613 * Given a string, this replaces all instances of one character | |
614 * with another. This happens inline (the original string IS | |
615 * modified). | |
616 * | |
617 * @param string The string from which to replace stuff. | |
618 * @param delimiter The character you want replaced. | |
619 * @param replacement The character you want inserted in place | |
620 * of the delimiting character. | |
621 */ | |
622 void gaim_util_chrreplace(char *string, char delimiter, | |
623 char replacement); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
624 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
625 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
626 * Given a string, this replaces one substring with another |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
627 * and returns a newly allocated string. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
628 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
629 * @param string The string from which to replace stuff. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
630 * @param delimiter The substring you want replaced. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
631 * @param replacement The substring you want inserted in place |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
632 * of the delimiting substring. |
8461 | 633 * |
634 * @return A new string, after performing the substitution. | |
635 * free this with g_free(). | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
636 */ |
8341 | 637 gchar *gaim_strreplace(const char *string, const char *delimiter, |
638 const char *replacement); | |
639 | |
640 /** | |
9171 | 641 * Given a string, this replaces any numerical character references |
642 * in that string with the corresponding actual utf-8 substrings, | |
643 * and returns a newly allocated string. | |
644 * | |
645 * @param in The string which might contain numerical character references. | |
646 * | |
647 * @return A new string, with numerical character references | |
648 * replaced with actual utf-8, free this with g_free(). | |
649 */ | |
650 char *gaim_utf8_ncr_decode(const char *in); | |
651 | |
652 /** | |
8341 | 653 * Given a string, this replaces one substring with another |
654 * ignoring case and returns a newly allocated string. | |
655 * | |
656 * @param string The string from which to replace stuff. | |
657 * @param delimiter The substring you want replaced. | |
658 * @param replacement The substring you want inserted in place | |
659 * of the delimiting substring. | |
8461 | 660 * |
661 * @return A new string, after performing the substitution. | |
662 * free this with g_free(). | |
8341 | 663 */ |
664 gchar *gaim_strcasereplace(const char *string, const char *delimiter, | |
665 const char *replacement); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
666 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
667 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
668 * This is like strstr, except that it ignores ASCII case in |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
669 * searching for the substring. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
670 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
671 * @param haystack The string to search in. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
672 * @param needle The substring to find. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
673 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
674 * @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
|
675 */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
676 const char *gaim_strcasestr(const char *haystack, const char *needle); |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
677 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
678 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
679 * Returns a string representing a filesize in the appropriate |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
680 * units (MB, KB, GB, etc.) |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
681 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
682 * @param size The size |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
683 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
684 * @return The string in units form. This must be freed. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
685 */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
686 char *gaim_str_size_to_units(size_t size); |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
687 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
688 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
689 * Converts seconds into a human-readable form. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
690 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
691 * @param sec The seconds. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
692 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
693 * @return A human-readable form, containing days, hours, minutes, and |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
694 * seconds. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
695 */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
696 char *gaim_str_seconds_to_string(guint sec); |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
697 |
9277 | 698 /** |
699 * Converts a binary string into a NUL terminated ascii string, | |
700 * replacing nonascii characters and characters below SPACE (including | |
9307 | 701 * NUL) into \\xyy, where yy are two hex digits. Also backslashes are |
702 * changed into two backslashes (\\\\). The returned, newly allocated | |
703 * string can be outputted to the console, and must be g_free()d. | |
9277 | 704 * |
705 * @param binary A string of random data, possibly with embedded NULs | |
706 * and such. | |
707 * @param len The length in bytes of the input string. Must not be 0. | |
708 * | |
709 * @return A newly allocated ASCIIZ string. | |
710 */ | |
711 char *gaim_str_binary_to_ascii(const unsigned char *binary, guint len); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
712 /*@}*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
713 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
714 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
715 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
716 /** @name URI/URL Functions */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
717 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
718 /*@{*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
719 |
7107
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
720 /** |
9227
9171e528d7e5
[gaim-migrate @ 10023]
Christian Hammond <chipx86@chipx86.com>
parents:
9175
diff
changeset
|
721 * Parses a URL, returning its host, port, file path, username and password. |
7094
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
722 * |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
723 * The returned data must be freed. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
724 * |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
725 * @param url The URL to parse. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
726 * @param ret_host The returned host. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
727 * @param ret_port The returned port. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
728 * @param ret_path The returned path. |
9227
9171e528d7e5
[gaim-migrate @ 10023]
Christian Hammond <chipx86@chipx86.com>
parents:
9175
diff
changeset
|
729 * @param ret_user The returned username. |
9171e528d7e5
[gaim-migrate @ 10023]
Christian Hammond <chipx86@chipx86.com>
parents:
9175
diff
changeset
|
730 * @param ret_passwd The returned password. |
7094
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
731 */ |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
732 gboolean gaim_url_parse(const char *url, char **ret_host, int *ret_port, |
9227
9171e528d7e5
[gaim-migrate @ 10023]
Christian Hammond <chipx86@chipx86.com>
parents:
9175
diff
changeset
|
733 char **ret_path, char **ret_user, char **ret_passwd); |
7094
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
734 |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
735 /** |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
736 * 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
|
737 * |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
738 * @param url The URL. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
739 * @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
|
740 * partial URL. |
9284 | 741 * @param user_agent The user agent field to use, or NULL. |
742 * @param http11 TRUE if HTTP/1.1 should be used to download the file. | |
7094
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
743 * @param cb The callback function. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
744 * @param data The user data to pass to the callback function. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
745 */ |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
746 void gaim_url_fetch(const char *url, gboolean full, |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
747 const char *user_agent, gboolean http11, |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
748 void (*cb)(void *, const char *, size_t), |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
749 void *data); |
7134 | 750 /** |
751 * Decodes a URL into a plain string. | |
752 * | |
753 * This will change hex codes and such to their ascii equivalents. | |
754 * | |
755 * @param str The string to translate. | |
756 * | |
757 * @return The resulting string. | |
7162 | 758 */ |
759 const char *gaim_url_decode(const char *str); | |
7134 | 760 |
761 /** | |
762 * Encodes a URL into an escaped string. | |
763 * | |
764 * This will change non-alphanumeric characters to hex codes. | |
765 * | |
766 * @param str The string to translate. | |
767 * | |
768 * @return The resulting string. | |
769 */ | |
7162 | 770 const char *gaim_url_encode(const char *str); |
6982 | 771 |
9045 | 772 /** |
773 * Checks if the given email address is syntactically valid. | |
774 * | |
775 * @param address The email address to validate. | |
776 * | |
777 * @return True if the email address is syntactically correct. | |
778 */ | |
779 gboolean gaim_email_is_valid(const char *address); | |
780 | |
9670 | 781 /** |
11135 | 782 * This function extracts a list of URIs from the a "text/uri-list" |
783 * string. It was "borrowed" from gnome_uri_list_extract_uris | |
784 * | |
785 * @param uri_list An uri-list in the standard format. | |
9670 | 786 * |
11135 | 787 * @return A GList containing strings allocated with g_malloc |
788 * that have been splitted from uri-list. | |
9670 | 789 */ |
11135 | 790 GList *gaim_uri_list_extract_uris(const gchar *uri_list); |
9670 | 791 |
792 /** | |
11135 | 793 * This function extracts a list of filenames from a |
794 * "text/uri-list" string. It was "borrowed" from | |
795 * gnome_uri_list_extract_filenames | |
796 * | |
797 * @param uri_list A uri-list in the standard format. | |
9670 | 798 * |
11135 | 799 * @return A GList containing strings allocated with g_malloc that |
800 * contain the filenames in the uri-list. Note that unlike | |
801 * gaim_uri_list_extract_uris() function, this will discard | |
802 * any non-file uri from the result value. | |
9670 | 803 */ |
11135 | 804 GList *gaim_uri_list_extract_filenames(const gchar *uri_list); |
9670 | 805 |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
806 /*@}*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
807 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
808 /************************************************************************** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
809 * UTF8 String Functions |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
810 **************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
811 /*@{*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
812 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
813 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
814 * 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
|
815 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
816 * This function checks the locale and tries sane defaults. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
817 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
818 * @param str The source string. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
819 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
820 * @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
|
821 */ |
9642 | 822 gchar *gaim_utf8_try_convert(const char *str); |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
823 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
824 /** |
10258 | 825 * Salvages the valid UTF-8 characters from a string, replacing any |
826 * invalid characters with a filler character (currently hardcoded to | |
827 * '?'). | |
828 * | |
829 * @param str The source string. | |
830 * | |
831 * @return A valid UTF-8 string. | |
832 */ | |
833 gchar *gaim_utf8_salvage(const char *str); | |
834 | |
835 /** | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
836 * Compares two UTF-8 strings. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
837 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
838 * @param a The first string. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
839 * @param b The second string. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
840 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
841 * @return -1 if @a is less than @a b. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
842 * 0 if @a is equal to @a b. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
843 * 1 if @a is greater than @a b. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
844 */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
845 int gaim_utf8_strcasecmp(const char *a, const char *b); |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
846 |
7564 | 847 /** |
11552
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11501
diff
changeset
|
848 * Case insensitive search for a word in a string. The needle string |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11501
diff
changeset
|
849 * must be contained in the haystack string and not be immediately |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11501
diff
changeset
|
850 * preceded or immediately followed by another alpha-numeric character. |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11501
diff
changeset
|
851 * |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11501
diff
changeset
|
852 * @param haystack The string to search in. |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11501
diff
changeset
|
853 * @param needle The substring to find. |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11501
diff
changeset
|
854 * |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11501
diff
changeset
|
855 * @return TRUE if haystack has the word, otherwise FALSE |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11501
diff
changeset
|
856 */ |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11501
diff
changeset
|
857 gboolean gaim_utf8_has_word(const char *haystack, const char *needle); |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11501
diff
changeset
|
858 |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11501
diff
changeset
|
859 /** |
7564 | 860 * Checks for messages starting with "/me " |
861 * | |
862 * @param message The message to check | |
863 * @param len The message length, or -1 | |
864 * | |
865 * @return TRUE if it starts with /me, and it has been removed, otherwise FALSE | |
866 */ | |
867 gboolean gaim_message_meify(char *message, size_t len); | |
868 | |
7889 | 869 /** |
870 * Removes the underscore characters from a string used identify the mnemonic | |
871 * character. | |
872 * | |
873 * @param in The string to strip | |
874 * | |
875 * @return The stripped string | |
876 */ | |
8432
33cc36f5a7a6
[gaim-migrate @ 9162]
Christian Hammond <chipx86@chipx86.com>
parents:
8341
diff
changeset
|
877 char *gaim_text_strip_mnemonic(const char *in); |
7889 | 878 |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
879 /*@}*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
880 |
8432
33cc36f5a7a6
[gaim-migrate @ 9162]
Christian Hammond <chipx86@chipx86.com>
parents:
8341
diff
changeset
|
881 /** |
33cc36f5a7a6
[gaim-migrate @ 9162]
Christian Hammond <chipx86@chipx86.com>
parents:
8341
diff
changeset
|
882 * Adds 8 to something. |
33cc36f5a7a6
[gaim-migrate @ 9162]
Christian Hammond <chipx86@chipx86.com>
parents:
8341
diff
changeset
|
883 * |
33cc36f5a7a6
[gaim-migrate @ 9162]
Christian Hammond <chipx86@chipx86.com>
parents:
8341
diff
changeset
|
884 * Blame SimGuy. |
33cc36f5a7a6
[gaim-migrate @ 9162]
Christian Hammond <chipx86@chipx86.com>
parents:
8341
diff
changeset
|
885 * |
9000 | 886 * @param x The number to add 8 to. |
8432
33cc36f5a7a6
[gaim-migrate @ 9162]
Christian Hammond <chipx86@chipx86.com>
parents:
8341
diff
changeset
|
887 * |
9000 | 888 * @return x + 8 |
8432
33cc36f5a7a6
[gaim-migrate @ 9162]
Christian Hammond <chipx86@chipx86.com>
parents:
8341
diff
changeset
|
889 */ |
8433 | 890 #define gaim_add_eight(x) ((x)+8) |
8432
33cc36f5a7a6
[gaim-migrate @ 9162]
Christian Hammond <chipx86@chipx86.com>
parents:
8341
diff
changeset
|
891 |
9926 | 892 /** |
893 * Does the reverse of gaim_escape_filename | |
894 * | |
895 * This will change hex codes and such to their ascii equivalents. | |
896 * | |
897 * @param str The string to translate. | |
898 * | |
899 * @return The resulting string. | |
900 */ | |
901 const char *gaim_unescape_filename(const char *str); | |
902 | |
903 /** | |
904 * Escapes filesystem-unfriendly characters from a filename | |
905 * | |
906 * @param str The string to translate. | |
907 * | |
908 * @return The resulting string. | |
909 */ | |
910 const char *gaim_escape_filename(const char *str); | |
911 | |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
912 #ifdef __cplusplus |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
913 } |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
914 #endif |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
915 |
4890 | 916 #endif /* _GAIM_UTIL_H_ */ |