2 * Public header for ZOOM C.
3 * $Id: zoom.h,v 1.22 2004-02-23 09:26:11 adam Exp $
7 #include <yaz/yconfig.h>
9 #define ZOOM_BEGIN_CDECL YAZ_BEGIN_CDECL
10 #define ZOOM_END_CDECL YAZ_END_CDECL
13 # define ZOOM_API(x) __declspec(dllexport) x __stdcall
15 # define ZOOM_API(x) x
20 /* ----------------------------------------------------------- */
21 /* the types we use */
23 typedef struct ZOOM_options_p *ZOOM_options;
24 typedef struct ZOOM_query_p *ZOOM_query;
25 typedef struct ZOOM_connection_p *ZOOM_connection;
26 typedef struct ZOOM_resultset_p *ZOOM_resultset;
27 typedef struct ZOOM_task_p *ZOOM_task;
28 typedef struct ZOOM_record_p *ZOOM_record;
29 typedef struct ZOOM_scanset_p *ZOOM_scanset;
30 typedef struct ZOOM_package_p *ZOOM_package;
32 typedef const char *(*ZOOM_options_callback)(void *handle, const char *name);
34 /* ----------------------------------------------------------- */
37 /* create connection, connect to host, if portnum is 0, then port is
38 read from host string (e.g. myhost:9821) */
39 ZOOM_API(ZOOM_connection)
40 ZOOM_connection_new (const char *host, int portnum);
42 /* create connection, don't connect, apply options */
43 ZOOM_API(ZOOM_connection)
44 ZOOM_connection_create (ZOOM_options options);
46 /* connect given existing connection */
48 ZOOM_connection_connect(ZOOM_connection c, const char *host,
51 /* destroy connection (close connection also) */
53 ZOOM_connection_destroy (ZOOM_connection c);
55 /* get/set option for connection */
56 ZOOM_API(const char *)
57 ZOOM_connection_option_get (ZOOM_connection c, const char *key);
60 ZOOM_connection_option_set (ZOOM_connection c, const char *key,
63 /* return error code (0 == success, failure otherwise). cp
64 holds error string on failure, addinfo holds addititional info (if any)
67 ZOOM_connection_error (ZOOM_connection c, const char **cp,
68 const char **addinfo);
71 ZOOM_connection_error_x (ZOOM_connection c, const char **cp,
72 const char **addinfo, const char **diagset);
74 /* returns error code */
76 ZOOM_connection_errcode (ZOOM_connection c);
77 /* returns error message */
78 ZOOM_API(const char *)
79 ZOOM_connection_errmsg (ZOOM_connection c);
80 /* returns additional info */
81 ZOOM_API(const char *)
82 ZOOM_connection_addinfo (ZOOM_connection c);
83 /* translates error code into human-readable string */
84 ZOOM_API(const char *)
85 ZOOM_diag_str (int error);
87 #define ZOOM_ERROR_NONE 0
88 #define ZOOM_ERROR_CONNECT 10000
89 #define ZOOM_ERROR_MEMORY 10001
90 #define ZOOM_ERROR_ENCODE 10002
91 #define ZOOM_ERROR_DECODE 10003
92 #define ZOOM_ERROR_CONNECTION_LOST 10004
93 #define ZOOM_ERROR_INIT 10005
94 #define ZOOM_ERROR_INTERNAL 10006
95 #define ZOOM_ERROR_TIMEOUT 10007
96 #define ZOOM_ERROR_UNSUPPORTED_PROTOCOL 10008
97 #define ZOOM_ERROR_UNSUPPORTED_QUERY 10009
98 #define ZOOM_ERROR_INVALID_QUERY 10010
101 ZOOM_connection_last_event(ZOOM_connection cs);
103 #define ZOOM_EVENT_NONE 0
104 #define ZOOM_EVENT_CONNECT 1
105 #define ZOOM_EVENT_SEND_DATA 2
106 #define ZOOM_EVENT_RECV_DATA 3
107 #define ZOOM_EVENT_TIMEOUT 4
108 #define ZOOM_EVENT_UNKNOWN 5
109 #define ZOOM_EVENT_SEND_APDU 6
110 #define ZOOM_EVENT_RECV_APDU 7
111 #define ZOOM_EVENT_RECV_RECORD 8
112 #define ZOOM_EVENT_RECV_SEARCH 9
114 /* ----------------------------------------------------------- */
117 /* create result set given a search */
118 ZOOM_API(ZOOM_resultset)
119 ZOOM_connection_search(ZOOM_connection, ZOOM_query q);
120 /* create result set given PQF query */
121 ZOOM_API(ZOOM_resultset)
122 ZOOM_connection_search_pqf(ZOOM_connection c, const char *q);
124 /* destroy result set */
126 ZOOM_resultset_destroy(ZOOM_resultset r);
128 /* result set option */
129 ZOOM_API(const char *)
130 ZOOM_resultset_option_get (ZOOM_resultset r, const char *key);
132 ZOOM_resultset_option_set (ZOOM_resultset r, const char *key, const char *val);
134 /* return size of result set (alias hit count AKA result count) */
136 ZOOM_resultset_size (ZOOM_resultset r);
138 /* retrieve records */
140 ZOOM_resultset_records (ZOOM_resultset r, ZOOM_record *recs,
141 size_t start, size_t count);
143 /* return record object at pos. Returns 0 if unavailable */
144 ZOOM_API(ZOOM_record)
145 ZOOM_resultset_record (ZOOM_resultset s, size_t pos);
147 /* like ZOOM_resultset_record - but never blocks .. */
148 ZOOM_API(ZOOM_record)
149 ZOOM_resultset_record_immediate (ZOOM_resultset s, size_t pos);
151 /* reset record cache for result set */
153 ZOOM_resultset_cache_reset(ZOOM_resultset r);
155 /* ----------------------------------------------------------- */
158 /* get record information, in a form given by type */
159 ZOOM_API(const char *)
160 ZOOM_record_get (ZOOM_record rec, const char *type, int *len);
164 ZOOM_record_destroy (ZOOM_record rec);
166 /* return copy of record */
167 ZOOM_API(ZOOM_record)
168 ZOOM_record_clone (ZOOM_record srec);
170 /* ----------------------------------------------------------- */
173 /* create search object */
175 ZOOM_query_create(void);
178 ZOOM_query_destroy(ZOOM_query s);
181 ZOOM_query_cql(ZOOM_query s, const char *str);
184 ZOOM_query_prefix(ZOOM_query s, const char *str);
185 /* specify sort criteria for search */
187 ZOOM_query_sortby(ZOOM_query s, const char *criteria);
189 /* ----------------------------------------------------------- */
191 ZOOM_API(ZOOM_scanset)
192 ZOOM_connection_scan (ZOOM_connection c, const char *startterm);
194 ZOOM_API(const char *)
195 ZOOM_scanset_term(ZOOM_scanset scan, size_t pos,
198 ZOOM_API(const char *)
199 ZOOM_scanset_display_term(ZOOM_scanset scan, size_t pos,
203 ZOOM_scanset_size(ZOOM_scanset scan);
206 ZOOM_scanset_destroy (ZOOM_scanset scan);
208 ZOOM_API(const char *)
209 ZOOM_scanset_option_get (ZOOM_scanset scan, const char *key);
212 ZOOM_scanset_option_set (ZOOM_scanset scan, const char *key,
214 /* ----------------------------------------------------------- */
215 /* Extended Services Packages */
217 ZOOM_API(ZOOM_package)
218 ZOOM_connection_package (ZOOM_connection c, ZOOM_options options);
221 ZOOM_package_destroy(ZOOM_package p);
224 ZOOM_package_send (ZOOM_package p, const char *type);
226 ZOOM_API(const char *)
227 ZOOM_package_option_get (ZOOM_package p, const char *key);
230 ZOOM_package_option_set (ZOOM_package p, const char *key,
233 /* ----------------------------------------------------------- */
236 ZOOM_resultset_sort(ZOOM_resultset r,
237 const char *sort_type, const char *sort_spec);
239 /* ----------------------------------------------------------- */
242 ZOOM_API(ZOOM_options_callback)
243 ZOOM_options_set_callback (ZOOM_options opt,
244 ZOOM_options_callback c,
246 ZOOM_API(ZOOM_options)
247 ZOOM_options_create (void);
249 ZOOM_API(ZOOM_options)
250 ZOOM_options_create_with_parent (ZOOM_options parent);
252 ZOOM_API(ZOOM_options)
253 ZOOM_options_create_with_parent2 (ZOOM_options parent1,
254 ZOOM_options parent2);
256 ZOOM_API(const char *)
257 ZOOM_options_get (ZOOM_options opt, const char *name);
260 ZOOM_options_set (ZOOM_options opt, const char *name, const char *v);
263 ZOOM_options_setl (ZOOM_options opt, const char *name, const char *value,
267 ZOOM_options_destroy (ZOOM_options opt);
270 ZOOM_options_get_bool (ZOOM_options opt, const char *name, int defa);
273 ZOOM_options_get_int (ZOOM_options opt, const char *name, int defa);
276 ZOOM_options_set_int(ZOOM_options opt, const char *name, int value);
278 /* ----------------------------------------------------------- */
280 /* poll for events on a number of connections. Returns positive
281 integer if event occurred ; zero if none occurred and no more
282 events are pending. The positive integer specifies the
283 connection for which the event occurred. */
285 ZOOM_event (int no, ZOOM_connection *cs);