Added new ZOOM connection option "sru_version" which specifies SRU
[yaz-moved-to-github.git] / src / zoom-p.h
1 /*
2  * Copyright (C) 1995-2005, Index Data ApS
3  * See the file LICENSE for details.
4  *
5  * $Id: zoom-p.h,v 1.22 2007-08-23 14:23:23 adam Exp $
6  */
7 /**
8  * \file zoom-p.h
9  * \brief Internal header for ZOOM implementation
10  */
11 #include <yaz/proto.h>
12 #include <yaz/oid_db.h>
13 #include <yaz/comstack.h>
14 #include <yaz/wrbuf.h>
15 #include <yaz/zoom.h>
16 #include <yaz/sortspec.h>
17 #include <yaz/srw.h>
18
19 typedef struct ZOOM_Event_p *ZOOM_Event;
20
21 struct ZOOM_query_p {
22     Z_Query *z_query;
23     Z_SortKeySpecList *sort_spec;
24     int refcount;
25     ODR odr;
26     char *query_string;
27 };
28
29 typedef enum {
30     zoom_sru_error,
31     zoom_sru_soap,
32     zoom_sru_get,
33     zoom_sru_post
34 } zoom_sru_mode;
35     
36
37 typedef struct ZOOM_task_p *ZOOM_task;
38
39 #define STATE_IDLE 0
40 #define STATE_CONNECTING 1
41 #define STATE_ESTABLISHED 2
42
43 struct ZOOM_connection_p {
44     enum oid_proto proto;
45     COMSTACK cs;
46     char *host_port;
47     char *path;
48     int error;
49     char *addinfo;
50     char *diagset;
51     int state;
52     int mask;
53     int reconnect_ok;
54     ODR odr_in;
55     ODR odr_out;
56     char *buf_in;
57     int len_in;
58     char *buf_out;
59     int len_out;
60     char *proxy;
61     char *charset;
62     char *lang;
63     char *cookie_out;
64     char *cookie_in;
65     char *client_IP;
66     char *sru_version;
67
68     char *user;
69     char *group;
70     char *password;
71
72     int async;
73     int support_named_resultsets;
74     int last_event;
75
76     int maximum_record_size;
77     int preferred_message_size;
78
79     ZOOM_task tasks;
80     ZOOM_options options;
81     ZOOM_resultset resultsets;
82     ZOOM_Event m_queue_front;
83     ZOOM_Event m_queue_back;
84     zoom_sru_mode sru_mode;
85 };
86
87 struct ZOOM_options_entry {
88     char *name;
89     char *value;
90     int len;                  /* of `value', which may contain NULs */
91     struct ZOOM_options_entry *next;
92 };
93
94 struct ZOOM_options_p {
95     int refcount;
96     void *callback_handle;
97     ZOOM_options_callback callback_func;
98     struct ZOOM_options_entry *entries;
99     ZOOM_options parent1;
100     ZOOM_options parent2;
101 };
102
103
104 typedef struct ZOOM_record_cache_p *ZOOM_record_cache;
105
106 #define RECORD_HASH_SIZE  131
107
108 struct ZOOM_resultset_p {
109     Z_SortKeySpecList *r_sort_spec;
110     ZOOM_query query;
111     int refcount;
112     int size;
113     int step;
114     int piggyback;
115     char *setname;
116     char *schema;
117     ODR odr;
118     ZOOM_record_cache record_hash[RECORD_HASH_SIZE];
119     ZOOM_options options;
120     ZOOM_connection connection;
121     ZOOM_resultset next;
122     char **databaseNames;
123     int num_databaseNames;
124 };
125
126 struct ZOOM_record_p {
127     ODR odr;
128     WRBUF wrbuf_marc;
129     WRBUF wrbuf_iconv;
130     WRBUF wrbuf_opac;
131     Z_NamePlusRecord *npr;
132 };
133
134 struct ZOOM_record_cache_p {
135     struct ZOOM_record_p rec;
136     char *elementSetName;
137     char *syntax;
138     char *schema;
139     int pos;
140     ZOOM_record_cache next;
141 };
142
143 struct ZOOM_scanset_p {
144     int refcount;
145     ODR odr;
146     ZOOM_options options;
147     ZOOM_connection connection;
148     ZOOM_query query;
149     Z_ScanResponse *scan_response;
150     Z_SRW_scanResponse *srw_scan_response;
151
152     char **databaseNames;
153     int num_databaseNames;
154 };
155
156 struct ZOOM_package_p {
157     int refcount;
158     ODR odr_out;
159     ZOOM_options options;
160     ZOOM_connection connection;
161     char *buf_out;
162     int len_out;
163 };
164
165 struct ZOOM_task_p {
166     int running;
167     int which;
168     union {
169 #define ZOOM_TASK_SEARCH 1
170         struct {
171             int count;
172             int start;
173             ZOOM_resultset resultset;
174             char *syntax;
175             char *elementSetName;
176         } search;
177 #define ZOOM_TASK_RETRIEVE 2
178         struct {
179             int start;
180             ZOOM_resultset resultset;
181             int count;
182             char *syntax;
183             char *elementSetName;
184         } retrieve;
185 #define ZOOM_TASK_CONNECT 3
186 #define ZOOM_TASK_SCAN 4
187         struct {
188             ZOOM_scanset scan;
189         } scan;
190 #define ZOOM_TASK_PACKAGE 5
191         ZOOM_package package;
192 #define ZOOM_TASK_SORT 6
193         struct {
194             ZOOM_resultset resultset;
195             ZOOM_query q;
196         } sort;
197     } u;
198     ZOOM_task next;
199 };
200
201 struct ZOOM_Event_p {
202     int kind;
203     ZOOM_Event next;
204     ZOOM_Event prev;
205 };
206
207 void ZOOM_options_addref (ZOOM_options opt);
208
209 /*
210  * Local variables:
211  * c-basic-offset: 4
212  * indent-tabs-mode: nil
213  * End:
214  * vim: shiftwidth=4 tabstop=8 expandtab
215  */
216