8fe0dad4ad400529ddbd791557f306a968abd237
[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.13 2002-02-20 17:30:01 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
16 YAZ_BEGIN_CDECL
17
18 /* Retrieval Record Descriptor */
19 typedef struct {
20     int errCode;         /* non-zero if error when fetching this */
21     char *errString;     /* error string */
22     int position;        /* position of record in result set (1,2,..) */
23     char *buf;           /* record buffer (void pointer really) */
24     int len;             /* length */
25     oid_value format;    /* record syntax */
26     char *base; 
27 } ZebraRetrievalRecord;
28
29 /* Scan Term Descriptor */
30 typedef struct {
31     int occurrences;     /* scan term occurrences */
32     char *term;          /* scan term string */
33 } ZebraScanEntry;
34
35 typedef struct zebra_session *ZebraHandle;
36 typedef struct zebra_service *ZebraService;
37
38 /* Open Zebra using file 'configName' (usually zebra.cfg) */
39 YAZ_EXPORT ZebraHandle zebra_open (ZebraService zs);
40
41 /* Search using RPN-Query */
42 YAZ_EXPORT void zebra_search_rpn (ZebraHandle zh, ODR input, ODR output,
43                        Z_RPNQuery *query, int num_bases, char **basenames, 
44                        const char *setname);
45
46 /* Retrieve record(s) */
47 YAZ_EXPORT void zebra_records_retrieve (ZebraHandle zh, ODR stream,
48                        const char *setname, Z_RecordComposition *comp,
49                        oid_value input_format,
50                        int num_recs, ZebraRetrievalRecord *recs);
51
52 /* Browse */
53 YAZ_EXPORT void zebra_scan (ZebraHandle zh, ODR stream,
54                             Z_AttributesPlusTerm *zapt,
55                             oid_value attributeset,
56                             int num_bases, char **basenames,
57                             int *position, int *num_entries,
58                             ZebraScanEntry **list,
59                             int *is_partial);
60     
61 /* Delete Result Set(s) */
62 YAZ_EXPORT int zebra_deleleResultSet(ZebraHandle zh, int function,
63                                      int num_setnames, char **setnames,
64                                      int *statuses);
65
66 /* Close zebra and destroy handle */
67 YAZ_EXPORT void zebra_close (ZebraHandle zh);
68
69 /* last error code */
70 YAZ_EXPORT int zebra_errCode (ZebraHandle zh);
71 /* string representatio of above */
72 YAZ_EXPORT const char *zebra_errString (ZebraHandle zh);
73
74 /* extra information associated with error */
75 YAZ_EXPORT char *zebra_errAdd (ZebraHandle zh);
76
77 /* number of hits (after search) */
78 YAZ_EXPORT int zebra_hits (ZebraHandle zh);
79
80 /* do authentication */
81 YAZ_EXPORT int zebra_auth (ZebraService zh, const char *user, const char *pass);
82
83 /* Character normalisation on specific register .
84    This routine is subject to change - do not use. */
85 YAZ_EXPORT int zebra_string_norm (ZebraHandle zh, unsigned reg_id,
86                                   const char *input_str, int input_len,
87                                   char *output_str, int output_len);
88
89 YAZ_EXPORT void zebra_admin_create (ZebraHandle zh, const char *db);
90
91 YAZ_EXPORT ZebraService zebra_start (const char *configName);
92 YAZ_EXPORT void zebra_stop (ZebraService zs);
93
94 YAZ_EXPORT void zebra_admin_shutdown (ZebraHandle zh);
95 YAZ_EXPORT void zebra_admin_start (ZebraHandle zh);
96
97 YAZ_EXPORT void zebra_shutdown (ZebraService zs);
98
99 YAZ_EXPORT void zebra_admin_import_begin (ZebraHandle zh, const char *database);
100
101 YAZ_EXPORT void zebra_admin_import_segment (ZebraHandle zh,
102                                             Z_Segment *segment);
103
104 void zebra_admin_import_end (ZebraHandle zh);
105
106 void zebra_begin_trans (ZebraHandle zh);
107 void zebra_end_trans (ZebraHandle zh);
108
109 void zebra_commit (ZebraHandle zh);
110
111 void zebra_init (ZebraHandle zh);
112 void zebra_compact (ZebraHandle zh);
113 void zebra_repository_update (ZebraHandle zh);
114 void zebra_repository_delete (ZebraHandle zh);
115 void zebra_repository_show (ZebraHandle zh);
116 int zebra_record_insert (ZebraHandle zh, const char *buf, int len);
117
118 YAZ_END_CDECL                                 
119 #endif