Follow of symlinks can be controlled with config followLinks and option -L
[idzebra-moved-to-github.git] / index / zebraapi.h
1 /* $Id: zebraapi.h,v 1.20 2002-09-03 11:44:54 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
129 YAZ_EXPORT void zebra_admin_import_segment (ZebraHandle zh,
130                                             Z_Segment *segment);
131
132 void zebra_admin_import_end (ZebraHandle zh);
133
134 void zebra_begin_trans (ZebraHandle zh);
135 void zebra_end_trans (ZebraHandle zh);
136
137 int zebra_commit (ZebraHandle zh);
138
139 int zebra_init (ZebraHandle zh);
140 int zebra_compact (ZebraHandle zh);
141 void zebra_repository_update (ZebraHandle zh);
142 void zebra_repository_delete (ZebraHandle zh);
143 void zebra_repository_show (ZebraHandle zh);
144 int zebra_record_insert (ZebraHandle zh, const char *buf, int len);
145
146 YAZ_EXPORT void zebra_set_group (ZebraHandle zh, struct recordGroup *rg);
147
148 YAZ_EXPORT void zebra_result (ZebraHandle zh, int *code, char **addinfo);
149
150
151 YAZ_EXPORT int zebra_resultSetTerms (ZebraHandle zh, const char *setname, 
152                                      int no, int *count, 
153                                      int *type, char *out, size_t *len);
154
155 YAZ_EXPORT void zebra_sort (ZebraHandle zh, ODR stream,
156                             int num_input_setnames,
157                             const char **input_setnames,
158                             const char *output_setname,
159                             Z_SortKeySpecList *sort_sequence,
160                             int *sort_status);
161
162
163 YAZ_EXPORT
164 int zebra_select_databases (ZebraHandle zh, int num_bases, 
165                             const char **basenames);
166
167 YAZ_EXPORT
168 int zebra_select_database (ZebraHandle zh, const char *basename);
169
170 YAZ_EXPORT
171 void zebra_shadow_enable (ZebraHandle zh, int value);
172
173 YAZ_EXPORT
174 void zebra_register_statistics (ZebraHandle zh, int dumpdict);
175
176 YAZ_EXPORT
177 int zebra_record_encoding (ZebraHandle zh, const char *encoding);
178
179 YAZ_END_CDECL                                 
180 #endif