dd092452ab8b58372d05aab030286d702ce0d260
[yaz-moved-to-github.git] / include / yaz / zgdu.h
1 /*
2  * Copyright (C) 1995-2005, Index Data ApS
3  * See the file LICENSE for details.
4  *
5  * $Id: zgdu.h,v 1.8 2006-09-14 07:39:49 marc Exp $
6  */
7
8 /**
9  * \file zgdu.h
10  * \brief Header for the Z_GDU (HTTP or Z39.50 package)
11  */
12
13 #ifndef Z_GDU_H
14 #define Z_GDU_H
15
16 #include <yaz/z-core.h>
17
18 YAZ_BEGIN_CDECL
19
20 typedef struct Z_HTTP_Header Z_HTTP_Header;
21
22 struct Z_HTTP_Header {
23     char *name;
24     char *value;
25     Z_HTTP_Header *next;
26 };
27
28 typedef struct {
29     char *method;
30     char *version;
31     char *path;
32     Z_HTTP_Header *headers;
33     char *content_buf;
34     int content_len;
35 } Z_HTTP_Request;
36
37 typedef struct {
38     int code;
39     char *version;
40     Z_HTTP_Header *headers;
41     char *content_buf;
42     int content_len;
43 } Z_HTTP_Response;
44
45 #define Z_GDU_Z3950         1
46 #define Z_GDU_HTTP_Request  2
47 #define Z_GDU_HTTP_Response 3
48 typedef struct {
49     int which;
50     union {
51         Z_APDU *z3950;
52         Z_HTTP_Request *HTTP_Request;
53         Z_HTTP_Response *HTTP_Response;
54     } u;
55 } Z_GDU ;
56 YAZ_EXPORT int z_GDU (ODR o, Z_GDU **p, int opt, const char *name);
57 YAZ_EXPORT void z_HTTP_header_add(ODR o, Z_HTTP_Header **hp, const char *n,
58                                   const char *v);
59 YAZ_EXPORT void z_HTTP_header_add_content_type(ODR o, Z_HTTP_Header **hp,
60                                                const char *content_type,
61                                                const char *charset);
62
63 YAZ_EXPORT const char *z_HTTP_header_lookup(const Z_HTTP_Header *hp, const char *n);
64
65 YAZ_EXPORT const char *z_HTTP_errmsg(int code);
66
67 YAZ_EXPORT Z_GDU *z_get_HTTP_Response(ODR o, int code);
68 YAZ_EXPORT Z_GDU *z_get_HTTP_Request(ODR o);
69 YAZ_EXPORT Z_GDU *z_get_HTTP_Request_host_path(ODR odr,
70                                                const char *host,
71                                                const char *path);
72
73 YAZ_END_CDECL
74
75 #endif
76 /*
77  * Local variables:
78  * c-basic-offset: 4
79  * indent-tabs-mode: nil
80  * End:
81  * vim: shiftwidth=4 tabstop=8 expandtab
82  */
83