YAZ version 1.4.
[yaz-moved-to-github.git] / include / backend.h
1 /*
2  * Copyright (c) 1995-1997, Index Data.
3  *
4  * Permission to use, copy, modify, distribute, and sell this software and
5  * its documentation, in whole or in part, for any purpose, is hereby granted,
6  * provided that:
7  *
8  * 1. This copyright and permission notice appear in all copies of the
9  * software and its documentation. Notices of copyright or attribution
10  * which appear at the beginning of any file must remain unchanged.
11  *
12  * 2. The name of Index Data or the individual authors may not be used to
13  * endorse or promote products derived from this software without specific
14  * prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS, IMPLIED, OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
18  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
19  * IN NO EVENT SHALL INDEX DATA BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
20  * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
21  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR
22  * NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
23  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
24  * OF THIS SOFTWARE.
25  *
26  * $Log: backend.h,v $
27  * Revision 1.16  1997-09-17 12:10:31  adam
28  * YAZ version 1.4.
29  *
30  */
31
32 #ifndef BACKEND_H
33 #define BACKEND_H
34
35 #include <yconfig.h>
36 #include <proto.h>
37 #include <statserv.h>
38
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42
43 typedef struct bend_initrequest
44 {
45     char *configname;
46     Z_IdAuthentication *auth;
47     ODR stream;                /* encoding stream */
48 } bend_initrequest;
49
50 typedef struct bend_initresult
51 {
52     int errcode;               /* 0==OK */
53     char *errstring;           /* system error string or NULL */
54     void *handle;              /* private handle to the backend module */
55 } bend_initresult;
56
57 YAZ_EXPORT bend_initresult MDF *bend_init(bend_initrequest *r);   
58
59 typedef struct bend_searchrequest
60 {
61     char *setname;             /* name to give to this set */
62     int replace_set;           /* replace set, if it already exists */
63     int num_bases;             /* number of databases in list */
64     char **basenames;          /* databases to search */
65     Z_Query *query;            /* query structure */
66     ODR stream;                /* encoding stream */
67 } bend_searchrequest;
68
69 typedef struct bend_searchresult
70 {
71     int hits;                  /* number of hits */
72     int errcode;               /* 0==OK */
73     char *errstring;           /* system error string or NULL */
74 } bend_searchresult;
75
76 YAZ_EXPORT bend_searchresult *bend_search(void *handle, bend_searchrequest *r,
77                                           int *fd);
78 YAZ_EXPORT bend_searchresult *bend_searchresponse(void *handle);
79
80 typedef struct bend_fetchrequest
81 {
82     char *setname;             /* set name */
83     int number;                /* record number */
84     oid_value format;          /* One of the CLASS_RECSYN members */
85     Z_RecordComposition *comp; /* Formatting instructions */
86     ODR stream;                /* encoding stream - memory source if required */
87 } bend_fetchrequest;
88
89 typedef struct bend_fetchresult
90 {
91     char *basename;            /* name of database that provided record */
92     int len;                   /* length of record or -1 if structured */
93     char *record;              /* record */
94     int last_in_set;           /* is it?  */
95     oid_value format;          /* format */
96     int errcode;               /* 0==success */
97     char *errstring;           /* system error string or NULL */
98 } bend_fetchresult;
99
100 YAZ_EXPORT bend_fetchresult *bend_fetch(void *handle, bend_fetchrequest *r,
101                                         int *fd);
102 YAZ_EXPORT bend_fetchresult *bend_fetchresponse(void *handle);
103
104 typedef struct bend_scanrequest
105 {
106     int num_bases;      /* number of elements in databaselist */
107     char **basenames;   /* databases to search */
108     oid_value attributeset;
109     Z_AttributesPlusTerm *term;
110     int term_position;  /* desired index of term in result list */
111     int num_entries;    /* number of entries requested */
112     ODR stream;         /* encoding stream - memory source if required */
113 } bend_scanrequest;
114
115 struct scan_entry {
116     char *term;
117     int occurrences;
118 };
119
120 typedef enum {
121     BEND_SCAN_SUCCESS,   /* ok */
122     BEND_SCAN_PARTIAL   /* not all entries could be found */
123 } bend_scan_status;
124
125 typedef struct bend_scanresult
126 {
127     int num_entries;
128     struct scan_entry *entries;
129     int term_position;
130     bend_scan_status status;
131     int errcode;
132     char *errstring;
133 } bend_scanresult;
134
135 YAZ_EXPORT bend_scanresult *bend_scan(void *handle, bend_scanrequest *r,
136                                       int *fd);
137 YAZ_EXPORT bend_scanresult *bend_scanresponse(void *handle);
138
139 typedef struct bend_deleterequest
140 {
141     char *setname;
142 } bend_deleterequest;
143
144 typedef struct bend_deleteresult
145 {
146     int errcode;               /* 0==success */
147     char *errstring;           /* system error string or NULL */
148 } bend_deleteresult;
149
150 YAZ_EXPORT bend_deleteresult *bend_delete(void *handle,
151                                           bend_deleterequest *r, int *fd);
152 YAZ_EXPORT bend_deleteresult *bend_deleteresponse(void *handle);
153
154 YAZ_EXPORT void bend_close(void *handle);
155
156 #ifdef __cplusplus
157 }
158 #endif
159
160 #endif