1 /* $Id: zebraapi.h,v 1.7 2003-06-18 11:46:33 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
28 #include <yaz/proto.h>
31 /* Fixme! Compare string (ignore case) */
33 #define STRCASECMP stricmp
35 #define STRCASECMP strcasecmp
62 } ZebraTransactionStatus;
64 /* Retrieval Record Descriptor */
66 int errCode; /* non-zero if error when fetching this */
67 char *errString; /* error string */
68 int position; /* position of record in result set (1,2,..) */
69 char *buf; /* record buffer (void pointer really) */
71 oid_value format; /* record syntax */
75 } ZebraRetrievalRecord;
77 /* Scan Term Descriptor */
79 int occurrences; /* scan term occurrences */
80 char *term; /* scan term string */
83 typedef struct zebra_session *ZebraHandle;
84 typedef struct zebra_service *ZebraService;
88 * Starting and stopping
91 /* Start Zebra using file 'configName' (usually zebra.cfg) */
92 /* There should be exactly one ZebraService */
93 YAZ_EXPORT ZebraService zebra_start (const char *configName);
95 /* Close the whole Zebra */
96 YAZ_EXPORT void zebra_stop (ZebraService zs);
99 /* Open a ZebraHandle */
100 /* There should be one handle for each thred doing something */
101 /* with zebra, be that searching or indexing. In simple apps */
102 /* one handle is sufficient */
103 YAZ_EXPORT ZebraHandle zebra_open (ZebraService zs);
106 YAZ_EXPORT void zebra_close (ZebraHandle zh);
112 /* last error code */
113 YAZ_EXPORT int zebra_errCode (ZebraHandle zh);
115 /* string representatio of above */
116 YAZ_EXPORT const char *zebra_errString (ZebraHandle zh);
118 /* extra information associated with error */
119 YAZ_EXPORT char *zebra_errAdd (ZebraHandle zh);
121 /* get the result code and addinfo from zh */
122 YAZ_EXPORT void zebra_result (ZebraHandle zh, int *code, char **addinfo);
123 /* FIXME - why is this needed?? -H */
130 /* Search using PQF Query */
131 YAZ_EXPORT int zebra_search_PQF (ZebraHandle zh, const char *pqf_query,
132 const char *setname);
134 /* Search using RPN Query */
135 YAZ_EXPORT void zebra_search_RPN (ZebraHandle zh, ODR o, Z_RPNQuery *query,
136 const char *setname, int *hits);
138 /* Retrieve record(s) */
139 YAZ_EXPORT void zebra_records_retrieve (ZebraHandle zh, ODR stream,
140 const char *setname, Z_RecordComposition *comp,
141 oid_value input_format,
142 int num_recs, ZebraRetrievalRecord *recs);
144 /* Delete Result Set(s) */
145 YAZ_EXPORT int zebra_deleleResultSet(ZebraHandle zh, int function,
146 int num_setnames, char **setnames,
151 YAZ_EXPORT void zebra_scan (ZebraHandle zh, ODR stream,
152 Z_AttributesPlusTerm *zapt,
153 oid_value attributeset,
154 int *position, int *num_entries,
155 ZebraScanEntry **list,
164 /* do authentication */
165 YAZ_EXPORT int zebra_auth (ZebraHandle zh, const char *user, const char *pass);
167 /* Character normalisation on specific register .
168 This routine is subject to change - do not use. */
169 YAZ_EXPORT int zebra_string_norm (ZebraHandle zh, unsigned reg_id,
170 const char *input_str, int input_len,
171 char *output_str, int output_len);
178 YAZ_EXPORT void zebra_create_database (ZebraHandle zh, const char *db);
181 YAZ_EXPORT void zebra_admin_shutdown (ZebraHandle zh);
182 YAZ_EXPORT void zebra_admin_start (ZebraHandle zh);
184 YAZ_EXPORT void zebra_shutdown (ZebraService zs);
186 YAZ_EXPORT void zebra_admin_import_begin (ZebraHandle zh, const char *database,
187 const char *record_type);
189 YAZ_EXPORT void zebra_admin_import_segment (ZebraHandle zh,
192 void zebra_admin_import_end (ZebraHandle zh);
194 int zebra_admin_exchange_record (ZebraHandle zh,
195 const char *database,
198 const char *recid_buf, size_t recid_len,
201 int zebra_begin_trans (ZebraHandle zh, int rw);
202 int zebra_end_trans (ZebraHandle zh);
203 int zebra_end_transaction (ZebraHandle zh, ZebraTransactionStatus *stat);
205 int zebra_commit (ZebraHandle zh);
206 int zebra_clean (ZebraHandle zh);
208 int zebra_init (ZebraHandle zh);
209 int zebra_compact (ZebraHandle zh);
210 void zebra_repository_update (ZebraHandle zh);
211 void zebra_repository_delete (ZebraHandle zh);
212 void zebra_repository_show (ZebraHandle zh);
213 int zebra_record_insert (ZebraHandle zh, const char *buf, int len);
215 YAZ_EXPORT void zebra_set_group (ZebraHandle zh, struct recordGroup *rg);
218 YAZ_EXPORT int zebra_resultSetTerms (ZebraHandle zh, const char *setname,
220 int *type, char *out, size_t *len);
222 YAZ_EXPORT void zebra_sort (ZebraHandle zh, ODR stream,
223 int num_input_setnames,
224 const char **input_setnames,
225 const char *output_setname,
226 Z_SortKeySpecList *sort_sequence,
231 int zebra_select_databases (ZebraHandle zh, int num_bases,
232 const char **basenames);
235 int zebra_select_database (ZebraHandle zh, const char *basename);
238 void zebra_shadow_enable (ZebraHandle zh, int value);
241 void zebra_register_statistics (ZebraHandle zh, int dumpdict);
244 int zebra_record_encoding (ZebraHandle zh, const char *encoding);
248 void zebra_set_resource(ZebraHandle zh, const char *name, const char *value);
250 const char *zebra_get_resource(ZebraHandle zh,
251 const char *name, const char *defaultvalue);