New ZOOM C option, "rpnCharset", which allows client-side conversion of
[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.19 2007-04-30 08:29:07 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     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     yaz_iconv_t rpn_iconv;
113 };
114
115 struct ZOOM_record_p {
116     ODR odr;
117     WRBUF wrbuf_marc;
118     WRBUF wrbuf_iconv;
119     WRBUF wrbuf_opac;
120     Z_NamePlusRecord *npr;
121 };
122
123 struct ZOOM_record_cache_p {
124     struct ZOOM_record_p rec;
125     char *elementSetName;
126     char *syntax;
127     char *schema;
128     int pos;
129     ZOOM_record_cache next;
130 };
131
132 struct ZOOM_scanset_p {
133     int refcount;
134     ODR odr;
135     ZOOM_options options;
136     ZOOM_connection connection;
137     Z_AttributesPlusTerm *termListAndStartPoint;
138     Z_AttributeSetId *attributeSet;
139     Z_ScanResponse *scan_response;
140     char **databaseNames;
141     int num_databaseNames;
142 };
143
144 struct ZOOM_package_p {
145     int refcount;
146     ODR odr_out;
147     ZOOM_options options;
148     ZOOM_connection connection;
149     char *buf_out;
150     int len_out;
151 };
152
153 struct ZOOM_task_p {
154     int running;
155     int which;
156     union {
157 #define ZOOM_TASK_SEARCH 1
158         struct {
159             int count;
160             int start;
161             ZOOM_resultset resultset;
162             char *syntax;
163             char *elementSetName;
164         } search;
165 #define ZOOM_TASK_RETRIEVE 2
166         struct {
167             int start;
168             ZOOM_resultset resultset;
169             int count;
170             char *syntax;
171             char *elementSetName;
172         } retrieve;
173 #define ZOOM_TASK_CONNECT 3
174 #define ZOOM_TASK_SCAN 4
175         struct {
176             ZOOM_scanset scan;
177         } scan;
178 #define ZOOM_TASK_PACKAGE 5
179         ZOOM_package package;
180 #define ZOOM_TASK_SORT 6
181         struct {
182             ZOOM_resultset resultset;
183             ZOOM_query q;
184         } sort;
185     } u;
186     ZOOM_task next;
187 };
188
189 struct ZOOM_Event_p {
190     int kind;
191     ZOOM_Event next;
192     ZOOM_Event prev;
193 };
194
195 void ZOOM_options_addref (ZOOM_options opt);
196
197 /*
198  * Local variables:
199  * c-basic-offset: 4
200  * indent-tabs-mode: nil
201  * End:
202  * vim: shiftwidth=4 tabstop=8 expandtab
203  */
204