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