2 * Copyright (C) 1995-2005, Index Data ApS
3 * See the file LICENSE for details.
5 * $Id: zoom.h,v 1.34 2006-04-07 11:27:24 adam Exp $
9 * \brief Header for ZOOM
13 #include <yaz/yconfig.h>
15 #define ZOOM_BEGIN_CDECL YAZ_BEGIN_CDECL
16 #define ZOOM_END_CDECL YAZ_END_CDECL
19 # define ZOOM_API(x) __declspec(dllexport) x __stdcall
21 # define ZOOM_API(x) x
26 /* ----------------------------------------------------------- */
27 /* the types we use */
29 typedef struct ZOOM_options_p *ZOOM_options;
30 typedef struct ZOOM_query_p *ZOOM_query;
31 typedef struct ZOOM_connection_p *ZOOM_connection;
32 typedef struct ZOOM_resultset_p *ZOOM_resultset;
33 typedef struct ZOOM_record_p *ZOOM_record;
34 typedef struct ZOOM_scanset_p *ZOOM_scanset;
35 typedef struct ZOOM_package_p *ZOOM_package;
37 typedef const char *(*ZOOM_options_callback)(void *handle, const char *name);
39 /* ----------------------------------------------------------- */
42 /* create connection, connect to host, if portnum is 0, then port is
43 read from host string (e.g. myhost:9821) */
44 ZOOM_API(ZOOM_connection)
45 ZOOM_connection_new (const char *host, int portnum);
47 /* create connection, don't connect, apply options */
48 ZOOM_API(ZOOM_connection)
49 ZOOM_connection_create (ZOOM_options options);
51 /* connect given existing connection */
53 ZOOM_connection_connect(ZOOM_connection c, const char *host,
56 /* destroy connection (close connection also) */
58 ZOOM_connection_destroy (ZOOM_connection c);
60 /* get/set option for connection */
61 ZOOM_API(const char *)
62 ZOOM_connection_option_get (ZOOM_connection c, const char *key);
64 ZOOM_API(const char *)
65 ZOOM_connection_option_getl (ZOOM_connection c, const char *key, int *lenp);
68 ZOOM_connection_option_set (ZOOM_connection c, const char *key,
72 ZOOM_connection_option_setl (ZOOM_connection c, const char *key,
73 const char *val, int len);
75 /* return error code (0 == success, failure otherwise). cp
76 holds error string on failure, addinfo holds addititional info (if any)
79 ZOOM_connection_error (ZOOM_connection c, const char **cp,
80 const char **addinfo);
83 ZOOM_connection_error_x (ZOOM_connection c, const char **cp,
84 const char **addinfo, const char **diagset);
86 /* returns error code */
88 ZOOM_connection_errcode (ZOOM_connection c);
89 /* returns error message */
90 ZOOM_API(const char *)
91 ZOOM_connection_errmsg (ZOOM_connection c);
92 /* returns additional info */
93 ZOOM_API(const char *)
94 ZOOM_connection_addinfo (ZOOM_connection c);
95 /* returns diagnostic set */
96 ZOOM_API(const char *)
97 ZOOM_connection_diagset (ZOOM_connection c);
98 /* translates error code into human-readable string */
99 ZOOM_API(const char *)
100 ZOOM_diag_str (int error);
102 #define ZOOM_ERROR_NONE 0
103 #define ZOOM_ERROR_CONNECT 10000
104 #define ZOOM_ERROR_MEMORY 10001
105 #define ZOOM_ERROR_ENCODE 10002
106 #define ZOOM_ERROR_DECODE 10003
107 #define ZOOM_ERROR_CONNECTION_LOST 10004
108 #define ZOOM_ERROR_INIT 10005
109 #define ZOOM_ERROR_INTERNAL 10006
110 #define ZOOM_ERROR_TIMEOUT 10007
111 #define ZOOM_ERROR_UNSUPPORTED_PROTOCOL 10008
112 #define ZOOM_ERROR_UNSUPPORTED_QUERY 10009
113 #define ZOOM_ERROR_INVALID_QUERY 10010
114 #define ZOOM_ERROR_CQL_PARSE 10011
115 #define ZOOM_ERROR_CQL_TRANSFORM 10012
118 ZOOM_connection_last_event(ZOOM_connection cs);
120 #define ZOOM_EVENT_NONE 0
121 #define ZOOM_EVENT_CONNECT 1
122 #define ZOOM_EVENT_SEND_DATA 2
123 #define ZOOM_EVENT_RECV_DATA 3
124 #define ZOOM_EVENT_TIMEOUT 4
125 #define ZOOM_EVENT_UNKNOWN 5
126 #define ZOOM_EVENT_SEND_APDU 6
127 #define ZOOM_EVENT_RECV_APDU 7
128 #define ZOOM_EVENT_RECV_RECORD 8
129 #define ZOOM_EVENT_RECV_SEARCH 9
130 #define ZOOM_EVENT_END 10
132 /* ----------------------------------------------------------- */
135 /* create result set given a search */
136 ZOOM_API(ZOOM_resultset)
137 ZOOM_connection_search(ZOOM_connection, ZOOM_query q);
138 /* create result set given PQF query */
139 ZOOM_API(ZOOM_resultset)
140 ZOOM_connection_search_pqf(ZOOM_connection c, const char *q);
142 /* destroy result set */
144 ZOOM_resultset_destroy(ZOOM_resultset r);
146 /* result set option */
147 ZOOM_API(const char *)
148 ZOOM_resultset_option_get (ZOOM_resultset r, const char *key);
150 ZOOM_resultset_option_set (ZOOM_resultset r, const char *key, const char *val);
152 /* return size of result set (alias hit count AKA result count) */
154 ZOOM_resultset_size (ZOOM_resultset r);
156 /* retrieve records */
158 ZOOM_resultset_records (ZOOM_resultset r, ZOOM_record *recs,
159 size_t start, size_t count);
161 /* return record object at pos. Returns 0 if unavailable */
162 ZOOM_API(ZOOM_record)
163 ZOOM_resultset_record (ZOOM_resultset s, size_t pos);
165 /* like ZOOM_resultset_record - but never blocks .. */
166 ZOOM_API(ZOOM_record)
167 ZOOM_resultset_record_immediate (ZOOM_resultset s, size_t pos);
169 /* reset record cache for result set */
171 ZOOM_resultset_cache_reset(ZOOM_resultset r);
173 /* ----------------------------------------------------------- */
176 /* get record information, in a form given by type */
177 ZOOM_API(const char *)
178 ZOOM_record_get (ZOOM_record rec, const char *type, int *len);
182 ZOOM_record_destroy (ZOOM_record rec);
184 /* return copy of record */
185 ZOOM_API(ZOOM_record)
186 ZOOM_record_clone (ZOOM_record srec);
188 /* ----------------------------------------------------------- */
191 /* create search object */
193 ZOOM_query_create(void);
196 ZOOM_query_destroy(ZOOM_query s);
199 ZOOM_query_cql(ZOOM_query s, const char *str);
200 /* CQL translated client-side into RPN: `conn' is optional for diagnostics */
202 ZOOM_query_cql2rpn(ZOOM_query s, const char *str, ZOOM_connection conn);
205 ZOOM_query_prefix(ZOOM_query s, const char *str);
206 /* specify sort criteria for search */
208 ZOOM_query_sortby(ZOOM_query s, const char *criteria);
210 /* ----------------------------------------------------------- */
212 ZOOM_API(ZOOM_scanset)
213 ZOOM_connection_scan (ZOOM_connection c, const char *startterm);
215 ZOOM_API(ZOOM_scanset)
216 ZOOM_connection_scan1 (ZOOM_connection c, ZOOM_query startterm);
218 ZOOM_API(const char *)
219 ZOOM_scanset_term(ZOOM_scanset scan, size_t pos,
222 ZOOM_API(const char *)
223 ZOOM_scanset_display_term(ZOOM_scanset scan, size_t pos,
227 ZOOM_scanset_size(ZOOM_scanset scan);
230 ZOOM_scanset_destroy (ZOOM_scanset scan);
232 ZOOM_API(const char *)
233 ZOOM_scanset_option_get (ZOOM_scanset scan, const char *key);
236 ZOOM_scanset_option_set (ZOOM_scanset scan, const char *key,
238 /* ----------------------------------------------------------- */
239 /* Extended Services Packages */
241 ZOOM_API(ZOOM_package)
242 ZOOM_connection_package (ZOOM_connection c, ZOOM_options options);
245 ZOOM_package_destroy(ZOOM_package p);
248 ZOOM_package_send (ZOOM_package p, const char *type);
250 ZOOM_API(const char *)
251 ZOOM_package_option_get (ZOOM_package p, const char *key);
254 ZOOM_package_option_set (ZOOM_package p, const char *key,
257 /* ----------------------------------------------------------- */
258 /* Sort. First function is deprecated, use second instead */
260 ZOOM_resultset_sort(ZOOM_resultset r,
261 const char *sort_type, const char *sort_spec);
263 ZOOM_resultset_sort1(ZOOM_resultset r,
264 const char *sort_type, const char *sort_spec);
266 /* ----------------------------------------------------------- */
269 ZOOM_API(ZOOM_options_callback)
270 ZOOM_options_set_callback (ZOOM_options opt,
271 ZOOM_options_callback c,
273 ZOOM_API(ZOOM_options)
274 ZOOM_options_create (void);
276 ZOOM_API(ZOOM_options)
277 ZOOM_options_create_with_parent (ZOOM_options parent);
279 ZOOM_API(ZOOM_options)
280 ZOOM_options_create_with_parent2 (ZOOM_options parent1,
281 ZOOM_options parent2);
283 ZOOM_API(const char *)
284 ZOOM_options_get (ZOOM_options opt, const char *name);
286 ZOOM_API(const char *)
287 ZOOM_options_getl (ZOOM_options opt, const char *name, int *lenp);
290 ZOOM_options_set (ZOOM_options opt, const char *name, const char *v);
293 ZOOM_options_setl (ZOOM_options opt, const char *name, const char *value,
297 ZOOM_options_destroy (ZOOM_options opt);
300 ZOOM_options_get_bool (ZOOM_options opt, const char *name, int defa);
303 ZOOM_options_get_int (ZOOM_options opt, const char *name, int defa);
306 ZOOM_options_set_int(ZOOM_options opt, const char *name, int value);
308 /* ----------------------------------------------------------- */
310 /* poll for events on a number of connections. Returns positive
311 integer if event occurred ; zero if none occurred and no more
312 events are pending. The positive integer specifies the
313 connection for which the event occurred. */
315 ZOOM_event (int no, ZOOM_connection *cs);
321 * indent-tabs-mode: nil
323 * vim: shiftwidth=4 tabstop=8 expandtab