--------------------- PatchSet 5979 Date: 2003/10/17 15:59:41 Author: rhorstmann Branch: icap-2_5 Tag: (none) Log: added missing strnstr (copied from gnutls) Members: src/icap_common.c:1.1.2.12->1.1.2.13 Index: squid/src/icap_common.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/icap_common.c,v retrieving revision 1.1.2.12 retrieving revision 1.1.2.13 diff -u -r1.1.2.12 -r1.1.2.13 --- squid/src/icap_common.c 17 Oct 2003 15:13:21 -0000 1.1.2.12 +++ squid/src/icap_common.c 17 Oct 2003 15:59:41 -0000 1.1.2.13 @@ -1,5 +1,5 @@ /* - * $Id: icap_common.c,v 1.1.2.12 2003/10/17 15:13:21 dwsquid Exp $ + * $Id: icap_common.c,v 1.1.2.13 2003/10/17 15:59:41 rhorstmann Exp $ * * DEBUG: section 81 Internet Content Adaptation Protocol (ICAP) Client * AUTHOR: Geetha Manjunath, Hewlett Packard Company @@ -411,6 +411,28 @@ 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) {