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