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