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