2935fef2d563d77917d0c4fe87fcb1d7d01b35db
[idzebra-moved-to-github.git] / index / zebraapi.h
1 /*
2  * Copyright (C) 1994-1998, Index Data
3  * All rights reserved.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: zebraapi.h,v $
7  * Revision 1.12  2000-04-05 09:49:35  adam
8  * On Unix, zebra/z'mbol uses automake.
9  *
10  * Revision 1.11  2000/03/20 19:08:36  adam
11  * Added remote record import using Z39.50 extended services and Segment
12  * Requests.
13  *
14  * Revision 1.10  2000/03/15 15:00:31  adam
15  * First work on threaded version.
16  *
17  * Revision 1.9  2000/02/24 12:31:17  adam
18  * Added zebra_string_norm.
19  *
20  * Revision 1.8  1999/11/30 13:48:03  adam
21  * Improved installation. Updated for inclusion of YAZ header files.
22  *
23  * Revision 1.7  1999/11/04 15:00:45  adam
24  * Implemented delete result set(s).
25  *
26  * Revision 1.6  1999/02/17 11:29:57  adam
27  * Fixed in record_fetch. Minor updates to API.
28  *
29  * Revision 1.5  1998/09/22 10:48:19  adam
30  * Minor changes in search API.
31  *
32  * Revision 1.4  1998/09/02 13:53:18  adam
33  * Extra parameter decode added to search routines to implement
34  * persistent queries.
35  *
36  * Revision 1.3  1998/06/22 11:36:48  adam
37  * Added authentication check facility to zebra.
38  *
39  * Revision 1.2  1998/06/13 00:14:09  adam
40  * Minor changes.
41  *
42  * Revision 1.1  1998/06/12 12:22:13  adam
43  * Work on Zebra API.
44  *
45  */
46
47 #include <yaz/odr.h>
48 #include <yaz/oid.h>
49 #include <yaz/proto.h>
50
51 YAZ_BEGIN_CDECL
52
53 /* Retrieval Record Descriptor */
54 typedef struct {
55     int errCode;         /* non-zero if error when fetching this */
56     char *errString;     /* error string */
57     int position;        /* position of record in result set (1,2,..) */
58     char *buf;           /* record buffer (void pointer really) */
59     int len;             /* length */
60     oid_value format;    /* record syntax */
61     char *base; 
62 } ZebraRetrievalRecord;
63
64 /* Scan Term Descriptor */
65 typedef struct {
66     int occurrences;     /* scan term occurrences */
67     char *term;          /* scan term string */
68 } ZebraScanEntry;
69
70 typedef struct zebra_session *ZebraHandle;
71 typedef struct zebra_service *ZebraService;
72
73 /* Open Zebra using file 'configName' (usually zebra.cfg) */
74 YAZ_EXPORT ZebraHandle zebra_open (ZebraService zs);
75
76 /* Search using RPN-Query */
77 YAZ_EXPORT void zebra_search_rpn (ZebraHandle zh, ODR input, ODR output,
78                        Z_RPNQuery *query, int num_bases, char **basenames, 
79                        const char *setname);
80
81 /* Retrieve record(s) */
82 YAZ_EXPORT void zebra_records_retrieve (ZebraHandle zh, ODR stream,
83                        const char *setname, Z_RecordComposition *comp,
84                        oid_value input_format,
85                        int num_recs, ZebraRetrievalRecord *recs);
86
87 /* Browse */
88 YAZ_EXPORT void zebra_scan (ZebraHandle zh, ODR stream,
89                             Z_AttributesPlusTerm *zapt,
90                             oid_value attributeset,
91                             int num_bases, char **basenames,
92                             int *position, int *num_entries,
93                             ZebraScanEntry **list,
94                             int *is_partial);
95     
96 /* Delete Result Set(s) */
97 YAZ_EXPORT int zebra_deleleResultSet(ZebraHandle zh, int function,
98                                      int num_setnames, char **setnames,
99                                      int *statuses);
100
101 /* Close zebra and destroy handle */
102 YAZ_EXPORT void zebra_close (ZebraHandle zh);
103
104 /* last error code */
105 YAZ_EXPORT int zebra_errCode (ZebraHandle zh);
106 /* string representatio of above */
107 YAZ_EXPORT const char *zebra_errString (ZebraHandle zh);
108
109 /* extra information associated with error */
110 YAZ_EXPORT char *zebra_errAdd (ZebraHandle zh);
111
112 /* number of hits (after search) */
113 YAZ_EXPORT int zebra_hits (ZebraHandle zh);
114
115 /* do authentication */
116 YAZ_EXPORT int zebra_auth (ZebraService 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
136 YAZ_EXPORT void zebra_admin_import_segment (ZebraHandle zh,
137                                             Z_Segment *segment);
138
139 void zebra_admin_import_end (ZebraHandle zh);
140 YAZ_END_CDECL