Added ODR encode in search and scen bend request structures.
[yaz-moved-to-github.git] / include / backend.h
1 /*
2  * Copyright (c) 1995, 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  */
27
28 #ifndef BACKEND_H
29 #define BACKEND_H
30
31 #include <yconfig.h>
32 #include <proto.h>
33 #include <statserv.h>
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 typedef struct bend_initrequest
40 {
41     char *configname;
42     Z_IdAuthentication *auth;
43 } bend_initrequest;
44
45 typedef struct bend_initresult
46 {
47     int errcode;               /* 0==OK */
48     char *errstring;           /* system error string or NULL */
49     void *handle;              /* private handle to the backend module */
50 } bend_initresult;
51
52 YAZ_EXPORT bend_initresult MDF *bend_init(bend_initrequest *r);   
53
54 typedef struct bend_searchrequest
55 {
56     char *setname;             /* name to give to this set */
57     int replace_set;           /* replace set, if it already exists */
58     int num_bases;             /* number of databases in list */
59     char **basenames;          /* databases to search */
60     Z_Query *query;            /* query structure */
61     ODR stream;                /* encoding stream */
62 } bend_searchrequest;
63
64 typedef struct bend_searchresult
65 {
66     int hits;                  /* number of hits */
67     int errcode;               /* 0==OK */
68     char *errstring;           /* system error string or NULL */
69 } bend_searchresult;
70
71 YAZ_EXPORT bend_searchresult *bend_search(void *handle, bend_searchrequest *r,
72                                           int *fd);
73 YAZ_EXPORT bend_searchresult *bend_searchresponse(void *handle);
74
75 typedef struct bend_fetchrequest
76 {
77     char *setname;             /* set name */
78     int number;                /* record number */
79     oid_value format;          /* One of the CLASS_RECSYN members */
80     Z_RecordComposition *comp; /* Formatting instructions */
81     ODR stream;                /* encoding stream - memory source if required */
82 } bend_fetchrequest;
83
84 typedef struct bend_fetchresult
85 {
86     char *basename;            /* name of database that provided record */
87     int len;                   /* length of record or -1 if structured */
88     char *record;              /* record */
89     int last_in_set;           /* is it?  */
90     oid_value format;          /* format */
91     int errcode;               /* 0==success */
92     char *errstring;           /* system error string or NULL */
93 } bend_fetchresult;
94
95 YAZ_EXPORT bend_fetchresult *bend_fetch(void *handle, bend_fetchrequest *r,
96                                         int *fd);
97 YAZ_EXPORT bend_fetchresult *bend_fetchresponse(void *handle);
98
99 typedef struct bend_scanrequest
100 {
101     int num_bases;      /* number of elements in databaselist */
102     char **basenames;   /* databases to search */
103     oid_value attributeset;
104     Z_AttributesPlusTerm *term;
105     int term_position;  /* desired index of term in result list */
106     int num_entries;    /* number of entries requested */
107     ODR stream;         /* encoding stream - memory source if required */
108 } bend_scanrequest;
109
110 struct scan_entry {
111     char *term;
112     int occurrences;
113 };
114
115 typedef enum {
116     BEND_SCAN_SUCCESS,   /* ok */
117     BEND_SCAN_PARTIAL   /* not all entries could be found */
118 } bend_scan_status;
119
120 typedef struct bend_scanresult
121 {
122     int num_entries;
123     struct scan_entry *entries;
124     int term_position;
125     bend_scan_status status;
126     int errcode;
127     char *errstring;
128 } bend_scanresult;
129
130 YAZ_EXPORT bend_scanresult *bend_scan(void *handle, bend_scanrequest *r,
131                                       int *fd);
132 YAZ_EXPORT bend_scanresult *bend_scanresponse(void *handle);
133
134 typedef struct bend_deleterequest
135 {
136     char *setname;
137 } bend_deleterequest;
138
139 typedef struct bend_deleteresult
140 {
141     int errcode;               /* 0==success */
142     char *errstring;           /* system error string or NULL */
143 } bend_deleteresult;
144
145 YAZ_EXPORT bend_deleteresult *bend_delete(void *handle,
146                                           bend_deleterequest *r, int *fd);
147 YAZ_EXPORT bend_deleteresult *bend_deleteresponse(void *handle);
148
149 YAZ_EXPORT void bend_close(void *handle);
150
151 #ifdef __cplusplus
152 }
153 #endif
154
155 #endif