annotate src/util.h @ 13093:4f615c9fb63a

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