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