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