--------------------- PatchSet 10269 Date: 2007/12/17 08:17:46 Author: adri Branch: s27_adri Tag: (none) Log: Begin "libhttp" with the String List stuff (which doesn't strictly belong in here!) The string list stuff is used in the http header routines and has been lifted from src/HttpHeaderTools.c . Modify strListGetItem() to operate on string offsets and not C-strings; remove the strBuf() calls and hopefully make it NUL-string friendly. Add in simple test routine - test-suite/check_strlist.c - which does a very simple add-and-remove inline check that items match. I'll expand this to be more generic in its testing abilities in a commit or two. (Holy crap, the beginnings of unit testing in squid-2!) Members: Makefile.am:1.20.36.3->1.20.36.4 configure.in:1.184.2.1.4.3->1.184.2.1.4.4 libhttp/HttpStrList.c:1.1->1.1.2.1 libhttp/HttpStrList.h:1.1->1.1.2.1 libhttp/Makefile.am:1.1->1.1.2.1 libmem/MemPool.h:1.1.2.1->1.1.2.2 src/HttpHdrCc.c:1.7.16.4->1.7.16.5 src/HttpHdrRange.c:1.8.58.1->1.8.58.2 src/HttpHeader.c:1.28.6.1.4.19->1.28.6.1.4.20 src/HttpHeaderTools.c:1.14.10.3->1.14.10.4 src/Makefile.am:1.54.2.1.4.3->1.54.2.1.4.4 src/ftp.c:1.44.4.2.4.6->1.44.4.2.4.7 src/http.c:1.63.2.3.4.12->1.63.2.3.4.13 src/protos.h:1.146.2.4.4.23->1.146.2.4.4.24 src/squid.h:1.36.24.8->1.36.24.9 src/typedefs.h:1.43.2.3.4.3->1.43.2.3.4.4 test-suite/Makefile:1.1.1.1->1.1.1.1.270.1 test-suite/check_strlist.c:1.1->1.1.2.1 test-suite/membanger.c:1.2->1.2.192.1 Index: squid/Makefile.am =================================================================== RCS file: /cvsroot/squid-sf//squid/Makefile.am,v retrieving revision 1.20.36.3 retrieving revision 1.20.36.4 diff -u -r1.20.36.3 -r1.20.36.4 --- squid/Makefile.am 6 Dec 2007 06:34:37 -0000 1.20.36.3 +++ squid/Makefile.am 17 Dec 2007 08:17:46 -0000 1.20.36.4 @@ -4,8 +4,8 @@ # AUTOMAKE_OPTIONS = dist-bzip2 subdir-objects 1.5 -DIST_SUBDIRS = lib libcore libmem libbuf snmplib scripts src icons errors contrib doc helpers tools -SUBDIRS = lib libcore libmem libbuf @makesnmplib@ scripts src icons errors doc helpers tools +DIST_SUBDIRS = lib libcore libmem libbuf libhttp snmplib scripts src icons errors contrib doc helpers tools +SUBDIRS = lib libcore libmem libbuf libhttp @makesnmplib@ scripts src icons errors doc helpers tools DISTCLEANFILES = include/stamp-h include/stamp-h[0-9]* DEFAULT_PINGER = $(libexecdir)/`echo pinger | sed '$(transform);s/$$/$(EXEEXT)/'` Index: squid/configure.in =================================================================== RCS file: /cvsroot/squid-sf//squid/configure.in,v retrieving revision 1.184.2.1.4.3 retrieving revision 1.184.2.1.4.4 diff -u -r1.184.2.1.4.3 -r1.184.2.1.4.4 --- squid/configure.in 6 Dec 2007 06:34:37 -0000 1.184.2.1.4.3 +++ squid/configure.in 17 Dec 2007 08:17:46 -0000 1.184.2.1.4.4 @@ -1,7 +1,7 @@ dnl dnl Configuration input file for Squid dnl -dnl $Id: configure.in,v 1.184.2.1.4.3 2007/12/06 06:34:37 adri Exp $ +dnl $Id: configure.in,v 1.184.2.1.4.4 2007/12/17 08:17:46 adri Exp $ dnl dnl dnl @@ -10,7 +10,7 @@ AM_CONFIG_HEADER(include/autoconf.h) AC_CONFIG_AUX_DIR(cfgaux) AM_INIT_AUTOMAKE -AC_REVISION($Revision: 1.184.2.1.4.3 $)dnl +AC_REVISION($Revision: 1.184.2.1.4.4 $)dnl AC_PREFIX_DEFAULT(/usr/local/squid) AM_MAINTAINER_MODE @@ -3176,6 +3176,7 @@ libcore/Makefile \ libmem/Makefile \ libbuf/Makefile \ + libhttp/Makefile \ lib/Makefile \ scripts/Makefile \ scripts/RunCache \ --- /dev/null Tue Dec 18 01:21:00 2007 +++ squid/libhttp/HttpStrList.c Tue Dec 18 01:21:00 2007 @@ -0,0 +1,178 @@ + +/* + * $Id: HttpStrList.c,v 1.1.2.1 2007/12/17 08:17:47 adri Exp $ + * + * DEBUG: section 66 HTTP Header Tools + * AUTHOR: Alex Rousskov + * + * SQUID Web Proxy Cache http://www.squid-cache.org/ + * ---------------------------------------------------------- + * + * Squid is the result of efforts by numerous individuals from + * the Internet community; see the CONTRIBUTORS file for full + * details. Many organizations have provided support for Squid's + * development; see the SPONSORS file for full details. Squid is + * Copyrighted (C) 2001 by the Regents of the University of + * California; see the COPYRIGHT file for full details. Squid + * incorporates software developed and/or copyrighted by other + * sources; see the CREDITS file for full details. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + * + */ + +#include +#include +#include +#include +#include +#include + +#include "../include/util.h" + +#include "../libcore/varargs.h" +#include "../libcore/debug.h" +#include "../libcore/tools.h" + +#include "../libbuf/buf.h" +#include "../libbuf/String.h" + +#include "HttpStrList.h" + +/* XXX temporary */ +extern const char *const w_space; /* " \t\n\r" */ + +/* returns true iff "m" is a member of the list */ +int +strListIsMemberStr(const String * list, const char *m, int mlen, char del) +{ + strListItemIterator ipos = 0; + const char *item; + int ilen = 0; + assert(list && m); + while (strListGetItem(list, del, &item, &ilen, &ipos)) { + if (mlen == ilen && !strncasecmp(item, m, ilen)) + return 1; + } + return 0; +} + +int +strListIsMember(const String *list, const char *m, char del) +{ + return strListIsMemberStr(list, m, strlen(m), del); +} + +/* returns true iff "s" is a substring of a member of the list, >1 if more than once */ +int +strIsSubstr(const String * list, const char *s) +{ + const char *p; + assert(list && s); + p = strStr(*list, s); + if (!p) + return 0; + if (strstr(p + 1, s) != NULL) + return 2; + return 1; +} + +/* appends an item to the list */ +void +strListAdd(String * str, const char *item, int len, char del) +{ + assert(str && item); + if (strLen(*str)) { + char buf[3]; + buf[0] = del; + buf[1] = ' '; + buf[2] = '\0'; + stringAppend(str, buf, 2); + } + stringAppend(str, item, len); +} + +/* appends an item to the list if not already there */ +void +strListAddUnique(String * str, const char *item, char del) +{ + if (!strListIsMember(str, item, del)) + strListAdd(str, item, strlen(item), del); +} + +/* + * iterates through a 0-terminated string of items separated by 'del's. + * white space around 'del' is considered to be a part of 'del' + * like strtok, but preserves the source, and can iterate several strings at once + * + * returns true if next item is found. + * init pos with NULL to start iteration. + */ +int +strListGetItem(const String * str, char del, const char **item, int *ilen, strListItemIterator *ipos) +{ + size_t len; + int ii; + static char delim[2][3] = + { + {'"', 0, 0}, + {'"', '\\', 0}}; + + int quoted = 0; + delim[0][1] = del; + assert(str && item); + + if (*ipos > 0) { + if (*ipos >= strLen2(*str)) /* end of string */ + return 0; + else + (*ipos)++; + } else { + /* handle emptry string */ + if (strLen2(*str) <= *ipos) + return 0; + } + + /* skip leading ws (ltrim) */ + while (*ipos < strLen2(*str) && xisspace(strGetPos(*str, *ipos))) + (*ipos)++; + *item = strBuf2(*str) + *ipos; /* remember item's start */ + ii = *ipos; + /* find next delimiter */ + do { + (*ipos) = strCSpn(*str, *ipos, delim[quoted]); + if (strGetPos(*str, *ipos) == del) + break; + if (strGetPos(*str, *ipos) == '"') { + quoted = !quoted; + (*ipos) += 1; + } + if (quoted && strGetPos(*str, *ipos) == '\\') { + *ipos += 1; + /* XXX off by one? */ + if (strLen2(*str) -1 > *ipos) + *ipos += 1; + } + } while (*ipos < strLen2(*str)); + + len = *ipos - ii; /* *pos points to del or '\0' */ + /* rtrim */ + while (len > 0 && xisspace(strGetPos(*str, *ipos + len))) + len--; + if (ilen) + *ilen = len; + return len > 0; +} + --- /dev/null Tue Dec 18 01:21:00 2007 +++ squid/libhttp/HttpStrList.h Tue Dec 18 01:21:00 2007 @@ -0,0 +1,14 @@ +#ifndef LIBHTTP__STRLIST_H__ +#define LIBHTTP__STRLIST_H__ + +typedef int strListItemIterator; + +extern void strListAdd(String * str, const char *item, int len, char del); +extern void strListAddUnique(String * str, const char *item, char del); +extern int strListIsMember(const String * str, const char *item, char del); +extern int strListIsMemberStr(const String * str, const char *item, int len, char del); +extern int strIsSubstr(const String * list, const char *s); +extern int strListGetItem(const String * str, char del, const char **item, int *ilen, strListItemIterator *ipos); + + +#endif --- /dev/null Tue Dec 18 01:21:00 2007 +++ squid/libhttp/Makefile.am Tue Dec 18 01:21:00 2007 @@ -0,0 +1,13 @@ +## Process this file with automake to produce Makefile.in +# +# $Id: Makefile.am,v 1.1.2.1 2007/12/17 08:17:47 adri Exp $ +# + +libhttp_a_SOURCES = \ + HttpStrList.c + +libhttp_a_LIBADD = \ + HttpStrList.o + +noinst_LIBRARIES = \ + libhttp.a Index: squid/libmem/MemPool.h =================================================================== RCS file: /cvsroot/squid-sf//squid/libmem/Attic/MemPool.h,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- squid/libmem/MemPool.h 6 Dec 2007 06:34:38 -0000 1.1.2.1 +++ squid/libmem/MemPool.h 17 Dec 2007 08:17:48 -0000 1.1.2.2 @@ -60,6 +60,9 @@ extern Stack Pools; +extern void memInitModule(void); +extern void memCleanModule(void); + extern void memConfigure(int enable, int limit, int dozero); extern MemPool *memPoolCreate(const char *label, size_t obj_size); extern void memPoolDestroy(MemPool * pool); Index: squid/src/HttpHdrCc.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/HttpHdrCc.c,v retrieving revision 1.7.16.4 retrieving revision 1.7.16.5 diff -u -r1.7.16.4 -r1.7.16.5 --- squid/src/HttpHdrCc.c 15 Dec 2007 10:43:27 -0000 1.7.16.4 +++ squid/src/HttpHdrCc.c 17 Dec 2007 08:17:48 -0000 1.7.16.5 @@ -1,6 +1,6 @@ /* - * $Id: HttpHdrCc.c,v 1.7.16.4 2007/12/15 10:43:27 adri Exp $ + * $Id: HttpHdrCc.c,v 1.7.16.5 2007/12/17 08:17:48 adri Exp $ * * DEBUG: section 65 HTTP Cache Control Header * AUTHOR: Alex Rousskov @@ -100,7 +100,7 @@ { const char *item; const char *p; /* '=' parameter */ - const char *pos = NULL; + strListItemIterator pos = 0; int type; int ilen; int nlen; Index: squid/src/HttpHdrRange.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/HttpHdrRange.c,v retrieving revision 1.8.58.1 retrieving revision 1.8.58.2 diff -u -r1.8.58.1 -r1.8.58.2 --- squid/src/HttpHdrRange.c 10 Dec 2007 18:59:38 -0000 1.8.58.1 +++ squid/src/HttpHdrRange.c 17 Dec 2007 08:17:48 -0000 1.8.58.2 @@ -1,6 +1,6 @@ /* - * $Id: HttpHdrRange.c,v 1.8.58.1 2007/12/10 18:59:38 adri Exp $ + * $Id: HttpHdrRange.c,v 1.8.58.2 2007/12/17 08:17:48 adri Exp $ * * DEBUG: section 64 HTTP Range Header * AUTHOR: Alex Rousskov @@ -232,7 +232,7 @@ httpHdrRangeParseInit(HttpHdrRange * range, const String * str) { const char *item; - const char *pos = NULL; + strListItemIterator pos = 0; int ilen; int count = 0; assert(range && str); Index: squid/src/HttpHeader.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/HttpHeader.c,v retrieving revision 1.28.6.1.4.19 retrieving revision 1.28.6.1.4.20 diff -u -r1.28.6.1.4.19 -r1.28.6.1.4.20 --- squid/src/HttpHeader.c 16 Dec 2007 14:52:31 -0000 1.28.6.1.4.19 +++ squid/src/HttpHeader.c 17 Dec 2007 08:17:48 -0000 1.28.6.1.4.20 @@ -1,6 +1,6 @@ /* - * $Id: HttpHeader.c,v 1.28.6.1.4.19 2007/12/16 14:52:31 adri Exp $ + * $Id: HttpHeader.c,v 1.28.6.1.4.20 2007/12/17 08:17:48 adri Exp $ * * DEBUG: section 55 HTTP Header * AUTHOR: Alex Rousskov @@ -851,7 +851,7 @@ { String result = StringNull; String header; - const char *pos = NULL; + strListItemIterator pos = 0; const char *item; int ilen; int mlen = strlen(member); @@ -879,7 +879,7 @@ { String result = StringNull; String header; - const char *pos = NULL; + strListItemIterator pos = 0; const char *item; int ilen; int mlen = strlen(member); Index: squid/src/HttpHeaderTools.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/HttpHeaderTools.c,v retrieving revision 1.14.10.3 retrieving revision 1.14.10.4 diff -u -r1.14.10.3 -r1.14.10.4 --- squid/src/HttpHeaderTools.c 16 Dec 2007 14:25:57 -0000 1.14.10.3 +++ squid/src/HttpHeaderTools.c 17 Dec 2007 08:17:48 -0000 1.14.10.4 @@ -1,6 +1,6 @@ /* - * $Id: HttpHeaderTools.c,v 1.14.10.3 2007/12/16 14:25:57 adri Exp $ + * $Id: HttpHeaderTools.c,v 1.14.10.4 2007/12/17 08:17:48 adri Exp $ * * DEBUG: section 66 HTTP Header Tools * AUTHOR: Alex Rousskov @@ -173,121 +173,6 @@ return res; } -/* returns true iff "m" is a member of the list */ -int -strListIsMemberStr(const String * list, const char *m, int mlen, char del) -{ - const char *pos = NULL; - const char *item; - int ilen = 0; - assert(list && m); - while (strListGetItem(list, del, &item, &ilen, &pos)) { - if (mlen == ilen && !strncasecmp(item, m, ilen)) - return 1; - } - return 0; -} - -int -strListIsMember(const String *list, const char *m, char del) -{ - return strListIsMemberStr(list, m, strlen(m), del); -} - -/* returns true iff "s" is a substring of a member of the list, >1 if more than once */ -int -strIsSubstr(const String * list, const char *s) -{ - const char *p; - assert(list && s); - p = strStr(*list, s); - if (!p) - return 0; - if (strstr(p + 1, s) != NULL) - return 2; - return 1; -} - -/* appends an item to the list */ -void -strListAdd(String * str, const char *item, int len, char del) -{ - assert(str && item); - if (strLen(*str)) { - char buf[3]; - buf[0] = del; - buf[1] = ' '; - buf[2] = '\0'; - stringAppend(str, buf, 2); - } - stringAppend(str, item, len); -} - -/* appends an item to the list if not already there */ -void -strListAddUnique(String * str, const char *item, char del) -{ - if (!strListIsMember(str, item, del)) - strListAdd(str, item, strlen(item), del); -} - -/* - * iterates through a 0-terminated string of items separated by 'del's. - * white space around 'del' is considered to be a part of 'del' - * like strtok, but preserves the source, and can iterate several strings at once - * - * returns true if next item is found. - * init pos with NULL to start iteration. - */ -int -strListGetItem(const String * str, char del, const char **item, int *ilen, const char **pos) -{ - size_t len; - static char delim[2][3] = - { - {'"', 0, 0}, - {'"', '\\', 0}}; - int quoted = 0; - delim[0][1] = del; - assert(str && item && pos); - if (*pos) { - if (!**pos) /* end of string */ - return 0; - else - (*pos)++; - } else { - *pos = strBuf(*str); - if (!*pos) - return 0; - } - - /* skip leading ws (ltrim) */ - *pos += xcountws(*pos); - *item = *pos; /* remember item's start */ - /* find next delimiter */ - do { - *pos += strcspn(*pos, delim[quoted]); - if (**pos == del) - break; - if (**pos == '"') { - quoted = !quoted; - *pos += 1; - } - if (quoted && **pos == '\\') { - *pos += 1; - if (**pos) - *pos += 1; - } - } while (**pos); - len = *pos - *item; /* *pos points to del or '\0' */ - /* rtrim */ - while (len > 0 && xisspace((*item)[len - 1])) - len--; - if (ilen) - *ilen = len; - return len > 0; -} - /* handy to printf prefixes of potentially very long buffers */ const char * getStringPrefix(const char *str, const char *end) Index: squid/src/Makefile.am =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Makefile.am,v retrieving revision 1.54.2.1.4.3 retrieving revision 1.54.2.1.4.4 diff -u -r1.54.2.1.4.3 -r1.54.2.1.4.4 --- squid/src/Makefile.am 6 Dec 2007 06:34:39 -0000 1.54.2.1.4.3 +++ squid/src/Makefile.am 17 Dec 2007 08:17:48 -0000 1.54.2.1.4.4 @@ -275,6 +275,7 @@ -L../libmem \ -L../libcore \ -L../libbuf \ + -L../libhttp \ @XTRA_OBJS@ \ @REPL_OBJS@ \ @STORE_OBJS@ \ @@ -289,6 +290,7 @@ -lcore \ -lmem \ -lbuf \ + -lhttp \ @XTRA_LIBS@ \ $(MINGWEXLIB) @@ -326,7 +328,7 @@ data_DATA = \ mib.txt -LDADD = -L../lib -L../libcore -L../libmem -L../libbuf -lcore -lbuf -lmiscutil @XTRA_LIBS@ +LDADD = -L../lib -L../libcore -L../libmem -L../libhttp -L../libbuf -lcore -lbuf -lhttp -lmiscutil @XTRA_LIBS@ EXTRA_DIST = \ cf_gen_defines \ Index: squid/src/ftp.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/ftp.c,v retrieving revision 1.44.4.2.4.6 retrieving revision 1.44.4.2.4.7 diff -u -r1.44.4.2.4.6 -r1.44.4.2.4.7 --- squid/src/ftp.c 16 Dec 2007 13:33:27 -0000 1.44.4.2.4.6 +++ squid/src/ftp.c 17 Dec 2007 08:17:49 -0000 1.44.4.2.4.7 @@ -1,6 +1,6 @@ /* - * $Id: ftp.c,v 1.44.4.2.4.6 2007/12/16 13:33:27 adri Exp $ + * $Id: ftp.c,v 1.44.4.2.4.7 2007/12/17 08:17:49 adri Exp $ * * DEBUG: section 9 File Transfer Protocol (FTP) * AUTHOR: Harvest Derived @@ -360,14 +360,13 @@ wordlist *w; char *dirup; int i, j, k; - const char *title = strBuf(ftpState->title_url); storeAppendPrintf(e, "\n"); storeAppendPrintf(e, "\n", version_string); storeAppendPrintf(e, "\n", mkrfc1123(squid_curtime)); storeAppendPrintf(e, "\n"); { - char *t = xstrdup(title); + char *t = strCDup(ftpState->title_url); rfc1738_unescape(t); storeAppendPrintf(e, "FTP Directory: %s\n", html_quote(t, strlen(t))); xfree(t); @@ -390,11 +389,11 @@ storeAppendPrintf(e, "FTP Directory: "); /* "ftp://" == 6 characters */ assert(strLen(ftpState->title_url) >= 6); - k = 6 + strcspn(&title[6], "/"); - for (i = 6, j = 0; title[i]; j = i) { - i += strcspn(&title[i], "/"); + k = 6 + strCSpn(ftpState->title_url, 0, "/"); + for (i = 6, j = 0; i < strLen2(ftpState->title_url); j = i) { + i += strCSpn(ftpState->title_url, i, "/"); if (i > j) { - char *url = xstrdup(title); + char *url = strCDup(ftpState->title_url); url[i] = '\0'; storeAppendPrintf(e, "<A HREF=\"%s/\">", html_quote(url + k, strlen(url + k))); rfc1738_unescape(url + j); @@ -402,13 +401,13 @@ safe_free(url); } storeAppendPrintf(e, "/"); - if (title[i] == '/') + if (strGetPos(ftpState->title_url, i) == '/') i++; if (i == j) { /* Error guard, or "assert" */ storeAppendPrintf(e, "ERROR: Failed to parse URL: %s\n", - html_quote(title, strlen(title))); - debug(9, 0) ("Failed to parse URL: %s\n", title); + html_quote(strBuf2(ftpState->title_url), strLen2(ftpState->title_url))); + debug(9, 0) ("Failed to parse URL: %.*s\n", strLen2(ftpState->title_url), strBuf2(ftpState->title_url)); break; } } Index: squid/src/http.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/http.c,v retrieving revision 1.63.2.3.4.12 retrieving revision 1.63.2.3.4.13 diff -u -r1.63.2.3.4.12 -r1.63.2.3.4.13 --- squid/src/http.c 16 Dec 2007 15:26:36 -0000 1.63.2.3.4.12 +++ squid/src/http.c 17 Dec 2007 08:17:49 -0000 1.63.2.3.4.13 @@ -1,6 +1,6 @@ /* - * $Id: http.c,v 1.63.2.3.4.12 2007/12/16 15:26:36 adri Exp $ + * $Id: http.c,v 1.63.2.3.4.13 2007/12/17 08:17:49 adri Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -348,7 +348,7 @@ httpMakeVaryMark(request_t * request, HttpReply * reply) { String vary = StringNull, hdr; - const char *pos = NULL; + strListItemIterator pos = 0; const char *item; const char *value; int ilen; @@ -489,7 +489,7 @@ debug(11, 3) ("httpProcessReplyHeader: HTTP CODE: %d\n", reply->sline.status); if (httpHeaderHas(&reply->header, HDR_TRANSFER_ENCODING)) { String tr = httpHeaderGetList(&reply->header, HDR_TRANSFER_ENCODING); - const char *pos = NULL; + strListItemIterator pos = 0; const char *item = NULL; int ilen = 0; if (strListGetItem(&tr, ',', &item, &ilen, &pos)) { Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.146.2.4.4.23 retrieving revision 1.146.2.4.4.24 diff -u -r1.146.2.4.4.23 -r1.146.2.4.4.24 --- squid/src/protos.h 16 Dec 2007 16:14:23 -0000 1.146.2.4.4.23 +++ squid/src/protos.h 17 Dec 2007 08:17:50 -0000 1.146.2.4.4.24 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.146.2.4.4.23 2007/12/16 16:14:23 adri Exp $ + * $Id: protos.h,v 1.146.2.4.4.24 2007/12/17 08:17:50 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -393,12 +393,6 @@ extern void httpHeaderCalcMask(HttpHeaderMask * mask, const http_hdr_type * enums, int count); extern int httpHeaderHasConnDir(const HttpHeader * hdr, const char *directive); extern void httpHeaderAddContRange(HttpHeader *, HttpHdrRangeSpec, squid_off_t); -extern void strListAdd(String * str, const char *item, int len, char del); -extern void strListAddUnique(String * str, const char *item, char del); -extern int strListIsMember(const String * str, const char *item, char del); -extern int strListIsMemberStr(const String * str, const char *item, int len, char del); -extern int strIsSubstr(const String * list, const char *s); -extern int strListGetItem(const String * str, char del, const char **item, int *ilen, const char **pos); extern const char *getStringPrefix(const char *str, const char *end); extern int httpHeaderParseInt(const char *start, int *val); extern int httpHeaderParseIntStr(String s, int *val); @@ -851,8 +845,6 @@ /* mem */ extern void memInit(void); extern void memClean(void); -extern void memInitModule(void); -extern void memCleanModule(void); extern void *memAllocate(mem_type); extern void *memAllocBuf(size_t net_size, size_t * gross_size); extern void *memReallocBuf(void *buf, size_t net_size, size_t * gross_size); Index: squid/src/squid.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/squid.h,v retrieving revision 1.36.24.8 retrieving revision 1.36.24.9 diff -u -r1.36.24.8 -r1.36.24.9 --- squid/src/squid.h 13 Dec 2007 12:18:24 -0000 1.36.24.8 +++ squid/src/squid.h 17 Dec 2007 08:17:51 -0000 1.36.24.9 @@ -1,6 +1,6 @@ /* - * $Id: squid.h,v 1.36.24.8 2007/12/13 12:18:24 adri Exp $ + * $Id: squid.h,v 1.36.24.9 2007/12/17 08:17:51 adri Exp $ * * AUTHOR: Duane Wessels * @@ -390,6 +390,9 @@ #include "../libmem/memstr.h" #include "../libmem/mem.h" +/* libhttp */ +#include "../libhttp/HttpStrList.h" + /* Needed for poll() on Linux at least */ #if USE_POLL #ifndef POLLRDNORM Index: squid/src/typedefs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/typedefs.h,v retrieving revision 1.43.2.3.4.3 retrieving revision 1.43.2.3.4.4 diff -u -r1.43.2.3.4.3 -r1.43.2.3.4.4 --- squid/src/typedefs.h 6 Dec 2007 06:34:46 -0000 1.43.2.3.4.3 +++ squid/src/typedefs.h 17 Dec 2007 08:17:51 -0000 1.43.2.3.4.4 @@ -1,6 +1,6 @@ /* - * $Id: typedefs.h,v 1.43.2.3.4.3 2007/12/06 06:34:46 adri Exp $ + * $Id: typedefs.h,v 1.43.2.3.4.4 2007/12/17 08:17:51 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -418,4 +418,5 @@ typedef void REFRESHCHECK(void *data, int fresh, const char *log); typedef struct _refresh_check_helper refresh_check_helper; + #endif /* SQUID_TYPEDEFS_H */ Index: squid/test-suite/Makefile =================================================================== RCS file: /cvsroot/squid-sf//squid/test-suite/Makefile,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.270.1 diff -u -r1.1.1.1 -r1.1.1.1.270.1 --- squid/test-suite/Makefile 26 Jan 2000 03:21:47 -0000 1.1.1.1 +++ squid/test-suite/Makefile 17 Dec 2007 08:17:51 -0000 1.1.1.1.270.1 @@ -1,6 +1,6 @@ CC = gcc CFLAGS = -g -Wall -I../include -I../src -OBJS = membanger.o hash.o SizeToPool.o +OBJS = membanger.o hash.o SizeToPool.o LIB = -L. -lMem TARGLIB = libMem.a LIBOBJS = Mem.o \ @@ -9,7 +9,10 @@ RM = rm XTRA_LIBS = -lm -lmalloc -all: membanger +LDFLAGS = -L../libcore -L../libbuf -L../libmem -L../libhttp -L../lib +LIB = -lhttp -lbuf -lmem -lcore -lmiscutil -lm + +all: check_strlist membanger: $(OBJS) $(TARGLIB) $(CC) -o membanger $(OBJS) $(LIB) @@ -20,10 +23,17 @@ tcp-banger2.o: tcp-banger2.c $(CC) -c $(CFLAGS) tcp-banger2.c +check_strlist.o: check_strlist.c + $(CC) -c $(CFLAGS) check_strlist.c + +# XXX argh, how do I provide the LIB line to the linker stage? +check_strlist: check_strlist.o + $(CC) -o check_strlist check_strlist.o $(LDFLAGS) $(LIB) + $(OBJS): Makefile $(TARGLIB): $(LIBOBJS) $(AR_R) $(TARGLIB) $(LIBOBJS) clean: - rm $(OBJS) $(TARGLIB) $(LIBOBJS) + rm *.o --- /dev/null Tue Dec 18 01:21:00 2007 +++ squid/test-suite/check_strlist.c Tue Dec 18 01:21:00 2007 @@ -0,0 +1,65 @@ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <errno.h> +#include <ctype.h> + +#include "../include/util.h" + +#include "../libcore/varargs.h" +#include "../libcore/debug.h" +#include "../libcore/tools.h" + +#include "../include/Stack.h" +#include "../libmem/MemPool.h" +#include "../libmem/memstr.h" + +#include "../libbuf/buf.h" +#include "../libbuf/String.h" + +#include "../libhttp/HttpStrList.h" + + +char const * w_space = " \r\n\t"; +int shutting_down; +time_t squid_curtime; + +static void +strlist_add(String *s, const char *str, char delim) +{ + strListAdd(s, str, strlen(str) + 1, delim); +} +void +check1(void) +{ + String s = StringNull; + strListItemIterator pos = 0; + const char *item; + int ilen; + + strlist_add(&s, "a", ','); + strlist_add(&s, "b", ','); + strlist_add(&s, "\"c,f\"", ','); + strlist_add(&s, "d", ','); + strlist_add(&s, "e", ','); + + printf("List: '%.*s'\n", strLen2(s), strBuf2(s)); + + while (strListGetItem(&s, ',', &item, &ilen, &pos)) { + printf(" member: %.*s\n", ilen, item); + } +} + +int +main(int argc, const char *argv[]) +{ + + memInitModule(); + memStringInit(); + buf_init(); + + check1(); + + exit(0); +} Index: squid/test-suite/membanger.c =================================================================== RCS file: /cvsroot/squid-sf//squid/test-suite/membanger.c,v retrieving revision 1.2 retrieving revision 1.2.192.1 diff -u -r1.2 -r1.2.192.1 --- squid/test-suite/membanger.c 7 Jan 2001 10:00:49 -0000 1.2 +++ squid/test-suite/membanger.c 17 Dec 2007 08:17:51 -0000 1.2.192.1 @@ -14,6 +14,15 @@ static hash_link *mem_entry; struct rusage myusage; +#include "../include/util.h" + +#include "../libcore/varargs.h" +#include "../libcore/debug.h" +#include "../libcore/tools.h" + +#include "../libbuf/buf.h" +#include "../libbuf/String.h" + #ifdef WITH_LIB #include "Mem.h" #include <assert.h>