1 /* $Id: api.h,v 1.8 2005-01-15 22:10:16 adam Exp $
2 Copyright (C) 1995-2005
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
29 * Most functions return an int. Unix-like, 0 means OK,
30 * non-zero means an error. The error info should be available
31 * via zebra_errCode and friends.
39 #include <yaz/proto.h>
40 #include <idzebra/res.h>
41 #include <idzebra/version.h>
52 } ZebraTransactionStatus;
54 /* Retrieval Record Descriptor */
56 int errCode; /* non-zero if error when fetching this */
57 char *errString; /* error string */
58 int position; /* position of record in result set (1,2,..) */
59 char *buf; /* record buffer (void pointer really) */
61 oid_value format; /* record syntax */
65 } ZebraRetrievalRecord;
67 /* Scan Term Descriptor */
69 int occurrences; /* scan term occurrences */
70 char *term; /* scan term string */
74 * \brief a Zebra Handle - (session)
76 typedef struct zebra_session *ZebraHandle;
79 * \brief a Zebra Service handle
81 typedef struct zebra_service *ZebraService;
85 * Starting and stopping
88 /* Start Zebra using file 'configName' (usually zebra.cfg) */
89 /* There should be exactly one ZebraService */
91 /** \fn ZebraService zebra_start(const char *configName)
92 * \brief starts a Zebra service
93 * \param configName name of configuration file
95 YAZ_EXPORT ZebraService zebra_start
96 (const char *configName);
98 /** \fn ZebraService zebra_start_res(const char *configName, Res def_res, Res over_res)
99 * \brief starts a Zebra service with resources
100 * \param configName name of configuration file
101 * \param def_res default resources
102 * \param over_res overriding resources
105 ZebraService zebra_start_res (const char *configName,
106 Res def_res, Res over_res);
108 /** \fn int zebra_stop(ZebraService zs)
109 * \brief stops a Zebra service
110 * \param zs service handle
113 int zebra_stop (ZebraService zs);
115 /** \fn void zebra_filter_info(ZebraService zs, void *cd, void (*cb)(void *cd, const char *name))
116 * \brief lists enabled Zebra filters
117 * \param zs service handle
118 * \param cd callback parameter (opaque)
119 * \param cb callback function
122 void zebra_filter_info(ZebraService zs, void *cd,
123 void (*cb)(void *cd, const char *name));
126 /* Open a ZebraHandle */
127 /* There should be one handle for each thred doing something */
128 /* with zebra, be that searching or indexing. In simple apps */
129 /* one handle is sufficient */
130 YAZ_EXPORT ZebraHandle zebra_open (ZebraService zs);
133 YAZ_EXPORT int zebra_close (ZebraHandle zh);
139 /* last error code */
140 YAZ_EXPORT int zebra_errCode (ZebraHandle zh);
142 /* string representatio of above */
143 YAZ_EXPORT const char *zebra_errString (ZebraHandle zh);
145 /* extra information associated with error */
146 YAZ_EXPORT char *zebra_errAdd (ZebraHandle zh);
148 /* get the result code and addinfo from zh */
149 YAZ_EXPORT int zebra_result (ZebraHandle zh, int *code, char **addinfo);
150 /* FIXME - why is this needed?? -H */
152 /* clear them error things */
153 YAZ_EXPORT void zebra_clearError(ZebraHandle zh);
159 /* Search using PQF Query */
160 YAZ_EXPORT int zebra_search_PQF (ZebraHandle zh, const char *pqf_query,
161 const char *setname, int *numhits);
163 /* Search using RPN Query */
164 YAZ_EXPORT int zebra_search_RPN (ZebraHandle zh, ODR o, Z_RPNQuery *query,
165 const char *setname, int *hits);
167 /* Retrieve record(s) */
168 YAZ_EXPORT int zebra_records_retrieve (ZebraHandle zh, ODR stream,
169 const char *setname, Z_RecordComposition *comp,
170 oid_value input_format,
171 int num_recs, ZebraRetrievalRecord *recs);
173 /* Delete Result Set(s) */
174 YAZ_EXPORT int zebra_deleleResultSet(ZebraHandle zh, int function,
175 int num_setnames, char **setnames,
180 YAZ_EXPORT int zebra_scan (ZebraHandle zh, ODR stream,
181 Z_AttributesPlusTerm *zapt,
182 oid_value attributeset,
183 int *position, int *num_entries,
184 ZebraScanEntry **list,
193 /* do authentication */
194 YAZ_EXPORT int zebra_auth (ZebraHandle zh, const char *user, const char *pass);
196 /* Character normalisation on specific register .
197 This routine is subject to change - do not use. */
198 YAZ_EXPORT int zebra_string_norm (ZebraHandle zh, unsigned reg_id,
199 const char *input_str, int input_len,
200 char *output_str, int output_len);
207 YAZ_EXPORT int zebra_create_database (ZebraHandle zh, const char *db);
208 YAZ_EXPORT int zebra_drop_database (ZebraHandle zh, const char *db);
210 YAZ_EXPORT int zebra_admin_shutdown (ZebraHandle zh);
211 YAZ_EXPORT int zebra_admin_start (ZebraHandle zh);
213 YAZ_EXPORT int zebra_shutdown (ZebraService zs);
215 YAZ_EXPORT int zebra_admin_import_begin (ZebraHandle zh, const char *database,
216 const char *record_type);
218 YAZ_EXPORT int zebra_admin_import_segment (ZebraHandle zh,
221 YAZ_EXPORT int zebra_admin_import_end (ZebraHandle zh);
223 int zebra_admin_exchange_record (ZebraHandle zh,
226 const char *recid_buf, size_t recid_len,
229 int zebra_begin_trans (ZebraHandle zh, int rw);
230 int zebra_end_trans (ZebraHandle zh);
231 int zebra_end_transaction (ZebraHandle zh, ZebraTransactionStatus *stat);
233 int zebra_commit (ZebraHandle zh);
234 int zebra_clean (ZebraHandle zh);
236 int zebra_init (ZebraHandle zh);
237 int zebra_compact (ZebraHandle zh);
238 int zebra_repository_update (ZebraHandle zh, const char *path);
239 int zebra_repository_delete (ZebraHandle zh, const char *path);
240 int zebra_repository_show (ZebraHandle zh, const char *path);
242 int zebra_add_record (ZebraHandle zh, const char *buf, int buf_size);
244 int zebra_insert_record (ZebraHandle zh,
245 const char *recordType,
246 SYSNO *sysno, const char *match, const char *fname,
247 const char *buf, int buf_size,
249 int zebra_update_record (ZebraHandle zh,
250 const char *recordType,
251 SYSNO *sysno, const char *match, const char *fname,
252 const char *buf, int buf_size,
254 int zebra_delete_record (ZebraHandle zh,
255 const char *recordType,
256 SYSNO *sysno, const char *match, const char *fname,
257 const char *buf, int buf_size,
260 YAZ_EXPORT int zebra_resultSetTerms (ZebraHandle zh, const char *setname,
262 int *type, char *out, size_t *len);
264 YAZ_EXPORT int zebra_sort (ZebraHandle zh, ODR stream,
265 int num_input_setnames,
266 const char **input_setnames,
267 const char *output_setname,
268 Z_SortKeySpecList *sort_sequence,
272 int zebra_select_databases (ZebraHandle zh, int num_bases,
273 const char **basenames);
276 int zebra_select_database (ZebraHandle zh, const char *basename);
279 int zebra_shadow_enable (ZebraHandle zh, int value);
282 int zebra_register_statistics (ZebraHandle zh, int dumpdict);
285 int zebra_record_encoding (ZebraHandle zh, const char *encoding);
288 int zebra_record_encoding (ZebraHandle zh, const char *encoding);
291 int zebra_octet_term_encoding(ZebraHandle zh, const char *encoding);
295 int zebra_set_resource(ZebraHandle zh, const char *name, const char *value);
297 const char *zebra_get_resource(ZebraHandle zh,
298 const char *name, const char *defaultvalue);
301 YAZ_EXPORT void zebra_pidfname(ZebraService zs, char *path);
311 ZebraMetaRecord *zebra_meta_records_create (ZebraHandle zh,
313 int num, zint *positions);
317 ZebraMetaRecord *zebra_meta_records_create_range (ZebraHandle zh,
319 zint start, int num);
322 void zebra_meta_records_destroy (ZebraHandle zh, ZebraMetaRecord *records,