annotate plugins/yay/misc.c @ 2009:ac9dd6b00b34

[gaim-migrate @ 2019] different way of specifying offline messages. Jeremy, I'm just about to look at your patch committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Wed, 13 Jun 2001 21:28:03 +0000
parents b669f48f0990
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1546
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 /*
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 * libyay
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 *
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 * Copyright (C) 2001 Eric Warmenhoven <warmenhoven@yahoo.com>
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 *
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 * (at your option) any later version.
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 *
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 * GNU General Public License for more details.
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 *
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 *
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 */
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22 #include "internal.h"
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23 #include <ctype.h>
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25 char *yahoo_urlencode(const char *str)
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26 {
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 int len;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28 char *ret;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 const char *s;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 char *r;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 if ((len = strlen(str)) == 0)
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33 return NULL;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35 ret = g_malloc(len * 3 + 1);
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36 if (!ret)
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37 return NULL;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39 for (s = str, r = ret; *s; s++) {
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40 if (isdigit(*s) || isalpha(*s) || *s == '_')
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41 *r++ = *s;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42 else {
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43 int tmp = *s / 16;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 *r++ = '%';
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45 *r++ = (tmp < 10) ? (tmp + '0') : (tmp - 10 + 'A');
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46 tmp = *s % 16;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47 *r++ = (tmp < 10) ? (tmp + '0') : (tmp - 10 + 'A');
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48 }
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49 }
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
51 *r = '\0';
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53 return ret;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54 }
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55
1552
b669f48f0990 [gaim-migrate @ 1562]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1546
diff changeset
56 int yahoo_makeint(guchar *buf)
1546
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57 {
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58 return ((buf[3] << 24) + (buf[2] << 16) + (buf[1] << 8) + buf[0]);
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59 }
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60
1552
b669f48f0990 [gaim-migrate @ 1562]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1546
diff changeset
61 void yahoo_storeint(guchar *buf, guint data)
1546
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
62 {
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63 int i;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
64 for (i = 0; i < 4; i++) {
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
65 buf[i] = data % 256;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66 data >>= 8;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
67 }
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
68 }