1 /* $Id: zebraapi.h,v 1.24 2003-02-11 14:01:39 heikki Exp $
2 Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
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
30 #include <yaz/proto.h>
33 /* Fixme! Compare string (ignore case) */
35 #define STRCASECMP stricmp
37 #define STRCASECMP strcasecmp
57 /* Retrieval Record Descriptor */
59 int errCode; /* non-zero if error when fetching this */
60 char *errString; /* error string */
61 int position; /* position of record in result set (1,2,..) */
62 char *buf; /* record buffer (void pointer really) */
64 oid_value format; /* record syntax */
66 } ZebraRetrievalRecord;
68 /* Scan Term Descriptor */
70 int occurrences; /* scan term occurrences */
71 char *term; /* scan term string */
74 typedef struct zebra_session *ZebraHandle;
75 typedef struct zebra_service *ZebraService;
79 * Starting and stopping
82 /* Start Zebra using file 'configName' (usually zebra.cfg) */
83 /* There should be exactly one ZebraService */
84 YAZ_EXPORT ZebraService zebra_start (const char *configName);
86 /* Close the whole Zebra */
87 YAZ_EXPORT void zebra_stop (ZebraService zs);
90 /* Open a ZebraHandle */
91 /* There should be one handle for each thred doing something */
92 /* with zebra, be that searching or indexing. In simple apps */
93 /* one handle is sufficient */
94 YAZ_EXPORT ZebraHandle zebra_open (ZebraService zs);
97 YAZ_EXPORT void zebra_close (ZebraHandle zh);
103 /* last error code */
104 YAZ_EXPORT int zebra_errCode (ZebraHandle zh);
106 /* string representatio of above */
107 YAZ_EXPORT const char *zebra_errString (ZebraHandle zh);
109 /* extra information associated with error */
110 YAZ_EXPORT char *zebra_errAdd (ZebraHandle zh);
116 /* Search using RPN-Query */
117 YAZ_EXPORT void zebra_search_rpn (ZebraHandle zh, ODR input, ODR output,
119 const char *setname, int *hits);
121 /* Retrieve record(s) */
122 YAZ_EXPORT void zebra_records_retrieve (ZebraHandle zh, ODR stream,
123 const char *setname, Z_RecordComposition *comp,
124 oid_value input_format,
125 int num_recs, ZebraRetrievalRecord *recs);
127 /* Delete Result Set(s) */
128 YAZ_EXPORT int zebra_deleleResultSet(ZebraHandle zh, int function,
129 int num_setnames, char **setnames,
134 YAZ_EXPORT void zebra_scan (ZebraHandle zh, ODR stream,
135 Z_AttributesPlusTerm *zapt,
136 oid_value attributeset,
137 int *position, int *num_entries,
138 ZebraScanEntry **list,
147 /* do authentication */
148 YAZ_EXPORT int zebra_auth (ZebraHandle zh, const char *user, const char *pass);
150 /* Character normalisation on specific register .
151 This routine is subject to change - do not use. */
152 YAZ_EXPORT int zebra_string_norm (ZebraHandle zh, unsigned reg_id,
153 const char *input_str, int input_len,
154 char *output_str, int output_len);
161 YAZ_EXPORT void zebra_admin_create (ZebraHandle zh, const char *db);
164 YAZ_EXPORT void zebra_admin_shutdown (ZebraHandle zh);
165 YAZ_EXPORT void zebra_admin_start (ZebraHandle zh);
167 YAZ_EXPORT void zebra_shutdown (ZebraService zs);
169 YAZ_EXPORT void zebra_admin_import_begin (ZebraHandle zh, const char *database,
170 const char *record_type);
172 YAZ_EXPORT void zebra_admin_import_segment (ZebraHandle zh,
175 void zebra_admin_import_end (ZebraHandle zh);
177 int zebra_admin_exchange_record (ZebraHandle zh,
178 const char *database,
181 const char *recid_buf, size_t recid_len,
184 void zebra_begin_trans (ZebraHandle zh);
185 void zebra_end_trans (ZebraHandle zh);
187 int zebra_commit (ZebraHandle zh);
189 int zebra_init (ZebraHandle zh);
190 int zebra_compact (ZebraHandle zh);
191 void zebra_repository_update (ZebraHandle zh);
192 void zebra_repository_delete (ZebraHandle zh);
193 void zebra_repository_show (ZebraHandle zh);
194 int zebra_record_insert (ZebraHandle zh, const char *buf, int len);
196 YAZ_EXPORT void zebra_set_group (ZebraHandle zh, struct recordGroup *rg);
198 YAZ_EXPORT void zebra_result (ZebraHandle zh, int *code, char **addinfo);
201 YAZ_EXPORT int zebra_resultSetTerms (ZebraHandle zh, const char *setname,
203 int *type, char *out, size_t *len);
205 YAZ_EXPORT void zebra_sort (ZebraHandle zh, ODR stream,
206 int num_input_setnames,
207 const char **input_setnames,
208 const char *output_setname,
209 Z_SortKeySpecList *sort_sequence,
214 int zebra_select_databases (ZebraHandle zh, int num_bases,
215 const char **basenames);
218 int zebra_select_database (ZebraHandle zh, const char *basename);
221 void zebra_shadow_enable (ZebraHandle zh, int value);
224 void zebra_register_statistics (ZebraHandle zh, int dumpdict);
227 int zebra_record_encoding (ZebraHandle zh, const char *encoding);
231 void zebra_set_resource(ZebraHandle zh, const char *name, const char *value);
233 const char *zebra_get_resource(ZebraHandle zh,
234 const char *name, const char *defaultvalue);