X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fcomstack.c;h=96b841ca38dbd0d38e368ac7932f87350954a4ab;hb=aa8b9d245d1ff378c907669a350a4e484b35eac5;hp=050fcc1e6d6c00f23f442ab9483a1674db8869c1;hpb=82988dd4a36739a5559015cb7df4dd757765d289;p=yaz-moved-to-github.git diff --git a/src/comstack.c b/src/comstack.c index 050fcc1..96b841c 100644 --- a/src/comstack.c +++ b/src/comstack.c @@ -2,7 +2,7 @@ * Copyright (c) 1995-2004, Index Data * See the file LICENSE for details. * - * $Id: comstack.c,v 1.3 2004-01-06 19:12:19 adam Exp $ + * $Id: comstack.c,v 1.5 2004-02-19 23:20:44 adam Exp $ */ #include @@ -14,6 +14,10 @@ #include #include +#ifdef WIN32 +#define strncasecmp _strnicmp +#endif + static const char *cs_errlist[] = { "No error or unspecified error", @@ -136,6 +140,7 @@ int cs_look (COMSTACK cs) return cs->event; } +#define CHUNK_DEBUG 0 int cs_complete_auto(const unsigned char *buf, int len) { if (len > 5 && buf[0] >= 0x20 && buf[0] < 0x7f @@ -156,23 +161,25 @@ int cs_complete_auto(const unsigned char *buf, int len) { if (chunked) { + /* inside chunked body .. */ while(1) { int chunk_len = 0; i += 2; -#if 0 +#if CHUNK_DEBUG /* debugging */ if (i >>"); + printf ("\n<<<"); + int j; for (j = i; j <= i+4; j++) printf ("%c", buf[j]); - printf ("<<<\n"); + printf (">>>\n"); } #endif while (1) if (i >= len-2) { -#if 0 +#if CHUNK_DEBUG /* debugging */ printf ("XXXXXXXX not there yet 1\n"); printf ("i=%d len=%d\n", i, len); @@ -192,6 +199,9 @@ int cs_complete_auto(const unsigned char *buf, int len) if (buf[i] != '\r' || buf[i+1] != '\n' || chunk_len < 0) return i+2; /* bad. stop now */ +#if CHUNK_DEBUG + printf ("XXXXXX chunk_len=%d\n", chunk_len); +#endif if (chunk_len == 0) { /* consider trailing headers .. */ @@ -203,7 +213,7 @@ int cs_complete_auto(const unsigned char *buf, int len) return i+4; i++; } -#if 0 +#if CHUNK_DEBUG /* debugging */ printf ("XXXXXXXXX not there yet 2\n"); printf ("i=%d len=%d\n", i, len);