e24a4ab4db8e8753291e6782fd2a7ef3812052af
[yaz-moved-to-github.git] / include / yaz / zgdu.h
1 /*
2  * Copyright (c) 1998-2003, Index Data
3  * See the file LICENSE for details.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Id: zgdu.h,v 1.2 2003-12-04 11:46:36 adam Exp $
7  */
8 #ifndef Z_GDU_H
9 #define Z_GDU_H
10
11 #include <yaz/z-core.h>
12
13 YAZ_BEGIN_CDECL
14
15 typedef struct Z_HTTP_Header Z_HTTP_Header;
16
17 struct Z_HTTP_Header {
18     char *name;
19     char *value;
20     Z_HTTP_Header *next;
21 };
22
23 typedef struct {
24     char *method;
25     char *version;
26     char *path;
27     Z_HTTP_Header *headers;
28     char *content_buf;
29     int content_len;
30 } Z_HTTP_Request;
31
32 typedef struct {
33     int code;
34     char *version;
35     Z_HTTP_Header *headers;
36     char *content_buf;
37     int content_len;
38 } Z_HTTP_Response;
39
40 #define Z_GDU_Z3950         1
41 #define Z_GDU_HTTP_Request  2
42 #define Z_GDU_HTTP_Response 3
43 typedef struct {
44     int which;
45     union {
46         Z_APDU *z3950;
47         Z_HTTP_Request *HTTP_Request;
48         Z_HTTP_Response *HTTP_Response;
49     } u;
50 } Z_GDU ;
51 YAZ_EXPORT int z_GDU (ODR o, Z_GDU **p, int opt, const char *name);
52 YAZ_EXPORT void z_HTTP_header_add(ODR o, Z_HTTP_Header **hp, const char *n,
53                                   const char *v);
54 YAZ_EXPORT const char *z_HTTP_header_lookup(Z_HTTP_Header *hp, const char *n);
55
56 YAZ_EXPORT const char *z_HTTP_errmsg(int code);
57
58 YAZ_EXPORT Z_GDU *z_get_HTTP_Response(ODR o, int code);
59 YAZ_EXPORT Z_GDU *z_get_HTTP_Request(ODR o);
60
61 YAZ_END_CDECL
62
63 #endif