2 * Copyright (c) 1995-2006, Index Data
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of Index Data nor the names of its contributors
13 * may be used to endorse or promote products derived from this
14 * software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 /* $Id: zoom.h,v 1.38 2006-10-09 21:02:41 adam Exp $ */
30 * Copyright (C) 1995-2005, Index Data ApS
31 * See the file LICENSE for details.
33 * $Id: zoom.h,v 1.38 2006-10-09 21:02:41 adam Exp $
37 * \brief Header for ZOOM
41 #include <yaz/yconfig.h>
43 #define ZOOM_BEGIN_CDECL YAZ_BEGIN_CDECL
44 #define ZOOM_END_CDECL YAZ_END_CDECL
47 # define ZOOM_API(x) __declspec(dllexport) x __stdcall
49 # define ZOOM_API(x) x
54 /* ----------------------------------------------------------- */
55 /* the types we use */
57 typedef struct ZOOM_options_p *ZOOM_options;
58 typedef struct ZOOM_query_p *ZOOM_query;
59 typedef struct ZOOM_connection_p *ZOOM_connection;
60 typedef struct ZOOM_resultset_p *ZOOM_resultset;
61 typedef struct ZOOM_record_p *ZOOM_record;
62 typedef struct ZOOM_scanset_p *ZOOM_scanset;
63 typedef struct ZOOM_package_p *ZOOM_package;
65 typedef const char *(*ZOOM_options_callback)(void *handle, const char *name);
67 /* ----------------------------------------------------------- */
70 /* create connection, connect to host, if portnum is 0, then port is
71 read from host string (e.g. myhost:9821) */
72 ZOOM_API(ZOOM_connection)
73 ZOOM_connection_new (const char *host, int portnum);
75 /* create connection, don't connect, apply options */
76 ZOOM_API(ZOOM_connection)
77 ZOOM_connection_create (ZOOM_options options);
79 /* connect given existing connection */
81 ZOOM_connection_connect(ZOOM_connection c, const char *host,
84 /* destroy connection (close connection also) */
86 ZOOM_connection_destroy (ZOOM_connection c);
88 /* get/set option for connection */
89 ZOOM_API(const char *)
90 ZOOM_connection_option_get (ZOOM_connection c, const char *key);
92 ZOOM_API(const char *)
93 ZOOM_connection_option_getl (ZOOM_connection c, const char *key, int *lenp);
96 ZOOM_connection_option_set (ZOOM_connection c, const char *key,
100 ZOOM_connection_option_setl (ZOOM_connection c, const char *key,
101 const char *val, int len);
103 /* return error code (0 == success, failure otherwise). cp
104 holds error string on failure, addinfo holds addititional info (if any)
107 ZOOM_connection_error (ZOOM_connection c, const char **cp,
108 const char **addinfo);
111 ZOOM_connection_error_x (ZOOM_connection c, const char **cp,
112 const char **addinfo, const char **diagset);
114 /* returns error code */
116 ZOOM_connection_errcode (ZOOM_connection c);
117 /* returns error message */
118 ZOOM_API(const char *)
119 ZOOM_connection_errmsg (ZOOM_connection c);
120 /* returns additional info */
121 ZOOM_API(const char *)
122 ZOOM_connection_addinfo (ZOOM_connection c);
123 /* returns diagnostic set */
124 ZOOM_API(const char *)
125 ZOOM_connection_diagset (ZOOM_connection c);
126 /* translates error code into human-readable string */
127 ZOOM_API(const char *)
128 ZOOM_diag_str (int error);
130 #define ZOOM_ERROR_NONE 0
131 #define ZOOM_ERROR_CONNECT 10000
132 #define ZOOM_ERROR_MEMORY 10001
133 #define ZOOM_ERROR_ENCODE 10002
134 #define ZOOM_ERROR_DECODE 10003
135 #define ZOOM_ERROR_CONNECTION_LOST 10004
136 #define ZOOM_ERROR_INIT 10005
137 #define ZOOM_ERROR_INTERNAL 10006
138 #define ZOOM_ERROR_TIMEOUT 10007
139 #define ZOOM_ERROR_UNSUPPORTED_PROTOCOL 10008
140 #define ZOOM_ERROR_UNSUPPORTED_QUERY 10009
141 #define ZOOM_ERROR_INVALID_QUERY 10010
142 #define ZOOM_ERROR_CQL_PARSE 10011
143 #define ZOOM_ERROR_CQL_TRANSFORM 10012
144 #define ZOOM_ERROR_CCL_CONFIG 10013
145 #define ZOOM_ERROR_CCL_PARSE 10014
148 ZOOM_connection_last_event(ZOOM_connection cs);
150 #define ZOOM_EVENT_NONE 0
151 #define ZOOM_EVENT_CONNECT 1
152 #define ZOOM_EVENT_SEND_DATA 2
153 #define ZOOM_EVENT_RECV_DATA 3
154 #define ZOOM_EVENT_TIMEOUT 4
155 #define ZOOM_EVENT_UNKNOWN 5
156 #define ZOOM_EVENT_SEND_APDU 6
157 #define ZOOM_EVENT_RECV_APDU 7
158 #define ZOOM_EVENT_RECV_RECORD 8
159 #define ZOOM_EVENT_RECV_SEARCH 9
160 #define ZOOM_EVENT_END 10
162 /* ----------------------------------------------------------- */
165 /* create result set given a search */
166 ZOOM_API(ZOOM_resultset)
167 ZOOM_connection_search(ZOOM_connection, ZOOM_query q);
168 /* create result set given PQF query */
169 ZOOM_API(ZOOM_resultset)
170 ZOOM_connection_search_pqf(ZOOM_connection c, const char *q);
172 /* destroy result set */
174 ZOOM_resultset_destroy(ZOOM_resultset r);
176 /* result set option */
177 ZOOM_API(const char *)
178 ZOOM_resultset_option_get (ZOOM_resultset r, const char *key);
180 ZOOM_resultset_option_set (ZOOM_resultset r, const char *key, const char *val);
182 /* return size of result set (alias hit count AKA result count) */
184 ZOOM_resultset_size (ZOOM_resultset r);
186 /* retrieve records */
188 ZOOM_resultset_records (ZOOM_resultset r, ZOOM_record *recs,
189 size_t start, size_t count);
191 /* return record object at pos. Returns 0 if unavailable */
192 ZOOM_API(ZOOM_record)
193 ZOOM_resultset_record (ZOOM_resultset s, size_t pos);
195 /* like ZOOM_resultset_record - but never blocks .. */
196 ZOOM_API(ZOOM_record)
197 ZOOM_resultset_record_immediate (ZOOM_resultset s, size_t pos);
199 /* reset record cache for result set */
201 ZOOM_resultset_cache_reset(ZOOM_resultset r);
203 /* ----------------------------------------------------------- */
206 /* get record information, in a form given by type */
207 ZOOM_API(const char *)
208 ZOOM_record_get (ZOOM_record rec, const char *type, int *len);
212 ZOOM_record_destroy (ZOOM_record rec);
214 /* return copy of record */
215 ZOOM_API(ZOOM_record)
216 ZOOM_record_clone (ZOOM_record srec);
218 /* ----------------------------------------------------------- */
221 /* create search object */
223 ZOOM_query_create(void);
226 ZOOM_query_destroy(ZOOM_query s);
229 ZOOM_query_cql(ZOOM_query s, const char *str);
230 /* CQL translated client-side into RPN: `conn' is optional for diagnostics */
232 ZOOM_query_cql2rpn(ZOOM_query s, const char *str, ZOOM_connection conn);
233 /* CCL translated client-side into RPN: `conn' is optional for diagnostics */
235 ZOOM_query_ccl2rpn(ZOOM_query s, const char *query_str,
237 int *ccl_error, const char **error_string, int *error_pos);
240 ZOOM_query_prefix(ZOOM_query s, const char *str);
241 /* specify sort criteria for search */
243 ZOOM_query_sortby(ZOOM_query s, const char *criteria);
245 /* ----------------------------------------------------------- */
247 ZOOM_API(ZOOM_scanset)
248 ZOOM_connection_scan (ZOOM_connection c, const char *startterm);
250 ZOOM_API(ZOOM_scanset)
251 ZOOM_connection_scan1 (ZOOM_connection c, ZOOM_query startterm);
253 ZOOM_API(const char *)
254 ZOOM_scanset_term(ZOOM_scanset scan, size_t pos,
257 ZOOM_API(const char *)
258 ZOOM_scanset_display_term(ZOOM_scanset scan, size_t pos,
262 ZOOM_scanset_size(ZOOM_scanset scan);
265 ZOOM_scanset_destroy (ZOOM_scanset scan);
267 ZOOM_API(const char *)
268 ZOOM_scanset_option_get (ZOOM_scanset scan, const char *key);
271 ZOOM_scanset_option_set (ZOOM_scanset scan, const char *key,
273 /* ----------------------------------------------------------- */
274 /* Extended Services Packages */
276 ZOOM_API(ZOOM_package)
277 ZOOM_connection_package (ZOOM_connection c, ZOOM_options options);
280 ZOOM_package_destroy(ZOOM_package p);
283 ZOOM_package_send (ZOOM_package p, const char *type);
285 ZOOM_API(const char *)
286 ZOOM_package_option_get (ZOOM_package p, const char *key);
289 ZOOM_package_option_set (ZOOM_package p, const char *key,
292 /* ----------------------------------------------------------- */
293 /* Sort. First function is deprecated, use second instead */
295 ZOOM_resultset_sort(ZOOM_resultset r,
296 const char *sort_type, const char *sort_spec);
298 ZOOM_resultset_sort1(ZOOM_resultset r,
299 const char *sort_type, const char *sort_spec);
301 /* ----------------------------------------------------------- */
304 ZOOM_API(ZOOM_options_callback)
305 ZOOM_options_set_callback (ZOOM_options opt,
306 ZOOM_options_callback c,
308 ZOOM_API(ZOOM_options)
309 ZOOM_options_create (void);
311 ZOOM_API(ZOOM_options)
312 ZOOM_options_create_with_parent (ZOOM_options parent);
314 ZOOM_API(ZOOM_options)
315 ZOOM_options_create_with_parent2 (ZOOM_options parent1,
316 ZOOM_options parent2);
318 ZOOM_API(const char *)
319 ZOOM_options_get (ZOOM_options opt, const char *name);
321 ZOOM_API(const char *)
322 ZOOM_options_getl (ZOOM_options opt, const char *name, int *lenp);
325 ZOOM_options_set (ZOOM_options opt, const char *name, const char *v);
328 ZOOM_options_setl (ZOOM_options opt, const char *name, const char *value,
332 ZOOM_options_destroy (ZOOM_options opt);
335 ZOOM_options_get_bool (ZOOM_options opt, const char *name, int defa);
338 ZOOM_options_get_int (ZOOM_options opt, const char *name, int defa);
341 ZOOM_options_set_int(ZOOM_options opt, const char *name, int value);
343 /* ----------------------------------------------------------- */
345 /* poll for events on a number of connections. Returns positive
346 integer if event occurred ; zero if none occurred and no more
347 events are pending. The positive integer specifies the
348 connection for which the event occurred. */
350 ZOOM_event (int no, ZOOM_connection *cs);
353 ZOOM_connection_is_idle(ZOOM_connection cs);
359 * indent-tabs-mode: nil
361 * vim: shiftwidth=4 tabstop=8 expandtab