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