f34c52a6b1aee8b6a7520cb59b3836921e71e8bf
[idzebra-moved-to-github.git] / index / zebraapi.h
1 /* $Id: zebraapi.h,v 1.23 2003-01-15 07:26:40 oleg Exp $
2    Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
3    Index Data Aps
4
5 This file is part of the Zebra server.
6
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
10 version.
11
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
15 for more details.
16
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
20 02111-1307, USA.
21 */
22
23
24
25 #ifndef ZEBRAAPI_H
26 #define ZEBRAAPI_H
27
28 #include <yaz/odr.h>
29 #include <yaz/oid.h>
30 #include <yaz/proto.h>
31 #include <zebraver.h>
32
33 /* Fixme! Compare string (ignore case) */
34 #ifdef WIN32
35 #define STRCASECMP      stricmp
36 #else
37 #define STRCASECMP      strcasecmp
38 #endif
39
40 YAZ_BEGIN_CDECL
41
42 struct recordGroup {
43     char  *groupName;
44     char  *databaseName;
45     char  *path;
46     char  *recordId;
47     char  *recordType;
48     int   flagStoreData;
49     int   flagStoreKeys;
50     int   flagRw;
51     int   fileVerboseLimit;
52     int   databaseNamePath;
53     int   explainDatabase;
54     int   followLinks;
55 };
56
57 /* Retrieval Record Descriptor */
58 typedef struct {
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) */
63     int len;             /* length */
64     oid_value format;    /* record syntax */
65     char *base; 
66 } ZebraRetrievalRecord;
67
68 /* Scan Term Descriptor */
69 typedef struct {
70     int occurrences;     /* scan term occurrences */
71     char *term;          /* scan term string */
72 } ZebraScanEntry;
73
74 typedef struct zebra_session *ZebraHandle;
75 typedef struct zebra_service *ZebraService;
76
77 /* Open Zebra using file 'configName' (usually zebra.cfg) */
78 YAZ_EXPORT ZebraHandle zebra_open (ZebraService zs);
79
80 /* Search using RPN-Query */
81 YAZ_EXPORT void zebra_search_rpn (ZebraHandle zh, ODR input, ODR output,
82                                   Z_RPNQuery *query,
83                                   const char *setname, int *hits);
84
85 /* Retrieve record(s) */
86 YAZ_EXPORT void zebra_records_retrieve (ZebraHandle zh, ODR stream,
87                        const char *setname, Z_RecordComposition *comp,
88                        oid_value input_format,
89                        int num_recs, ZebraRetrievalRecord *recs);
90
91 /* Browse */
92 YAZ_EXPORT void zebra_scan (ZebraHandle zh, ODR stream,
93                             Z_AttributesPlusTerm *zapt,
94                             oid_value attributeset,
95                             int *position, int *num_entries,
96                             ZebraScanEntry **list,
97                             int *is_partial);
98     
99 /* Delete Result Set(s) */
100 YAZ_EXPORT int zebra_deleleResultSet(ZebraHandle zh, int function,
101                                      int num_setnames, char **setnames,
102                                      int *statuses);
103
104 /* Close zebra and destroy handle */
105 YAZ_EXPORT void zebra_close (ZebraHandle zh);
106
107 /* last error code */
108 YAZ_EXPORT int zebra_errCode (ZebraHandle zh);
109 /* string representatio of above */
110 YAZ_EXPORT const char *zebra_errString (ZebraHandle zh);
111
112 /* extra information associated with error */
113 YAZ_EXPORT char *zebra_errAdd (ZebraHandle zh);
114
115 /* do authentication */
116 YAZ_EXPORT int zebra_auth (ZebraHandle zh, const char *user, const char *pass);
117
118 /* Character normalisation on specific register .
119    This routine is subject to change - do not use. */
120 YAZ_EXPORT int zebra_string_norm (ZebraHandle zh, unsigned reg_id,
121                                   const char *input_str, int input_len,
122                                   char *output_str, int output_len);
123
124 YAZ_EXPORT void zebra_admin_create (ZebraHandle zh, const char *db);
125
126 YAZ_EXPORT ZebraService zebra_start (const char *configName);
127 YAZ_EXPORT void zebra_stop (ZebraService zs);
128
129 YAZ_EXPORT void zebra_admin_shutdown (ZebraHandle zh);
130 YAZ_EXPORT void zebra_admin_start (ZebraHandle zh);
131
132 YAZ_EXPORT void zebra_shutdown (ZebraService zs);
133
134 YAZ_EXPORT void zebra_admin_import_begin (ZebraHandle zh, const char *database,
135                                           const char *record_type);
136
137 YAZ_EXPORT void zebra_admin_import_segment (ZebraHandle zh,
138                                             Z_Segment *segment);
139
140 void zebra_admin_import_end (ZebraHandle zh);
141
142 int zebra_admin_exchange_record (ZebraHandle zh,
143                                  const char *database,
144                                  const char *rec_buf,
145                                  size_t rec_len,
146                                  const char *recid_buf, size_t recid_len,
147                                  int action);
148
149 void zebra_begin_trans (ZebraHandle zh);
150 void zebra_end_trans (ZebraHandle zh);
151
152 int zebra_commit (ZebraHandle zh);
153
154 int zebra_init (ZebraHandle zh);
155 int zebra_compact (ZebraHandle zh);
156 void zebra_repository_update (ZebraHandle zh);
157 void zebra_repository_delete (ZebraHandle zh);
158 void zebra_repository_show (ZebraHandle zh);
159 int zebra_record_insert (ZebraHandle zh, const char *buf, int len);
160
161 YAZ_EXPORT void zebra_set_group (ZebraHandle zh, struct recordGroup *rg);
162
163 YAZ_EXPORT void zebra_result (ZebraHandle zh, int *code, char **addinfo);
164
165
166 YAZ_EXPORT int zebra_resultSetTerms (ZebraHandle zh, const char *setname, 
167                                      int no, int *count, 
168                                      int *type, char *out, size_t *len);
169
170 YAZ_EXPORT void zebra_sort (ZebraHandle zh, ODR stream,
171                             int num_input_setnames,
172                             const char **input_setnames,
173                             const char *output_setname,
174                             Z_SortKeySpecList *sort_sequence,
175                             int *sort_status);
176
177
178 YAZ_EXPORT
179 int zebra_select_databases (ZebraHandle zh, int num_bases, 
180                             const char **basenames);
181
182 YAZ_EXPORT
183 int zebra_select_database (ZebraHandle zh, const char *basename);
184
185 YAZ_EXPORT
186 void zebra_shadow_enable (ZebraHandle zh, int value);
187
188 YAZ_EXPORT
189 void zebra_register_statistics (ZebraHandle zh, int dumpdict);
190
191 YAZ_EXPORT
192 int zebra_record_encoding (ZebraHandle zh, const char *encoding);
193
194 /* Resources */
195 YAZ_EXPORT
196 void zebra_set_resource(ZebraHandle zh, const char *name, const char *value);
197 YAZ_EXPORT
198 const char *zebra_get_resource(ZebraHandle zh, 
199                 const char *name, const char *defaultvalue);
200
201
202 YAZ_END_CDECL                                 
203 #endif