Thu, 02 Sep 2004 19:01:33 +0000
[gaim-migrate @ 10831]
More doc cleanups from Gary
committer: Ethan Blanton <elb@pidgin.im>
| 4890 | 1 | /** |
| 2 | * @file util.h Utility Functions | |
|
5034
077678f7b048
[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
8f9588491993
[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
12d3fe5e5b1b
[gaim-migrate @ 6983]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
31 | #include <stdio.h> |
|
12d3fe5e5b1b
[gaim-migrate @ 6983]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
32 | |
|
5563
d5a7852aa0cb
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5532
diff
changeset
|
33 | #include "account.h" |
|
d5a7852aa0cb
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5532
diff
changeset
|
34 | |
|
5944
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
35 | #ifdef __cplusplus |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
36 | extern "C" { |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
37 | #endif |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
38 | |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
39 | /**************************************************************************/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
40 | /** @name Base16 Functions */ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
41 | /**************************************************************************/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
42 | /*@{*/ |
| 4890 | 43 | |
| 44 | /** | |
| 45 | * Converts a string to its base-16 equivalent. | |
| 46 | * | |
| 47 | * @param str The string to convert. | |
| 48 | * @param len The length of the string. | |
| 49 | * | |
| 50 | * @return The base-16 string. | |
| 51 | * | |
|
7123
a308c150e74a
[gaim-migrate @ 7690]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
52 | * @see gaim_base16_decode() |
| 4890 | 53 | */ |
|
7106
eaeff5775818
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7105
diff
changeset
|
54 | unsigned char *gaim_base16_encode(const unsigned char *str, int len); |
| 4890 | 55 | |
| 56 | /** | |
| 57 | * Converts a string back from its base-16 equivalent. | |
| 58 | * | |
| 59 | * @param str The string to convert back. | |
| 60 | * @param ret_str The returned, non-base-16 string. | |
| 5451 | 61 | * |
| 4890 | 62 | * @return The length of the returned string. |
| 63 | * | |
|
7123
a308c150e74a
[gaim-migrate @ 7690]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
64 | * @see gaim_base16_encode() |
| 4890 | 65 | */ |
|
7106
eaeff5775818
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7105
diff
changeset
|
66 | int gaim_base16_decode(const char *str, unsigned char **ret_str); |
| 4890 | 67 | |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
68 | /*@}*/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
69 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
70 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
71 | /**************************************************************************/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
72 | /** @name Base64 Functions */ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
73 | /**************************************************************************/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
74 | /*@{*/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
75 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
76 | /** |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
77 | * Converts a string to its base-64 equivalent. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
78 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
79 | * @param buf The data to convert. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
80 | * @param len The length of the data. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
81 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
82 | * @return The base-64 version of @a str. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
83 | * |
|
7123
a308c150e74a
[gaim-migrate @ 7690]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
84 | * @see gaim_base64_decode() |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
85 | */ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
86 | unsigned char *gaim_base64_encode(const unsigned char *buf, size_t len); |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
87 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
88 | /** |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
89 | * Converts a string back from its base-64 equivalent. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
90 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
91 | * @param str The string to convert back. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
92 | * @param ret_str The returned, non-base-64 string. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
93 | * @param ret_len The returned string length. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
94 | * |
|
7123
a308c150e74a
[gaim-migrate @ 7690]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
95 | * @see gaim_base64_encode() |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
96 | */ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
97 | void gaim_base64_decode(const char *str, char **ret_str, int *ret_len); |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
98 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
99 | /*@}*/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
100 | |
|
7679
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
101 | /**************************************************************************/ |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
102 | /** @name Quoted Printable Functions */ |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
103 | /**************************************************************************/ |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
104 | /*@{*/ |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
105 | |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
106 | /** |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
107 | * Converts a quoted printable string back to its readable equivalent. |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
108 | * |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
109 | * @param str The string to convert back. |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
110 | * @param ret_str The returned, readable string. |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
111 | * @param ret_len The returned string length. |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
112 | */ |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
113 | void gaim_quotedp_decode (const char *str, char **ret_str, int *ret_len); |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
114 | |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
115 | /*@}*/ |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
116 | |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
117 | /**************************************************************************/ |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
118 | /** @name MIME Functions */ |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
119 | /**************************************************************************/ |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
120 | /*@{*/ |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
121 | |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
122 | /** |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
123 | * Converts a MIME header field string back to its readable equivalent |
| 8432 | 124 | * according to RFC 2047. Basically, a header is plain ASCII and can |
| 125 | * contain any number of sections called "encoded-words." The format | |
|
7821
d15fc781c318
[gaim-migrate @ 8473]
Mark Doliner <markdoliner@pidgin.im>
parents:
7679
diff
changeset
|
126 | * of an encoded word is =?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= |
|
d15fc781c318
[gaim-migrate @ 8473]
Mark Doliner <markdoliner@pidgin.im>
parents:
7679
diff
changeset
|
127 | * =? designates the beginning of the encoded-word |
|
d15fc781c318
[gaim-migrate @ 8473]
Mark Doliner <markdoliner@pidgin.im>
parents:
7679
diff
changeset
|
128 | * ?= designates the end of the encoded-word |
| 8432 | 129 | * ? segments the encoded word into three pieces. The first piece is |
|
8735
01248ea222d3
[gaim-migrate @ 9490]
Jonathan Champ <royanee@users.sourceforge.net>
parents:
8700
diff
changeset
|
130 | * the character set, the second piece is the encoding, and the |
|
7821
d15fc781c318
[gaim-migrate @ 8473]
Mark Doliner <markdoliner@pidgin.im>
parents:
7679
diff
changeset
|
131 | * third piece is the encoded text. |
|
7679
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
132 | * |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
133 | * @param str The string to convert back. |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
134 | * |
|
8735
01248ea222d3
[gaim-migrate @ 9490]
Jonathan Champ <royanee@users.sourceforge.net>
parents:
8700
diff
changeset
|
135 | * @return The readable string. |
|
7679
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
136 | */ |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
137 | char *gaim_mime_decode_field (const char *str); |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
138 | |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
139 | /*@}*/ |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
140 | |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
141 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
142 | /**************************************************************************/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
143 | /** @name Date/Time Functions */ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
144 | /**************************************************************************/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
145 | /*@{*/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
146 | |
| 4890 | 147 | /** |
| 148 | * Returns the current local time in hour:minute:second form. | |
| 149 | * | |
| 150 | * The returned string is stored in a static buffer, so the result | |
| 151 | * should be g_strdup()'d if it's intended to be used for long. | |
| 152 | * | |
| 153 | * @return The current local time. | |
| 154 | * | |
|
7123
a308c150e74a
[gaim-migrate @ 7690]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
155 | * @see gaim_date_full() |
| 4890 | 156 | */ |
| 7162 | 157 | const char *gaim_date(void); |
| 4890 | 158 | |
| 159 | /** | |
| 160 | * Returns the date and time in human-readable form. | |
| 161 | * | |
| 162 | * The returned string is stored in a static buffer, so the result | |
| 163 | * should be g_strdup()'d if it's intended to be used for long. | |
| 164 | * | |
| 165 | * @return The date and time in human-readable form. | |
| 166 | * | |
|
7123
a308c150e74a
[gaim-migrate @ 7690]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
167 | * @see gaim_date() |
| 4890 | 168 | */ |
| 7162 | 169 | const char *gaim_date_full(void); |
| 4890 | 170 | |
| 171 | /** | |
| 172 | * Builds a time_t from the supplied information. | |
| 173 | * | |
| 174 | * @param year The year. | |
| 175 | * @param month The month. | |
| 176 | * @param day The day. | |
| 177 | * @param hour The hour. | |
| 178 | * @param min The minute. | |
| 179 | * @param sec The second. | |
| 180 | * | |
| 181 | * @return A time_t. | |
| 182 | */ | |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
183 | time_t gaim_time_build(int year, int month, int day, int hour, |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
184 | int min, int sec); |
| 4890 | 185 | |
| 8577 | 186 | /** |
| 187 | * Parses a timestamp in jabber or ISO8601 format and returns a time_t. | |
| 188 | * | |
| 189 | * @param timestamp The timestamp | |
| 190 | * @param utc Assume UTC if no timezone specified | |
| 191 | * | |
| 192 | * @return A time_t. | |
| 193 | */ | |
| 194 | time_t gaim_str_to_time(const char *timestamp, gboolean utc); | |
| 195 | ||
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
196 | /*@}*/ |
| 4890 | 197 | |
| 198 | ||
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
199 | /**************************************************************************/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
200 | /** @name Markup Functions */ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
201 | /**************************************************************************/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
202 | /*@{*/ |
| 5826 | 203 | |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6861
diff
changeset
|
204 | /** |
|
7094
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
205 | * Finds a HTML tag matching the given name. |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
206 | * |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
207 | * This locates an HTML tag's start and end, and stores its attributes |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
208 | * in a GData hash table. The names of the attributes are lower-cased |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
209 | * in the hash table, and the name of the tag is case insensitive. |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6861
diff
changeset
|
210 | * |
|
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6861
diff
changeset
|
211 | * @param needle the name of the tag |
|
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6861
diff
changeset
|
212 | * @param haystack the null-delimited string to search in |
|
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6861
diff
changeset
|
213 | * @param start a pointer to the start of the tag if found |
|
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6861
diff
changeset
|
214 | * @param end a pointer to the end of the tag if found |
|
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6861
diff
changeset
|
215 | * @param attributes the attributes, if the tag was found |
|
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6861
diff
changeset
|
216 | * @return TRUE if the tag was found |
|
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6861
diff
changeset
|
217 | */ |
|
7094
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
218 | gboolean gaim_markup_find_tag(const char *needle, const char *haystack, |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
219 | const char **start, const char **end, |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
220 | GData **attributes); |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
221 | |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
222 | /** |
|
7095
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
223 | * Extracts a field of data from HTML. |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
224 | * |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
225 | * This is a scary function. See protocols/msn/msn.c and |
| 9175 | 226 | * protocols/yahoo/yahoo_profile.c for example usage. |
|
7095
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
227 | * |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
228 | * @param str The string to parse. |
| 7675 | 229 | * @param len The size of str. |
| 230 | * @param dest The destination GString to append the new | |
|
7095
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
231 | * field info to. |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
232 | * @param start_token The beginning token. |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
233 | * @param skip The number of characters to skip after the |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
234 | * start token. |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
235 | * @param end_token The ending token. |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
236 | * @param check_value The value that the last character must meet. |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
237 | * @param no_value_token The token indicating no value is given. |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
238 | * @param display_name The short descriptive name to display for this token. |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
239 | * @param is_link TRUE if this should be a link, or FALSE otherwise. |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
240 | * @param link_prefix The prefix for the link. |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
241 | * |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
242 | * @return TRUE if successful, or FALSE otherwise. |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
243 | */ |
| 7675 | 244 | gboolean gaim_markup_extract_info_field(const char *str, int len, GString *dest, |
| 245 | const char *start_token, int skip, | |
| 246 | const char *end_token, char check_value, | |
| 247 | const char *no_value_token, | |
| 248 | const char *display_name, gboolean is_link, | |
| 249 | const char *link_prefix); | |
|
7095
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
250 | |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
251 | /** |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
252 | * Converts HTML markup to XHTML. |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
253 | * |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
254 | * @param html The HTML markup. |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
255 | * @param dest_xhtml The destination XHTML output. |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
256 | * @param dest_plain The destination plain-text output. |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
257 | */ |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
258 | void gaim_markup_html_to_xhtml(const char *html, char **dest_xhtml, |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
259 | char **dest_plain); |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
260 | |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
261 | /** |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
262 | * Strips HTML tags from a string. |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
263 | * |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
264 | * @param str The string to strip HTML from. |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
265 | * |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
266 | * @return The new string without HTML. This must be freed. |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
267 | */ |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
268 | char *gaim_markup_strip_html(const char *str); |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
269 | |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
270 | /** |
|
7107
903864ff76c3
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
271 | * Adds the necessary HTML code to turn URIs into HTML links in a string. |
|
903864ff76c3
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
272 | * |
|
903864ff76c3
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
273 | * @param str The string to linkify. |
|
903864ff76c3
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
274 | * |
|
903864ff76c3
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
275 | * @return The linkified text. |
|
903864ff76c3
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
276 | */ |
|
903864ff76c3
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
277 | char *gaim_markup_linkify(const char *str); |
|
903864ff76c3
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
278 | |
| 8163 | 279 | /** |
| 280 | * Escapes HTML special characters to be displayed literally. | |
| 281 | * For example '&' is replaced by "&" and so on | |
| 282 | * | |
| 283 | * @param html The string in which to escape any HTML special characters | |
| 284 | * | |
| 285 | * @return the text with HTML special characters escaped | |
| 286 | */ | |
| 287 | char *gaim_escape_html(const char *html); | |
| 288 | ||
| 8442 | 289 | /** |
| 290 | * Unescapes HTML entities to their literal characters. | |
| 291 | * For example "&" is replaced by '&' and so on. | |
| 292 | * Actually only "&", """, "<" and ">" are currently | |
| 293 | * supported. | |
| 294 | * | |
| 295 | * @param html The string in which to unescape any HTML entities | |
| 296 | * | |
| 297 | * @return the text with HTML entities literalized | |
| 298 | */ | |
| 299 | char *gaim_unescape_html(const char *html); | |
| 300 | ||
| 9175 | 301 | /** |
| 302 | * Returns a newly allocated substring of the HTML UTF-8 string "str". | |
| 303 | * The markup is preserved such that the substring will have the same | |
| 304 | * formatting as original string, even though some tags may have been | |
| 305 | * opened before "x", or may close after "y". All open tags are closed | |
| 306 | * at the end of the returned string, in the proper order. | |
| 307 | * | |
| 308 | * Note that x and y are in character offsets, not byte offsets, and | |
| 309 | * are offsets into an unformatted version of str. Because of this, | |
| 310 | * this function may be sensitive to changes in GtkIMHtml and may break | |
| 311 | * when used with other UI's. libgaim users are encouraged to report and | |
| 312 | * work out any problems encountered. | |
| 313 | * | |
| 314 | * @param str The input NUL terminated, HTML, UTF-8 (or ASCII) string. | |
| 315 | * @param x The character offset into an unformatted version of str to | |
| 316 | * begin at. | |
| 317 | * @param y The character offset (into an unformatted vesion of str) of | |
| 318 | * one past the last character to include in the slice. | |
| 319 | * | |
| 320 | * @return The HTML slice of string, with all formatting retained. | |
| 321 | */ | |
| 322 | char *gaim_markup_slice(const char *str, guint x, guint y); | |
| 323 | ||
| 324 | /** | |
| 325 | * Returns a newly allocated string containing the name of the tag | |
| 326 | * located at "tag". Tag is expected to point to a '<', and contain | |
| 327 | * a '>' sometime after that. If there is no '>' and the string is | |
| 328 | * not NUL terminated, this function can be expected to segfault. | |
| 329 | * | |
| 330 | * @param tag The string starting a HTML tag. | |
| 331 | * @return A string containing the name of the tag. | |
| 332 | */ | |
| 333 | char *gaim_markup_get_tag_name(const char *tag); | |
| 334 | ||
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
335 | /*@}*/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
336 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
337 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
338 | /**************************************************************************/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
339 | /** @name Path/Filename Functions */ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
340 | /**************************************************************************/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
341 | /*@{*/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
342 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
343 | /** |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
344 | * Returns the user's home directory. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
345 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
346 | * @return The user's home directory. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
347 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
348 | * @see gaim_user_dir() |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
349 | */ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
350 | const gchar *gaim_home_dir(void); |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
351 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
352 | /** |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
353 | * Returns the gaim settings directory in the user's home directory. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
354 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
355 | * @return The gaim settings directory. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
356 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
357 | * @see gaim_home_dir() |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
358 | */ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
359 | char *gaim_user_dir(void); |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
360 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
361 | /** |
| 8596 | 362 | * Define a custom gaim settings directory, overriding the default (user's home directory/.gaim) |
| 363 | * @param dir The custom settings directory | |
| 364 | */ | |
| 365 | void set_gaim_user_dir(const char *dir); | |
| 366 | ||
| 367 | /** | |
| 7612 | 368 | * Builds a complete path from the root, making any directories along |
| 369 | * the path which do not already exist. | |
| 7622 | 370 | * |
| 7612 | 371 | * @param path The path you wish to create. Note that it must start |
| 372 | * from the root or this function will fail. | |
| 373 | * @param mode Unix-style permissions for this directory. | |
| 7622 | 374 | * |
| 7612 | 375 | * @return 0 for success, nonzero on any error. |
| 376 | */ | |
| 7622 | 377 | int gaim_build_dir(const char *path, int mode); |
| 7612 | 378 | |
| 379 | /** | |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
380 | * Creates a temporary file and returns a file pointer to it. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
381 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
382 | * This is like mkstemp(), but returns a file pointer and uses a |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
383 | * pre-set template. It uses the semantics of tempnam() for the |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
384 | * directory to use and allocates the space for the file path. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
385 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
386 | * The caller is responsible for closing the file and removing it when |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
387 | * done, as well as freeing the space pointed to by @a path with |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
388 | * g_free(). |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
389 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
390 | * @param path The returned path to the temp file. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
391 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
392 | * @return A file pointer to the temporary file, or @c NULL on failure. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
393 | */ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
394 | FILE *gaim_mkstemp(char **path); |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
395 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
396 | /** |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
397 | * Checks if the given program name is valid and executable. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
398 | * |
|
7303
b7b02c31b5bb
[gaim-migrate @ 7887]
Christian Hammond <chipx86@chipx86.com>
parents:
7261
diff
changeset
|
399 | * @param program The file name of the application. |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
400 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
401 | * @return True if the program is runable. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
402 | */ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
403 | gboolean gaim_program_is_valid(const char *program); |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
404 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
405 | /** |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
406 | * Returns the IP address from a socket file descriptor. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
407 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
408 | * @param fd The socket file descriptor. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
409 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
410 | * @return The IP address, or @c NULL on error. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
411 | */ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
412 | char *gaim_fd_get_ip(int fd); |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
413 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
414 | /*@}*/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
415 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
416 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
417 | /**************************************************************************/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
418 | /** @name String Functions */ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
419 | /**************************************************************************/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
420 | /*@{*/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
421 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
422 | /** |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
423 | * Normalizes a string, so that it is suitable for comparison. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
424 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
425 | * The returned string will point to a static buffer, so if the |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
426 | * string is intended to be kept long-term, you <i>must</i> |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
427 | * g_strdup() it. Also, calling normalize() twice in the same line |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
428 | * will lead to problems. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
429 | * |
| 7261 | 430 | * @param account The account the string belongs to. |
| 431 | * @param str The string to normalize. | |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
432 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
433 | * @return A pointer to the normalized version stored in a static buffer. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
434 | */ |
| 7261 | 435 | const char *gaim_normalize(const GaimAccount *account, const char *str); |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
436 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
437 | /** |
| 7628 | 438 | * Compares two strings to see if the first contains the second as |
| 439 | * a proper prefix. | |
| 8432 | 440 | * |
| 7628 | 441 | * @param s The string to check. |
| 442 | * @param p The prefix in question. | |
| 8432 | 443 | * |
| 7628 | 444 | * @return TRUE if p is a prefix of s, otherwise FALSE. |
| 445 | */ | |
| 446 | gboolean gaim_str_has_prefix(const char *s, const char *p); | |
| 447 | ||
| 448 | /** | |
| 449 | * Compares two strings to see if the second is a proper suffix | |
| 450 | * of the first. | |
| 8432 | 451 | * |
| 7628 | 452 | * @param s The string to check. |
| 453 | * @param x The suffix in question. | |
| 8432 | 454 | * |
| 7628 | 455 | * @return TRUE if x is a a suffix of s, otherwise FALSE. |
| 456 | */ | |
| 457 | gboolean gaim_str_has_suffix(const char *s, const char *x); | |
| 458 | ||
| 459 | /** | |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
460 | * Looks for %n, %d, or %t in a string, and replaces them with the |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
461 | * specified name, date, and time, respectively. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
462 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
463 | * @param str The string that may contain the special variables. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
464 | * @param name The sender name. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
465 | * |
|
8700
0c9288c5e40e
[gaim-migrate @ 9453]
Mark Doliner <markdoliner@pidgin.im>
parents:
8596
diff
changeset
|
466 | * @return A newly allocated string where the special variables are |
|
0c9288c5e40e
[gaim-migrate @ 9453]
Mark Doliner <markdoliner@pidgin.im>
parents:
8596
diff
changeset
|
467 | * expanded. This should be g_free'd by the caller. |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
468 | */ |
|
8700
0c9288c5e40e
[gaim-migrate @ 9453]
Mark Doliner <markdoliner@pidgin.im>
parents:
8596
diff
changeset
|
469 | gchar *gaim_str_sub_away_formatters(const char *str, const char *name); |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
470 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
471 | /** |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
472 | * Duplicates a string and replaces all newline characters from the |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
473 | * source string with HTML linebreaks. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
474 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
475 | * @param src The source string. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
476 | * |
|
8341
dc43b1acfc1a
[gaim-migrate @ 9065]
Mark Doliner <markdoliner@pidgin.im>
parents:
8163
diff
changeset
|
477 | * @return The new string. Must be g_free'd by the caller. |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
478 | */ |
|
8341
dc43b1acfc1a
[gaim-migrate @ 9065]
Mark Doliner <markdoliner@pidgin.im>
parents:
8163
diff
changeset
|
479 | gchar *gaim_strdup_withhtml(const gchar *src); |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
480 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
481 | /** |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
482 | * Ensures that all linefeeds have a matching carriage return. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
483 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
484 | * @param str The source string. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
485 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
486 | * @return The string with carriage returns. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
487 | */ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
488 | char *gaim_str_add_cr(const char *str); |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
489 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
490 | /** |
|
7478
a7df4df98778
[gaim-migrate @ 8091]
Herman Bloggs <herman@bluedigits.com>
parents:
7303
diff
changeset
|
491 | * Strips all carriage returns from a string. |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
492 | * |
|
7478
a7df4df98778
[gaim-migrate @ 8091]
Herman Bloggs <herman@bluedigits.com>
parents:
7303
diff
changeset
|
493 | * @param str The string to strip carriage returns from. |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
494 | */ |
|
7478
a7df4df98778
[gaim-migrate @ 8091]
Herman Bloggs <herman@bluedigits.com>
parents:
7303
diff
changeset
|
495 | void gaim_str_strip_cr(char *str); |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
496 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
497 | /** |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
498 | * Given a string, this replaces one substring with another |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
499 | * and returns a newly allocated string. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
500 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
501 | * @param string The string from which to replace stuff. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
502 | * @param delimiter The substring you want replaced. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
503 | * @param replacement The substring you want inserted in place |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
504 | * of the delimiting substring. |
|
8461
920171a59e45
[gaim-migrate @ 9191]
Mark Doliner <markdoliner@pidgin.im>
parents:
8442
diff
changeset
|
505 | * |
|
920171a59e45
[gaim-migrate @ 9191]
Mark Doliner <markdoliner@pidgin.im>
parents:
8442
diff
changeset
|
506 | * @return A new string, after performing the substitution. |
|
920171a59e45
[gaim-migrate @ 9191]
Mark Doliner <markdoliner@pidgin.im>
parents:
8442
diff
changeset
|
507 | * free this with g_free(). |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
508 | */ |
|
8341
dc43b1acfc1a
[gaim-migrate @ 9065]
Mark Doliner <markdoliner@pidgin.im>
parents:
8163
diff
changeset
|
509 | gchar *gaim_strreplace(const char *string, const char *delimiter, |
|
dc43b1acfc1a
[gaim-migrate @ 9065]
Mark Doliner <markdoliner@pidgin.im>
parents:
8163
diff
changeset
|
510 | const char *replacement); |
|
dc43b1acfc1a
[gaim-migrate @ 9065]
Mark Doliner <markdoliner@pidgin.im>
parents:
8163
diff
changeset
|
511 | |
|
dc43b1acfc1a
[gaim-migrate @ 9065]
Mark Doliner <markdoliner@pidgin.im>
parents:
8163
diff
changeset
|
512 | /** |
| 9171 | 513 | * Given a string, this replaces any numerical character references |
| 514 | * in that string with the corresponding actual utf-8 substrings, | |
| 515 | * and returns a newly allocated string. | |
| 516 | * | |
| 517 | * @param in The string which might contain numerical character references. | |
| 518 | * | |
| 519 | * @return A new string, with numerical character references | |
| 520 | * replaced with actual utf-8, free this with g_free(). | |
| 521 | */ | |
| 522 | char *gaim_utf8_ncr_decode(const char *in); | |
| 523 | ||
| 524 | /** | |
|
8341
dc43b1acfc1a
[gaim-migrate @ 9065]
Mark Doliner <markdoliner@pidgin.im>
parents:
8163
diff
changeset
|
525 | * Given a string, this replaces one substring with another |
|
dc43b1acfc1a
[gaim-migrate @ 9065]
Mark Doliner <markdoliner@pidgin.im>
parents:
8163
diff
changeset
|
526 | * ignoring case and returns a newly allocated string. |
|
dc43b1acfc1a
[gaim-migrate @ 9065]
Mark Doliner <markdoliner@pidgin.im>
parents:
8163
diff
changeset
|
527 | * |
|
dc43b1acfc1a
[gaim-migrate @ 9065]
Mark Doliner <markdoliner@pidgin.im>
parents:
8163
diff
changeset
|
528 | * @param string The string from which to replace stuff. |
|
dc43b1acfc1a
[gaim-migrate @ 9065]
Mark Doliner <markdoliner@pidgin.im>
parents:
8163
diff
changeset
|
529 | * @param delimiter The substring you want replaced. |
|
dc43b1acfc1a
[gaim-migrate @ 9065]
Mark Doliner <markdoliner@pidgin.im>
parents:
8163
diff
changeset
|
530 | * @param replacement The substring you want inserted in place |
|
dc43b1acfc1a
[gaim-migrate @ 9065]
Mark Doliner <markdoliner@pidgin.im>
parents:
8163
diff
changeset
|
531 | * of the delimiting substring. |
|
8461
920171a59e45
[gaim-migrate @ 9191]
Mark Doliner <markdoliner@pidgin.im>
parents:
8442
diff
changeset
|
532 | * |
|
920171a59e45
[gaim-migrate @ 9191]
Mark Doliner <markdoliner@pidgin.im>
parents:
8442
diff
changeset
|
533 | * @return A new string, after performing the substitution. |
|
920171a59e45
[gaim-migrate @ 9191]
Mark Doliner <markdoliner@pidgin.im>
parents:
8442
diff
changeset
|
534 | * free this with g_free(). |
|
8341
dc43b1acfc1a
[gaim-migrate @ 9065]
Mark Doliner <markdoliner@pidgin.im>
parents:
8163
diff
changeset
|
535 | */ |
|
dc43b1acfc1a
[gaim-migrate @ 9065]
Mark Doliner <markdoliner@pidgin.im>
parents:
8163
diff
changeset
|
536 | gchar *gaim_strcasereplace(const char *string, const char *delimiter, |
|
dc43b1acfc1a
[gaim-migrate @ 9065]
Mark Doliner <markdoliner@pidgin.im>
parents:
8163
diff
changeset
|
537 | const char *replacement); |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
538 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
539 | /** |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
540 | * This is like strstr, except that it ignores ASCII case in |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
541 | * searching for the substring. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
542 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
543 | * @param haystack The string to search in. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
544 | * @param needle The substring to find. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
545 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
546 | * @return the location of the substring if found, or NULL if not |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
547 | */ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
548 | const char *gaim_strcasestr(const char *haystack, const char *needle); |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
549 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
550 | /** |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
551 | * Returns a string representing a filesize in the appropriate |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
552 | * units (MB, KB, GB, etc.) |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
553 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
554 | * @param size The size |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
555 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
556 | * @return The string in units form. This must be freed. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
557 | */ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
558 | char *gaim_str_size_to_units(size_t size); |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
559 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
560 | /** |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
561 | * Converts seconds into a human-readable form. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
562 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
563 | * @param sec The seconds. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
564 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
565 | * @return A human-readable form, containing days, hours, minutes, and |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
566 | * seconds. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
567 | */ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
568 | char *gaim_str_seconds_to_string(guint sec); |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
569 | |
| 9277 | 570 | /** |
| 571 | * Converts a binary string into a NUL terminated ascii string, | |
| 572 | * replacing nonascii characters and characters below SPACE (including | |
| 9307 | 573 | * NUL) into \\xyy, where yy are two hex digits. Also backslashes are |
| 574 | * changed into two backslashes (\\\\). The returned, newly allocated | |
| 575 | * string can be outputted to the console, and must be g_free()d. | |
| 9277 | 576 | * |
| 577 | * @param binary A string of random data, possibly with embedded NULs | |
| 578 | * and such. | |
| 579 | * @param len The length in bytes of the input string. Must not be 0. | |
| 580 | * | |
| 581 | * @return A newly allocated ASCIIZ string. | |
| 582 | */ | |
| 583 | char *gaim_str_binary_to_ascii(const unsigned char *binary, guint len); | |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
584 | /*@}*/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
585 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
586 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
587 | /**************************************************************************/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
588 | /** @name URI/URL Functions */ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
589 | /**************************************************************************/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
590 | /*@{*/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
591 | |
|
7107
903864ff76c3
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
592 | /** |
| 9227 | 593 | * Parses a URL, returning its host, port, file path, username and password. |
|
7094
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
594 | * |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
595 | * The returned data must be freed. |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
596 | * |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
597 | * @param url The URL to parse. |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
598 | * @param ret_host The returned host. |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
599 | * @param ret_port The returned port. |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
600 | * @param ret_path The returned path. |
| 9227 | 601 | * @param ret_user The returned username. |
| 602 | * @param ret_passwd The returned password. | |
|
7094
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
603 | */ |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
604 | gboolean gaim_url_parse(const char *url, char **ret_host, int *ret_port, |
| 9227 | 605 | char **ret_path, char **ret_user, char **ret_passwd); |
|
7094
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
606 | |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
607 | /** |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
608 | * Fetches the data from a URL, and passes it to a callback function. |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
609 | * |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
610 | * @param url The URL. |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
611 | * @param full TRUE if this is the full URL, or FALSE if it's a |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
612 | * partial URL. |
| 9284 | 613 | * @param user_agent The user agent field to use, or NULL. |
| 614 | * @param http11 TRUE if HTTP/1.1 should be used to download the file. | |
|
7094
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
615 | * @param cb The callback function. |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
616 | * @param data The user data to pass to the callback function. |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
617 | */ |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
618 | void gaim_url_fetch(const char *url, gboolean full, |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
619 | const char *user_agent, gboolean http11, |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
620 | void (*cb)(void *, const char *, size_t), |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
621 | void *data); |
| 7134 | 622 | /** |
| 623 | * Decodes a URL into a plain string. | |
| 624 | * | |
| 625 | * This will change hex codes and such to their ascii equivalents. | |
| 626 | * | |
| 627 | * @param str The string to translate. | |
| 628 | * | |
| 629 | * @return The resulting string. | |
| 7162 | 630 | */ |
| 631 | const char *gaim_url_decode(const char *str); | |
| 7134 | 632 | |
| 633 | /** | |
| 634 | * Encodes a URL into an escaped string. | |
| 635 | * | |
| 636 | * This will change non-alphanumeric characters to hex codes. | |
| 637 | * | |
| 638 | * @param str The string to translate. | |
| 639 | * | |
| 640 | * @return The resulting string. | |
| 641 | */ | |
| 7162 | 642 | const char *gaim_url_encode(const char *str); |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6861
diff
changeset
|
643 | |
| 9045 | 644 | /** |
| 645 | * Checks if the given email address is syntactically valid. | |
| 646 | * | |
| 647 | * @param address The email address to validate. | |
| 648 | * | |
| 649 | * @return True if the email address is syntactically correct. | |
| 650 | */ | |
| 651 | gboolean gaim_email_is_valid(const char *address); | |
| 652 | ||
|
9670
4e8cb7ef72ab
[gaim-migrate @ 10522]
Daniel Atallah <datallah@pidgin.im>
parents:
9642
diff
changeset
|
653 | /** |
|
4e8cb7ef72ab
[gaim-migrate @ 10522]
Daniel Atallah <datallah@pidgin.im>
parents:
9642
diff
changeset
|
654 | * This function extracts a list of URIs from the a "text/uri-list" string |
|
4e8cb7ef72ab
[gaim-migrate @ 10522]
Daniel Atallah <datallah@pidgin.im>
parents:
9642
diff
changeset
|
655 | * It was "borrowed" from gnome_uri_list_extract_uris |
|
4e8cb7ef72ab
[gaim-migrate @ 10522]
Daniel Atallah <datallah@pidgin.im>
parents:
9642
diff
changeset
|
656 | * |
|
4e8cb7ef72ab
[gaim-migrate @ 10522]
Daniel Atallah <datallah@pidgin.im>
parents:
9642
diff
changeset
|
657 | * @param uri_list an uri-list in the standard format. |
|
4e8cb7ef72ab
[gaim-migrate @ 10522]
Daniel Atallah <datallah@pidgin.im>
parents:
9642
diff
changeset
|
658 | * |
|
4e8cb7ef72ab
[gaim-migrate @ 10522]
Daniel Atallah <datallah@pidgin.im>
parents:
9642
diff
changeset
|
659 | * @return a GList containing strings allocated with g_malloc that have been |
|
4e8cb7ef72ab
[gaim-migrate @ 10522]
Daniel Atallah <datallah@pidgin.im>
parents:
9642
diff
changeset
|
660 | * splitted from uri-list. |
|
4e8cb7ef72ab
[gaim-migrate @ 10522]
Daniel Atallah <datallah@pidgin.im>
parents:
9642
diff
changeset
|
661 | */ |
|
4e8cb7ef72ab
[gaim-migrate @ 10522]
Daniel Atallah <datallah@pidgin.im>
parents:
9642
diff
changeset
|
662 | GList* gaim_uri_list_extract_uris (const gchar* uri_list); |
|
4e8cb7ef72ab
[gaim-migrate @ 10522]
Daniel Atallah <datallah@pidgin.im>
parents:
9642
diff
changeset
|
663 | |
|
4e8cb7ef72ab
[gaim-migrate @ 10522]
Daniel Atallah <datallah@pidgin.im>
parents:
9642
diff
changeset
|
664 | /** |
|
4e8cb7ef72ab
[gaim-migrate @ 10522]
Daniel Atallah <datallah@pidgin.im>
parents:
9642
diff
changeset
|
665 | * This function extracts a list of filenames from the a "text/uri-list" string |
|
4e8cb7ef72ab
[gaim-migrate @ 10522]
Daniel Atallah <datallah@pidgin.im>
parents:
9642
diff
changeset
|
666 | * It was "borrowed" from gnome_uri_list_extract_filenames |
|
4e8cb7ef72ab
[gaim-migrate @ 10522]
Daniel Atallah <datallah@pidgin.im>
parents:
9642
diff
changeset
|
667 | * |
|
4e8cb7ef72ab
[gaim-migrate @ 10522]
Daniel Atallah <datallah@pidgin.im>
parents:
9642
diff
changeset
|
668 | * @param uri_list an uri-list in the standard format. |
|
4e8cb7ef72ab
[gaim-migrate @ 10522]
Daniel Atallah <datallah@pidgin.im>
parents:
9642
diff
changeset
|
669 | * |
|
4e8cb7ef72ab
[gaim-migrate @ 10522]
Daniel Atallah <datallah@pidgin.im>
parents:
9642
diff
changeset
|
670 | * @return a GList containing strings allocated with g_malloc that contain the |
|
4e8cb7ef72ab
[gaim-migrate @ 10522]
Daniel Atallah <datallah@pidgin.im>
parents:
9642
diff
changeset
|
671 | * filenames in the uri-list. Note that unlike gaim_uri_list_extract_uris() |
|
4e8cb7ef72ab
[gaim-migrate @ 10522]
Daniel Atallah <datallah@pidgin.im>
parents:
9642
diff
changeset
|
672 | * function, this will discard any non-file uri from the result value. |
|
4e8cb7ef72ab
[gaim-migrate @ 10522]
Daniel Atallah <datallah@pidgin.im>
parents:
9642
diff
changeset
|
673 | */ |
|
4e8cb7ef72ab
[gaim-migrate @ 10522]
Daniel Atallah <datallah@pidgin.im>
parents:
9642
diff
changeset
|
674 | GList* gaim_uri_list_extract_filenames (const gchar* uri_list); |
|
4e8cb7ef72ab
[gaim-migrate @ 10522]
Daniel Atallah <datallah@pidgin.im>
parents:
9642
diff
changeset
|
675 | |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
676 | /*@}*/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
677 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
678 | /************************************************************************** |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
679 | * UTF8 String Functions |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
680 | **************************************************************************/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
681 | /*@{*/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
682 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
683 | /** |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
684 | * Attempts to convert a string to UTF-8 from an unknown encoding. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
685 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
686 | * This function checks the locale and tries sane defaults. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
687 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
688 | * @param str The source string. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
689 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
690 | * @return The UTF-8 string, or @c NULL if it could not be converted. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
691 | */ |
|
9642
ec0b88cf9161
[gaim-migrate @ 10490]
Mark Doliner <markdoliner@pidgin.im>
parents:
9427
diff
changeset
|
692 | gchar *gaim_utf8_try_convert(const char *str); |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
693 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
694 | /** |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
695 | * Compares two UTF-8 strings. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
696 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
697 | * @param a The first string. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
698 | * @param b The second string. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
699 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
700 | * @return -1 if @a is less than @a b. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
701 | * 0 if @a is equal to @a b. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
702 | * 1 if @a is greater than @a b. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
703 | */ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
704 | int gaim_utf8_strcasecmp(const char *a, const char *b); |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
705 | |
| 7564 | 706 | /** |
| 707 | * Checks for messages starting with "/me " | |
| 708 | * | |
| 709 | * @param message The message to check | |
| 710 | * @param len The message length, or -1 | |
| 711 | * | |
| 712 | * @return TRUE if it starts with /me, and it has been removed, otherwise FALSE | |
| 713 | */ | |
| 714 | gboolean gaim_message_meify(char *message, size_t len); | |
| 715 | ||
| 7889 | 716 | /** |
| 717 | * Removes the underscore characters from a string used identify the mnemonic | |
| 718 | * character. | |
| 719 | * | |
| 720 | * @param in The string to strip | |
| 721 | * | |
| 722 | * @return The stripped string | |
| 723 | */ | |
| 8432 | 724 | char *gaim_text_strip_mnemonic(const char *in); |
| 7889 | 725 | |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
726 | /*@}*/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
727 | |
| 8432 | 728 | /** |
| 729 | * Adds 8 to something. | |
| 730 | * | |
| 731 | * Blame SimGuy. | |
| 732 | * | |
| 9000 | 733 | * @param x The number to add 8 to. |
| 8432 | 734 | * |
| 9000 | 735 | * @return x + 8 |
| 8432 | 736 | */ |
| 8433 | 737 | #define gaim_add_eight(x) ((x)+8) |
| 8432 | 738 | |
| 9926 | 739 | /** |
| 740 | * Does the reverse of gaim_escape_filename | |
| 741 | * | |
| 742 | * This will change hex codes and such to their ascii equivalents. | |
| 743 | * | |
| 744 | * @param str The string to translate. | |
| 745 | * | |
| 746 | * @return The resulting string. | |
| 747 | */ | |
| 748 | const char *gaim_unescape_filename(const char *str); | |
| 749 | ||
| 750 | /** | |
| 751 | * Escapes filesystem-unfriendly characters from a filename | |
| 752 | * | |
| 753 | * @param str The string to translate. | |
| 754 | * | |
| 755 | * @return The resulting string. | |
| 756 | */ | |
| 757 | const char *gaim_escape_filename(const char *str); | |
| 758 | ||
|
5944
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
759 | #ifdef __cplusplus |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
760 | } |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
761 | #endif |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
762 | |
| 4890 | 763 | #endif /* _GAIM_UTIL_H_ */ |