X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=zutil%2Fzgdu.c;h=dbd921e14ea8f08bb5b1fb372a8332f295e4110f;hb=94c77ca831e55b3dee31184347f25dd0583085d2;hp=6213b12c7e2433bf8701b589253a2ef7e8dc7789;hpb=d9d97a04b6f9597225b8440dad61790dfa39a751;p=yaz-moved-to-github.git diff --git a/zutil/zgdu.c b/zutil/zgdu.c index 6213b12..dbd921e 100644 --- a/zutil/zgdu.c +++ b/zutil/zgdu.c @@ -2,12 +2,12 @@ * Copyright (c) 2002-2003, Index Data. * See the file LICENSE for details. * - * $Id: zgdu.c,v 1.3 2003-02-17 14:35:42 adam Exp $ + * $Id: zgdu.c,v 1.9 2003-03-11 11:09:17 adam Exp $ */ -#include - -#define HTTP_DEBUG 1 +#include +#include +#include static int decode_headers_content(ODR o, int off, Z_HTTP_Header **headers, char **content_buf, int *content_len) @@ -185,9 +185,6 @@ int z_GDU (ODR o, Z_GDU **p, int opt, const char *name) Z_HTTP_Response *hr; (*p)->which = Z_GDU_HTTP_Response; -#if HTTP_DEBUG - fprintf(stderr, "-- HTTP decode:\n%.*s\n", o->size, o->buf); -#endif hr = (*p)->u.HTTP_Response = (Z_HTTP_Response *) odr_malloc(o, sizeof(*hr)); po = i = 5; @@ -223,9 +220,6 @@ int z_GDU (ODR o, Z_GDU **p, int opt, const char *name) int i, po; Z_HTTP_Request *hr; -#if HTTP_DEBUG - fprintf(stderr, "-- HTTP decode:\n%.*s\n", o->size, o->buf); -#endif (*p)->which = Z_GDU_HTTP_Request; hr = (*p)->u.HTTP_Request = (Z_HTTP_Request *) odr_malloc(o, sizeof(*hr)); @@ -283,8 +277,9 @@ int z_GDU (ODR o, Z_GDU **p, int opt, const char *name) return z_APDU(o, &(*p)->u.z3950, opt, 0); } } - else if (o->direction == ODR_ENCODE) + else /* ENCODE or PRINT */ { + int top0 = o->top; char sbuf[80]; Z_HTTP_Header *h; switch((*p)->which) @@ -316,9 +311,12 @@ int z_GDU (ODR o, Z_GDU **p, int opt, const char *name) odr_write(o, (unsigned char *) (*p)->u.HTTP_Response->content_buf, (*p)->u.HTTP_Response->content_len); -#if HTTP_DEBUG - fprintf(stderr, "-- HTTP response:\n%.*s\n", o->top, o->buf); -#endif + if (o->direction == ODR_PRINT) + { + fprintf(o->print, "-- HTTP response:\n%.*s\n", o->top - top0, + o->buf + top0); + fprintf(o->print, "-- \n"); + } break; case Z_GDU_HTTP_Request: odr_write(o, (unsigned char *) (*p)->u.HTTP_Request->method, @@ -352,23 +350,10 @@ int z_GDU (ODR o, Z_GDU **p, int opt, const char *name) odr_write(o, (unsigned char *) (*p)->u.HTTP_Request->content_buf, (*p)->u.HTTP_Request->content_len); -#if HTTP_DEBUG - fprintf(stderr, "-- HTTP request:\n%.*s\n", o->top, o->buf); -#endif - break; - case Z_GDU_Z3950: - return z_APDU(o, &(*p)->u.z3950, opt, 0); - } - } - else if (o->direction == ODR_PRINT) - { - switch((*p)->which) - { - case Z_GDU_HTTP_Response: - fprintf (stderr, "not implemented"); - break; - case Z_GDU_HTTP_Request: - fprintf (stderr, "not implemented"); + if (o->direction == ODR_PRINT) + { + fprintf(o->print, "-- HTTP request:\n%.*s\n", o->top, o->buf); + } break; case Z_GDU_Z3950: return z_APDU(o, &(*p)->u.z3950, opt, 0);