Added support for SRU scan.
[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.21 2007-08-16 10:09:36 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
67     char *user;
68     char *group;
69     char *password;
70
71     int async;
72     int support_named_resultsets;
73     int last_event;
74
75     int maximum_record_size;
76     int preferred_message_size;
77
78     ZOOM_task tasks;
79     ZOOM_options options;
80     ZOOM_resultset resultsets;
81     ZOOM_Event m_queue_front;
82     ZOOM_Event m_queue_back;
83     zoom_sru_mode sru_mode;
84 };
85
86 struct ZOOM_options_entry {
87     char *name;
88     char *value;
89     int len;                  /* of `value', which may contain NULs */
90     struct ZOOM_options_entry *next;
91 };
92
93 struct ZOOM_options_p {
94     int refcount;
95     void *callback_handle;
96     ZOOM_options_callback callback_func;
97     struct ZOOM_options_entry *entries;
98     ZOOM_options parent1;
99     ZOOM_options parent2;
100 };
101
102
103 typedef struct ZOOM_record_cache_p *ZOOM_record_cache;
104
105 #define RECORD_HASH_SIZE  131
106
107 struct ZOOM_resultset_p {
108     Z_SortKeySpecList *r_sort_spec;
109     ZOOM_query query;
110     int refcount;
111     int size;
112     int step;
113     int piggyback;
114     char *setname;
115     char *schema;
116     ODR odr;
117     ZOOM_record_cache record_hash[RECORD_HASH_SIZE];
118     ZOOM_options options;
119     ZOOM_connection connection;
120     ZOOM_resultset next;
121     char **databaseNames;
122     int num_databaseNames;
123 };
124
125 struct ZOOM_record_p {
126     ODR odr;
127     WRBUF wrbuf_marc;
128     WRBUF wrbuf_iconv;
129     WRBUF wrbuf_opac;
130     Z_NamePlusRecord *npr;
131 };
132
133 struct ZOOM_record_cache_p {
134     struct ZOOM_record_p rec;
135     char *elementSetName;
136     char *syntax;
137     char *schema;
138     int pos;
139     ZOOM_record_cache next;
140 };
141
142 struct ZOOM_scanset_p {
143     int refcount;
144     ODR odr;
145     ZOOM_options options;
146     ZOOM_connection connection;
147     ZOOM_query query;
148     Z_ScanResponse *scan_response;
149     Z_SRW_scanResponse *srw_scan_response;
150
151     char **databaseNames;
152     int num_databaseNames;
153 };
154
155 struct ZOOM_package_p {
156     int refcount;
157     ODR odr_out;
158     ZOOM_options options;
159     ZOOM_connection connection;
160     char *buf_out;
161     int len_out;
162 };
163
164 struct ZOOM_task_p {
165     int running;
166     int which;
167     union {
168 #define ZOOM_TASK_SEARCH 1
169         struct {
170             int count;
171             int start;
172             ZOOM_resultset resultset;
173             char *syntax;
174             char *elementSetName;
175         } search;
176 #define ZOOM_TASK_RETRIEVE 2
177         struct {
178             int start;
179             ZOOM_resultset resultset;
180             int count;
181             char *syntax;
182             char *elementSetName;
183         } retrieve;
184 #define ZOOM_TASK_CONNECT 3
185 #define ZOOM_TASK_SCAN 4
186         struct {
187             ZOOM_scanset scan;
188         } scan;
189 #define ZOOM_TASK_PACKAGE 5
190         ZOOM_package package;
191 #define ZOOM_TASK_SORT 6
192         struct {
193             ZOOM_resultset resultset;
194             ZOOM_query q;
195         } sort;
196     } u;
197     ZOOM_task next;
198 };
199
200 struct ZOOM_Event_p {
201     int kind;
202     ZOOM_Event next;
203     ZOOM_Event prev;
204 };
205
206 void ZOOM_options_addref (ZOOM_options opt);
207
208 /*
209  * Local variables:
210  * c-basic-offset: 4
211  * indent-tabs-mode: nil
212  * End:
213  * vim: shiftwidth=4 tabstop=8 expandtab
214  */
215