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