2 * Public header for ZOOM C.
3 * $Id: zoom.h,v 1.3 2001-11-06 17:05:19 adam Exp $
7 Renamed type Z3950_search to Z3950_query and the functions
9 Changed positions/sizes to be of type size_t rather than int.
11 #include <yaz/yconfig.h>
13 #define ZOOM_EXPORT YAZ_EXPORT
14 #define ZOOM_BEGIN_CDECL YAZ_BEGIN_CDECL
15 #define ZOOM_END_CDECL YAZ_END_CDECL
19 /* ----------------------------------------------------------- */
20 /* the types we use */
22 typedef struct Z3950_options_p *Z3950_options;
23 typedef struct Z3950_query_p *Z3950_query;
24 typedef struct Z3950_connection_p *Z3950_connection;
25 typedef struct Z3950_resultset_p *Z3950_resultset;
26 typedef struct Z3950_task_p *Z3950_task;
27 typedef struct Z3950_record_p *Z3950_record;
29 /* ----------------------------------------------------------- */
32 /* create connection, connect to host, if portnum is 0, then port is
33 read from host string (e.g. myhost:9821) */
35 Z3950_connection Z3950_connection_new (const char *host, int portnum);
37 /* create connection, don't connect, apply options */
39 Z3950_connection Z3950_connection_create (Z3950_options options);
41 /* connect given existing connection */
43 void Z3950_connection_connect(Z3950_connection c, const char *host,
46 /* destroy connection (close connection also) */
48 void Z3950_connection_destroy (Z3950_connection c);
50 /* set option for connection */
52 const char *Z3950_connection_option (Z3950_connection c, const char *key,
54 /* return host for connection */
56 const char *Z3950_connection_host (Z3950_connection c);
58 /* return error code (0 == success, failure otherwise). cp
59 holds error string on failure, addinfo holds addititional info (if any)
62 int Z3950_connection_error (Z3950_connection c, const char **cp,
63 const char **addinfo);
65 /* returns error code */
67 int Z3950_connection_errcode (Z3950_connection c);
68 /* returns error message */
70 const char *Z3950_connection_errmsg (Z3950_connection c);
71 /* returns additional info */
73 const char *Z3950_connection_addinfo (Z3950_connection c);
75 #define Z3950_ERROR_NONE 0
76 #define Z3950_ERROR_CONNECT 10000
77 #define Z3950_ERROR_MEMORY 10001
78 #define Z3950_ERROR_ENCODE 10002
79 #define Z3950_ERROR_DECODE 10003
80 #define Z3950_ERROR_CONNECTION_LOST 10004
81 #define Z3950_ERROR_INIT 10005
82 #define Z3950_ERROR_INTERNAL 10006
83 #define Z3950_ERROR_TIMEOUT 10007
85 /* ----------------------------------------------------------- */
88 /* create result set given a search */
90 Z3950_resultset Z3950_connection_search(Z3950_connection, Z3950_query q);
91 /* create result set given PQF query */
93 Z3950_resultset Z3950_connection_search_pqf(Z3950_connection c, const char *q);
95 /* destroy result set */
97 void Z3950_resultset_destroy(Z3950_resultset r);
99 /* result set option */
101 const char *Z3950_resultset_option (Z3950_resultset r, const char *key,
103 /* return size of result set (hit count, AKA resultCount) */
105 int Z3950_resultset_size (Z3950_resultset r);
107 /* return record at pos (starting from ), render given spec in type */
109 void *Z3950_resultset_get (Z3950_resultset s, size_t pos, const char *type,
111 /* retrieve records */
113 void Z3950_resultset_records (Z3950_resultset r, Z3950_record *recs,
114 size_t start, size_t count);
116 /* return record object at pos. Returns 0 if unavailable */
118 Z3950_record Z3950_resultset_record (Z3950_resultset s, size_t pos);
120 /* like Z3950_resultset_record - but never blocks .. */
122 Z3950_record Z3950_resultset_record_immediate (Z3950_resultset s, size_t pos);
124 /* ----------------------------------------------------------- */
127 /* Get record information, in a form given by type */
129 void *Z3950_record_get (Z3950_record rec, const char *type, size_t *len);
133 void Z3950_record_destroy (Z3950_record rec);
135 /* ----------------------------------------------------------- */
138 /* create search object */
140 Z3950_query Z3950_query_create(void);
143 void Z3950_query_destroy(Z3950_query s);
144 /* specify prefix query for search */
146 int Z3950_query_prefix(Z3950_query s, const char *str);
147 /* specify sort criteria for search */
149 int Z3950_query_sortby(Z3950_query s, const char *criteria);
152 /* ----------------------------------------------------------- */
154 typedef const char *(*Z3950_options_callback)(void *handle, const char *name);
157 Z3950_options_callback Z3950_options_set_callback (Z3950_options opt,
158 Z3950_options_callback c,
161 Z3950_options Z3950_options_create (void);
164 Z3950_options Z3950_options_create_with_parent (Z3950_options parent);
167 const char *Z3950_options_get (Z3950_options opt, const char *name);
170 void Z3950_options_set (Z3950_options opt, const char *name, const char *v);
173 void Z3950_options_destroy (Z3950_options opt);
176 int Z3950_options_get_bool (Z3950_options opt, const char *name, int defa);
179 int Z3950_options_get_int (Z3950_options opt, const char *name, int defa);
182 void Z3950_options_addref (Z3950_options opt);
184 /* ----------------------------------------------------------- */
186 /* poll for events on a number of connections. Returns positive
187 integer if event occurred ; zero if none occurred and no more
188 events are pending. The positive integer specifies the
189 connection for which the event occurred. There's no way to get
190 the details yet, sigh. */
192 int Z3950_event (int no, Z3950_connection *cs);