1 /* $Id: zebraapi.h,v 1.9 2003-06-30 19:37:12 adam Exp $
2 Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
5 This file is part of the Zebra server.
7 Zebra is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with Zebra; see the file LICENSE.zebra. If not, write to the
19 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
24 * Most functions return an int. Unix-like, 0 means OK,
25 * non-zero means an error. The error info should be available
26 * via zebra_errCode and friends.
34 #include <yaz/proto.h>
37 /* Fixme! Compare string (ignore case) */
39 #define STRCASECMP stricmp
41 #define STRCASECMP strcasecmp
68 } ZebraTransactionStatus;
70 /* Retrieval Record Descriptor */
72 int errCode; /* non-zero if error when fetching this */
73 char *errString; /* error string */
74 int position; /* position of record in result set (1,2,..) */
75 char *buf; /* record buffer (void pointer really) */
77 oid_value format; /* record syntax */
81 } ZebraRetrievalRecord;
83 /* Scan Term Descriptor */
85 int occurrences; /* scan term occurrences */
86 char *term; /* scan term string */
89 typedef struct zebra_session *ZebraHandle;
90 typedef struct zebra_service *ZebraService;
94 * Starting and stopping
97 /* Start Zebra using file 'configName' (usually zebra.cfg) */
98 /* There should be exactly one ZebraService */
99 YAZ_EXPORT ZebraService zebra_start (const char *configName);
101 /* Close the whole Zebra */
102 YAZ_EXPORT int zebra_stop (ZebraService zs);
105 /* Open a ZebraHandle */
106 /* There should be one handle for each thred doing something */
107 /* with zebra, be that searching or indexing. In simple apps */
108 /* one handle is sufficient */
109 YAZ_EXPORT ZebraHandle zebra_open (ZebraService zs);
112 YAZ_EXPORT int zebra_close (ZebraHandle zh);
118 /* last error code */
119 YAZ_EXPORT int zebra_errCode (ZebraHandle zh);
121 /* string representatio of above */
122 YAZ_EXPORT const char *zebra_errString (ZebraHandle zh);
124 /* extra information associated with error */
125 YAZ_EXPORT char *zebra_errAdd (ZebraHandle zh);
127 /* get the result code and addinfo from zh */
128 YAZ_EXPORT int zebra_result (ZebraHandle zh, int *code, char **addinfo);
129 /* FIXME - why is this needed?? -H */
131 /* clear them error things */
132 YAZ_EXPORT void zebra_clearError(ZebraHandle zh);
138 /* Search using PQF Query */
139 YAZ_EXPORT int zebra_search_PQF (ZebraHandle zh, const char *pqf_query,
140 const char *setname, int *numhits);
142 /* Search using RPN Query */
143 YAZ_EXPORT int zebra_search_RPN (ZebraHandle zh, ODR o, Z_RPNQuery *query,
144 const char *setname, int *hits);
146 /* Retrieve record(s) */
147 YAZ_EXPORT int zebra_records_retrieve (ZebraHandle zh, ODR stream,
148 const char *setname, Z_RecordComposition *comp,
149 oid_value input_format,
150 int num_recs, ZebraRetrievalRecord *recs);
152 /* Delete Result Set(s) */
153 YAZ_EXPORT int zebra_deleleResultSet(ZebraHandle zh, int function,
154 int num_setnames, char **setnames,
159 YAZ_EXPORT int zebra_scan (ZebraHandle zh, ODR stream,
160 Z_AttributesPlusTerm *zapt,
161 oid_value attributeset,
162 int *position, int *num_entries,
163 ZebraScanEntry **list,
172 /* do authentication */
173 YAZ_EXPORT int zebra_auth (ZebraHandle zh, const char *user, const char *pass);
175 /* Character normalisation on specific register .
176 This routine is subject to change - do not use. */
177 YAZ_EXPORT int zebra_string_norm (ZebraHandle zh, unsigned reg_id,
178 const char *input_str, int input_len,
179 char *output_str, int output_len);
186 YAZ_EXPORT int zebra_create_database (ZebraHandle zh, const char *db);
187 YAZ_EXPORT int zebra_drop_database (ZebraHandle zh, const char *db);
189 YAZ_EXPORT int zebra_admin_shutdown (ZebraHandle zh);
190 YAZ_EXPORT int zebra_admin_start (ZebraHandle zh);
192 YAZ_EXPORT int zebra_shutdown (ZebraService zs);
194 YAZ_EXPORT int zebra_admin_import_begin (ZebraHandle zh, const char *database,
195 const char *record_type);
197 YAZ_EXPORT int zebra_admin_import_segment (ZebraHandle zh,
200 YAZ_EXPORT int zebra_admin_import_end (ZebraHandle zh);
202 int zebra_admin_exchange_record (ZebraHandle zh,
203 const char *database,
206 const char *recid_buf, size_t recid_len,
209 int zebra_begin_trans (ZebraHandle zh, int rw);
210 int zebra_end_trans (ZebraHandle zh);
211 int zebra_end_transaction (ZebraHandle zh, ZebraTransactionStatus *stat);
213 int zebra_commit (ZebraHandle zh);
214 int zebra_clean (ZebraHandle zh);
216 int zebra_init (ZebraHandle zh);
217 int zebra_compact (ZebraHandle zh);
218 int zebra_repository_update (ZebraHandle zh);
219 int zebra_repository_delete (ZebraHandle zh);
220 int zebra_repository_show (ZebraHandle zh);
221 int zebra_record_insert (ZebraHandle zh, const char *buf, int len, int *sysno);
223 YAZ_EXPORT int zebra_set_group (ZebraHandle zh, struct recordGroup *rg);
226 YAZ_EXPORT int zebra_resultSetTerms (ZebraHandle zh, const char *setname,
228 int *type, char *out, size_t *len);
230 YAZ_EXPORT int zebra_sort (ZebraHandle zh, ODR stream,
231 int num_input_setnames,
232 const char **input_setnames,
233 const char *output_setname,
234 Z_SortKeySpecList *sort_sequence,
239 int zebra_select_databases (ZebraHandle zh, int num_bases,
240 const char **basenames);
243 int zebra_select_database (ZebraHandle zh, const char *basename);
246 int zebra_shadow_enable (ZebraHandle zh, int value);
249 int zebra_register_statistics (ZebraHandle zh, int dumpdict);
252 int zebra_record_encoding (ZebraHandle zh, const char *encoding);
256 int zebra_set_resource(ZebraHandle zh, const char *name, const char *value);
258 const char *zebra_get_resource(ZebraHandle zh,
259 const char *name, const char *defaultvalue);