Mercurial > pidgin
annotate libpurple/util.c @ 29414:623e60f8cb65
New-fangled toolbar code and all that.
*** Plucked rev 907442ea1932404e6753dbf649de9a5ea2406766 (qulogic@pidgin.im):
Update the toolbar code in the Debug Window. There remains a bug when it's
set to \"Icons and Text\", because all I see are the icons (and the one that
has no icon is blank). If I set the toolbar to \"Text Only\" or \"Icons Only\"
then it works correctly.
*** Plucked rev c84278b37825ba8ccdb2f6f02a3bc7903251efe1 (qulogic@pidgin.im):
Fix the Pause button in the debug window.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Sat, 20 Feb 2010 06:33:00 +0000 |
parents | 05d727f76ca9 |
children | 41142f2bcafb |
rev | line source |
---|---|
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2 * @file util.h Utility Functions |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3 * @ingroup core |
20074
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
4 */ |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
5 |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
6 /* Purple is the legal property of its developers, whose names are too numerous |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
7 * to list here. Please refer to the COPYRIGHT file distributed with this |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
8 * source distribution. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
9 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
10 * This program is free software; you can redistribute it and/or modify |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
11 * it under the terms of the GNU General Public License as published by |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
12 * the Free Software Foundation; either version 2 of the License, or |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
13 * (at your option) any later version. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
14 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
15 * This program is distributed in the hope that it will be useful, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
18 * GNU General Public License for more details. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
19 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
20 * You should have received a copy of the GNU General Public License |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
21 * along with this program; if not, write to the Free Software |
19681
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19662
diff
changeset
|
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
23 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
24 #include "internal.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
25 |
18039
c588a4a9d287
A patch from David Grohmann (dave1g) to log embedded images.
Richard Laager <rlaager@wiktel.com>
parents:
17765
diff
changeset
|
26 #include "cipher.h" |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
27 #include "conversation.h" |
15612
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
28 #include "core.h" |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
29 #include "debug.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
30 #include "notify.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
31 #include "prpl.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
32 #include "prefs.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
33 #include "util.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
34 |
15822 | 35 struct _PurpleUtilFetchUrlData |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
36 { |
15822 | 37 PurpleUtilFetchUrlCallback callback; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
38 void *user_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
39 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
40 struct |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
41 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
42 char *user; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
43 char *passwd; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
44 char *address; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
45 int port; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
46 char *page; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
47 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
48 } website; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
49 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
50 char *url; |
17450
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
51 int num_times_redirected; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
52 gboolean full; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
53 char *user_agent; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
54 gboolean http11; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
55 char *request; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
56 gsize request_written; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
57 gboolean include_headers; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
58 |
24592
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
59 gboolean is_ssl; |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
60 PurpleSslConnection *ssl_connection; |
15822 | 61 PurpleProxyConnectData *connect_data; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
62 int fd; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
63 guint inpa; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
64 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
65 gboolean got_headers; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
66 gboolean has_explicit_data_len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
67 char *webdata; |
27445
065294d973b4
This fixes this compile warning:
Stu Tomlinson <stu@nosnilmot.com>
parents:
27404
diff
changeset
|
68 gsize len; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
69 unsigned long data_len; |
23684
de8f2d3e538a
Add temporary purple_util_fetch_url_request_len and purple_util_fetch_url_len
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23666
diff
changeset
|
70 gssize max_len; |
27220
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
71 gboolean chunked; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
72 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
73 |
18147
5653692dcf79
Use dynamically allocated strings for the user_dir caching. Do we need to
Richard Laager <rlaager@wiktel.com>
parents:
18129
diff
changeset
|
74 static char *custom_user_dir = NULL; |
20091
2ab6b55ffa3d
Rename the internal home_dir variable to user_dir to match the function and
Richard Laager <rlaager@wiktel.com>
parents:
20074
diff
changeset
|
75 static char *user_dir = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
76 |
21248
5915ad785ee7
Add and call a purple_util_uninit() to free user_dir and customer_home_dir
Richard Laager <rlaager@wiktel.com>
parents:
20917
diff
changeset
|
77 |
15822 | 78 PurpleMenuAction * |
79 purple_menu_action_new(const char *label, PurpleCallback callback, gpointer data, | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
80 GList *children) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
81 { |
15822 | 82 PurpleMenuAction *act = g_new0(PurpleMenuAction, 1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
83 act->label = g_strdup(label); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
84 act->callback = callback; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
85 act->data = data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
86 act->children = children; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
87 return act; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
88 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
89 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
90 void |
15822 | 91 purple_menu_action_free(PurpleMenuAction *act) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
92 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
93 g_return_if_fail(act != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
94 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
95 g_free(act->label); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
96 g_free(act); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
97 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
98 |
21248
5915ad785ee7
Add and call a purple_util_uninit() to free user_dir and customer_home_dir
Richard Laager <rlaager@wiktel.com>
parents:
20917
diff
changeset
|
99 void |
5915ad785ee7
Add and call a purple_util_uninit() to free user_dir and customer_home_dir
Richard Laager <rlaager@wiktel.com>
parents:
20917
diff
changeset
|
100 purple_util_init(void) |
5915ad785ee7
Add and call a purple_util_uninit() to free user_dir and customer_home_dir
Richard Laager <rlaager@wiktel.com>
parents:
20917
diff
changeset
|
101 { |
25924
584063555949
Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents:
25894
diff
changeset
|
102 /* This does nothing right now. It exists for symmetry with |
21248
5915ad785ee7
Add and call a purple_util_uninit() to free user_dir and customer_home_dir
Richard Laager <rlaager@wiktel.com>
parents:
20917
diff
changeset
|
103 * purple_util_uninit() and forwards compatibility. */ |
5915ad785ee7
Add and call a purple_util_uninit() to free user_dir and customer_home_dir
Richard Laager <rlaager@wiktel.com>
parents:
20917
diff
changeset
|
104 } |
5915ad785ee7
Add and call a purple_util_uninit() to free user_dir and customer_home_dir
Richard Laager <rlaager@wiktel.com>
parents:
20917
diff
changeset
|
105 |
5915ad785ee7
Add and call a purple_util_uninit() to free user_dir and customer_home_dir
Richard Laager <rlaager@wiktel.com>
parents:
20917
diff
changeset
|
106 void |
5915ad785ee7
Add and call a purple_util_uninit() to free user_dir and customer_home_dir
Richard Laager <rlaager@wiktel.com>
parents:
20917
diff
changeset
|
107 purple_util_uninit(void) |
5915ad785ee7
Add and call a purple_util_uninit() to free user_dir and customer_home_dir
Richard Laager <rlaager@wiktel.com>
parents:
20917
diff
changeset
|
108 { |
5915ad785ee7
Add and call a purple_util_uninit() to free user_dir and customer_home_dir
Richard Laager <rlaager@wiktel.com>
parents:
20917
diff
changeset
|
109 /* Free these so we don't have leaks at shutdown. */ |
5915ad785ee7
Add and call a purple_util_uninit() to free user_dir and customer_home_dir
Richard Laager <rlaager@wiktel.com>
parents:
20917
diff
changeset
|
110 |
5915ad785ee7
Add and call a purple_util_uninit() to free user_dir and customer_home_dir
Richard Laager <rlaager@wiktel.com>
parents:
20917
diff
changeset
|
111 g_free(custom_user_dir); |
5915ad785ee7
Add and call a purple_util_uninit() to free user_dir and customer_home_dir
Richard Laager <rlaager@wiktel.com>
parents:
20917
diff
changeset
|
112 custom_user_dir = NULL; |
5915ad785ee7
Add and call a purple_util_uninit() to free user_dir and customer_home_dir
Richard Laager <rlaager@wiktel.com>
parents:
20917
diff
changeset
|
113 |
5915ad785ee7
Add and call a purple_util_uninit() to free user_dir and customer_home_dir
Richard Laager <rlaager@wiktel.com>
parents:
20917
diff
changeset
|
114 g_free(user_dir); |
5915ad785ee7
Add and call a purple_util_uninit() to free user_dir and customer_home_dir
Richard Laager <rlaager@wiktel.com>
parents:
20917
diff
changeset
|
115 user_dir = NULL; |
5915ad785ee7
Add and call a purple_util_uninit() to free user_dir and customer_home_dir
Richard Laager <rlaager@wiktel.com>
parents:
20917
diff
changeset
|
116 } |
5915ad785ee7
Add and call a purple_util_uninit() to free user_dir and customer_home_dir
Richard Laager <rlaager@wiktel.com>
parents:
20917
diff
changeset
|
117 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
118 /************************************************************************** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
119 * Base16 Functions |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
120 **************************************************************************/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
121 gchar * |
15822 | 122 purple_base16_encode(const guchar *data, gsize len) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
123 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
124 int i; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
125 gchar *ascii = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
126 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
127 g_return_val_if_fail(data != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
128 g_return_val_if_fail(len > 0, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
129 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
130 ascii = g_malloc(len * 2 + 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
131 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
132 for (i = 0; i < len; i++) |
26885
8290e36a5a73
A patch from Scott Wolchok to replace snprintf() with g_snprintf() and
Richard Laager <rlaager@wiktel.com>
parents:
26772
diff
changeset
|
133 g_snprintf(&ascii[i * 2], 3, "%02hhx", data[i]); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
134 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
135 return ascii; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
136 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
137 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
138 guchar * |
15822 | 139 purple_base16_decode(const char *str, gsize *ret_len) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
140 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
141 int len, i, accumulator = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
142 guchar *data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
143 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
144 g_return_val_if_fail(str != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
145 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
146 len = strlen(str); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
147 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
148 g_return_val_if_fail(strlen(str) > 0, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
149 g_return_val_if_fail(len % 2 == 0, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
150 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
151 data = g_malloc(len / 2); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
152 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
153 for (i = 0; i < len; i++) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
154 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
155 if ((i % 2) == 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
156 accumulator = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
157 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
158 accumulator <<= 4; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
159 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
160 if (isdigit(str[i])) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
161 accumulator |= str[i] - 48; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
162 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
163 { |
16153
6613fb7af427
Call strtolower() so that we don't have to check against the
Mark Doliner <mark@kingant.net>
parents:
16084
diff
changeset
|
164 switch(tolower(str[i])) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
165 { |
16153
6613fb7af427
Call strtolower() so that we don't have to check against the
Mark Doliner <mark@kingant.net>
parents:
16084
diff
changeset
|
166 case 'a': accumulator |= 10; break; |
6613fb7af427
Call strtolower() so that we don't have to check against the
Mark Doliner <mark@kingant.net>
parents:
16084
diff
changeset
|
167 case 'b': accumulator |= 11; break; |
6613fb7af427
Call strtolower() so that we don't have to check against the
Mark Doliner <mark@kingant.net>
parents:
16084
diff
changeset
|
168 case 'c': accumulator |= 12; break; |
6613fb7af427
Call strtolower() so that we don't have to check against the
Mark Doliner <mark@kingant.net>
parents:
16084
diff
changeset
|
169 case 'd': accumulator |= 13; break; |
6613fb7af427
Call strtolower() so that we don't have to check against the
Mark Doliner <mark@kingant.net>
parents:
16084
diff
changeset
|
170 case 'e': accumulator |= 14; break; |
6613fb7af427
Call strtolower() so that we don't have to check against the
Mark Doliner <mark@kingant.net>
parents:
16084
diff
changeset
|
171 case 'f': accumulator |= 15; break; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
172 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
173 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
174 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
175 if (i % 2) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
176 data[(i - 1) / 2] = accumulator; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
177 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
178 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
179 if (ret_len != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
180 *ret_len = len / 2; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
181 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
182 return data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
183 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
184 |
17765
ba768014f91f
- Add purple_base16_encode_chunked, which is handy for key fingerprints.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17195
diff
changeset
|
185 gchar * |
ba768014f91f
- Add purple_base16_encode_chunked, which is handy for key fingerprints.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17195
diff
changeset
|
186 purple_base16_encode_chunked(const guchar *data, gsize len) |
ba768014f91f
- Add purple_base16_encode_chunked, which is handy for key fingerprints.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17195
diff
changeset
|
187 { |
ba768014f91f
- Add purple_base16_encode_chunked, which is handy for key fingerprints.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17195
diff
changeset
|
188 int i; |
ba768014f91f
- Add purple_base16_encode_chunked, which is handy for key fingerprints.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17195
diff
changeset
|
189 gchar *ascii = NULL; |
ba768014f91f
- Add purple_base16_encode_chunked, which is handy for key fingerprints.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17195
diff
changeset
|
190 |
ba768014f91f
- Add purple_base16_encode_chunked, which is handy for key fingerprints.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17195
diff
changeset
|
191 g_return_val_if_fail(data != NULL, NULL); |
ba768014f91f
- Add purple_base16_encode_chunked, which is handy for key fingerprints.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17195
diff
changeset
|
192 g_return_val_if_fail(len > 0, NULL); |
ba768014f91f
- Add purple_base16_encode_chunked, which is handy for key fingerprints.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17195
diff
changeset
|
193 |
ba768014f91f
- Add purple_base16_encode_chunked, which is handy for key fingerprints.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17195
diff
changeset
|
194 /* For each byte of input, we need 2 bytes for the hex representation |
ba768014f91f
- Add purple_base16_encode_chunked, which is handy for key fingerprints.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17195
diff
changeset
|
195 * and 1 for the colon. |
ba768014f91f
- Add purple_base16_encode_chunked, which is handy for key fingerprints.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17195
diff
changeset
|
196 * The final colon will be replaced by a terminating NULL |
ba768014f91f
- Add purple_base16_encode_chunked, which is handy for key fingerprints.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17195
diff
changeset
|
197 */ |
ba768014f91f
- Add purple_base16_encode_chunked, which is handy for key fingerprints.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17195
diff
changeset
|
198 ascii = g_malloc(len * 3 + 1); |
ba768014f91f
- Add purple_base16_encode_chunked, which is handy for key fingerprints.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17195
diff
changeset
|
199 |
ba768014f91f
- Add purple_base16_encode_chunked, which is handy for key fingerprints.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17195
diff
changeset
|
200 for (i = 0; i < len; i++) |
ba768014f91f
- Add purple_base16_encode_chunked, which is handy for key fingerprints.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17195
diff
changeset
|
201 g_snprintf(&ascii[i * 3], 4, "%02hhx:", data[i]); |
ba768014f91f
- Add purple_base16_encode_chunked, which is handy for key fingerprints.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17195
diff
changeset
|
202 |
ba768014f91f
- Add purple_base16_encode_chunked, which is handy for key fingerprints.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17195
diff
changeset
|
203 /* Replace the final colon with NULL */ |
ba768014f91f
- Add purple_base16_encode_chunked, which is handy for key fingerprints.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17195
diff
changeset
|
204 ascii[len * 3 - 1] = 0; |
ba768014f91f
- Add purple_base16_encode_chunked, which is handy for key fingerprints.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17195
diff
changeset
|
205 |
ba768014f91f
- Add purple_base16_encode_chunked, which is handy for key fingerprints.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17195
diff
changeset
|
206 return ascii; |
ba768014f91f
- Add purple_base16_encode_chunked, which is handy for key fingerprints.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17195
diff
changeset
|
207 } |
ba768014f91f
- Add purple_base16_encode_chunked, which is handy for key fingerprints.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17195
diff
changeset
|
208 |
ba768014f91f
- Add purple_base16_encode_chunked, which is handy for key fingerprints.
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17195
diff
changeset
|
209 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
210 /************************************************************************** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
211 * Base64 Functions |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
212 **************************************************************************/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
213 static const char alphabet[] = |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
214 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
215 "0123456789+/"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
216 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
217 static const char xdigits[] = |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
218 "0123456789abcdef"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
219 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
220 gchar * |
15822 | 221 purple_base64_encode(const guchar *data, gsize len) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
222 { |
27217
3d92b968d49f
Use glib's base64 encode and decode functions if they're available.
Mark Doliner <mark@kingant.net>
parents:
27137
diff
changeset
|
223 return g_base64_encode(data, len); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
224 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
225 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
226 guchar * |
15822 | 227 purple_base64_decode(const char *str, gsize *ret_len) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
228 { |
27217
3d92b968d49f
Use glib's base64 encode and decode functions if they're available.
Mark Doliner <mark@kingant.net>
parents:
27137
diff
changeset
|
229 /* |
3d92b968d49f
Use glib's base64 encode and decode functions if they're available.
Mark Doliner <mark@kingant.net>
parents:
27137
diff
changeset
|
230 * We want to allow ret_len to be NULL for backward compatibility, |
3d92b968d49f
Use glib's base64 encode and decode functions if they're available.
Mark Doliner <mark@kingant.net>
parents:
27137
diff
changeset
|
231 * but g_base64_decode() requires a valid length variable. So if |
3d92b968d49f
Use glib's base64 encode and decode functions if they're available.
Mark Doliner <mark@kingant.net>
parents:
27137
diff
changeset
|
232 * ret_len is NULL then pass in a dummy variable. |
3d92b968d49f
Use glib's base64 encode and decode functions if they're available.
Mark Doliner <mark@kingant.net>
parents:
27137
diff
changeset
|
233 */ |
3d92b968d49f
Use glib's base64 encode and decode functions if they're available.
Mark Doliner <mark@kingant.net>
parents:
27137
diff
changeset
|
234 gsize unused; |
3d92b968d49f
Use glib's base64 encode and decode functions if they're available.
Mark Doliner <mark@kingant.net>
parents:
27137
diff
changeset
|
235 return g_base64_decode(str, ret_len != NULL ? ret_len : &unused); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
236 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
237 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
238 /************************************************************************** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
239 * Quoted Printable Functions (see RFC 2045). |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
240 **************************************************************************/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
241 guchar * |
15822 | 242 purple_quotedp_decode(const char *str, gsize *ret_len) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
243 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
244 char *n, *new; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
245 const char *end, *p; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
246 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
247 n = new = g_malloc(strlen (str) + 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
248 end = str + strlen(str); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
249 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
250 for (p = str; p < end; p++, n++) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
251 if (*p == '=') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
252 if (p[1] == '\r' && p[2] == '\n') { /* 5.1 #5 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
253 n -= 1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
254 p += 2; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
255 } else if (p[1] == '\n') { /* fuzzy case for 5.1 #5 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
256 n -= 1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
257 p += 1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
258 } else if (p[1] && p[2]) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
259 char *nibble1 = strchr(xdigits, tolower(p[1])); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
260 char *nibble2 = strchr(xdigits, tolower(p[2])); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
261 if (nibble1 && nibble2) { /* 5.1 #1 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
262 *n = ((nibble1 - xdigits) << 4) | (nibble2 - xdigits); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
263 p += 2; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
264 } else { /* This should never happen */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
265 *n = *p; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
266 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
267 } else { /* This should never happen */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
268 *n = *p; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
269 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
270 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
271 else if (*p == '_') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
272 *n = ' '; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
273 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
274 *n = *p; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
275 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
276 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
277 *n = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
278 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
279 if (ret_len != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
280 *ret_len = n - new; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
281 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
282 /* Resize to take less space */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
283 /* new = realloc(new, n - new); */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
284 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
285 return (guchar *)new; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
286 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
287 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
288 /************************************************************************** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
289 * MIME Functions |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
290 **************************************************************************/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
291 char * |
15822 | 292 purple_mime_decode_field(const char *str) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
293 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
294 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
295 * This is wing's version, partially based on revo/shx's version |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
296 * See RFC2047 [which apparently obsoletes RFC1342] |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
297 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
298 typedef enum { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
299 state_start, state_equal1, state_question1, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
300 state_charset, state_question2, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
301 state_encoding, state_question3, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
302 state_encoded_text, state_question4, state_equal2 = state_start |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
303 } encoded_word_state_t; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
304 encoded_word_state_t state = state_start; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
305 const char *cur, *mark; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
306 const char *charset0 = NULL, *encoding0 = NULL, *encoded_text0 = NULL; |
27907
9358464cdf6a
How about we just use a GString instead of this ridiculous
Mark Doliner <mark@kingant.net>
parents:
27860
diff
changeset
|
307 GString *new; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
308 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
309 /* token can be any CHAR (supposedly ISO8859-1/ISO2022), not just ASCII */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
310 #define token_char_p(c) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
311 (c != ' ' && !iscntrl(c) && !strchr("()<>@,;:\"/[]?.=", c)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
312 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
313 /* But encoded-text must be ASCII; alas, isascii() may not exist */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
314 #define encoded_text_char_p(c) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
315 ((c & 0x80) == 0 && c != '?' && c != ' ' && isgraph(c)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
316 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
317 g_return_val_if_fail(str != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
318 |
27907
9358464cdf6a
How about we just use a GString instead of this ridiculous
Mark Doliner <mark@kingant.net>
parents:
27860
diff
changeset
|
319 new = g_string_new(NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
320 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
321 /* Here we will be looking for encoded words and if they seem to be |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
322 * valid then decode them. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
323 * They are of this form: =?charset?encoding?text?= |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
324 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
325 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
326 for (cur = str, mark = NULL; *cur; cur += 1) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
327 switch (state) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
328 case state_equal1: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
329 if (*cur == '?') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
330 state = state_question1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
331 } else { |
27907
9358464cdf6a
How about we just use a GString instead of this ridiculous
Mark Doliner <mark@kingant.net>
parents:
27860
diff
changeset
|
332 g_string_append_len(new, mark, cur - mark + 1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
333 state = state_start; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
334 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
335 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
336 case state_question1: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
337 if (token_char_p(*cur)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
338 charset0 = cur; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
339 state = state_charset; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
340 } else { /* This should never happen */ |
27907
9358464cdf6a
How about we just use a GString instead of this ridiculous
Mark Doliner <mark@kingant.net>
parents:
27860
diff
changeset
|
341 g_string_append_len(new, mark, cur - mark + 1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
342 state = state_start; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
343 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
344 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
345 case state_charset: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
346 if (*cur == '?') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
347 state = state_question2; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
348 } else if (!token_char_p(*cur)) { /* This should never happen */ |
27907
9358464cdf6a
How about we just use a GString instead of this ridiculous
Mark Doliner <mark@kingant.net>
parents:
27860
diff
changeset
|
349 g_string_append_len(new, mark, cur - mark + 1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
350 state = state_start; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
351 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
352 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
353 case state_question2: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
354 if (token_char_p(*cur)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
355 encoding0 = cur; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
356 state = state_encoding; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
357 } else { /* This should never happen */ |
27907
9358464cdf6a
How about we just use a GString instead of this ridiculous
Mark Doliner <mark@kingant.net>
parents:
27860
diff
changeset
|
358 g_string_append_len(new, mark, cur - mark + 1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
359 state = state_start; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
360 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
361 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
362 case state_encoding: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
363 if (*cur == '?') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
364 state = state_question3; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
365 } else if (!token_char_p(*cur)) { /* This should never happen */ |
27907
9358464cdf6a
How about we just use a GString instead of this ridiculous
Mark Doliner <mark@kingant.net>
parents:
27860
diff
changeset
|
366 g_string_append_len(new, mark, cur - mark + 1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
367 state = state_start; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
368 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
369 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
370 case state_question3: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
371 if (encoded_text_char_p(*cur)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
372 encoded_text0 = cur; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
373 state = state_encoded_text; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
374 } else if (*cur == '?') { /* empty string */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
375 encoded_text0 = cur; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
376 state = state_question4; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
377 } else { /* This should never happen */ |
27907
9358464cdf6a
How about we just use a GString instead of this ridiculous
Mark Doliner <mark@kingant.net>
parents:
27860
diff
changeset
|
378 g_string_append_len(new, mark, cur - mark + 1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
379 state = state_start; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
380 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
381 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
382 case state_encoded_text: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
383 if (*cur == '?') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
384 state = state_question4; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
385 } else if (!encoded_text_char_p(*cur)) { |
27907
9358464cdf6a
How about we just use a GString instead of this ridiculous
Mark Doliner <mark@kingant.net>
parents:
27860
diff
changeset
|
386 g_string_append_len(new, mark, cur - mark + 1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
387 state = state_start; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
388 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
389 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
390 case state_question4: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
391 if (*cur == '=') { /* Got the whole encoded-word */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
392 char *charset = g_strndup(charset0, encoding0 - charset0 - 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
393 char *encoding = g_strndup(encoding0, encoded_text0 - encoding0 - 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
394 char *encoded_text = g_strndup(encoded_text0, cur - encoded_text0 - 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
395 guchar *decoded = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
396 gsize dec_len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
397 if (g_ascii_strcasecmp(encoding, "Q") == 0) |
15822 | 398 decoded = purple_quotedp_decode(encoded_text, &dec_len); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
399 else if (g_ascii_strcasecmp(encoding, "B") == 0) |
15822 | 400 decoded = purple_base64_decode(encoded_text, &dec_len); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
401 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
402 decoded = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
403 if (decoded) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
404 gsize len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
405 char *converted = g_convert((const gchar *)decoded, dec_len, "utf-8", charset, NULL, &len, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
406 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
407 if (converted) { |
27907
9358464cdf6a
How about we just use a GString instead of this ridiculous
Mark Doliner <mark@kingant.net>
parents:
27860
diff
changeset
|
408 g_string_append_len(new, converted, len); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
409 g_free(converted); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
410 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
411 g_free(decoded); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
412 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
413 g_free(charset); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
414 g_free(encoding); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
415 g_free(encoded_text); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
416 state = state_equal2; /* Restart the FSM */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
417 } else { /* This should never happen */ |
27907
9358464cdf6a
How about we just use a GString instead of this ridiculous
Mark Doliner <mark@kingant.net>
parents:
27860
diff
changeset
|
418 g_string_append_len(new, mark, cur - mark + 1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
419 state = state_start; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
420 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
421 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
422 default: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
423 if (*cur == '=') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
424 mark = cur; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
425 state = state_equal1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
426 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
427 /* Some unencoded text. */ |
27907
9358464cdf6a
How about we just use a GString instead of this ridiculous
Mark Doliner <mark@kingant.net>
parents:
27860
diff
changeset
|
428 g_string_append_c(new, *cur); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
429 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
430 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
431 } /* switch */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
432 } /* for */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
433 |
27907
9358464cdf6a
How about we just use a GString instead of this ridiculous
Mark Doliner <mark@kingant.net>
parents:
27860
diff
changeset
|
434 if (state != state_start) |
9358464cdf6a
How about we just use a GString instead of this ridiculous
Mark Doliner <mark@kingant.net>
parents:
27860
diff
changeset
|
435 g_string_append_len(new, mark, cur - mark + 1); |
9358464cdf6a
How about we just use a GString instead of this ridiculous
Mark Doliner <mark@kingant.net>
parents:
27860
diff
changeset
|
436 |
9358464cdf6a
How about we just use a GString instead of this ridiculous
Mark Doliner <mark@kingant.net>
parents:
27860
diff
changeset
|
437 return g_string_free(new, FALSE);; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
438 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
439 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
440 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
441 /************************************************************************** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
442 * Date/Time Functions |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
443 **************************************************************************/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
444 |
18259
c5c265dff90c
support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents:
18147
diff
changeset
|
445 const char *purple_get_tzoff_str(const struct tm *tm, gboolean iso) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
446 { |
18259
c5c265dff90c
support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents:
18147
diff
changeset
|
447 static char buf[7]; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
448 long off; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
449 gint8 min; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
450 gint8 hrs; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
451 struct tm new_tm = *tm; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
452 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
453 mktime(&new_tm); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
454 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
455 if (new_tm.tm_isdst < 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
456 g_return_val_if_reached(""); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
457 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
458 #ifdef _WIN32 |
20503
905891855710
3rd time the charm? Fixes #2990, maybe
Ka-Hing Cheung <khc@hxbc.us>
parents:
19499
diff
changeset
|
459 if ((off = wpurple_get_tz_offset()) == -1) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
460 return ""; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
461 #else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
462 # ifdef HAVE_TM_GMTOFF |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
463 off = new_tm.tm_gmtoff; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
464 # else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
465 # ifdef HAVE_TIMEZONE |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
466 tzset(); |
18259
c5c265dff90c
support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents:
18147
diff
changeset
|
467 off = -1 * timezone; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
468 # endif /* HAVE_TIMEZONE */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
469 # endif /* !HAVE_TM_GMTOFF */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
470 #endif /* _WIN32 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
471 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
472 min = (off / 60) % 60; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
473 hrs = ((off / 60) - min) / 60; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
474 |
18259
c5c265dff90c
support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents:
18147
diff
changeset
|
475 if(iso) { |
c5c265dff90c
support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents:
18147
diff
changeset
|
476 if (0 == off) { |
c5c265dff90c
support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents:
18147
diff
changeset
|
477 strcpy(buf, "Z"); |
c5c265dff90c
support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents:
18147
diff
changeset
|
478 } else { |
c5c265dff90c
support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents:
18147
diff
changeset
|
479 /* please leave the colons...they're optional for iso, but jabber |
c5c265dff90c
support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents:
18147
diff
changeset
|
480 * wants them */ |
c5c265dff90c
support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents:
18147
diff
changeset
|
481 if(g_snprintf(buf, sizeof(buf), "%+03d:%02d", hrs, ABS(min)) > 6) |
c5c265dff90c
support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents:
18147
diff
changeset
|
482 g_return_val_if_reached(""); |
c5c265dff90c
support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents:
18147
diff
changeset
|
483 } |
c5c265dff90c
support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents:
18147
diff
changeset
|
484 } else { |
c5c265dff90c
support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents:
18147
diff
changeset
|
485 if (g_snprintf(buf, sizeof(buf), "%+03d%02d", hrs, ABS(min)) > 5) |
c5c265dff90c
support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents:
18147
diff
changeset
|
486 g_return_val_if_reached(""); |
c5c265dff90c
support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents:
18147
diff
changeset
|
487 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
488 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
489 return buf; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
490 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
491 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
492 /* Windows doesn't HAVE_STRFTIME_Z_FORMAT, but this seems clearer. -- rlaager */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
493 #if !defined(HAVE_STRFTIME_Z_FORMAT) || defined(_WIN32) |
15822 | 494 static size_t purple_internal_strftime(char *s, size_t max, const char *format, const struct tm *tm) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
495 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
496 const char *start; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
497 const char *c; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
498 char *fmt = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
499 |
15822 | 500 /* Yes, this is checked in purple_utf8_strftime(), |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
501 * but better safe than sorry. -- rlaager */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
502 g_return_val_if_fail(format != NULL, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
503 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
504 /* This is fairly efficient, and it only gets |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
505 * executed on Windows or if the underlying |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
506 * system doesn't support the %z format string, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
507 * for strftime() so I think it's good enough. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
508 * -- rlaager */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
509 for (c = start = format; *c ; c++) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
510 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
511 if (*c != '%') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
512 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
513 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
514 c++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
515 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
516 #ifndef HAVE_STRFTIME_Z_FORMAT |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
517 if (*c == 'z') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
518 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
519 char *tmp = g_strdup_printf("%s%.*s%s", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
520 fmt ? fmt : "", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
521 c - start - 1, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
522 start, |
18259
c5c265dff90c
support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents:
18147
diff
changeset
|
523 purple_get_tzoff_str(tm, FALSE)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
524 g_free(fmt); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
525 fmt = tmp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
526 start = c + 1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
527 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
528 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
529 #ifdef _WIN32 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
530 if (*c == 'Z') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
531 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
532 char *tmp = g_strdup_printf("%s%.*s%s", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
533 fmt ? fmt : "", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
534 c - start - 1, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
535 start, |
15822 | 536 wpurple_get_timezone_abbreviation(tm)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
537 g_free(fmt); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
538 fmt = tmp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
539 start = c + 1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
540 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
541 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
542 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
543 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
544 if (fmt != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
545 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
546 size_t ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
547 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
548 if (*start) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
549 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
550 char *tmp = g_strconcat(fmt, start, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
551 g_free(fmt); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
552 fmt = tmp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
553 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
554 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
555 ret = strftime(s, max, fmt, tm); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
556 g_free(fmt); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
557 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
558 return ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
559 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
560 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
561 return strftime(s, max, format, tm); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
562 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
563 #else /* HAVE_STRFTIME_Z_FORMAT && !_WIN32 */ |
15822 | 564 #define purple_internal_strftime strftime |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
565 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
566 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
567 const char * |
15822 | 568 purple_utf8_strftime(const char *format, const struct tm *tm) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
569 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
570 static char buf[128]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
571 char *locale; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
572 GError *err = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
573 int len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
574 char *utf8; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
575 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
576 g_return_val_if_fail(format != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
577 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
578 if (tm == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
579 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
580 time_t now = time(NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
581 tm = localtime(&now); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
582 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
583 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
584 locale = g_locale_from_utf8(format, -1, NULL, NULL, &err); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
585 if (err != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
586 { |
19654
941965d6fd88
Patch from QuLogic. Fixes #2903 ('Missing newlines in debug messages.')
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19603
diff
changeset
|
587 purple_debug_error("util", "Format conversion failed in purple_utf8_strftime(): %s\n", err->message); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
588 g_error_free(err); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
589 locale = g_strdup(format); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
590 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
591 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
592 /* A return value of 0 is either an error (in |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
593 * which case, the contents of the buffer are |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
594 * undefined) or the empty string (in which |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
595 * case, no harm is done here). */ |
15822 | 596 if ((len = purple_internal_strftime(buf, sizeof(buf), locale, tm)) == 0) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
597 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
598 g_free(locale); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
599 return ""; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
600 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
601 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
602 g_free(locale); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
603 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
604 utf8 = g_locale_to_utf8(buf, len, NULL, NULL, &err); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
605 if (err != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
606 { |
19654
941965d6fd88
Patch from QuLogic. Fixes #2903 ('Missing newlines in debug messages.')
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19603
diff
changeset
|
607 purple_debug_error("util", "Result conversion failed in purple_utf8_strftime(): %s\n", err->message); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
608 g_error_free(err); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
609 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
610 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
611 { |
15822 | 612 purple_strlcpy(buf, utf8); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
613 g_free(utf8); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
614 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
615 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
616 return buf; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
617 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
618 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
619 const char * |
15822 | 620 purple_date_format_short(const struct tm *tm) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
621 { |
15822 | 622 return purple_utf8_strftime("%x", tm); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
623 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
624 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
625 const char * |
15822 | 626 purple_date_format_long(const struct tm *tm) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
627 { |
23666
187a3649f04b
Add a note for translators, because they probably have no idea what
Mark Doliner <mark@kingant.net>
parents:
23652
diff
changeset
|
628 /* |
187a3649f04b
Add a note for translators, because they probably have no idea what
Mark Doliner <mark@kingant.net>
parents:
23652
diff
changeset
|
629 * This string determines how some dates are displayed. The default |
187a3649f04b
Add a note for translators, because they probably have no idea what
Mark Doliner <mark@kingant.net>
parents:
23652
diff
changeset
|
630 * string "%x %X" shows the date then the time. Translators can |
187a3649f04b
Add a note for translators, because they probably have no idea what
Mark Doliner <mark@kingant.net>
parents:
23652
diff
changeset
|
631 * change this to "%X %x" if they want the time to be shown first, |
187a3649f04b
Add a note for translators, because they probably have no idea what
Mark Doliner <mark@kingant.net>
parents:
23652
diff
changeset
|
632 * followed by the date. |
187a3649f04b
Add a note for translators, because they probably have no idea what
Mark Doliner <mark@kingant.net>
parents:
23652
diff
changeset
|
633 */ |
15822 | 634 return purple_utf8_strftime(_("%x %X"), tm); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
635 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
636 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
637 const char * |
15822 | 638 purple_date_format_full(const struct tm *tm) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
639 { |
15822 | 640 return purple_utf8_strftime("%c", tm); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
641 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
642 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
643 const char * |
15822 | 644 purple_time_format(const struct tm *tm) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
645 { |
15822 | 646 return purple_utf8_strftime("%X", tm); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
647 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
648 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
649 time_t |
15822 | 650 purple_time_build(int year, int month, int day, int hour, int min, int sec) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
651 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
652 struct tm tm; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
653 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
654 tm.tm_year = year - 1900; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
655 tm.tm_mon = month - 1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
656 tm.tm_mday = day; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
657 tm.tm_hour = hour; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
658 tm.tm_min = min; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
659 tm.tm_sec = sec >= 0 ? sec : time(NULL) % 60; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
660 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
661 return mktime(&tm); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
662 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
663 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
664 time_t |
15822 | 665 purple_str_to_time(const char *timestamp, gboolean utc, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
666 struct tm *tm, long *tz_off, const char **rest) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
667 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
668 time_t retval = 0; |
21613
31101e7d275f
'man 3 ctime' says of localtime() (and friends):
Stu Tomlinson <stu@nosnilmot.com>
parents:
21612
diff
changeset
|
669 static struct tm t; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
670 const char *c = timestamp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
671 int year = 0; |
15822 | 672 long tzoff = PURPLE_NO_TZ_OFF; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
673 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
674 time(&retval); |
21613
31101e7d275f
'man 3 ctime' says of localtime() (and friends):
Stu Tomlinson <stu@nosnilmot.com>
parents:
21612
diff
changeset
|
675 localtime_r(&retval, &t); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
676 |
23975
b789b54c5bb2
purple_str_to_time() didn't necessarily set "rest" under all circumstances.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23734
diff
changeset
|
677 if (rest != NULL) |
b789b54c5bb2
purple_str_to_time() didn't necessarily set "rest" under all circumstances.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23734
diff
changeset
|
678 *rest = NULL; |
b789b54c5bb2
purple_str_to_time() didn't necessarily set "rest" under all circumstances.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23734
diff
changeset
|
679 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
680 /* 4 digit year */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
681 if (sscanf(c, "%04d", &year) && year > 1900) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
682 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
683 c += 4; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
684 if (*c == '-') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
685 c++; |
21613
31101e7d275f
'man 3 ctime' says of localtime() (and friends):
Stu Tomlinson <stu@nosnilmot.com>
parents:
21612
diff
changeset
|
686 t.tm_year = year - 1900; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
687 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
688 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
689 /* 2 digit month */ |
21613
31101e7d275f
'man 3 ctime' says of localtime() (and friends):
Stu Tomlinson <stu@nosnilmot.com>
parents:
21612
diff
changeset
|
690 if (!sscanf(c, "%02d", &t.tm_mon)) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
691 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
692 if (rest != NULL && *c != '\0') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
693 *rest = c; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
694 return 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
695 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
696 c += 2; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
697 if (*c == '-' || *c == '/') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
698 c++; |
21613
31101e7d275f
'man 3 ctime' says of localtime() (and friends):
Stu Tomlinson <stu@nosnilmot.com>
parents:
21612
diff
changeset
|
699 t.tm_mon -= 1; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
700 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
701 /* 2 digit day */ |
21613
31101e7d275f
'man 3 ctime' says of localtime() (and friends):
Stu Tomlinson <stu@nosnilmot.com>
parents:
21612
diff
changeset
|
702 if (!sscanf(c, "%02d", &t.tm_mday)) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
703 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
704 if (rest != NULL && *c != '\0') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
705 *rest = c; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
706 return 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
707 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
708 c += 2; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
709 if (*c == '/') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
710 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
711 c++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
712 |
21613
31101e7d275f
'man 3 ctime' says of localtime() (and friends):
Stu Tomlinson <stu@nosnilmot.com>
parents:
21612
diff
changeset
|
713 if (!sscanf(c, "%04d", &t.tm_year)) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
714 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
715 if (rest != NULL && *c != '\0') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
716 *rest = c; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
717 return 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
718 } |
21613
31101e7d275f
'man 3 ctime' says of localtime() (and friends):
Stu Tomlinson <stu@nosnilmot.com>
parents:
21612
diff
changeset
|
719 t.tm_year -= 1900; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
720 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
721 else if (*c == 'T' || *c == '.') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
722 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
723 c++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
724 /* we have more than a date, keep going */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
725 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
726 /* 2 digit hour */ |
21613
31101e7d275f
'man 3 ctime' says of localtime() (and friends):
Stu Tomlinson <stu@nosnilmot.com>
parents:
21612
diff
changeset
|
727 if ((sscanf(c, "%02d:%02d:%02d", &t.tm_hour, &t.tm_min, &t.tm_sec) == 3 && (c = c + 8)) || |
31101e7d275f
'man 3 ctime' says of localtime() (and friends):
Stu Tomlinson <stu@nosnilmot.com>
parents:
21612
diff
changeset
|
728 (sscanf(c, "%02d%02d%02d", &t.tm_hour, &t.tm_min, &t.tm_sec) == 3 && (c = c + 6))) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
729 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
730 gboolean offset_positive = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
731 int tzhrs; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
732 int tzmins; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
733 |
21613
31101e7d275f
'man 3 ctime' says of localtime() (and friends):
Stu Tomlinson <stu@nosnilmot.com>
parents:
21612
diff
changeset
|
734 t.tm_isdst = -1; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
735 |
21611
87387eac4348
Fix a bug in purple_str_to_time() that could cause it to try reading past
Stu Tomlinson <stu@nosnilmot.com>
parents:
21580
diff
changeset
|
736 if (*c == '.') { |
87387eac4348
Fix a bug in purple_str_to_time() that could cause it to try reading past
Stu Tomlinson <stu@nosnilmot.com>
parents:
21580
diff
changeset
|
737 do { |
87387eac4348
Fix a bug in purple_str_to_time() that could cause it to try reading past
Stu Tomlinson <stu@nosnilmot.com>
parents:
21580
diff
changeset
|
738 c++; |
87387eac4348
Fix a bug in purple_str_to_time() that could cause it to try reading past
Stu Tomlinson <stu@nosnilmot.com>
parents:
21580
diff
changeset
|
739 } while (*c >= '0' && *c <= '9'); /* dealing with precision we don't care about */ |
87387eac4348
Fix a bug in purple_str_to_time() that could cause it to try reading past
Stu Tomlinson <stu@nosnilmot.com>
parents:
21580
diff
changeset
|
740 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
741 if (*c == '+') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
742 offset_positive = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
743 if (((*c == '+' || *c == '-') && (c = c + 1)) && |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
744 ((sscanf(c, "%02d:%02d", &tzhrs, &tzmins) == 2 && (c = c + 5)) || |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
745 (sscanf(c, "%02d%02d", &tzhrs, &tzmins) == 2 && (c = c + 4)))) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
746 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
747 tzoff = tzhrs*60*60 + tzmins*60; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
748 if (offset_positive) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
749 tzoff *= -1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
750 } |
23365
ef4dbd2bb696
Allow a 'Z' (UTC) TZ in strings passed to purple_str_to_time. Used for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23248
diff
changeset
|
751 else if ((*c == 'Z') && (c = c + 1)) |
ef4dbd2bb696
Allow a 'Z' (UTC) TZ in strings passed to purple_str_to_time. Used for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23248
diff
changeset
|
752 { |
ef4dbd2bb696
Allow a 'Z' (UTC) TZ in strings passed to purple_str_to_time. Used for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23248
diff
changeset
|
753 /* 'Z' = Zulu = UTC */ |
ef4dbd2bb696
Allow a 'Z' (UTC) TZ in strings passed to purple_str_to_time. Used for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23248
diff
changeset
|
754 tzoff = 0; |
ef4dbd2bb696
Allow a 'Z' (UTC) TZ in strings passed to purple_str_to_time. Used for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23248
diff
changeset
|
755 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
756 else if (utc) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
757 { |
21613
31101e7d275f
'man 3 ctime' says of localtime() (and friends):
Stu Tomlinson <stu@nosnilmot.com>
parents:
21612
diff
changeset
|
758 static struct tm tmptm; |
21612
18fb032a602a
Fix the bug in purple_str_to_time() that was causing 'make check' to fail.
Stu Tomlinson <stu@nosnilmot.com>
parents:
21611
diff
changeset
|
759 time_t tmp; |
21613
31101e7d275f
'man 3 ctime' says of localtime() (and friends):
Stu Tomlinson <stu@nosnilmot.com>
parents:
21612
diff
changeset
|
760 tmp = mktime(&t); |
21612
18fb032a602a
Fix the bug in purple_str_to_time() that was causing 'make check' to fail.
Stu Tomlinson <stu@nosnilmot.com>
parents:
21611
diff
changeset
|
761 /* we care about whether it *was* dst, and the offset, here on this |
18fb032a602a
Fix the bug in purple_str_to_time() that was causing 'make check' to fail.
Stu Tomlinson <stu@nosnilmot.com>
parents:
21611
diff
changeset
|
762 * date, not whether we are currently observing dst locally *now*. |
18fb032a602a
Fix the bug in purple_str_to_time() that was causing 'make check' to fail.
Stu Tomlinson <stu@nosnilmot.com>
parents:
21611
diff
changeset
|
763 * This isn't perfect, because we would need to know in advance the |
18fb032a602a
Fix the bug in purple_str_to_time() that was causing 'make check' to fail.
Stu Tomlinson <stu@nosnilmot.com>
parents:
21611
diff
changeset
|
764 * offset we are trying to work out in advance to be sure this |
18fb032a602a
Fix the bug in purple_str_to_time() that was causing 'make check' to fail.
Stu Tomlinson <stu@nosnilmot.com>
parents:
21611
diff
changeset
|
765 * works for times around dst transitions but it'll have to do. */ |
21613
31101e7d275f
'man 3 ctime' says of localtime() (and friends):
Stu Tomlinson <stu@nosnilmot.com>
parents:
21612
diff
changeset
|
766 localtime_r(&tmp, &tmptm); |
31101e7d275f
'man 3 ctime' says of localtime() (and friends):
Stu Tomlinson <stu@nosnilmot.com>
parents:
21612
diff
changeset
|
767 t.tm_isdst = tmptm.tm_isdst; |
21612
18fb032a602a
Fix the bug in purple_str_to_time() that was causing 'make check' to fail.
Stu Tomlinson <stu@nosnilmot.com>
parents:
21611
diff
changeset
|
768 #ifdef HAVE_TM_GMTOFF |
21613
31101e7d275f
'man 3 ctime' says of localtime() (and friends):
Stu Tomlinson <stu@nosnilmot.com>
parents:
21612
diff
changeset
|
769 t.tm_gmtoff = tmptm.tm_gmtoff; |
21612
18fb032a602a
Fix the bug in purple_str_to_time() that was causing 'make check' to fail.
Stu Tomlinson <stu@nosnilmot.com>
parents:
21611
diff
changeset
|
770 #endif |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
771 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
772 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
773 if (rest != NULL && *c != '\0') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
774 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
775 if (*c == ' ') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
776 c++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
777 if (*c != '\0') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
778 *rest = c; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
779 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
780 |
15822 | 781 if (tzoff != PURPLE_NO_TZ_OFF || utc) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
782 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
783 #if defined(_WIN32) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
784 long sys_tzoff; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
785 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
786 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
787 #if defined(_WIN32) || defined(HAVE_TM_GMTOFF) || defined (HAVE_TIMEZONE) |
15822 | 788 if (tzoff == PURPLE_NO_TZ_OFF) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
789 tzoff = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
790 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
791 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
792 #ifdef _WIN32 |
20503
905891855710
3rd time the charm? Fixes #2990, maybe
Ka-Hing Cheung <khc@hxbc.us>
parents:
19499
diff
changeset
|
793 if ((sys_tzoff = wpurple_get_tz_offset()) == -1) |
15822 | 794 tzoff = PURPLE_NO_TZ_OFF; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
795 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
796 tzoff += sys_tzoff; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
797 #else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
798 #ifdef HAVE_TM_GMTOFF |
21613
31101e7d275f
'man 3 ctime' says of localtime() (and friends):
Stu Tomlinson <stu@nosnilmot.com>
parents:
21612
diff
changeset
|
799 tzoff += t.tm_gmtoff; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
800 #else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
801 # ifdef HAVE_TIMEZONE |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
802 tzset(); /* making sure */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
803 tzoff -= timezone; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
804 # endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
805 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
806 #endif /* _WIN32 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
807 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
808 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
809 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
810 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
811 if (rest != NULL && *c != '\0') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
812 *rest = c; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
813 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
814 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
815 |
22896
8dadddab10ed
Fix purple_str_to_time() to not break the returned value when we have given
Richard Laager <rlaager@wiktel.com>
parents:
22864
diff
changeset
|
816 retval = mktime(&t); |
8dadddab10ed
Fix purple_str_to_time() to not break the returned value when we have given
Richard Laager <rlaager@wiktel.com>
parents:
22864
diff
changeset
|
817 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
818 if (tm != NULL) |
21621
b2aa68cdc8b9
I had used memcpy to copy the struct tm to where the caller wants it, but
Stu Tomlinson <stu@nosnilmot.com>
parents:
21613
diff
changeset
|
819 *tm = t; |
22896
8dadddab10ed
Fix purple_str_to_time() to not break the returned value when we have given
Richard Laager <rlaager@wiktel.com>
parents:
22864
diff
changeset
|
820 |
15822 | 821 if (tzoff != PURPLE_NO_TZ_OFF) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
822 retval += tzoff; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
823 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
824 if (tz_off != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
825 *tz_off = tzoff; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
826 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
827 return retval; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
828 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
829 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
830 /************************************************************************** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
831 * Markup Functions |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
832 **************************************************************************/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
833 |
27393
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
834 /* |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
835 * This function is stolen from glib's gmarkup.c and modified to not |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
836 * replace ' with ' |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
837 */ |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
838 static void append_escaped_text(GString *str, |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
839 const gchar *text, gssize length) |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
840 { |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
841 const gchar *p; |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
842 const gchar *end; |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
843 gunichar c; |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
844 |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
845 p = text; |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
846 end = text + length; |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
847 |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
848 while (p != end) |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
849 { |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
850 const gchar *next; |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
851 next = g_utf8_next_char (p); |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
852 |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
853 switch (*p) |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
854 { |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
855 case '&': |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
856 g_string_append (str, "&"); |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
857 break; |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
858 |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
859 case '<': |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
860 g_string_append (str, "<"); |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
861 break; |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
862 |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
863 case '>': |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
864 g_string_append (str, ">"); |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
865 break; |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
866 |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
867 case '"': |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
868 g_string_append (str, """); |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
869 break; |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
870 |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
871 default: |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
872 c = g_utf8_get_char (p); |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
873 if ((0x1 <= c && c <= 0x8) || |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
874 (0xb <= c && c <= 0xc) || |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
875 (0xe <= c && c <= 0x1f) || |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
876 (0x7f <= c && c <= 0x84) || |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
877 (0x86 <= c && c <= 0x9f)) |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
878 g_string_append_printf (str, "&#x%x;", c); |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
879 else |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
880 g_string_append_len (str, p, next - p); |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
881 break; |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
882 } |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
883 |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
884 p = next; |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
885 } |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
886 } |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
887 |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
888 /* This function is stolen from glib's gmarkup.c */ |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
889 gchar *purple_markup_escape_text(const gchar *text, gssize length) |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
890 { |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
891 GString *str; |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
892 |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
893 g_return_val_if_fail(text != NULL, NULL); |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
894 |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
895 if (length < 0) |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
896 length = strlen(text); |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
897 |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
898 /* prealloc at least as long as original text */ |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
899 str = g_string_sized_new(length); |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
900 append_escaped_text(str, text, length); |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
901 |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
902 return g_string_free(str, FALSE); |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
903 } |
57fdb7853fc7
Create a purple_markup_escape_text() function and use it in one place
Mark Doliner <mark@kingant.net>
parents:
27378
diff
changeset
|
904 |
16083
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
905 const char * |
16084 | 906 purple_markup_unescape_entity(const char *text, int *length) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
907 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
908 const char *pln; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
909 int len, pound; |
21794
8f82dc5e0b76
Patch #3848 from Eion Robb: "purple_markup_unescape_entity doesn't escape hexadecimal references", with changes from QuLogic.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21621
diff
changeset
|
910 char temp[2]; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
911 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
912 if (!text || *text != '&') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
913 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
914 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
915 #define IS_ENTITY(s) (!g_ascii_strncasecmp(text, s, (len = sizeof(s) - 1))) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
916 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
917 if(IS_ENTITY("&")) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
918 pln = "&"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
919 else if(IS_ENTITY("<")) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
920 pln = "<"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
921 else if(IS_ENTITY(">")) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
922 pln = ">"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
923 else if(IS_ENTITY(" ")) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
924 pln = " "; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
925 else if(IS_ENTITY("©")) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
926 pln = "\302\251"; /* or use g_unichar_to_utf8(0xa9); */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
927 else if(IS_ENTITY(""")) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
928 pln = "\""; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
929 else if(IS_ENTITY("®")) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
930 pln = "\302\256"; /* or use g_unichar_to_utf8(0xae); */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
931 else if(IS_ENTITY("'")) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
932 pln = "\'"; |
21794
8f82dc5e0b76
Patch #3848 from Eion Robb: "purple_markup_unescape_entity doesn't escape hexadecimal references", with changes from QuLogic.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21621
diff
changeset
|
933 else if(*(text+1) == '#' && |
22313
bb1dc0095856
Revert some bits of the earlier patch not related to custom smileys.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22312
diff
changeset
|
934 (sscanf(text, "&#%u%1[;]", £, temp) == 2 || |
bb1dc0095856
Revert some bits of the earlier patch not related to custom smileys.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22312
diff
changeset
|
935 sscanf(text, "&#x%x%1[;]", £, temp) == 2) && |
21794
8f82dc5e0b76
Patch #3848 from Eion Robb: "purple_markup_unescape_entity doesn't escape hexadecimal references", with changes from QuLogic.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21621
diff
changeset
|
936 pound != 0) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
937 static char buf[7]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
938 int buflen = g_unichar_to_utf8((gunichar)pound, buf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
939 buf[buflen] = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
940 pln = buf; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
941 |
27295
d4c6d2c6fb03
Fix purple_markup_unescape_entity to properly consume '\' and similar.
Paul Aurich <paul@darkrain42.org>
parents:
27281
diff
changeset
|
942 len = (*(text+2) == 'x' ? 3 : 2); |
d4c6d2c6fb03
Fix purple_markup_unescape_entity to properly consume '\' and similar.
Paul Aurich <paul@darkrain42.org>
parents:
27281
diff
changeset
|
943 while(isxdigit((gint) text[len])) len++; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
944 if(text[len] == ';') len++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
945 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
946 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
947 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
948 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
949 if (length) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
950 *length = len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
951 return pln; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
952 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
953 |
16084 | 954 char * |
955 purple_markup_get_css_property(const gchar *style, | |
956 const gchar *opt) | |
16083
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
957 { |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
958 const gchar *css_str = style; |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
959 const gchar *css_value_start; |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
960 const gchar *css_value_end; |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
961 gchar *tmp; |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
962 gchar *ret; |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
963 |
24421 | 964 g_return_val_if_fail(opt != NULL, NULL); |
965 | |
16084 | 966 if (!css_str) |
16083
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
967 return NULL; |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
968 |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
969 /* find the CSS property */ |
16084 | 970 while (1) |
971 { | |
972 /* skip whitespace characters */ | |
973 while (*css_str && g_ascii_isspace(*css_str)) | |
16083
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
974 css_str++; |
16084 | 975 if (!g_ascii_isalpha(*css_str)) |
16083
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
976 return NULL; |
16084 | 977 if (g_ascii_strncasecmp(css_str, opt, strlen(opt))) |
16083
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
978 { |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
979 /* go to next css property positioned after the next ';' */ |
16084 | 980 while (*css_str && *css_str != '"' && *css_str != ';') |
16083
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
981 css_str++; |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
982 if(*css_str != ';') |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
983 return NULL; |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
984 css_str++; |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
985 } |
16084 | 986 else |
987 break; | |
16083
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
988 } |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
989 |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
990 /* find the CSS value position in the string */ |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
991 css_str += strlen(opt); |
16084 | 992 while (*css_str && g_ascii_isspace(*css_str)) |
16083
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
993 css_str++; |
16084 | 994 if (*css_str != ':') |
16083
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
995 return NULL; |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
996 css_str++; |
16084 | 997 while (*css_str && g_ascii_isspace(*css_str)) |
16083
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
998 css_str++; |
16084 | 999 if (*css_str == '\0' || *css_str == '"' || *css_str == ';') |
16083
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
1000 return NULL; |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
1001 |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
1002 /* mark the CSS value */ |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
1003 css_value_start = css_str; |
16084 | 1004 while (*css_str && *css_str != '"' && *css_str != ';') |
16083
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
1005 css_str++; |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
1006 css_value_end = css_str - 1; |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
1007 |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
1008 /* Removes trailing whitespace */ |
16084 | 1009 while (css_value_end > css_value_start && g_ascii_isspace(*css_value_end)) |
16083
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
1010 css_value_end--; |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
1011 |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
1012 tmp = g_strndup(css_value_start, css_value_end - css_value_start + 1); |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
1013 ret = purple_unescape_html(tmp); |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
1014 g_free(tmp); |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
1015 |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
1016 return ret; |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
1017 } |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
16063
diff
changeset
|
1018 |
27012
af4a4ebc6441
Add a utlity function purple_markup_is_rtl
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26969
diff
changeset
|
1019 gboolean purple_markup_is_rtl(const char *html) |
af4a4ebc6441
Add a utlity function purple_markup_is_rtl
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26969
diff
changeset
|
1020 { |
af4a4ebc6441
Add a utlity function purple_markup_is_rtl
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26969
diff
changeset
|
1021 GData *attributes; |
af4a4ebc6441
Add a utlity function purple_markup_is_rtl
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26969
diff
changeset
|
1022 const gchar *start, *end; |
af4a4ebc6441
Add a utlity function purple_markup_is_rtl
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26969
diff
changeset
|
1023 gboolean res = FALSE; |
af4a4ebc6441
Add a utlity function purple_markup_is_rtl
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26969
diff
changeset
|
1024 |
af4a4ebc6441
Add a utlity function purple_markup_is_rtl
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26969
diff
changeset
|
1025 if (purple_markup_find_tag("span", html, &start, &end, &attributes)) |
af4a4ebc6441
Add a utlity function purple_markup_is_rtl
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26969
diff
changeset
|
1026 { |
af4a4ebc6441
Add a utlity function purple_markup_is_rtl
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26969
diff
changeset
|
1027 /* tmp is a member of attributes and is free with g_datalist_clear call */ |
af4a4ebc6441
Add a utlity function purple_markup_is_rtl
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26969
diff
changeset
|
1028 const char *tmp = g_datalist_get_data(&attributes, "dir"); |
af4a4ebc6441
Add a utlity function purple_markup_is_rtl
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26969
diff
changeset
|
1029 if (tmp && !g_ascii_strcasecmp(tmp, "RTL")) |
af4a4ebc6441
Add a utlity function purple_markup_is_rtl
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26969
diff
changeset
|
1030 res = TRUE; |
af4a4ebc6441
Add a utlity function purple_markup_is_rtl
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26969
diff
changeset
|
1031 if (!res) |
af4a4ebc6441
Add a utlity function purple_markup_is_rtl
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26969
diff
changeset
|
1032 { |
af4a4ebc6441
Add a utlity function purple_markup_is_rtl
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26969
diff
changeset
|
1033 tmp = g_datalist_get_data(&attributes, "style"); |
af4a4ebc6441
Add a utlity function purple_markup_is_rtl
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26969
diff
changeset
|
1034 if (tmp) |
af4a4ebc6441
Add a utlity function purple_markup_is_rtl
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26969
diff
changeset
|
1035 { |
af4a4ebc6441
Add a utlity function purple_markup_is_rtl
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26969
diff
changeset
|
1036 char *tmp2 = purple_markup_get_css_property(tmp, "direction"); |
af4a4ebc6441
Add a utlity function purple_markup_is_rtl
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26969
diff
changeset
|
1037 if (tmp2 && !g_ascii_strcasecmp(tmp2, "RTL")) |
af4a4ebc6441
Add a utlity function purple_markup_is_rtl
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26969
diff
changeset
|
1038 res = TRUE; |
af4a4ebc6441
Add a utlity function purple_markup_is_rtl
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26969
diff
changeset
|
1039 g_free(tmp2); |
af4a4ebc6441
Add a utlity function purple_markup_is_rtl
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26969
diff
changeset
|
1040 } |
af4a4ebc6441
Add a utlity function purple_markup_is_rtl
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26969
diff
changeset
|
1041 |
af4a4ebc6441
Add a utlity function purple_markup_is_rtl
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26969
diff
changeset
|
1042 } |
af4a4ebc6441
Add a utlity function purple_markup_is_rtl
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26969
diff
changeset
|
1043 g_datalist_clear(&attributes); |
af4a4ebc6441
Add a utlity function purple_markup_is_rtl
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26969
diff
changeset
|
1044 } |
af4a4ebc6441
Add a utlity function purple_markup_is_rtl
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26969
diff
changeset
|
1045 return res; |
af4a4ebc6441
Add a utlity function purple_markup_is_rtl
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26969
diff
changeset
|
1046 } |
af4a4ebc6441
Add a utlity function purple_markup_is_rtl
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26969
diff
changeset
|
1047 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1048 gboolean |
15822 | 1049 purple_markup_find_tag(const char *needle, const char *haystack, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1050 const char **start, const char **end, GData **attributes) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1051 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1052 GData *attribs; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1053 const char *cur = haystack; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1054 char *name = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1055 gboolean found = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1056 gboolean in_tag = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1057 gboolean in_attr = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1058 const char *in_quotes = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1059 size_t needlelen; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1060 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1061 g_return_val_if_fail( needle != NULL, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1062 g_return_val_if_fail( *needle != '\0', FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1063 g_return_val_if_fail( haystack != NULL, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1064 g_return_val_if_fail( start != NULL, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1065 g_return_val_if_fail( end != NULL, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1066 g_return_val_if_fail(attributes != NULL, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1067 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1068 needlelen = strlen(needle); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1069 g_datalist_init(&attribs); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1070 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1071 while (*cur && !found) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1072 if (in_tag) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1073 if (in_quotes) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1074 const char *close = cur; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1075 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1076 while (*close && *close != *in_quotes) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1077 close++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1078 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1079 /* if we got the close quote, store the value and carry on from * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1080 * after it. if we ran to the end of the string, point to the NULL * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1081 * and we're outta here */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1082 if (*close) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1083 /* only store a value if we have an attribute name */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1084 if (name) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1085 size_t len = close - cur; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1086 char *val = g_strndup(cur, len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1087 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1088 g_datalist_set_data_full(&attribs, name, val, g_free); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1089 g_free(name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1090 name = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1091 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1092 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1093 in_quotes = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1094 cur = close + 1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1095 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1096 cur = close; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1097 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1098 } else if (in_attr) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1099 const char *close = cur; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1100 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1101 while (*close && *close != '>' && *close != '"' && |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1102 *close != '\'' && *close != ' ' && *close != '=') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1103 close++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1104 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1105 /* if we got the equals, store the name of the attribute. if we got |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1106 * the quote, save the attribute and go straight to quote mode. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1107 * otherwise the tag closed or we reached the end of the string, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1108 * so we can get outta here */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1109 switch (*close) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1110 case '"': |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1111 case '\'': |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1112 in_quotes = close; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1113 case '=': |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1114 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1115 size_t len = close - cur; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1116 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1117 /* don't store a blank attribute name */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1118 if (len) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1119 g_free(name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1120 name = g_ascii_strdown(cur, len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1121 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1122 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1123 in_attr = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1124 cur = close + 1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1125 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1126 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1127 case ' ': |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1128 case '>': |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1129 in_attr = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1130 default: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1131 cur = close; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1132 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1133 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1134 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1135 switch (*cur) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1136 case ' ': |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1137 /* swallow extra spaces inside tag */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1138 while (*cur && *cur == ' ') cur++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1139 in_attr = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1140 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1141 case '>': |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1142 found = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1143 *end = cur; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1144 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1145 case '"': |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1146 case '\'': |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1147 in_quotes = cur; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1148 default: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1149 cur++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1150 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1151 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1152 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1153 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1154 /* if we hit a < followed by the name of our tag... */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1155 if (*cur == '<' && !g_ascii_strncasecmp(cur + 1, needle, needlelen)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1156 *start = cur; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1157 cur = cur + needlelen + 1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1158 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1159 /* if we're pointing at a space or a >, we found the right tag. if * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1160 * we're not, we've found a longer tag, so we need to skip to the * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1161 * >, but not being distracted by >s inside quotes. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1162 if (*cur == ' ' || *cur == '>') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1163 in_tag = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1164 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1165 while (*cur && *cur != '"' && *cur != '\'' && *cur != '>') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1166 if (*cur == '"') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1167 cur++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1168 while (*cur && *cur != '"') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1169 cur++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1170 } else if (*cur == '\'') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1171 cur++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1172 while (*cur && *cur != '\'') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1173 cur++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1174 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1175 cur++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1176 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1177 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1178 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1179 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1180 cur++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1181 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1182 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1183 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1184 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1185 /* clean up any attribute name from a premature termination */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1186 g_free(name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1187 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1188 if (found) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1189 *attributes = attribs; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1190 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1191 *start = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1192 *end = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1193 *attributes = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1194 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1195 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1196 return found; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1197 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1198 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1199 gboolean |
15822 | 1200 purple_markup_extract_info_field(const char *str, int len, PurpleNotifyUserInfo *user_info, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1201 const char *start_token, int skip, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1202 const char *end_token, char check_value, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1203 const char *no_value_token, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1204 const char *display_name, gboolean is_link, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1205 const char *link_prefix, |
15822 | 1206 PurpleInfoFieldFormatCallback format_cb) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1207 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1208 const char *p, *q; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1209 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1210 g_return_val_if_fail(str != NULL, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1211 g_return_val_if_fail(user_info != NULL, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1212 g_return_val_if_fail(start_token != NULL, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1213 g_return_val_if_fail(end_token != NULL, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1214 g_return_val_if_fail(display_name != NULL, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1215 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1216 p = strstr(str, start_token); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1217 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1218 if (p == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1219 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1220 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1221 p += strlen(start_token) + skip; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1222 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1223 if (p >= str + len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1224 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1225 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1226 if (check_value != '\0' && *p == check_value) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1227 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1228 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1229 q = strstr(p, end_token); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1230 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1231 /* Trim leading blanks */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1232 while (*p != '\n' && g_ascii_isspace(*p)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1233 p += 1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1234 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1235 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1236 /* Trim trailing blanks */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1237 while (q > p && g_ascii_isspace(*(q - 1))) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1238 q -= 1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1239 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1240 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1241 /* Don't bother with null strings */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1242 if (p == q) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1243 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1244 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1245 if (q != NULL && (!no_value_token || |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1246 (no_value_token && strncmp(p, no_value_token, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1247 strlen(no_value_token))))) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1248 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1249 GString *dest = g_string_new(""); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1250 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1251 if (is_link) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1252 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1253 g_string_append(dest, "<a href=\""); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1254 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1255 if (link_prefix) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1256 g_string_append(dest, link_prefix); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1257 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1258 if (format_cb != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1259 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1260 char *reformatted = format_cb(p, q - p); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1261 g_string_append(dest, reformatted); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1262 g_free(reformatted); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1263 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1264 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1265 g_string_append_len(dest, p, q - p); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1266 g_string_append(dest, "\">"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1267 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1268 if (link_prefix) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1269 g_string_append(dest, link_prefix); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1270 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1271 g_string_append_len(dest, p, q - p); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1272 g_string_append(dest, "</a>"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1273 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1274 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1275 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1276 if (format_cb != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1277 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1278 char *reformatted = format_cb(p, q - p); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1279 g_string_append(dest, reformatted); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1280 g_free(reformatted); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1281 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1282 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1283 g_string_append_len(dest, p, q - p); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1284 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1285 |
15822 | 1286 purple_notify_user_info_add_pair(user_info, display_name, dest->str); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1287 g_string_free(dest, TRUE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1288 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1289 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1290 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1291 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1292 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1293 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1294 |
15822 | 1295 struct purple_parse_tag { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1296 char *src_tag; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1297 char *dest_tag; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1298 gboolean ignore; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1299 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1300 |
27641
1316f2b180be
Make a note about these ALLOW_TAG* macros so people don't do stuff like
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27622
diff
changeset
|
1301 /* NOTE: Do not put `do {} while(0)` around this macro (as this is the method |
1316f2b180be
Make a note about these ALLOW_TAG* macros so people don't do stuff like
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27622
diff
changeset
|
1302 recommended in the GCC docs). It contains 'continue's that should |
1316f2b180be
Make a note about these ALLOW_TAG* macros so people don't do stuff like
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27622
diff
changeset
|
1303 affect the while-loop in purple_markup_html_to_xhtml and doing the |
1316f2b180be
Make a note about these ALLOW_TAG* macros so people don't do stuff like
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27622
diff
changeset
|
1304 above would break that. |
1316f2b180be
Make a note about these ALLOW_TAG* macros so people don't do stuff like
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27622
diff
changeset
|
1305 Also, remember to put braces in constructs that require them for |
1316f2b180be
Make a note about these ALLOW_TAG* macros so people don't do stuff like
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27622
diff
changeset
|
1306 multiple statements when using this macro. */ |
27622
3edd01d04004
disapproval of revision '0a9f6836dbe4facb38768025e830328a50c5ddd8'
Mark Doliner <mark@kingant.net>
parents:
27621
diff
changeset
|
1307 #define ALLOW_TAG_ALT(x, y) if(!g_ascii_strncasecmp(c, "<" x " ", strlen("<" x " "))) { \ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1308 const char *o = c + strlen("<" x); \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1309 const char *p = NULL, *q = NULL, *r = NULL; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1310 GString *innards = g_string_new(""); \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1311 while(o && *o) { \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1312 if(!q && (*o == '\"' || *o == '\'') ) { \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1313 q = o; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1314 } else if(q) { \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1315 if(*o == *q) { \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1316 char *unescaped = g_strndup(q+1, o-q-1); \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1317 char *escaped = g_markup_escape_text(unescaped, -1); \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1318 g_string_append_printf(innards, "%c%s%c", *q, escaped, *q); \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1319 g_free(unescaped); \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1320 g_free(escaped); \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1321 q = NULL; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1322 } else if(*c == '\\') { \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1323 o++; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1324 } \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1325 } else if(*o == '<') { \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1326 r = o; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1327 } else if(*o == '>') { \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1328 p = o; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1329 break; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1330 } else { \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1331 innards = g_string_append_c(innards, *o); \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1332 } \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1333 o++; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1334 } \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1335 if(p && !r) { \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1336 if(*(p-1) != '/') { \ |
15822 | 1337 struct purple_parse_tag *pt = g_new0(struct purple_parse_tag, 1); \ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1338 pt->src_tag = x; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1339 pt->dest_tag = y; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1340 tags = g_list_prepend(tags, pt); \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1341 } \ |
17481
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1342 if(xhtml) { \ |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1343 xhtml = g_string_append(xhtml, "<" y); \ |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1344 xhtml = g_string_append(xhtml, innards->str); \ |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1345 xhtml = g_string_append_c(xhtml, '>'); \ |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1346 } \ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1347 c = p + 1; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1348 } else { \ |
17481
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1349 if(xhtml) \ |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1350 xhtml = g_string_append(xhtml, "<"); \ |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1351 if(plain) \ |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1352 plain = g_string_append_c(plain, '<'); \ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1353 c++; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1354 } \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1355 g_string_free(innards, TRUE); \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1356 continue; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1357 } \ |
27620
c800bdb5ebbc
Correct the indentation of this macro by removing one level of indentation
Mark Doliner <mark@kingant.net>
parents:
27589
diff
changeset
|
1358 if(!g_ascii_strncasecmp(c, "<" x, strlen("<" x)) && \ |
c800bdb5ebbc
Correct the indentation of this macro by removing one level of indentation
Mark Doliner <mark@kingant.net>
parents:
27589
diff
changeset
|
1359 (*(c+strlen("<" x)) == '>' || \ |
c800bdb5ebbc
Correct the indentation of this macro by removing one level of indentation
Mark Doliner <mark@kingant.net>
parents:
27589
diff
changeset
|
1360 !g_ascii_strncasecmp(c+strlen("<" x), "/>", 2))) { \ |
c800bdb5ebbc
Correct the indentation of this macro by removing one level of indentation
Mark Doliner <mark@kingant.net>
parents:
27589
diff
changeset
|
1361 if(xhtml) \ |
c800bdb5ebbc
Correct the indentation of this macro by removing one level of indentation
Mark Doliner <mark@kingant.net>
parents:
27589
diff
changeset
|
1362 xhtml = g_string_append(xhtml, "<" y); \ |
c800bdb5ebbc
Correct the indentation of this macro by removing one level of indentation
Mark Doliner <mark@kingant.net>
parents:
27589
diff
changeset
|
1363 c += strlen("<" x); \ |
c800bdb5ebbc
Correct the indentation of this macro by removing one level of indentation
Mark Doliner <mark@kingant.net>
parents:
27589
diff
changeset
|
1364 if(*c != '/') { \ |
c800bdb5ebbc
Correct the indentation of this macro by removing one level of indentation
Mark Doliner <mark@kingant.net>
parents:
27589
diff
changeset
|
1365 struct purple_parse_tag *pt = g_new0(struct purple_parse_tag, 1); \ |
c800bdb5ebbc
Correct the indentation of this macro by removing one level of indentation
Mark Doliner <mark@kingant.net>
parents:
27589
diff
changeset
|
1366 pt->src_tag = x; \ |
c800bdb5ebbc
Correct the indentation of this macro by removing one level of indentation
Mark Doliner <mark@kingant.net>
parents:
27589
diff
changeset
|
1367 pt->dest_tag = y; \ |
c800bdb5ebbc
Correct the indentation of this macro by removing one level of indentation
Mark Doliner <mark@kingant.net>
parents:
27589
diff
changeset
|
1368 tags = g_list_prepend(tags, pt); \ |
17481
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1369 if(xhtml) \ |
27620
c800bdb5ebbc
Correct the indentation of this macro by removing one level of indentation
Mark Doliner <mark@kingant.net>
parents:
27589
diff
changeset
|
1370 xhtml = g_string_append_c(xhtml, '>'); \ |
c800bdb5ebbc
Correct the indentation of this macro by removing one level of indentation
Mark Doliner <mark@kingant.net>
parents:
27589
diff
changeset
|
1371 } else { \ |
c800bdb5ebbc
Correct the indentation of this macro by removing one level of indentation
Mark Doliner <mark@kingant.net>
parents:
27589
diff
changeset
|
1372 if(xhtml) \ |
c800bdb5ebbc
Correct the indentation of this macro by removing one level of indentation
Mark Doliner <mark@kingant.net>
parents:
27589
diff
changeset
|
1373 xhtml = g_string_append(xhtml, "/>");\ |
c800bdb5ebbc
Correct the indentation of this macro by removing one level of indentation
Mark Doliner <mark@kingant.net>
parents:
27589
diff
changeset
|
1374 } \ |
c800bdb5ebbc
Correct the indentation of this macro by removing one level of indentation
Mark Doliner <mark@kingant.net>
parents:
27589
diff
changeset
|
1375 c = strchr(c, '>') + 1; \ |
c800bdb5ebbc
Correct the indentation of this macro by removing one level of indentation
Mark Doliner <mark@kingant.net>
parents:
27589
diff
changeset
|
1376 continue; \ |
27634
91333c6c16ef
567c0647 introduced an extra backslash at the end of ALLOW_TAG_ALT
Ka-Hing Cheung <khc@hxbc.us>
parents:
27633
diff
changeset
|
1377 } |
27641
1316f2b180be
Make a note about these ALLOW_TAG* macros so people don't do stuff like
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27622
diff
changeset
|
1378 /* Don't forget to check the note above for ALLOW_TAG_ALT. */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1379 #define ALLOW_TAG(x) ALLOW_TAG_ALT(x, x) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1380 void |
15822 | 1381 purple_markup_html_to_xhtml(const char *html, char **xhtml_out, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1382 char **plain_out) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1383 { |
17481
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1384 GString *xhtml = NULL; |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1385 GString *plain = NULL; |
18493
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1386 GString *url = NULL; |
19262
450090c68351
When converting to xhtml, only add URLs in angle brackets if it doesn't match the cdata. Fixes #2445
Sean Egan <seanegan@gmail.com>
parents:
18600
diff
changeset
|
1387 GString *cdata = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1388 GList *tags = NULL, *tag; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1389 const char *c = html; |
23248
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1390 char quote = '\0'; |
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1391 |
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1392 #define CHECK_QUOTE(ptr) if (*(ptr) == '\'' || *(ptr) == '\"') \ |
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1393 quote = *(ptr++); \ |
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1394 else \ |
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1395 quote = '\0'; |
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1396 |
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1397 #define VALID_CHAR(ptr) (*(ptr) && *(ptr) != quote && (quote || (*(ptr) != ' ' && *(ptr) != '>'))) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1398 |
17481
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1399 g_return_if_fail(xhtml_out != NULL || plain_out != NULL); |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1400 |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1401 if(xhtml_out) |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1402 xhtml = g_string_new(""); |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1403 if(plain_out) |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1404 plain = g_string_new(""); |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1405 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1406 while(c && *c) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1407 if(*c == '<') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1408 if(*(c+1) == '/') { /* closing tag */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1409 tag = tags; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1410 while(tag) { |
15822 | 1411 struct purple_parse_tag *pt = tag->data; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1412 if(!g_ascii_strncasecmp((c+2), pt->src_tag, strlen(pt->src_tag)) && *(c+strlen(pt->src_tag)+2) == '>') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1413 c += strlen(pt->src_tag) + 3; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1414 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1415 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1416 tag = tag->next; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1417 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1418 if(tag) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1419 while(tags) { |
15822 | 1420 struct purple_parse_tag *pt = tags->data; |
28906
68bc7c617fa0
Fix a corner case where purple_markup_html_to_xhtml generated malformed XHTML.
Paul Aurich <paul@darkrain42.org>
parents:
28285
diff
changeset
|
1421 if(xhtml && !pt->ignore) |
17481
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1422 g_string_append_printf(xhtml, "</%s>", pt->dest_tag); |
25894
a6e3cb32cdd2
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <paul@darkrain42.org>
parents:
25890
diff
changeset
|
1423 if(plain && purple_strequal(pt->src_tag, "a")) { |
18493
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1424 /* if this is a link, we have to add the url to the plaintext, too */ |
21185
4a0f841e6f26
applied changes from f0cdd16c20f9773e28cd79b36ffcf1c66057e32e
Stu Tomlinson <stu@nosnilmot.com>
parents:
21177
diff
changeset
|
1425 if (cdata && url && |
4a0f841e6f26
applied changes from f0cdd16c20f9773e28cd79b36ffcf1c66057e32e
Stu Tomlinson <stu@nosnilmot.com>
parents:
21177
diff
changeset
|
1426 (!g_string_equal(cdata, url) && (g_ascii_strncasecmp(url->str, "mailto:", 7) != 0 || |
4a0f841e6f26
applied changes from f0cdd16c20f9773e28cd79b36ffcf1c66057e32e
Stu Tomlinson <stu@nosnilmot.com>
parents:
21177
diff
changeset
|
1427 g_utf8_collate(url->str + 7, cdata->str) != 0))) |
19262
450090c68351
When converting to xhtml, only add URLs in angle brackets if it doesn't match the cdata. Fixes #2445
Sean Egan <seanegan@gmail.com>
parents:
18600
diff
changeset
|
1428 g_string_append_printf(plain, " <%s>", g_strstrip(url->str)); |
450090c68351
When converting to xhtml, only add URLs in angle brackets if it doesn't match the cdata. Fixes #2445
Sean Egan <seanegan@gmail.com>
parents:
18600
diff
changeset
|
1429 if (cdata) { |
450090c68351
When converting to xhtml, only add URLs in angle brackets if it doesn't match the cdata. Fixes #2445
Sean Egan <seanegan@gmail.com>
parents:
18600
diff
changeset
|
1430 g_string_free(cdata, TRUE); |
450090c68351
When converting to xhtml, only add URLs in angle brackets if it doesn't match the cdata. Fixes #2445
Sean Egan <seanegan@gmail.com>
parents:
18600
diff
changeset
|
1431 cdata = NULL; |
450090c68351
When converting to xhtml, only add URLs in angle brackets if it doesn't match the cdata. Fixes #2445
Sean Egan <seanegan@gmail.com>
parents:
18600
diff
changeset
|
1432 } |
19408
cc36a5aac908
Fix some conversion warnings about using negative values with unsigned types. There are more, but these were easy fixes. You may think that I'm changing the API, but I'm really not - it was just wrong.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19262
diff
changeset
|
1433 |
18493
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1434 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1435 if(tags == tag) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1436 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1437 tags = g_list_remove(tags, pt); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1438 g_free(pt); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1439 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1440 g_free(tag->data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1441 tags = g_list_remove(tags, tag->data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1442 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1443 /* a closing tag we weren't expecting... |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1444 * we'll let it slide, if it's really a tag...if it's |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1445 * just a </ we'll escape it properly */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1446 const char *end = c+2; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1447 while(*end && g_ascii_isalpha(*end)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1448 end++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1449 if(*end == '>') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1450 c = end+1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1451 } else { |
17481
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1452 if(xhtml) |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1453 xhtml = g_string_append(xhtml, "<"); |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1454 if(plain) |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1455 plain = g_string_append_c(plain, '<'); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1456 c++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1457 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1458 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1459 } else { /* opening tag */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1460 ALLOW_TAG("blockquote"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1461 ALLOW_TAG("cite"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1462 ALLOW_TAG("div"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1463 ALLOW_TAG("em"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1464 ALLOW_TAG("h1"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1465 ALLOW_TAG("h2"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1466 ALLOW_TAG("h3"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1467 ALLOW_TAG("h4"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1468 ALLOW_TAG("h5"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1469 ALLOW_TAG("h6"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1470 /* we only allow html to start the message */ |
27622
3edd01d04004
disapproval of revision '0a9f6836dbe4facb38768025e830328a50c5ddd8'
Mark Doliner <mark@kingant.net>
parents:
27621
diff
changeset
|
1471 if(c == html) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1472 ALLOW_TAG("html"); |
27622
3edd01d04004
disapproval of revision '0a9f6836dbe4facb38768025e830328a50c5ddd8'
Mark Doliner <mark@kingant.net>
parents:
27621
diff
changeset
|
1473 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1474 ALLOW_TAG_ALT("i", "em"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1475 ALLOW_TAG_ALT("italic", "em"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1476 ALLOW_TAG("li"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1477 ALLOW_TAG("ol"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1478 ALLOW_TAG("p"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1479 ALLOW_TAG("pre"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1480 ALLOW_TAG("q"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1481 ALLOW_TAG("span"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1482 ALLOW_TAG("ul"); |
18493
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1483 |
19408
cc36a5aac908
Fix some conversion warnings about using negative values with unsigned types. There are more, but these were easy fixes. You may think that I'm changing the API, but I'm really not - it was just wrong.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19262
diff
changeset
|
1484 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1485 /* we skip <HR> because it's not legal in XHTML-IM. However, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1486 * we still want to send something sensible, so we put a |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1487 * linebreak in its place. <BR> also needs special handling |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1488 * because putting a </BR> to close it would just be dumb. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1489 if((!g_ascii_strncasecmp(c, "<br", 3) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1490 || !g_ascii_strncasecmp(c, "<hr", 3)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1491 && (*(c+3) == '>' || |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1492 !g_ascii_strncasecmp(c+3, "/>", 2) || |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1493 !g_ascii_strncasecmp(c+3, " />", 3))) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1494 c = strchr(c, '>') + 1; |
17481
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1495 if(xhtml) |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1496 xhtml = g_string_append(xhtml, "<br/>"); |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1497 if(plain && *c != '\n') |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1498 plain = g_string_append_c(plain, '\n'); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1499 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1500 } |
22191
3634d27ec6f1
Change purple_markup_html_to_xhtml() to convert <strong> tags to
Mark Doliner <mark@kingant.net>
parents:
22089
diff
changeset
|
1501 if(!g_ascii_strncasecmp(c, "<b>", 3) || !g_ascii_strncasecmp(c, "<bold>", strlen("<bold>")) || !g_ascii_strncasecmp(c, "<strong>", strlen("<strong>"))) { |
15822 | 1502 struct purple_parse_tag *pt = g_new0(struct purple_parse_tag, 1); |
22191
3634d27ec6f1
Change purple_markup_html_to_xhtml() to convert <strong> tags to
Mark Doliner <mark@kingant.net>
parents:
22089
diff
changeset
|
1503 if (*(c+2) == '>') |
3634d27ec6f1
Change purple_markup_html_to_xhtml() to convert <strong> tags to
Mark Doliner <mark@kingant.net>
parents:
22089
diff
changeset
|
1504 pt->src_tag = "b"; |
3634d27ec6f1
Change purple_markup_html_to_xhtml() to convert <strong> tags to
Mark Doliner <mark@kingant.net>
parents:
22089
diff
changeset
|
1505 else if (*(c+2) == 'o') |
3634d27ec6f1
Change purple_markup_html_to_xhtml() to convert <strong> tags to
Mark Doliner <mark@kingant.net>
parents:
22089
diff
changeset
|
1506 pt->src_tag = "bold"; |
3634d27ec6f1
Change purple_markup_html_to_xhtml() to convert <strong> tags to
Mark Doliner <mark@kingant.net>
parents:
22089
diff
changeset
|
1507 else |
3634d27ec6f1
Change purple_markup_html_to_xhtml() to convert <strong> tags to
Mark Doliner <mark@kingant.net>
parents:
22089
diff
changeset
|
1508 pt->src_tag = "strong"; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1509 pt->dest_tag = "span"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1510 tags = g_list_prepend(tags, pt); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1511 c = strchr(c, '>') + 1; |
17481
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1512 if(xhtml) |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1513 xhtml = g_string_append(xhtml, "<span style='font-weight: bold;'>"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1514 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1515 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1516 if(!g_ascii_strncasecmp(c, "<u>", 3) || !g_ascii_strncasecmp(c, "<underline>", strlen("<underline>"))) { |
15822 | 1517 struct purple_parse_tag *pt = g_new0(struct purple_parse_tag, 1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1518 pt->src_tag = *(c+2) == '>' ? "u" : "underline"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1519 pt->dest_tag = "span"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1520 tags = g_list_prepend(tags, pt); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1521 c = strchr(c, '>') + 1; |
17481
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1522 if (xhtml) |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1523 xhtml = g_string_append(xhtml, "<span style='text-decoration: underline;'>"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1524 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1525 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1526 if(!g_ascii_strncasecmp(c, "<s>", 3) || !g_ascii_strncasecmp(c, "<strike>", strlen("<strike>"))) { |
15822 | 1527 struct purple_parse_tag *pt = g_new0(struct purple_parse_tag, 1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1528 pt->src_tag = *(c+2) == '>' ? "s" : "strike"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1529 pt->dest_tag = "span"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1530 tags = g_list_prepend(tags, pt); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1531 c = strchr(c, '>') + 1; |
17481
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1532 if(xhtml) |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1533 xhtml = g_string_append(xhtml, "<span style='text-decoration: line-through;'>"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1534 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1535 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1536 if(!g_ascii_strncasecmp(c, "<sub>", 5)) { |
15822 | 1537 struct purple_parse_tag *pt = g_new0(struct purple_parse_tag, 1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1538 pt->src_tag = "sub"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1539 pt->dest_tag = "span"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1540 tags = g_list_prepend(tags, pt); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1541 c = strchr(c, '>') + 1; |
17481
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1542 if(xhtml) |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1543 xhtml = g_string_append(xhtml, "<span style='vertical-align:sub;'>"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1544 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1545 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1546 if(!g_ascii_strncasecmp(c, "<sup>", 5)) { |
15822 | 1547 struct purple_parse_tag *pt = g_new0(struct purple_parse_tag, 1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1548 pt->src_tag = "sup"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1549 pt->dest_tag = "span"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1550 tags = g_list_prepend(tags, pt); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1551 c = strchr(c, '>') + 1; |
17481
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1552 if(xhtml) |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1553 xhtml = g_string_append(xhtml, "<span style='vertical-align:super;'>"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1554 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1555 } |
23248
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1556 if (!g_ascii_strncasecmp(c, "<img", 4) && (*(c+4) == '>' || *(c+4) == ' ')) { |
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1557 const char *p = c + 4; |
18493
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1558 GString *src = NULL, *alt = NULL; |
23248
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1559 while (*p && *p != '>') { |
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1560 if (!g_ascii_strncasecmp(p, "src=", 4)) { |
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1561 const char *q = p + 4; |
22864
7d4fcb142572
Fix some potential leakage in the craziness called purple_markup_html_to_xhtml().
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22486
diff
changeset
|
1562 if (src) |
7d4fcb142572
Fix some potential leakage in the craziness called purple_markup_html_to_xhtml().
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22486
diff
changeset
|
1563 g_string_free(src, TRUE); |
18493
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1564 src = g_string_new(""); |
23248
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1565 CHECK_QUOTE(q); |
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1566 while (VALID_CHAR(q)) { |
18493
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1567 src = g_string_append_c(src, *q); |
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1568 q++; |
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1569 } |
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1570 p = q; |
23248
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1571 } else if (!g_ascii_strncasecmp(p, "alt=", 4)) { |
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1572 const char *q = p + 4; |
22864
7d4fcb142572
Fix some potential leakage in the craziness called purple_markup_html_to_xhtml().
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22486
diff
changeset
|
1573 if (alt) |
7d4fcb142572
Fix some potential leakage in the craziness called purple_markup_html_to_xhtml().
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22486
diff
changeset
|
1574 g_string_free(alt, TRUE); |
18493
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1575 alt = g_string_new(""); |
23248
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1576 CHECK_QUOTE(q); |
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1577 while (VALID_CHAR(q)) { |
18493
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1578 alt = g_string_append_c(alt, *q); |
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1579 q++; |
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1580 } |
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1581 p = q; |
23248
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1582 } else { |
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1583 p++; |
18493
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1584 } |
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1585 } |
23248
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1586 if ((c = strchr(p, '>')) != NULL) |
18493
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1587 c++; |
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1588 else |
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1589 c = p; |
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1590 /* src and alt are required! */ |
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1591 if(src && xhtml) |
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1592 g_string_append_printf(xhtml, "<img src='%s' alt='%s' />", g_strstrip(src->str), alt ? alt->str : ""); |
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1593 if(alt) { |
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1594 if(plain) |
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1595 plain = g_string_append(plain, alt->str); |
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1596 if(!src && xhtml) |
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1597 xhtml = g_string_append(xhtml, alt->str); |
20969
17ee8c81c99b
Only free the GString "alt" if it's non-null. This was causing an
Mark Doliner <mark@kingant.net>
parents:
20961
diff
changeset
|
1598 g_string_free(alt, TRUE); |
18493
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1599 } |
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1600 g_string_free(src, TRUE); |
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1601 continue; |
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1602 } |
23248
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1603 if (!g_ascii_strncasecmp(c, "<a", 2) && (*(c+2) == '>' || *(c+2) == ' ')) { |
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1604 const char *p = c + 2; |
18493
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1605 struct purple_parse_tag *pt; |
23248
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1606 while (*p && *p != '>') { |
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1607 if (!g_ascii_strncasecmp(p, "href=", 5)) { |
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1608 const char *q = p + 5; |
20587
45b524709475
Fix some incorrect assertions when G_DEBUG=fatal_warnings is set.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20541
diff
changeset
|
1609 if (url) |
45b524709475
Fix some incorrect assertions when G_DEBUG=fatal_warnings is set.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20541
diff
changeset
|
1610 g_string_free(url, TRUE); |
18493
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1611 url = g_string_new(""); |
22864
7d4fcb142572
Fix some potential leakage in the craziness called purple_markup_html_to_xhtml().
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22486
diff
changeset
|
1612 if (cdata) |
7d4fcb142572
Fix some potential leakage in the craziness called purple_markup_html_to_xhtml().
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22486
diff
changeset
|
1613 g_string_free(cdata, TRUE); |
19262
450090c68351
When converting to xhtml, only add URLs in angle brackets if it doesn't match the cdata. Fixes #2445
Sean Egan <seanegan@gmail.com>
parents:
18600
diff
changeset
|
1614 cdata = g_string_new(""); |
23248
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1615 CHECK_QUOTE(q); |
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1616 while (VALID_CHAR(q)) { |
21299
39231317310a
Escape any un-escaped entities in purple_markup_html_to_xhtml when parsing
Stu Tomlinson <stu@nosnilmot.com>
parents:
21284
diff
changeset
|
1617 int len; |
39231317310a
Escape any un-escaped entities in purple_markup_html_to_xhtml when parsing
Stu Tomlinson <stu@nosnilmot.com>
parents:
21284
diff
changeset
|
1618 if ((*q == '&') && (purple_markup_unescape_entity(q, &len) == NULL)) |
39231317310a
Escape any un-escaped entities in purple_markup_html_to_xhtml when parsing
Stu Tomlinson <stu@nosnilmot.com>
parents:
21284
diff
changeset
|
1619 url = g_string_append(url, "&"); |
39231317310a
Escape any un-escaped entities in purple_markup_html_to_xhtml when parsing
Stu Tomlinson <stu@nosnilmot.com>
parents:
21284
diff
changeset
|
1620 else |
39231317310a
Escape any un-escaped entities in purple_markup_html_to_xhtml when parsing
Stu Tomlinson <stu@nosnilmot.com>
parents:
21284
diff
changeset
|
1621 url = g_string_append_c(url, *q); |
18493
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1622 q++; |
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1623 } |
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1624 p = q; |
23248
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1625 } else { |
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1626 p++; |
18493
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1627 } |
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1628 } |
23248
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1629 if ((c = strchr(p, '>')) != NULL) |
18493
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1630 c++; |
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1631 else |
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1632 c = p; |
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1633 pt = g_new0(struct purple_parse_tag, 1); |
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1634 pt->src_tag = "a"; |
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1635 pt->dest_tag = "a"; |
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1636 tags = g_list_prepend(tags, pt); |
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1637 if(xhtml) |
26881
795606e2f7c6
According to RFC 1738, "'" is a valid character in a URL.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26772
diff
changeset
|
1638 g_string_append_printf(xhtml, "<a href=\"%s\">", url ? g_strstrip(url->str) : ""); |
18493
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1639 continue; |
274a08f56ea6
Per request of rlaager, propagated my xhtml-creator fixes to the main branch. This adds two things: proper <img>-handling and appending URLs to the plain text version like this: <http://www.example.com>.
Andreas Monitzer <pidgin@monitzer.com>
parents:
18397
diff
changeset
|
1640 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1641 if(!g_ascii_strncasecmp(c, "<font", 5) && (*(c+5) == '>' || *(c+5) == ' ')) { |
23248
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1642 const char *p = c + 5; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1643 GString *style = g_string_new(""); |
15822 | 1644 struct purple_parse_tag *pt; |
23248
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1645 while (*p && *p != '>') { |
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1646 if (!g_ascii_strncasecmp(p, "back=", 5)) { |
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1647 const char *q = p + 5; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1648 GString *color = g_string_new(""); |
23248
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1649 CHECK_QUOTE(q); |
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1650 while (VALID_CHAR(q)) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1651 color = g_string_append_c(color, *q); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1652 q++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1653 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1654 g_string_append_printf(style, "background: %s; ", color->str); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1655 g_string_free(color, TRUE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1656 p = q; |
23248
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1657 } else if (!g_ascii_strncasecmp(p, "color=", 6)) { |
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1658 const char *q = p + 6; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1659 GString *color = g_string_new(""); |
23248
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1660 CHECK_QUOTE(q); |
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1661 while (VALID_CHAR(q)) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1662 color = g_string_append_c(color, *q); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1663 q++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1664 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1665 g_string_append_printf(style, "color: %s; ", color->str); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1666 g_string_free(color, TRUE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1667 p = q; |
23248
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1668 } else if (!g_ascii_strncasecmp(p, "face=", 5)) { |
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1669 const char *q = p + 5; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1670 GString *face = g_string_new(""); |
23248
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1671 CHECK_QUOTE(q); |
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1672 while (VALID_CHAR(q)) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1673 face = g_string_append_c(face, *q); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1674 q++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1675 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1676 g_string_append_printf(style, "font-family: %s; ", g_strstrip(face->str)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1677 g_string_free(face, TRUE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1678 p = q; |
23248
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1679 } else if (!g_ascii_strncasecmp(p, "size=", 5)) { |
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1680 const char *q = p + 5; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1681 int sz; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1682 const char *size = "medium"; |
23248
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1683 CHECK_QUOTE(q); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1684 sz = atoi(q); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1685 switch (sz) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1686 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1687 case 1: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1688 size = "xx-small"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1689 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1690 case 2: |
24863
3d3376237a7c
Change the font size mapping table in purple_markup_html_to_xhtml() to
Mark Doliner <mark@kingant.net>
parents:
24841
diff
changeset
|
1691 size = "small"; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1692 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1693 case 3: |
24863
3d3376237a7c
Change the font size mapping table in purple_markup_html_to_xhtml() to
Mark Doliner <mark@kingant.net>
parents:
24841
diff
changeset
|
1694 size = "medium"; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1695 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1696 case 4: |
24863
3d3376237a7c
Change the font size mapping table in purple_markup_html_to_xhtml() to
Mark Doliner <mark@kingant.net>
parents:
24841
diff
changeset
|
1697 size = "large"; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1698 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1699 case 5: |
24863
3d3376237a7c
Change the font size mapping table in purple_markup_html_to_xhtml() to
Mark Doliner <mark@kingant.net>
parents:
24841
diff
changeset
|
1700 size = "x-large"; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1701 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1702 case 6: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1703 case 7: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1704 size = "xx-large"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1705 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1706 default: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1707 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1708 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1709 g_string_append_printf(style, "font-size: %s; ", size); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1710 p = q; |
23248
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1711 } else { |
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1712 p++; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1713 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1714 } |
23248
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1715 if ((c = strchr(p, '>')) != NULL) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1716 c++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1717 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1718 c = p; |
15822 | 1719 pt = g_new0(struct purple_parse_tag, 1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1720 pt->src_tag = "font"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1721 pt->dest_tag = "span"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1722 tags = g_list_prepend(tags, pt); |
21028
e4cf0506be74
Avoid g_log warnings when there's no xhtml to append to, and remove a
Stu Tomlinson <stu@nosnilmot.com>
parents:
21015
diff
changeset
|
1723 if(style->len && xhtml) |
18046
58e28ccf08e6
merge of '9d95292d55daedb7f74c7df323ad2c69d347d384'
Sadrul Habib Chowdhury <imadil@gmail.com>
diff
changeset
|
1724 g_string_append_printf(xhtml, "<span style='%s'>", g_strstrip(style->str)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1725 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1726 pt->ignore = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1727 g_string_free(style, TRUE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1728 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1729 } |
23248
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1730 if (!g_ascii_strncasecmp(c, "<body ", 6)) { |
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1731 const char *p = c + 6; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1732 gboolean did_something = FALSE; |
23248
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1733 while (*p && *p != '>') { |
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1734 if (!g_ascii_strncasecmp(p, "bgcolor=", 8)) { |
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1735 const char *q = p + 8; |
15822 | 1736 struct purple_parse_tag *pt = g_new0(struct purple_parse_tag, 1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1737 GString *color = g_string_new(""); |
23248
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1738 CHECK_QUOTE(q); |
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1739 while (VALID_CHAR(q)) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1740 color = g_string_append_c(color, *q); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1741 q++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1742 } |
23248
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1743 if (xhtml) |
17481
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1744 g_string_append_printf(xhtml, "<span style='background: %s;'>", g_strstrip(color->str)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1745 g_string_free(color, TRUE); |
23248
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1746 if ((c = strchr(p, '>')) != NULL) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1747 c++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1748 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1749 c = p; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1750 pt->src_tag = "body"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1751 pt->dest_tag = "span"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1752 tags = g_list_prepend(tags, pt); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1753 did_something = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1754 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1755 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1756 p++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1757 } |
23248
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1758 if (did_something) continue; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1759 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1760 /* this has to come after the special case for bgcolor */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1761 ALLOW_TAG("body"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1762 if(!g_ascii_strncasecmp(c, "<!--", strlen("<!--"))) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1763 char *p = strstr(c + strlen("<!--"), "-->"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1764 if(p) { |
17481
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1765 if(xhtml) |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1766 xhtml = g_string_append(xhtml, "<!--"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1767 c += strlen("<!--"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1768 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1769 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1770 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1771 |
17481
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1772 if(xhtml) |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1773 xhtml = g_string_append(xhtml, "<"); |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1774 if(plain) |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1775 plain = g_string_append_c(plain, '<'); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1776 c++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1777 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1778 } else if(*c == '&') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1779 char buf[7]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1780 const char *pln; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1781 int len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1782 |
16084 | 1783 if ((pln = purple_markup_unescape_entity(c, &len)) == NULL) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1784 len = 1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1785 g_snprintf(buf, sizeof(buf), "%c", *c); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1786 pln = buf; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1787 } |
17481
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1788 if(xhtml) |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1789 xhtml = g_string_append_len(xhtml, c, len); |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1790 if(plain) |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1791 plain = g_string_append(plain, pln); |
21185
4a0f841e6f26
applied changes from f0cdd16c20f9773e28cd79b36ffcf1c66057e32e
Stu Tomlinson <stu@nosnilmot.com>
parents:
21177
diff
changeset
|
1792 if(cdata) |
4a0f841e6f26
applied changes from f0cdd16c20f9773e28cd79b36ffcf1c66057e32e
Stu Tomlinson <stu@nosnilmot.com>
parents:
21177
diff
changeset
|
1793 cdata = g_string_append_len(cdata, c, len); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1794 c += len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1795 } else { |
17481
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1796 if(xhtml) |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1797 xhtml = g_string_append_c(xhtml, *c); |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1798 if(plain) |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1799 plain = g_string_append_c(plain, *c); |
19262
450090c68351
When converting to xhtml, only add URLs in angle brackets if it doesn't match the cdata. Fixes #2445
Sean Egan <seanegan@gmail.com>
parents:
18600
diff
changeset
|
1800 if(cdata) |
450090c68351
When converting to xhtml, only add URLs in angle brackets if it doesn't match the cdata. Fixes #2445
Sean Egan <seanegan@gmail.com>
parents:
18600
diff
changeset
|
1801 cdata = g_string_append_c(cdata, *c); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1802 c++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1803 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1804 } |
17481
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1805 if(xhtml) { |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1806 for (tag = tags; tag ; tag = tag->next) { |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1807 struct purple_parse_tag *pt = tag->data; |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1808 if(!pt->ignore) |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1809 g_string_append_printf(xhtml, "</%s>", pt->dest_tag); |
6608a7ab0fd9
In purple_markup_html_to_xhtml:
Richard Laager <rlaager@wiktel.com>
parents:
17480
diff
changeset
|
1810 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1811 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1812 g_list_free(tags); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1813 if(xhtml_out) |
17480
a7a8e4245b33
Remove needless string duplication.
Richard Laager <rlaager@wiktel.com>
parents:
17450
diff
changeset
|
1814 *xhtml_out = g_string_free(xhtml, FALSE); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1815 if(plain_out) |
17480
a7a8e4245b33
Remove needless string duplication.
Richard Laager <rlaager@wiktel.com>
parents:
17450
diff
changeset
|
1816 *plain_out = g_string_free(plain, FALSE); |
18560
481eb37730bf
This was crashing for me when writing a system message when logging
Mark Doliner <mark@kingant.net>
parents:
18493
diff
changeset
|
1817 if(url) |
481eb37730bf
This was crashing for me when writing a system message when logging
Mark Doliner <mark@kingant.net>
parents:
18493
diff
changeset
|
1818 g_string_free(url, TRUE); |
21185
4a0f841e6f26
applied changes from f0cdd16c20f9773e28cd79b36ffcf1c66057e32e
Stu Tomlinson <stu@nosnilmot.com>
parents:
21177
diff
changeset
|
1819 if (cdata) |
4a0f841e6f26
applied changes from f0cdd16c20f9773e28cd79b36ffcf1c66057e32e
Stu Tomlinson <stu@nosnilmot.com>
parents:
21177
diff
changeset
|
1820 g_string_free(cdata, TRUE); |
23248
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1821 #undef CHECK_QUOTE |
228d576a7dd7
Modified patch from Dylan Simon (dylex) to improve
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23142
diff
changeset
|
1822 #undef VALID_CHAR |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1823 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1824 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1825 /* The following are probably reasonable changes: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1826 * - \n should be converted to a normal space |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1827 * - in addition to <br>, <p> and <div> etc. should also be converted into \n |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1828 * - We want to turn </td>#whitespace<td> sequences into a single tab |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1829 * - We want to turn <td> into a single tab (for msn profile "parsing") |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1830 * - We want to turn </tr>#whitespace<tr> sequences into a single \n |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1831 * - <script>...</script> and <style>...</style> should be completely removed |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1832 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1833 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1834 char * |
15822 | 1835 purple_markup_strip_html(const char *str) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1836 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1837 int i, j, k, entlen; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1838 gboolean visible = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1839 gboolean closing_td_p = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1840 gchar *str2; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1841 const gchar *cdata_close_tag = NULL, *ent; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1842 gchar *href = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1843 int href_st = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1844 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1845 if(!str) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1846 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1847 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1848 str2 = g_strdup(str); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1849 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1850 for (i = 0, j = 0; str2[i]; i++) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1851 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1852 if (str2[i] == '<') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1853 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1854 if (cdata_close_tag) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1855 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1856 /* Note: Don't even assume any other tag is a tag in CDATA */ |
18397
e122b631a657
Replace some strncasecmp() calls with g_ascii_strncasecmp() as part of the
Nick Hebner <hebnern@gmail.com>
parents:
18259
diff
changeset
|
1857 if (g_ascii_strncasecmp(str2 + i, cdata_close_tag, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1858 strlen(cdata_close_tag)) == 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1859 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1860 i += strlen(cdata_close_tag) - 1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1861 cdata_close_tag = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1862 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1863 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1864 } |
18397
e122b631a657
Replace some strncasecmp() calls with g_ascii_strncasecmp() as part of the
Nick Hebner <hebnern@gmail.com>
parents:
18259
diff
changeset
|
1865 else if (g_ascii_strncasecmp(str2 + i, "<td", 3) == 0 && closing_td_p) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1866 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1867 str2[j++] = '\t'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1868 visible = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1869 } |
18397
e122b631a657
Replace some strncasecmp() calls with g_ascii_strncasecmp() as part of the
Nick Hebner <hebnern@gmail.com>
parents:
18259
diff
changeset
|
1870 else if (g_ascii_strncasecmp(str2 + i, "</td>", 5) == 0) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1871 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1872 closing_td_p = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1873 visible = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1874 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1875 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1876 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1877 closing_td_p = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1878 visible = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1879 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1880 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1881 k = i + 1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1882 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1883 if(g_ascii_isspace(str2[k])) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1884 visible = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1885 else if (str2[k]) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1886 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1887 /* Scan until we end the tag either implicitly (closed start |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1888 * tag) or explicitly, using a sloppy method (i.e., < or > |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1889 * inside quoted attributes will screw us up) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1890 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1891 while (str2[k] && str2[k] != '<' && str2[k] != '>') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1892 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1893 k++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1894 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1895 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1896 /* If we've got an <a> tag with an href, save the address |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1897 * to print later. */ |
18397
e122b631a657
Replace some strncasecmp() calls with g_ascii_strncasecmp() as part of the
Nick Hebner <hebnern@gmail.com>
parents:
18259
diff
changeset
|
1898 if (g_ascii_strncasecmp(str2 + i, "<a", 2) == 0 && |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1899 g_ascii_isspace(str2[i+2])) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1900 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1901 int st; /* start of href, inclusive [ */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1902 int end; /* end of href, exclusive ) */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1903 char delim = ' '; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1904 /* Find start of href */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1905 for (st = i + 3; st < k; st++) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1906 { |
18397
e122b631a657
Replace some strncasecmp() calls with g_ascii_strncasecmp() as part of the
Nick Hebner <hebnern@gmail.com>
parents:
18259
diff
changeset
|
1907 if (g_ascii_strncasecmp(str2+st, "href=", 5) == 0) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1908 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1909 st += 5; |
16169
49a1fed5ee37
This was causing problems with jabber in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16153
diff
changeset
|
1910 if (str2[st] == '"' || str2[st] == '\'') |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1911 { |
16169
49a1fed5ee37
This was causing problems with jabber in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16153
diff
changeset
|
1912 delim = str2[st]; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1913 st++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1914 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1915 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1916 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1917 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1918 /* find end of address */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1919 for (end = st; end < k && str2[end] != delim; end++) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1920 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1921 /* All the work is done in the loop construct above. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1922 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1923 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1924 /* If there's an address, save it. If there was |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1925 * already one saved, kill it. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1926 if (st < k) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1927 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1928 char *tmp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1929 g_free(href); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1930 tmp = g_strndup(str2 + st, end - st); |
15822 | 1931 href = purple_unescape_html(tmp); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1932 g_free(tmp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1933 href_st = j; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1934 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1935 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1936 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1937 /* Replace </a> with an ascii representation of the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1938 * address the link was pointing to. */ |
18397
e122b631a657
Replace some strncasecmp() calls with g_ascii_strncasecmp() as part of the
Nick Hebner <hebnern@gmail.com>
parents:
18259
diff
changeset
|
1939 else if (href != NULL && g_ascii_strncasecmp(str2 + i, "</a>", 4) == 0) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1940 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1941 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1942 size_t hrlen = strlen(href); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1943 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1944 /* Only insert the href if it's different from the CDATA. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1945 if ((hrlen != j - href_st || |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1946 strncmp(str2 + href_st, href, hrlen)) && |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1947 (hrlen != j - href_st + 7 || /* 7 == strlen("http://") */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1948 strncmp(str2 + href_st, href + 7, hrlen - 7))) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1949 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1950 str2[j++] = ' '; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1951 str2[j++] = '('; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1952 g_memmove(str2 + j, href, hrlen); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1953 j += hrlen; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1954 str2[j++] = ')'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1955 g_free(href); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1956 href = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1957 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1958 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1959 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1960 /* Check for tags which should be mapped to newline */ |
18397
e122b631a657
Replace some strncasecmp() calls with g_ascii_strncasecmp() as part of the
Nick Hebner <hebnern@gmail.com>
parents:
18259
diff
changeset
|
1961 else if (g_ascii_strncasecmp(str2 + i, "<p>", 3) == 0 |
e122b631a657
Replace some strncasecmp() calls with g_ascii_strncasecmp() as part of the
Nick Hebner <hebnern@gmail.com>
parents:
18259
diff
changeset
|
1962 || g_ascii_strncasecmp(str2 + i, "<tr", 3) == 0 |
e122b631a657
Replace some strncasecmp() calls with g_ascii_strncasecmp() as part of the
Nick Hebner <hebnern@gmail.com>
parents:
18259
diff
changeset
|
1963 || g_ascii_strncasecmp(str2 + i, "<br", 3) == 0 |
e122b631a657
Replace some strncasecmp() calls with g_ascii_strncasecmp() as part of the
Nick Hebner <hebnern@gmail.com>
parents:
18259
diff
changeset
|
1964 || g_ascii_strncasecmp(str2 + i, "<hr", 3) == 0 |
e122b631a657
Replace some strncasecmp() calls with g_ascii_strncasecmp() as part of the
Nick Hebner <hebnern@gmail.com>
parents:
18259
diff
changeset
|
1965 || g_ascii_strncasecmp(str2 + i, "<li", 3) == 0 |
e122b631a657
Replace some strncasecmp() calls with g_ascii_strncasecmp() as part of the
Nick Hebner <hebnern@gmail.com>
parents:
18259
diff
changeset
|
1966 || g_ascii_strncasecmp(str2 + i, "<div", 4) == 0 |
e122b631a657
Replace some strncasecmp() calls with g_ascii_strncasecmp() as part of the
Nick Hebner <hebnern@gmail.com>
parents:
18259
diff
changeset
|
1967 || g_ascii_strncasecmp(str2 + i, "</table>", 8) == 0) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1968 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1969 str2[j++] = '\n'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1970 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1971 /* Check for tags which begin CDATA and need to be closed */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1972 #if 0 /* FIXME.. option is end tag optional, we can't handle this right now */ |
18397
e122b631a657
Replace some strncasecmp() calls with g_ascii_strncasecmp() as part of the
Nick Hebner <hebnern@gmail.com>
parents:
18259
diff
changeset
|
1973 else if (g_ascii_strncasecmp(str2 + i, "<option", 7) == 0) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1974 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1975 /* FIXME: We should not do this if the OPTION is SELECT'd */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1976 cdata_close_tag = "</option>"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1977 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1978 #endif |
18397
e122b631a657
Replace some strncasecmp() calls with g_ascii_strncasecmp() as part of the
Nick Hebner <hebnern@gmail.com>
parents:
18259
diff
changeset
|
1979 else if (g_ascii_strncasecmp(str2 + i, "<script", 7) == 0) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1980 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1981 cdata_close_tag = "</script>"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1982 } |
18397
e122b631a657
Replace some strncasecmp() calls with g_ascii_strncasecmp() as part of the
Nick Hebner <hebnern@gmail.com>
parents:
18259
diff
changeset
|
1983 else if (g_ascii_strncasecmp(str2 + i, "<style", 6) == 0) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1984 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1985 cdata_close_tag = "</style>"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1986 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1987 /* Update the index and continue checking after the tag */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1988 i = (str2[k] == '<' || str2[k] == '\0')? k - 1: k; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1989 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1990 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1991 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1992 else if (cdata_close_tag) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1993 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1994 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1995 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1996 else if (!g_ascii_isspace(str2[i])) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1997 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1998 visible = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1999 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2000 |
16084 | 2001 if (str2[i] == '&' && (ent = purple_markup_unescape_entity(str2 + i, &entlen)) != NULL) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2002 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2003 while (*ent) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2004 str2[j++] = *ent++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2005 i += entlen - 1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2006 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2007 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2008 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2009 if (visible) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2010 str2[j++] = g_ascii_isspace(str2[i])? ' ': str2[i]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2011 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2012 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2013 g_free(href); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2014 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2015 str2[j] = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2016 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2017 return str2; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2018 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2019 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2020 static gboolean |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2021 badchar(char c) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2022 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2023 switch (c) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2024 case ' ': |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2025 case ',': |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2026 case '\0': |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2027 case '\n': |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2028 case '\r': |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2029 case '<': |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2030 case '>': |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2031 case '"': |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2032 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2033 default: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2034 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2035 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2036 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2037 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2038 static gboolean |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2039 badentity(const char *c) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2040 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2041 if (!g_ascii_strncasecmp(c, "<", 4) || |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2042 !g_ascii_strncasecmp(c, ">", 4) || |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2043 !g_ascii_strncasecmp(c, """, 6)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2044 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2045 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2046 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2047 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2048 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2049 char * |
15822 | 2050 purple_markup_linkify(const char *text) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2051 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2052 const char *c, *t, *q = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2053 char *tmpurlbuf, *url_buf; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2054 gunichar g; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2055 gboolean inside_html = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2056 int inside_paren = 0; |
23652
27eacd38c721
Add NULL checking to purple_markup_linkify().
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23538
diff
changeset
|
2057 GString *ret; |
27eacd38c721
Add NULL checking to purple_markup_linkify().
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23538
diff
changeset
|
2058 |
27eacd38c721
Add NULL checking to purple_markup_linkify().
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23538
diff
changeset
|
2059 if (text == NULL) |
27eacd38c721
Add NULL checking to purple_markup_linkify().
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23538
diff
changeset
|
2060 return NULL; |
27eacd38c721
Add NULL checking to purple_markup_linkify().
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23538
diff
changeset
|
2061 |
27eacd38c721
Add NULL checking to purple_markup_linkify().
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23538
diff
changeset
|
2062 ret = g_string_new(""); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2063 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2064 c = text; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2065 while (*c) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2066 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2067 if(*c == '(' && !inside_html) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2068 inside_paren++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2069 ret = g_string_append_c(ret, *c); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2070 c++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2071 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2072 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2073 if(inside_html) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2074 if(*c == '>') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2075 inside_html = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2076 } else if(!q && (*c == '\"' || *c == '\'')) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2077 q = c; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2078 } else if(q) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2079 if(*c == *q) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2080 q = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2081 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2082 } else if(*c == '<') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2083 inside_html = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2084 if (!g_ascii_strncasecmp(c, "<A", 2)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2085 while (1) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2086 if (!g_ascii_strncasecmp(c, "/A>", 3)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2087 inside_html = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2088 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2089 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2090 ret = g_string_append_c(ret, *c); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2091 c++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2092 if (!(*c)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2093 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2094 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2095 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2096 } else if ((*c=='h') && (!g_ascii_strncasecmp(c, "http://", 7) || |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2097 (!g_ascii_strncasecmp(c, "https://", 8)))) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2098 t = c; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2099 while (1) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2100 if (badchar(*t) || badentity(t)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2101 |
17158 | 2102 if ((!g_ascii_strncasecmp(c, "http://", 7) && (t - c == 7)) || |
2103 (!g_ascii_strncasecmp(c, "https://", 8) && (t - c == 8))) { | |
2104 break; | |
2105 } | |
2106 | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2107 if (*(t) == ',' && (*(t + 1) != ' ')) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2108 t++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2109 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2110 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2111 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2112 if (*(t - 1) == '.') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2113 t--; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2114 if ((*(t - 1) == ')' && (inside_paren > 0))) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2115 t--; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2116 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2117 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2118 url_buf = g_strndup(c, t - c); |
15822 | 2119 tmpurlbuf = purple_unescape_html(url_buf); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2120 g_string_append_printf(ret, "<A HREF=\"%s\">%s</A>", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2121 tmpurlbuf, url_buf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2122 g_free(url_buf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2123 g_free(tmpurlbuf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2124 c = t; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2125 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2126 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2127 t++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2128 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2129 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2130 } else if (!g_ascii_strncasecmp(c, "www.", 4) && (c == text || badchar(c[-1]) || badentity(c-1))) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2131 if (c[4] != '.') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2132 t = c; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2133 while (1) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2134 if (badchar(*t) || badentity(t)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2135 if (t - c == 4) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2136 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2137 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2138 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2139 if (*(t) == ',' && (*(t + 1) != ' ')) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2140 t++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2141 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2142 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2143 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2144 if (*(t - 1) == '.') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2145 t--; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2146 if ((*(t - 1) == ')' && (inside_paren > 0))) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2147 t--; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2148 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2149 url_buf = g_strndup(c, t - c); |
15822 | 2150 tmpurlbuf = purple_unescape_html(url_buf); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2151 g_string_append_printf(ret, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2152 "<A HREF=\"http://%s\">%s</A>", tmpurlbuf, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2153 url_buf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2154 g_free(url_buf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2155 g_free(tmpurlbuf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2156 c = t; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2157 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2158 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2159 t++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2160 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2161 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2162 } else if (!g_ascii_strncasecmp(c, "ftp://", 6) || !g_ascii_strncasecmp(c, "sftp://", 7)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2163 t = c; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2164 while (1) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2165 if (badchar(*t) || badentity(t)) { |
17158 | 2166 |
2167 if ((!g_ascii_strncasecmp(c, "ftp://", 6) && (t - c == 6)) || | |
2168 (!g_ascii_strncasecmp(c, "sftp://", 7) && (t - c == 7))) { | |
2169 break; | |
2170 } | |
2171 | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2172 if (*(t - 1) == '.') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2173 t--; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2174 if ((*(t - 1) == ')' && (inside_paren > 0))) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2175 t--; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2176 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2177 url_buf = g_strndup(c, t - c); |
15822 | 2178 tmpurlbuf = purple_unescape_html(url_buf); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2179 g_string_append_printf(ret, "<A HREF=\"%s\">%s</A>", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2180 tmpurlbuf, url_buf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2181 g_free(url_buf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2182 g_free(tmpurlbuf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2183 c = t; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2184 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2185 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2186 if (!t) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2187 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2188 t++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2189 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2190 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2191 } else if (!g_ascii_strncasecmp(c, "ftp.", 4) && (c == text || badchar(c[-1]) || badentity(c-1))) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2192 if (c[4] != '.') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2193 t = c; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2194 while (1) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2195 if (badchar(*t) || badentity(t)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2196 if (t - c == 4) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2197 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2198 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2199 if (*(t - 1) == '.') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2200 t--; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2201 if ((*(t - 1) == ')' && (inside_paren > 0))) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2202 t--; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2203 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2204 url_buf = g_strndup(c, t - c); |
15822 | 2205 tmpurlbuf = purple_unescape_html(url_buf); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2206 g_string_append_printf(ret, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2207 "<A HREF=\"ftp://%s\">%s</A>", tmpurlbuf, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2208 url_buf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2209 g_free(url_buf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2210 g_free(tmpurlbuf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2211 c = t; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2212 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2213 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2214 if (!t) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2215 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2216 t++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2217 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2218 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2219 } else if (!g_ascii_strncasecmp(c, "mailto:", 7)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2220 t = c; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2221 while (1) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2222 if (badchar(*t) || badentity(t)) { |
17158 | 2223 char *d; |
2224 if (t - c == 7) { | |
2225 break; | |
2226 } | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2227 if (*(t - 1) == '.') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2228 t--; |
17158 | 2229 if ((d = strstr(c + 7, "?")) != NULL && d < t) |
2230 url_buf = g_strndup(c + 7, d - c - 7); | |
2231 else | |
2232 url_buf = g_strndup(c + 7, t - c - 7); | |
2233 if (!purple_email_is_valid(url_buf)) { | |
2234 g_free(url_buf); | |
2235 break; | |
2236 } | |
2237 g_free(url_buf); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2238 url_buf = g_strndup(c, t - c); |
15822 | 2239 tmpurlbuf = purple_unescape_html(url_buf); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2240 g_string_append_printf(ret, "<A HREF=\"%s\">%s</A>", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2241 tmpurlbuf, url_buf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2242 g_free(url_buf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2243 g_free(tmpurlbuf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2244 c = t; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2245 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2246 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2247 if (!t) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2248 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2249 t++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2250 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2251 } |
17158 | 2252 } else if ((*c=='x') && (!g_ascii_strncasecmp(c, "xmpp:", 5)) && |
2253 (c == text || badchar(c[-1]) || badentity(c-1))) { | |
2254 t = c; | |
2255 while (1) { | |
2256 if (badchar(*t) || badentity(t)) { | |
2257 | |
2258 if (t - c == 5) { | |
2259 break; | |
2260 } | |
2261 | |
2262 if (*(t) == ',' && (*(t + 1) != ' ')) { | |
2263 t++; | |
2264 continue; | |
2265 } | |
2266 | |
2267 if (*(t - 1) == '.') | |
2268 t--; | |
2269 if ((*(t - 1) == ')' && (inside_paren > 0))) { | |
2270 t--; | |
2271 } | |
2272 | |
2273 url_buf = g_strndup(c, t - c); | |
2274 tmpurlbuf = purple_unescape_html(url_buf); | |
2275 g_string_append_printf(ret, "<A HREF=\"%s\">%s</A>", | |
2276 tmpurlbuf, url_buf); | |
2277 g_free(url_buf); | |
2278 g_free(tmpurlbuf); | |
2279 c = t; | |
2280 break; | |
2281 } | |
2282 t++; | |
2283 | |
2284 } | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2285 } else if (c != text && (*c == '@')) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2286 int flag; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2287 GString *gurl_buf = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2288 const char illegal_chars[] = "!@#$%^&*()[]{}/|\\<>\":;\r\n \0"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2289 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2290 if (strchr(illegal_chars,*(c - 1)) || strchr(illegal_chars, *(c + 1))) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2291 flag = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2292 else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2293 flag = 1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2294 gurl_buf = g_string_new(""); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2295 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2296 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2297 t = c; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2298 while (flag) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2299 /* iterate backwards grabbing the local part of an email address */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2300 g = g_utf8_get_char(t); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2301 if (badchar(*t) || (g >= 127) || (*t == '(') || |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2302 ((*t == ';') && ((t > (text+2) && (!g_ascii_strncasecmp(t - 3, "<", 4) || |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2303 !g_ascii_strncasecmp(t - 3, ">", 4))) || |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2304 (t > (text+4) && (!g_ascii_strncasecmp(t - 5, """, 6)))))) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2305 /* local part will already be part of ret, strip it out */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2306 ret = g_string_truncate(ret, ret->len - (c - t)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2307 ret = g_string_append_unichar(ret, g); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2308 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2309 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2310 g_string_prepend_unichar(gurl_buf, g); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2311 t = g_utf8_find_prev_char(text, t); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2312 if (t < text) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2313 ret = g_string_assign(ret, ""); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2314 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2315 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2316 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2317 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2318 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2319 t = g_utf8_find_next_char(c, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2320 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2321 while (flag) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2322 /* iterate forwards grabbing the domain part of an email address */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2323 g = g_utf8_get_char(t); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2324 if (badchar(*t) || (g >= 127) || (*t == ')') || badentity(t)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2325 char *d; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2326 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2327 url_buf = g_string_free(gurl_buf, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2328 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2329 /* strip off trailing periods */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2330 if (strlen(url_buf) > 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2331 for (d = url_buf + strlen(url_buf) - 1; *d == '.'; d--, t--) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2332 *d = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2333 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2334 |
15822 | 2335 tmpurlbuf = purple_unescape_html(url_buf); |
2336 if (purple_email_is_valid(tmpurlbuf)) { | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2337 g_string_append_printf(ret, "<A HREF=\"mailto:%s\">%s</A>", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2338 tmpurlbuf, url_buf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2339 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2340 g_string_append(ret, url_buf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2341 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2342 g_free(url_buf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2343 g_free(tmpurlbuf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2344 c = t; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2345 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2346 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2347 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2348 g_string_append_unichar(gurl_buf, g); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2349 t = g_utf8_find_next_char(t, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2350 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2351 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2352 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2353 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2354 if(*c == ')' && !inside_html) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2355 inside_paren--; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2356 ret = g_string_append_c(ret, *c); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2357 c++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2358 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2359 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2360 if (*c == 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2361 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2362 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2363 ret = g_string_append_c(ret, *c); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2364 c++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2365 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2366 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2367 return g_string_free(ret, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2368 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2369 |
29359
05d727f76ca9
Combine the three purple_unescape_text()s into one.
Paul Aurich <paul@darkrain42.org>
parents:
29348
diff
changeset
|
2370 char *purple_unescape_text(const char *in) |
05d727f76ca9
Combine the three purple_unescape_text()s into one.
Paul Aurich <paul@darkrain42.org>
parents:
29348
diff
changeset
|
2371 { |
05d727f76ca9
Combine the three purple_unescape_text()s into one.
Paul Aurich <paul@darkrain42.org>
parents:
29348
diff
changeset
|
2372 GString *ret; |
05d727f76ca9
Combine the three purple_unescape_text()s into one.
Paul Aurich <paul@darkrain42.org>
parents:
29348
diff
changeset
|
2373 const char *c = in; |
05d727f76ca9
Combine the three purple_unescape_text()s into one.
Paul Aurich <paul@darkrain42.org>
parents:
29348
diff
changeset
|
2374 |
05d727f76ca9
Combine the three purple_unescape_text()s into one.
Paul Aurich <paul@darkrain42.org>
parents:
29348
diff
changeset
|
2375 if (in == NULL) |
05d727f76ca9
Combine the three purple_unescape_text()s into one.
Paul Aurich <paul@darkrain42.org>
parents:
29348
diff
changeset
|
2376 return NULL; |
05d727f76ca9
Combine the three purple_unescape_text()s into one.
Paul Aurich <paul@darkrain42.org>
parents:
29348
diff
changeset
|
2377 |
05d727f76ca9
Combine the three purple_unescape_text()s into one.
Paul Aurich <paul@darkrain42.org>
parents:
29348
diff
changeset
|
2378 ret = g_string_new(""); |
05d727f76ca9
Combine the three purple_unescape_text()s into one.
Paul Aurich <paul@darkrain42.org>
parents:
29348
diff
changeset
|
2379 while (*c) { |
05d727f76ca9
Combine the three purple_unescape_text()s into one.
Paul Aurich <paul@darkrain42.org>
parents:
29348
diff
changeset
|
2380 int len; |
05d727f76ca9
Combine the three purple_unescape_text()s into one.
Paul Aurich <paul@darkrain42.org>
parents:
29348
diff
changeset
|
2381 const char *ent; |
05d727f76ca9
Combine the three purple_unescape_text()s into one.
Paul Aurich <paul@darkrain42.org>
parents:
29348
diff
changeset
|
2382 |
05d727f76ca9
Combine the three purple_unescape_text()s into one.
Paul Aurich <paul@darkrain42.org>
parents:
29348
diff
changeset
|
2383 if ((ent = purple_markup_unescape_entity(c, &len)) != NULL) { |
05d727f76ca9
Combine the three purple_unescape_text()s into one.
Paul Aurich <paul@darkrain42.org>
parents:
29348
diff
changeset
|
2384 g_string_append(ret, ent); |
05d727f76ca9
Combine the three purple_unescape_text()s into one.
Paul Aurich <paul@darkrain42.org>
parents:
29348
diff
changeset
|
2385 c += len; |
05d727f76ca9
Combine the three purple_unescape_text()s into one.
Paul Aurich <paul@darkrain42.org>
parents:
29348
diff
changeset
|
2386 } else { |
05d727f76ca9
Combine the three purple_unescape_text()s into one.
Paul Aurich <paul@darkrain42.org>
parents:
29348
diff
changeset
|
2387 g_string_append_c(ret, *c); |
05d727f76ca9
Combine the three purple_unescape_text()s into one.
Paul Aurich <paul@darkrain42.org>
parents:
29348
diff
changeset
|
2388 c++; |
05d727f76ca9
Combine the three purple_unescape_text()s into one.
Paul Aurich <paul@darkrain42.org>
parents:
29348
diff
changeset
|
2389 } |
05d727f76ca9
Combine the three purple_unescape_text()s into one.
Paul Aurich <paul@darkrain42.org>
parents:
29348
diff
changeset
|
2390 } |
05d727f76ca9
Combine the three purple_unescape_text()s into one.
Paul Aurich <paul@darkrain42.org>
parents:
29348
diff
changeset
|
2391 |
05d727f76ca9
Combine the three purple_unescape_text()s into one.
Paul Aurich <paul@darkrain42.org>
parents:
29348
diff
changeset
|
2392 return g_string_free(ret, FALSE); |
05d727f76ca9
Combine the three purple_unescape_text()s into one.
Paul Aurich <paul@darkrain42.org>
parents:
29348
diff
changeset
|
2393 } |
05d727f76ca9
Combine the three purple_unescape_text()s into one.
Paul Aurich <paul@darkrain42.org>
parents:
29348
diff
changeset
|
2394 |
27268
c0075538109b
Formatting changes, no functionality.
Mark Doliner <mark@kingant.net>
parents:
27246
diff
changeset
|
2395 char *purple_unescape_html(const char *html) |
c0075538109b
Formatting changes, no functionality.
Mark Doliner <mark@kingant.net>
parents:
27246
diff
changeset
|
2396 { |
c0075538109b
Formatting changes, no functionality.
Mark Doliner <mark@kingant.net>
parents:
27246
diff
changeset
|
2397 GString *ret; |
c0075538109b
Formatting changes, no functionality.
Mark Doliner <mark@kingant.net>
parents:
27246
diff
changeset
|
2398 const char *c = html; |
c0075538109b
Formatting changes, no functionality.
Mark Doliner <mark@kingant.net>
parents:
27246
diff
changeset
|
2399 |
c0075538109b
Formatting changes, no functionality.
Mark Doliner <mark@kingant.net>
parents:
27246
diff
changeset
|
2400 if (html == NULL) |
c0075538109b
Formatting changes, no functionality.
Mark Doliner <mark@kingant.net>
parents:
27246
diff
changeset
|
2401 return NULL; |
c0075538109b
Formatting changes, no functionality.
Mark Doliner <mark@kingant.net>
parents:
27246
diff
changeset
|
2402 |
c0075538109b
Formatting changes, no functionality.
Mark Doliner <mark@kingant.net>
parents:
27246
diff
changeset
|
2403 ret = g_string_new(""); |
c0075538109b
Formatting changes, no functionality.
Mark Doliner <mark@kingant.net>
parents:
27246
diff
changeset
|
2404 while (*c) { |
c0075538109b
Formatting changes, no functionality.
Mark Doliner <mark@kingant.net>
parents:
27246
diff
changeset
|
2405 int len; |
c0075538109b
Formatting changes, no functionality.
Mark Doliner <mark@kingant.net>
parents:
27246
diff
changeset
|
2406 const char *ent; |
c0075538109b
Formatting changes, no functionality.
Mark Doliner <mark@kingant.net>
parents:
27246
diff
changeset
|
2407 |
c0075538109b
Formatting changes, no functionality.
Mark Doliner <mark@kingant.net>
parents:
27246
diff
changeset
|
2408 if ((ent = purple_markup_unescape_entity(c, &len)) != NULL) { |
c0075538109b
Formatting changes, no functionality.
Mark Doliner <mark@kingant.net>
parents:
27246
diff
changeset
|
2409 g_string_append(ret, ent); |
c0075538109b
Formatting changes, no functionality.
Mark Doliner <mark@kingant.net>
parents:
27246
diff
changeset
|
2410 c += len; |
c0075538109b
Formatting changes, no functionality.
Mark Doliner <mark@kingant.net>
parents:
27246
diff
changeset
|
2411 } else if (!strncmp(c, "<br>", 4)) { |
c0075538109b
Formatting changes, no functionality.
Mark Doliner <mark@kingant.net>
parents:
27246
diff
changeset
|
2412 g_string_append_c(ret, '\n'); |
c0075538109b
Formatting changes, no functionality.
Mark Doliner <mark@kingant.net>
parents:
27246
diff
changeset
|
2413 c += 4; |
c0075538109b
Formatting changes, no functionality.
Mark Doliner <mark@kingant.net>
parents:
27246
diff
changeset
|
2414 } else { |
c0075538109b
Formatting changes, no functionality.
Mark Doliner <mark@kingant.net>
parents:
27246
diff
changeset
|
2415 g_string_append_c(ret, *c); |
c0075538109b
Formatting changes, no functionality.
Mark Doliner <mark@kingant.net>
parents:
27246
diff
changeset
|
2416 c++; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2417 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2418 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2419 |
27268
c0075538109b
Formatting changes, no functionality.
Mark Doliner <mark@kingant.net>
parents:
27246
diff
changeset
|
2420 return g_string_free(ret, FALSE); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2421 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2422 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2423 char * |
15822 | 2424 purple_markup_slice(const char *str, guint x, guint y) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2425 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2426 GString *ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2427 GQueue *q; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2428 guint z = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2429 gboolean appended = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2430 gunichar c; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2431 char *tag; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2432 |
24420 | 2433 g_return_val_if_fail(str != NULL, NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2434 g_return_val_if_fail(x <= y, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2435 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2436 if (x == y) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2437 return g_strdup(""); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2438 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2439 ret = g_string_new(""); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2440 q = g_queue_new(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2441 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2442 while (*str && (z < y)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2443 c = g_utf8_get_char(str); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2444 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2445 if (c == '<') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2446 char *end = strchr(str, '>'); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2447 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2448 if (!end) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2449 g_string_free(ret, TRUE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2450 while ((tag = g_queue_pop_head(q))) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2451 g_free(tag); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2452 g_queue_free(q); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2453 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2454 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2455 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2456 if (!g_ascii_strncasecmp(str, "<img ", 5)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2457 z += strlen("[Image]"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2458 } else if (!g_ascii_strncasecmp(str, "<br", 3)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2459 z += 1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2460 } else if (!g_ascii_strncasecmp(str, "<hr>", 4)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2461 z += strlen("\n---\n"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2462 } else if (!g_ascii_strncasecmp(str, "</", 2)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2463 /* pop stack */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2464 char *tmp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2465 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2466 tmp = g_queue_pop_head(q); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2467 g_free(tmp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2468 /* z += 0; */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2469 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2470 /* push it unto the stack */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2471 char *tmp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2472 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2473 tmp = g_strndup(str, end - str + 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2474 g_queue_push_head(q, tmp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2475 /* z += 0; */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2476 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2477 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2478 if (z >= x) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2479 g_string_append_len(ret, str, end - str + 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2480 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2481 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2482 str = end; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2483 } else if (c == '&') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2484 char *end = strchr(str, ';'); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2485 if (!end) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2486 g_string_free(ret, TRUE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2487 while ((tag = g_queue_pop_head(q))) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2488 g_free(tag); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2489 g_queue_free(q); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2490 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2491 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2492 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2493 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2494 if (z >= x) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2495 g_string_append_len(ret, str, end - str + 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2496 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2497 z++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2498 str = end; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2499 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2500 if (z == x && z > 0 && !appended) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2501 GList *l = q->tail; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2502 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2503 while (l) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2504 tag = l->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2505 g_string_append(ret, tag); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2506 l = l->prev; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2507 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2508 appended = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2509 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2510 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2511 if (z >= x) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2512 g_string_append_unichar(ret, c); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2513 z++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2514 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2515 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2516 str = g_utf8_next_char(str); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2517 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2518 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2519 while ((tag = g_queue_pop_head(q))) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2520 char *name; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2521 |
15822 | 2522 name = purple_markup_get_tag_name(tag); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2523 g_string_append_printf(ret, "</%s>", name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2524 g_free(name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2525 g_free(tag); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2526 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2527 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2528 g_queue_free(q); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2529 return g_string_free(ret, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2530 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2531 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2532 char * |
15822 | 2533 purple_markup_get_tag_name(const char *tag) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2534 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2535 int i; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2536 g_return_val_if_fail(tag != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2537 g_return_val_if_fail(*tag == '<', NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2538 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2539 for (i = 1; tag[i]; i++) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2540 if (tag[i] == '>' || tag[i] == ' ' || tag[i] == '/') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2541 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2542 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2543 return g_strndup(tag+1, i-1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2544 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2545 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2546 /************************************************************************** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2547 * Path/Filename Functions |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2548 **************************************************************************/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2549 const char * |
15822 | 2550 purple_home_dir(void) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2551 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2552 #ifndef _WIN32 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2553 return g_get_home_dir(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2554 #else |
15822 | 2555 return wpurple_data_dir(); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2556 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2557 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2558 |
16367
6a9ae99e7050
Use ~/.purple only, never ~/.gaim. This is a revert of the functional
Richard Laager <rlaager@wiktel.com>
parents:
16169
diff
changeset
|
2559 /* Returns the argument passed to -c IFF it was present, or ~/.purple. */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2560 const char * |
15822 | 2561 purple_user_dir(void) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2562 { |
18147
5653692dcf79
Use dynamically allocated strings for the user_dir caching. Do we need to
Richard Laager <rlaager@wiktel.com>
parents:
18129
diff
changeset
|
2563 if (custom_user_dir != NULL) |
5653692dcf79
Use dynamically allocated strings for the user_dir caching. Do we need to
Richard Laager <rlaager@wiktel.com>
parents:
18129
diff
changeset
|
2564 return custom_user_dir; |
20091
2ab6b55ffa3d
Rename the internal home_dir variable to user_dir to match the function and
Richard Laager <rlaager@wiktel.com>
parents:
20074
diff
changeset
|
2565 else if (!user_dir) |
2ab6b55ffa3d
Rename the internal home_dir variable to user_dir to match the function and
Richard Laager <rlaager@wiktel.com>
parents:
20074
diff
changeset
|
2566 user_dir = g_build_filename(purple_home_dir(), ".purple", NULL); |
2ab6b55ffa3d
Rename the internal home_dir variable to user_dir to match the function and
Richard Laager <rlaager@wiktel.com>
parents:
20074
diff
changeset
|
2567 |
2ab6b55ffa3d
Rename the internal home_dir variable to user_dir to match the function and
Richard Laager <rlaager@wiktel.com>
parents:
20074
diff
changeset
|
2568 return user_dir; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2569 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2570 |
15822 | 2571 void purple_util_set_user_dir(const char *dir) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2572 { |
18147
5653692dcf79
Use dynamically allocated strings for the user_dir caching. Do we need to
Richard Laager <rlaager@wiktel.com>
parents:
18129
diff
changeset
|
2573 g_free(custom_user_dir); |
5653692dcf79
Use dynamically allocated strings for the user_dir caching. Do we need to
Richard Laager <rlaager@wiktel.com>
parents:
18129
diff
changeset
|
2574 |
5653692dcf79
Use dynamically allocated strings for the user_dir caching. Do we need to
Richard Laager <rlaager@wiktel.com>
parents:
18129
diff
changeset
|
2575 if (dir != NULL && *dir) |
5653692dcf79
Use dynamically allocated strings for the user_dir caching. Do we need to
Richard Laager <rlaager@wiktel.com>
parents:
18129
diff
changeset
|
2576 custom_user_dir = g_strdup(dir); |
5653692dcf79
Use dynamically allocated strings for the user_dir caching. Do we need to
Richard Laager <rlaager@wiktel.com>
parents:
18129
diff
changeset
|
2577 else |
5653692dcf79
Use dynamically allocated strings for the user_dir caching. Do we need to
Richard Laager <rlaager@wiktel.com>
parents:
18129
diff
changeset
|
2578 custom_user_dir = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2579 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2580 |
15822 | 2581 int purple_build_dir (const char *path, int mode) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2582 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2583 return g_mkdir_with_parents(path, mode); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2584 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2585 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2586 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2587 * This function is long and beautiful, like my--um, yeah. Anyway, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2588 * it includes lots of error checking so as we don't overwrite |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2589 * people's settings if there is a problem writing the new values. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2590 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2591 gboolean |
19408
cc36a5aac908
Fix some conversion warnings about using negative values with unsigned types. There are more, but these were easy fixes. You may think that I'm changing the API, but I'm really not - it was just wrong.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19262
diff
changeset
|
2592 purple_util_write_data_to_file(const char *filename, const char *data, gssize size) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2593 { |
15822 | 2594 const char *user_dir = purple_user_dir(); |
19498
7589b218f89a
- Add purple_util_write_data_to_file_absolute; glib's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19262
diff
changeset
|
2595 gchar *filename_full; |
7589b218f89a
- Add purple_util_write_data_to_file_absolute; glib's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19262
diff
changeset
|
2596 gboolean ret = FALSE; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2597 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2598 g_return_val_if_fail(user_dir != NULL, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2599 |
15822 | 2600 purple_debug_info("util", "Writing file %s to directory %s\n", |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2601 filename, user_dir); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2602 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2603 /* Ensure the user directory exists */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2604 if (!g_file_test(user_dir, G_FILE_TEST_IS_DIR)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2605 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2606 if (g_mkdir(user_dir, S_IRUSR | S_IWUSR | S_IXUSR) == -1) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2607 { |
15822 | 2608 purple_debug_error("util", "Error creating directory %s: %s\n", |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
21028
diff
changeset
|
2609 user_dir, g_strerror(errno)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2610 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2611 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2612 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2613 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2614 filename_full = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", user_dir, filename); |
19498
7589b218f89a
- Add purple_util_write_data_to_file_absolute; glib's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19262
diff
changeset
|
2615 |
20853
1a44d1a17784
purple_util_write_data_to_file_absolute() should take a signed argument for the size as -1 is used to indicate that the string is nul-delimited. This resolves CID 330.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20685
diff
changeset
|
2616 ret = purple_util_write_data_to_file_absolute(filename_full, data, size); |
19498
7589b218f89a
- Add purple_util_write_data_to_file_absolute; glib's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19262
diff
changeset
|
2617 |
7589b218f89a
- Add purple_util_write_data_to_file_absolute; glib's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19262
diff
changeset
|
2618 g_free(filename_full); |
7589b218f89a
- Add purple_util_write_data_to_file_absolute; glib's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19262
diff
changeset
|
2619 return ret; |
7589b218f89a
- Add purple_util_write_data_to_file_absolute; glib's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19262
diff
changeset
|
2620 } |
7589b218f89a
- Add purple_util_write_data_to_file_absolute; glib's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19262
diff
changeset
|
2621 |
7589b218f89a
- Add purple_util_write_data_to_file_absolute; glib's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19262
diff
changeset
|
2622 gboolean |
20853
1a44d1a17784
purple_util_write_data_to_file_absolute() should take a signed argument for the size as -1 is used to indicate that the string is nul-delimited. This resolves CID 330.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20685
diff
changeset
|
2623 purple_util_write_data_to_file_absolute(const char *filename_full, const char *data, gssize size) |
19498
7589b218f89a
- Add purple_util_write_data_to_file_absolute; glib's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19262
diff
changeset
|
2624 { |
7589b218f89a
- Add purple_util_write_data_to_file_absolute; glib's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19262
diff
changeset
|
2625 gchar *filename_temp; |
7589b218f89a
- Add purple_util_write_data_to_file_absolute; glib's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19262
diff
changeset
|
2626 FILE *file; |
7589b218f89a
- Add purple_util_write_data_to_file_absolute; glib's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19262
diff
changeset
|
2627 size_t real_size, byteswritten; |
7589b218f89a
- Add purple_util_write_data_to_file_absolute; glib's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19262
diff
changeset
|
2628 struct stat st; |
21172
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2629 #ifndef HAVE_FILENO |
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2630 int fd; |
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2631 #endif |
19498
7589b218f89a
- Add purple_util_write_data_to_file_absolute; glib's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19262
diff
changeset
|
2632 |
7589b218f89a
- Add purple_util_write_data_to_file_absolute; glib's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19262
diff
changeset
|
2633 purple_debug_info("util", "Writing file %s\n", |
7589b218f89a
- Add purple_util_write_data_to_file_absolute; glib's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19262
diff
changeset
|
2634 filename_full); |
7589b218f89a
- Add purple_util_write_data_to_file_absolute; glib's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19262
diff
changeset
|
2635 |
20917
aa420b502a6b
nosnilmot points out that this is a better way to ensure the size is valid.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20916
diff
changeset
|
2636 g_return_val_if_fail((size >= -1), FALSE); |
aa420b502a6b
nosnilmot points out that this is a better way to ensure the size is valid.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20916
diff
changeset
|
2637 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2638 filename_temp = g_strdup_printf("%s.save", filename_full); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2639 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2640 /* Remove an old temporary file, if one exists */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2641 if (g_file_test(filename_temp, G_FILE_TEST_EXISTS)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2642 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2643 if (g_unlink(filename_temp) == -1) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2644 { |
19498
7589b218f89a
- Add purple_util_write_data_to_file_absolute; glib's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19262
diff
changeset
|
2645 purple_debug_error("util", "Error removing old file " |
7589b218f89a
- Add purple_util_write_data_to_file_absolute; glib's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19262
diff
changeset
|
2646 "%s: %s\n", |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
21028
diff
changeset
|
2647 filename_temp, g_strerror(errno)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2648 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2649 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2650 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2651 /* Open file */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2652 file = g_fopen(filename_temp, "wb"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2653 if (file == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2654 { |
19498
7589b218f89a
- Add purple_util_write_data_to_file_absolute; glib's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19262
diff
changeset
|
2655 purple_debug_error("util", "Error opening file %s for " |
7589b218f89a
- Add purple_util_write_data_to_file_absolute; glib's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19262
diff
changeset
|
2656 "writing: %s\n", |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
21028
diff
changeset
|
2657 filename_temp, g_strerror(errno)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2658 g_free(filename_temp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2659 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2660 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2661 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2662 /* Write to file */ |
20917
aa420b502a6b
nosnilmot points out that this is a better way to ensure the size is valid.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20916
diff
changeset
|
2663 real_size = (size == -1) ? strlen(data) : (size_t) size; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2664 byteswritten = fwrite(data, 1, real_size, file); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2665 |
21172
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2666 #ifdef HAVE_FILENO |
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2667 /* Apparently XFS (and possibly other filesystems) do not |
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2668 * guarantee that file data is flushed before file metadata, |
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2669 * so this procedure is insufficient without some flushage. */ |
21177
abc909eeb580
jtb indirectly points out that we need a fflush() before the fsync(),
Ethan Blanton <elb@pidgin.im>
parents:
21172
diff
changeset
|
2670 if (fflush(file) < 0) { |
abc909eeb580
jtb indirectly points out that we need a fflush() before the fsync(),
Ethan Blanton <elb@pidgin.im>
parents:
21172
diff
changeset
|
2671 purple_debug_error("util", "Error flushing %s: %s\n", |
abc909eeb580
jtb indirectly points out that we need a fflush() before the fsync(),
Ethan Blanton <elb@pidgin.im>
parents:
21172
diff
changeset
|
2672 filename_temp, g_strerror(errno)); |
abc909eeb580
jtb indirectly points out that we need a fflush() before the fsync(),
Ethan Blanton <elb@pidgin.im>
parents:
21172
diff
changeset
|
2673 g_free(filename_temp); |
abc909eeb580
jtb indirectly points out that we need a fflush() before the fsync(),
Ethan Blanton <elb@pidgin.im>
parents:
21172
diff
changeset
|
2674 fclose(file); |
abc909eeb580
jtb indirectly points out that we need a fflush() before the fsync(),
Ethan Blanton <elb@pidgin.im>
parents:
21172
diff
changeset
|
2675 return FALSE; |
abc909eeb580
jtb indirectly points out that we need a fflush() before the fsync(),
Ethan Blanton <elb@pidgin.im>
parents:
21172
diff
changeset
|
2676 } |
21172
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2677 if (fsync(fileno(file)) < 0) { |
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2678 purple_debug_error("util", "Error syncing file contents for %s: %s\n", |
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2679 filename_temp, g_strerror(errno)); |
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2680 g_free(filename_temp); |
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2681 fclose(file); |
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2682 return FALSE; |
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2683 } |
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2684 #endif |
25924
584063555949
Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents:
25894
diff
changeset
|
2685 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2686 /* Close file */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2687 if (fclose(file) != 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2688 { |
15822 | 2689 purple_debug_error("util", "Error closing file %s: %s\n", |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
21028
diff
changeset
|
2690 filename_temp, g_strerror(errno)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2691 g_free(filename_temp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2692 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2693 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2694 |
21172
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2695 #ifndef HAVE_FILENO |
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2696 /* This is the same effect (we hope) as the HAVE_FILENO block |
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2697 * above, but for systems without fileno(). */ |
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2698 if ((fd = open(filename_temp, O_RDWR)) < 0) { |
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2699 purple_debug_error("util", "Error opening file %s for flush: %s\n", |
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2700 filename_temp, g_strerror(errno)); |
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2701 g_free(filename_temp); |
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2702 return FALSE; |
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2703 } |
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2704 if (fsync(fd) < 0) { |
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2705 purple_debug_error("util", "Error syncing %s: %s\n", |
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2706 filename_temp, g_strerror(errno)); |
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2707 g_free(filename_temp); |
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2708 close(fd); |
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2709 return FALSE; |
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2710 } |
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2711 if (close(fd) < 0) { |
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2712 purple_debug_error("util", "Error closing %s after sync: %s\n", |
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2713 filename_temp, g_strerror(errno)); |
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2714 g_free(filename_temp); |
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2715 return FALSE; |
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2716 } |
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2717 #endif |
33da7f2a30e4
Manually fflush() files written with purple_util_write_data_to_file,
Ethan Blanton <elb@pidgin.im>
parents:
21121
diff
changeset
|
2718 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2719 /* Ensure the file is the correct size */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2720 if (byteswritten != real_size) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2721 { |
19498
7589b218f89a
- Add purple_util_write_data_to_file_absolute; glib's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19262
diff
changeset
|
2722 purple_debug_error("util", "Error writing to file %s: Wrote %" |
7589b218f89a
- Add purple_util_write_data_to_file_absolute; glib's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19262
diff
changeset
|
2723 G_GSIZE_FORMAT " bytes " |
7589b218f89a
- Add purple_util_write_data_to_file_absolute; glib's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19262
diff
changeset
|
2724 "but should have written %" G_GSIZE_FORMAT |
7589b218f89a
- Add purple_util_write_data_to_file_absolute; glib's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19262
diff
changeset
|
2725 "; is your disk full?\n", |
7589b218f89a
- Add purple_util_write_data_to_file_absolute; glib's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19262
diff
changeset
|
2726 filename_temp, byteswritten, real_size); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2727 g_free(filename_temp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2728 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2729 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2730 /* Use stat to be absolutely sure. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2731 if ((g_stat(filename_temp, &st) == -1) || (st.st_size != real_size)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2732 { |
15822 | 2733 purple_debug_error("util", "Error writing data to file %s: " |
19498
7589b218f89a
- Add purple_util_write_data_to_file_absolute; glib's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19262
diff
changeset
|
2734 "Incomplete file written; is your disk " |
7589b218f89a
- Add purple_util_write_data_to_file_absolute; glib's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19262
diff
changeset
|
2735 "full?\n", |
7589b218f89a
- Add purple_util_write_data_to_file_absolute; glib's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19262
diff
changeset
|
2736 filename_temp); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2737 g_free(filename_temp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2738 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2739 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2740 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2741 #ifndef _WIN32 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2742 /* Set file permissions */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2743 if (chmod(filename_temp, S_IRUSR | S_IWUSR) == -1) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2744 { |
15822 | 2745 purple_debug_error("util", "Error setting permissions of file %s: %s\n", |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
21028
diff
changeset
|
2746 filename_temp, g_strerror(errno)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2747 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2748 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2749 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2750 /* Rename to the REAL name */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2751 if (g_rename(filename_temp, filename_full) == -1) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2752 { |
15822 | 2753 purple_debug_error("util", "Error renaming %s to %s: %s\n", |
19498
7589b218f89a
- Add purple_util_write_data_to_file_absolute; glib's
William Ehlhardt <williamehlhardt@gmail.com>
parents:
19262
diff
changeset
|
2754 filename_temp, filename_full, |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
21028
diff
changeset
|
2755 g_strerror(errno)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2756 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2757 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2758 g_free(filename_temp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2759 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2760 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2761 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2762 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2763 xmlnode * |
15822 | 2764 purple_util_read_xml_from_file(const char *filename, const char *description) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2765 { |
25086
774ef2a2e7f8
added a more generic function to read xml files (and made the util version into a wrapper) so it can be used by the
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23142
diff
changeset
|
2766 return xmlnode_from_file(purple_user_dir(), filename, description, "util"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2767 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2768 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2769 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2770 * Like mkstemp() but returns a file pointer, uses a pre-set template, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2771 * uses the semantics of tempnam() for the directory to use and allocates |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2772 * the space for the filepath. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2773 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2774 * Caller is responsible for closing the file and removing it when done, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2775 * as well as freeing the space pointed-to by "path" with g_free(). |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2776 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2777 * Returns NULL on failure and cleans up after itself if so. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2778 */ |
15822 | 2779 static const char *purple_mkstemp_templ = {"purpleXXXXXX"}; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2780 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2781 FILE * |
15822 | 2782 purple_mkstemp(char **fpath, gboolean binary) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2783 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2784 const gchar *tmpdir; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2785 int fd; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2786 FILE *fp = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2787 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2788 g_return_val_if_fail(fpath != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2789 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2790 if((tmpdir = (gchar*)g_get_tmp_dir()) != NULL) { |
15822 | 2791 if((*fpath = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", tmpdir, purple_mkstemp_templ)) != NULL) { |
16858
ec79e3ad09a9
_mktmp() sucks, so use g_mkstemp() instead. This probably doesn't have to be done differently for win32 and elsewhere, but I don't want to be changing things right now.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
16548
diff
changeset
|
2792 fd = g_mkstemp(*fpath); |
ec79e3ad09a9
_mktmp() sucks, so use g_mkstemp() instead. This probably doesn't have to be done differently for win32 and elsewhere, but I don't want to be changing things right now.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
16548
diff
changeset
|
2793 if(fd == -1) { |
15822 | 2794 purple_debug(PURPLE_DEBUG_ERROR, "purple_mkstemp", |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2795 "Couldn't make \"%s\", error: %d\n", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2796 *fpath, errno); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2797 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2798 if((fp = fdopen(fd, "r+")) == NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2799 close(fd); |
15822 | 2800 purple_debug(PURPLE_DEBUG_ERROR, "purple_mkstemp", |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2801 "Couldn't fdopen(), error: %d\n", errno); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2802 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2803 } |
16858
ec79e3ad09a9
_mktmp() sucks, so use g_mkstemp() instead. This probably doesn't have to be done differently for win32 and elsewhere, but I don't want to be changing things right now.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
16548
diff
changeset
|
2804 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2805 if(!fp) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2806 g_free(*fpath); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2807 *fpath = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2808 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2809 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2810 } else { |
15822 | 2811 purple_debug(PURPLE_DEBUG_ERROR, "purple_mkstemp", |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2812 "g_get_tmp_dir() failed!\n"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2813 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2814 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2815 return fp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2816 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2817 |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16368
diff
changeset
|
2818 const char * |
16487
b8b2e35ec7c6
Fix purple_util_get_image_extension()'s data param. to be correctly marked as constant.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
16475
diff
changeset
|
2819 purple_util_get_image_extension(gconstpointer data, size_t len) |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16368
diff
changeset
|
2820 { |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16368
diff
changeset
|
2821 g_return_val_if_fail(data != NULL, NULL); |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16368
diff
changeset
|
2822 g_return_val_if_fail(len > 0, NULL); |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16368
diff
changeset
|
2823 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16368
diff
changeset
|
2824 if (len >= 4) |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16368
diff
changeset
|
2825 { |
17491
0a4238600947
Fixed recognition of the extension of certain JPG files. The 4th character may be anything between e0 and ef; the first 3 should be sufficient for a magic number, though a more 'complete' solution would verify that (e0 <= data[3] <= ef). Also, added recognition of TIF files (magic number: MM or II). Refs #725, which gave examples of several JPGs with (data[3] == e1).
Evan Schoenberg <evan.s@dreskin.net>
parents:
17481
diff
changeset
|
2826 if (!strncmp((char *)data, "GIF8", 4)) |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16368
diff
changeset
|
2827 return "gif"; |
17491
0a4238600947
Fixed recognition of the extension of certain JPG files. The 4th character may be anything between e0 and ef; the first 3 should be sufficient for a magic number, though a more 'complete' solution would verify that (e0 <= data[3] <= ef). Also, added recognition of TIF files (magic number: MM or II). Refs #725, which gave examples of several JPGs with (data[3] == e1).
Evan Schoenberg <evan.s@dreskin.net>
parents:
17481
diff
changeset
|
2828 else if (!strncmp((char *)data, "\xff\xd8\xff", 3)) /* 4th may be e0 through ef */ |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16368
diff
changeset
|
2829 return "jpg"; |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16368
diff
changeset
|
2830 else if (!strncmp((char *)data, "\x89PNG", 4)) |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16368
diff
changeset
|
2831 return "png"; |
17491
0a4238600947
Fixed recognition of the extension of certain JPG files. The 4th character may be anything between e0 and ef; the first 3 should be sufficient for a magic number, though a more 'complete' solution would verify that (e0 <= data[3] <= ef). Also, added recognition of TIF files (magic number: MM or II). Refs #725, which gave examples of several JPGs with (data[3] == e1).
Evan Schoenberg <evan.s@dreskin.net>
parents:
17481
diff
changeset
|
2832 else if (!strncmp((char *)data, "MM", 2) || |
0a4238600947
Fixed recognition of the extension of certain JPG files. The 4th character may be anything between e0 and ef; the first 3 should be sufficient for a magic number, though a more 'complete' solution would verify that (e0 <= data[3] <= ef). Also, added recognition of TIF files (magic number: MM or II). Refs #725, which gave examples of several JPGs with (data[3] == e1).
Evan Schoenberg <evan.s@dreskin.net>
parents:
17481
diff
changeset
|
2833 !strncmp((char *)data, "II", 2)) |
0a4238600947
Fixed recognition of the extension of certain JPG files. The 4th character may be anything between e0 and ef; the first 3 should be sufficient for a magic number, though a more 'complete' solution would verify that (e0 <= data[3] <= ef). Also, added recognition of TIF files (magic number: MM or II). Refs #725, which gave examples of several JPGs with (data[3] == e1).
Evan Schoenberg <evan.s@dreskin.net>
parents:
17481
diff
changeset
|
2834 return "tif"; |
17492
647bfc2b2a7b
Where did ekse come from?
Richard Laager <rlaager@wiktel.com>
parents:
17491
diff
changeset
|
2835 else if (!strncmp((char *)data, "BM", 2)) |
17491
0a4238600947
Fixed recognition of the extension of certain JPG files. The 4th character may be anything between e0 and ef; the first 3 should be sufficient for a magic number, though a more 'complete' solution would verify that (e0 <= data[3] <= ef). Also, added recognition of TIF files (magic number: MM or II). Refs #725, which gave examples of several JPGs with (data[3] == e1).
Evan Schoenberg <evan.s@dreskin.net>
parents:
17481
diff
changeset
|
2836 return "bmp"; |
16375
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16368
diff
changeset
|
2837 } |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16368
diff
changeset
|
2838 |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16368
diff
changeset
|
2839 return "icon"; |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16368
diff
changeset
|
2840 } |
391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents:
16368
diff
changeset
|
2841 |
26181
00c659e55902
Add a note that this function could potentially be faster.
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2842 /* |
27404
52298a298260
Update this comment. We talked about using CRC32 on the devel list
Mark Doliner <mark@kingant.net>
parents:
27393
diff
changeset
|
2843 * We thought about using non-cryptographic hashes like CRC32 here. |
52298a298260
Update this comment. We talked about using CRC32 on the devel list
Mark Doliner <mark@kingant.net>
parents:
27393
diff
changeset
|
2844 * They would be faster, but we think using something more secure is |
52298a298260
Update this comment. We talked about using CRC32 on the devel list
Mark Doliner <mark@kingant.net>
parents:
27393
diff
changeset
|
2845 * important, so that it is more difficult for someone to maliciously |
52298a298260
Update this comment. We talked about using CRC32 on the devel list
Mark Doliner <mark@kingant.net>
parents:
27393
diff
changeset
|
2846 * replace one buddy's icon with something else. |
26181
00c659e55902
Add a note that this function could potentially be faster.
Mark Doliner <mark@kingant.net>
parents:
25924
diff
changeset
|
2847 */ |
18039
c588a4a9d287
A patch from David Grohmann (dave1g) to log embedded images.
Richard Laager <rlaager@wiktel.com>
parents:
17765
diff
changeset
|
2848 char * |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villase«Ðo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22191
diff
changeset
|
2849 purple_util_get_image_checksum(gconstpointer image_data, size_t image_len) |
18039
c588a4a9d287
A patch from David Grohmann (dave1g) to log embedded images.
Richard Laager <rlaager@wiktel.com>
parents:
17765
diff
changeset
|
2850 { |
c588a4a9d287
A patch from David Grohmann (dave1g) to log embedded images.
Richard Laager <rlaager@wiktel.com>
parents:
17765
diff
changeset
|
2851 PurpleCipherContext *context; |
c588a4a9d287
A patch from David Grohmann (dave1g) to log embedded images.
Richard Laager <rlaager@wiktel.com>
parents:
17765
diff
changeset
|
2852 gchar digest[41]; |
c588a4a9d287
A patch from David Grohmann (dave1g) to log embedded images.
Richard Laager <rlaager@wiktel.com>
parents:
17765
diff
changeset
|
2853 |
c588a4a9d287
A patch from David Grohmann (dave1g) to log embedded images.
Richard Laager <rlaager@wiktel.com>
parents:
17765
diff
changeset
|
2854 context = purple_cipher_context_new_by_name("sha1", NULL); |
c588a4a9d287
A patch from David Grohmann (dave1g) to log embedded images.
Richard Laager <rlaager@wiktel.com>
parents:
17765
diff
changeset
|
2855 if (context == NULL) |
c588a4a9d287
A patch from David Grohmann (dave1g) to log embedded images.
Richard Laager <rlaager@wiktel.com>
parents:
17765
diff
changeset
|
2856 { |
c588a4a9d287
A patch from David Grohmann (dave1g) to log embedded images.
Richard Laager <rlaager@wiktel.com>
parents:
17765
diff
changeset
|
2857 purple_debug_error("util", "Could not find sha1 cipher\n"); |
c588a4a9d287
A patch from David Grohmann (dave1g) to log embedded images.
Richard Laager <rlaager@wiktel.com>
parents:
17765
diff
changeset
|
2858 g_return_val_if_reached(NULL); |
c588a4a9d287
A patch from David Grohmann (dave1g) to log embedded images.
Richard Laager <rlaager@wiktel.com>
parents:
17765
diff
changeset
|
2859 } |
c588a4a9d287
A patch from David Grohmann (dave1g) to log embedded images.
Richard Laager <rlaager@wiktel.com>
parents:
17765
diff
changeset
|
2860 |
c588a4a9d287
A patch from David Grohmann (dave1g) to log embedded images.
Richard Laager <rlaager@wiktel.com>
parents:
17765
diff
changeset
|
2861 /* Hash the image data */ |
c588a4a9d287
A patch from David Grohmann (dave1g) to log embedded images.
Richard Laager <rlaager@wiktel.com>
parents:
17765
diff
changeset
|
2862 purple_cipher_context_append(context, image_data, image_len); |
c588a4a9d287
A patch from David Grohmann (dave1g) to log embedded images.
Richard Laager <rlaager@wiktel.com>
parents:
17765
diff
changeset
|
2863 if (!purple_cipher_context_digest_to_str(context, sizeof(digest), digest, NULL)) |
c588a4a9d287
A patch from David Grohmann (dave1g) to log embedded images.
Richard Laager <rlaager@wiktel.com>
parents:
17765
diff
changeset
|
2864 { |
c588a4a9d287
A patch from David Grohmann (dave1g) to log embedded images.
Richard Laager <rlaager@wiktel.com>
parents:
17765
diff
changeset
|
2865 purple_debug_error("util", "Failed to get SHA-1 digest.\n"); |
c588a4a9d287
A patch from David Grohmann (dave1g) to log embedded images.
Richard Laager <rlaager@wiktel.com>
parents:
17765
diff
changeset
|
2866 g_return_val_if_reached(NULL); |
c588a4a9d287
A patch from David Grohmann (dave1g) to log embedded images.
Richard Laager <rlaager@wiktel.com>
parents:
17765
diff
changeset
|
2867 } |
c588a4a9d287
A patch from David Grohmann (dave1g) to log embedded images.
Richard Laager <rlaager@wiktel.com>
parents:
17765
diff
changeset
|
2868 purple_cipher_context_destroy(context); |
c588a4a9d287
A patch from David Grohmann (dave1g) to log embedded images.
Richard Laager <rlaager@wiktel.com>
parents:
17765
diff
changeset
|
2869 |
22311
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villase«Ðo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22191
diff
changeset
|
2870 return g_strdup(digest); |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villase«Ðo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22191
diff
changeset
|
2871 } |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villase«Ðo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22191
diff
changeset
|
2872 |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villase«Ðo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22191
diff
changeset
|
2873 char * |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villase«Ðo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22191
diff
changeset
|
2874 purple_util_get_image_filename(gconstpointer image_data, size_t image_len) |
02eda4bd2b22
Apply the custom smiley patches from #1187, from Jorge Villase«Ðo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22191
diff
changeset
|
2875 { |
18039
c588a4a9d287
A patch from David Grohmann (dave1g) to log embedded images.
Richard Laager <rlaager@wiktel.com>
parents:
17765
diff
changeset
|
2876 /* Return the filename */ |
22312 | 2877 char *checksum = purple_util_get_image_checksum(image_data, image_len); |
2878 char *filename = g_strdup_printf("%s.%s", checksum, | |
18039
c588a4a9d287
A patch from David Grohmann (dave1g) to log embedded images.
Richard Laager <rlaager@wiktel.com>
parents:
17765
diff
changeset
|
2879 purple_util_get_image_extension(image_data, image_len)); |
22312 | 2880 g_free(checksum); |
2881 return filename; | |
18039
c588a4a9d287
A patch from David Grohmann (dave1g) to log embedded images.
Richard Laager <rlaager@wiktel.com>
parents:
17765
diff
changeset
|
2882 } |
c588a4a9d287
A patch from David Grohmann (dave1g) to log embedded images.
Richard Laager <rlaager@wiktel.com>
parents:
17765
diff
changeset
|
2883 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2884 gboolean |
15822 | 2885 purple_program_is_valid(const char *program) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2886 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2887 GError *error = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2888 char **argv; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2889 gchar *progname; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2890 gboolean is_valid = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2891 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2892 g_return_val_if_fail(program != NULL, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2893 g_return_val_if_fail(*program != '\0', FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2894 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2895 if (!g_shell_parse_argv(program, NULL, &argv, &error)) { |
15822 | 2896 purple_debug(PURPLE_DEBUG_ERROR, "program_is_valid", |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2897 "Could not parse program '%s': %s\n", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2898 program, error->message); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2899 g_error_free(error); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2900 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2901 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2902 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2903 if (argv == NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2904 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2905 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2906 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2907 progname = g_find_program_in_path(argv[0]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2908 is_valid = (progname != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2909 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2910 g_strfreev(argv); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2911 g_free(progname); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2912 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2913 return is_valid; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2914 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2915 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2916 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2917 gboolean |
15822 | 2918 purple_running_gnome(void) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2919 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2920 #ifndef _WIN32 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2921 gchar *tmp = g_find_program_in_path("gnome-open"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2922 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2923 if (tmp == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2924 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2925 g_free(tmp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2926 |
21580
07588cb48434
Allow empty GNOME_DESKTOP_SESSION_ID to "fail" the running_gnome check as
Stu Tomlinson <stu@nosnilmot.com>
parents:
21299
diff
changeset
|
2927 tmp = (gchar *)g_getenv("GNOME_DESKTOP_SESSION_ID"); |
07588cb48434
Allow empty GNOME_DESKTOP_SESSION_ID to "fail" the running_gnome check as
Stu Tomlinson <stu@nosnilmot.com>
parents:
21299
diff
changeset
|
2928 |
07588cb48434
Allow empty GNOME_DESKTOP_SESSION_ID to "fail" the running_gnome check as
Stu Tomlinson <stu@nosnilmot.com>
parents:
21299
diff
changeset
|
2929 return ((tmp != NULL) && (*tmp != '\0')); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2930 #else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2931 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2932 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2933 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2934 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2935 gboolean |
15822 | 2936 purple_running_kde(void) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2937 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2938 #ifndef _WIN32 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2939 gchar *tmp = g_find_program_in_path("kfmclient"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2940 const char *session; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2941 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2942 if (tmp == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2943 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2944 g_free(tmp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2945 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2946 session = g_getenv("KDE_FULL_SESSION"); |
25894
a6e3cb32cdd2
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <paul@darkrain42.org>
parents:
25890
diff
changeset
|
2947 if (purple_strequal(session, "true")) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2948 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2949 |
15822 | 2950 /* If you run Purple from Konsole under !KDE, this will provide a |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2951 * a false positive. Since we do the GNOME checks first, this is |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2952 * only a problem if you're running something !(KDE || GNOME) and |
15822 | 2953 * you run Purple from Konsole. This really shouldn't be a problem. */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2954 return ((g_getenv("KDEDIR") != NULL) || g_getenv("KDEDIRS") != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2955 #else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2956 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2957 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2958 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2959 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2960 gboolean |
15822 | 2961 purple_running_osx(void) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2962 { |
16487
b8b2e35ec7c6
Fix purple_util_get_image_extension()'s data param. to be correctly marked as constant.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
16475
diff
changeset
|
2963 #if defined(__APPLE__) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2964 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2965 #else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2966 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2967 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2968 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2969 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2970 char * |
15822 | 2971 purple_fd_get_ip(int fd) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2972 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2973 struct sockaddr addr; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2974 socklen_t namelen = sizeof(addr); |
27448
60d128c6413a
No functional change, but my gcc is bitching at me. Fixes this warning,
Stu Tomlinson <stu@nosnilmot.com>
parents:
27445
diff
changeset
|
2975 struct in_addr in; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2976 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2977 g_return_val_if_fail(fd != 0, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2978 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2979 if (getsockname(fd, &addr, &namelen)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2980 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2981 |
27448
60d128c6413a
No functional change, but my gcc is bitching at me. Fixes this warning,
Stu Tomlinson <stu@nosnilmot.com>
parents:
27445
diff
changeset
|
2982 in = ((struct sockaddr_in *)&addr)->sin_addr; |
60d128c6413a
No functional change, but my gcc is bitching at me. Fixes this warning,
Stu Tomlinson <stu@nosnilmot.com>
parents:
27445
diff
changeset
|
2983 return g_strdup(inet_ntoa(in)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2984 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2985 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2986 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2987 /************************************************************************** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2988 * String Functions |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2989 **************************************************************************/ |
25894
a6e3cb32cdd2
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <paul@darkrain42.org>
parents:
25890
diff
changeset
|
2990 gboolean |
a6e3cb32cdd2
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <paul@darkrain42.org>
parents:
25890
diff
changeset
|
2991 purple_strequal(const gchar *left, const gchar *right) |
a6e3cb32cdd2
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <paul@darkrain42.org>
parents:
25890
diff
changeset
|
2992 { |
a6e3cb32cdd2
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <paul@darkrain42.org>
parents:
25890
diff
changeset
|
2993 #if GLIB_CHECK_VERSION(2,16,0) |
a6e3cb32cdd2
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <paul@darkrain42.org>
parents:
25890
diff
changeset
|
2994 return (g_strcmp0(left, right) == 0); |
a6e3cb32cdd2
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <paul@darkrain42.org>
parents:
25890
diff
changeset
|
2995 #else |
a6e3cb32cdd2
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <paul@darkrain42.org>
parents:
25890
diff
changeset
|
2996 return ((left == NULL && right == NULL) || |
a6e3cb32cdd2
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <paul@darkrain42.org>
parents:
25890
diff
changeset
|
2997 (left != NULL && right != NULL && strcmp(left, right) == 0)); |
a6e3cb32cdd2
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <paul@darkrain42.org>
parents:
25890
diff
changeset
|
2998 #endif |
a6e3cb32cdd2
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <paul@darkrain42.org>
parents:
25890
diff
changeset
|
2999 } |
a6e3cb32cdd2
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <paul@darkrain42.org>
parents:
25890
diff
changeset
|
3000 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3001 const char * |
15822 | 3002 purple_normalize(const PurpleAccount *account, const char *str) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3003 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3004 const char *ret = NULL; |
16548
0cd684e34403
sadrul fixed the next but not last crash
Luke Schierer <lschiere@pidgin.im>
parents:
16487
diff
changeset
|
3005 static char buf[BUF_LEN]; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3006 |
28123
5901b1dd8d07
As darkrain pointed out this isnt caused by that certain bug in glib. My mistake. Recomment, and change how I test str to be NULL and return NULL.
Sulabh Mahajan <sulabh@soc.pidgin.im>
parents:
28120
diff
changeset
|
3007 /* This should prevent a crash if purple_normalize gets called with NULL str, see #10115 */ |
5901b1dd8d07
As darkrain pointed out this isnt caused by that certain bug in glib. My mistake. Recomment, and change how I test str to be NULL and return NULL.
Sulabh Mahajan <sulabh@soc.pidgin.im>
parents:
28120
diff
changeset
|
3008 g_return_val_if_fail(str != NULL, ""); |
28120
862467b37ee6
g_utf8_normalize() for glib ver < 2.15.0 causes a crash when an invalid utf8 string is passed to it (http://bugzilla.gnome.org/show_bug.cgi?id=501997).
Sulabh Mahajan <sulabh@soc.pidgin.im>
parents:
28108
diff
changeset
|
3009 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3010 if (account != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3011 { |
15822 | 3012 PurplePlugin *prpl = purple_find_prpl(purple_account_get_protocol_id(account)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3013 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3014 if (prpl != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3015 { |
15822 | 3016 PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3017 |
28285
dab0d17dc6c1
Minor cleanup. gc->prpl is guarranteed to be a PurplePlugin with
Mark Doliner <mark@kingant.net>
parents:
28255
diff
changeset
|
3018 if (prpl_info->normalize) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3019 ret = prpl_info->normalize(account, str); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3020 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3021 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3022 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3023 if (ret == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3024 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3025 char *tmp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3026 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3027 tmp = g_utf8_normalize(str, -1, G_NORMALIZE_DEFAULT); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3028 g_snprintf(buf, sizeof(buf), "%s", tmp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3029 g_free(tmp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3030 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3031 ret = buf; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3032 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3033 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3034 return ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3035 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3036 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3037 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3038 * You probably don't want to call this directly, it is |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3039 * mainly for use as a PRPL callback function. See the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3040 * comments in util.h. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3041 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3042 const char * |
15822 | 3043 purple_normalize_nocase(const PurpleAccount *account, const char *str) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3044 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3045 static char buf[BUF_LEN]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3046 char *tmp1, *tmp2; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3047 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3048 g_return_val_if_fail(str != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3049 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3050 tmp1 = g_utf8_strdown(str, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3051 tmp2 = g_utf8_normalize(tmp1, -1, G_NORMALIZE_DEFAULT); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3052 g_snprintf(buf, sizeof(buf), "%s", tmp2 ? tmp2 : ""); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3053 g_free(tmp2); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3054 g_free(tmp1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3055 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3056 return buf; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3057 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3058 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3059 gchar * |
15822 | 3060 purple_strdup_withhtml(const gchar *src) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3061 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3062 gulong destsize, i, j; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3063 gchar *dest; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3064 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3065 g_return_val_if_fail(src != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3066 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3067 /* New length is (length of src) + (number of \n's * 3) - (number of \r's) + 1 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3068 destsize = 1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3069 for (i = 0; src[i] != '\0'; i++) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3070 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3071 if (src[i] == '\n') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3072 destsize += 4; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3073 else if (src[i] != '\r') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3074 destsize++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3075 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3076 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3077 dest = g_malloc(destsize); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3078 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3079 /* Copy stuff, ignoring \r's, because they are dumb */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3080 for (i = 0, j = 0; src[i] != '\0'; i++) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3081 if (src[i] == '\n') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3082 strcpy(&dest[j], "<BR>"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3083 j += 4; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3084 } else if (src[i] != '\r') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3085 dest[j++] = src[i]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3086 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3087 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3088 dest[destsize-1] = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3089 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3090 return dest; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3091 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3092 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3093 gboolean |
15822 | 3094 purple_str_has_prefix(const char *s, const char *p) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3095 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3096 return g_str_has_prefix(s, p); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3097 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3098 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3099 gboolean |
15822 | 3100 purple_str_has_suffix(const char *s, const char *x) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3101 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3102 return g_str_has_suffix(s, x); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3103 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3104 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3105 char * |
15822 | 3106 purple_str_add_cr(const char *text) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3107 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3108 char *ret = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3109 int count = 0, j; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3110 guint i; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3111 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3112 g_return_val_if_fail(text != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3113 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3114 if (text[0] == '\n') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3115 count++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3116 for (i = 1; i < strlen(text); i++) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3117 if (text[i] == '\n' && text[i - 1] != '\r') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3118 count++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3119 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3120 if (count == 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3121 return g_strdup(text); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3122 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3123 ret = g_malloc0(strlen(text) + count + 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3124 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3125 i = 0; j = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3126 if (text[i] == '\n') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3127 ret[j++] = '\r'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3128 ret[j++] = text[i++]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3129 for (; i < strlen(text); i++) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3130 if (text[i] == '\n' && text[i - 1] != '\r') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3131 ret[j++] = '\r'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3132 ret[j++] = text[i]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3133 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3134 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3135 return ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3136 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3137 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3138 void |
15822 | 3139 purple_str_strip_char(char *text, char thechar) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3140 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3141 int i, j; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3142 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3143 g_return_if_fail(text != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3144 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3145 for (i = 0, j = 0; text[i]; i++) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3146 if (text[i] != thechar) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3147 text[j++] = text[i]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3148 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3149 text[j++] = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3150 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3151 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3152 void |
15822 | 3153 purple_util_chrreplace(char *string, char delimiter, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3154 char replacement) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3155 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3156 int i = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3157 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3158 g_return_if_fail(string != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3159 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3160 while (string[i] != '\0') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3161 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3162 if (string[i] == delimiter) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3163 string[i] = replacement; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3164 i++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3165 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3166 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3167 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3168 gchar * |
15822 | 3169 purple_strreplace(const char *string, const char *delimiter, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3170 const char *replacement) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3171 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3172 gchar **split; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3173 gchar *ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3174 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3175 g_return_val_if_fail(string != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3176 g_return_val_if_fail(delimiter != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3177 g_return_val_if_fail(replacement != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3178 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3179 split = g_strsplit(string, delimiter, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3180 ret = g_strjoinv(replacement, split); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3181 g_strfreev(split); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3182 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3183 return ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3184 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3185 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3186 gchar * |
15822 | 3187 purple_strcasereplace(const char *string, const char *delimiter, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3188 const char *replacement) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3189 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3190 gchar *ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3191 int length_del, length_rep, i, j; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3192 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3193 g_return_val_if_fail(string != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3194 g_return_val_if_fail(delimiter != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3195 g_return_val_if_fail(replacement != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3196 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3197 length_del = strlen(delimiter); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3198 length_rep = strlen(replacement); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3199 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3200 /* Count how many times the delimiter appears */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3201 i = 0; /* position in the source string */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3202 j = 0; /* number of occurrences of "delimiter" */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3203 while (string[i] != '\0') { |
18397
e122b631a657
Replace some strncasecmp() calls with g_ascii_strncasecmp() as part of the
Nick Hebner <hebnern@gmail.com>
parents:
18259
diff
changeset
|
3204 if (!g_ascii_strncasecmp(&string[i], delimiter, length_del)) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3205 i += length_del; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3206 j += length_rep; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3207 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3208 i++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3209 j++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3210 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3211 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3212 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3213 ret = g_malloc(j+1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3214 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3215 i = 0; /* position in the source string */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3216 j = 0; /* position in the destination string */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3217 while (string[i] != '\0') { |
18397
e122b631a657
Replace some strncasecmp() calls with g_ascii_strncasecmp() as part of the
Nick Hebner <hebnern@gmail.com>
parents:
18259
diff
changeset
|
3218 if (!g_ascii_strncasecmp(&string[i], delimiter, length_del)) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3219 strncpy(&ret[j], replacement, length_rep); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3220 i += length_del; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3221 j += length_rep; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3222 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3223 ret[j] = string[i]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3224 i++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3225 j++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3226 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3227 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3228 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3229 ret[j] = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3230 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3231 return ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3232 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3233 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3234 const char * |
15822 | 3235 purple_strcasestr(const char *haystack, const char *needle) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3236 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3237 size_t hlen, nlen; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3238 const char *tmp, *ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3239 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3240 g_return_val_if_fail(haystack != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3241 g_return_val_if_fail(needle != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3242 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3243 hlen = strlen(haystack); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3244 nlen = strlen(needle); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3245 tmp = haystack, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3246 ret = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3247 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3248 g_return_val_if_fail(hlen > 0, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3249 g_return_val_if_fail(nlen > 0, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3250 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3251 while (*tmp && !ret) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3252 if (!g_ascii_strncasecmp(needle, tmp, nlen)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3253 ret = tmp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3254 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3255 tmp++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3256 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3257 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3258 return ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3259 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3260 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3261 char * |
15822 | 3262 purple_str_size_to_units(size_t size) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3263 { |
21015
787b3897ba9f
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@hxbc.us>
parents:
21000
diff
changeset
|
3264 static const char * const size_str[] = { "bytes", "KiB", "MiB", "GiB" }; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3265 float size_mag; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3266 int size_index = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3267 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3268 if (size == -1) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3269 return g_strdup(_("Calculating...")); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3270 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3271 else if (size == 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3272 return g_strdup(_("Unknown.")); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3273 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3274 else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3275 size_mag = (float)size; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3276 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3277 while ((size_index < 3) && (size_mag > 1024)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3278 size_mag /= 1024; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3279 size_index++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3280 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3281 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3282 if (size_index == 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3283 return g_strdup_printf("%" G_GSIZE_FORMAT " %s", size, size_str[size_index]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3284 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3285 return g_strdup_printf("%.2f %s", size_mag, size_str[size_index]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3286 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3287 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3288 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3289 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3290 char * |
15822 | 3291 purple_str_seconds_to_string(guint secs) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3292 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3293 char *ret = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3294 guint days, hrs, mins; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3295 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3296 if (secs < 60) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3297 { |
16063
fa8aeab4ca5a
Hopefully prevent libpurple causing problems for 3rd party UIs if they also
Stu Tomlinson <stu@nosnilmot.com>
parents:
16017
diff
changeset
|
3298 return g_strdup_printf(dngettext(PACKAGE, "%d second", "%d seconds", secs), secs); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3299 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3300 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3301 days = secs / (60 * 60 * 24); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3302 secs = secs % (60 * 60 * 24); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3303 hrs = secs / (60 * 60); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3304 secs = secs % (60 * 60); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3305 mins = secs / 60; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3306 secs = secs % 60; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3307 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3308 if (days > 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3309 { |
16063
fa8aeab4ca5a
Hopefully prevent libpurple causing problems for 3rd party UIs if they also
Stu Tomlinson <stu@nosnilmot.com>
parents:
16017
diff
changeset
|
3310 ret = g_strdup_printf(dngettext(PACKAGE, "%d day", "%d days", days), days); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3311 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3312 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3313 if (hrs > 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3314 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3315 if (ret != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3316 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3317 char *tmp = g_strdup_printf( |
16063
fa8aeab4ca5a
Hopefully prevent libpurple causing problems for 3rd party UIs if they also
Stu Tomlinson <stu@nosnilmot.com>
parents:
16017
diff
changeset
|
3318 dngettext(PACKAGE, "%s, %d hour", "%s, %d hours", hrs), |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3319 ret, hrs); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3320 g_free(ret); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3321 ret = tmp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3322 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3323 else |
16063
fa8aeab4ca5a
Hopefully prevent libpurple causing problems for 3rd party UIs if they also
Stu Tomlinson <stu@nosnilmot.com>
parents:
16017
diff
changeset
|
3324 ret = g_strdup_printf(dngettext(PACKAGE, "%d hour", "%d hours", hrs), hrs); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3325 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3326 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3327 if (mins > 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3328 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3329 if (ret != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3330 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3331 char *tmp = g_strdup_printf( |
16063
fa8aeab4ca5a
Hopefully prevent libpurple causing problems for 3rd party UIs if they also
Stu Tomlinson <stu@nosnilmot.com>
parents:
16017
diff
changeset
|
3332 dngettext(PACKAGE, "%s, %d minute", "%s, %d minutes", mins), |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3333 ret, mins); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3334 g_free(ret); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3335 ret = tmp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3336 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3337 else |
16063
fa8aeab4ca5a
Hopefully prevent libpurple causing problems for 3rd party UIs if they also
Stu Tomlinson <stu@nosnilmot.com>
parents:
16017
diff
changeset
|
3338 ret = g_strdup_printf(dngettext(PACKAGE, "%d minute", "%d minutes", mins), mins); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3339 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3340 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3341 return ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3342 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3343 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3344 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3345 char * |
15822 | 3346 purple_str_binary_to_ascii(const unsigned char *binary, guint len) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3347 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3348 GString *ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3349 guint i; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3350 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3351 g_return_val_if_fail(len > 0, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3352 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3353 ret = g_string_sized_new(len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3354 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3355 for (i = 0; i < len; i++) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3356 if (binary[i] < 32 || binary[i] > 126) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3357 g_string_append_printf(ret, "\\x%02hhx", binary[i]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3358 else if (binary[i] == '\\') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3359 g_string_append(ret, "\\\\"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3360 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3361 g_string_append_c(ret, binary[i]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3362 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3363 return g_string_free(ret, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3364 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3365 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3366 /************************************************************************** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3367 * URI/URL Functions |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3368 **************************************************************************/ |
15612
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3369 |
15822 | 3370 void purple_got_protocol_handler_uri(const char *uri) |
15612
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3371 { |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3372 char proto[11]; |
27860
da22b6d0151e
Add support for XMPP URIs on Windows. Closes #2326.
Paul Aurich <paul@darkrain42.org>
parents:
27643
diff
changeset
|
3373 char delimiter; |
15612
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3374 const char *tmp, *param_string; |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3375 char *cmd; |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3376 GHashTable *params = NULL; |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3377 int len; |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3378 if (!(tmp = strchr(uri, ':')) || tmp == uri) { |
15822 | 3379 purple_debug_error("util", "Malformed protocol handler message - missing protocol.\n"); |
15612
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3380 return; |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3381 } |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3382 |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3383 len = MIN(sizeof(proto) - 1, (tmp - uri)); |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3384 |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3385 strncpy(proto, uri, len); |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3386 proto[len] = '\0'; |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3387 |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3388 tmp++; |
27860
da22b6d0151e
Add support for XMPP URIs on Windows. Closes #2326.
Paul Aurich <paul@darkrain42.org>
parents:
27643
diff
changeset
|
3389 |
da22b6d0151e
Add support for XMPP URIs on Windows. Closes #2326.
Paul Aurich <paul@darkrain42.org>
parents:
27643
diff
changeset
|
3390 if (g_str_equal(proto, "xmpp")) |
da22b6d0151e
Add support for XMPP URIs on Windows. Closes #2326.
Paul Aurich <paul@darkrain42.org>
parents:
27643
diff
changeset
|
3391 delimiter = ';'; |
da22b6d0151e
Add support for XMPP URIs on Windows. Closes #2326.
Paul Aurich <paul@darkrain42.org>
parents:
27643
diff
changeset
|
3392 else |
da22b6d0151e
Add support for XMPP URIs on Windows. Closes #2326.
Paul Aurich <paul@darkrain42.org>
parents:
27643
diff
changeset
|
3393 delimiter = '&'; |
da22b6d0151e
Add support for XMPP URIs on Windows. Closes #2326.
Paul Aurich <paul@darkrain42.org>
parents:
27643
diff
changeset
|
3394 |
da22b6d0151e
Add support for XMPP URIs on Windows. Closes #2326.
Paul Aurich <paul@darkrain42.org>
parents:
27643
diff
changeset
|
3395 purple_debug_info("util", "Processing message '%s' for protocol '%s' using delimiter '%c'.\n", tmp, proto, delimiter); |
15612
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3396 |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3397 if ((param_string = strchr(tmp, '?'))) { |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3398 const char *keyend = NULL, *pairstart; |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3399 char *key, *value = NULL; |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3400 |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3401 cmd = g_strndup(tmp, (param_string - tmp)); |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3402 param_string++; |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3403 |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3404 params = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3405 pairstart = tmp = param_string; |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3406 |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3407 while (*tmp || *pairstart) { |
27860
da22b6d0151e
Add support for XMPP URIs on Windows. Closes #2326.
Paul Aurich <paul@darkrain42.org>
parents:
27643
diff
changeset
|
3408 if (*tmp == delimiter || !(*tmp)) { |
15612
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3409 /* If there is no explicit value */ |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3410 if (keyend == NULL) |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3411 keyend = tmp; |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3412 |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3413 if (keyend && keyend != pairstart) { |
17037
cc9242ce1435
Patch #756 from EvilSporkMan. Use Datallah's url handling for Dbus
Sean Egan <seanegan@gmail.com>
parents:
17035
diff
changeset
|
3414 char *p; |
15612
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3415 key = g_strndup(pairstart, (keyend - pairstart)); |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3416 /* If there is an explicit value */ |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3417 if (keyend != tmp && keyend != (tmp - 1)) |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3418 value = g_strndup(keyend + 1, (tmp - keyend - 1)); |
17037
cc9242ce1435
Patch #756 from EvilSporkMan. Use Datallah's url handling for Dbus
Sean Egan <seanegan@gmail.com>
parents:
17035
diff
changeset
|
3419 for (p = key; *p; ++p) |
cc9242ce1435
Patch #756 from EvilSporkMan. Use Datallah's url handling for Dbus
Sean Egan <seanegan@gmail.com>
parents:
17035
diff
changeset
|
3420 *p = g_ascii_tolower(*p); |
15612
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3421 g_hash_table_insert(params, key, value); |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3422 } |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3423 keyend = value = NULL; |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3424 pairstart = (*tmp) ? tmp + 1 : tmp; |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3425 } else if (*tmp == '=') |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3426 keyend = tmp; |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3427 |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3428 if (*tmp) |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3429 tmp++; |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3430 } |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3431 } else |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3432 cmd = g_strdup(tmp); |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3433 |
15822 | 3434 purple_signal_emit_return_1(purple_get_core(), "uri-handler", proto, cmd, params); |
15612
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3435 |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3436 g_free(cmd); |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3437 if (params) |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3438 g_hash_table_destroy(params); |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3439 } |
b0471b2a1de9
Core support for external protocol URIs. The actual handling of the URIs will be in the prpls and other plugins. This commit only includes the win32 method of actually passing in a URI - the dbus implementation still needs to be written.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15420
diff
changeset
|
3440 |
17450
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3441 /* |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3442 * TODO: Should probably add a "gboolean *ret_ishttps" parameter that |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3443 * is set to TRUE if this URL is https, otherwise it is set to |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3444 * FALSE. But that change will break the API. |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3445 * |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3446 * This is important for Yahoo! web messenger login. They now |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3447 * force https login, and if you access the web messenger login |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3448 * page via http then it redirects you to the https version, but |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3449 * purple_util_fetch_url() ignores the "https" and attempts to |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3450 * fetch the URL via http again, which gets redirected again. |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3451 */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3452 gboolean |
15822 | 3453 purple_url_parse(const char *url, char **ret_host, int *ret_port, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3454 char **ret_path, char **ret_user, char **ret_passwd) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3455 { |
24592
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3456 gboolean is_https = FALSE; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3457 char scan_info[255]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3458 char port_str[6]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3459 int f; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3460 const char *at, *slash; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3461 const char *turl; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3462 char host[256], path[256], user[256], passwd[256]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3463 int port = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3464 /* hyphen at end includes it in control set */ |
21015
787b3897ba9f
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@hxbc.us>
parents:
21000
diff
changeset
|
3465 static const char addr_ctrl[] = "A-Za-z0-9.-"; |
787b3897ba9f
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@hxbc.us>
parents:
21000
diff
changeset
|
3466 static const char port_ctrl[] = "0-9"; |
787b3897ba9f
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@hxbc.us>
parents:
21000
diff
changeset
|
3467 static const char page_ctrl[] = "A-Za-z0-9.~_/:*!@&%%?=+^-"; |
787b3897ba9f
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@hxbc.us>
parents:
21000
diff
changeset
|
3468 static const char user_ctrl[] = "A-Za-z0-9.~_/*!&%%?=+^-"; |
787b3897ba9f
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@hxbc.us>
parents:
21000
diff
changeset
|
3469 static const char passwd_ctrl[] = "A-Za-z0-9.~_/*!&%%?=+^-"; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3470 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3471 g_return_val_if_fail(url != NULL, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3472 |
17450
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3473 if ((turl = purple_strcasestr(url, "http://")) != NULL) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3474 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3475 turl += 7; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3476 url = turl; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3477 } |
17450
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3478 else if ((turl = purple_strcasestr(url, "https://")) != NULL) |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3479 { |
24592
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3480 is_https = TRUE; |
17450
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3481 turl += 8; |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3482 url = turl; |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3483 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3484 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3485 /* parse out authentication information if supplied */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3486 /* Only care about @ char BEFORE the first / */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3487 at = strchr(url, '@'); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3488 slash = strchr(url, '/'); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3489 if ((at != NULL) && |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3490 (((slash != NULL) && (strlen(at) > strlen(slash))) || |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3491 (slash == NULL))) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3492 g_snprintf(scan_info, sizeof(scan_info), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3493 "%%255[%s]:%%255[%s]^@", user_ctrl, passwd_ctrl); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3494 f = sscanf(url, scan_info, user, passwd); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3495 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3496 if (f ==1 ) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3497 /* No passwd, possibly just username supplied */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3498 g_snprintf(scan_info, sizeof(scan_info), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3499 "%%255[%s]^@", user_ctrl); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3500 f = sscanf(url, scan_info, user); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3501 *passwd = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3502 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3503 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3504 url = at+1; /* move pointer after the @ char */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3505 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3506 *user = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3507 *passwd = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3508 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3509 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3510 g_snprintf(scan_info, sizeof(scan_info), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3511 "%%255[%s]:%%5[%s]/%%255[%s]", addr_ctrl, port_ctrl, page_ctrl); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3512 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3513 f = sscanf(url, scan_info, host, port_str, path); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3514 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3515 if (f == 1) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3516 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3517 g_snprintf(scan_info, sizeof(scan_info), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3518 "%%255[%s]/%%255[%s]", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3519 addr_ctrl, page_ctrl); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3520 f = sscanf(url, scan_info, host, path); |
24592
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3521 /* Use the default port */ |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3522 if (is_https) |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3523 g_snprintf(port_str, sizeof(port_str), "443"); |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3524 else |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3525 g_snprintf(port_str, sizeof(port_str), "80"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3526 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3527 |
23982
7fbc99a1481d
purple_url_parse() now gracefully handles a url which is wholly invalid.
Evan Schoenberg <evan.s@dreskin.net>
parents:
23975
diff
changeset
|
3528 if (f == 0) |
7fbc99a1481d
purple_url_parse() now gracefully handles a url which is wholly invalid.
Evan Schoenberg <evan.s@dreskin.net>
parents:
23975
diff
changeset
|
3529 *host = '\0'; |
7fbc99a1481d
purple_url_parse() now gracefully handles a url which is wholly invalid.
Evan Schoenberg <evan.s@dreskin.net>
parents:
23975
diff
changeset
|
3530 |
7fbc99a1481d
purple_url_parse() now gracefully handles a url which is wholly invalid.
Evan Schoenberg <evan.s@dreskin.net>
parents:
23975
diff
changeset
|
3531 if (f <= 1) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3532 *path = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3533 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3534 sscanf(port_str, "%d", &port); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3535 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3536 if (ret_host != NULL) *ret_host = g_strdup(host); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3537 if (ret_port != NULL) *ret_port = port; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3538 if (ret_path != NULL) *ret_path = g_strdup(path); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3539 if (ret_user != NULL) *ret_user = g_strdup(user); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3540 if (ret_passwd != NULL) *ret_passwd = g_strdup(passwd); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3541 |
23983
58e3b422e595
Return FALSE from purple_url_parse() if a host could not be determined
Evan Schoenberg <evan.s@dreskin.net>
parents:
23982
diff
changeset
|
3542 return ((*host != '\0') ? TRUE : FALSE); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3543 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3544 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3545 /** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3546 * The arguments to this function are similar to printf. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3547 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3548 static void |
15822 | 3549 purple_util_fetch_url_error(PurpleUtilFetchUrlData *gfud, const char *format, ...) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3550 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3551 gchar *error_message; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3552 va_list args; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3553 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3554 va_start(args, format); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3555 error_message = g_strdup_vprintf(format, args); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3556 va_end(args); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3557 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3558 gfud->callback(gfud, gfud->user_data, NULL, 0, error_message); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3559 g_free(error_message); |
15822 | 3560 purple_util_fetch_url_cancel(gfud); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3561 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3562 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3563 static void url_fetch_connect_cb(gpointer url_data, gint source, const gchar *error_message); |
24592
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3564 static void ssl_url_fetch_connect_cb(gpointer data, PurpleSslConnection *ssl_connection, PurpleInputCondition cond); |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3565 static void ssl_url_fetch_error_cb(PurpleSslConnection *ssl_connection, PurpleSslErrorType error, gpointer data); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3566 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3567 static gboolean |
23388 | 3568 parse_redirect(const char *data, size_t data_len, |
15822 | 3569 PurpleUtilFetchUrlData *gfud) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3570 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3571 gchar *s; |
17450
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3572 gchar *new_url, *temp_url, *end; |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3573 gboolean full; |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3574 int len; |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3575 |
20961
4a8366502f01
When checking for redirects in purple_util_fetch_url(), look for
Mark Doliner <mark@kingant.net>
parents:
20917
diff
changeset
|
3576 if ((s = g_strstr_len(data, data_len, "\nLocation: ")) == NULL) |
17450
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3577 /* We're not being redirected */ |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3578 return FALSE; |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3579 |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3580 s += strlen("Location: "); |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3581 end = strchr(s, '\r'); |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3582 |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3583 /* Just in case :) */ |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3584 if (end == NULL) |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3585 end = strchr(s, '\n'); |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3586 |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3587 if (end == NULL) |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3588 return FALSE; |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3589 |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3590 len = end - s; |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3591 |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3592 new_url = g_malloc(len + 1); |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3593 strncpy(new_url, s, len); |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3594 new_url[len] = '\0'; |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3595 |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3596 full = gfud->full; |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3597 |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3598 if (*new_url == '/' || g_strstr_len(new_url, len, "://") == NULL) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3599 { |
17450
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3600 temp_url = new_url; |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3601 |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3602 new_url = g_strdup_printf("%s:%d%s", gfud->website.address, |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3603 gfud->website.port, temp_url); |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3604 |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3605 g_free(temp_url); |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3606 |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3607 full = FALSE; |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3608 } |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3609 |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3610 purple_debug_info("util", "Redirecting to %s\n", new_url); |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3611 |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3612 gfud->num_times_redirected++; |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3613 if (gfud->num_times_redirected >= 5) |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3614 { |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3615 purple_util_fetch_url_error(gfud, |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3616 _("Could not open %s: Redirected too many times"), |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3617 gfud->url); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3618 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3619 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3620 |
17450
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3621 /* |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3622 * Try again, with this new location. This code is somewhat |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3623 * ugly, but we need to reuse the gfud because whoever called |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3624 * us is holding a reference to it. |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3625 */ |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3626 g_free(gfud->url); |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3627 gfud->url = new_url; |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3628 gfud->full = full; |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3629 g_free(gfud->request); |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3630 gfud->request = NULL; |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3631 |
24592
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3632 if (gfud->is_ssl) { |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3633 gfud->is_ssl = FALSE; |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3634 purple_ssl_close(gfud->ssl_connection); |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3635 gfud->ssl_connection = NULL; |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3636 } else { |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3637 purple_input_remove(gfud->inpa); |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3638 gfud->inpa = 0; |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3639 close(gfud->fd); |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3640 gfud->fd = -1; |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3641 } |
17450
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3642 gfud->request_written = 0; |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3643 gfud->len = 0; |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3644 gfud->data_len = 0; |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3645 |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3646 g_free(gfud->website.user); |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3647 g_free(gfud->website.passwd); |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3648 g_free(gfud->website.address); |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3649 g_free(gfud->website.page); |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3650 purple_url_parse(new_url, &gfud->website.address, &gfud->website.port, |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3651 &gfud->website.page, &gfud->website.user, &gfud->website.passwd); |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3652 |
24592
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3653 if (purple_strcasestr(new_url, "https://") != NULL) { |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3654 gfud->is_ssl = TRUE; |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3655 gfud->ssl_connection = purple_ssl_connect(NULL, |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3656 gfud->website.address, gfud->website.port, |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3657 ssl_url_fetch_connect_cb, ssl_url_fetch_error_cb, gfud); |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3658 } else { |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3659 gfud->connect_data = purple_proxy_connect(NULL, NULL, |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3660 gfud->website.address, gfud->website.port, |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3661 url_fetch_connect_cb, gfud); |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3662 } |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3663 |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3664 if (gfud->ssl_connection == NULL && gfud->connect_data == NULL) |
17450
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3665 { |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3666 purple_util_fetch_url_error(gfud, _("Unable to connect to %s"), |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3667 gfud->website.address); |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3668 } |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3669 |
3d035cdd103b
Add some notes about why Yahoo! web messenger login doesn't work
Mark Doliner <mark@kingant.net>
parents:
17195
diff
changeset
|
3670 return TRUE; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3671 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3672 |
27220
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3673 static const char * |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3674 find_header_content(const char *data, size_t data_len, const char *header, size_t header_len) |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3675 { |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3676 const char *p = NULL; |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3677 |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3678 if (header_len <= 0) |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3679 header_len = strlen(header); |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3680 |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3681 /* Note: data is _not_ nul-terminated. */ |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3682 if (data_len > header_len) { |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3683 if (header[0] == '\n') |
27936
703b20fa6c5c
g_strncasecmp is deprecated. I thought I removed these already. Anyway, I
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27907
diff
changeset
|
3684 p = (g_ascii_strncasecmp(data, header + 1, header_len - 1) == 0) ? data : NULL; |
27220
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3685 if (!p) |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3686 p = purple_strcasestr(data, header); |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3687 if (p) |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3688 p += header_len; |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3689 } |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3690 |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3691 /* If we can find the header at all, try to sscanf it. |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3692 * Response headers should end with at least \r\n, so sscanf is safe, |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3693 * if we make sure that there is indeed a \n in our header. |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3694 */ |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3695 if (p && g_strstr_len(p, data_len - (p - data), "\n")) { |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3696 return p; |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3697 } |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3698 |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3699 return NULL; |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3700 } |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3701 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3702 static size_t |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3703 parse_content_len(const char *data, size_t data_len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3704 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3705 size_t content_len = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3706 const char *p = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3707 |
27220
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3708 p = find_header_content(data, data_len, "\nContent-Length: ", sizeof("\nContent-Length: ") - 1); |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3709 if (p) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3710 sscanf(p, "%" G_GSIZE_FORMAT, &content_len); |
22486
3225c99785b8
Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <mark@kingant.net>
parents:
22354
diff
changeset
|
3711 purple_debug_misc("util", "parsed %" G_GSIZE_FORMAT "\n", content_len); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3712 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3713 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3714 return content_len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3715 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3716 |
27220
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3717 static gboolean |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3718 content_is_chunked(const char *data, size_t data_len) |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3719 { |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3720 const char *p = find_header_content(data, data_len, "\nTransfer-Encoding: ", sizeof("\nTransfer-Encoding: ") - 1); |
27936
703b20fa6c5c
g_strncasecmp is deprecated. I thought I removed these already. Anyway, I
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27907
diff
changeset
|
3721 if (p && g_ascii_strncasecmp(p, "chunked", 7) == 0) |
27245
a051f77d86a8
Remove just a tad bit of indirection
Mark Doliner <mark@kingant.net>
parents:
27244
diff
changeset
|
3722 return TRUE; |
a051f77d86a8
Remove just a tad bit of indirection
Mark Doliner <mark@kingant.net>
parents:
27244
diff
changeset
|
3723 |
a051f77d86a8
Remove just a tad bit of indirection
Mark Doliner <mark@kingant.net>
parents:
27244
diff
changeset
|
3724 return FALSE; |
27220
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3725 } |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3726 |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3727 /* Process in-place */ |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3728 static void |
27244
7a4f56967512
Use unsigned lengths here and use %zu when reading into the gsize var
Mark Doliner <mark@kingant.net>
parents:
27223
diff
changeset
|
3729 process_chunked_data(char *data, gsize *len) |
27220
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3730 { |
27244
7a4f56967512
Use unsigned lengths here and use %zu when reading into the gsize var
Mark Doliner <mark@kingant.net>
parents:
27223
diff
changeset
|
3731 gsize sz; |
27246
e28b627be482
A few changes to our code to handle chunked transfer-encodings (technically
Mark Doliner <mark@kingant.net>
parents:
27245
diff
changeset
|
3732 gsize newlen = 0; |
27220
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3733 char *p = data; |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3734 char *s = data; |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3735 |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3736 while (*s) { |
27246
e28b627be482
A few changes to our code to handle chunked transfer-encodings (technically
Mark Doliner <mark@kingant.net>
parents:
27245
diff
changeset
|
3737 /* Read the size of this chunk */ |
27376
70e64287f790
Hey Stu, it should be safe to combine this check, right? It'll make us
Mark Doliner <mark@kingant.net>
parents:
27298
diff
changeset
|
3738 if (sscanf(s, "%" G_GSIZE_MODIFIER "x", &sz) != 1) |
27246
e28b627be482
A few changes to our code to handle chunked transfer-encodings (technically
Mark Doliner <mark@kingant.net>
parents:
27245
diff
changeset
|
3739 { |
e28b627be482
A few changes to our code to handle chunked transfer-encodings (technically
Mark Doliner <mark@kingant.net>
parents:
27245
diff
changeset
|
3740 purple_debug_error("util", "Error processing chunked data: " |
e28b627be482
A few changes to our code to handle chunked transfer-encodings (technically
Mark Doliner <mark@kingant.net>
parents:
27245
diff
changeset
|
3741 "Expected data length, found: %s\n", s); |
27220
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3742 break; |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3743 } |
27246
e28b627be482
A few changes to our code to handle chunked transfer-encodings (technically
Mark Doliner <mark@kingant.net>
parents:
27245
diff
changeset
|
3744 if (sz == 0) { |
e28b627be482
A few changes to our code to handle chunked transfer-encodings (technically
Mark Doliner <mark@kingant.net>
parents:
27245
diff
changeset
|
3745 /* We've reached the last chunk */ |
e28b627be482
A few changes to our code to handle chunked transfer-encodings (technically
Mark Doliner <mark@kingant.net>
parents:
27245
diff
changeset
|
3746 /* |
e28b627be482
A few changes to our code to handle chunked transfer-encodings (technically
Mark Doliner <mark@kingant.net>
parents:
27245
diff
changeset
|
3747 * TODO: The spec allows "footers" to follow the last chunk. |
e28b627be482
A few changes to our code to handle chunked transfer-encodings (technically
Mark Doliner <mark@kingant.net>
parents:
27245
diff
changeset
|
3748 * If there is more data after this line then we should |
e28b627be482
A few changes to our code to handle chunked transfer-encodings (technically
Mark Doliner <mark@kingant.net>
parents:
27245
diff
changeset
|
3749 * treat it like a header. |
e28b627be482
A few changes to our code to handle chunked transfer-encodings (technically
Mark Doliner <mark@kingant.net>
parents:
27245
diff
changeset
|
3750 */ |
27220
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3751 break; |
27246
e28b627be482
A few changes to our code to handle chunked transfer-encodings (technically
Mark Doliner <mark@kingant.net>
parents:
27245
diff
changeset
|
3752 } |
e28b627be482
A few changes to our code to handle chunked transfer-encodings (technically
Mark Doliner <mark@kingant.net>
parents:
27245
diff
changeset
|
3753 |
e28b627be482
A few changes to our code to handle chunked transfer-encodings (technically
Mark Doliner <mark@kingant.net>
parents:
27245
diff
changeset
|
3754 /* Advance to the start of the data */ |
27281
e8ac5369d567
Apparently there might be stuff after the semicolon before the \r\n so just
Stu Tomlinson <stu@nosnilmot.com>
parents:
27274
diff
changeset
|
3755 s = strstr(s, "\r\n"); |
e8ac5369d567
Apparently there might be stuff after the semicolon before the \r\n so just
Stu Tomlinson <stu@nosnilmot.com>
parents:
27274
diff
changeset
|
3756 if (s == NULL) |
e8ac5369d567
Apparently there might be stuff after the semicolon before the \r\n so just
Stu Tomlinson <stu@nosnilmot.com>
parents:
27274
diff
changeset
|
3757 break; |
e8ac5369d567
Apparently there might be stuff after the semicolon before the \r\n so just
Stu Tomlinson <stu@nosnilmot.com>
parents:
27274
diff
changeset
|
3758 s += 2; |
27246
e28b627be482
A few changes to our code to handle chunked transfer-encodings (technically
Mark Doliner <mark@kingant.net>
parents:
27245
diff
changeset
|
3759 |
e28b627be482
A few changes to our code to handle chunked transfer-encodings (technically
Mark Doliner <mark@kingant.net>
parents:
27245
diff
changeset
|
3760 if (s + sz > data + *len) { |
e28b627be482
A few changes to our code to handle chunked transfer-encodings (technically
Mark Doliner <mark@kingant.net>
parents:
27245
diff
changeset
|
3761 purple_debug_error("util", "Error processing chunked data: " |
e28b627be482
A few changes to our code to handle chunked transfer-encodings (technically
Mark Doliner <mark@kingant.net>
parents:
27245
diff
changeset
|
3762 "Chunk size %" G_GSIZE_FORMAT " bytes was longer " |
e28b627be482
A few changes to our code to handle chunked transfer-encodings (technically
Mark Doliner <mark@kingant.net>
parents:
27245
diff
changeset
|
3763 "than the data remaining in the buffer (%" |
e28b627be482
A few changes to our code to handle chunked transfer-encodings (technically
Mark Doliner <mark@kingant.net>
parents:
27245
diff
changeset
|
3764 G_GSIZE_FORMAT " bytes)\n", sz, data + *len - s); |
e28b627be482
A few changes to our code to handle chunked transfer-encodings (technically
Mark Doliner <mark@kingant.net>
parents:
27245
diff
changeset
|
3765 } |
e28b627be482
A few changes to our code to handle chunked transfer-encodings (technically
Mark Doliner <mark@kingant.net>
parents:
27245
diff
changeset
|
3766 |
e28b627be482
A few changes to our code to handle chunked transfer-encodings (technically
Mark Doliner <mark@kingant.net>
parents:
27245
diff
changeset
|
3767 /* Move all data overtop of the chunk length that we read in earlier */ |
27220
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3768 g_memmove(p, s, sz); |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3769 p += sz; |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3770 s += sz; |
27246
e28b627be482
A few changes to our code to handle chunked transfer-encodings (technically
Mark Doliner <mark@kingant.net>
parents:
27245
diff
changeset
|
3771 newlen += sz; |
27220
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3772 if (*s != '\r' && *(s + 1) != '\n') { |
27246
e28b627be482
A few changes to our code to handle chunked transfer-encodings (technically
Mark Doliner <mark@kingant.net>
parents:
27245
diff
changeset
|
3773 purple_debug_error("util", "Error processing chunked data: " |
e28b627be482
A few changes to our code to handle chunked transfer-encodings (technically
Mark Doliner <mark@kingant.net>
parents:
27245
diff
changeset
|
3774 "Expected \\r\\n, found: %s\n", s); |
27220
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3775 break; |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3776 } |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3777 s += 2; |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3778 } |
27246
e28b627be482
A few changes to our code to handle chunked transfer-encodings (technically
Mark Doliner <mark@kingant.net>
parents:
27245
diff
changeset
|
3779 |
e28b627be482
A few changes to our code to handle chunked transfer-encodings (technically
Mark Doliner <mark@kingant.net>
parents:
27245
diff
changeset
|
3780 /* NULL terminate the data */ |
27220
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3781 *p = 0; |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3782 |
27246
e28b627be482
A few changes to our code to handle chunked transfer-encodings (technically
Mark Doliner <mark@kingant.net>
parents:
27245
diff
changeset
|
3783 *len = newlen; |
27220
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3784 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3785 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3786 static void |
15822 | 3787 url_fetch_recv_cb(gpointer url_data, gint source, PurpleInputCondition cond) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3788 { |
15822 | 3789 PurpleUtilFetchUrlData *gfud = url_data; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3790 int len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3791 char buf[4096]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3792 char *data_cursor; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3793 gboolean got_eof = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3794 |
24592
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3795 /* |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3796 * Read data in a loop until we can't read any more! This is a |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3797 * little confusing because we read using a different function |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3798 * depending on whether the socket is ssl or cleartext. |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3799 */ |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3800 while ((gfud->is_ssl && ((len = purple_ssl_read(gfud->ssl_connection, buf, sizeof(buf))) > 0)) || |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3801 (!gfud->is_ssl && (len = read(source, buf, sizeof(buf))) > 0)) |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3802 { |
23684
de8f2d3e538a
Add temporary purple_util_fetch_url_request_len and purple_util_fetch_url_len
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23666
diff
changeset
|
3803 if(gfud->max_len != -1 && (gfud->len + len) > gfud->max_len) { |
24075
fa39c801167d
Fix a TODO and mark a string translatable now that we're not string frozen.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23983
diff
changeset
|
3804 purple_util_fetch_url_error(gfud, _("Error reading from %s: response too long (%d bytes limit)"), |
23684
de8f2d3e538a
Add temporary purple_util_fetch_url_request_len and purple_util_fetch_url_len
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23666
diff
changeset
|
3805 gfud->website.address, gfud->max_len); |
de8f2d3e538a
Add temporary purple_util_fetch_url_request_len and purple_util_fetch_url_len
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23666
diff
changeset
|
3806 return; |
de8f2d3e538a
Add temporary purple_util_fetch_url_request_len and purple_util_fetch_url_len
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23666
diff
changeset
|
3807 } |
de8f2d3e538a
Add temporary purple_util_fetch_url_request_len and purple_util_fetch_url_len
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23666
diff
changeset
|
3808 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3809 /* If we've filled up our buffer, make it bigger */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3810 if((gfud->len + len) >= gfud->data_len) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3811 while((gfud->len + len) >= gfud->data_len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3812 gfud->data_len += sizeof(buf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3813 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3814 gfud->webdata = g_realloc(gfud->webdata, gfud->data_len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3815 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3816 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3817 data_cursor = gfud->webdata + gfud->len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3818 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3819 gfud->len += len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3820 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3821 memcpy(data_cursor, buf, len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3822 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3823 gfud->webdata[gfud->len] = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3824 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3825 if(!gfud->got_headers) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3826 char *tmp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3827 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3828 /* See if we've reached the end of the headers yet */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3829 if((tmp = strstr(gfud->webdata, "\r\n\r\n"))) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3830 char * new_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3831 guint header_len = (tmp + 4 - gfud->webdata); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3832 size_t content_len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3833 |
15822 | 3834 purple_debug_misc("util", "Response headers: '%.*s'\n", |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3835 header_len, gfud->webdata); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3836 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3837 /* See if we can find a redirect. */ |
23388 | 3838 if(parse_redirect(gfud->webdata, header_len, gfud)) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3839 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3840 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3841 gfud->got_headers = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3842 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3843 /* No redirect. See if we can find a content length. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3844 content_len = parse_content_len(gfud->webdata, header_len); |
27220
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3845 gfud->chunked = content_is_chunked(gfud->webdata, header_len); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3846 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3847 if(content_len == 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3848 /* We'll stick with an initial 8192 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3849 content_len = 8192; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3850 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3851 gfud->has_explicit_data_len = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3852 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3853 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3854 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3855 /* If we're returning the headers too, we don't need to clean them out */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3856 if(gfud->include_headers) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3857 gfud->data_len = content_len + header_len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3858 gfud->webdata = g_realloc(gfud->webdata, gfud->data_len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3859 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3860 size_t body_len = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3861 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3862 if(gfud->len > (header_len + 1)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3863 body_len = (gfud->len - header_len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3864 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3865 content_len = MAX(content_len, body_len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3866 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3867 new_data = g_try_malloc(content_len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3868 if(new_data == NULL) { |
15822 | 3869 purple_debug_error("util", |
22486
3225c99785b8
Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <mark@kingant.net>
parents:
22354
diff
changeset
|
3870 "Failed to allocate %" G_GSIZE_FORMAT " bytes: %s\n", |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
21028
diff
changeset
|
3871 content_len, g_strerror(errno)); |
15822 | 3872 purple_util_fetch_url_error(gfud, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3873 _("Unable to allocate enough memory to hold " |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3874 "the contents from %s. The web server may " |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3875 "be trying something malicious."), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3876 gfud->website.address); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3877 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3878 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3879 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3880 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3881 /* We may have read part of the body when reading the headers, don't lose it */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3882 if(body_len > 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3883 tmp += 4; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3884 memcpy(new_data, tmp, body_len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3885 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3886 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3887 /* Out with the old... */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3888 g_free(gfud->webdata); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3889 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3890 /* In with the new. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3891 gfud->len = body_len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3892 gfud->data_len = content_len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3893 gfud->webdata = new_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3894 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3895 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3896 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3897 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3898 if(gfud->has_explicit_data_len && gfud->len >= gfud->data_len) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3899 got_eof = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3900 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3901 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3902 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3903 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3904 if(len < 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3905 if(errno == EAGAIN) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3906 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3907 } else { |
15822 | 3908 purple_util_fetch_url_error(gfud, _("Error reading from %s: %s"), |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
21028
diff
changeset
|
3909 gfud->website.address, g_strerror(errno)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3910 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3911 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3912 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3913 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3914 if((len == 0) || got_eof) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3915 gfud->webdata = g_realloc(gfud->webdata, gfud->len + 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3916 gfud->webdata[gfud->len] = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3917 |
27220
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3918 if (!gfud->include_headers && gfud->chunked) { |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3919 /* Process only if we don't want the headers. */ |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3920 process_chunked_data(gfud->webdata, &gfud->len); |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3921 } |
716bd29bdc28
Process the data correctly if the server sends chunked data.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27137
diff
changeset
|
3922 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3923 gfud->callback(gfud, gfud->user_data, gfud->webdata, gfud->len, NULL); |
15822 | 3924 purple_util_fetch_url_cancel(gfud); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3925 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3926 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3927 |
24592
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3928 static void ssl_url_fetch_recv_cb(gpointer data, PurpleSslConnection *ssl_connection, PurpleInputCondition cond) |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3929 { |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3930 url_fetch_recv_cb(data, -1, cond); |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3931 } |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3932 |
27120
9ff4b4cbc4c9
Allow doxygen to pick up the comment for this function. It's
Mark Doliner <mark@kingant.net>
parents:
27024
diff
changeset
|
3933 /** |
24592
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3934 * This function is called when the socket is available to be written |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3935 * to. |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3936 * |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3937 * @param source The file descriptor that can be written to. This can |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3938 * be an http connection or it can be the SSL connection of an |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3939 * https request. So be careful what you use it for! If it's |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3940 * an https request then use purple_ssl_write() instead of |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3941 * writing to it directly. |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3942 */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3943 static void |
15822 | 3944 url_fetch_send_cb(gpointer data, gint source, PurpleInputCondition cond) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3945 { |
15822 | 3946 PurpleUtilFetchUrlData *gfud; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3947 int len, total_len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3948 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3949 gfud = data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3950 |
24592
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3951 if (gfud->request == NULL) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3952 { |
24592
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3953 /* Host header is not forbidden in HTTP/1.0 requests, and HTTP/1.1 |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3954 * clients must know how to handle the "chunked" transfer encoding. |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3955 * Purple doesn't know how to handle "chunked", so should always send |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3956 * the Host header regardless, to get around some observed problems |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3957 */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3958 if (gfud->user_agent) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3959 gfud->request = g_strdup_printf( |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3960 "GET %s%s HTTP/%s\r\n" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3961 "Connection: close\r\n" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3962 "User-Agent: %s\r\n" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3963 "Accept: */*\r\n" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3964 "Host: %s\r\n\r\n", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3965 (gfud->full ? "" : "/"), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3966 (gfud->full ? (gfud->url ? gfud->url : "") : (gfud->website.page ? gfud->website.page : "")), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3967 (gfud->http11 ? "1.1" : "1.0"), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3968 (gfud->user_agent ? gfud->user_agent : ""), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3969 (gfud->website.address ? gfud->website.address : "")); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3970 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3971 gfud->request = g_strdup_printf( |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3972 "GET %s%s HTTP/%s\r\n" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3973 "Connection: close\r\n" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3974 "Accept: */*\r\n" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3975 "Host: %s\r\n\r\n", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3976 (gfud->full ? "" : "/"), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3977 (gfud->full ? (gfud->url ? gfud->url : "") : (gfud->website.page ? gfud->website.page : "")), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3978 (gfud->http11 ? "1.1" : "1.0"), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3979 (gfud->website.address ? gfud->website.address : "")); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3980 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3981 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3982 |
27298
e9279f0e551a
Convert all uses of PURPLE_UNSAFE_DEBUG to the new API I added.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
27295
diff
changeset
|
3983 if(purple_debug_is_unsafe()) |
25623
fb89c9f6e57a
*** Plucked rev c1ede5faf776dc1cc966dabb42c1ef0dbaea31db (rekkanoryo@pidgin.im):
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24863
diff
changeset
|
3984 purple_debug_misc("util", "Request: '%s'\n", gfud->request); |
fb89c9f6e57a
*** Plucked rev c1ede5faf776dc1cc966dabb42c1ef0dbaea31db (rekkanoryo@pidgin.im):
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24863
diff
changeset
|
3985 else |
fb89c9f6e57a
*** Plucked rev c1ede5faf776dc1cc966dabb42c1ef0dbaea31db (rekkanoryo@pidgin.im):
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24863
diff
changeset
|
3986 purple_debug_misc("util", "request constructed\n"); |
15822 | 3987 |
24592
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3988 total_len = strlen(gfud->request); |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3989 |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3990 if (gfud->is_ssl) |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3991 len = purple_ssl_write(gfud->ssl_connection, gfud->request + gfud->request_written, |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3992 total_len - gfud->request_written); |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3993 else |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3994 len = write(gfud->fd, gfud->request + gfud->request_written, |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3995 total_len - gfud->request_written); |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3996 |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3997 if (len < 0 && errno == EAGAIN) |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3998 return; |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
3999 else if (len < 0) { |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4000 purple_util_fetch_url_error(gfud, _("Error writing to %s: %s"), |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4001 gfud->website.address, g_strerror(errno)); |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4002 return; |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4003 } |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4004 gfud->request_written += len; |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4005 |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4006 if (gfud->request_written < total_len) |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4007 return; |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4008 |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4009 /* We're done writing our request, now start reading the response */ |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4010 if (gfud->is_ssl) { |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4011 purple_input_remove(gfud->inpa); |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4012 gfud->inpa = 0; |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4013 purple_ssl_input_add(gfud->ssl_connection, ssl_url_fetch_recv_cb, gfud); |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4014 } else { |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4015 purple_input_remove(gfud->inpa); |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4016 gfud->inpa = purple_input_add(gfud->fd, PURPLE_INPUT_READ, url_fetch_recv_cb, |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4017 gfud); |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4018 } |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4019 } |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4020 |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4021 static void |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4022 url_fetch_connect_cb(gpointer url_data, gint source, const gchar *error_message) |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4023 { |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4024 PurpleUtilFetchUrlData *gfud; |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4025 |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4026 gfud = url_data; |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4027 gfud->connect_data = NULL; |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4028 |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4029 if (source == -1) |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4030 { |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4031 purple_util_fetch_url_error(gfud, _("Unable to connect to %s: %s"), |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4032 (gfud->website.address ? gfud->website.address : ""), error_message); |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4033 return; |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4034 } |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4035 |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4036 gfud->fd = source; |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4037 |
15822 | 4038 gfud->inpa = purple_input_add(source, PURPLE_INPUT_WRITE, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4039 url_fetch_send_cb, gfud); |
15822 | 4040 url_fetch_send_cb(gfud, source, PURPLE_INPUT_WRITE); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4041 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4042 |
24592
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4043 static void ssl_url_fetch_connect_cb(gpointer data, PurpleSslConnection *ssl_connection, PurpleInputCondition cond) |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4044 { |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4045 PurpleUtilFetchUrlData *gfud; |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4046 |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4047 gfud = data; |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4048 |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4049 gfud->inpa = purple_input_add(ssl_connection->fd, PURPLE_INPUT_WRITE, |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4050 url_fetch_send_cb, gfud); |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4051 url_fetch_send_cb(gfud, ssl_connection->fd, PURPLE_INPUT_WRITE); |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4052 } |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4053 |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4054 static void ssl_url_fetch_error_cb(PurpleSslConnection *ssl_connection, PurpleSslErrorType error, gpointer data) |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4055 { |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4056 PurpleUtilFetchUrlData *gfud; |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4057 |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4058 gfud = data; |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4059 gfud->ssl_connection = NULL; |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4060 |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4061 purple_util_fetch_url_error(gfud, _("Unable to connect to %s: %s"), |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4062 (gfud->website.address ? gfud->website.address : ""), |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4063 purple_ssl_strerror(error)); |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4064 } |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4065 |
15822 | 4066 PurpleUtilFetchUrlData * |
4067 purple_util_fetch_url_request(const char *url, gboolean full, | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4068 const char *user_agent, gboolean http11, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4069 const char *request, gboolean include_headers, |
15822 | 4070 PurpleUtilFetchUrlCallback callback, void *user_data) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4071 { |
26969
f303787f144d
Add yet another URL fetching function. This one takes an account as a
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
26895
diff
changeset
|
4072 return purple_util_fetch_url_request_len_with_account(NULL, url, full, |
23684
de8f2d3e538a
Add temporary purple_util_fetch_url_request_len and purple_util_fetch_url_len
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23666
diff
changeset
|
4073 user_agent, http11, |
de8f2d3e538a
Add temporary purple_util_fetch_url_request_len and purple_util_fetch_url_len
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23666
diff
changeset
|
4074 request, include_headers, -1, |
de8f2d3e538a
Add temporary purple_util_fetch_url_request_len and purple_util_fetch_url_len
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23666
diff
changeset
|
4075 callback, user_data); |
de8f2d3e538a
Add temporary purple_util_fetch_url_request_len and purple_util_fetch_url_len
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23666
diff
changeset
|
4076 } |
de8f2d3e538a
Add temporary purple_util_fetch_url_request_len and purple_util_fetch_url_len
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23666
diff
changeset
|
4077 |
de8f2d3e538a
Add temporary purple_util_fetch_url_request_len and purple_util_fetch_url_len
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23666
diff
changeset
|
4078 PurpleUtilFetchUrlData * |
de8f2d3e538a
Add temporary purple_util_fetch_url_request_len and purple_util_fetch_url_len
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23666
diff
changeset
|
4079 purple_util_fetch_url_request_len(const char *url, gboolean full, |
de8f2d3e538a
Add temporary purple_util_fetch_url_request_len and purple_util_fetch_url_len
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23666
diff
changeset
|
4080 const char *user_agent, gboolean http11, |
de8f2d3e538a
Add temporary purple_util_fetch_url_request_len and purple_util_fetch_url_len
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23666
diff
changeset
|
4081 const char *request, gboolean include_headers, gssize max_len, |
de8f2d3e538a
Add temporary purple_util_fetch_url_request_len and purple_util_fetch_url_len
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23666
diff
changeset
|
4082 PurpleUtilFetchUrlCallback callback, void *user_data) |
de8f2d3e538a
Add temporary purple_util_fetch_url_request_len and purple_util_fetch_url_len
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23666
diff
changeset
|
4083 { |
26969
f303787f144d
Add yet another URL fetching function. This one takes an account as a
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
26895
diff
changeset
|
4084 return purple_util_fetch_url_request_len_with_account(NULL, url, full, |
f303787f144d
Add yet another URL fetching function. This one takes an account as a
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
26895
diff
changeset
|
4085 user_agent, http11, request, include_headers, max_len, callback, |
f303787f144d
Add yet another URL fetching function. This one takes an account as a
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
26895
diff
changeset
|
4086 user_data); |
f303787f144d
Add yet another URL fetching function. This one takes an account as a
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
26895
diff
changeset
|
4087 } |
f303787f144d
Add yet another URL fetching function. This one takes an account as a
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
26895
diff
changeset
|
4088 |
f303787f144d
Add yet another URL fetching function. This one takes an account as a
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
26895
diff
changeset
|
4089 PurpleUtilFetchUrlData * |
f303787f144d
Add yet another URL fetching function. This one takes an account as a
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
26895
diff
changeset
|
4090 purple_util_fetch_url_request_len_with_account(PurpleAccount *account, |
f303787f144d
Add yet another URL fetching function. This one takes an account as a
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
26895
diff
changeset
|
4091 const char *url, gboolean full, const char *user_agent, gboolean http11, |
f303787f144d
Add yet another URL fetching function. This one takes an account as a
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
26895
diff
changeset
|
4092 const char *request, gboolean include_headers, gssize max_len, |
f303787f144d
Add yet another URL fetching function. This one takes an account as a
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
26895
diff
changeset
|
4093 PurpleUtilFetchUrlCallback callback, void *user_data) |
f303787f144d
Add yet another URL fetching function. This one takes an account as a
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
26895
diff
changeset
|
4094 { |
15822 | 4095 PurpleUtilFetchUrlData *gfud; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4096 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4097 g_return_val_if_fail(url != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4098 g_return_val_if_fail(callback != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4099 |
27298
e9279f0e551a
Convert all uses of PURPLE_UNSAFE_DEBUG to the new API I added.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
27295
diff
changeset
|
4100 if(purple_debug_is_unsafe()) |
25623
fb89c9f6e57a
*** Plucked rev c1ede5faf776dc1cc966dabb42c1ef0dbaea31db (rekkanoryo@pidgin.im):
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24863
diff
changeset
|
4101 purple_debug_info("util", |
fb89c9f6e57a
*** Plucked rev c1ede5faf776dc1cc966dabb42c1ef0dbaea31db (rekkanoryo@pidgin.im):
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24863
diff
changeset
|
4102 "requested to fetch (%s), full=%d, user_agent=(%s), http11=%d\n", |
fb89c9f6e57a
*** Plucked rev c1ede5faf776dc1cc966dabb42c1ef0dbaea31db (rekkanoryo@pidgin.im):
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24863
diff
changeset
|
4103 url, full, user_agent?user_agent:"(null)", http11); |
fb89c9f6e57a
*** Plucked rev c1ede5faf776dc1cc966dabb42c1ef0dbaea31db (rekkanoryo@pidgin.im):
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24863
diff
changeset
|
4104 else |
fb89c9f6e57a
*** Plucked rev c1ede5faf776dc1cc966dabb42c1ef0dbaea31db (rekkanoryo@pidgin.im):
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
24863
diff
changeset
|
4105 purple_debug_info("util", "requesting to fetch a URL\n"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4106 |
15822 | 4107 gfud = g_new0(PurpleUtilFetchUrlData, 1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4108 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4109 gfud->callback = callback; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4110 gfud->user_data = user_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4111 gfud->url = g_strdup(url); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4112 gfud->user_agent = g_strdup(user_agent); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4113 gfud->http11 = http11; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4114 gfud->full = full; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4115 gfud->request = g_strdup(request); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4116 gfud->include_headers = include_headers; |
20592
383b9180b2c8
Initialize file-descriptors to -1.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20587
diff
changeset
|
4117 gfud->fd = -1; |
23684
de8f2d3e538a
Add temporary purple_util_fetch_url_request_len and purple_util_fetch_url_len
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23666
diff
changeset
|
4118 gfud->max_len = max_len; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4119 |
15822 | 4120 purple_url_parse(url, &gfud->website.address, &gfud->website.port, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4121 &gfud->website.page, &gfud->website.user, &gfud->website.passwd); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4122 |
24592
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4123 if (purple_strcasestr(url, "https://") != NULL) { |
26190
2db8a92b3cde
Add a friendly error message if something uses
Mark Doliner <mark@kingant.net>
parents:
26181
diff
changeset
|
4124 if (!purple_ssl_is_supported()) { |
2db8a92b3cde
Add a friendly error message if something uses
Mark Doliner <mark@kingant.net>
parents:
26181
diff
changeset
|
4125 purple_util_fetch_url_error(gfud, |
27378
6275df9d2d62
Change strings in libpurple/protocols/jabber/auth.c and util.c a little bit
Mark Doliner <mark@kingant.net>
parents:
27376
diff
changeset
|
4126 _("Unable to connect to %s: %s"), |
6275df9d2d62
Change strings in libpurple/protocols/jabber/auth.c and util.c a little bit
Mark Doliner <mark@kingant.net>
parents:
27376
diff
changeset
|
4127 gfud->website.address, |
6275df9d2d62
Change strings in libpurple/protocols/jabber/auth.c and util.c a little bit
Mark Doliner <mark@kingant.net>
parents:
27376
diff
changeset
|
4128 _("Server requires TLS/SSL, but no TLS/SSL support was found.")); |
26190
2db8a92b3cde
Add a friendly error message if something uses
Mark Doliner <mark@kingant.net>
parents:
26181
diff
changeset
|
4129 return NULL; |
2db8a92b3cde
Add a friendly error message if something uses
Mark Doliner <mark@kingant.net>
parents:
26181
diff
changeset
|
4130 } |
2db8a92b3cde
Add a friendly error message if something uses
Mark Doliner <mark@kingant.net>
parents:
26181
diff
changeset
|
4131 |
24592
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4132 gfud->is_ssl = TRUE; |
26969
f303787f144d
Add yet another URL fetching function. This one takes an account as a
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
26895
diff
changeset
|
4133 gfud->ssl_connection = purple_ssl_connect(account, |
24592
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4134 gfud->website.address, gfud->website.port, |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4135 ssl_url_fetch_connect_cb, ssl_url_fetch_error_cb, gfud); |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4136 } else { |
26969
f303787f144d
Add yet another URL fetching function. This one takes an account as a
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
26895
diff
changeset
|
4137 gfud->connect_data = purple_proxy_connect(NULL, account, |
24592
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4138 gfud->website.address, gfud->website.port, |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4139 url_fetch_connect_cb, gfud); |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4140 } |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4141 |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4142 if (gfud->ssl_connection == NULL && gfud->connect_data == NULL) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4143 { |
24592
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4144 purple_util_fetch_url_error(gfud, _("Unable to connect to %s"), |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4145 gfud->website.address); |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4146 return NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4147 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4148 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4149 return gfud; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4150 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4151 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4152 void |
15822 | 4153 purple_util_fetch_url_cancel(PurpleUtilFetchUrlData *gfud) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4154 { |
24592
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4155 if (gfud->ssl_connection != NULL) |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4156 purple_ssl_close(gfud->ssl_connection); |
104f6f755c7e
Make our purple_util_fetch_url_request() function able to handle
Mark Doliner <mark@kingant.net>
parents:
24426
diff
changeset
|
4157 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4158 if (gfud->connect_data != NULL) |
15822 | 4159 purple_proxy_connect_cancel(gfud->connect_data); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4160 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4161 if (gfud->inpa > 0) |
15822 | 4162 purple_input_remove(gfud->inpa); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4163 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4164 if (gfud->fd >= 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4165 close(gfud->fd); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4166 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4167 g_free(gfud->website.user); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4168 g_free(gfud->website.passwd); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4169 g_free(gfud->website.address); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4170 g_free(gfud->website.page); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4171 g_free(gfud->url); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4172 g_free(gfud->user_agent); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4173 g_free(gfud->request); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4174 g_free(gfud->webdata); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4175 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4176 g_free(gfud); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4177 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4178 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4179 const char * |
15822 | 4180 purple_url_decode(const char *str) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4181 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4182 static char buf[BUF_LEN]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4183 guint i, j = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4184 char *bum; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4185 char hex[3]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4186 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4187 g_return_val_if_fail(str != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4188 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4189 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4190 * XXX - This check could be removed and buf could be made |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4191 * dynamically allocated, but this is easier. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4192 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4193 if (strlen(str) >= BUF_LEN) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4194 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4195 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4196 for (i = 0; i < strlen(str); i++) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4197 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4198 if (str[i] != '%') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4199 buf[j++] = str[i]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4200 else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4201 strncpy(hex, str + ++i, 2); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4202 hex[2] = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4203 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4204 /* i is pointing to the start of the number */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4205 i++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4206 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4207 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4208 * Now it's at the end and at the start of the for loop |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4209 * will be at the next character. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4210 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4211 buf[j++] = strtol(hex, NULL, 16); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4212 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4213 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4214 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4215 buf[j] = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4216 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4217 if (!g_utf8_validate(buf, -1, (const char **)&bum)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4218 *bum = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4219 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4220 return buf; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4221 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4222 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4223 const char * |
15822 | 4224 purple_url_encode(const char *str) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4225 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4226 const char *iter; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4227 static char buf[BUF_LEN]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4228 char utf_char[6]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4229 guint i, j = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4230 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4231 g_return_val_if_fail(str != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4232 g_return_val_if_fail(g_utf8_validate(str, -1, NULL), NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4233 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4234 iter = str; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4235 for (; *iter && j < (BUF_LEN - 1) ; iter = g_utf8_next_char(iter)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4236 gunichar c = g_utf8_get_char(iter); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4237 /* If the character is an ASCII character and is alphanumeric |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4238 * no need to escape */ |
28255
79c14adf9669
Change purple_url_encode() to not encode . _ - ~ because it's not
Mark Doliner <mark@kingant.net>
parents:
28153
diff
changeset
|
4239 if (c < 128 && (isalnum(c) || c == '-' || c == '.' || c == '_' || c == '~')) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4240 buf[j++] = c; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4241 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4242 int bytes = g_unichar_to_utf8(c, utf_char); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4243 for (i = 0; i < bytes; i++) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4244 if (j > (BUF_LEN - 4)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4245 break; |
28255
79c14adf9669
Change purple_url_encode() to not encode . _ - ~ because it's not
Mark Doliner <mark@kingant.net>
parents:
28153
diff
changeset
|
4246 sprintf(buf + j, "%%%02X", utf_char[i] & 0xff); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4247 j += 3; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4248 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4249 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4250 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4251 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4252 buf[j] = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4253 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4254 return buf; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4255 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4256 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4257 /* Originally lifted from |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4258 * http://www.oreillynet.com/pub/a/network/excerpt/spcookbook_chap03/index3.html |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4259 * ... and slightly modified to be a bit more rfc822 compliant |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4260 * ... and modified a bit more to make domain checking rfc1035 compliant |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4261 * with the exception permitted in rfc1101 for domains to start with digit |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4262 * but not completely checking to avoid conflicts with IP addresses |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4263 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4264 gboolean |
15822 | 4265 purple_email_is_valid(const char *address) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4266 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4267 const char *c, *domain; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4268 static char *rfc822_specials = "()<>@,;:\\\"[]"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4269 |
24424 | 4270 g_return_val_if_fail(address != NULL, FALSE); |
4271 | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4272 /* first we validate the name portion (name@domain) (rfc822)*/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4273 for (c = address; *c; c++) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4274 if (*c == '\"' && (c == address || *(c - 1) == '.' || *(c - 1) == '\"')) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4275 while (*++c) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4276 if (*c == '\\') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4277 if (*c++ && *c < 127 && *c != '\n' && *c != '\r') continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4278 else return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4279 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4280 if (*c == '\"') break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4281 if (*c < ' ' || *c >= 127) return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4282 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4283 if (!*c++) return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4284 if (*c == '@') break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4285 if (*c != '.') return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4286 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4287 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4288 if (*c == '@') break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4289 if (*c <= ' ' || *c >= 127) return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4290 if (strchr(rfc822_specials, *c)) return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4291 } |
18600
321658bf0e03
Valgrind was showing "Invalid read of size 1" when a string is passed
Mark Doliner <mark@kingant.net>
parents:
18560
diff
changeset
|
4292 |
321658bf0e03
Valgrind was showing "Invalid read of size 1" when a string is passed
Mark Doliner <mark@kingant.net>
parents:
18560
diff
changeset
|
4293 /* It's obviously not an email address if we didn't find an '@' above */ |
321658bf0e03
Valgrind was showing "Invalid read of size 1" when a string is passed
Mark Doliner <mark@kingant.net>
parents:
18560
diff
changeset
|
4294 if (*c == '\0') return FALSE; |
321658bf0e03
Valgrind was showing "Invalid read of size 1" when a string is passed
Mark Doliner <mark@kingant.net>
parents:
18560
diff
changeset
|
4295 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4296 /* strictly we should return false if (*(c - 1) == '.') too, but I think |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4297 * we should permit user.@domain type addresses - they do work :) */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4298 if (c == address) return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4299 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4300 /* next we validate the domain portion (name@domain) (rfc1035 & rfc1011) */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4301 if (!*(domain = ++c)) return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4302 do { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4303 if (*c == '.' && (c == domain || *(c - 1) == '.' || *(c - 1) == '-')) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4304 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4305 if (*c == '-' && *(c - 1) == '.') return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4306 if ((*c < '0' && *c != '-' && *c != '.') || (*c > '9' && *c < 'A') || |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4307 (*c > 'Z' && *c < 'a') || (*c > 'z')) return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4308 } while (*++c); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4309 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4310 if (*(c - 1) == '-') return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4311 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4312 return ((c - domain) > 3 ? TRUE : FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4313 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4314 |
22337
dc47e908965f
Use connect server as FQDN for SASL auth except when it is an IP address.
Stu Tomlinson <stu@nosnilmot.com>
parents:
22191
diff
changeset
|
4315 gboolean |
27473
1d30e9d6de9b
Added the function in util.h, forgot it here.
Paul Aurich <paul@darkrain42.org>
parents:
27469
diff
changeset
|
4316 purple_ipv4_address_is_valid(const char *ip) |
22337
dc47e908965f
Use connect server as FQDN for SASL auth except when it is an IP address.
Stu Tomlinson <stu@nosnilmot.com>
parents:
22191
diff
changeset
|
4317 { |
dc47e908965f
Use connect server as FQDN for SASL auth except when it is an IP address.
Stu Tomlinson <stu@nosnilmot.com>
parents:
22191
diff
changeset
|
4318 int c, o1, o2, o3, o4; |
dc47e908965f
Use connect server as FQDN for SASL auth except when it is an IP address.
Stu Tomlinson <stu@nosnilmot.com>
parents:
22191
diff
changeset
|
4319 char end; |
24422 | 4320 |
4321 g_return_val_if_fail(ip != NULL, FALSE); | |
4322 | |
22337
dc47e908965f
Use connect server as FQDN for SASL auth except when it is an IP address.
Stu Tomlinson <stu@nosnilmot.com>
parents:
22191
diff
changeset
|
4323 c = sscanf(ip, "%d.%d.%d.%d%c", &o1, &o2, &o3, &o4, &end); |
22354
51e740d3af3b
Fixes an error detected by valgrind:
Ka-Hing Cheung <khc@hxbc.us>
parents:
22337
diff
changeset
|
4324 if (c != 4 || o1 < 0 || o1 > 255 || o2 < 0 || o2 > 255 || o3 < 0 || o3 > 255 || o4 < 0 || o4 > 255) |
22337
dc47e908965f
Use connect server as FQDN for SASL auth except when it is an IP address.
Stu Tomlinson <stu@nosnilmot.com>
parents:
22191
diff
changeset
|
4325 return FALSE; |
dc47e908965f
Use connect server as FQDN for SASL auth except when it is an IP address.
Stu Tomlinson <stu@nosnilmot.com>
parents:
22191
diff
changeset
|
4326 return TRUE; |
dc47e908965f
Use connect server as FQDN for SASL auth except when it is an IP address.
Stu Tomlinson <stu@nosnilmot.com>
parents:
22191
diff
changeset
|
4327 } |
dc47e908965f
Use connect server as FQDN for SASL auth except when it is an IP address.
Stu Tomlinson <stu@nosnilmot.com>
parents:
22191
diff
changeset
|
4328 |
27469
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4329 gboolean |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4330 purple_ipv6_address_is_valid(const gchar *ip) |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4331 { |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4332 const gchar *c; |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4333 gboolean double_colon = FALSE; |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4334 gint chunks = 1; |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4335 gint in = 0; |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4336 |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4337 g_return_val_if_fail(ip != NULL, FALSE); |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4338 |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4339 if (*ip == '\0') |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4340 return FALSE; |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4341 |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4342 for (c = ip; *c; ++c) { |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4343 if ((*c >= '0' && *c <= '9') || |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4344 (*c >= 'a' && *c <= 'f') || |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4345 (*c >= 'A' && *c <= 'F')) { |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4346 if (++in > 4) |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4347 /* Only four hex digits per chunk */ |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4348 return FALSE; |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4349 continue; |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4350 } else if (*c == ':') { |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4351 /* The start of a new chunk */ |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4352 ++chunks; |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4353 in = 0; |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4354 if (*(c + 1) == ':') { |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4355 /* |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4356 * '::' indicates a consecutive series of chunks full |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4357 * of zeroes. There can be only one of these per address. |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4358 */ |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4359 if (double_colon) |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4360 return FALSE; |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4361 double_colon = TRUE; |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4362 } |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4363 } else |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4364 return FALSE; |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4365 } |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4366 |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4367 /* |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4368 * Either we saw a '::' and there were fewer than 8 chunks -or- |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4369 * we didn't see a '::' and saw exactly 8 chunks. |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4370 */ |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4371 return (double_colon && chunks < 8) || (!double_colon && chunks == 8); |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4372 } |
8c41a23e6b44
Add purple_ipv6_address_is_valid; guess what it does?
Paul Aurich <paul@darkrain42.org>
parents:
27448
diff
changeset
|
4373 |
27473
1d30e9d6de9b
Added the function in util.h, forgot it here.
Paul Aurich <paul@darkrain42.org>
parents:
27469
diff
changeset
|
4374 /* TODO 3.0.0: Add ipv6 check, too */ |
1d30e9d6de9b
Added the function in util.h, forgot it here.
Paul Aurich <paul@darkrain42.org>
parents:
27469
diff
changeset
|
4375 gboolean |
1d30e9d6de9b
Added the function in util.h, forgot it here.
Paul Aurich <paul@darkrain42.org>
parents:
27469
diff
changeset
|
4376 purple_ip_address_is_valid(const char *ip) |
1d30e9d6de9b
Added the function in util.h, forgot it here.
Paul Aurich <paul@darkrain42.org>
parents:
27469
diff
changeset
|
4377 { |
1d30e9d6de9b
Added the function in util.h, forgot it here.
Paul Aurich <paul@darkrain42.org>
parents:
27469
diff
changeset
|
4378 return purple_ipv4_address_is_valid(ip); |
1d30e9d6de9b
Added the function in util.h, forgot it here.
Paul Aurich <paul@darkrain42.org>
parents:
27469
diff
changeset
|
4379 } |
1d30e9d6de9b
Added the function in util.h, forgot it here.
Paul Aurich <paul@darkrain42.org>
parents:
27469
diff
changeset
|
4380 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4381 /* Stolen from gnome_uri_list_extract_uris */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4382 GList * |
15822 | 4383 purple_uri_list_extract_uris(const gchar *uri_list) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4384 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4385 const gchar *p, *q; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4386 gchar *retval; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4387 GList *result = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4388 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4389 g_return_val_if_fail (uri_list != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4390 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4391 p = uri_list; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4392 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4393 /* We don't actually try to validate the URI according to RFC |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4394 * 2396, or even check for allowed characters - we just ignore |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4395 * comments and trim whitespace off the ends. We also |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4396 * allow LF delimination as well as the specified CRLF. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4397 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4398 while (p) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4399 if (*p != '#') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4400 while (isspace(*p)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4401 p++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4402 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4403 q = p; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4404 while (*q && (*q != '\n') && (*q != '\r')) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4405 q++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4406 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4407 if (q > p) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4408 q--; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4409 while (q > p && isspace(*q)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4410 q--; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4411 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4412 retval = (gchar*)g_malloc (q - p + 2); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4413 strncpy (retval, p, q - p + 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4414 retval[q - p + 1] = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4415 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4416 result = g_list_prepend (result, retval); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4417 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4418 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4419 p = strchr (p, '\n'); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4420 if (p) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4421 p++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4422 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4423 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4424 return g_list_reverse (result); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4425 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4426 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4427 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4428 /* Stolen from gnome_uri_list_extract_filenames */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4429 GList * |
15822 | 4430 purple_uri_list_extract_filenames(const gchar *uri_list) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4431 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4432 GList *tmp_list, *node, *result; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4433 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4434 g_return_val_if_fail (uri_list != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4435 |
15822 | 4436 result = purple_uri_list_extract_uris(uri_list); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4437 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4438 tmp_list = result; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4439 while (tmp_list) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4440 gchar *s = (gchar*)tmp_list->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4441 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4442 node = tmp_list; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4443 tmp_list = tmp_list->next; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4444 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4445 if (!strncmp (s, "file:", 5)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4446 node->data = g_filename_from_uri (s, NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4447 /* not sure if this fallback is useful at all */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4448 if (!node->data) node->data = g_strdup (s+5); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4449 } else { |
22864
7d4fcb142572
Fix some potential leakage in the craziness called purple_markup_html_to_xhtml().
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22486
diff
changeset
|
4450 result = g_list_delete_link(result, node); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4451 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4452 g_free (s); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4453 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4454 return result; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4455 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4456 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4457 /************************************************************************** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4458 * UTF8 String Functions |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4459 **************************************************************************/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4460 gchar * |
15822 | 4461 purple_utf8_try_convert(const char *str) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4462 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4463 gsize converted; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4464 gchar *utf8; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4465 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4466 g_return_val_if_fail(str != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4467 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4468 if (g_utf8_validate(str, -1, NULL)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4469 return g_strdup(str); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4470 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4471 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4472 utf8 = g_locale_to_utf8(str, -1, &converted, NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4473 if (utf8 != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4474 return utf8; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4475 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4476 utf8 = g_convert(str, -1, "UTF-8", "ISO-8859-15", &converted, NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4477 if ((utf8 != NULL) && (converted == strlen(str))) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4478 return utf8; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4479 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4480 g_free(utf8); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4481 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4482 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4483 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4484 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4485 #define utf8_first(x) ((x & 0x80) == 0 || (x & 0xe0) == 0xc0 \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4486 || (x & 0xf0) == 0xe0 || (x & 0xf8) == 0xf) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4487 gchar * |
15822 | 4488 purple_utf8_salvage(const char *str) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4489 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4490 GString *workstr; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4491 const char *end; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4492 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4493 g_return_val_if_fail(str != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4494 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4495 workstr = g_string_sized_new(strlen(str)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4496 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4497 do { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4498 g_utf8_validate(str, -1, &end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4499 workstr = g_string_append_len(workstr, str, end - str); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4500 str = end; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4501 if (*str == '\0') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4502 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4503 do { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4504 workstr = g_string_append_c(workstr, '?'); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4505 str++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4506 } while (!utf8_first(*str)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4507 } while (*str != '\0'); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4508 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4509 return g_string_free(workstr, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4510 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4511 |
27019
bf9db4c67679
Add purple_utf8_strip_unprintables and use it on outgoing XMPP messages.
Paul Aurich <paul@darkrain42.org>
parents:
27012
diff
changeset
|
4512 gchar * |
bf9db4c67679
Add purple_utf8_strip_unprintables and use it on outgoing XMPP messages.
Paul Aurich <paul@darkrain42.org>
parents:
27012
diff
changeset
|
4513 purple_utf8_strip_unprintables(const gchar *str) |
bf9db4c67679
Add purple_utf8_strip_unprintables and use it on outgoing XMPP messages.
Paul Aurich <paul@darkrain42.org>
parents:
27012
diff
changeset
|
4514 { |
bf9db4c67679
Add purple_utf8_strip_unprintables and use it on outgoing XMPP messages.
Paul Aurich <paul@darkrain42.org>
parents:
27012
diff
changeset
|
4515 gchar *workstr, *iter; |
28107
0a4d0d4cf5df
Add more verbose debugging to purple_utf8_strip_unprintables.
Paul Aurich <paul@darkrain42.org>
parents:
28106
diff
changeset
|
4516 const gchar *bad; |
27019
bf9db4c67679
Add purple_utf8_strip_unprintables and use it on outgoing XMPP messages.
Paul Aurich <paul@darkrain42.org>
parents:
27012
diff
changeset
|
4517 |
27024
c59918579c3a
Strip unprintable UTF-8 characters from buddy list strings. Fixes #8776.
Paul Aurich <paul@darkrain42.org>
parents:
27019
diff
changeset
|
4518 if (str == NULL) |
c59918579c3a
Strip unprintable UTF-8 characters from buddy list strings. Fixes #8776.
Paul Aurich <paul@darkrain42.org>
parents:
27019
diff
changeset
|
4519 /* Act like g_strdup */ |
c59918579c3a
Strip unprintable UTF-8 characters from buddy list strings. Fixes #8776.
Paul Aurich <paul@darkrain42.org>
parents:
27019
diff
changeset
|
4520 return NULL; |
c59918579c3a
Strip unprintable UTF-8 characters from buddy list strings. Fixes #8776.
Paul Aurich <paul@darkrain42.org>
parents:
27019
diff
changeset
|
4521 |
28108
6b018d1efc5c
Oops, I think it's either sleep or coffee time.
Paul Aurich <paul@darkrain42.org>
parents:
28107
diff
changeset
|
4522 if (!g_utf8_validate(str, -1, &bad)) { |
28107
0a4d0d4cf5df
Add more verbose debugging to purple_utf8_strip_unprintables.
Paul Aurich <paul@darkrain42.org>
parents:
28106
diff
changeset
|
4523 purple_debug_error("util", "purple_utf8_strip_unprintables(%s) failed; " |
0a4d0d4cf5df
Add more verbose debugging to purple_utf8_strip_unprintables.
Paul Aurich <paul@darkrain42.org>
parents:
28106
diff
changeset
|
4524 "first bad character was %02x (%c)\n", |
0a4d0d4cf5df
Add more verbose debugging to purple_utf8_strip_unprintables.
Paul Aurich <paul@darkrain42.org>
parents:
28106
diff
changeset
|
4525 str, *bad, *bad); |
0a4d0d4cf5df
Add more verbose debugging to purple_utf8_strip_unprintables.
Paul Aurich <paul@darkrain42.org>
parents:
28106
diff
changeset
|
4526 g_return_val_if_reached(NULL); |
0a4d0d4cf5df
Add more verbose debugging to purple_utf8_strip_unprintables.
Paul Aurich <paul@darkrain42.org>
parents:
28106
diff
changeset
|
4527 } |
27019
bf9db4c67679
Add purple_utf8_strip_unprintables and use it on outgoing XMPP messages.
Paul Aurich <paul@darkrain42.org>
parents:
27012
diff
changeset
|
4528 |
bf9db4c67679
Add purple_utf8_strip_unprintables and use it on outgoing XMPP messages.
Paul Aurich <paul@darkrain42.org>
parents:
27012
diff
changeset
|
4529 workstr = iter = g_new(gchar, strlen(str) + 1); |
28101
c9c038529f38
Hmm, g_unichar_isgraph is too restrictive in the characters allowed (it munges \t). Change purple_utf8_strip_unprintables to simply remove ASCII control characters instead.
Paul Aurich <paul@darkrain42.org>
parents:
27936
diff
changeset
|
4530 for ( ; *str; ++str) { |
28153
10c28fac798d
gah, signed comparison meant this was stripping all multibyte UTF-8 characters.
Paul Aurich <paul@darkrain42.org>
parents:
28123
diff
changeset
|
4531 guchar c = *str; |
10c28fac798d
gah, signed comparison meant this was stripping all multibyte UTF-8 characters.
Paul Aurich <paul@darkrain42.org>
parents:
28123
diff
changeset
|
4532 if (c >= 0x20 || c == '\t' || c == '\n' || c == '\r') { |
10c28fac798d
gah, signed comparison meant this was stripping all multibyte UTF-8 characters.
Paul Aurich <paul@darkrain42.org>
parents:
28123
diff
changeset
|
4533 *iter = c; |
28101
c9c038529f38
Hmm, g_unichar_isgraph is too restrictive in the characters allowed (it munges \t). Change purple_utf8_strip_unprintables to simply remove ASCII control characters instead.
Paul Aurich <paul@darkrain42.org>
parents:
27936
diff
changeset
|
4534 ++iter; |
27019
bf9db4c67679
Add purple_utf8_strip_unprintables and use it on outgoing XMPP messages.
Paul Aurich <paul@darkrain42.org>
parents:
27012
diff
changeset
|
4535 } |
bf9db4c67679
Add purple_utf8_strip_unprintables and use it on outgoing XMPP messages.
Paul Aurich <paul@darkrain42.org>
parents:
27012
diff
changeset
|
4536 } |
bf9db4c67679
Add purple_utf8_strip_unprintables and use it on outgoing XMPP messages.
Paul Aurich <paul@darkrain42.org>
parents:
27012
diff
changeset
|
4537 |
bf9db4c67679
Add purple_utf8_strip_unprintables and use it on outgoing XMPP messages.
Paul Aurich <paul@darkrain42.org>
parents:
27012
diff
changeset
|
4538 /* nul-terminate the new string */ |
bf9db4c67679
Add purple_utf8_strip_unprintables and use it on outgoing XMPP messages.
Paul Aurich <paul@darkrain42.org>
parents:
27012
diff
changeset
|
4539 *iter = '\0'; |
bf9db4c67679
Add purple_utf8_strip_unprintables and use it on outgoing XMPP messages.
Paul Aurich <paul@darkrain42.org>
parents:
27012
diff
changeset
|
4540 |
bf9db4c67679
Add purple_utf8_strip_unprintables and use it on outgoing XMPP messages.
Paul Aurich <paul@darkrain42.org>
parents:
27012
diff
changeset
|
4541 return workstr; |
bf9db4c67679
Add purple_utf8_strip_unprintables and use it on outgoing XMPP messages.
Paul Aurich <paul@darkrain42.org>
parents:
27012
diff
changeset
|
4542 } |
bf9db4c67679
Add purple_utf8_strip_unprintables and use it on outgoing XMPP messages.
Paul Aurich <paul@darkrain42.org>
parents:
27012
diff
changeset
|
4543 |
21863
7e833250a0ef
Add a comment that I took this from glib
Mark Doliner <mark@kingant.net>
parents:
21862
diff
changeset
|
4544 /* |
7e833250a0ef
Add a comment that I took this from glib
Mark Doliner <mark@kingant.net>
parents:
21862
diff
changeset
|
4545 * This function is copied from g_strerror() but changed to use |
7e833250a0ef
Add a comment that I took this from glib
Mark Doliner <mark@kingant.net>
parents:
21862
diff
changeset
|
4546 * gai_strerror(). |
7e833250a0ef
Add a comment that I took this from glib
Mark Doliner <mark@kingant.net>
parents:
21862
diff
changeset
|
4547 */ |
21862
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4548 G_CONST_RETURN gchar * |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4549 purple_gai_strerror(gint errnum) |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4550 { |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4551 static GStaticPrivate msg_private = G_STATIC_PRIVATE_INIT; |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4552 char *msg; |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4553 int saved_errno = errno; |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4554 |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4555 const char *msg_locale; |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4556 |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4557 msg_locale = gai_strerror(errnum); |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4558 if (g_get_charset(NULL)) |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4559 { |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4560 /* This string is already UTF-8--great! */ |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4561 errno = saved_errno; |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4562 return msg_locale; |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4563 } |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4564 else |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4565 { |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4566 gchar *msg_utf8 = g_locale_to_utf8(msg_locale, -1, NULL, NULL, NULL); |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4567 if (msg_utf8) |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4568 { |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4569 /* Stick in the quark table so that we can return a static result */ |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4570 GQuark msg_quark = g_quark_from_string(msg_utf8); |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4571 g_free(msg_utf8); |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4572 |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4573 msg_utf8 = (gchar *)g_quark_to_string(msg_quark); |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4574 errno = saved_errno; |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4575 return msg_utf8; |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4576 } |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4577 } |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4578 |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4579 msg = g_static_private_get(&msg_private); |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4580 if (!msg) |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4581 { |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4582 msg = g_new(gchar, 64); |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4583 g_static_private_set(&msg_private, msg, g_free); |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4584 } |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4585 |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4586 sprintf(msg, "unknown error (%d)", errnum); |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4587 |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4588 errno = saved_errno; |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4589 return msg; |
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21794
diff
changeset
|
4590 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4591 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4592 char * |
15822 | 4593 purple_utf8_ncr_encode(const char *str) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4594 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4595 GString *out; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4596 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4597 g_return_val_if_fail(str != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4598 g_return_val_if_fail(g_utf8_validate(str, -1, NULL), NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4599 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4600 out = g_string_new(""); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4601 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4602 for(; *str; str = g_utf8_next_char(str)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4603 gunichar wc = g_utf8_get_char(str); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4604 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4605 /* super simple check. hopefully not too wrong. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4606 if(wc >= 0x80) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4607 g_string_append_printf(out, "&#%u;", (guint32) wc); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4608 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4609 g_string_append_unichar(out, wc); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4610 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4611 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4612 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4613 return g_string_free(out, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4614 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4615 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4616 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4617 char * |
15822 | 4618 purple_utf8_ncr_decode(const char *str) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4619 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4620 GString *out; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4621 char *buf, *b; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4622 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4623 g_return_val_if_fail(str != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4624 g_return_val_if_fail(g_utf8_validate(str, -1, NULL), NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4625 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4626 buf = (char *) str; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4627 out = g_string_new(""); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4628 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4629 while( (b = strstr(buf, "&#")) ) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4630 gunichar wc; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4631 int base = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4632 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4633 /* append everything leading up to the &# */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4634 g_string_append_len(out, buf, b-buf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4635 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4636 b += 2; /* skip past the &# */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4637 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4638 /* strtoul will treat 0x prefix as hex, but not just x */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4639 if(*b == 'x' || *b == 'X') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4640 base = 16; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4641 b++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4642 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4643 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4644 /* advances buf to the end of the ncr segment */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4645 wc = (gunichar) strtoul(b, &buf, base); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4646 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4647 /* this mimics the previous impl of ncr_decode */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4648 if(*buf == ';') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4649 g_string_append_unichar(out, wc); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4650 buf++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4651 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4652 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4653 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4654 /* append whatever's left */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4655 g_string_append(out, buf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4656 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4657 return g_string_free(out, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4658 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4659 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4660 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4661 int |
15822 | 4662 purple_utf8_strcasecmp(const char *a, const char *b) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4663 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4664 char *a_norm = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4665 char *b_norm = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4666 int ret = -1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4667 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4668 if(!a && b) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4669 return -1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4670 else if(!b && a) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4671 return 1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4672 else if(!a && !b) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4673 return 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4674 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4675 if(!g_utf8_validate(a, -1, NULL) || !g_utf8_validate(b, -1, NULL)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4676 { |
15822 | 4677 purple_debug_error("purple_utf8_strcasecmp", |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4678 "One or both parameters are invalid UTF8\n"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4679 return ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4680 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4681 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4682 a_norm = g_utf8_casefold(a, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4683 b_norm = g_utf8_casefold(b, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4684 ret = g_utf8_collate(a_norm, b_norm); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4685 g_free(a_norm); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4686 g_free(b_norm); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4687 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4688 return ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4689 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4690 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4691 /* previously conversation::find_nick() */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4692 gboolean |
15822 | 4693 purple_utf8_has_word(const char *haystack, const char *needle) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4694 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4695 char *hay, *pin, *p; |
24841
e7b27ee5e7b6
Make purple_utf8_has_word() better about detecting word boundaries (still not
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24592
diff
changeset
|
4696 const char *start, *prev_char; |
e7b27ee5e7b6
Make purple_utf8_has_word() better about detecting word boundaries (still not
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24592
diff
changeset
|
4697 gunichar before, after; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4698 int n; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4699 gboolean ret = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4700 |
24841
e7b27ee5e7b6
Make purple_utf8_has_word() better about detecting word boundaries (still not
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24592
diff
changeset
|
4701 start = hay = g_utf8_strdown(haystack, -1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4702 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4703 pin = g_utf8_strdown(needle, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4704 n = strlen(pin); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4705 |
24841
e7b27ee5e7b6
Make purple_utf8_has_word() better about detecting word boundaries (still not
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24592
diff
changeset
|
4706 while ((p = strstr(start, pin)) != NULL) { |
e7b27ee5e7b6
Make purple_utf8_has_word() better about detecting word boundaries (still not
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24592
diff
changeset
|
4707 prev_char = g_utf8_find_prev_char(hay, p); |
e7b27ee5e7b6
Make purple_utf8_has_word() better about detecting word boundaries (still not
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24592
diff
changeset
|
4708 before = -2; |
e7b27ee5e7b6
Make purple_utf8_has_word() better about detecting word boundaries (still not
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24592
diff
changeset
|
4709 if (prev_char) { |
e7b27ee5e7b6
Make purple_utf8_has_word() better about detecting word boundaries (still not
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24592
diff
changeset
|
4710 before = g_utf8_get_char(prev_char); |
e7b27ee5e7b6
Make purple_utf8_has_word() better about detecting word boundaries (still not
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24592
diff
changeset
|
4711 } |
e7b27ee5e7b6
Make purple_utf8_has_word() better about detecting word boundaries (still not
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24592
diff
changeset
|
4712 after = g_utf8_get_char_validated(p + n, - 1); |
e7b27ee5e7b6
Make purple_utf8_has_word() better about detecting word boundaries (still not
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24592
diff
changeset
|
4713 |
e7b27ee5e7b6
Make purple_utf8_has_word() better about detecting word boundaries (still not
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24592
diff
changeset
|
4714 if ((p == hay || |
e7b27ee5e7b6
Make purple_utf8_has_word() better about detecting word boundaries (still not
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24592
diff
changeset
|
4715 /* The character before is a reasonable guess for a word boundary |
e7b27ee5e7b6
Make purple_utf8_has_word() better about detecting word boundaries (still not
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24592
diff
changeset
|
4716 ("!g_unichar_isalnum()" is not a valid way to determine word |
e7b27ee5e7b6
Make purple_utf8_has_word() better about detecting word boundaries (still not
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24592
diff
changeset
|
4717 boundaries, but it is the only reasonable thing to do here), |
e7b27ee5e7b6
Make purple_utf8_has_word() better about detecting word boundaries (still not
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24592
diff
changeset
|
4718 and isn't the '&' from a "&" or some such entity*/ |
e7b27ee5e7b6
Make purple_utf8_has_word() better about detecting word boundaries (still not
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24592
diff
changeset
|
4719 (before != -2 && !g_unichar_isalnum(before) && *(p - 1) != '&')) |
e7b27ee5e7b6
Make purple_utf8_has_word() better about detecting word boundaries (still not
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24592
diff
changeset
|
4720 && after != -2 && !g_unichar_isalnum(after)) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4721 ret = TRUE; |
24841
e7b27ee5e7b6
Make purple_utf8_has_word() better about detecting word boundaries (still not
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24592
diff
changeset
|
4722 break; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4723 } |
24841
e7b27ee5e7b6
Make purple_utf8_has_word() better about detecting word boundaries (still not
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24592
diff
changeset
|
4724 start = p + 1; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4725 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4726 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4727 g_free(pin); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4728 g_free(hay); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4729 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4730 return ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4731 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4732 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4733 void |
15822 | 4734 purple_print_utf8_to_console(FILE *filestream, char *message) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4735 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4736 gchar *message_conv; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4737 GError *error = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4738 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4739 /* Try to convert 'message' to user's locale */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4740 message_conv = g_locale_from_utf8(message, -1, NULL, NULL, &error); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4741 if (message_conv != NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4742 fputs(message_conv, filestream); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4743 g_free(message_conv); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4744 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4745 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4746 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4747 /* use 'message' as a fallback */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4748 g_warning("%s\n", error->message); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4749 g_error_free(error); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4750 fputs(message, filestream); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4751 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4752 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4753 |
19408
cc36a5aac908
Fix some conversion warnings about using negative values with unsigned types. There are more, but these were easy fixes. You may think that I'm changing the API, but I'm really not - it was just wrong.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19262
diff
changeset
|
4754 gboolean purple_message_meify(char *message, gssize len) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4755 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4756 char *c; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4757 gboolean inside_html = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4758 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4759 g_return_val_if_fail(message != NULL, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4760 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4761 if(len == -1) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4762 len = strlen(message); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4763 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4764 for (c = message; *c; c++, len--) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4765 if(inside_html) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4766 if(*c == '>') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4767 inside_html = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4768 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4769 if(*c == '<') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4770 inside_html = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4771 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4772 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4773 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4774 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4775 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4776 if(*c && !g_ascii_strncasecmp(c, "/me ", 4)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4777 memmove(c, c+4, len-3); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4778 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4779 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4780 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4781 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4782 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4783 |
15822 | 4784 char *purple_text_strip_mnemonic(const char *in) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4785 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4786 char *out; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4787 char *a; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4788 char *a0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4789 const char *b; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4790 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4791 g_return_val_if_fail(in != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4792 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4793 out = g_malloc(strlen(in)+1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4794 a = out; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4795 b = in; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4796 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4797 a0 = a; /* The last non-space char seen so far, or the first char */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4798 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4799 while(*b) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4800 if(*b == '_') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4801 if(a > out && b > in && *(b-1) == '(' && *(b+1) && !(*(b+1) & 0x80) && *(b+2) == ')') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4802 /* Detected CJK style shortcut (Bug 875311) */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4803 a = a0; /* undo the left parenthesis */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4804 b += 3; /* and skip the whole mess */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4805 } else if(*(b+1) == '_') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4806 *(a++) = '_'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4807 b += 2; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4808 a0 = a; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4809 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4810 b++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4811 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4812 /* We don't want to corrupt the middle of UTF-8 characters */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4813 } else if (!(*b & 0x80)) { /* other 1-byte char */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4814 if (*b != ' ') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4815 a0 = a; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4816 *(a++) = *(b++); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4817 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4818 /* Multibyte utf8 char, don't look for _ inside these */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4819 int n = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4820 int i; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4821 if ((*b & 0xe0) == 0xc0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4822 n = 2; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4823 } else if ((*b & 0xf0) == 0xe0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4824 n = 3; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4825 } else if ((*b & 0xf8) == 0xf0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4826 n = 4; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4827 } else if ((*b & 0xfc) == 0xf8) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4828 n = 5; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4829 } else if ((*b & 0xfe) == 0xfc) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4830 n = 6; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4831 } else { /* Illegal utf8 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4832 n = 1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4833 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4834 a0 = a; /* unless we want to delete CJK spaces too */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4835 for (i = 0; i < n && *b; i += 1) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4836 *(a++) = *(b++); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4837 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4838 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4839 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4840 *a = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4841 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4842 return out; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4843 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4844 |
15822 | 4845 const char* purple_unescape_filename(const char *escaped) { |
4846 return purple_url_decode(escaped); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4847 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4848 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4849 |
15822 | 4850 /* this is almost identical to purple_url_encode (hence purple_url_decode |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4851 * being used above), but we want to keep certain characters unescaped |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4852 * for compat reasons */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4853 const char * |
15822 | 4854 purple_escape_filename(const char *str) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4855 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4856 const char *iter; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4857 static char buf[BUF_LEN]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4858 char utf_char[6]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4859 guint i, j = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4860 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4861 g_return_val_if_fail(str != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4862 g_return_val_if_fail(g_utf8_validate(str, -1, NULL), NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4863 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4864 iter = str; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4865 for (; *iter && j < (BUF_LEN - 1) ; iter = g_utf8_next_char(iter)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4866 gunichar c = g_utf8_get_char(iter); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4867 /* If the character is an ASCII character and is alphanumeric, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4868 * or one of the specified values, no need to escape */ |
17161
51f8dac490d7
If we're operating on ASCII characters only, we should use g_ascii_isalnum.
Richard Laager <rlaager@wiktel.com>
parents:
17158
diff
changeset
|
4869 if (c < 128 && (g_ascii_isalnum(c) || c == '@' || c == '-' || |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4870 c == '_' || c == '.' || c == '#')) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4871 buf[j++] = c; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4872 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4873 int bytes = g_unichar_to_utf8(c, utf_char); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4874 for (i = 0; i < bytes; i++) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4875 if (j > (BUF_LEN - 4)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4876 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4877 sprintf(buf + j, "%%%02x", utf_char[i] & 0xff); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4878 j += 3; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4879 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4880 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4881 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4882 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4883 buf[j] = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4884 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4885 return buf; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4886 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4887 |
15822 | 4888 const char *_purple_oscar_convert(const char *act, const char *protocol) |
15420
6d8728fd3dda
Make sure the pounces, buddy-aliases, savedstatuses etc. saved before the aim/icq split works after the split. The util function _gaim_oscar_convert will be removed at a 'suitable' time in the future.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15398
diff
changeset
|
4889 { |
25894
a6e3cb32cdd2
Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code. Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us
Paul Aurich <paul@darkrain42.org>
parents:
25890
diff
changeset
|
4890 if (act && purple_strequal(protocol, "prpl-oscar")) { |
19603
79d624f7c3ee
You can't just look at the first letter of the screen name to determine
Mark Doliner <mark@kingant.net>
parents:
19499
diff
changeset
|
4891 int i; |
79d624f7c3ee
You can't just look at the first letter of the screen name to determine
Mark Doliner <mark@kingant.net>
parents:
19499
diff
changeset
|
4892 for (i = 0; act[i] != '\0'; i++) |
79d624f7c3ee
You can't just look at the first letter of the screen name to determine
Mark Doliner <mark@kingant.net>
parents:
19499
diff
changeset
|
4893 if (!isdigit(act[i])) |
79d624f7c3ee
You can't just look at the first letter of the screen name to determine
Mark Doliner <mark@kingant.net>
parents:
19499
diff
changeset
|
4894 return "prpl-aim"; |
79d624f7c3ee
You can't just look at the first letter of the screen name to determine
Mark Doliner <mark@kingant.net>
parents:
19499
diff
changeset
|
4895 return "prpl-icq"; |
15420
6d8728fd3dda
Make sure the pounces, buddy-aliases, savedstatuses etc. saved before the aim/icq split works after the split. The util function _gaim_oscar_convert will be removed at a 'suitable' time in the future.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15398
diff
changeset
|
4896 } |
6d8728fd3dda
Make sure the pounces, buddy-aliases, savedstatuses etc. saved before the aim/icq split works after the split. The util function _gaim_oscar_convert will be removed at a 'suitable' time in the future.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15398
diff
changeset
|
4897 return protocol; |
6d8728fd3dda
Make sure the pounces, buddy-aliases, savedstatuses etc. saved before the aim/icq split works after the split. The util function _gaim_oscar_convert will be removed at a 'suitable' time in the future.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15398
diff
changeset
|
4898 } |
6d8728fd3dda
Make sure the pounces, buddy-aliases, savedstatuses etc. saved before the aim/icq split works after the split. The util function _gaim_oscar_convert will be removed at a 'suitable' time in the future.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15398
diff
changeset
|
4899 |
15822 | 4900 void purple_restore_default_signal_handlers(void) |
15645
61b42cf81aa4
Restore default signal handlers in fork()'d children. This adds a gaim_restore_default_signal_handlers() utility function since children are made in multiple places.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15612
diff
changeset
|
4901 { |
15664
95c4dee525f0
Merge fix and build fix for win32
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15663
diff
changeset
|
4902 #ifndef _WIN32 |
15645
61b42cf81aa4
Restore default signal handlers in fork()'d children. This adds a gaim_restore_default_signal_handlers() utility function since children are made in multiple places.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15612
diff
changeset
|
4903 #ifdef HAVE_SIGNAL_H |
61b42cf81aa4
Restore default signal handlers in fork()'d children. This adds a gaim_restore_default_signal_handlers() utility function since children are made in multiple places.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15612
diff
changeset
|
4904 signal(SIGHUP, SIG_DFL); /* 1: terminal line hangup */ |
61b42cf81aa4
Restore default signal handlers in fork()'d children. This adds a gaim_restore_default_signal_handlers() utility function since children are made in multiple places.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15612
diff
changeset
|
4905 signal(SIGINT, SIG_DFL); /* 2: interrupt program */ |
61b42cf81aa4
Restore default signal handlers in fork()'d children. This adds a gaim_restore_default_signal_handlers() utility function since children are made in multiple places.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15612
diff
changeset
|
4906 signal(SIGQUIT, SIG_DFL); /* 3: quit program */ |
61b42cf81aa4
Restore default signal handlers in fork()'d children. This adds a gaim_restore_default_signal_handlers() utility function since children are made in multiple places.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15612
diff
changeset
|
4907 signal(SIGILL, SIG_DFL); /* 4: illegal instruction (not reset when caught) */ |
61b42cf81aa4
Restore default signal handlers in fork()'d children. This adds a gaim_restore_default_signal_handlers() utility function since children are made in multiple places.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15612
diff
changeset
|
4908 signal(SIGTRAP, SIG_DFL); /* 5: trace trap (not reset when caught) */ |
61b42cf81aa4
Restore default signal handlers in fork()'d children. This adds a gaim_restore_default_signal_handlers() utility function since children are made in multiple places.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15612
diff
changeset
|
4909 signal(SIGABRT, SIG_DFL); /* 6: abort program */ |
15661
80944a182710
SIGEMT is not available on non-POSIX systems; SIGPOLL is present, instead. Thanks to Richard for catching this.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15645
diff
changeset
|
4910 |
80944a182710
SIGEMT is not available on non-POSIX systems; SIGPOLL is present, instead. Thanks to Richard for catching this.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15645
diff
changeset
|
4911 #ifdef SIGPOLL |
16487
b8b2e35ec7c6
Fix purple_util_get_image_extension()'s data param. to be correctly marked as constant.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
16475
diff
changeset
|
4912 signal(SIGPOLL, SIG_DFL); /* 7: pollable event (POSIX) */ |
15661
80944a182710
SIGEMT is not available on non-POSIX systems; SIGPOLL is present, instead. Thanks to Richard for catching this.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15645
diff
changeset
|
4913 #endif /* SIGPOLL */ |
80944a182710
SIGEMT is not available on non-POSIX systems; SIGPOLL is present, instead. Thanks to Richard for catching this.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15645
diff
changeset
|
4914 |
80944a182710
SIGEMT is not available on non-POSIX systems; SIGPOLL is present, instead. Thanks to Richard for catching this.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15645
diff
changeset
|
4915 #ifdef SIGEMT |
80944a182710
SIGEMT is not available on non-POSIX systems; SIGPOLL is present, instead. Thanks to Richard for catching this.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15645
diff
changeset
|
4916 signal(SIGEMT, SIG_DFL); /* 7: EMT instruction (Non-POSIX) */ |
80944a182710
SIGEMT is not available on non-POSIX systems; SIGPOLL is present, instead. Thanks to Richard for catching this.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15645
diff
changeset
|
4917 #endif /* SIGEMT */ |
80944a182710
SIGEMT is not available on non-POSIX systems; SIGPOLL is present, instead. Thanks to Richard for catching this.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15645
diff
changeset
|
4918 |
15645
61b42cf81aa4
Restore default signal handlers in fork()'d children. This adds a gaim_restore_default_signal_handlers() utility function since children are made in multiple places.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15612
diff
changeset
|
4919 signal(SIGFPE, SIG_DFL); /* 8: floating point exception */ |
61b42cf81aa4
Restore default signal handlers in fork()'d children. This adds a gaim_restore_default_signal_handlers() utility function since children are made in multiple places.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15612
diff
changeset
|
4920 signal(SIGBUS, SIG_DFL); /* 10: bus error */ |
61b42cf81aa4
Restore default signal handlers in fork()'d children. This adds a gaim_restore_default_signal_handlers() utility function since children are made in multiple places.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15612
diff
changeset
|
4921 signal(SIGSEGV, SIG_DFL); /* 11: segmentation violation */ |
61b42cf81aa4
Restore default signal handlers in fork()'d children. This adds a gaim_restore_default_signal_handlers() utility function since children are made in multiple places.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15612
diff
changeset
|
4922 signal(SIGSYS, SIG_DFL); /* 12: bad argument to system call */ |
61b42cf81aa4
Restore default signal handlers in fork()'d children. This adds a gaim_restore_default_signal_handlers() utility function since children are made in multiple places.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15612
diff
changeset
|
4923 signal(SIGPIPE, SIG_DFL); /* 13: write on a pipe with no reader */ |
61b42cf81aa4
Restore default signal handlers in fork()'d children. This adds a gaim_restore_default_signal_handlers() utility function since children are made in multiple places.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15612
diff
changeset
|
4924 signal(SIGALRM, SIG_DFL); /* 14: real-time timer expired */ |
61b42cf81aa4
Restore default signal handlers in fork()'d children. This adds a gaim_restore_default_signal_handlers() utility function since children are made in multiple places.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15612
diff
changeset
|
4925 signal(SIGTERM, SIG_DFL); /* 15: software termination signal */ |
61b42cf81aa4
Restore default signal handlers in fork()'d children. This adds a gaim_restore_default_signal_handlers() utility function since children are made in multiple places.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15612
diff
changeset
|
4926 signal(SIGCHLD, SIG_DFL); /* 20: child status has changed */ |
61b42cf81aa4
Restore default signal handlers in fork()'d children. This adds a gaim_restore_default_signal_handlers() utility function since children are made in multiple places.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15612
diff
changeset
|
4927 signal(SIGXCPU, SIG_DFL); /* 24: exceeded CPU time limit */ |
16487
b8b2e35ec7c6
Fix purple_util_get_image_extension()'s data param. to be correctly marked as constant.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
16475
diff
changeset
|
4928 signal(SIGXFSZ, SIG_DFL); /* 25: exceeded file size limit */ |
15661
80944a182710
SIGEMT is not available on non-POSIX systems; SIGPOLL is present, instead. Thanks to Richard for catching this.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15645
diff
changeset
|
4929 #endif /* HAVE_SIGNAL_H */ |
15664
95c4dee525f0
Merge fix and build fix for win32
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15663
diff
changeset
|
4930 #endif /* !_WIN32 */ |
15645
61b42cf81aa4
Restore default signal handlers in fork()'d children. This adds a gaim_restore_default_signal_handlers() utility function since children are made in multiple places.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15612
diff
changeset
|
4931 } |
22000
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4932 |
22089
1e227e2587e6
Make setting 'now listening' actually work, thanks to khc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22060
diff
changeset
|
4933 static void |
1e227e2587e6
Make setting 'now listening' actually work, thanks to khc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22060
diff
changeset
|
4934 set_status_with_attrs(PurpleStatus *status, ...) |
1e227e2587e6
Make setting 'now listening' actually work, thanks to khc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22060
diff
changeset
|
4935 { |
1e227e2587e6
Make setting 'now listening' actually work, thanks to khc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22060
diff
changeset
|
4936 va_list args; |
1e227e2587e6
Make setting 'now listening' actually work, thanks to khc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22060
diff
changeset
|
4937 va_start(args, status); |
1e227e2587e6
Make setting 'now listening' actually work, thanks to khc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22060
diff
changeset
|
4938 purple_status_set_active_with_attrs(status, TRUE, args); |
1e227e2587e6
Make setting 'now listening' actually work, thanks to khc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22060
diff
changeset
|
4939 va_end(args); |
1e227e2587e6
Make setting 'now listening' actually work, thanks to khc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22060
diff
changeset
|
4940 } |
1e227e2587e6
Make setting 'now listening' actually work, thanks to khc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22060
diff
changeset
|
4941 |
22000
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4942 void purple_util_set_current_song(const char *title, const char *artist, const char *album) |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4943 { |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4944 GList *list = purple_accounts_get_all(); |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4945 for (; list; list = list->next) { |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4946 PurplePresence *presence; |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4947 PurpleStatus *tune; |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4948 PurpleAccount *account = list->data; |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4949 if (!purple_account_get_enabled(account, purple_core_get_ui())) |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4950 continue; |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4951 |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4952 presence = purple_account_get_presence(account); |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4953 tune = purple_presence_get_status(presence, "tune"); |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4954 if (!tune) |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4955 continue; |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4956 if (title) { |
22089
1e227e2587e6
Make setting 'now listening' actually work, thanks to khc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22060
diff
changeset
|
4957 set_status_with_attrs(tune, |
1e227e2587e6
Make setting 'now listening' actually work, thanks to khc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22060
diff
changeset
|
4958 PURPLE_TUNE_TITLE, title, |
1e227e2587e6
Make setting 'now listening' actually work, thanks to khc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22060
diff
changeset
|
4959 PURPLE_TUNE_ARTIST, artist, |
1e227e2587e6
Make setting 'now listening' actually work, thanks to khc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22060
diff
changeset
|
4960 PURPLE_TUNE_ALBUM, album, |
1e227e2587e6
Make setting 'now listening' actually work, thanks to khc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22060
diff
changeset
|
4961 NULL); |
22000
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4962 } else { |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4963 purple_status_set_active(tune, FALSE); |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4964 } |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4965 } |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4966 } |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4967 |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4968 char * purple_util_format_song_info(const char *title, const char *artist, const char *album, gpointer unused) |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4969 { |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4970 GString *string; |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4971 char *esc; |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4972 |
22060
83613550512b
Ignore both NULL and empty strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22000
diff
changeset
|
4973 if (!title || !*title) |
22000
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4974 return NULL; |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4975 |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4976 esc = g_markup_escape_text(title, -1); |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4977 string = g_string_new(""); |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4978 g_string_append_printf(string, "%s", esc); |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4979 g_free(esc); |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4980 |
22060
83613550512b
Ignore both NULL and empty strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22000
diff
changeset
|
4981 if (artist && *artist) { |
22000
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4982 esc = g_markup_escape_text(artist, -1); |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4983 g_string_append_printf(string, _(" - %s"), esc); |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4984 g_free(esc); |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4985 } |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4986 |
22060
83613550512b
Ignore both NULL and empty strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22000
diff
changeset
|
4987 if (album && *album) { |
22000
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4988 esc = g_markup_escape_text(album, -1); |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4989 g_string_append_printf(string, _(" (%s)"), esc); |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4990 g_free(esc); |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4991 } |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4992 |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4993 return g_string_free(string, FALSE); |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4994 } |
af0426c34c27
Utility functions to set and format song information. Closes #4398.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21863
diff
changeset
|
4995 |
23538
399975ad001c
Add purple_get_host_name to get the hostname of the machine.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23388
diff
changeset
|
4996 const gchar * |
399975ad001c
Add purple_get_host_name to get the hostname of the machine.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23388
diff
changeset
|
4997 purple_get_host_name(void) |
399975ad001c
Add purple_get_host_name to get the hostname of the machine.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23388
diff
changeset
|
4998 { |
399975ad001c
Add purple_get_host_name to get the hostname of the machine.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23388
diff
changeset
|
4999 return g_get_host_name(); |
399975ad001c
Add purple_get_host_name to get the hostname of the machine.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23388
diff
changeset
|
5000 } |
29129
ecd2136ff818
Broke out the generation of random UUIDs to its own function
Marcus Lundblad <ml@update.uu.se>
parents:
29110
diff
changeset
|
5001 |
ecd2136ff818
Broke out the generation of random UUIDs to its own function
Marcus Lundblad <ml@update.uu.se>
parents:
29110
diff
changeset
|
5002 gchar * |
ecd2136ff818
Broke out the generation of random UUIDs to its own function
Marcus Lundblad <ml@update.uu.se>
parents:
29110
diff
changeset
|
5003 purple_uuid_random(void) |
ecd2136ff818
Broke out the generation of random UUIDs to its own function
Marcus Lundblad <ml@update.uu.se>
parents:
29110
diff
changeset
|
5004 { |
ecd2136ff818
Broke out the generation of random UUIDs to its own function
Marcus Lundblad <ml@update.uu.se>
parents:
29110
diff
changeset
|
5005 guint32 tmp, a, b; |
ecd2136ff818
Broke out the generation of random UUIDs to its own function
Marcus Lundblad <ml@update.uu.se>
parents:
29110
diff
changeset
|
5006 |
ecd2136ff818
Broke out the generation of random UUIDs to its own function
Marcus Lundblad <ml@update.uu.se>
parents:
29110
diff
changeset
|
5007 tmp = g_random_int(); |
ecd2136ff818
Broke out the generation of random UUIDs to its own function
Marcus Lundblad <ml@update.uu.se>
parents:
29110
diff
changeset
|
5008 a = 0x4000 | (tmp & 0xFFF); /* 0x4000 to 0x4FFF */ |
ecd2136ff818
Broke out the generation of random UUIDs to its own function
Marcus Lundblad <ml@update.uu.se>
parents:
29110
diff
changeset
|
5009 tmp >>= 12; |
ecd2136ff818
Broke out the generation of random UUIDs to its own function
Marcus Lundblad <ml@update.uu.se>
parents:
29110
diff
changeset
|
5010 b = ((1 << 3) << 12) | (tmp & 0x3FFF); /* 0x8000 to 0xBFFF */ |
ecd2136ff818
Broke out the generation of random UUIDs to its own function
Marcus Lundblad <ml@update.uu.se>
parents:
29110
diff
changeset
|
5011 |
ecd2136ff818
Broke out the generation of random UUIDs to its own function
Marcus Lundblad <ml@update.uu.se>
parents:
29110
diff
changeset
|
5012 tmp = g_random_int(); |
ecd2136ff818
Broke out the generation of random UUIDs to its own function
Marcus Lundblad <ml@update.uu.se>
parents:
29110
diff
changeset
|
5013 |
ecd2136ff818
Broke out the generation of random UUIDs to its own function
Marcus Lundblad <ml@update.uu.se>
parents:
29110
diff
changeset
|
5014 return g_strdup_printf("%08x-%04x-%04x-%04x-%04x%08x", |
ecd2136ff818
Broke out the generation of random UUIDs to its own function
Marcus Lundblad <ml@update.uu.se>
parents:
29110
diff
changeset
|
5015 g_random_int(), |
ecd2136ff818
Broke out the generation of random UUIDs to its own function
Marcus Lundblad <ml@update.uu.se>
parents:
29110
diff
changeset
|
5016 tmp & 0xFFFF, |
ecd2136ff818
Broke out the generation of random UUIDs to its own function
Marcus Lundblad <ml@update.uu.se>
parents:
29110
diff
changeset
|
5017 a, |
ecd2136ff818
Broke out the generation of random UUIDs to its own function
Marcus Lundblad <ml@update.uu.se>
parents:
29110
diff
changeset
|
5018 b, |
ecd2136ff818
Broke out the generation of random UUIDs to its own function
Marcus Lundblad <ml@update.uu.se>
parents:
29110
diff
changeset
|
5019 (tmp >> 16) & 0xFFFF, g_random_int()); |
ecd2136ff818
Broke out the generation of random UUIDs to its own function
Marcus Lundblad <ml@update.uu.se>
parents:
29110
diff
changeset
|
5020 } |