1 /* $Id: api.h,v 1.1 2004-08-25 09:23:36 adam Exp $
2 Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
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>
35 #include <idzebra/res.h>
36 #include <idzebra/version.h>
38 /* Fixme! Compare string (ignore case) */
40 #define STRCASECMP stricmp
42 #define STRCASECMP strcasecmp
54 } ZebraTransactionStatus;
56 /* Retrieval Record Descriptor */
58 int errCode; /* non-zero if error when fetching this */
59 char *errString; /* error string */
60 int position; /* position of record in result set (1,2,..) */
61 char *buf; /* record buffer (void pointer really) */
63 oid_value format; /* record syntax */
67 } ZebraRetrievalRecord;
69 /* Scan Term Descriptor */
71 int occurrences; /* scan term occurrences */
72 char *term; /* scan term string */
75 typedef struct zebra_session *ZebraHandle;
76 typedef struct zebra_service *ZebraService;
80 * Starting and stopping
83 /* Start Zebra using file 'configName' (usually zebra.cfg) */
84 /* There should be exactly one ZebraService */
85 YAZ_EXPORT ZebraService zebra_start (const char *configName);
86 YAZ_EXPORT ZebraService zebra_start_res (const char *configName,
87 Res def_res, Res over_res);
89 /* Close the whole Zebra */
90 YAZ_EXPORT int zebra_stop (ZebraService zs);
93 /* Open a ZebraHandle */
94 /* There should be one handle for each thred doing something */
95 /* with zebra, be that searching or indexing. In simple apps */
96 /* one handle is sufficient */
97 YAZ_EXPORT ZebraHandle zebra_open (ZebraService zs);
100 YAZ_EXPORT int zebra_close (ZebraHandle zh);
106 /* last error code */
107 YAZ_EXPORT int zebra_errCode (ZebraHandle zh);
109 /* string representatio of above */
110 YAZ_EXPORT const char *zebra_errString (ZebraHandle zh);
112 /* extra information associated with error */
113 YAZ_EXPORT char *zebra_errAdd (ZebraHandle zh);
115 /* get the result code and addinfo from zh */
116 YAZ_EXPORT int zebra_result (ZebraHandle zh, int *code, char **addinfo);
117 /* FIXME - why is this needed?? -H */
119 /* clear them error things */
120 YAZ_EXPORT void zebra_clearError(ZebraHandle zh);
126 /* Search using PQF Query */
127 YAZ_EXPORT int zebra_search_PQF (ZebraHandle zh, const char *pqf_query,
128 const char *setname, int *numhits);
130 /* Search using RPN Query */
131 YAZ_EXPORT int zebra_search_RPN (ZebraHandle zh, ODR o, Z_RPNQuery *query,
132 const char *setname, int *hits);
134 /* Retrieve record(s) */
135 YAZ_EXPORT int zebra_records_retrieve (ZebraHandle zh, ODR stream,
136 const char *setname, Z_RecordComposition *comp,
137 oid_value input_format,
138 int num_recs, ZebraRetrievalRecord *recs);
140 /* Delete Result Set(s) */
141 YAZ_EXPORT int zebra_deleleResultSet(ZebraHandle zh, int function,
142 int num_setnames, char **setnames,
147 YAZ_EXPORT int zebra_scan (ZebraHandle zh, ODR stream,
148 Z_AttributesPlusTerm *zapt,
149 oid_value attributeset,
150 int *position, int *num_entries,
151 ZebraScanEntry **list,
160 /* do authentication */
161 YAZ_EXPORT int zebra_auth (ZebraHandle zh, const char *user, const char *pass);
163 /* Character normalisation on specific register .
164 This routine is subject to change - do not use. */
165 YAZ_EXPORT int zebra_string_norm (ZebraHandle zh, unsigned reg_id,
166 const char *input_str, int input_len,
167 char *output_str, int output_len);
174 YAZ_EXPORT int zebra_create_database (ZebraHandle zh, const char *db);
175 YAZ_EXPORT int zebra_drop_database (ZebraHandle zh, const char *db);
177 YAZ_EXPORT int zebra_admin_shutdown (ZebraHandle zh);
178 YAZ_EXPORT int zebra_admin_start (ZebraHandle zh);
180 YAZ_EXPORT int zebra_shutdown (ZebraService zs);
182 YAZ_EXPORT int zebra_admin_import_begin (ZebraHandle zh, const char *database,
183 const char *record_type);
185 YAZ_EXPORT int zebra_admin_import_segment (ZebraHandle zh,
188 YAZ_EXPORT int zebra_admin_import_end (ZebraHandle zh);
190 int zebra_admin_exchange_record (ZebraHandle zh,
193 const char *recid_buf, size_t recid_len,
196 int zebra_begin_trans (ZebraHandle zh, int rw);
197 int zebra_end_trans (ZebraHandle zh);
198 int zebra_end_transaction (ZebraHandle zh, ZebraTransactionStatus *stat);
200 int zebra_commit (ZebraHandle zh);
201 int zebra_clean (ZebraHandle zh);
203 int zebra_init (ZebraHandle zh);
204 int zebra_compact (ZebraHandle zh);
205 int zebra_repository_update (ZebraHandle zh, const char *path);
206 int zebra_repository_delete (ZebraHandle zh, const char *path);
207 int zebra_repository_show (ZebraHandle zh, const char *path);
209 int zebra_add_record (ZebraHandle zh, const char *buf, int buf_size);
211 int zebra_insert_record (ZebraHandle zh,
212 const char *recordType,
213 SYSNO *sysno, const char *match, const char *fname,
214 const char *buf, int buf_size,
216 int zebra_update_record (ZebraHandle zh,
217 const char *recordType,
218 SYSNO *sysno, const char *match, const char *fname,
219 const char *buf, int buf_size,
221 int zebra_delete_record (ZebraHandle zh,
222 const char *recordType,
223 SYSNO *sysno, const char *match, const char *fname,
224 const char *buf, int buf_size,
227 YAZ_EXPORT int zebra_resultSetTerms (ZebraHandle zh, const char *setname,
229 int *type, char *out, size_t *len);
231 YAZ_EXPORT int zebra_sort (ZebraHandle zh, ODR stream,
232 int num_input_setnames,
233 const char **input_setnames,
234 const char *output_setname,
235 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);
262 YAZ_EXPORT void zebra_pidfname(ZebraService zs, char *path);