1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2009 Index Data
3 * See the file LICENSE for details.
8 * \brief Implements HTTP and Z39.50 encoding and decoding.
15 int z_GDU (ODR o, Z_GDU **p, int opt, const char *name)
17 if (o->direction == ODR_DECODE) {
18 *p = (Z_GDU *) odr_malloc(o, sizeof(**p));
19 if (o->size > 10 && !memcmp(o->buf, "HTTP/", 5))
21 (*p)->which = Z_GDU_HTTP_Response;
22 return yaz_decode_http_response(o, &(*p)->u.HTTP_Response);
25 else if (o->size > 5 &&
26 o->buf[0] >= 0x20 && o->buf[0] < 0x7f
27 && o->buf[1] >= 0x20 && o->buf[1] < 0x7f
28 && o->buf[2] >= 0x20 && o->buf[2] < 0x7f
29 && o->buf[3] >= 0x20 && o->buf[3] < 0x7f)
31 (*p)->which = Z_GDU_HTTP_Request;
32 return yaz_decode_http_request(o, &(*p)->u.HTTP_Request);
36 (*p)->which = Z_GDU_Z3950;
37 return z_APDU(o, &(*p)->u.z3950, opt, 0);
40 else /* ENCODE or PRINT */
44 case Z_GDU_HTTP_Response:
45 return yaz_encode_http_response(o, (*p)->u.HTTP_Response);
46 case Z_GDU_HTTP_Request:
47 return yaz_encode_http_request(o, (*p)->u.HTTP_Request);
49 return z_APDU(o, &(*p)->u.z3950, opt, 0);
58 * indent-tabs-mode: nil
60 * vim: shiftwidth=4 tabstop=8 expandtab