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