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