87b5fb62054613c8e77428ac21362ce4f255babb
[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.24 2007-09-09 05:54:45 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     const char *schema;
133     Z_SRW_diagnostic *diag;
134     const char *diagset;
135 };
136
137 struct ZOOM_record_cache_p {
138     struct ZOOM_record_p rec;
139     char *elementSetName;
140     char *syntax;
141     char *schema;
142     int pos;
143     ZOOM_record_cache next;
144 };
145
146 struct ZOOM_scanset_p {
147     int refcount;
148     ODR odr;
149     ZOOM_options options;
150     ZOOM_connection connection;
151     ZOOM_query query;
152     Z_ScanResponse *scan_response;
153     Z_SRW_scanResponse *srw_scan_response;
154
155     char **databaseNames;
156     int num_databaseNames;
157 };
158
159 struct ZOOM_package_p {
160     int refcount;
161     ODR odr_out;
162     ZOOM_options options;
163     ZOOM_connection connection;
164     char *buf_out;
165     int len_out;
166 };
167
168 struct ZOOM_task_p {
169     int running;
170     int which;
171     union {
172 #define ZOOM_TASK_SEARCH 1
173         struct {
174             int count;
175             int start;
176             ZOOM_resultset resultset;
177             char *syntax;
178             char *elementSetName;
179         } search;
180 #define ZOOM_TASK_RETRIEVE 2
181         struct {
182             int start;
183             ZOOM_resultset resultset;
184             int count;
185             char *syntax;
186             char *elementSetName;
187         } retrieve;
188 #define ZOOM_TASK_CONNECT 3
189 #define ZOOM_TASK_SCAN 4
190         struct {
191             ZOOM_scanset scan;
192         } scan;
193 #define ZOOM_TASK_PACKAGE 5
194         ZOOM_package package;
195 #define ZOOM_TASK_SORT 6
196         struct {
197             ZOOM_resultset resultset;
198             ZOOM_query q;
199         } sort;
200     } u;
201     ZOOM_task next;
202 };
203
204 struct ZOOM_Event_p {
205     int kind;
206     ZOOM_Event next;
207     ZOOM_Event prev;
208 };
209
210 void ZOOM_options_addref (ZOOM_options opt);
211
212 /*
213  * Local variables:
214  * c-basic-offset: 4
215  * indent-tabs-mode: nil
216  * End:
217  * vim: shiftwidth=4 tabstop=8 expandtab
218  */
219