Mercurial > pidgin
changeset 1375:b167222b5c93
[gaim-migrate @ 1385]
updates to libyahoo, and jlsantiago told me how to get icq to work on hpux
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Thu, 04 Jan 2001 22:46:19 +0000 |
parents | 8331d967288e |
children | 730a1a19b4cc |
files | plugins/icq/icqbyteorder.h plugins/yay/libyahoo.c |
diffstat | 2 files changed, 70 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/icq/icqbyteorder.h Thu Jan 04 22:41:12 2001 +0000 +++ b/plugins/icq/icqbyteorder.h Thu Jan 04 22:46:19 2001 +0000 @@ -1,5 +1,5 @@ /* - * $Id: icqbyteorder.h 1319 2000-12-19 10:08:29Z warmenhoven $ + * $Id: icqbyteorder.h 1385 2001-01-04 22:46:19Z warmenhoven $ * * This header defines macros to handle ICQ protocol byte order conversion. * @@ -62,6 +62,12 @@ # include <arpa/nameser_compat.h> #endif +/* put in by EWarmenhoven; jlsantiago told me what to do. I should send this on to the + * icqlib guys. */ +#ifdef hpux +#include <arpa/nameser.h> +#endif + /* * I am really trying to use builtin optimized byte swap routines. * they are highly optimised on some platforms.
--- a/plugins/yay/libyahoo.c Thu Jan 04 22:41:12 2001 +0000 +++ b/plugins/yay/libyahoo.c Thu Jan 04 22:46:19 2001 +0000 @@ -660,47 +660,74 @@ return servfd; } -/* really ugly brute force approach - someone find a GPL'd/free - equivalent and replace this p.o.s. */ -static char *yahoo_urlencode(char *data) +/* + * yahoo_urlencode(char *) + * + * + * 29/12/2000: + * + * function modified to accept only one arg. + * added code to reuse the buffer and check allocs. + * + * -- Hrishikesh Desai <hrishi@mediaibc.com> + * + */ + + +static char *yahoo_urlencode(char *instr) { - static char *tmp = NULL; - char buf[4]; - int i, len; - - len = 3 * strlen(data) + 1; - - if (tmp) - FREE(tmp); - - if (!data) - return NULL; - - /* change this at some point to re-use the buffer, no sense - allocating repeatedly */ - if (!(tmp = (char *) malloc(len))) - return NULL; - tmp[0] = 0; - - for (i = 0; i < strlen(data); i++) + register int ipos, bpos; //input str pos., buffer pos. + static unsigned char *str=NULL; + int len=strlen(instr); + int tmp; + + //attempt to reuse buffer + if(NULL==str) + str = (unsigned char *) malloc(3 * len + 1); + else + str = (unsigned char *) realloc(str,3 * len + 1); + + //malloc, realloc failed ? + if(errno==ENOMEM) + { + perror("libyahoo[yahoo_urlencode]"); + //return ref. to empty string, so's prog. or whatever wont crash + return ""; + } + + ipos=bpos=0; + + while(ipos<len) { - if (isdigit((int) (data[i])) || - isalpha((int) data[i]) || data[i] == '_') - { - buf[0] = data[i]; - buf[1] = 0; - strcat(tmp, buf); - } - else - { - sprintf(buf, "%%%.2X", data[i]); - strcat(tmp, buf); - } + + //using inverted logic frm original code.... + if (!isdigit((int) (instr[ipos])) + && !isalpha((int) instr[ipos]) && instr[ipos] != '_') + { + tmp=instr[ipos] / 16; + str[bpos++]='%'; + str[bpos++]=( (tmp < 10)?(tmp+'0'):(tmp+'A'-10)); + tmp=instr[ipos] % 16; + str[bpos++]=( (tmp < 10)?(tmp+'0'):(tmp+'A'-10)); } - - return tmp; + else + { + str[bpos++]=instr[ipos]; + } + + ipos++; + } + + str[bpos] = '\0'; + + //free extra alloc'ed mem. + tmp=strlen(str); + str = (unsigned char *) realloc(str,tmp + 1); + + return ( str); } + static int yahoo_addtobuffer(struct yahoo_context *ctx, char *data, int datalen) {