28446c8c166e01af4a04cfa94845a790705579c2
[yaz-moved-to-github.git] / zoom / zoom-p.h
1 /*
2  * Private C header for ZOOM C.
3  * $Id: zoom-p.h,v 1.6 2001-11-22 09:45:31 adam Exp $
4  */
5 #include <yaz/proto.h>
6 #include <yaz/comstack.h>
7 #include <yaz/wrbuf.h>
8 #include <yaz/zoom.h>
9
10 typedef struct ZOOM_Event_p *ZOOM_Event;
11
12 struct ZOOM_query_p {
13     Z_Query *query;
14     Z_SortKeySpecList *sort_spec;
15     int refcount;
16     ODR odr;
17 };
18
19 #define STATE_IDLE 0
20 #define STATE_CONNECTING 1
21 #define STATE_ESTABLISHED 2
22
23 #define ZOOM_SELECT_READ 1
24 #define ZOOM_SELECT_WRITE 2
25 #define ZOOM_SELECT_EXCEPT 4
26
27 struct ZOOM_connection_p {
28     COMSTACK cs;
29     char *host_port;
30     int error;
31     char *addinfo;
32     int state;
33     int mask;
34     ODR odr_in;
35     ODR odr_out;
36     char *buf_in;
37     int len_in;
38     char *buf_out;
39     int len_out;
40     char *proxy;
41     char *cookie_out;
42     char *cookie_in;
43     int async;
44     int support_named_resultsets;
45     ZOOM_task tasks;
46     ZOOM_options options;
47     ZOOM_resultset resultsets;
48     ZOOM_Event m_queue_front;
49     ZOOM_Event m_queue_back;
50 };
51
52
53 struct ZOOM_options_entry {
54     char *name;
55     char *value;
56     struct ZOOM_options_entry *next;
57 };
58
59 struct ZOOM_options_p {
60     int refcount;
61     void *callback_handle;
62     ZOOM_options_callback callback_func;
63     struct ZOOM_options_entry *entries;
64     ZOOM_options parent;
65 };
66
67 typedef struct ZOOM_record_cache_p *ZOOM_record_cache;
68
69 struct ZOOM_resultset_p {
70     Z_Query *r_query;
71     Z_SortKeySpecList *r_sort_spec;
72     ZOOM_query search;
73     int refcount;
74     int size;
75     int start;
76     int count;
77     int piggyback;
78     char *setname;
79     ODR odr;
80     ZOOM_record_cache record_cache;
81     ZOOM_options options;
82     ZOOM_connection connection;
83     ZOOM_resultset next;
84 };
85
86 struct ZOOM_record_p {
87     ODR odr;
88     WRBUF wrbuf_marc;
89     Z_NamePlusRecord *npr;
90 };
91
92 struct ZOOM_record_cache_p {
93     struct ZOOM_record_p rec;
94     char *elementSetName;
95     int pos;
96     ZOOM_record_cache next;
97 };
98
99 struct ZOOM_task_p {
100     int running;
101     int which;
102     union {
103 #define ZOOM_TASK_SEARCH 1
104         ZOOM_resultset resultset;
105 #define ZOOM_TASK_RETRIEVE 2
106         /** also resultset here */
107 #define ZOOM_TASK_CONNECT 3
108     } u;
109     ZOOM_task next;
110 };
111
112 struct ZOOM_Event_p {
113     int kind;
114     ZOOM_Event next;
115     ZOOM_Event prev;
116 };
117
118
119 #ifndef YAZ_DATE
120 COMSTACK cs_create_host(const char *type_and_host, int blocking, void **vp);
121 Odr_oid *yaz_str_to_z3950oid (ODR o, int oid_class, const char *str);
122 Z_SortKeySpecList *yaz_sort_spec (ODR out, const char *arg);
123 #else
124 #include <yaz/sortspec.h>
125 #endif