Mercurial > pidgin
annotate src/protocols/yahoo/misc.c @ 2210:3a6fd1e8f00a
[gaim-migrate @ 2220]
i haven't even tested this.
committer: Tailor Script <tailor@pidgin.im>
| author | Eric Warmenhoven <eric@warmenhoven.org> |
|---|---|
| date | Wed, 05 Sep 2001 05:25:13 +0000 |
| parents | cff133e0ec0c |
| children |
| rev | line source |
|---|---|
| 2086 | 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> | |
|
2154
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
24 #include <string.h> |
| 2086 | 25 |
| 26 char *yahoo_urlencode(const char *str) | |
| 27 { | |
| 28 int len; | |
| 29 char *ret; | |
| 30 const char *s; | |
| 31 char *r; | |
| 32 | |
| 33 if ((len = strlen(str)) == 0) | |
| 34 return NULL; | |
| 35 | |
| 36 ret = g_malloc(len * 3 + 1); | |
| 37 if (!ret) | |
| 38 return NULL; | |
| 39 | |
| 40 for (s = str, r = ret; *s; s++) { | |
| 41 if (isdigit(*s) || isalpha(*s) || *s == '_') | |
| 42 *r++ = *s; | |
| 43 else { | |
| 44 int tmp = *s / 16; | |
| 45 *r++ = '%'; | |
| 46 *r++ = (tmp < 10) ? (tmp + '0') : (tmp - 10 + 'A'); | |
| 47 tmp = *s % 16; | |
| 48 *r++ = (tmp < 10) ? (tmp + '0') : (tmp - 10 + 'A'); | |
| 49 } | |
| 50 } | |
| 51 | |
| 52 *r = '\0'; | |
| 53 | |
| 54 return ret; | |
| 55 } | |
| 56 | |
| 57 int yahoo_makeint(guchar *buf) | |
| 58 { | |
| 59 return ((buf[3] << 24) + (buf[2] << 16) + (buf[1] << 8) + buf[0]); | |
| 60 } | |
| 61 | |
| 62 void yahoo_storeint(guchar *buf, guint data) | |
| 63 { | |
| 64 int i; | |
| 65 for (i = 0; i < 4; i++) { | |
| 66 buf[i] = data % 256; | |
| 67 data >>= 8; | |
| 68 } | |
| 69 } |
