1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) Index Data
3 * See the file LICENSE for details.
7 * \brief Implements HTTP and Z39.50 encoding and decoding.
17 int z_GDU(ODR o, Z_GDU **p, int opt, const char *name)
19 const char *buf = o->op->buf;
20 if (o->direction == ODR_DECODE) {
21 *p = (Z_GDU *) odr_malloc(o, sizeof(**p));
22 if (o->op->size > 10 && !memcmp(buf, "HTTP/", 5))
24 (*p)->which = Z_GDU_HTTP_Response;
25 return yaz_decode_http_response(o, &(*p)->u.HTTP_Response);
28 else if (o->op->size > 5 &&
29 buf[0] >= 0x20 && buf[0] < 0x7f
30 && buf[1] >= 0x20 && buf[1] < 0x7f
31 && buf[2] >= 0x20 && buf[2] < 0x7f
32 && buf[3] >= 0x20 && buf[3] < 0x7f)
34 (*p)->which = Z_GDU_HTTP_Request;
35 return yaz_decode_http_request(o, &(*p)->u.HTTP_Request);
39 (*p)->which = Z_GDU_Z3950;
40 return z_APDU(o, &(*p)->u.z3950, opt, 0);
43 else /* ENCODE or PRINT */
47 case Z_GDU_HTTP_Response:
48 return yaz_encode_http_response(o, (*p)->u.HTTP_Response);
49 case Z_GDU_HTTP_Request:
50 return yaz_encode_http_request(o, (*p)->u.HTTP_Request);
52 return z_APDU(o, &(*p)->u.z3950, opt, 0);
61 * c-file-style: "Stroustrup"
62 * indent-tabs-mode: nil
64 * vim: shiftwidth=4 tabstop=8 expandtab