Wed, 20 Jul 2005 23:10:33 +0000
[gaim-migrate @ 13196]
Straighten out some comments and get rid of a warning in gtkutils.c
| 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" |
|
10425
d82cef15da95
[gaim-migrate @ 11677]
Mark Doliner <markdoliner@pidgin.im>
parents:
10415
diff
changeset
|
34 | #include "xmlnode.h" |
|
5563
d5a7852aa0cb
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5532
diff
changeset
|
35 | |
|
5944
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
36 | #ifdef __cplusplus |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
37 | extern "C" { |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
38 | #endif |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
39 | |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
40 | /**************************************************************************/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
41 | /** @name Base16 Functions */ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
42 | /**************************************************************************/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
43 | /*@{*/ |
| 4890 | 44 | |
| 45 | /** | |
|
11127
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10871
diff
changeset
|
46 | * Converts a chunk of binary data to its base-16 equivalent. |
| 4890 | 47 | * |
|
11127
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10871
diff
changeset
|
48 | * @param data The data to convert. |
|
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10871
diff
changeset
|
49 | * @param len The length of the data. |
| 4890 | 50 | * |
|
11127
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10871
diff
changeset
|
51 | * @return The base-16 string in the ASCII encoding. Must be |
|
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10871
diff
changeset
|
52 | * g_free'd when no longer needed. |
| 4890 | 53 | * |
|
7123
a308c150e74a
[gaim-migrate @ 7690]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
54 | * @see gaim_base16_decode() |
| 4890 | 55 | */ |
|
11127
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10871
diff
changeset
|
56 | gchar *gaim_base16_encode(const guint8 *data, gsize len); |
| 4890 | 57 | |
| 58 | /** | |
|
11127
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10871
diff
changeset
|
59 | * Converts an ASCII string of base-16 encoded data to |
|
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10871
diff
changeset
|
60 | * the binary equivalent. |
| 4890 | 61 | * |
|
11127
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10871
diff
changeset
|
62 | * @param str The base-16 string to convert to raw data. |
|
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10871
diff
changeset
|
63 | * @param ret_len The length of the returned data. You can |
|
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10871
diff
changeset
|
64 | * pass in NULL if you're sure that you know |
|
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10871
diff
changeset
|
65 | * the length of the decoded data, or if you |
|
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10871
diff
changeset
|
66 | * know you'll be able to use strlen to |
|
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10871
diff
changeset
|
67 | * determine the length, etc. |
| 5451 | 68 | * |
|
11127
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10871
diff
changeset
|
69 | * @return The raw data. Must be g_free'd when no longer needed. |
| 4890 | 70 | * |
|
7123
a308c150e74a
[gaim-migrate @ 7690]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
71 | * @see gaim_base16_encode() |
| 4890 | 72 | */ |
|
11127
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10871
diff
changeset
|
73 | guint8 *gaim_base16_decode(const char *str, gsize *ret_len); |
| 4890 | 74 | |
|
7108
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 | |
|
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 | /** @name Base64 Functions */ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
80 | /**************************************************************************/ |
|
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 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
83 | /** |
|
11127
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10871
diff
changeset
|
84 | * Converts a chunk of binary data to its base-64 equivalent. |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
85 | * |
|
11127
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10871
diff
changeset
|
86 | * @param data The data to convert. |
|
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10871
diff
changeset
|
87 | * @param len The length of the data. |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
88 | * |
|
11127
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10871
diff
changeset
|
89 | * @return The base-64 string in the ASCII encoding. Must be |
|
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10871
diff
changeset
|
90 | * g_free'd when no longer needed. |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
91 | * |
|
7123
a308c150e74a
[gaim-migrate @ 7690]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
92 | * @see gaim_base64_decode() |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
93 | */ |
|
11127
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10871
diff
changeset
|
94 | gchar *gaim_base64_encode(const guint8 *data, gsize len); |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
95 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
96 | /** |
|
11127
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10871
diff
changeset
|
97 | * Converts an ASCII string of base-64 encoded data to |
|
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10871
diff
changeset
|
98 | * the binary equivalent. |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
99 | * |
|
11127
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10871
diff
changeset
|
100 | * @param str The base-64 string to convert to raw data. |
|
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10871
diff
changeset
|
101 | * @param ret_len The length of the returned data. You can |
|
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10871
diff
changeset
|
102 | * pass in NULL if you're sure that you know |
|
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10871
diff
changeset
|
103 | * the length of the decoded data, or if you |
|
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10871
diff
changeset
|
104 | * know you'll be able to use strlen to |
|
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10871
diff
changeset
|
105 | * determine the length, etc. |
|
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10871
diff
changeset
|
106 | * |
|
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10871
diff
changeset
|
107 | * @return The raw data. Must be g_free'd when no longer needed. |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
108 | * |
|
7123
a308c150e74a
[gaim-migrate @ 7690]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
109 | * @see gaim_base64_encode() |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
110 | */ |
|
11127
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10871
diff
changeset
|
111 | guint8 *gaim_base64_decode(const char *str, gsize *ret_len); |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
112 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
113 | /*@}*/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
114 | |
|
7679
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 | /** @name Quoted Printable Functions */ |
|
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 | /*@{*/ |
|
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 | * Converts a quoted printable string back to its readable equivalent. |
|
11132
eeb2afd70f70
[gaim-migrate @ 13189]
Mark Doliner <markdoliner@pidgin.im>
parents:
11127
diff
changeset
|
122 | * What is a quoted printable string, you ask? It's an encoding used |
|
eeb2afd70f70
[gaim-migrate @ 13189]
Mark Doliner <markdoliner@pidgin.im>
parents:
11127
diff
changeset
|
123 | * to transmit binary data as ASCII. It's intended purpose is to send |
|
eeb2afd70f70
[gaim-migrate @ 13189]
Mark Doliner <markdoliner@pidgin.im>
parents:
11127
diff
changeset
|
124 | * e-mails containing non-ASCII characters. Wikipedia has a pretty good |
|
eeb2afd70f70
[gaim-migrate @ 13189]
Mark Doliner <markdoliner@pidgin.im>
parents:
11127
diff
changeset
|
125 | * explanation. Also see RFC 2045. |
|
7679
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
126 | * |
|
11132
eeb2afd70f70
[gaim-migrate @ 13189]
Mark Doliner <markdoliner@pidgin.im>
parents:
11127
diff
changeset
|
127 | * @param str The quoted printable ASCII string to convert to raw data. |
|
7679
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
128 | * @param ret_str The returned, readable string. |
|
11132
eeb2afd70f70
[gaim-migrate @ 13189]
Mark Doliner <markdoliner@pidgin.im>
parents:
11127
diff
changeset
|
129 | * @param ret_len The length of the returned data. You can |
|
eeb2afd70f70
[gaim-migrate @ 13189]
Mark Doliner <markdoliner@pidgin.im>
parents:
11127
diff
changeset
|
130 | * pass in NULL if you're sure that you know |
|
eeb2afd70f70
[gaim-migrate @ 13189]
Mark Doliner <markdoliner@pidgin.im>
parents:
11127
diff
changeset
|
131 | * the length of the decoded data, or if you |
|
eeb2afd70f70
[gaim-migrate @ 13189]
Mark Doliner <markdoliner@pidgin.im>
parents:
11127
diff
changeset
|
132 | * know you'll be able to use strlen to |
|
eeb2afd70f70
[gaim-migrate @ 13189]
Mark Doliner <markdoliner@pidgin.im>
parents:
11127
diff
changeset
|
133 | * determine the length, etc. |
|
eeb2afd70f70
[gaim-migrate @ 13189]
Mark Doliner <markdoliner@pidgin.im>
parents:
11127
diff
changeset
|
134 | * |
|
11135
063678d038f9
[gaim-migrate @ 13196]
Mark Doliner <markdoliner@pidgin.im>
parents:
11132
diff
changeset
|
135 | * @return The raw data. Must be g_free'd when no longer needed. |
|
7679
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
136 | */ |
|
11132
eeb2afd70f70
[gaim-migrate @ 13189]
Mark Doliner <markdoliner@pidgin.im>
parents:
11127
diff
changeset
|
137 | guint8 *gaim_quotedp_decode(const char *str, gsize *ret_len); |
|
7679
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 | |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
141 | /**************************************************************************/ |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
142 | /** @name MIME Functions */ |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
143 | /**************************************************************************/ |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
144 | /*@{*/ |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
145 | |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
146 | /** |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
147 | * Converts a MIME header field string back to its readable equivalent |
| 8432 | 148 | * according to RFC 2047. Basically, a header is plain ASCII and can |
| 149 | * contain any number of sections called "encoded-words." The format | |
|
7821
d15fc781c318
[gaim-migrate @ 8473]
Mark Doliner <markdoliner@pidgin.im>
parents:
7679
diff
changeset
|
150 | * 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
|
151 | * =? designates the beginning of the encoded-word |
|
d15fc781c318
[gaim-migrate @ 8473]
Mark Doliner <markdoliner@pidgin.im>
parents:
7679
diff
changeset
|
152 | * ?= designates the end of the encoded-word |
|
11135
063678d038f9
[gaim-migrate @ 13196]
Mark Doliner <markdoliner@pidgin.im>
parents:
11132
diff
changeset
|
153 | * |
|
063678d038f9
[gaim-migrate @ 13196]
Mark Doliner <markdoliner@pidgin.im>
parents:
11132
diff
changeset
|
154 | * An encoded word is segmented into three pieces by the use of a |
|
063678d038f9
[gaim-migrate @ 13196]
Mark Doliner <markdoliner@pidgin.im>
parents:
11132
diff
changeset
|
155 | * question mark. The first piece is the character set, the second |
|
063678d038f9
[gaim-migrate @ 13196]
Mark Doliner <markdoliner@pidgin.im>
parents:
11132
diff
changeset
|
156 | * piece is the encoding, and the third piece is the encoded text. |
|
7679
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
157 | * |
|
11135
063678d038f9
[gaim-migrate @ 13196]
Mark Doliner <markdoliner@pidgin.im>
parents:
11132
diff
changeset
|
158 | * @param str The ASCII string, possibly containing any number of |
|
063678d038f9
[gaim-migrate @ 13196]
Mark Doliner <markdoliner@pidgin.im>
parents:
11132
diff
changeset
|
159 | * encoded-word sections. |
|
7679
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
160 | * |
|
11135
063678d038f9
[gaim-migrate @ 13196]
Mark Doliner <markdoliner@pidgin.im>
parents:
11132
diff
changeset
|
161 | * @return The string, with any encoded-word sections decoded and |
|
063678d038f9
[gaim-migrate @ 13196]
Mark Doliner <markdoliner@pidgin.im>
parents:
11132
diff
changeset
|
162 | * converted to UTF-8. Must be g_free'd when no longer |
|
063678d038f9
[gaim-migrate @ 13196]
Mark Doliner <markdoliner@pidgin.im>
parents:
11132
diff
changeset
|
163 | * needed. |
|
7679
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
164 | */ |
|
11135
063678d038f9
[gaim-migrate @ 13196]
Mark Doliner <markdoliner@pidgin.im>
parents:
11132
diff
changeset
|
165 | char *gaim_mime_decode_field(const char *str); |
|
7679
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
166 | |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
167 | /*@}*/ |
|
c9804d02dcab
[gaim-migrate @ 8323]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7675
diff
changeset
|
168 | |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
169 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
170 | /**************************************************************************/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
171 | /** @name Date/Time Functions */ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
172 | /**************************************************************************/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
173 | /*@{*/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
174 | |
| 4890 | 175 | /** |
| 176 | * Returns the current local time in hour:minute:second form. | |
| 177 | * | |
| 178 | * The returned string is stored in a static buffer, so the result | |
| 179 | * should be g_strdup()'d if it's intended to be used for long. | |
| 180 | * | |
| 181 | * @return The current local time. | |
| 182 | * | |
|
7123
a308c150e74a
[gaim-migrate @ 7690]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
183 | * @see gaim_date_full() |
| 4890 | 184 | */ |
| 7162 | 185 | const char *gaim_date(void); |
| 4890 | 186 | |
| 187 | /** | |
| 188 | * Returns the date and time in human-readable form. | |
| 189 | * | |
| 190 | * The returned string is stored in a static buffer, so the result | |
| 191 | * should be g_strdup()'d if it's intended to be used for long. | |
| 192 | * | |
| 193 | * @return The date and time in human-readable form. | |
| 194 | * | |
|
7123
a308c150e74a
[gaim-migrate @ 7690]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
195 | * @see gaim_date() |
| 4890 | 196 | */ |
| 7162 | 197 | const char *gaim_date_full(void); |
| 4890 | 198 | |
| 199 | /** | |
| 200 | * Builds a time_t from the supplied information. | |
| 201 | * | |
| 202 | * @param year The year. | |
| 203 | * @param month The month. | |
| 204 | * @param day The day. | |
| 205 | * @param hour The hour. | |
| 206 | * @param min The minute. | |
| 207 | * @param sec The second. | |
| 208 | * | |
| 209 | * @return A time_t. | |
| 210 | */ | |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
211 | 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
|
212 | int min, int sec); |
| 4890 | 213 | |
| 8577 | 214 | /** |
| 215 | * Parses a timestamp in jabber or ISO8601 format and returns a time_t. | |
| 216 | * | |
| 217 | * @param timestamp The timestamp | |
| 218 | * @param utc Assume UTC if no timezone specified | |
| 219 | * | |
| 220 | * @return A time_t. | |
| 221 | */ | |
| 222 | time_t gaim_str_to_time(const char *timestamp, gboolean utc); | |
| 223 | ||
| 10636 | 224 | /** |
| 225 | * Creates a string according to a time and format string | |
| 226 | * | |
| 227 | * This function just calls strftime. The only advantage to using it | |
| 228 | * is that gcc won't give a warning if you use %c | |
|
11135
063678d038f9
[gaim-migrate @ 13196]
Mark Doliner <markdoliner@pidgin.im>
parents:
11132
diff
changeset
|
229 | * |
|
063678d038f9
[gaim-migrate @ 13196]
Mark Doliner <markdoliner@pidgin.im>
parents:
11132
diff
changeset
|
230 | * TODO: The warning is gone in gcc4, and this function can |
|
063678d038f9
[gaim-migrate @ 13196]
Mark Doliner <markdoliner@pidgin.im>
parents:
11132
diff
changeset
|
231 | * eventually be removed. |
| 10636 | 232 | */ |
| 233 | size_t gaim_strftime(char *s, size_t max, const char *format, const struct tm *tm); | |
| 234 | ||
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
235 | /*@}*/ |
| 4890 | 236 | |
| 237 | ||
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
238 | /**************************************************************************/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
239 | /** @name Markup Functions */ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
240 | /**************************************************************************/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
241 | /*@{*/ |
| 5826 | 242 | |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6861
diff
changeset
|
243 | /** |
|
11135
063678d038f9
[gaim-migrate @ 13196]
Mark Doliner <markdoliner@pidgin.im>
parents:
11132
diff
changeset
|
244 | * Finds an HTML tag matching the given name. |
|
7094
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
245 | * |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
246 | * 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
|
247 | * 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
|
248 | * 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
|
249 | * |
|
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6861
diff
changeset
|
250 | * @param needle the name of the tag |
|
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6861
diff
changeset
|
251 | * @param haystack the null-delimited string to search in |
|
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6861
diff
changeset
|
252 | * @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
|
253 | * @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
|
254 | * @param attributes the attributes, if the tag was found |
|
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6861
diff
changeset
|
255 | * @return TRUE if the tag was found |
|
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6861
diff
changeset
|
256 | */ |
|
7094
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
257 | gboolean gaim_markup_find_tag(const char *needle, const char *haystack, |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
258 | const char **start, const char **end, |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
259 | GData **attributes); |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
260 | |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
261 | /** |
|
7095
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
262 | * Extracts a field of data from HTML. |
|
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 | * This is a scary function. See protocols/msn/msn.c and |
| 9175 | 265 | * protocols/yahoo/yahoo_profile.c for example usage. |
|
7095
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
266 | * |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
267 | * @param str The string to parse. |
| 7675 | 268 | * @param len The size of str. |
| 269 | * @param dest The destination GString to append the new | |
|
7095
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
270 | * field info to. |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
271 | * @param start_token The beginning token. |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
272 | * @param skip The number of characters to skip after the |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
273 | * start token. |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
274 | * @param end_token The ending token. |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
275 | * @param check_value The value that the last character must meet. |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
276 | * @param no_value_token The token indicating no value is given. |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
277 | * @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
|
278 | * @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
|
279 | * @param link_prefix The prefix for the link. |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
280 | * |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
281 | * @return TRUE if successful, or FALSE otherwise. |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
282 | */ |
| 7675 | 283 | gboolean gaim_markup_extract_info_field(const char *str, int len, GString *dest, |
| 284 | const char *start_token, int skip, | |
| 285 | const char *end_token, char check_value, | |
| 286 | const char *no_value_token, | |
| 287 | const char *display_name, gboolean is_link, | |
| 288 | const char *link_prefix); | |
|
7095
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
289 | |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
290 | /** |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
291 | * Converts HTML markup to XHTML. |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
292 | * |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
293 | * @param html The HTML markup. |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
294 | * @param dest_xhtml The destination XHTML output. |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
295 | * @param dest_plain The destination plain-text output. |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
296 | */ |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
297 | 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
|
298 | char **dest_plain); |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
299 | |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
300 | /** |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
301 | * Strips HTML tags from a string. |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
302 | * |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
303 | * @param str The string to strip HTML from. |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
304 | * |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
305 | * @return The new string without HTML. This must be freed. |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
306 | */ |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
307 | char *gaim_markup_strip_html(const char *str); |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
308 | |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7094
diff
changeset
|
309 | /** |
|
7107
903864ff76c3
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
310 | * 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
|
311 | * |
|
903864ff76c3
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
312 | * @param str The string to linkify. |
|
903864ff76c3
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
313 | * |
|
903864ff76c3
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
314 | * @return The linkified text. |
|
903864ff76c3
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
315 | */ |
|
903864ff76c3
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
316 | char *gaim_markup_linkify(const char *str); |
|
903864ff76c3
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
317 | |
| 8163 | 318 | /** |
| 8442 | 319 | * Unescapes HTML entities to their literal characters. |
| 320 | * For example "&" is replaced by '&' and so on. | |
| 321 | * Actually only "&", """, "<" and ">" are currently | |
| 322 | * supported. | |
| 323 | * | |
| 324 | * @param html The string in which to unescape any HTML entities | |
| 325 | * | |
| 326 | * @return the text with HTML entities literalized | |
| 327 | */ | |
| 328 | char *gaim_unescape_html(const char *html); | |
| 329 | ||
| 9175 | 330 | /** |
| 331 | * Returns a newly allocated substring of the HTML UTF-8 string "str". | |
| 332 | * The markup is preserved such that the substring will have the same | |
| 333 | * formatting as original string, even though some tags may have been | |
| 334 | * opened before "x", or may close after "y". All open tags are closed | |
| 335 | * at the end of the returned string, in the proper order. | |
| 336 | * | |
| 337 | * Note that x and y are in character offsets, not byte offsets, and | |
| 338 | * are offsets into an unformatted version of str. Because of this, | |
| 339 | * this function may be sensitive to changes in GtkIMHtml and may break | |
| 340 | * when used with other UI's. libgaim users are encouraged to report and | |
| 341 | * work out any problems encountered. | |
| 342 | * | |
| 343 | * @param str The input NUL terminated, HTML, UTF-8 (or ASCII) string. | |
| 344 | * @param x The character offset into an unformatted version of str to | |
| 345 | * begin at. | |
| 346 | * @param y The character offset (into an unformatted vesion of str) of | |
| 347 | * one past the last character to include in the slice. | |
| 348 | * | |
| 349 | * @return The HTML slice of string, with all formatting retained. | |
| 350 | */ | |
| 351 | char *gaim_markup_slice(const char *str, guint x, guint y); | |
| 352 | ||
| 353 | /** | |
| 354 | * Returns a newly allocated string containing the name of the tag | |
| 355 | * located at "tag". Tag is expected to point to a '<', and contain | |
| 356 | * a '>' sometime after that. If there is no '>' and the string is | |
| 357 | * not NUL terminated, this function can be expected to segfault. | |
| 358 | * | |
| 359 | * @param tag The string starting a HTML tag. | |
| 360 | * @return A string containing the name of the tag. | |
| 361 | */ | |
| 362 | char *gaim_markup_get_tag_name(const char *tag); | |
| 363 | ||
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
364 | /*@}*/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
365 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
366 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
367 | /**************************************************************************/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
368 | /** @name Path/Filename Functions */ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
369 | /**************************************************************************/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
370 | /*@{*/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
371 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
372 | /** |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
373 | * Returns the user's home directory. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
374 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
375 | * @return The user's home directory. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
376 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
377 | * @see gaim_user_dir() |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
378 | */ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
379 | const gchar *gaim_home_dir(void); |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
380 | |
|
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 | * Returns the gaim settings directory in the user's home directory. |
|
10869
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10732
diff
changeset
|
383 | * This is usually ~/.gaim |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
384 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
385 | * @return The gaim settings directory. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
386 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
387 | * @see gaim_home_dir() |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
388 | */ |
|
10332
62ed0121db22
[gaim-migrate @ 11539]
Mark Doliner <markdoliner@pidgin.im>
parents:
10258
diff
changeset
|
389 | const char *gaim_user_dir(void); |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
390 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
391 | /** |
| 8596 | 392 | * Define a custom gaim settings directory, overriding the default (user's home directory/.gaim) |
| 393 | * @param dir The custom settings directory | |
| 394 | */ | |
|
10871
c0282a4f2250
[gaim-migrate @ 12558]
Mark Doliner <markdoliner@pidgin.im>
parents:
10869
diff
changeset
|
395 | void gaim_util_set_user_dir(const char *dir); |
| 8596 | 396 | |
| 397 | /** | |
| 7612 | 398 | * Builds a complete path from the root, making any directories along |
| 399 | * the path which do not already exist. | |
| 7622 | 400 | * |
| 7612 | 401 | * @param path The path you wish to create. Note that it must start |
| 402 | * from the root or this function will fail. | |
| 403 | * @param mode Unix-style permissions for this directory. | |
| 7622 | 404 | * |
| 7612 | 405 | * @return 0 for success, nonzero on any error. |
| 406 | */ | |
| 7622 | 407 | int gaim_build_dir(const char *path, int mode); |
| 7612 | 408 | |
| 409 | /** | |
|
10415
faceb835eb87
[gaim-migrate @ 11665]
Mark Doliner <markdoliner@pidgin.im>
parents:
10414
diff
changeset
|
410 | * Write a string of data to a file of the given name in the Gaim |
|
faceb835eb87
[gaim-migrate @ 11665]
Mark Doliner <markdoliner@pidgin.im>
parents:
10414
diff
changeset
|
411 | * user directory ($HOME/.gaim by default). The data is typically |
|
faceb835eb87
[gaim-migrate @ 11665]
Mark Doliner <markdoliner@pidgin.im>
parents:
10414
diff
changeset
|
412 | * a serialized version of one of Gaim's config files, such as |
|
faceb835eb87
[gaim-migrate @ 11665]
Mark Doliner <markdoliner@pidgin.im>
parents:
10414
diff
changeset
|
413 | * prefs.xml, accounts.xml, etc. And the string is typically |
|
faceb835eb87
[gaim-migrate @ 11665]
Mark Doliner <markdoliner@pidgin.im>
parents:
10414
diff
changeset
|
414 | * obtained using xmlnode_to_formatted_str. However, this function |
|
faceb835eb87
[gaim-migrate @ 11665]
Mark Doliner <markdoliner@pidgin.im>
parents:
10414
diff
changeset
|
415 | * should work fine for saving binary files as well. |
|
10414
6b10b76933e1
[gaim-migrate @ 11664]
Mark Doliner <markdoliner@pidgin.im>
parents:
10332
diff
changeset
|
416 | * |
|
6b10b76933e1
[gaim-migrate @ 11664]
Mark Doliner <markdoliner@pidgin.im>
parents:
10332
diff
changeset
|
417 | * @param filename The basename of the file to write in the gaim_user_dir. |
|
6b10b76933e1
[gaim-migrate @ 11664]
Mark Doliner <markdoliner@pidgin.im>
parents:
10332
diff
changeset
|
418 | * @param data A null-terminated string of data to write. |
|
10415
faceb835eb87
[gaim-migrate @ 11665]
Mark Doliner <markdoliner@pidgin.im>
parents:
10414
diff
changeset
|
419 | * @param size The size of the data to save. If data is |
|
faceb835eb87
[gaim-migrate @ 11665]
Mark Doliner <markdoliner@pidgin.im>
parents:
10414
diff
changeset
|
420 | * null-terminated you can pass in -1. |
|
10414
6b10b76933e1
[gaim-migrate @ 11664]
Mark Doliner <markdoliner@pidgin.im>
parents:
10332
diff
changeset
|
421 | * |
|
6b10b76933e1
[gaim-migrate @ 11664]
Mark Doliner <markdoliner@pidgin.im>
parents:
10332
diff
changeset
|
422 | * @return TRUE if the file was written successfully. FALSE otherwise. |
|
6b10b76933e1
[gaim-migrate @ 11664]
Mark Doliner <markdoliner@pidgin.im>
parents:
10332
diff
changeset
|
423 | */ |
|
10415
faceb835eb87
[gaim-migrate @ 11665]
Mark Doliner <markdoliner@pidgin.im>
parents:
10414
diff
changeset
|
424 | gboolean gaim_util_write_data_to_file(const char *filename, const char *data, |
|
faceb835eb87
[gaim-migrate @ 11665]
Mark Doliner <markdoliner@pidgin.im>
parents:
10414
diff
changeset
|
425 | size_t size); |
|
10414
6b10b76933e1
[gaim-migrate @ 11664]
Mark Doliner <markdoliner@pidgin.im>
parents:
10332
diff
changeset
|
426 | |
|
6b10b76933e1
[gaim-migrate @ 11664]
Mark Doliner <markdoliner@pidgin.im>
parents:
10332
diff
changeset
|
427 | /** |
|
10425
d82cef15da95
[gaim-migrate @ 11677]
Mark Doliner <markdoliner@pidgin.im>
parents:
10415
diff
changeset
|
428 | * Read the contents of a given file and parse the results into an |
|
d82cef15da95
[gaim-migrate @ 11677]
Mark Doliner <markdoliner@pidgin.im>
parents:
10415
diff
changeset
|
429 | * xmlnode tree structure. This is intended to be used to read |
|
d82cef15da95
[gaim-migrate @ 11677]
Mark Doliner <markdoliner@pidgin.im>
parents:
10415
diff
changeset
|
430 | * Gaim's configuration xml files (prefs.xml, pounces.xml, etc.) |
|
d82cef15da95
[gaim-migrate @ 11677]
Mark Doliner <markdoliner@pidgin.im>
parents:
10415
diff
changeset
|
431 | * |
|
d82cef15da95
[gaim-migrate @ 11677]
Mark Doliner <markdoliner@pidgin.im>
parents:
10415
diff
changeset
|
432 | * @param filename The basename of the file to open in the gaim_user_dir. |
|
d82cef15da95
[gaim-migrate @ 11677]
Mark Doliner <markdoliner@pidgin.im>
parents:
10415
diff
changeset
|
433 | * @param description A very short description of the contents of this |
|
d82cef15da95
[gaim-migrate @ 11677]
Mark Doliner <markdoliner@pidgin.im>
parents:
10415
diff
changeset
|
434 | * file. This is used in error messages shown to the |
|
d82cef15da95
[gaim-migrate @ 11677]
Mark Doliner <markdoliner@pidgin.im>
parents:
10415
diff
changeset
|
435 | * user when the file can not be opened. For example, |
|
d82cef15da95
[gaim-migrate @ 11677]
Mark Doliner <markdoliner@pidgin.im>
parents:
10415
diff
changeset
|
436 | * "preferences," or "buddy pounces." |
|
d82cef15da95
[gaim-migrate @ 11677]
Mark Doliner <markdoliner@pidgin.im>
parents:
10415
diff
changeset
|
437 | * |
|
d82cef15da95
[gaim-migrate @ 11677]
Mark Doliner <markdoliner@pidgin.im>
parents:
10415
diff
changeset
|
438 | * @return An xmlnode tree of the contents of the given file. Or NULL, if |
|
d82cef15da95
[gaim-migrate @ 11677]
Mark Doliner <markdoliner@pidgin.im>
parents:
10415
diff
changeset
|
439 | * the file does not exist or there was an error reading the file. |
|
d82cef15da95
[gaim-migrate @ 11677]
Mark Doliner <markdoliner@pidgin.im>
parents:
10415
diff
changeset
|
440 | */ |
|
d82cef15da95
[gaim-migrate @ 11677]
Mark Doliner <markdoliner@pidgin.im>
parents:
10415
diff
changeset
|
441 | xmlnode *gaim_util_read_xml_from_file(const char *filename, |
|
d82cef15da95
[gaim-migrate @ 11677]
Mark Doliner <markdoliner@pidgin.im>
parents:
10415
diff
changeset
|
442 | const char *description); |
|
d82cef15da95
[gaim-migrate @ 11677]
Mark Doliner <markdoliner@pidgin.im>
parents:
10415
diff
changeset
|
443 | |
|
d82cef15da95
[gaim-migrate @ 11677]
Mark Doliner <markdoliner@pidgin.im>
parents:
10415
diff
changeset
|
444 | /** |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
445 | * Creates a temporary file and returns a file pointer to it. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
446 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
447 | * 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
|
448 | * pre-set template. It uses the semantics of tempnam() for the |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
449 | * directory to use and allocates the space for the file path. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
450 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
451 | * 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
|
452 | * 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
|
453 | * g_free(). |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
454 | * |
|
10203
21d6c11a53c6
[gaim-migrate @ 11324]
Herman Bloggs <herman@bluedigits.com>
parents:
9926
diff
changeset
|
455 | * @param path The returned path to the temp file. |
|
21d6c11a53c6
[gaim-migrate @ 11324]
Herman Bloggs <herman@bluedigits.com>
parents:
9926
diff
changeset
|
456 | * @param binary Text or binary, for platforms where it matters. |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
457 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
458 | * @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
|
459 | */ |
|
10203
21d6c11a53c6
[gaim-migrate @ 11324]
Herman Bloggs <herman@bluedigits.com>
parents:
9926
diff
changeset
|
460 | FILE *gaim_mkstemp(char **path, gboolean binary); |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
461 | |
|
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 | * Checks if the given program name is valid and executable. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
464 | * |
|
7303
b7b02c31b5bb
[gaim-migrate @ 7887]
Christian Hammond <chipx86@chipx86.com>
parents:
7261
diff
changeset
|
465 | * @param program The file name of the application. |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
466 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
467 | * @return True if the program is runable. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
468 | */ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
469 | gboolean gaim_program_is_valid(const char *program); |
|
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 | * Returns the IP address from a socket file descriptor. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
473 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
474 | * @param fd The socket file descriptor. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
475 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
476 | * @return The IP address, or @c NULL on error. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
477 | */ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
478 | char *gaim_fd_get_ip(int fd); |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
479 | |
|
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 | |
|
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 | /** @name String Functions */ |
|
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 | /*@{*/ |
|
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 | /** |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
489 | * Normalizes a string, so that it is suitable for comparison. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
490 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
491 | * 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
|
492 | * 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
|
493 | * g_strdup() it. Also, calling normalize() twice in the same line |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
494 | * will lead to problems. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
495 | * |
|
10433
04cf48e72655
[gaim-migrate @ 11689]
Mark Doliner <markdoliner@pidgin.im>
parents:
10425
diff
changeset
|
496 | * @param account The account the string belongs to, or NULL if you do |
|
04cf48e72655
[gaim-migrate @ 11689]
Mark Doliner <markdoliner@pidgin.im>
parents:
10425
diff
changeset
|
497 | * not know the account. If you use NULL, the string |
|
04cf48e72655
[gaim-migrate @ 11689]
Mark Doliner <markdoliner@pidgin.im>
parents:
10425
diff
changeset
|
498 | * will still be normalized, but if the PRPL uses a |
|
04cf48e72655
[gaim-migrate @ 11689]
Mark Doliner <markdoliner@pidgin.im>
parents:
10425
diff
changeset
|
499 | * custom normalization function then the string may |
|
04cf48e72655
[gaim-migrate @ 11689]
Mark Doliner <markdoliner@pidgin.im>
parents:
10425
diff
changeset
|
500 | * not be normalized correctly. |
| 7261 | 501 | * @param str The string to normalize. |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
502 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
503 | * @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
|
504 | */ |
| 7261 | 505 | const char *gaim_normalize(const GaimAccount *account, const char *str); |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
506 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
507 | /** |
| 7628 | 508 | * Compares two strings to see if the first contains the second as |
| 509 | * a proper prefix. | |
| 8432 | 510 | * |
| 7628 | 511 | * @param s The string to check. |
| 512 | * @param p The prefix in question. | |
| 8432 | 513 | * |
| 7628 | 514 | * @return TRUE if p is a prefix of s, otherwise FALSE. |
| 515 | */ | |
| 516 | gboolean gaim_str_has_prefix(const char *s, const char *p); | |
| 517 | ||
| 518 | /** | |
| 519 | * Compares two strings to see if the second is a proper suffix | |
| 520 | * of the first. | |
| 8432 | 521 | * |
| 7628 | 522 | * @param s The string to check. |
| 523 | * @param x The suffix in question. | |
| 8432 | 524 | * |
| 7628 | 525 | * @return TRUE if x is a a suffix of s, otherwise FALSE. |
| 526 | */ | |
| 527 | gboolean gaim_str_has_suffix(const char *s, const char *x); | |
| 528 | ||
| 529 | /** | |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
530 | * 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
|
531 | * specified name, date, and time, respectively. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
532 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
533 | * @param str The string that may contain the special variables. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
534 | * @param name The sender name. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
535 | * |
|
8700
0c9288c5e40e
[gaim-migrate @ 9453]
Mark Doliner <markdoliner@pidgin.im>
parents:
8596
diff
changeset
|
536 | * @return A newly allocated string where the special variables are |
|
0c9288c5e40e
[gaim-migrate @ 9453]
Mark Doliner <markdoliner@pidgin.im>
parents:
8596
diff
changeset
|
537 | * expanded. This should be g_free'd by the caller. |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
538 | */ |
|
8700
0c9288c5e40e
[gaim-migrate @ 9453]
Mark Doliner <markdoliner@pidgin.im>
parents:
8596
diff
changeset
|
539 | 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
|
540 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
541 | /** |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
542 | * Duplicates a string and replaces all newline characters from the |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
543 | * source string with HTML linebreaks. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
544 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
545 | * @param src The source string. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
546 | * |
|
8341
dc43b1acfc1a
[gaim-migrate @ 9065]
Mark Doliner <markdoliner@pidgin.im>
parents:
8163
diff
changeset
|
547 | * @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
|
548 | */ |
|
8341
dc43b1acfc1a
[gaim-migrate @ 9065]
Mark Doliner <markdoliner@pidgin.im>
parents:
8163
diff
changeset
|
549 | gchar *gaim_strdup_withhtml(const gchar *src); |
|
7108
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 | /** |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
552 | * Ensures that all linefeeds have a matching carriage return. |
|
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 str The source string. |
|
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 with carriage returns. |
|
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_add_cr(const char *str); |
|
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 | /** |
|
7478
a7df4df98778
[gaim-migrate @ 8091]
Herman Bloggs <herman@bluedigits.com>
parents:
7303
diff
changeset
|
561 | * Strips all carriage returns from a string. |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
562 | * |
|
7478
a7df4df98778
[gaim-migrate @ 8091]
Herman Bloggs <herman@bluedigits.com>
parents:
7303
diff
changeset
|
563 | * @param str The string to strip carriage returns from. |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
564 | */ |
|
7478
a7df4df98778
[gaim-migrate @ 8091]
Herman Bloggs <herman@bluedigits.com>
parents:
7303
diff
changeset
|
565 | void gaim_str_strip_cr(char *str); |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
566 | |
|
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 | * Given a string, this replaces one substring with another |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
569 | * and returns a newly allocated string. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
570 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
571 | * @param string The string from which to replace stuff. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
572 | * @param delimiter The substring you want replaced. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
573 | * @param replacement The substring you want inserted in place |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
574 | * of the delimiting substring. |
|
8461
920171a59e45
[gaim-migrate @ 9191]
Mark Doliner <markdoliner@pidgin.im>
parents:
8442
diff
changeset
|
575 | * |
|
920171a59e45
[gaim-migrate @ 9191]
Mark Doliner <markdoliner@pidgin.im>
parents:
8442
diff
changeset
|
576 | * @return A new string, after performing the substitution. |
|
920171a59e45
[gaim-migrate @ 9191]
Mark Doliner <markdoliner@pidgin.im>
parents:
8442
diff
changeset
|
577 | * free this with g_free(). |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
578 | */ |
|
8341
dc43b1acfc1a
[gaim-migrate @ 9065]
Mark Doliner <markdoliner@pidgin.im>
parents:
8163
diff
changeset
|
579 | gchar *gaim_strreplace(const char *string, const char *delimiter, |
|
dc43b1acfc1a
[gaim-migrate @ 9065]
Mark Doliner <markdoliner@pidgin.im>
parents:
8163
diff
changeset
|
580 | const char *replacement); |
|
dc43b1acfc1a
[gaim-migrate @ 9065]
Mark Doliner <markdoliner@pidgin.im>
parents:
8163
diff
changeset
|
581 | |
|
dc43b1acfc1a
[gaim-migrate @ 9065]
Mark Doliner <markdoliner@pidgin.im>
parents:
8163
diff
changeset
|
582 | /** |
| 9171 | 583 | * Given a string, this replaces any numerical character references |
| 584 | * in that string with the corresponding actual utf-8 substrings, | |
| 585 | * and returns a newly allocated string. | |
| 586 | * | |
| 587 | * @param in The string which might contain numerical character references. | |
| 588 | * | |
| 589 | * @return A new string, with numerical character references | |
| 590 | * replaced with actual utf-8, free this with g_free(). | |
| 591 | */ | |
| 592 | char *gaim_utf8_ncr_decode(const char *in); | |
| 593 | ||
| 594 | /** | |
|
8341
dc43b1acfc1a
[gaim-migrate @ 9065]
Mark Doliner <markdoliner@pidgin.im>
parents:
8163
diff
changeset
|
595 | * Given a string, this replaces one substring with another |
|
dc43b1acfc1a
[gaim-migrate @ 9065]
Mark Doliner <markdoliner@pidgin.im>
parents:
8163
diff
changeset
|
596 | * ignoring case and returns a newly allocated string. |
|
dc43b1acfc1a
[gaim-migrate @ 9065]
Mark Doliner <markdoliner@pidgin.im>
parents:
8163
diff
changeset
|
597 | * |
|
dc43b1acfc1a
[gaim-migrate @ 9065]
Mark Doliner <markdoliner@pidgin.im>
parents:
8163
diff
changeset
|
598 | * @param string The string from which to replace stuff. |
|
dc43b1acfc1a
[gaim-migrate @ 9065]
Mark Doliner <markdoliner@pidgin.im>
parents:
8163
diff
changeset
|
599 | * @param delimiter The substring you want replaced. |
|
dc43b1acfc1a
[gaim-migrate @ 9065]
Mark Doliner <markdoliner@pidgin.im>
parents:
8163
diff
changeset
|
600 | * @param replacement The substring you want inserted in place |
|
dc43b1acfc1a
[gaim-migrate @ 9065]
Mark Doliner <markdoliner@pidgin.im>
parents:
8163
diff
changeset
|
601 | * of the delimiting substring. |
|
8461
920171a59e45
[gaim-migrate @ 9191]
Mark Doliner <markdoliner@pidgin.im>
parents:
8442
diff
changeset
|
602 | * |
|
920171a59e45
[gaim-migrate @ 9191]
Mark Doliner <markdoliner@pidgin.im>
parents:
8442
diff
changeset
|
603 | * @return A new string, after performing the substitution. |
|
920171a59e45
[gaim-migrate @ 9191]
Mark Doliner <markdoliner@pidgin.im>
parents:
8442
diff
changeset
|
604 | * free this with g_free(). |
|
8341
dc43b1acfc1a
[gaim-migrate @ 9065]
Mark Doliner <markdoliner@pidgin.im>
parents:
8163
diff
changeset
|
605 | */ |
|
dc43b1acfc1a
[gaim-migrate @ 9065]
Mark Doliner <markdoliner@pidgin.im>
parents:
8163
diff
changeset
|
606 | gchar *gaim_strcasereplace(const char *string, const char *delimiter, |
|
dc43b1acfc1a
[gaim-migrate @ 9065]
Mark Doliner <markdoliner@pidgin.im>
parents:
8163
diff
changeset
|
607 | const char *replacement); |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
608 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
609 | /** |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
610 | * This is like strstr, except that it ignores ASCII case in |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
611 | * searching for the substring. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
612 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
613 | * @param haystack The string to search in. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
614 | * @param needle The substring to find. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
615 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
616 | * @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
|
617 | */ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
618 | const char *gaim_strcasestr(const char *haystack, const char *needle); |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
619 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
620 | /** |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
621 | * Returns a string representing a filesize in the appropriate |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
622 | * units (MB, KB, GB, etc.) |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
623 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
624 | * @param size The size |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
625 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
626 | * @return The string in units form. This must be freed. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
627 | */ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
628 | char *gaim_str_size_to_units(size_t size); |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
629 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
630 | /** |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
631 | * Converts seconds into a human-readable form. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
632 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
633 | * @param sec The seconds. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
634 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
635 | * @return A human-readable form, containing days, hours, minutes, and |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
636 | * seconds. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
637 | */ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
638 | char *gaim_str_seconds_to_string(guint sec); |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
639 | |
| 9277 | 640 | /** |
| 641 | * Converts a binary string into a NUL terminated ascii string, | |
| 642 | * replacing nonascii characters and characters below SPACE (including | |
| 9307 | 643 | * NUL) into \\xyy, where yy are two hex digits. Also backslashes are |
| 644 | * changed into two backslashes (\\\\). The returned, newly allocated | |
| 645 | * string can be outputted to the console, and must be g_free()d. | |
| 9277 | 646 | * |
| 647 | * @param binary A string of random data, possibly with embedded NULs | |
| 648 | * and such. | |
| 649 | * @param len The length in bytes of the input string. Must not be 0. | |
| 650 | * | |
| 651 | * @return A newly allocated ASCIIZ string. | |
| 652 | */ | |
| 653 | 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
|
654 | /*@}*/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
655 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
656 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
657 | /**************************************************************************/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
658 | /** @name URI/URL Functions */ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
659 | /**************************************************************************/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
660 | /*@{*/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
661 | |
|
7107
903864ff76c3
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7106
diff
changeset
|
662 | /** |
| 9227 | 663 | * 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
|
664 | * |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
665 | * The returned data must be freed. |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
666 | * |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
667 | * @param url The URL to parse. |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
668 | * @param ret_host The returned host. |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
669 | * @param ret_port The returned port. |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
670 | * @param ret_path The returned path. |
| 9227 | 671 | * @param ret_user The returned username. |
| 672 | * @param ret_passwd The returned password. | |
|
7094
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
673 | */ |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
674 | gboolean gaim_url_parse(const char *url, char **ret_host, int *ret_port, |
| 9227 | 675 | char **ret_path, char **ret_user, char **ret_passwd); |
|
7094
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
676 | |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
677 | /** |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
678 | * 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
|
679 | * |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
680 | * @param url The URL. |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
681 | * @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
|
682 | * partial URL. |
| 9284 | 683 | * @param user_agent The user agent field to use, or NULL. |
| 684 | * @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
|
685 | * @param cb The callback function. |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
686 | * @param data The user data to pass to the callback function. |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
687 | */ |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
688 | void gaim_url_fetch(const char *url, gboolean full, |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
689 | const char *user_agent, gboolean http11, |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
690 | void (*cb)(void *, const char *, size_t), |
|
8f9588491993
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
691 | void *data); |
| 7134 | 692 | /** |
| 693 | * Decodes a URL into a plain string. | |
| 694 | * | |
| 695 | * This will change hex codes and such to their ascii equivalents. | |
| 696 | * | |
| 697 | * @param str The string to translate. | |
| 698 | * | |
| 699 | * @return The resulting string. | |
| 7162 | 700 | */ |
| 701 | const char *gaim_url_decode(const char *str); | |
| 7134 | 702 | |
| 703 | /** | |
| 704 | * Encodes a URL into an escaped string. | |
| 705 | * | |
| 706 | * This will change non-alphanumeric characters to hex codes. | |
| 707 | * | |
| 708 | * @param str The string to translate. | |
| 709 | * | |
| 710 | * @return The resulting string. | |
| 711 | */ | |
| 7162 | 712 | const char *gaim_url_encode(const char *str); |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6861
diff
changeset
|
713 | |
| 9045 | 714 | /** |
| 715 | * Checks if the given email address is syntactically valid. | |
| 716 | * | |
| 717 | * @param address The email address to validate. | |
| 718 | * | |
| 719 | * @return True if the email address is syntactically correct. | |
| 720 | */ | |
| 721 | gboolean gaim_email_is_valid(const char *address); | |
| 722 | ||
|
9670
4e8cb7ef72ab
[gaim-migrate @ 10522]
Daniel Atallah <datallah@pidgin.im>
parents:
9642
diff
changeset
|
723 | /** |
|
11135
063678d038f9
[gaim-migrate @ 13196]
Mark Doliner <markdoliner@pidgin.im>
parents:
11132
diff
changeset
|
724 | * This function extracts a list of URIs from the a "text/uri-list" |
|
063678d038f9
[gaim-migrate @ 13196]
Mark Doliner <markdoliner@pidgin.im>
parents:
11132
diff
changeset
|
725 | * string. It was "borrowed" from gnome_uri_list_extract_uris |
|
063678d038f9
[gaim-migrate @ 13196]
Mark Doliner <markdoliner@pidgin.im>
parents:
11132
diff
changeset
|
726 | * |
|
063678d038f9
[gaim-migrate @ 13196]
Mark Doliner <markdoliner@pidgin.im>
parents:
11132
diff
changeset
|
727 | * @param uri_list An uri-list in the standard format. |
|
9670
4e8cb7ef72ab
[gaim-migrate @ 10522]
Daniel Atallah <datallah@pidgin.im>
parents:
9642
diff
changeset
|
728 | * |
|
11135
063678d038f9
[gaim-migrate @ 13196]
Mark Doliner <markdoliner@pidgin.im>
parents:
11132
diff
changeset
|
729 | * @return A GList containing strings allocated with g_malloc |
|
063678d038f9
[gaim-migrate @ 13196]
Mark Doliner <markdoliner@pidgin.im>
parents:
11132
diff
changeset
|
730 | * that have been splitted from uri-list. |
|
9670
4e8cb7ef72ab
[gaim-migrate @ 10522]
Daniel Atallah <datallah@pidgin.im>
parents:
9642
diff
changeset
|
731 | */ |
|
11135
063678d038f9
[gaim-migrate @ 13196]
Mark Doliner <markdoliner@pidgin.im>
parents:
11132
diff
changeset
|
732 | GList *gaim_uri_list_extract_uris(const gchar *uri_list); |
|
9670
4e8cb7ef72ab
[gaim-migrate @ 10522]
Daniel Atallah <datallah@pidgin.im>
parents:
9642
diff
changeset
|
733 | |
|
4e8cb7ef72ab
[gaim-migrate @ 10522]
Daniel Atallah <datallah@pidgin.im>
parents:
9642
diff
changeset
|
734 | /** |
|
11135
063678d038f9
[gaim-migrate @ 13196]
Mark Doliner <markdoliner@pidgin.im>
parents:
11132
diff
changeset
|
735 | * This function extracts a list of filenames from a |
|
063678d038f9
[gaim-migrate @ 13196]
Mark Doliner <markdoliner@pidgin.im>
parents:
11132
diff
changeset
|
736 | * "text/uri-list" string. It was "borrowed" from |
|
063678d038f9
[gaim-migrate @ 13196]
Mark Doliner <markdoliner@pidgin.im>
parents:
11132
diff
changeset
|
737 | * gnome_uri_list_extract_filenames |
|
063678d038f9
[gaim-migrate @ 13196]
Mark Doliner <markdoliner@pidgin.im>
parents:
11132
diff
changeset
|
738 | * |
|
063678d038f9
[gaim-migrate @ 13196]
Mark Doliner <markdoliner@pidgin.im>
parents:
11132
diff
changeset
|
739 | * @param uri_list A uri-list in the standard format. |
|
9670
4e8cb7ef72ab
[gaim-migrate @ 10522]
Daniel Atallah <datallah@pidgin.im>
parents:
9642
diff
changeset
|
740 | * |
|
11135
063678d038f9
[gaim-migrate @ 13196]
Mark Doliner <markdoliner@pidgin.im>
parents:
11132
diff
changeset
|
741 | * @return A GList containing strings allocated with g_malloc that |
|
063678d038f9
[gaim-migrate @ 13196]
Mark Doliner <markdoliner@pidgin.im>
parents:
11132
diff
changeset
|
742 | * contain the filenames in the uri-list. Note that unlike |
|
063678d038f9
[gaim-migrate @ 13196]
Mark Doliner <markdoliner@pidgin.im>
parents:
11132
diff
changeset
|
743 | * gaim_uri_list_extract_uris() function, this will discard |
|
063678d038f9
[gaim-migrate @ 13196]
Mark Doliner <markdoliner@pidgin.im>
parents:
11132
diff
changeset
|
744 | * any non-file uri from the result value. |
|
9670
4e8cb7ef72ab
[gaim-migrate @ 10522]
Daniel Atallah <datallah@pidgin.im>
parents:
9642
diff
changeset
|
745 | */ |
|
11135
063678d038f9
[gaim-migrate @ 13196]
Mark Doliner <markdoliner@pidgin.im>
parents:
11132
diff
changeset
|
746 | GList *gaim_uri_list_extract_filenames(const gchar *uri_list); |
|
9670
4e8cb7ef72ab
[gaim-migrate @ 10522]
Daniel Atallah <datallah@pidgin.im>
parents:
9642
diff
changeset
|
747 | |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
748 | /*@}*/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
749 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
750 | /************************************************************************** |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
751 | * UTF8 String Functions |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
752 | **************************************************************************/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
753 | /*@{*/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
754 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
755 | /** |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
756 | * 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
|
757 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
758 | * This function checks the locale and tries sane defaults. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
759 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
760 | * @param str The source string. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
761 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
762 | * @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
|
763 | */ |
|
9642
ec0b88cf9161
[gaim-migrate @ 10490]
Mark Doliner <markdoliner@pidgin.im>
parents:
9427
diff
changeset
|
764 | gchar *gaim_utf8_try_convert(const char *str); |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
765 | |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
766 | /** |
| 10258 | 767 | * Salvages the valid UTF-8 characters from a string, replacing any |
| 768 | * invalid characters with a filler character (currently hardcoded to | |
| 769 | * '?'). | |
| 770 | * | |
| 771 | * @param str The source string. | |
| 772 | * | |
| 773 | * @return A valid UTF-8 string. | |
| 774 | */ | |
| 775 | gchar *gaim_utf8_salvage(const char *str); | |
| 776 | ||
| 777 | /** | |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
778 | * Compares two UTF-8 strings. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
779 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
780 | * @param a The first string. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
781 | * @param b The second string. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
782 | * |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
783 | * @return -1 if @a is less than @a b. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
784 | * 0 if @a is equal to @a b. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
785 | * 1 if @a is greater than @a b. |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
786 | */ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
787 | int gaim_utf8_strcasecmp(const char *a, const char *b); |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
788 | |
| 7564 | 789 | /** |
| 790 | * Checks for messages starting with "/me " | |
| 791 | * | |
| 792 | * @param message The message to check | |
| 793 | * @param len The message length, or -1 | |
| 794 | * | |
| 795 | * @return TRUE if it starts with /me, and it has been removed, otherwise FALSE | |
| 796 | */ | |
| 797 | gboolean gaim_message_meify(char *message, size_t len); | |
| 798 | ||
| 7889 | 799 | /** |
| 800 | * Removes the underscore characters from a string used identify the mnemonic | |
| 801 | * character. | |
| 802 | * | |
| 803 | * @param in The string to strip | |
| 804 | * | |
| 805 | * @return The stripped string | |
| 806 | */ | |
| 8432 | 807 | char *gaim_text_strip_mnemonic(const char *in); |
| 7889 | 808 | |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
809 | /*@}*/ |
|
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
810 | |
| 8432 | 811 | /** |
| 812 | * Adds 8 to something. | |
| 813 | * | |
| 814 | * Blame SimGuy. | |
| 815 | * | |
| 9000 | 816 | * @param x The number to add 8 to. |
| 8432 | 817 | * |
| 9000 | 818 | * @return x + 8 |
| 8432 | 819 | */ |
| 8433 | 820 | #define gaim_add_eight(x) ((x)+8) |
| 8432 | 821 | |
| 9926 | 822 | /** |
| 823 | * Does the reverse of gaim_escape_filename | |
| 824 | * | |
| 825 | * This will change hex codes and such to their ascii equivalents. | |
| 826 | * | |
| 827 | * @param str The string to translate. | |
| 828 | * | |
| 829 | * @return The resulting string. | |
| 830 | */ | |
| 831 | const char *gaim_unescape_filename(const char *str); | |
| 832 | ||
| 833 | /** | |
| 834 | * Escapes filesystem-unfriendly characters from a filename | |
| 835 | * | |
| 836 | * @param str The string to translate. | |
| 837 | * | |
| 838 | * @return The resulting string. | |
| 839 | */ | |
| 840 | const char *gaim_escape_filename(const char *str); | |
| 841 | ||
|
5944
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
842 | #ifdef __cplusplus |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
843 | } |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
844 | #endif |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5943
diff
changeset
|
845 | |
| 4890 | 846 | #endif /* _GAIM_UTIL_H_ */ |