Mercurial > pidgin
annotate src/util.h @ 7100:abdc55ffadba
[gaim-migrate @ 7665]
Update plugins to the new API changes.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Wed, 01 Oct 2003 04:09:54 +0000 |
parents | c8bf2da398e3 |
children | 9d0e74b6ca68 |
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 * | |
7 * Copyright (C) 2002-2003, Christian Hammond <chipx86@gnupdate.org> | |
7094
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
8 * |
4890 | 9 * This program is free software; you can redistribute it and/or modify |
10 * it under the terms of the GNU General Public License as published by | |
11 * the Free Software Foundation; either version 2 of the License, or | |
12 * (at your option) any later version. | |
13 * | |
14 * This program is distributed in the hope that it will be useful, | |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 * GNU General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
20 * along with this program; if not, write to the Free Software | |
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
22 * | |
23 * @todo Rename the functions so that they live somewhere in the gaim | |
24 * namespace. | |
25 */ | |
26 #ifndef _GAIM_UTIL_H_ | |
27 #define _GAIM_UTIL_H_ | |
28 | |
6474
2fed50891afa
[gaim-migrate @ 6983]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
29 #include <stdio.h> |
2fed50891afa
[gaim-migrate @ 6983]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
30 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5532
diff
changeset
|
31 #include "account.h" |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5532
diff
changeset
|
32 |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
33 #ifdef __cplusplus |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
34 extern "C" { |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
35 #endif |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
36 |
4890 | 37 /** |
38 * Normalizes a string, so that it is suitable for comparison. | |
39 * | |
40 * The returned string will point to a static buffer, so if the | |
41 * string is intended to be kept long-term, you <i>must</i> | |
42 * g_strdup() it. Also, calling normalize() twice in the same line | |
43 * will lead to problems. | |
44 * | |
45 * @param str The string to normalize. | |
46 * | |
47 * @return A pointer to the normalized version stored in a static buffer. | |
48 */ | |
49 char *normalize(const char *str); | |
50 | |
51 /** | |
52 * Converts a string to its base-64 equivalent. | |
53 * | |
5426 | 54 * @param buf The data to convert. |
5532 | 55 * @param len The length of the data. |
4890 | 56 * |
57 * @return The base-64 version of @a str. | |
58 * | |
59 * @see frombase64() | |
60 */ | |
5426 | 61 char *tobase64(const unsigned char *buf, size_t len); |
4890 | 62 |
63 /** | |
64 * Converts a string back from its base-64 equivalent. | |
65 * | |
66 * @param str The string to convert back. | |
67 * @param ret_str The returned, non-base-64 string. | |
68 * @param ret_len The returned string length. | |
69 * | |
70 * @see tobase64() | |
71 */ | |
72 void frombase64(const char *str, char **ret_str, int *ret_len); | |
73 | |
74 /** | |
75 * Converts a string to its base-16 equivalent. | |
76 * | |
77 * @param str The string to convert. | |
78 * @param len The length of the string. | |
79 * | |
80 * @return The base-16 string. | |
81 * | |
82 * @see frombase16() | |
83 */ | |
5451 | 84 unsigned char *tobase16(const unsigned char *str, int len); |
4890 | 85 |
86 /** | |
87 * Converts a string back from its base-16 equivalent. | |
88 * | |
89 * @param str The string to convert back. | |
90 * @param ret_str The returned, non-base-16 string. | |
5451 | 91 * |
4890 | 92 * @return The length of the returned string. |
93 * | |
94 * @see tobase16() | |
95 */ | |
5497 | 96 int frombase16(const char *str, unsigned char **ret_str); |
4890 | 97 |
98 /** | |
99 * Waits for all child processes to terminate. | |
100 */ | |
101 void clean_pid(void); | |
102 | |
103 /** | |
104 * Returns the current local time in hour:minute:second form. | |
105 * | |
106 * The returned string is stored in a static buffer, so the result | |
107 * should be g_strdup()'d if it's intended to be used for long. | |
108 * | |
109 * @return The current local time. | |
110 * | |
111 * @see full_date() | |
112 */ | |
113 char *date(void); | |
114 | |
115 /** | |
116 * Adds the necessary HTML code to turn URIs into HTML links in a string. | |
117 * | |
5136 | 118 * @param str The string to linkify. |
4890 | 119 * |
5136 | 120 * @return The linkified text. |
4890 | 121 */ |
5136 | 122 char *linkify_text(const char *str); |
4890 | 123 |
124 /** | |
125 * Converts seconds into a human-readable form. | |
126 * | |
127 * @param sec The seconds. | |
128 * | |
129 * @return A human-readable form, containing days, hours, minutes, and | |
130 * seconds. | |
131 */ | |
132 char *sec_to_text(guint sec); | |
133 | |
134 /** | |
135 * Returns the date and time in human-readable form. | |
136 * | |
137 * The returned string is stored in a static buffer, so the result | |
138 * should be g_strdup()'d if it's intended to be used for long. | |
139 * | |
140 * @return The date and time in human-readable form. | |
141 * | |
142 * @see date() | |
143 */ | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5532
diff
changeset
|
144 char *full_date(void); |
4890 | 145 |
146 /** | |
147 * Looks for %n, %d, or %t in a string, and replaces them with the | |
148 * specified name, date, and time, respectively. | |
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 * @param str The string that may contain the special variables. | |
154 * @param name The sender name. | |
155 * | |
156 * @return A new string where the special variables are expanded. | |
157 */ | |
158 char *away_subs(const char *str, const char *name); | |
159 | |
160 /**` | |
161 * Returns the user's home directory. | |
162 * | |
163 * @return The user's home directory. | |
164 * | |
165 * @see gaim_user_dir() | |
166 */ | |
167 const gchar *gaim_home_dir(void); | |
168 | |
169 /** | |
170 * Returns the gaim settings directory in the user's home directory. | |
171 * | |
172 * @return The gaim settings directory. | |
173 * | |
174 * @see gaim_home_dir() | |
175 */ | |
176 char *gaim_user_dir(void); | |
177 | |
178 /** | |
179 * Copies a string and replaces all HTML linebreaks with newline characters. | |
180 * | |
181 * @param dest The destination string. | |
182 * @param src The source string. | |
183 * @param dest_len The destination string length. | |
184 * | |
185 * @see strncpy_withhtml() | |
186 * @see strdup_withhtml() | |
187 */ | |
188 void strncpy_nohtml(gchar *dest, const gchar *src, size_t dest_len); | |
189 | |
190 /** | |
191 * Copies a string and replaces all newline characters with HTML linebreaks. | |
192 * | |
193 * @param dest The destination string. | |
194 * @param src The source string. | |
195 * @param dest_len The destination string length. | |
196 * | |
197 * @see strncpy_nohtml() | |
198 * @see strdup_withhtml() | |
199 */ | |
200 void strncpy_withhtml(gchar *dest, const gchar *src, size_t dest_len); | |
201 | |
202 /** | |
203 * Duplicates a string and replaces all newline characters from the | |
204 * source string with HTML linebreaks. | |
205 * | |
206 * @param src The source string. | |
207 * | |
208 * @return The new string. | |
209 * | |
210 * @see strncpy_nohtml() | |
211 * @see strncpy_withhtml() | |
212 */ | |
213 gchar *strdup_withhtml(const gchar *src); | |
214 | |
215 /** | |
216 * Ensures that all linefeeds have a matching carriage return. | |
217 * | |
218 * @param str The source string. | |
219 * | |
220 * @return The string with carriage returns. | |
221 */ | |
6720
41120df7ed94
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6474
diff
changeset
|
222 char *add_cr(const char *str); |
4890 | 223 |
224 /** | |
225 * Strips all linefeeds from a string. | |
226 * | |
227 * @param str The string to strip linefeeds from. | |
228 */ | |
229 void strip_linefeed(char *str); | |
230 | |
231 /** | |
232 * Builds a time_t from the supplied information. | |
233 * | |
234 * @param year The year. | |
235 * @param month The month. | |
236 * @param day The day. | |
237 * @param hour The hour. | |
238 * @param min The minute. | |
239 * @param sec The second. | |
240 * | |
241 * @return A time_t. | |
242 */ | |
243 time_t get_time(int year, int month, int day, | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5532
diff
changeset
|
244 int hour, int min, int sec); |
4890 | 245 |
246 /** | |
247 * Creates a temporary file and returns a file pointer to it. | |
248 * | |
249 * This is like mkstemp(), but returns a file pointer and uses a | |
250 * pre-set template. It uses the semantics of tempnam() for the | |
251 * directory to use and allocates the space for the file path. | |
252 * | |
253 * The caller is responsible for closing the file and removing it when | |
254 * done, as well as freeing the space pointed to by @a path with | |
255 * g_free(). | |
256 * | |
257 * @param path The returned path to the temp file. | |
258 * | |
259 * @return A file pointer to the temporary file, or @c NULL on failure. | |
260 */ | |
261 FILE *gaim_mkstemp(gchar **path); | |
262 | |
263 /** | |
6861 | 264 * Checks if the given program name is valid and executable. |
265 * | |
266 * @parm program The file name of the application. | |
267 * | |
268 * @return True if the program is runable. | |
269 */ | |
270 gboolean program_is_valid(const char *program); | |
271 | |
272 /** | |
4890 | 273 * Attempts to convert a string to UTF-8 from an unknown encoding. |
274 * | |
275 * This function checks the locale and tries sane defaults. | |
276 * | |
277 * @param str The source string. | |
278 * | |
279 * @return The UTF-8 string, or @c NULL if it could not be converted. | |
280 */ | |
281 char *gaim_try_conv_to_utf8(const char *str); | |
282 | |
283 /** | |
284 * Returns the IP address from a socket file descriptor. | |
285 * | |
286 * @param fd The socket file descriptor. | |
287 * | |
288 * @return The IP address, or @c NULL on error. | |
289 */ | |
290 char *gaim_getip_from_fd(int fd); | |
291 | |
292 /** | |
293 * Compares two UTF-8 strings. | |
294 * | |
295 * @param a The first string. | |
296 * @param b The second string. | |
297 * | |
298 * @return -1 if @a is less than @a b. | |
299 * 0 if @a is equal to @a b. | |
300 * 1 if @a is greater than @a b. | |
301 */ | |
302 gint gaim_utf8_strcasecmp(const gchar *a, const gchar *b); | |
303 | |
5515 | 304 /** |
305 * Given a string, this replaces one substring with another | |
306 * and returns a newly allocated string. | |
307 * | |
308 * @param string The string from which to replace stuff. | |
309 * @param delimiter The substring you want replaced. | |
310 * @param replacement The substring you want inserted in place | |
311 * of the delimiting substring. | |
312 */ | |
5874
964e4f94fc56
[gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
313 gchar *gaim_strreplace(const gchar *string, const gchar *delimiter, |
964e4f94fc56
[gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
314 const gchar *replacement); |
5515 | 315 |
5826 | 316 /** |
6982 | 317 * This is like strstr, except that it ignores ASCII case in |
318 * searching for the substring. | |
319 * | |
320 * @param haystack The string to search in. | |
321 * @param needle The substring to find. | |
322 * @return the location of the substring if found, or NULL if not | |
323 */ | |
324 const char *gaim_strcasestr(const char *haystack, const char *needle); | |
325 | |
326 /** | |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
327 * Returns a string representing a filesize in the appropriate |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
328 * units (MB, KB, GB, etc.) |
5826 | 329 * |
330 * @param size The size | |
331 */ | |
332 char *gaim_get_size_string(size_t size); | |
333 | |
6982 | 334 /** |
7094
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
335 * Finds a HTML tag matching the given name. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
336 * |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
337 * 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
|
338 * 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
|
339 * in the hash table, and the name of the tag is case insensitive. |
6982 | 340 * |
341 * @param needle the name of the tag | |
342 * @param haystack the null-delimited string to search in | |
343 * @param start a pointer to the start of the tag if found | |
344 * @param end a pointer to the end of the tag if found | |
345 * @param attributes the attributes, if the tag was found | |
346 * @return TRUE if the tag was found | |
347 */ | |
7094
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
348 gboolean gaim_markup_find_tag(const char *needle, const char *haystack, |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
349 const char **start, const char **end, |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
350 GData **attributes); |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
351 |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
352 /** |
7095
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
353 * Extracts a field of data from HTML. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
354 * |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
355 * This is a scary function. See protocols/msn/msn.c and |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
356 * protocols/yahoo/yahoo.c for example usage. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
357 * |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
358 * @param str The string to parse. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
359 * @param dest_buffer The destination buffer to append the new |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
360 * field info to. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
361 * @param start_token The beginning token. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
362 * @param skip The number of characters to skip after the |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
363 * start token. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
364 * @param end_token The ending token. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
365 * @param check_value The value that the last character must meet. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
366 * @param no_value_token The token indicating no value is given. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
367 * @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
|
368 * @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
|
369 * @param link_prefix The prefix for the link. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
370 * |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
371 * @return TRUE if successful, or FALSE otherwise. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
372 */ |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
373 gboolean gaim_markup_extract_info_field(const char *str, char *dest_buffer, |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
374 const char *start_token, int skip, |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
375 const char *end_token, |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
376 char check_value, |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
377 const char *no_value_token, |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
378 const char *display_name, |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
379 gboolean is_link, |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
380 const char *link_prefix); |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
381 |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
382 /** |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
383 * Converts HTML markup to XHTML. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
384 * |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
385 * @param html The HTML markup. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
386 * @param dest_xhtml The destination XHTML output. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
387 * @param dest_plain The destination plain-text output. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
388 */ |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
389 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
|
390 char **dest_plain); |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
391 |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
392 /** |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
393 * Strips HTML tags from a string. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
394 * |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
395 * @param str The string to strip HTML from. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
396 * |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
397 * @return The new string without HTML. This must be freed. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
398 */ |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
399 char *gaim_markup_strip_html(const char *str); |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
400 |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
401 /** |
7094
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
402 * Parses a URL, returning its host, port, and file path. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
403 * |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
404 * The returned data must be freed. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
405 * |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
406 * @param url The URL to parse. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
407 * @param ret_host The returned host. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
408 * @param ret_port The returned port. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
409 * @param ret_path The returned path. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
410 */ |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
411 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
|
412 char **ret_path); |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
413 |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
414 /** |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
415 * 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
|
416 * |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
417 * @param url The URL. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
418 * @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
|
419 * partial URL. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
420 * @param cb The callback function. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
421 * @param data The user data to pass to the callback function. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
422 * @param user_agent The user agent field to use, or NULL. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
423 * @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
|
424 */ |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
425 void gaim_url_fetch(const char *url, gboolean full, |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
426 const char *user_agent, gboolean http11, |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
427 void (*cb)(void *, const char *, size_t), |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
428 void *data); |
6982 | 429 |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
430 #ifdef __cplusplus |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
431 } |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
432 #endif |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
433 |
4890 | 434 #endif /* _GAIM_UTIL_H_ */ |