--------------------- PatchSet 5980 Date: 2003/10/17 19:53:09 Author: dwsquid Branch: icap-2_5 Tag: (none) Log: moved our own strnstr() from src/icap_common.c to lib/strnstr.c and added configure/makefile checks whether or not it needs to be added to libmiscutil.a. Members: configure.in:1.42.2.35.2.5->1.42.2.35.2.6 include/util.h:1.10->1.10.30.1 lib/Makefile.am:1.4->1.4.26.1 lib/strnstr.c:1.1->1.1.2.1 src/icap_common.c:1.1.2.13->1.1.2.14 Index: squid/configure.in =================================================================== RCS file: /cvsroot/squid-sf//squid/configure.in,v retrieving revision 1.42.2.35.2.5 retrieving revision 1.42.2.35.2.6 diff -u -r1.42.2.35.2.5 -r1.42.2.35.2.6 --- squid/configure.in 22 Sep 2003 20:03:37 -0000 1.42.2.35.2.5 +++ squid/configure.in 17 Oct 2003 19:53:09 -0000 1.42.2.35.2.6 @@ -3,7 +3,7 @@ dnl dnl Duane Wessels, wessels@nlanr.net, February 1996 (autoconf v2.9) dnl -dnl $Id: configure.in,v 1.42.2.35.2.5 2003/09/22 20:03:37 dwsquid Exp $ +dnl $Id: configure.in,v 1.42.2.35.2.6 2003/10/17 19:53:09 dwsquid Exp $ dnl dnl dnl @@ -11,7 +11,7 @@ AC_CONFIG_AUX_DIR(cfgaux) AM_INIT_AUTOMAKE(squid, 2.5.STABLE4-CVS) AM_CONFIG_HEADER(include/autoconf.h) -AC_REVISION($Revision: 1.42.2.35.2.5 $)dnl +AC_REVISION($Revision: 1.42.2.35.2.6 $)dnl AC_PREFIX_DEFAULT(/usr/local/squid) AM_MAINTAINER_MODE @@ -1720,6 +1720,7 @@ srand48 \ srandom \ statfs \ + strnstr \ sysconf \ syslog \ timegm \ @@ -1752,6 +1753,11 @@ if test "$ac_cv_func_snprintf" = "no" || test "$ac_cv_func_vsnprintf" = "no" ; then AM_CONDITIONAL(NEED_OWN_SNPRINTF, true) fi + +AM_CONDITIONAL(NEED_OWN_STRNSTR, false) +if test "$ac_cv_func_strnstr" = "no" || test "$ac_cv_func_vstrnstr" = "no" ; then + AM_CONDITIONAL(NEED_OWN_STRNSTR, true) +fi dnl IP-Filter support requires ipf header files. These aren't dnl installed by default, so we need to check for them Index: squid/include/util.h =================================================================== RCS file: /cvsroot/squid-sf//squid/include/util.h,v retrieving revision 1.10 retrieving revision 1.10.30.1 diff -u -r1.10 -r1.10.30.1 --- squid/include/util.h 17 Oct 2001 12:30:51 -0000 1.10 +++ squid/include/util.h 17 Oct 2003 19:53:10 -0000 1.10.30.1 @@ -1,5 +1,5 @@ /* - * $Id: util.h,v 1.10 2001/10/17 12:30:51 squidadm Exp $ + * $Id: util.h,v 1.10.30.1 2003/10/17 19:53:10 dwsquid Exp $ * * AUTHOR: Harvest Derived * @@ -132,4 +132,8 @@ */ int statMemoryAccounted(void); +#ifndef HAVE_STRNSTR +extern char *strnstr(const char *haystack, const char *needle, size_t haystacklen); +#endif + #endif /* SQUID_UTIL_H */ Index: squid/lib/Makefile.am =================================================================== RCS file: /cvsroot/squid-sf//squid/lib/Makefile.am,v retrieving revision 1.4 retrieving revision 1.4.26.1 diff -u -r1.4 -r1.4.26.1 --- squid/lib/Makefile.am 21 Nov 2001 23:48:57 -0000 1.4 +++ squid/lib/Makefile.am 17 Oct 2003 19:53:10 -0000 1.4.26.1 @@ -8,6 +8,13 @@ else SNPRINTFSOURCE= endif + +if NEED_OWN_STRNSTR +STRNSTRSOURCE=strnstr.c +else +STRNSTRSOURCE= +endif + if NEED_OWN_MD5 MD5SOURCE=md5.c else @@ -43,6 +50,7 @@ $(SNPRINTFSOURCE) \ splay.c \ Stack.c \ + $(STRNSTRSOURCE) \ stub_memaccount.c \ util.c \ uudecode.c --- /dev/null Wed Feb 14 01:07:22 2007 +++ squid/lib/strnstr.c Wed Feb 14 01:09:21 2007 @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2003 Nikos Mavroyanopoulos + * + * This file is part of GNUTLS. + * + * The GNUTLS library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + + /* + * DW 2003/10/17: + * Changed 'ssize_t' types to 'size_t' + */ + +#include "config.h" +#ifndef HAVE_STRNSTR +#include + +char *strnstr(const char *haystack, const char *needle, size_t haystacklen) +{ + char *p; + size_t plen; + size_t len = strlen(needle); + + if (*needle == '\0') /* everything matches empty string */ + return (char*) haystack; + + plen = haystacklen; + for (p = (char*) haystack; p != NULL; p = memchr(p + 1, *needle, plen-1)) { + plen = haystacklen - (p - haystack); + + if (plen < len) return NULL; + + if (strncmp(p, needle, len) == 0) + return (p); + } + return NULL; +} +#endif Index: squid/src/icap_common.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/icap_common.c,v retrieving revision 1.1.2.13 retrieving revision 1.1.2.14 diff -u -r1.1.2.13 -r1.1.2.14 --- squid/src/icap_common.c 17 Oct 2003 15:59:41 -0000 1.1.2.13 +++ squid/src/icap_common.c 17 Oct 2003 19:53:11 -0000 1.1.2.14 @@ -1,5 +1,5 @@ /* - * $Id: icap_common.c,v 1.1.2.13 2003/10/17 15:59:41 rhorstmann Exp $ + * $Id: icap_common.c,v 1.1.2.14 2003/10/17 19:53:11 dwsquid Exp $ * * DEBUG: section 81 Internet Content Adaptation Protocol (ICAP) Client * AUTHOR: Geetha Manjunath, Hewlett Packard Company @@ -411,28 +411,6 @@ return 0; } -/* copied from gnutls */ -static char *strnstr(const char *haystack, const char *needle, size_t haystacklen) -{ - char *p; - ssize_t plen; - ssize_t len = strlen(needle); - - if (*needle == '\0') /* everything matches empty string */ - return (char*) haystack; - - plen = haystacklen; - for (p = (char*) haystack; p != NULL; p = memchr(p + 1, *needle, plen-1)) { - plen = haystacklen - (p - haystack); - - if (plen < len) return NULL; - - if (strncmp(p, needle, len) == 0) - return (p); - } - return NULL; -} - static int icapParseConnectionClose(const IcapStateData * icap, const char *s, const char *e) {