2 * Copyright (C) 1995-2005, Index Data ApS
3 * See the file LICENSE for details.
5 * $Id: zoom.h,v 1.29 2005-11-08 16:51:34 mike 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 /* translates error code into human-readable string */
96 ZOOM_API(const char *)
97 ZOOM_diag_str (int error);
99 #define ZOOM_ERROR_NONE 0
100 #define ZOOM_ERROR_CONNECT 10000
101 #define ZOOM_ERROR_MEMORY 10001
102 #define ZOOM_ERROR_ENCODE 10002
103 #define ZOOM_ERROR_DECODE 10003
104 #define ZOOM_ERROR_CONNECTION_LOST 10004
105 #define ZOOM_ERROR_INIT 10005
106 #define ZOOM_ERROR_INTERNAL 10006
107 #define ZOOM_ERROR_TIMEOUT 10007
108 #define ZOOM_ERROR_UNSUPPORTED_PROTOCOL 10008
109 #define ZOOM_ERROR_UNSUPPORTED_QUERY 10009
110 #define ZOOM_ERROR_INVALID_QUERY 10010
113 ZOOM_connection_last_event(ZOOM_connection cs);
115 #define ZOOM_EVENT_NONE 0
116 #define ZOOM_EVENT_CONNECT 1
117 #define ZOOM_EVENT_SEND_DATA 2
118 #define ZOOM_EVENT_RECV_DATA 3
119 #define ZOOM_EVENT_TIMEOUT 4
120 #define ZOOM_EVENT_UNKNOWN 5
121 #define ZOOM_EVENT_SEND_APDU 6
122 #define ZOOM_EVENT_RECV_APDU 7
123 #define ZOOM_EVENT_RECV_RECORD 8
124 #define ZOOM_EVENT_RECV_SEARCH 9
126 /* ----------------------------------------------------------- */
129 /* create result set given a search */
130 ZOOM_API(ZOOM_resultset)
131 ZOOM_connection_search(ZOOM_connection, ZOOM_query q);
132 /* create result set given PQF query */
133 ZOOM_API(ZOOM_resultset)
134 ZOOM_connection_search_pqf(ZOOM_connection c, const char *q);
136 /* destroy result set */
138 ZOOM_resultset_destroy(ZOOM_resultset r);
140 /* result set option */
141 ZOOM_API(const char *)
142 ZOOM_resultset_option_get (ZOOM_resultset r, const char *key);
144 ZOOM_resultset_option_set (ZOOM_resultset r, const char *key, const char *val);
146 /* return size of result set (alias hit count AKA result count) */
148 ZOOM_resultset_size (ZOOM_resultset r);
150 /* retrieve records */
152 ZOOM_resultset_records (ZOOM_resultset r, ZOOM_record *recs,
153 size_t start, size_t count);
155 /* return record object at pos. Returns 0 if unavailable */
156 ZOOM_API(ZOOM_record)
157 ZOOM_resultset_record (ZOOM_resultset s, size_t pos);
159 /* like ZOOM_resultset_record - but never blocks .. */
160 ZOOM_API(ZOOM_record)
161 ZOOM_resultset_record_immediate (ZOOM_resultset s, size_t pos);
163 /* reset record cache for result set */
165 ZOOM_resultset_cache_reset(ZOOM_resultset r);
167 /* ----------------------------------------------------------- */
170 /* get record information, in a form given by type */
171 ZOOM_API(const char *)
172 ZOOM_record_get (ZOOM_record rec, const char *type, int *len);
176 ZOOM_record_destroy (ZOOM_record rec);
178 /* return copy of record */
179 ZOOM_API(ZOOM_record)
180 ZOOM_record_clone (ZOOM_record srec);
182 /* ----------------------------------------------------------- */
185 /* create search object */
187 ZOOM_query_create(void);
190 ZOOM_query_destroy(ZOOM_query s);
193 ZOOM_query_cql(ZOOM_query s, const char *str);
196 ZOOM_query_prefix(ZOOM_query s, const char *str);
197 /* specify sort criteria for search */
199 ZOOM_query_sortby(ZOOM_query s, const char *criteria);
201 /* ----------------------------------------------------------- */
203 ZOOM_API(ZOOM_scanset)
204 ZOOM_connection_scan (ZOOM_connection c, const char *startterm);
206 ZOOM_API(const char *)
207 ZOOM_scanset_term(ZOOM_scanset scan, size_t pos,
210 ZOOM_API(const char *)
211 ZOOM_scanset_display_term(ZOOM_scanset scan, size_t pos,
215 ZOOM_scanset_size(ZOOM_scanset scan);
218 ZOOM_scanset_destroy (ZOOM_scanset scan);
220 ZOOM_API(const char *)
221 ZOOM_scanset_option_get (ZOOM_scanset scan, const char *key);
224 ZOOM_scanset_option_set (ZOOM_scanset scan, const char *key,
226 /* ----------------------------------------------------------- */
227 /* Extended Services Packages */
229 ZOOM_API(ZOOM_package)
230 ZOOM_connection_package (ZOOM_connection c, ZOOM_options options);
233 ZOOM_package_destroy(ZOOM_package p);
236 ZOOM_package_send (ZOOM_package p, const char *type);
238 ZOOM_API(const char *)
239 ZOOM_package_option_get (ZOOM_package p, const char *key);
242 ZOOM_package_option_set (ZOOM_package p, const char *key,
245 /* ----------------------------------------------------------- */
246 /* Sort. First function is deprecated, use second instead */
248 ZOOM_resultset_sort(ZOOM_resultset r,
249 const char *sort_type, const char *sort_spec);
251 ZOOM_resultset_sort1(ZOOM_resultset r,
252 const char *sort_type, const char *sort_spec);
254 /* ----------------------------------------------------------- */
257 ZOOM_API(ZOOM_options_callback)
258 ZOOM_options_set_callback (ZOOM_options opt,
259 ZOOM_options_callback c,
261 ZOOM_API(ZOOM_options)
262 ZOOM_options_create (void);
264 ZOOM_API(ZOOM_options)
265 ZOOM_options_create_with_parent (ZOOM_options parent);
267 ZOOM_API(ZOOM_options)
268 ZOOM_options_create_with_parent2 (ZOOM_options parent1,
269 ZOOM_options parent2);
271 ZOOM_API(const char *)
272 ZOOM_options_get (ZOOM_options opt, const char *name);
274 ZOOM_API(const char *)
275 ZOOM_options_getl (ZOOM_options opt, const char *name, int *lenp);
278 ZOOM_options_set (ZOOM_options opt, const char *name, const char *v);
281 ZOOM_options_setl (ZOOM_options opt, const char *name, const char *value,
285 ZOOM_options_destroy (ZOOM_options opt);
288 ZOOM_options_get_bool (ZOOM_options opt, const char *name, int defa);
291 ZOOM_options_get_int (ZOOM_options opt, const char *name, int defa);
294 ZOOM_options_set_int(ZOOM_options opt, const char *name, int value);
296 /* ----------------------------------------------------------- */
298 /* poll for events on a number of connections. Returns positive
299 integer if event occurred ; zero if none occurred and no more
300 events are pending. The positive integer specifies the
301 connection for which the event occurred. */
303 ZOOM_event (int no, ZOOM_connection *cs);
309 * indent-tabs-mode: nil
311 * vim: shiftwidth=4 tabstop=8 expandtab