Mercurial > pidgin
annotate src/util.h @ 10424:108151be77a3
[gaim-migrate @ 11676]
Those 2 helper functions in xmlnode made things less readable...
Lesson #456: Helper functions, while possible saving time, can
hurt you in the long run when they steal your wallet.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 26 Dec 2004 18:58:36 +0000 |
parents | 5b7a74d397cc |
children | 9903182f2aac |
rev | line source |
---|---|
4890 | 1 /** |
2 * @file util.h Utility Functions | |
5034
4691c5936c01
[gaim-migrate @ 5377]
Christian Hammond <chipx86@chipx86.com>
parents:
4890
diff
changeset
|
3 * @ingroup core |
4890 | 4 * |
5 * gaim | |
6 * | |
8046 | 7 * Gaim is the legal property of its developers, whose names are too numerous |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
7094
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
10 * |
4890 | 11 * This program is free software; you can redistribute it and/or modify |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 * | |
25 * @todo Rename the functions so that they live somewhere in the gaim | |
26 * namespace. | |
27 */ | |
28 #ifndef _GAIM_UTIL_H_ | |
29 #define _GAIM_UTIL_H_ | |
30 | |
6474
2fed50891afa
[gaim-migrate @ 6983]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
31 #include <stdio.h> |
2fed50891afa
[gaim-migrate @ 6983]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
32 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5532
diff
changeset
|
33 #include "account.h" |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5532
diff
changeset
|
34 |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
35 #ifdef __cplusplus |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
36 extern "C" { |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
37 #endif |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
38 |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
39 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
40 /** @name Base16 Functions */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
41 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
42 /*@{*/ |
4890 | 43 |
44 /** | |
45 * Converts a string to its base-16 equivalent. | |
46 * | |
47 * @param str The string to convert. | |
48 * @param len The length of the string. | |
49 * | |
50 * @return The base-16 string. | |
51 * | |
7123
d40966338ea6
[gaim-migrate @ 7690]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
52 * @see gaim_base16_decode() |
4890 | 53 */ |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7105
diff
changeset
|
54 unsigned char *gaim_base16_encode(const unsigned char *str, int len); |
4890 | 55 |
56 /** | |
57 * Converts a string back from its base-16 equivalent. | |
58 * | |
59 * @param str The string to convert back. | |
60 * @param ret_str The returned, non-base-16 string. | |
5451 | 61 * |
4890 | 62 * @return The length of the returned string. |
63 * | |
7123
d40966338ea6
[gaim-migrate @ 7690]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
64 * @see gaim_base16_encode() |
4890 | 65 */ |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7105
diff
changeset
|
66 int gaim_base16_decode(const char *str, unsigned char **ret_str); |
4890 | 67 |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
68 /*@}*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
69 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
70 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
71 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
72 /** @name Base64 Functions */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
73 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
74 /*@{*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
75 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
76 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
77 * Converts a string to its base-64 equivalent. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
78 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
79 * @param buf The data to convert. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
80 * @param len The length of the data. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
81 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
82 * @return The base-64 version of @a str. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
83 * |
7123
d40966338ea6
[gaim-migrate @ 7690]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
84 * @see gaim_base64_decode() |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
85 */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
86 unsigned char *gaim_base64_encode(const unsigned char *buf, size_t len); |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
87 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
88 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
89 * Converts a string back from its base-64 equivalent. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
90 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
91 * @param str The string to convert back. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
92 * @param ret_str The returned, non-base-64 string. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
93 * @param ret_len The returned string length. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
94 * |
7123
d40966338ea6
[gaim-migrate @ 7690]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
95 * @see gaim_base64_encode() |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
96 */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
97 void gaim_base64_decode(const char *str, char **ret_str, int *ret_len); |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
98 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
99 /*@}*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
100 |
7679 | 101 /**************************************************************************/ |
102 /** @name Quoted Printable Functions */ | |
103 /**************************************************************************/ | |
104 /*@{*/ | |
105 | |
106 /** | |
107 * Converts a quoted printable string back to its readable equivalent. | |
108 * | |
109 * @param str The string to convert back. | |
110 * @param ret_str The returned, readable string. | |
111 * @param ret_len The returned string length. | |
112 */ | |
113 void gaim_quotedp_decode (const char *str, char **ret_str, int *ret_len); | |
114 | |
115 /*@}*/ | |
116 | |
117 /**************************************************************************/ | |
118 /** @name MIME Functions */ | |
119 /**************************************************************************/ | |
120 /*@{*/ | |
121 | |
122 /** | |
123 * Converts a MIME header field string back to its readable equivalent | |
8432
33cc36f5a7a6
[gaim-migrate @ 9162]
Christian Hammond <chipx86@chipx86.com>
parents:
8341
diff
changeset
|
124 * 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
|
125 * contain any number of sections called "encoded-words." The format |
7821 | 126 * of an encoded word is =?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= |
127 * =? designates the beginning of the encoded-word | |
128 * ?= designates the end of the encoded-word | |
8432
33cc36f5a7a6
[gaim-migrate @ 9162]
Christian Hammond <chipx86@chipx86.com>
parents:
8341
diff
changeset
|
129 * ? segments the encoded word into three pieces. The first piece is |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8700
diff
changeset
|
130 * the character set, the second piece is the encoding, and the |
7821 | 131 * third piece is the encoded text. |
7679 | 132 * |
133 * @param str The string to convert back. | |
134 * | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8700
diff
changeset
|
135 * @return The readable string. |
7679 | 136 */ |
137 char *gaim_mime_decode_field (const char *str); | |
138 | |
139 /*@}*/ | |
140 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
141 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
142 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
143 /** @name Date/Time Functions */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
144 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
145 /*@{*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
146 |
4890 | 147 /** |
148 * Returns the current local time in hour:minute:second form. | |
149 * | |
150 * The returned string is stored in a static buffer, so the result | |
151 * should be g_strdup()'d if it's intended to be used for long. | |
152 * | |
153 * @return The current local time. | |
154 * | |
7123
d40966338ea6
[gaim-migrate @ 7690]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
155 * @see gaim_date_full() |
4890 | 156 */ |
7162 | 157 const char *gaim_date(void); |
4890 | 158 |
159 /** | |
160 * Returns the date and time in human-readable form. | |
161 * | |
162 * The returned string is stored in a static buffer, so the result | |
163 * should be g_strdup()'d if it's intended to be used for long. | |
164 * | |
165 * @return The date and time in human-readable form. | |
166 * | |
7123
d40966338ea6
[gaim-migrate @ 7690]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
167 * @see gaim_date() |
4890 | 168 */ |
7162 | 169 const char *gaim_date_full(void); |
4890 | 170 |
171 /** | |
172 * Builds a time_t from the supplied information. | |
173 * | |
174 * @param year The year. | |
175 * @param month The month. | |
176 * @param day The day. | |
177 * @param hour The hour. | |
178 * @param min The minute. | |
179 * @param sec The second. | |
180 * | |
181 * @return A time_t. | |
182 */ | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
183 time_t gaim_time_build(int year, int month, int day, int hour, |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
184 int min, int sec); |
4890 | 185 |
8577 | 186 /** |
187 * Parses a timestamp in jabber or ISO8601 format and returns a time_t. | |
188 * | |
189 * @param timestamp The timestamp | |
190 * @param utc Assume UTC if no timezone specified | |
191 * | |
192 * @return A time_t. | |
193 */ | |
194 time_t gaim_str_to_time(const char *timestamp, gboolean utc); | |
195 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
196 /*@}*/ |
4890 | 197 |
198 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
199 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
200 /** @name Markup Functions */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
201 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
202 /*@{*/ |
5826 | 203 |
6982 | 204 /** |
7094
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
205 * Finds a HTML tag matching the given name. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
206 * |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
207 * 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
|
208 * 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
|
209 * in the hash table, and the name of the tag is case insensitive. |
6982 | 210 * |
211 * @param needle the name of the tag | |
212 * @param haystack the null-delimited string to search in | |
213 * @param start a pointer to the start of the tag if found | |
214 * @param end a pointer to the end of the tag if found | |
215 * @param attributes the attributes, if the tag was found | |
216 * @return TRUE if the tag was found | |
217 */ | |
7094
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
218 gboolean gaim_markup_find_tag(const char *needle, const char *haystack, |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
219 const char **start, const char **end, |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
220 GData **attributes); |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
221 |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
222 /** |
7095
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
223 * Extracts a field of data from HTML. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
224 * |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
225 * This is a scary function. See protocols/msn/msn.c and |
9175 | 226 * protocols/yahoo/yahoo_profile.c for example usage. |
7095
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
227 * |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
228 * @param str The string to parse. |
7675 | 229 * @param len The size of str. |
230 * @param dest The destination GString to append the new | |
7095
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
231 * field info to. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
232 * @param start_token The beginning token. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
233 * @param skip The number of characters to skip after the |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
234 * start token. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
235 * @param end_token The ending token. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
236 * @param check_value The value that the last character must meet. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
237 * @param no_value_token The token indicating no value is given. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
238 * @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
|
239 * @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
|
240 * @param link_prefix The prefix for the link. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
241 * |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
242 * @return TRUE if successful, or FALSE otherwise. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
243 */ |
7675 | 244 gboolean gaim_markup_extract_info_field(const char *str, int len, GString *dest, |
245 const char *start_token, int skip, | |
246 const char *end_token, char check_value, | |
247 const char *no_value_token, | |
248 const char *display_name, gboolean is_link, | |
249 const char *link_prefix); | |
7095
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
250 |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
251 /** |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
252 * Converts HTML markup to XHTML. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
253 * |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
254 * @param html The HTML markup. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
255 * @param dest_xhtml The destination XHTML output. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
256 * @param dest_plain The destination plain-text output. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
257 */ |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
258 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
|
259 char **dest_plain); |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
260 |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
261 /** |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
262 * Strips HTML tags from a string. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
263 * |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
264 * @param str The string to strip HTML from. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
265 * |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
266 * @return The new string without HTML. This must be freed. |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
267 */ |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
268 char *gaim_markup_strip_html(const char *str); |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
269 |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
270 /** |
7107
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
271 * 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
|
272 * |
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
273 * @param str The string to linkify. |
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
274 * |
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
275 * @return The linkified text. |
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
276 */ |
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
277 char *gaim_markup_linkify(const char *str); |
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
278 |
8163 | 279 /** |
280 * Escapes HTML special characters to be displayed literally. | |
281 * For example '&' is replaced by "&" and so on | |
282 * | |
283 * @param html The string in which to escape any HTML special characters | |
284 * | |
285 * @return the text with HTML special characters escaped | |
286 */ | |
287 char *gaim_escape_html(const char *html); | |
288 | |
8442 | 289 /** |
290 * Unescapes HTML entities to their literal characters. | |
291 * For example "&" is replaced by '&' and so on. | |
292 * Actually only "&", """, "<" and ">" are currently | |
293 * supported. | |
294 * | |
295 * @param html The string in which to unescape any HTML entities | |
296 * | |
297 * @return the text with HTML entities literalized | |
298 */ | |
299 char *gaim_unescape_html(const char *html); | |
300 | |
9175 | 301 /** |
302 * Returns a newly allocated substring of the HTML UTF-8 string "str". | |
303 * The markup is preserved such that the substring will have the same | |
304 * formatting as original string, even though some tags may have been | |
305 * opened before "x", or may close after "y". All open tags are closed | |
306 * at the end of the returned string, in the proper order. | |
307 * | |
308 * Note that x and y are in character offsets, not byte offsets, and | |
309 * are offsets into an unformatted version of str. Because of this, | |
310 * this function may be sensitive to changes in GtkIMHtml and may break | |
311 * when used with other UI's. libgaim users are encouraged to report and | |
312 * work out any problems encountered. | |
313 * | |
314 * @param str The input NUL terminated, HTML, UTF-8 (or ASCII) string. | |
315 * @param x The character offset into an unformatted version of str to | |
316 * begin at. | |
317 * @param y The character offset (into an unformatted vesion of str) of | |
318 * one past the last character to include in the slice. | |
319 * | |
320 * @return The HTML slice of string, with all formatting retained. | |
321 */ | |
322 char *gaim_markup_slice(const char *str, guint x, guint y); | |
323 | |
324 /** | |
325 * Returns a newly allocated string containing the name of the tag | |
326 * located at "tag". Tag is expected to point to a '<', and contain | |
327 * a '>' sometime after that. If there is no '>' and the string is | |
328 * not NUL terminated, this function can be expected to segfault. | |
329 * | |
330 * @param tag The string starting a HTML tag. | |
331 * @return A string containing the name of the tag. | |
332 */ | |
333 char *gaim_markup_get_tag_name(const char *tag); | |
334 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
335 /*@}*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
336 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
337 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
338 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
339 /** @name Path/Filename Functions */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
340 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
341 /*@{*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
342 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
343 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
344 * Returns the user's home directory. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
345 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
346 * @return The user's home directory. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
347 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
348 * @see gaim_user_dir() |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
349 */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
350 const gchar *gaim_home_dir(void); |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
351 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
352 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
353 * Returns the gaim settings directory in the user's home directory. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
354 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
355 * @return The gaim settings directory. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
356 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
357 * @see gaim_home_dir() |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
358 */ |
10332 | 359 const char *gaim_user_dir(void); |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
360 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
361 /** |
8596 | 362 * Define a custom gaim settings directory, overriding the default (user's home directory/.gaim) |
363 * @param dir The custom settings directory | |
364 */ | |
365 void set_gaim_user_dir(const char *dir); | |
366 | |
367 /** | |
7612 | 368 * Builds a complete path from the root, making any directories along |
369 * the path which do not already exist. | |
7622 | 370 * |
7612 | 371 * @param path The path you wish to create. Note that it must start |
372 * from the root or this function will fail. | |
373 * @param mode Unix-style permissions for this directory. | |
7622 | 374 * |
7612 | 375 * @return 0 for success, nonzero on any error. |
376 */ | |
7622 | 377 int gaim_build_dir(const char *path, int mode); |
7612 | 378 |
379 /** | |
10415 | 380 * Write a string of data to a file of the given name in the Gaim |
381 * user directory ($HOME/.gaim by default). The data is typically | |
382 * a serialized version of one of Gaim's config files, such as | |
383 * prefs.xml, accounts.xml, etc. And the string is typically | |
384 * obtained using xmlnode_to_formatted_str. However, this function | |
385 * should work fine for saving binary files as well. | |
10414 | 386 * |
387 * @param filename The basename of the file to write in the gaim_user_dir. | |
388 * @param data A null-terminated string of data to write. | |
10415 | 389 * @param size The size of the data to save. If data is |
390 * null-terminated you can pass in -1. | |
10414 | 391 * |
392 * @return TRUE if the file was written successfully. FALSE otherwise. | |
393 */ | |
10415 | 394 gboolean gaim_util_write_data_to_file(const char *filename, const char *data, |
395 size_t size); | |
10414 | 396 |
397 /** | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
398 * Creates a temporary file and returns a file pointer to it. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
399 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
400 * 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
|
401 * pre-set template. It uses the semantics of tempnam() for the |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
402 * directory to use and allocates the space for the file path. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
403 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
404 * 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
|
405 * 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
|
406 * g_free(). |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
407 * |
10203
7ff9b8b22e7d
[gaim-migrate @ 11324]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
9926
diff
changeset
|
408 * @param path The returned path to the temp file. |
7ff9b8b22e7d
[gaim-migrate @ 11324]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
9926
diff
changeset
|
409 * @param binary Text or binary, for platforms where it matters. |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
410 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
411 * @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
|
412 */ |
10203
7ff9b8b22e7d
[gaim-migrate @ 11324]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
9926
diff
changeset
|
413 FILE *gaim_mkstemp(char **path, gboolean binary); |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
414 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
415 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
416 * Checks if the given program name is valid and executable. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
417 * |
7303
3ec38f08b0b2
[gaim-migrate @ 7887]
Christian Hammond <chipx86@chipx86.com>
parents:
7261
diff
changeset
|
418 * @param program The file name of the application. |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
419 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
420 * @return True if the program is runable. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
421 */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
422 gboolean gaim_program_is_valid(const char *program); |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
423 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
424 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
425 * Returns the IP address from a socket file descriptor. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
426 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
427 * @param fd The socket file descriptor. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
428 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
429 * @return The IP address, or @c NULL on error. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
430 */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
431 char *gaim_fd_get_ip(int fd); |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
432 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
433 /*@}*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
434 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
435 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
436 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
437 /** @name String Functions */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
438 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
439 /*@{*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
440 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
441 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
442 * Normalizes a string, so that it is suitable for comparison. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
443 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
444 * 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
|
445 * 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
|
446 * g_strdup() it. Also, calling normalize() twice in the same line |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
447 * will lead to problems. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
448 * |
7261 | 449 * @param account The account the string belongs to. |
450 * @param str The string to normalize. | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
451 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
452 * @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
|
453 */ |
7261 | 454 const char *gaim_normalize(const GaimAccount *account, const char *str); |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
455 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
456 /** |
7628 | 457 * Compares two strings to see if the first contains the second as |
458 * a proper prefix. | |
8432
33cc36f5a7a6
[gaim-migrate @ 9162]
Christian Hammond <chipx86@chipx86.com>
parents:
8341
diff
changeset
|
459 * |
7628 | 460 * @param s The string to check. |
461 * @param p The prefix in question. | |
8432
33cc36f5a7a6
[gaim-migrate @ 9162]
Christian Hammond <chipx86@chipx86.com>
parents:
8341
diff
changeset
|
462 * |
7628 | 463 * @return TRUE if p is a prefix of s, otherwise FALSE. |
464 */ | |
465 gboolean gaim_str_has_prefix(const char *s, const char *p); | |
466 | |
467 /** | |
468 * Compares two strings to see if the second is a proper suffix | |
469 * of the first. | |
8432
33cc36f5a7a6
[gaim-migrate @ 9162]
Christian Hammond <chipx86@chipx86.com>
parents:
8341
diff
changeset
|
470 * |
7628 | 471 * @param s The string to check. |
472 * @param x The suffix in question. | |
8432
33cc36f5a7a6
[gaim-migrate @ 9162]
Christian Hammond <chipx86@chipx86.com>
parents:
8341
diff
changeset
|
473 * |
7628 | 474 * @return TRUE if x is a a suffix of s, otherwise FALSE. |
475 */ | |
476 gboolean gaim_str_has_suffix(const char *s, const char *x); | |
477 | |
478 /** | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
479 * 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
|
480 * specified name, date, and time, respectively. |
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 * @param str The string that may contain the special variables. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
483 * @param name The sender name. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
484 * |
8700 | 485 * @return A newly allocated string where the special variables are |
486 * expanded. This should be g_free'd by the caller. | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
487 */ |
8700 | 488 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
|
489 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
490 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
491 * Duplicates a string and replaces all newline characters from the |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
492 * source string with HTML linebreaks. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
493 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
494 * @param src The source string. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
495 * |
8341 | 496 * @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
|
497 */ |
8341 | 498 gchar *gaim_strdup_withhtml(const gchar *src); |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
499 |
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 * Ensures that all linefeeds have a matching carriage return. |
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 * @param str The source string. |
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 * @return The string with carriage returns. |
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 char *gaim_str_add_cr(const char *str); |
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 /** |
7478
3c21f3084ff0
[gaim-migrate @ 8091]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7303
diff
changeset
|
510 * Strips all carriage returns from a string. |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
511 * |
7478
3c21f3084ff0
[gaim-migrate @ 8091]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7303
diff
changeset
|
512 * @param str The string to strip carriage returns from. |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
513 */ |
7478
3c21f3084ff0
[gaim-migrate @ 8091]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7303
diff
changeset
|
514 void gaim_str_strip_cr(char *str); |
7108
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 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
517 * Given a string, this replaces one substring with another |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
518 * and returns a newly allocated string. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
519 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
520 * @param string The string from which to replace stuff. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
521 * @param delimiter The substring you want replaced. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
522 * @param replacement The substring you want inserted in place |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
523 * of the delimiting substring. |
8461 | 524 * |
525 * @return A new string, after performing the substitution. | |
526 * free this with g_free(). | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
527 */ |
8341 | 528 gchar *gaim_strreplace(const char *string, const char *delimiter, |
529 const char *replacement); | |
530 | |
531 /** | |
9171 | 532 * Given a string, this replaces any numerical character references |
533 * in that string with the corresponding actual utf-8 substrings, | |
534 * and returns a newly allocated string. | |
535 * | |
536 * @param in The string which might contain numerical character references. | |
537 * | |
538 * @return A new string, with numerical character references | |
539 * replaced with actual utf-8, free this with g_free(). | |
540 */ | |
541 char *gaim_utf8_ncr_decode(const char *in); | |
542 | |
543 /** | |
8341 | 544 * Given a string, this replaces one substring with another |
545 * ignoring case and returns a newly allocated string. | |
546 * | |
547 * @param string The string from which to replace stuff. | |
548 * @param delimiter The substring you want replaced. | |
549 * @param replacement The substring you want inserted in place | |
550 * of the delimiting substring. | |
8461 | 551 * |
552 * @return A new string, after performing the substitution. | |
553 * free this with g_free(). | |
8341 | 554 */ |
555 gchar *gaim_strcasereplace(const char *string, const char *delimiter, | |
556 const char *replacement); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
557 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
558 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
559 * This is like strstr, except that it ignores ASCII case in |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
560 * searching for the substring. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
561 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
562 * @param haystack The string to search in. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
563 * @param needle The substring to find. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
564 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
565 * @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
|
566 */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
567 const char *gaim_strcasestr(const char *haystack, const char *needle); |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
568 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
569 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
570 * Returns a string representing a filesize in the appropriate |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
571 * units (MB, KB, GB, etc.) |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
572 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
573 * @param size The size |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
574 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
575 * @return The string in units form. This must be freed. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
576 */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
577 char *gaim_str_size_to_units(size_t size); |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
578 |
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 * Converts seconds into a human-readable form. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
581 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
582 * @param sec The seconds. |
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 * @return A human-readable form, containing days, hours, minutes, and |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
585 * seconds. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
586 */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
587 char *gaim_str_seconds_to_string(guint sec); |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
588 |
9277 | 589 /** |
590 * Converts a binary string into a NUL terminated ascii string, | |
591 * replacing nonascii characters and characters below SPACE (including | |
9307 | 592 * NUL) into \\xyy, where yy are two hex digits. Also backslashes are |
593 * changed into two backslashes (\\\\). The returned, newly allocated | |
594 * string can be outputted to the console, and must be g_free()d. | |
9277 | 595 * |
596 * @param binary A string of random data, possibly with embedded NULs | |
597 * and such. | |
598 * @param len The length in bytes of the input string. Must not be 0. | |
599 * | |
600 * @return A newly allocated ASCIIZ string. | |
601 */ | |
602 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
|
603 /*@}*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
604 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
605 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
606 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
607 /** @name URI/URL Functions */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
608 /**************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
609 /*@{*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
610 |
7107
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
611 /** |
9227
9171e528d7e5
[gaim-migrate @ 10023]
Christian Hammond <chipx86@chipx86.com>
parents:
9175
diff
changeset
|
612 * 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
|
613 * |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
614 * The returned data must be freed. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
615 * |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
616 * @param url The URL to parse. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
617 * @param ret_host The returned host. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
618 * @param ret_port The returned port. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
619 * @param ret_path The returned path. |
9227
9171e528d7e5
[gaim-migrate @ 10023]
Christian Hammond <chipx86@chipx86.com>
parents:
9175
diff
changeset
|
620 * @param ret_user The returned username. |
9171e528d7e5
[gaim-migrate @ 10023]
Christian Hammond <chipx86@chipx86.com>
parents:
9175
diff
changeset
|
621 * @param ret_passwd The returned password. |
7094
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
622 */ |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
623 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
|
624 char **ret_path, char **ret_user, char **ret_passwd); |
7094
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
625 |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
626 /** |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
627 * 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
|
628 * |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
629 * @param url The URL. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
630 * @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
|
631 * partial URL. |
9284 | 632 * @param user_agent The user agent field to use, or NULL. |
633 * @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
|
634 * @param cb The callback function. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
635 * @param data The user data to pass to the callback function. |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
636 */ |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
637 void gaim_url_fetch(const char *url, gboolean full, |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
638 const char *user_agent, gboolean http11, |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
639 void (*cb)(void *, const char *, size_t), |
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
640 void *data); |
7134 | 641 /** |
642 * Decodes a URL into a plain string. | |
643 * | |
644 * This will change hex codes and such to their ascii equivalents. | |
645 * | |
646 * @param str The string to translate. | |
647 * | |
648 * @return The resulting string. | |
7162 | 649 */ |
650 const char *gaim_url_decode(const char *str); | |
7134 | 651 |
652 /** | |
653 * Encodes a URL into an escaped string. | |
654 * | |
655 * This will change non-alphanumeric characters to hex codes. | |
656 * | |
657 * @param str The string to translate. | |
658 * | |
659 * @return The resulting string. | |
660 */ | |
7162 | 661 const char *gaim_url_encode(const char *str); |
6982 | 662 |
9045 | 663 /** |
664 * Checks if the given email address is syntactically valid. | |
665 * | |
666 * @param address The email address to validate. | |
667 * | |
668 * @return True if the email address is syntactically correct. | |
669 */ | |
670 gboolean gaim_email_is_valid(const char *address); | |
671 | |
9670 | 672 /** |
673 * This function extracts a list of URIs from the a "text/uri-list" string | |
674 * It was "borrowed" from gnome_uri_list_extract_uris | |
675 * | |
676 * @param uri_list an uri-list in the standard format. | |
677 * | |
678 * @return a GList containing strings allocated with g_malloc that have been | |
679 * splitted from uri-list. | |
680 */ | |
681 GList* gaim_uri_list_extract_uris (const gchar* uri_list); | |
682 | |
683 /** | |
684 * This function extracts a list of filenames from the a "text/uri-list" string | |
685 * It was "borrowed" from gnome_uri_list_extract_filenames | |
686 * | |
687 * @param uri_list an uri-list in the standard format. | |
688 * | |
689 * @return a GList containing strings allocated with g_malloc that contain the | |
690 * filenames in the uri-list. Note that unlike gaim_uri_list_extract_uris() | |
691 * function, this will discard any non-file uri from the result value. | |
692 */ | |
693 GList* gaim_uri_list_extract_filenames (const gchar* uri_list); | |
694 | |
7108
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 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
697 /************************************************************************** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
698 * UTF8 String Functions |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
699 **************************************************************************/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
700 /*@{*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
701 |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
702 /** |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
703 * 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
|
704 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
705 * This function checks the locale and tries sane defaults. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
706 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
707 * @param str The source string. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
708 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
709 * @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
|
710 */ |
9642 | 711 gchar *gaim_utf8_try_convert(const char *str); |
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 /** |
10258 | 714 * Salvages the valid UTF-8 characters from a string, replacing any |
715 * invalid characters with a filler character (currently hardcoded to | |
716 * '?'). | |
717 * | |
718 * @param str The source string. | |
719 * | |
720 * @return A valid UTF-8 string. | |
721 */ | |
722 gchar *gaim_utf8_salvage(const char *str); | |
723 | |
724 /** | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
725 * Compares two UTF-8 strings. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
726 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
727 * @param a The first string. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
728 * @param b The second string. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
729 * |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
730 * @return -1 if @a is less than @a b. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
731 * 0 if @a is equal to @a b. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
732 * 1 if @a is greater than @a b. |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
733 */ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
734 int gaim_utf8_strcasecmp(const char *a, const char *b); |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
735 |
7564 | 736 /** |
737 * Checks for messages starting with "/me " | |
738 * | |
739 * @param message The message to check | |
740 * @param len The message length, or -1 | |
741 * | |
742 * @return TRUE if it starts with /me, and it has been removed, otherwise FALSE | |
743 */ | |
744 gboolean gaim_message_meify(char *message, size_t len); | |
745 | |
7889 | 746 /** |
747 * Removes the underscore characters from a string used identify the mnemonic | |
748 * character. | |
749 * | |
750 * @param in The string to strip | |
751 * | |
752 * @return The stripped string | |
753 */ | |
8432
33cc36f5a7a6
[gaim-migrate @ 9162]
Christian Hammond <chipx86@chipx86.com>
parents:
8341
diff
changeset
|
754 char *gaim_text_strip_mnemonic(const char *in); |
7889 | 755 |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
756 /*@}*/ |
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
757 |
8432
33cc36f5a7a6
[gaim-migrate @ 9162]
Christian Hammond <chipx86@chipx86.com>
parents:
8341
diff
changeset
|
758 /** |
33cc36f5a7a6
[gaim-migrate @ 9162]
Christian Hammond <chipx86@chipx86.com>
parents:
8341
diff
changeset
|
759 * Adds 8 to something. |
33cc36f5a7a6
[gaim-migrate @ 9162]
Christian Hammond <chipx86@chipx86.com>
parents:
8341
diff
changeset
|
760 * |
33cc36f5a7a6
[gaim-migrate @ 9162]
Christian Hammond <chipx86@chipx86.com>
parents:
8341
diff
changeset
|
761 * Blame SimGuy. |
33cc36f5a7a6
[gaim-migrate @ 9162]
Christian Hammond <chipx86@chipx86.com>
parents:
8341
diff
changeset
|
762 * |
9000 | 763 * @param x The number to add 8 to. |
8432
33cc36f5a7a6
[gaim-migrate @ 9162]
Christian Hammond <chipx86@chipx86.com>
parents:
8341
diff
changeset
|
764 * |
9000 | 765 * @return x + 8 |
8432
33cc36f5a7a6
[gaim-migrate @ 9162]
Christian Hammond <chipx86@chipx86.com>
parents:
8341
diff
changeset
|
766 */ |
8433 | 767 #define gaim_add_eight(x) ((x)+8) |
8432
33cc36f5a7a6
[gaim-migrate @ 9162]
Christian Hammond <chipx86@chipx86.com>
parents:
8341
diff
changeset
|
768 |
9926 | 769 /** |
770 * Does the reverse of gaim_escape_filename | |
771 * | |
772 * This will change hex codes and such to their ascii equivalents. | |
773 * | |
774 * @param str The string to translate. | |
775 * | |
776 * @return The resulting string. | |
777 */ | |
778 const char *gaim_unescape_filename(const char *str); | |
779 | |
780 /** | |
781 * Escapes filesystem-unfriendly characters from a filename | |
782 * | |
783 * @param str The string to translate. | |
784 * | |
785 * @return The resulting string. | |
786 */ | |
787 const char *gaim_escape_filename(const char *str); | |
788 | |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
789 #ifdef __cplusplus |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
790 } |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
791 #endif |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
792 |
4890 | 793 #endif /* _GAIM_UTIL_H_ */ |