More work on event queues. *_option returns new value (not previous).
[yaz-moved-to-github.git] / zoom / zoom-p.h
1 /*
2  * Private C header for ZOOM C.
3  * $Id: zoom-p.h,v 1.4 2001-11-13 22:57:03 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 Z3950_Event_p *Z3950_Event;
11
12 struct Z3950_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 Z3950_SELECT_READ 1
24 #define Z3950_SELECT_WRITE 2
25 #define Z3950_SELECT_EXCEPT 4
26
27 struct Z3950_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     Z3950_task tasks;
45     Z3950_options options;
46     Z3950_resultset resultsets;
47     Z3950_Event m_queue_front;
48     Z3950_Event m_queue_back;
49 };
50
51
52 struct Z3950_options_entry {
53     char *name;
54     char *value;
55     struct Z3950_options_entry *next;
56 };
57
58 struct Z3950_options_p {
59     int refcount;
60     void *callback_handle;
61     Z3950_options_callback callback_func;
62     struct Z3950_options_entry *entries;
63     Z3950_options parent;
64 };
65
66 typedef struct Z3950_record_cache_p *Z3950_record_cache;
67
68 struct Z3950_resultset_p {
69     Z_Query *r_query;
70     Z_SortKeySpecList *r_sort_spec;
71     Z3950_query search;
72     int refcount;
73     int size;
74     int start;
75     int count;
76     int piggyback;
77     ODR odr;
78     Z3950_record_cache record_cache;
79     Z3950_options options;
80     Z3950_connection connection;
81     Z3950_resultset next;
82 };
83
84 struct Z3950_record_p {
85     ODR odr;
86     WRBUF wrbuf_marc;
87     Z_NamePlusRecord *npr;
88 };
89
90 struct Z3950_record_cache_p {
91     struct Z3950_record_p rec;
92     char *elementSetName;
93     int pos;
94     Z3950_record_cache next;
95 };
96
97 struct Z3950_task_p {
98     int running;
99     int which;
100     union {
101 #define Z3950_TASK_SEARCH 1
102         Z3950_resultset resultset;
103 #define Z3950_TASK_RETRIEVE 2
104         /** also resultset here */
105 #define Z3950_TASK_CONNECT 3
106     } u;
107     Z3950_task next;
108 };
109
110 struct Z3950_Event_p {
111     int kind;
112     Z3950_Event next;
113     Z3950_Event prev;
114 };
115
116
117 #ifndef YAZ_DATE
118 COMSTACK cs_create_host(const char *type_and_host, int blocking, void **vp);
119 Odr_oid *yaz_str_to_z3950oid (ODR o, int oid_class, const char *str);
120 Z_SortKeySpecList *yaz_sort_spec (ODR out, const char *arg);
121 #else
122 #include <yaz/sortspec.h>
123 #endif