1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 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.
29 * \brief Internal header for ZOOM implementation
31 #include <yaz/proto.h>
32 #include <yaz/oid_db.h>
33 #include <yaz/comstack.h>
34 #include <yaz/wrbuf.h>
37 #include <yaz/cookie.h>
38 #include <yaz/mutex.h>
39 #if HAVE_LIBMEMCACHED_MEMCACHED_H
40 #include <libmemcached/memcached.h>
45 typedef struct ZOOM_Event_p *ZOOM_Event;
56 typedef struct ZOOM_task_p *ZOOM_task;
59 #define STATE_CONNECTING 1
60 #define STATE_ESTABLISHED 2
62 struct ZOOM_connection_p {
93 int url_authentication;
96 int support_named_resultsets;
99 int maximum_record_size;
100 int preferred_message_size;
103 ZOOM_options options;
104 ZOOM_resultset resultsets;
105 ZOOM_Event m_queue_front;
106 ZOOM_Event m_queue_back;
107 zoom_sru_mode sru_mode;
108 int no_redirects; /* 0 for no redirects. >0 for number of redirects */
109 yaz_cookies_t cookies;
114 WRBUF saveAPDU_wrbuf;
115 #if HAVE_LIBMEMCACHED_MEMCACHED_H
120 typedef struct ZOOM_record_cache_p *ZOOM_record_cache;
122 #define RECORD_HASH_SIZE 131
124 struct ZOOM_resultset_p {
125 Z_SortKeySpecList *r_sort_spec;
133 ZOOM_record_cache record_hash[RECORD_HASH_SIZE];
134 ZOOM_options options;
135 ZOOM_connection connection;
136 char **databaseNames;
137 int num_databaseNames;
140 struct WRBUF_shptr *record_wrbuf;
144 ZOOM_facet_field *res_facets;
146 char **facets_names; /* redundant. For ZOOM_resultset_facets_names only */
148 int live_set; /* 0=no hit count, 1=cached hit, 2=hits + real set */
151 struct facet_term_p {
156 struct ZOOM_facet_field_p {
159 struct facet_term_p *facet_terms;
162 struct ZOOM_scanset_p {
165 ZOOM_options options;
166 ZOOM_connection connection;
168 Z_ScanResponse *scan_response;
169 Z_SRW_scanResponse *srw_scan_response;
171 char **databaseNames;
172 int num_databaseNames;
175 struct ZOOM_package_p {
178 ZOOM_options options;
179 ZOOM_connection connection;
188 #define ZOOM_TASK_SEARCH 1
192 ZOOM_resultset resultset;
194 char *elementSetName;
197 #define ZOOM_TASK_CONNECT 3
198 #define ZOOM_TASK_SCAN 4
202 #define ZOOM_TASK_PACKAGE 5
203 ZOOM_package package;
204 #define ZOOM_TASK_SORT 6
206 ZOOM_resultset resultset;
218 void ZOOM_options_addref (ZOOM_options opt);
220 void ZOOM_handle_Z3950_apdu(ZOOM_connection c, Z_APDU *apdu);
222 void ZOOM_set_dset_error(ZOOM_connection c, int error,
224 const char *addinfo, const char *addinfo2);
226 void ZOOM_set_error(ZOOM_connection c, int error, const char *addinfo);
228 ZOOM_Event ZOOM_Event_create(int kind);
229 void ZOOM_connection_put_event(ZOOM_connection c, ZOOM_Event event);
231 zoom_ret ZOOM_connection_Z3950_search(ZOOM_connection c);
232 zoom_ret ZOOM_connection_Z3950_send_scan(ZOOM_connection c);
233 zoom_ret ZOOM_send_buf(ZOOM_connection c);
234 zoom_ret send_Z3950_sort(ZOOM_connection c, ZOOM_resultset resultset);
235 char **ZOOM_connection_get_databases(ZOOM_connection con, ZOOM_options options,
237 zoom_ret ZOOM_connection_Z3950_send_init(ZOOM_connection c);
239 ZOOM_task ZOOM_connection_add_task(ZOOM_connection c, int which);
240 void ZOOM_connection_remove_task(ZOOM_connection c);
241 int ZOOM_test_reconnect(ZOOM_connection c);
243 ZOOM_record ZOOM_record_cache_lookup(ZOOM_resultset r, int pos,
245 const char *elementSetName,
247 void ZOOM_record_cache_add(ZOOM_resultset r, Z_NamePlusRecord *npr,
249 const char *syntax, const char *elementSetName,
251 Z_SRW_diagnostic *diag);
253 Z_Query *ZOOM_query_get_Z_Query(ZOOM_query s);
254 Z_SortKeySpecList *ZOOM_query_get_sortspec(ZOOM_query s);
255 const char *ZOOM_query_get_query_string(ZOOM_query s);
256 const char *ZOOM_query_get_sru11(ZOOM_query s);
257 void ZOOM_query_get_hash(ZOOM_query s, WRBUF w);
259 int ZOOM_uri_to_code(const char *uri);
261 zoom_ret ZOOM_connection_srw_send_search(ZOOM_connection c);
262 zoom_ret ZOOM_connection_srw_send_scan(ZOOM_connection c);
264 int ZOOM_handle_sru(ZOOM_connection c, Z_HTTP_Response *hres,
265 zoom_ret *cret, char **addinfo);
267 void ZOOM_set_HTTP_error(ZOOM_connection c, int error,
268 const char *addinfo, const char *addinfo2);
270 ZOOM_Event ZOOM_connection_get_event(ZOOM_connection c);
271 void ZOOM_connection_remove_events(ZOOM_connection c);
272 void ZOOM_Event_destroy(ZOOM_Event event);
273 zoom_ret ZOOM_send_GDU(ZOOM_connection c, Z_GDU *gdu);
274 void ZOOM_handle_facet_list(ZOOM_resultset r, Z_FacetList *fl);
276 void ZOOM_memcached_init(ZOOM_connection c);
277 int ZOOM_memcached_configure(ZOOM_connection c);
278 void ZOOM_memcached_destroy(ZOOM_connection c);
279 void ZOOM_memcached_resultset(ZOOM_resultset r, ZOOM_query q);
280 void ZOOM_memcached_search(ZOOM_connection c, ZOOM_resultset r);
281 void ZOOM_memcached_hitcount(ZOOM_connection c, ZOOM_resultset result,
282 Z_OtherInformation *oi, const char *precision);
283 void ZOOM_memcached_add(ZOOM_resultset r, Z_NamePlusRecord *npr,
285 const char *syntax, const char *elementSetName,
287 Z_SRW_diagnostic *diag);
288 Z_NamePlusRecord *ZOOM_memcached_lookup(ZOOM_resultset r, int pos,
290 const char *elementSetName,
292 ZOOM_record ZOOM_record_cache_lookup_i(ZOOM_resultset r, int pos,
294 const char *elementSetName,
296 void ZOOM_handle_facet_result(ZOOM_connection c, ZOOM_resultset r,
297 Z_OtherInformation *o);
298 void ZOOM_handle_search_result(ZOOM_connection c, ZOOM_resultset resultset,
299 Z_OtherInformation *o);
304 * c-file-style: "Stroustrup"
305 * indent-tabs-mode: nil
307 * vim: shiftwidth=4 tabstop=8 expandtab