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