4a6196877da71eaecbf95fd6a112eb38c19aa36f
[egate.git] / include / zaccess.h
1 /*
2  * Copyright (c) 1995, the EUROPAGATE consortium (see below).
3  *
4  * The EUROPAGATE consortium members are:
5  *
6  *    University College Dublin
7  *    Danmarks Teknologiske Videnscenter
8  *    An Chomhairle Leabharlanna
9  *    Consejo Superior de Investigaciones Cientificas
10  *
11  * Permission to use, copy, modify, distribute, and sell this software and
12  * its documentation, in whole or in part, for any purpose, is hereby granted,
13  * provided that:
14  *
15  * 1. This copyright and permission notice appear in all copies of the
16  * software and its documentation. Notices of copyright or attribution
17  * which appear at the beginning of any file must remain unchanged.
18  *
19  * 2. The names of EUROPAGATE or the project partners may not be used to
20  * endorse or promote products derived from this software without specific
21  * prior written permission.
22  *
23  * 3. Users of this software (implementors and gateway operators) agree to
24  * inform the EUROPAGATE consortium of their use of the software. This
25  * information will be used to evaluate the EUROPAGATE project and the
26  * software, and to plan further developments. The consortium may use
27  * the information in later publications.
28  * 
29  * 4. Users of this software agree to make their best efforts, when
30  * documenting their use of the software, to acknowledge the EUROPAGATE
31  * consortium, and the role played by the software in their work.
32  *
33  * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,
34  * EXPRESS, IMPLIED, OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
35  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
36  * IN NO EVENT SHALL THE EUROPAGATE CONSORTIUM OR ITS MEMBERS BE LIABLE
37  * FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF
38  * ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA
39  * OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND
40  * ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
41  * USE OR PERFORMANCE OF THIS SOFTWARE.
42  *
43  */
44 /*
45  * Europagate, 1995
46  *
47  * $Log: zaccess.h,v $
48  * Revision 1.13  1995/05/16 09:39:40  adam
49  * LICENSE.
50  *
51  * Revision 1.12  1995/04/20  15:25:25  quinn
52  * Asynch. API
53  *
54  * Revision 1.11  1995/04/19  12:55:41  quinn
55  * Added auth
56  *
57  * Revision 1.10  1995/04/17  11:27:24  quinn
58  * Smallish
59  *
60  * Revision 1.9  1995/02/23  08:32:12  adam
61  * Changed header.
62  *
63  * Revision 1.7  1995/02/17  13:59:06  quinn
64  * Added header.
65  *
66  */
67
68 #ifndef ZACCESS_H
69 #define ZACCESS_H
70
71 #define ZASS_DEBUG GW_LOG_DEBUGN(9)
72 #define ZASS_TYPE "zass"
73
74 #define ZASS_ID "EUROPAGATE/DTV/ID"
75 #define ZASS_NAME "EUROPAGATE E-mail/Z39.50 gateway"
76 #define ZASS_VERSION "development 0.2"
77
78 #define ZASS_MAXRECORDSIZE  40000
79 #define ZASS_PREFERREDMESSAGESIZE 40000
80
81 typedef struct zass *ZASS;
82
83 enum present_status
84 {
85     ZASS_PRES_SUCCESS,        /* all records available */
86     ZASS_PRES_PARTIAL_1,      /* subset only 'cause of access control */
87     ZASS_PRES_PARTIAL_2,      /* subset 'cause of max msg size constraints*/
88     ZASS_PRES_PARTIAL_3,      /* subset 'cause of resource control org */
89     ZASS_PRES_PARTIAL_4,      /* subset 'cause of resource control trg */
90     ZASS_PRES_FAILURE         /* check errcode */
91 };
92
93 typedef struct zass_searchent
94 {
95     int num;      /* # hits */
96     int status;   /* status - boolean - qualified by setstatus */
97     enum present_status setstatus; /* consult if status. Value according to Z proto */
98
99     /* These two fields provide info from a diagnostic rec returned with 
100        response */
101     int errcode;           /* bib 1 assumed here. -1 if none provided */
102     char errstring[512];   /* Additional info from diagnostic rec, or "" */
103 } zass_searchent;
104
105 typedef struct zass_record
106 {
107     enum
108     {
109         ZASS_REC_UNKNOWN=-1,
110         ZASS_REC_DIAG=0,
111         ZASS_REC_USMARC=10
112     } which;      /* 0 = diagnostic, others according to z3950v3 */
113     char *record;   /* marc or other */
114
115     int errcode;    /* Only valid if which == 0 */
116     char errstring[200];
117
118     struct zass_record *next;
119 } zass_record;
120
121 typedef struct zass_presentent
122 {
123     int num;             /* # of recs returned */
124     int nextpos;         /* next resultset position. 1==first record */
125     enum present_status presentstatus;   /* status of set */
126     struct zass_record *records;
127 } zass_presentent;
128
129 /*
130  * open a connection to the target. If complete is NULL, the connection
131  * will be blocking, and complete will be ignored by the following
132  * primitives. If complete is not null, the connection will be non-blocking.
133  * if the connection cannot be established immediately, *complete will
134  * be set to zero, and the user should call openresult when select signals
135  * that I/O is possible. Returns NULL on a fatal error in the connection
136  * establishment.
137  */
138 ZASS zass_open(char *host, int port, int *complete, char *auth);
139
140 /*
141  * second half of connection establishment in nonblocking mode.
142  * Returns:
143  * -1 with *complete == 0   : call again when select allows.
144  * -1 with *complete == 1   : fatal error. Abort connection.
145  * 0                        : success. 
146  */
147 int zass_openresult(ZASS a, int *complete);
148
149 /*
150  * Return the file handle of the association (for select() & other fun.
151  */
152 int zass_fileno(ZASS a);
153
154 /*
155  * Returns:
156  * NULL with *complete == 0 : call searchresult when select allows (nonbl. only)
157  * NULL with *complete == 1 : fatal error. Abort connection.
158  * non-null                 : operation complete.
159  */
160 const struct zass_searchent *zass_search(ZASS a, struct ccl_rpn_node *query,
161     char *resname, char *databases, int *complete);
162
163 /*
164  * Returns:
165  * NULL with *complete == 0 : call again when select allows (nonbl. only)
166  * NULL with *complete == 1 : fatal error. Abort connection.
167  * non-null                 : operation complete.
168  */
169 const struct zass_searchent *zass_searchresult(ZASS a, int *complete);
170
171 /*
172  * Returns:
173  * NULL with *complete == 0 : call presentresult when select ok (nonbl. only)
174  * NULL with *complete == 1 : fatal error. Abort connection.
175  * non-null                 : operation complete.
176  */
177 const struct zass_presentent *zass_present(ZASS a, char *resname, int start,
178     int num, int *complete);
179
180 /*
181  * Returns:
182  * NULL with *complete == 0 : call again when select allows (nonbl. only)
183  * NULL with *complete == 1 : fatal error. Abort connection.
184  * non-null                 : operation complete.
185  */
186 const struct zass_presentent *zass_presentresult(ZASS a, int *complete);
187
188 #endif