2 * Public header for ZOOM C.
3 * $Id: zoom.h,v 1.20 2004-02-11 13:37:16 adam Exp $
6 #include <yaz/yconfig.h>
8 #define ZOOM_BEGIN_CDECL YAZ_BEGIN_CDECL
9 #define ZOOM_END_CDECL YAZ_END_CDECL
12 # define ZOOM_API(x) __declspec(dllexport) x __stdcall
14 # define ZOOM_API(x) x
19 /* ----------------------------------------------------------- */
20 /* the types we use */
22 typedef struct ZOOM_options_p *ZOOM_options;
23 typedef struct ZOOM_query_p *ZOOM_query;
24 typedef struct ZOOM_connection_p *ZOOM_connection;
25 typedef struct ZOOM_resultset_p *ZOOM_resultset;
26 typedef struct ZOOM_task_p *ZOOM_task;
27 typedef struct ZOOM_record_p *ZOOM_record;
28 typedef struct ZOOM_scanset_p *ZOOM_scanset;
29 typedef struct ZOOM_package_p *ZOOM_package;
31 typedef const char *(*ZOOM_options_callback)(void *handle, const char *name);
33 /* ----------------------------------------------------------- */
36 /* create connection, connect to host, if portnum is 0, then port is
37 read from host string (e.g. myhost:9821) */
38 ZOOM_API(ZOOM_connection)
39 ZOOM_connection_new (const char *host, int portnum);
41 /* create connection, don't connect, apply options */
42 ZOOM_API(ZOOM_connection)
43 ZOOM_connection_create (ZOOM_options options);
45 /* connect given existing connection */
47 ZOOM_connection_connect(ZOOM_connection c, const char *host,
50 /* destroy connection (close connection also) */
52 ZOOM_connection_destroy (ZOOM_connection c);
54 /* get/set option for connection */
55 ZOOM_API(const char *)
56 ZOOM_connection_option_get (ZOOM_connection c, const char *key);
59 ZOOM_connection_option_set (ZOOM_connection c, const char *key,
62 /* return error code (0 == success, failure otherwise). cp
63 holds error string on failure, addinfo holds addititional info (if any)
66 ZOOM_connection_error (ZOOM_connection c, const char **cp,
67 const char **addinfo);
70 ZOOM_connection_error_x (ZOOM_connection c, const char **cp,
71 const char **addinfo, const char **diagset);
73 /* returns error code */
75 ZOOM_connection_errcode (ZOOM_connection c);
76 /* returns error message */
77 ZOOM_API(const char *)
78 ZOOM_connection_errmsg (ZOOM_connection c);
79 /* returns additional info */
80 ZOOM_API(const char *)
81 ZOOM_connection_addinfo (ZOOM_connection c);
82 /* translates error code into human-readable string */
83 ZOOM_API(const char *)
84 ZOOM_diag_str (int error);
86 #define ZOOM_ERROR_NONE 0
87 #define ZOOM_ERROR_CONNECT 10000
88 #define ZOOM_ERROR_MEMORY 10001
89 #define ZOOM_ERROR_ENCODE 10002
90 #define ZOOM_ERROR_DECODE 10003
91 #define ZOOM_ERROR_CONNECTION_LOST 10004
92 #define ZOOM_ERROR_INIT 10005
93 #define ZOOM_ERROR_INTERNAL 10006
94 #define ZOOM_ERROR_TIMEOUT 10007
95 #define ZOOM_ERROR_UNSUPPORTED_PROTOCOL 10008
96 #define ZOOM_ERROR_UNSUPPORTED_QUERY 10009
97 #define ZOOM_ERROR_INVALID_QUERY 10010
100 ZOOM_connection_last_event(ZOOM_connection cs);
102 #define ZOOM_EVENT_NONE 0
103 #define ZOOM_EVENT_CONNECT 1
104 #define ZOOM_EVENT_SEND_DATA 2
105 #define ZOOM_EVENT_RECV_DATA 3
106 #define ZOOM_EVENT_TIMEOUT 4
107 #define ZOOM_EVENT_UNKNOWN 5
108 #define ZOOM_EVENT_SEND_APDU 6
109 #define ZOOM_EVENT_RECV_APDU 7
110 #define ZOOM_EVENT_RECV_RECORD 8
111 #define ZOOM_EVENT_RECV_SEARCH 9
113 /* ----------------------------------------------------------- */
116 /* create result set given a search */
117 ZOOM_API(ZOOM_resultset)
118 ZOOM_connection_search(ZOOM_connection, ZOOM_query q);
119 /* create result set given PQF query */
120 ZOOM_API(ZOOM_resultset)
121 ZOOM_connection_search_pqf(ZOOM_connection c, const char *q);
123 /* destroy result set */
125 ZOOM_resultset_destroy(ZOOM_resultset r);
127 /* result set option */
128 ZOOM_API(const char *)
129 ZOOM_resultset_option_get (ZOOM_resultset r, const char *key);
131 ZOOM_resultset_option_set (ZOOM_resultset r, const char *key, const char *val);
133 /* return size of result set (alias hit count AKA result count) */
135 ZOOM_resultset_size (ZOOM_resultset r);
137 /* retrieve records */
139 ZOOM_resultset_records (ZOOM_resultset r, ZOOM_record *recs,
140 size_t start, size_t count);
142 /* return record object at pos. Returns 0 if unavailable */
143 ZOOM_API(ZOOM_record)
144 ZOOM_resultset_record (ZOOM_resultset s, size_t pos);
146 /* like ZOOM_resultset_record - but never blocks .. */
147 ZOOM_API(ZOOM_record)
148 ZOOM_resultset_record_immediate (ZOOM_resultset s, size_t pos);
150 /* ----------------------------------------------------------- */
153 /* get record information, in a form given by type */
154 ZOOM_API(const char *)
155 ZOOM_record_get (ZOOM_record rec, const char *type, int *len);
159 ZOOM_record_destroy (ZOOM_record rec);
161 /* return copy of record */
162 ZOOM_API(ZOOM_record)
163 ZOOM_record_clone (ZOOM_record srec);
165 /* ----------------------------------------------------------- */
168 /* create search object */
170 ZOOM_query_create(void);
173 ZOOM_query_destroy(ZOOM_query s);
176 ZOOM_query_cql(ZOOM_query s, const char *str);
179 ZOOM_query_prefix(ZOOM_query s, const char *str);
180 /* specify sort criteria for search */
182 ZOOM_query_sortby(ZOOM_query s, const char *criteria);
184 /* ----------------------------------------------------------- */
186 ZOOM_API(ZOOM_scanset)
187 ZOOM_connection_scan (ZOOM_connection c, const char *startterm);
189 ZOOM_API(const char *)
190 ZOOM_scanset_term(ZOOM_scanset scan, size_t pos,
193 ZOOM_API(const char *)
194 ZOOM_scanset_display_term(ZOOM_scanset scan, size_t pos,
198 ZOOM_scanset_size(ZOOM_scanset scan);
201 ZOOM_scanset_destroy (ZOOM_scanset scan);
203 ZOOM_API(const char *)
204 ZOOM_scanset_option_get (ZOOM_scanset scan, const char *key);
207 ZOOM_scanset_option_set (ZOOM_scanset scan, const char *key,
209 /* ----------------------------------------------------------- */
210 /* Extended Services Packages */
212 ZOOM_API(ZOOM_package)
213 ZOOM_connection_package (ZOOM_connection c, ZOOM_options options);
216 ZOOM_package_destroy(ZOOM_package p);
219 ZOOM_package_send (ZOOM_package p, const char *type);
221 ZOOM_API(const char *)
222 ZOOM_package_option_get (ZOOM_package p, const char *key);
225 ZOOM_package_option_set (ZOOM_package p, const char *key,
228 /* ----------------------------------------------------------- */
231 ZOOM_API(ZOOM_options_callback)
232 ZOOM_options_set_callback (ZOOM_options opt,
233 ZOOM_options_callback c,
235 ZOOM_API(ZOOM_options)
236 ZOOM_options_create (void);
238 ZOOM_API(ZOOM_options)
239 ZOOM_options_create_with_parent (ZOOM_options parent);
241 ZOOM_API(ZOOM_options)
242 ZOOM_options_create_with_parent2 (ZOOM_options parent1,
243 ZOOM_options parent2);
245 ZOOM_API(const char *)
246 ZOOM_options_get (ZOOM_options opt, const char *name);
249 ZOOM_options_set (ZOOM_options opt, const char *name, const char *v);
252 ZOOM_options_setl (ZOOM_options opt, const char *name, const char *value,
256 ZOOM_options_destroy (ZOOM_options opt);
259 ZOOM_options_get_bool (ZOOM_options opt, const char *name, int defa);
262 ZOOM_options_get_int (ZOOM_options opt, const char *name, int defa);
265 ZOOM_options_set_int(ZOOM_options opt, const char *name, int value);
267 /* ----------------------------------------------------------- */
269 /* poll for events on a number of connections. Returns positive
270 integer if event occurred ; zero if none occurred and no more
271 events are pending. The positive integer specifies the
272 connection for which the event occurred. */
274 ZOOM_event (int no, ZOOM_connection *cs);