b1463b87bd7f485516da78af7dfee3fef158258c
[idzebra-moved-to-github.git] / index / zebraapi.h
1 /*
2  * Copyright (C) 1994-2002, Index Data
3  * All rights reserved.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Id: zebraapi.h,v 1.18 2002-07-25 13:06:43 adam Exp $
7  */
8
9 #ifndef ZEBRAAPI_H
10 #define ZEBRAAPI_H
11
12 #include <yaz/odr.h>
13 #include <yaz/oid.h>
14 #include <yaz/proto.h>
15 #include <zebraver.h>
16
17 YAZ_BEGIN_CDECL
18
19 struct recordGroup {
20     char         *groupName;
21     char         *databaseName;
22     char         *path;
23     char         *recordId;
24     char         *recordType;
25     int          flagStoreData;
26     int          flagStoreKeys;
27     int          flagRw;
28     int          fileVerboseLimit;
29     int          databaseNamePath;
30     int          explainDatabase;
31 };
32
33 /* Retrieval Record Descriptor */
34 typedef struct {
35     int errCode;         /* non-zero if error when fetching this */
36     char *errString;     /* error string */
37     int position;        /* position of record in result set (1,2,..) */
38     char *buf;           /* record buffer (void pointer really) */
39     int len;             /* length */
40     oid_value format;    /* record syntax */
41     char *base; 
42 } ZebraRetrievalRecord;
43
44 /* Scan Term Descriptor */
45 typedef struct {
46     int occurrences;     /* scan term occurrences */
47     char *term;          /* scan term string */
48 } ZebraScanEntry;
49
50 typedef struct zebra_session *ZebraHandle;
51 typedef struct zebra_service *ZebraService;
52
53 /* Open Zebra using file 'configName' (usually zebra.cfg) */
54 YAZ_EXPORT ZebraHandle zebra_open (ZebraService zs);
55
56 /* Search using RPN-Query */
57 YAZ_EXPORT void zebra_search_rpn (ZebraHandle zh, ODR input, ODR output,
58                                   Z_RPNQuery *query,
59                                   const char *setname, int *hits);
60
61 /* Retrieve record(s) */
62 YAZ_EXPORT void zebra_records_retrieve (ZebraHandle zh, ODR stream,
63                        const char *setname, Z_RecordComposition *comp,
64                        oid_value input_format,
65                        int num_recs, ZebraRetrievalRecord *recs);
66
67 /* Browse */
68 YAZ_EXPORT void zebra_scan (ZebraHandle zh, ODR stream,
69                             Z_AttributesPlusTerm *zapt,
70                             oid_value attributeset,
71                             int *position, int *num_entries,
72                             ZebraScanEntry **list,
73                             int *is_partial);
74     
75 /* Delete Result Set(s) */
76 YAZ_EXPORT int zebra_deleleResultSet(ZebraHandle zh, int function,
77                                      int num_setnames, char **setnames,
78                                      int *statuses);
79
80 /* Close zebra and destroy handle */
81 YAZ_EXPORT void zebra_close (ZebraHandle zh);
82
83 /* last error code */
84 YAZ_EXPORT int zebra_errCode (ZebraHandle zh);
85 /* string representatio of above */
86 YAZ_EXPORT const char *zebra_errString (ZebraHandle zh);
87
88 /* extra information associated with error */
89 YAZ_EXPORT char *zebra_errAdd (ZebraHandle zh);
90
91 /* do authentication */
92 YAZ_EXPORT int zebra_auth (ZebraHandle zh, const char *user, const char *pass);
93
94 /* Character normalisation on specific register .
95    This routine is subject to change - do not use. */
96 YAZ_EXPORT int zebra_string_norm (ZebraHandle zh, unsigned reg_id,
97                                   const char *input_str, int input_len,
98                                   char *output_str, int output_len);
99
100 YAZ_EXPORT void zebra_admin_create (ZebraHandle zh, const char *db);
101
102 YAZ_EXPORT ZebraService zebra_start (const char *configName);
103 YAZ_EXPORT void zebra_stop (ZebraService zs);
104
105 YAZ_EXPORT void zebra_admin_shutdown (ZebraHandle zh);
106 YAZ_EXPORT void zebra_admin_start (ZebraHandle zh);
107
108 YAZ_EXPORT void zebra_shutdown (ZebraService zs);
109
110 YAZ_EXPORT void zebra_admin_import_begin (ZebraHandle zh, const char *database);
111
112 YAZ_EXPORT void zebra_admin_import_segment (ZebraHandle zh,
113                                             Z_Segment *segment);
114
115 void zebra_admin_import_end (ZebraHandle zh);
116
117 void zebra_begin_trans (ZebraHandle zh);
118 void zebra_end_trans (ZebraHandle zh);
119
120 int zebra_commit (ZebraHandle zh);
121
122 int zebra_init (ZebraHandle zh);
123 int zebra_compact (ZebraHandle zh);
124 void zebra_repository_update (ZebraHandle zh);
125 void zebra_repository_delete (ZebraHandle zh);
126 void zebra_repository_show (ZebraHandle zh);
127 int zebra_record_insert (ZebraHandle zh, const char *buf, int len);
128
129 YAZ_EXPORT void zebra_set_group (ZebraHandle zh, struct recordGroup *rg);
130
131 YAZ_EXPORT void zebra_result (ZebraHandle zh, int *code, char **addinfo);
132
133
134 YAZ_EXPORT int zebra_resultSetTerms (ZebraHandle zh, const char *setname, 
135                                      int no, int *count, 
136                                      int *type, char *out, size_t *len);
137
138 YAZ_EXPORT void zebra_sort (ZebraHandle zh, ODR stream,
139                             int num_input_setnames,
140                             const char **input_setnames,
141                             const char *output_setname,
142                             Z_SortKeySpecList *sort_sequence,
143                             int *sort_status);
144
145
146 YAZ_EXPORT
147 int zebra_select_databases (ZebraHandle zh, int num_bases, 
148                             const char **basenames);
149
150 YAZ_EXPORT
151 int zebra_select_database (ZebraHandle zh, const char *basename);
152
153 YAZ_EXPORT
154 void zebra_shadow_enable (ZebraHandle zh, int value);
155
156 YAZ_EXPORT
157 void zebra_register_statistics (ZebraHandle zh, int dumpdict);
158
159 YAZ_EXPORT
160 int zebra_record_encoding (ZebraHandle zh, const char *encoding);
161
162 YAZ_END_CDECL                                 
163 #endif