a7c7bf542a599c6a97c1da8f44714e5cd529b22b
[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 <proto.h>
32
33 typedef struct bend_initrequest
34 {
35     char *configname;
36 } bend_initrequest;
37
38 typedef struct bend_initresult
39 {
40     int errcode;               /* 0==OK */
41     char *errstring;           /* system error string or NULL */
42     void *handle;              /* private handle to the backend module */
43 } bend_initresult;
44
45 typedef struct bend_searchrequest
46 {
47     char *setname;             /* name to give to this set */
48     int replace_set;           /* replace set, if it already exists */
49     int num_bases;             /* number of databases in list */
50     char **basenames;          /* databases to search */
51     Z_Query *query;            /* query structure */
52 } bend_searchrequest;
53
54 typedef struct bend_scanrequest
55 {
56     int num_bases;      /* number of elements in databaselist */
57     char **basenames;   /* databases to search */
58     Z_AttributesPlusTerm *term;
59     int term_position;  /* desired index of term in result list */
60     int num_entries;    /* number of entries requested */
61 } bend_scanrequest;
62
63 typedef struct bend_scanresult
64 {
65     int num_entries;
66     struct scan_entry
67     {
68         char *term;
69         int occurrences;
70     } *entries;
71     int term_position;
72     enum
73     {
74         BEND_SCAN_SUCCESS,   /* ok */
75         BEND_SCAN_PARTIAL   /* not all entries could be found */
76     } status;
77     int errcode;
78     char *errstring;
79 } bend_scanresult;
80
81 typedef struct bend_searchresult
82 {
83     int hits;                  /* number of hits */
84     int errcode;               /* 0==OK */
85     char *errstring;           /* system error string or NULL */
86 } bend_searchresult;
87
88 typedef struct bend_fetchrequest
89 {
90     char *setname;             /* set name */
91     int number;                /* record number */
92 } bend_fetchrequest;
93
94 typedef struct bend_fetchresult
95 {
96     char *basename;            /* name of database that provided record */
97     int len;                   /* length of record */
98     char *record;              /* record */
99     int last_in_set;           /* is it?  */
100     int errcode;               /* 0==success */
101     char *errstring;           /* system error string or NULL */
102 } bend_fetchresult;
103
104 typedef struct bend_deleterequest
105 {
106     char *setname;
107 } bend_deleterequest;
108
109 typedef struct bend_deleteresult
110 {
111     int errcode;               /* 0==success */
112     char *errstring;           /* system error string or NULL */
113 } bend_deleteresult;
114
115 bend_initresult *bend_init(bend_initrequest *r);
116
117 bend_searchresult *bend_search(void *handle, bend_searchrequest *r, int *fd);
118 bend_searchresult *bend_searchresponse(void *handle);
119
120 bend_fetchresult *bend_fetch(void *handle, bend_fetchrequest *r, int *fd);
121 bend_fetchresult *bend_fetchresponse(void *handle);
122
123 bend_scanresult *bend_scan(void *handle, bend_scanrequest *r, int *fd);
124 bend_scanresult *bend_scanresponse(void *handle);
125
126 bend_deleteresult *bend_delete(void *handle, bend_deleterequest *r, int *fd);
127 bend_deleteresult *bend_deleteresponse(void *handle);
128
129 void bend_close(void *handle);
130
131 #endif