9ac0a810e194f897bd80ac362ca64806311a2703
[idzebra-moved-to-github.git] / index / zebraapi.h
1 /* $Id: zebraapi.h,v 1.21 2002-09-17 12:27:12 adam 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 YAZ_BEGIN_CDECL
34
35 struct recordGroup {
36     char  *groupName;
37     char  *databaseName;
38     char  *path;
39     char  *recordId;
40     char  *recordType;
41     int   flagStoreData;
42     int   flagStoreKeys;
43     int   flagRw;
44     int   fileVerboseLimit;
45     int   databaseNamePath;
46     int   explainDatabase;
47     int   followLinks;
48 };
49
50 /* Retrieval Record Descriptor */
51 typedef struct {
52     int errCode;         /* non-zero if error when fetching this */
53     char *errString;     /* error string */
54     int position;        /* position of record in result set (1,2,..) */
55     char *buf;           /* record buffer (void pointer really) */
56     int len;             /* length */
57     oid_value format;    /* record syntax */
58     char *base; 
59 } ZebraRetrievalRecord;
60
61 /* Scan Term Descriptor */
62 typedef struct {
63     int occurrences;     /* scan term occurrences */
64     char *term;          /* scan term string */
65 } ZebraScanEntry;
66
67 typedef struct zebra_session *ZebraHandle;
68 typedef struct zebra_service *ZebraService;
69
70 /* Open Zebra using file 'configName' (usually zebra.cfg) */
71 YAZ_EXPORT ZebraHandle zebra_open (ZebraService zs);
72
73 /* Search using RPN-Query */
74 YAZ_EXPORT void zebra_search_rpn (ZebraHandle zh, ODR input, ODR output,
75                                   Z_RPNQuery *query,
76                                   const char *setname, int *hits);
77
78 /* Retrieve record(s) */
79 YAZ_EXPORT void zebra_records_retrieve (ZebraHandle zh, ODR stream,
80                        const char *setname, Z_RecordComposition *comp,
81                        oid_value input_format,
82                        int num_recs, ZebraRetrievalRecord *recs);
83
84 /* Browse */
85 YAZ_EXPORT void zebra_scan (ZebraHandle zh, ODR stream,
86                             Z_AttributesPlusTerm *zapt,
87                             oid_value attributeset,
88                             int *position, int *num_entries,
89                             ZebraScanEntry **list,
90                             int *is_partial);
91     
92 /* Delete Result Set(s) */
93 YAZ_EXPORT int zebra_deleleResultSet(ZebraHandle zh, int function,
94                                      int num_setnames, char **setnames,
95                                      int *statuses);
96
97 /* Close zebra and destroy handle */
98 YAZ_EXPORT void zebra_close (ZebraHandle zh);
99
100 /* last error code */
101 YAZ_EXPORT int zebra_errCode (ZebraHandle zh);
102 /* string representatio of above */
103 YAZ_EXPORT const char *zebra_errString (ZebraHandle zh);
104
105 /* extra information associated with error */
106 YAZ_EXPORT char *zebra_errAdd (ZebraHandle zh);
107
108 /* do authentication */
109 YAZ_EXPORT int zebra_auth (ZebraHandle zh, const char *user, const char *pass);
110
111 /* Character normalisation on specific register .
112    This routine is subject to change - do not use. */
113 YAZ_EXPORT int zebra_string_norm (ZebraHandle zh, unsigned reg_id,
114                                   const char *input_str, int input_len,
115                                   char *output_str, int output_len);
116
117 YAZ_EXPORT void zebra_admin_create (ZebraHandle zh, const char *db);
118
119 YAZ_EXPORT ZebraService zebra_start (const char *configName);
120 YAZ_EXPORT void zebra_stop (ZebraService zs);
121
122 YAZ_EXPORT void zebra_admin_shutdown (ZebraHandle zh);
123 YAZ_EXPORT void zebra_admin_start (ZebraHandle zh);
124
125 YAZ_EXPORT void zebra_shutdown (ZebraService zs);
126
127 YAZ_EXPORT void zebra_admin_import_begin (ZebraHandle zh, const char *database,
128                                           const char *record_type);
129
130 YAZ_EXPORT void zebra_admin_import_segment (ZebraHandle zh,
131                                             Z_Segment *segment);
132
133 void zebra_admin_import_end (ZebraHandle zh);
134
135 int zebra_admin_exchange_record (ZebraHandle zh,
136                                  const char *database,
137                                  const char *rec_buf,
138                                  size_t rec_len,
139                                  const char *recid_buf, size_t recid_len,
140                                  int action);
141
142 void zebra_begin_trans (ZebraHandle zh);
143 void zebra_end_trans (ZebraHandle zh);
144
145 int zebra_commit (ZebraHandle zh);
146
147 int zebra_init (ZebraHandle zh);
148 int zebra_compact (ZebraHandle zh);
149 void zebra_repository_update (ZebraHandle zh);
150 void zebra_repository_delete (ZebraHandle zh);
151 void zebra_repository_show (ZebraHandle zh);
152 int zebra_record_insert (ZebraHandle zh, const char *buf, int len);
153
154 YAZ_EXPORT void zebra_set_group (ZebraHandle zh, struct recordGroup *rg);
155
156 YAZ_EXPORT void zebra_result (ZebraHandle zh, int *code, char **addinfo);
157
158
159 YAZ_EXPORT int zebra_resultSetTerms (ZebraHandle zh, const char *setname, 
160                                      int no, int *count, 
161                                      int *type, char *out, size_t *len);
162
163 YAZ_EXPORT void zebra_sort (ZebraHandle zh, ODR stream,
164                             int num_input_setnames,
165                             const char **input_setnames,
166                             const char *output_setname,
167                             Z_SortKeySpecList *sort_sequence,
168                             int *sort_status);
169
170
171 YAZ_EXPORT
172 int zebra_select_databases (ZebraHandle zh, int num_bases, 
173                             const char **basenames);
174
175 YAZ_EXPORT
176 int zebra_select_database (ZebraHandle zh, const char *basename);
177
178 YAZ_EXPORT
179 void zebra_shadow_enable (ZebraHandle zh, int value);
180
181 YAZ_EXPORT
182 void zebra_register_statistics (ZebraHandle zh, int dumpdict);
183
184 YAZ_EXPORT
185 int zebra_record_encoding (ZebraHandle zh, const char *encoding);
186
187 YAZ_END_CDECL                                 
188 #endif