Mercurial > pidgin.yaz
annotate src/util.h @ 7107:9220c7490cd1
[gaim-migrate @ 7672]
This is a big one: normalize() -> gaim_normalize, linkify_text() ->
gaim_markup_linkify(), gaim_get_size_string() -> gaim_str_size_to_units(),
and moved clean_pid() to main.c.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Wed, 01 Oct 2003 06:17:28 +0000 |
parents | db6bd3e794d8 |
children | 6faeeecab0dc |
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 */ | |
7107
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
49 char *gaim_normalize(const char *str); |
4890 | 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 */ | |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7105
diff
changeset
|
61 char *gaim_base64_encode(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 */ | |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7105
diff
changeset
|
72 void gaim_base64_decode(const char *str, char **ret_str, int *ret_len); |
4890 | 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 */ | |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7105
diff
changeset
|
84 unsigned char *gaim_base16_encode(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 */ | |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7105
diff
changeset
|
96 int gaim_base16_decode(const char *str, unsigned char **ret_str); |
4890 | 97 |
98 /** | |
99 * Returns the current local time in hour:minute:second form. | |
100 * | |
101 * The returned string is stored in a static buffer, so the result | |
102 * should be g_strdup()'d if it's intended to be used for long. | |
103 * | |
104 * @return The current local time. | |
105 * | |
106 * @see full_date() | |
107 */ | |
108 char *date(void); | |
109 | |
110 /** | |
111 * Converts seconds into a human-readable form. | |
112 * | |
113 * @param sec The seconds. | |
114 * | |
115 * @return A human-readable form, containing days, hours, minutes, and | |
116 * seconds. | |
117 */ | |
118 char *sec_to_text(guint sec); | |
119 | |
120 /** | |
121 * Returns the date and time in human-readable form. | |
122 * | |
123 * The returned string is stored in a static buffer, so the result | |
124 * should be g_strdup()'d if it's intended to be used for long. | |
125 * | |
126 * @return The date and time in human-readable form. | |
127 * | |
128 * @see date() | |
129 */ | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5532
diff
changeset
|
130 char *full_date(void); |
4890 | 131 |
132 /** | |
133 * Looks for %n, %d, or %t in a string, and replaces them with the | |
134 * specified name, date, and time, respectively. | |
135 * | |
136 * The returned string is stored in a static buffer, so the result | |
137 * should be g_strdup()'d if it's intended to be used for long. | |
138 * | |
139 * @param str The string that may contain the special variables. | |
140 * @param name The sender name. | |
141 * | |
142 * @return A new string where the special variables are expanded. | |
143 */ | |
144 char *away_subs(const char *str, const char *name); | |
145 | |
146 /**` | |
147 * Returns the user's home directory. | |
148 * | |
149 * @return The user's home directory. | |
150 * | |
151 * @see gaim_user_dir() | |
152 */ | |
153 const gchar *gaim_home_dir(void); | |
154 | |
155 /** | |
156 * Returns the gaim settings directory in the user's home directory. | |
7105
9d0e74b6ca68
[gaim-migrate @ 7670]
Christian Hammond <chipx86@chipx86.com>
parents:
7095
diff
changeset
|
157 * |
4890 | 158 * @return The gaim settings directory. |
159 * | |
160 * @see gaim_home_dir() | |
161 */ | |
162 char *gaim_user_dir(void); | |
163 | |
164 /** | |
165 * Copies a string and replaces all HTML linebreaks with newline characters. | |
166 * | |
167 * @param dest The destination string. | |
168 * @param src The source string. | |
169 * @param dest_len The destination string length. | |
170 * | |
171 * @see strncpy_withhtml() | |
172 * @see strdup_withhtml() | |
173 */ | |
174 void strncpy_nohtml(gchar *dest, const gchar *src, size_t dest_len); | |
175 | |
176 /** | |
177 * Copies a string and replaces all newline characters with HTML linebreaks. | |
178 * | |
179 * @param dest The destination string. | |
180 * @param src The source string. | |
181 * @param dest_len The destination string length. | |
182 * | |
183 * @see strncpy_nohtml() | |
184 * @see strdup_withhtml() | |
185 */ | |
186 void strncpy_withhtml(gchar *dest, const gchar *src, size_t dest_len); | |
187 | |
188 /** | |
189 * Duplicates a string and replaces all newline characters from the | |
190 * source string with HTML linebreaks. | |
191 * | |
192 * @param src The source string. | |
193 * | |
194 * @return The new string. | |
195 * | |
196 * @see strncpy_nohtml() | |
197 * @see strncpy_withhtml() | |
198 */ | |
199 gchar *strdup_withhtml(const gchar *src); | |
200 | |
201 /** | |
202 * Ensures that all linefeeds have a matching carriage return. | |
203 * | |
204 * @param str The source string. | |
205 * | |
206 * @return The string with carriage returns. | |
207 */ | |
6720
41120df7ed94
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6474
diff
changeset
|
208 char *add_cr(const char *str); |
4890 | 209 |
210 /** | |
211 * Strips all linefeeds from a string. | |
212 * | |
213 * @param str The string to strip linefeeds from. | |
214 */ | |
215 void strip_linefeed(char *str); | |
216 | |
217 /** | |
218 * Builds a time_t from the supplied information. | |
219 * | |
220 * @param year The year. | |
221 * @param month The month. | |
222 * @param day The day. | |
223 * @param hour The hour. | |
224 * @param min The minute. | |
225 * @param sec The second. | |
226 * | |
227 * @return A time_t. | |
228 */ | |
229 time_t get_time(int year, int month, int day, | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5532
diff
changeset
|
230 int hour, int min, int sec); |
4890 | 231 |
232 /** | |
233 * Creates a temporary file and returns a file pointer to it. | |
234 * | |
235 * This is like mkstemp(), but returns a file pointer and uses a | |
236 * pre-set template. It uses the semantics of tempnam() for the | |
237 * directory to use and allocates the space for the file path. | |
238 * | |
239 * The caller is responsible for closing the file and removing it when | |
240 * done, as well as freeing the space pointed to by @a path with | |
241 * g_free(). | |
242 * | |
243 * @param path The returned path to the temp file. | |
7105
9d0e74b6ca68
[gaim-migrate @ 7670]
Christian Hammond <chipx86@chipx86.com>
parents:
7095
diff
changeset
|
244 * |
4890 | 245 * @return A file pointer to the temporary file, or @c NULL on failure. |
246 */ | |
247 FILE *gaim_mkstemp(gchar **path); | |
248 | |
249 /** | |
6861 | 250 * Checks if the given program name is valid and executable. |
251 * | |
252 * @parm program The file name of the application. | |
253 * | |
254 * @return True if the program is runable. | |
255 */ | |
256 gboolean program_is_valid(const char *program); | |
257 | |
258 /** | |
4890 | 259 * Attempts to convert a string to UTF-8 from an unknown encoding. |
260 * | |
261 * This function checks the locale and tries sane defaults. | |
262 * | |
263 * @param str The source string. | |
264 * | |
265 * @return The UTF-8 string, or @c NULL if it could not be converted. | |
266 */ | |
267 char *gaim_try_conv_to_utf8(const char *str); | |
268 | |
269 /** | |
270 * Returns the IP address from a socket file descriptor. | |
271 * | |
272 * @param fd The socket file descriptor. | |
273 * | |
274 * @return The IP address, or @c NULL on error. | |
275 */ | |
276 char *gaim_getip_from_fd(int fd); | |
277 | |
278 /** | |
279 * Compares two UTF-8 strings. | |
280 * | |
281 * @param a The first string. | |
282 * @param b The second string. | |
283 * | |
284 * @return -1 if @a is less than @a b. | |
285 * 0 if @a is equal to @a b. | |
286 * 1 if @a is greater than @a b. | |
287 */ | |
288 gint gaim_utf8_strcasecmp(const gchar *a, const gchar *b); | |
289 | |
5515 | 290 /** |
291 * Given a string, this replaces one substring with another | |
292 * and returns a newly allocated string. | |
293 * | |
294 * @param string The string from which to replace stuff. | |
295 * @param delimiter The substring you want replaced. | |
7105
9d0e74b6ca68
[gaim-migrate @ 7670]
Christian Hammond <chipx86@chipx86.com>
parents:
7095
diff
changeset
|
296 * @param replacement The substring you want inserted in place |
5515 | 297 * of the delimiting substring. |
298 */ | |
5874
964e4f94fc56
[gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
299 gchar *gaim_strreplace(const gchar *string, const gchar *delimiter, |
964e4f94fc56
[gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
300 const gchar *replacement); |
5515 | 301 |
5826 | 302 /** |
6982 | 303 * This is like strstr, except that it ignores ASCII case in |
304 * searching for the substring. | |
305 * | |
306 * @param haystack The string to search in. | |
307 * @param needle The substring to find. | |
7107
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
308 * |
6982 | 309 * @return the location of the substring if found, or NULL if not |
310 */ | |
311 const char *gaim_strcasestr(const char *haystack, const char *needle); | |
312 | |
313 /** | |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
314 * Returns a string representing a filesize in the appropriate |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
315 * units (MB, KB, GB, etc.) |
5826 | 316 * |
317 * @param size The size | |
7107
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
318 * |
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
319 * @return The string in units form. This must be freed. |
5826 | 320 */ |
7107
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
321 char *gaim_str_size_to_units(size_t size); |
5826 | 322 |
6982 | 323 /** |
7094
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
324 * Finds a HTML tag matching the given name. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
325 * |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
326 * 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
|
327 * 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
|
328 * in the hash table, and the name of the tag is case insensitive. |
6982 | 329 * |
330 * @param needle the name of the tag | |
331 * @param haystack the null-delimited string to search in | |
332 * @param start a pointer to the start of the tag if found | |
333 * @param end a pointer to the end of the tag if found | |
334 * @param attributes the attributes, if the tag was found | |
335 * @return TRUE if the tag was found | |
336 */ | |
7094
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
337 gboolean gaim_markup_find_tag(const char *needle, const char *haystack, |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
338 const char **start, const char **end, |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
339 GData **attributes); |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
340 |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
341 /** |
7095
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
342 * Extracts a field of data from HTML. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
343 * |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
344 * This is a scary function. See protocols/msn/msn.c and |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
345 * protocols/yahoo/yahoo.c for example usage. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
346 * |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
347 * @param str The string to parse. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
348 * @param dest_buffer The destination buffer to append the new |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
349 * field info to. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
350 * @param start_token The beginning token. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
351 * @param skip The number of characters to skip after the |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
352 * start token. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
353 * @param end_token The ending token. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
354 * @param check_value The value that the last character must meet. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
355 * @param no_value_token The token indicating no value is given. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
356 * @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
|
357 * @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
|
358 * @param link_prefix The prefix for the link. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
359 * |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
360 * @return TRUE if successful, or FALSE otherwise. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
361 */ |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
362 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
|
363 const char *start_token, int skip, |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
364 const char *end_token, |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
365 char check_value, |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
366 const char *no_value_token, |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
367 const char *display_name, |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
368 gboolean is_link, |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
369 const char *link_prefix); |
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 /** |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
372 * Converts HTML markup to XHTML. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
373 * |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
374 * @param html The HTML markup. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
375 * @param dest_xhtml The destination XHTML output. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
376 * @param dest_plain The destination plain-text output. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
377 */ |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
378 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
|
379 char **dest_plain); |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
380 |
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 * Strips HTML tags from a string. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
383 * |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
384 * @param str The string to strip HTML from. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
385 * |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
386 * @return The new string without HTML. This must be freed. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
387 */ |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
388 char *gaim_markup_strip_html(const char *str); |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
389 |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
390 /** |
7107
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
391 * 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
|
392 * |
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
393 * @param str The string to linkify. |
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
394 * |
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
395 * @return The linkified text. |
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
396 */ |
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
397 char *gaim_markup_linkify(const char *str); |
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
398 |
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
399 /** |
7094
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
400 * Parses a URL, returning its host, port, and file path. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
401 * |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
402 * The returned data must be freed. |
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 * @param url The URL to parse. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
405 * @param ret_host The returned host. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
406 * @param ret_port The returned port. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
407 * @param ret_path The returned path. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
408 */ |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
409 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
|
410 char **ret_path); |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
411 |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
412 /** |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
413 * 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
|
414 * |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
415 * @param url The URL. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
416 * @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
|
417 * partial URL. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
418 * @param cb The callback function. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
419 * @param data The user data to pass to the callback function. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
420 * @param user_agent The user agent field to use, or NULL. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
421 * @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
|
422 */ |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
423 void gaim_url_fetch(const char *url, gboolean full, |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
424 const char *user_agent, gboolean http11, |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
425 void (*cb)(void *, const char *, size_t), |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
426 void *data); |
6982 | 427 |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
428 #ifdef __cplusplus |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
429 } |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
430 #endif |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
431 |
4890 | 432 #endif /* _GAIM_UTIL_H_ */ |