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