1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2010 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/mutex.h>
40 #define ZOOM_RESULT_LISTS 0
42 typedef struct ZOOM_Event_p *ZOOM_Event;
52 typedef struct ZOOM_task_p *ZOOM_task;
55 #define STATE_CONNECTING 1
56 #define STATE_ESTABLISHED 2
59 typedef struct ZOOM_resultsets_p *ZOOM_resultsets;
62 struct ZOOM_connection_p {
93 int support_named_resultsets;
96 int maximum_record_size;
97 int preferred_message_size;
100 ZOOM_options options;
101 #if ZOOM_RESULT_LISTS
102 ZOOM_resultsets resultsets;
104 ZOOM_resultset resultsets;
106 ZOOM_Event m_queue_front;
107 ZOOM_Event m_queue_back;
108 zoom_sru_mode sru_mode;
109 int no_redirects; /* 0 for no redirects. >0 for number of redirects */
115 #if ZOOM_RESULT_LISTS
116 struct ZOOM_resultsets_p {
117 ZOOM_resultset resultset;
118 ZOOM_resultsets next;
122 struct ZOOM_options_entry {
125 int len; /* of `value', which may contain NULs */
126 struct ZOOM_options_entry *next;
129 struct ZOOM_options_p {
131 void *callback_handle;
132 ZOOM_options_callback callback_func;
133 struct ZOOM_options_entry *entries;
134 ZOOM_options parent1;
135 ZOOM_options parent2;
139 typedef struct ZOOM_record_cache_p *ZOOM_record_cache;
141 #define RECORD_HASH_SIZE 131
143 struct ZOOM_resultset_p {
144 Z_SortKeySpecList *r_sort_spec;
153 ZOOM_record_cache record_hash[RECORD_HASH_SIZE];
154 ZOOM_options options;
155 ZOOM_connection connection;
156 char **databaseNames;
157 int num_databaseNames;
160 struct WRBUF_shptr *record_wrbuf;
162 #if ZOOM_RESULT_LISTS
166 ZOOM_facet_field *facets;
171 struct ZOOM_record_p {
174 struct WRBUF_shptr *record_wrbuf;
179 Z_NamePlusRecord *npr;
182 const char *diag_uri;
183 const char *diag_message;
184 const char *diag_details;
185 const char *diag_set;
188 struct facet_term_p {
193 struct ZOOM_facet_field_p {
196 struct facet_term_p *facet_terms;
200 struct ZOOM_record_cache_p {
201 struct ZOOM_record_p rec;
202 char *elementSetName;
206 ZOOM_record_cache next;
209 struct ZOOM_scanset_p {
212 ZOOM_options options;
213 ZOOM_connection connection;
215 Z_ScanResponse *scan_response;
216 Z_SRW_scanResponse *srw_scan_response;
218 char **databaseNames;
219 int num_databaseNames;
222 struct ZOOM_package_p {
225 ZOOM_options options;
226 ZOOM_connection connection;
235 #define ZOOM_TASK_SEARCH 1
239 ZOOM_resultset resultset;
241 char *elementSetName;
242 int recv_search_fired;
244 #define ZOOM_TASK_RETRIEVE 2
247 ZOOM_resultset resultset;
250 char *elementSetName;
252 #define ZOOM_TASK_CONNECT 3
253 #define ZOOM_TASK_SCAN 4
257 #define ZOOM_TASK_PACKAGE 5
258 ZOOM_package package;
259 #define ZOOM_TASK_SORT 6
261 ZOOM_resultset resultset;
268 struct ZOOM_Event_p {
279 void ZOOM_options_addref (ZOOM_options opt);
281 void ZOOM_handle_Z3950_apdu(ZOOM_connection c, Z_APDU *apdu);
283 void ZOOM_set_dset_error(ZOOM_connection c, int error,
285 const char *addinfo, const char *addinfo2);
287 void ZOOM_set_error(ZOOM_connection c, int error, const char *addinfo);
289 ZOOM_Event ZOOM_Event_create(int kind);
290 void ZOOM_connection_put_event(ZOOM_connection c, ZOOM_Event event);
292 zoom_ret ZOOM_connection_Z3950_send_search(ZOOM_connection c);
293 zoom_ret send_Z3950_present(ZOOM_connection c);
294 zoom_ret ZOOM_connection_Z3950_send_scan(ZOOM_connection c);
295 zoom_ret ZOOM_send_buf(ZOOM_connection c);
296 zoom_ret send_Z3950_sort(ZOOM_connection c, ZOOM_resultset resultset);
297 char **ZOOM_connection_get_databases(ZOOM_connection con, ZOOM_options options,
299 zoom_ret ZOOM_connection_Z3950_send_init(ZOOM_connection c);
301 ZOOM_task ZOOM_connection_add_task(ZOOM_connection c, int which);
302 void ZOOM_connection_remove_task(ZOOM_connection c);
303 int ZOOM_test_reconnect(ZOOM_connection c);
305 ZOOM_record ZOOM_record_cache_lookup(ZOOM_resultset r, int pos,
307 const char *elementSetName);
308 void ZOOM_record_cache_add(ZOOM_resultset r, Z_NamePlusRecord *npr,
310 const char *syntax, const char *elementSetName,
312 Z_SRW_diagnostic *diag);
314 Z_Query *ZOOM_query_get_Z_Query(ZOOM_query s);
315 Z_SortKeySpecList *ZOOM_query_get_sortspec(ZOOM_query s);
316 char *ZOOM_query_get_query_string(ZOOM_query s);
321 * c-file-style: "Stroustrup"
322 * indent-tabs-mode: nil
324 * vim: shiftwidth=4 tabstop=8 expandtab