Fixes for bug #709: Records are fetched in wrong format when tasks are
[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.14 2006-10-26 15:34:46 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 #define ZOOM_SELECT_READ 1
42 #define ZOOM_SELECT_WRITE 2
43 #define ZOOM_SELECT_EXCEPT 4
44
45 struct ZOOM_connection_p {
46     enum oid_proto proto;
47     COMSTACK cs;
48     char *host_port;
49     char *path;
50     int error;
51     char *addinfo;
52     char *diagset;
53     int state;
54     int mask;
55     int reconnect_ok;
56     ODR odr_in;
57     ODR odr_out;
58     char *buf_in;
59     int len_in;
60     char *buf_out;
61     int len_out;
62     char *proxy;
63     char *charset;
64     char *lang;
65     char *cookie_out;
66     char *cookie_in;
67     char *client_IP;
68     int async;
69     int support_named_resultsets;
70     int last_event;
71     ZOOM_task tasks;
72     ZOOM_options options;
73     ZOOM_resultset resultsets;
74     ZOOM_Event m_queue_front;
75     ZOOM_Event m_queue_back;
76     zoom_sru_mode sru_mode;
77 };
78
79 struct ZOOM_options_entry {
80     char *name;
81     char *value;
82     int len;                  /* of `value', which may contain NULs */
83     struct ZOOM_options_entry *next;
84 };
85
86 struct ZOOM_options_p {
87     int refcount;
88     void *callback_handle;
89     ZOOM_options_callback callback_func;
90     struct ZOOM_options_entry *entries;
91     ZOOM_options parent1;
92     ZOOM_options parent2;
93 };
94
95
96 typedef struct ZOOM_record_cache_p *ZOOM_record_cache;
97
98 #define RECORD_HASH_SIZE  131
99
100 struct ZOOM_resultset_p {
101     Z_SortKeySpecList *r_sort_spec;
102     ZOOM_query query;
103     int refcount;
104     int size;
105     int step;
106     int piggyback;
107     char *setname;
108     char *schema;
109     ODR odr;
110     ZOOM_record_cache record_hash[RECORD_HASH_SIZE];
111     ZOOM_options options;
112     ZOOM_connection connection;
113     ZOOM_resultset next;
114 };
115
116 struct ZOOM_record_p {
117     ODR odr;
118     WRBUF wrbuf_marc;
119     WRBUF wrbuf_iconv;
120     WRBUF wrbuf_opac;
121     Z_NamePlusRecord *npr;
122 };
123
124 struct ZOOM_record_cache_p {
125     struct ZOOM_record_p rec;
126     char *elementSetName;
127     char *syntax;
128     char *schema;
129     int pos;
130     ZOOM_record_cache next;
131 };
132
133 struct ZOOM_scanset_p {
134     int refcount;
135     ODR odr;
136     ZOOM_options options;
137     ZOOM_connection connection;
138     Z_AttributesPlusTerm *termListAndStartPoint;
139     Z_AttributeSetId *attributeSet;
140     Z_ScanResponse *scan_response;
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  * Local variables:
197  * c-basic-offset: 4
198  * indent-tabs-mode: nil
199  * End:
200  * vim: shiftwidth=4 tabstop=8 expandtab
201  */
202