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