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