2 * Public header for ZOOM C.
3 * $Id: zoom.h,v 1.4 2001-11-15 08:58:29 adam Exp $
6 /* 1. Renamed type Z3950_search to Z3950_query and the functions
8 Changed positions/sizes to be of type size_t rather than int.
9 2. Deleted Z3950_resultset_get. Added Z3950_record_dup. Record
10 reference(s) returned by Z350_resultset_records and
11 Z3950_resultset_record are "owned" by result set.
13 #include <yaz/yconfig.h>
15 #define ZOOM_EXPORT YAZ_EXPORT
16 #define ZOOM_BEGIN_CDECL YAZ_BEGIN_CDECL
17 #define ZOOM_END_CDECL YAZ_END_CDECL
21 /* ----------------------------------------------------------- */
22 /* the types we use */
24 typedef struct Z3950_options_p *Z3950_options;
25 typedef struct Z3950_query_p *Z3950_query;
26 typedef struct Z3950_connection_p *Z3950_connection;
27 typedef struct Z3950_resultset_p *Z3950_resultset;
28 typedef struct Z3950_task_p *Z3950_task;
29 typedef struct Z3950_record_p *Z3950_record;
31 /* ----------------------------------------------------------- */
34 /* create connection, connect to host, if portnum is 0, then port is
35 read from host string (e.g. myhost:9821) */
37 Z3950_connection Z3950_connection_new (const char *host, int portnum);
39 /* create connection, don't connect, apply options */
41 Z3950_connection Z3950_connection_create (Z3950_options options);
43 /* connect given existing connection */
45 void Z3950_connection_connect(Z3950_connection c, const char *host,
48 /* destroy connection (close connection also) */
50 void Z3950_connection_destroy (Z3950_connection c);
52 /* set option for connection */
54 const char *Z3950_connection_option (Z3950_connection c, const char *key,
56 /* return host for connection */
58 const char *Z3950_connection_host (Z3950_connection c);
60 /* return error code (0 == success, failure otherwise). cp
61 holds error string on failure, addinfo holds addititional info (if any)
64 int Z3950_connection_error (Z3950_connection c, const char **cp,
65 const char **addinfo);
67 /* returns error code */
69 int Z3950_connection_errcode (Z3950_connection c);
70 /* returns error message */
72 const char *Z3950_connection_errmsg (Z3950_connection c);
73 /* returns additional info */
75 const char *Z3950_connection_addinfo (Z3950_connection c);
77 #define Z3950_ERROR_NONE 0
78 #define Z3950_ERROR_CONNECT 10000
79 #define Z3950_ERROR_MEMORY 10001
80 #define Z3950_ERROR_ENCODE 10002
81 #define Z3950_ERROR_DECODE 10003
82 #define Z3950_ERROR_CONNECTION_LOST 10004
83 #define Z3950_ERROR_INIT 10005
84 #define Z3950_ERROR_INTERNAL 10006
85 #define Z3950_ERROR_TIMEOUT 10007
87 /* ----------------------------------------------------------- */
90 /* create result set given a search */
92 Z3950_resultset Z3950_connection_search(Z3950_connection, Z3950_query q);
93 /* create result set given PQF query */
95 Z3950_resultset Z3950_connection_search_pqf(Z3950_connection c, const char *q);
97 /* destroy result set */
99 void Z3950_resultset_destroy(Z3950_resultset r);
101 /* result set option */
103 const char *Z3950_resultset_option (Z3950_resultset r, const char *key,
105 /* return size of result set (alias hit count AKA result count) */
107 size_t Z3950_resultset_size (Z3950_resultset r);
109 /* retrieve records */
111 void Z3950_resultset_records (Z3950_resultset r, Z3950_record *recs,
112 size_t start, size_t count);
114 /* return record object at pos. Returns 0 if unavailable */
116 Z3950_record Z3950_resultset_record (Z3950_resultset s, size_t pos);
118 /* like Z3950_resultset_record - but never blocks .. */
120 Z3950_record Z3950_resultset_record_immediate (Z3950_resultset s, size_t pos);
122 /* ----------------------------------------------------------- */
125 /* get record information, in a form given by type */
127 void *Z3950_record_get (Z3950_record rec, const char *type, size_t *len);
131 void Z3950_record_destroy (Z3950_record rec);
133 /* return copy of record */
135 Z3950_record Z3950_record_dup (Z3950_record srec);
137 /* ----------------------------------------------------------- */
140 /* create search object */
142 Z3950_query Z3950_query_create(void);
145 void Z3950_query_destroy(Z3950_query s);
146 /* specify prefix query for search */
148 int Z3950_query_prefix(Z3950_query s, const char *str);
149 /* specify sort criteria for search */
151 int Z3950_query_sortby(Z3950_query s, const char *criteria);
153 /* ----------------------------------------------------------- */
155 typedef const char *(*Z3950_options_callback)(void *handle, const char *name);
158 Z3950_options_callback Z3950_options_set_callback (Z3950_options opt,
159 Z3950_options_callback c,
162 Z3950_options Z3950_options_create (void);
165 Z3950_options Z3950_options_create_with_parent (Z3950_options parent);
168 const char *Z3950_options_get (Z3950_options opt, const char *name);
171 void Z3950_options_set (Z3950_options opt, const char *name, const char *v);
174 void Z3950_options_destroy (Z3950_options opt);
177 int Z3950_options_get_bool (Z3950_options opt, const char *name, int defa);
180 int Z3950_options_get_int (Z3950_options opt, const char *name, int defa);
183 void Z3950_options_addref (Z3950_options opt);
185 /* ----------------------------------------------------------- */
187 /* poll for events on a number of connections. Returns positive
188 integer if event occurred ; zero if none occurred and no more
189 events are pending. The positive integer specifies the
190 connection for which the event occurred. There's no way to get
191 the details yet, sigh. */
193 int Z3950_event (int no, Z3950_connection *cs);