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