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