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