Updated for YAZ 1.7. HTML output tidy up. Added LOC target.
[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.14  2001/02/26 14:32:36  adam
49  * Updated for YAZ 1.7. HTML output tidy up. Added LOC target.
50  *
51  * Revision 1.13  1995/05/16 09:39:40  adam
52  * LICENSE.
53  *
54  * Revision 1.12  1995/04/20  15:25:25  quinn
55  * Asynch. API
56  *
57  * Revision 1.11  1995/04/19  12:55:41  quinn
58  * Added auth
59  *
60  * Revision 1.10  1995/04/17  11:27:24  quinn
61  * Smallish
62  *
63  * Revision 1.9  1995/02/23  08:32:12  adam
64  * Changed header.
65  *
66  * Revision 1.7  1995/02/17  13:59:06  quinn
67  * Added header.
68  *
69  */
70
71 #ifndef ZACCESS_H
72 #define ZACCESS_H
73
74 #define ZASS_DEBUG GW_LOG_DEBUGN(9)
75 #define ZASS_TYPE "zass"
76
77 #define ZASS_ID "EUROPAGATE/DTV/ID"
78 #define ZASS_NAME "EUROPAGATE E-mail/Z39.50 gateway"
79 #define ZASS_VERSION "development 0.2"
80
81 #define ZASS_MAXRECORDSIZE  40000
82 #define ZASS_PREFERREDMESSAGESIZE 40000
83
84 typedef struct zass *ZASS;
85
86 enum present_status
87 {
88     ZASS_PRES_SUCCESS,        /* all records available */
89     ZASS_PRES_PARTIAL_1,      /* subset only 'cause of access control */
90     ZASS_PRES_PARTIAL_2,      /* subset 'cause of max msg size constraints*/
91     ZASS_PRES_PARTIAL_3,      /* subset 'cause of resource control org */
92     ZASS_PRES_PARTIAL_4,      /* subset 'cause of resource control trg */
93     ZASS_PRES_FAILURE         /* check errcode */
94 };
95
96 typedef struct zass_searchent
97 {
98     int num;      /* # hits */
99     int status;   /* status - boolean - qualified by setstatus */
100     enum present_status setstatus; /* consult if status. Value according to Z proto */
101
102     /* These two fields provide info from a diagnostic rec returned with 
103        response */
104     int errcode;           /* bib 1 assumed here. -1 if none provided */
105     char errstring[512];   /* Additional info from diagnostic rec, or "" */
106 } zass_searchent;
107
108 typedef struct zass_record
109 {
110     enum
111     {
112         ZASS_REC_UNKNOWN=-1,
113         ZASS_REC_DIAG=0,
114         ZASS_REC_USMARC=10,
115         ZASS_REC_DANMARC=11
116     } which;      /* 0 = diagnostic, others according to z3950v3 */
117     char *record;   /* marc or other */
118
119     int errcode;    /* Only valid if which == 0 */
120     char errstring[200];
121
122     struct zass_record *next;
123 } zass_record;
124
125 typedef struct zass_presentent
126 {
127     int num;             /* # of recs returned */
128     int nextpos;         /* next resultset position. 1==first record */
129     enum present_status presentstatus;   /* status of set */
130     struct zass_record *records;
131 } zass_presentent;
132
133 /*
134  * open a connection to the target. If complete is NULL, the connection
135  * will be blocking, and complete will be ignored by the following
136  * primitives. If complete is not null, the connection will be non-blocking.
137  * if the connection cannot be established immediately, *complete will
138  * be set to zero, and the user should call openresult when select signals
139  * that I/O is possible. Returns NULL on a fatal error in the connection
140  * establishment.
141  */
142 ZASS zass_open(char *host, int port, int *complete, char *auth);
143
144 /*
145  * second half of connection establishment in nonblocking mode.
146  * Returns:
147  * -1 with *complete == 0   : call again when select allows.
148  * -1 with *complete == 1   : fatal error. Abort connection.
149  * 0                        : success. 
150  */
151 int zass_openresult(ZASS a, int *complete);
152
153 /*
154  * Return the file handle of the association (for select() & other fun.
155  */
156 int zass_fileno(ZASS a);
157
158 /*
159  * Returns:
160  * NULL with *complete == 0 : call searchresult when select allows (nonbl. only)
161  * NULL with *complete == 1 : fatal error. Abort connection.
162  * non-null                 : operation complete.
163  */
164 const struct zass_searchent *zass_search(ZASS a, struct ccl_rpn_node *query,
165     char *resname, char *databases, int *complete);
166
167 /*
168  * Returns:
169  * NULL with *complete == 0 : call again when select allows (nonbl. only)
170  * NULL with *complete == 1 : fatal error. Abort connection.
171  * non-null                 : operation complete.
172  */
173 const struct zass_searchent *zass_searchresult(ZASS a, int *complete);
174
175 /*
176  * Returns:
177  * NULL with *complete == 0 : call presentresult when select ok (nonbl. only)
178  * NULL with *complete == 1 : fatal error. Abort connection.
179  * non-null                 : operation complete.
180  */
181 const struct zass_presentent *zass_present(ZASS a, char *resname, int start,
182     int num, int *complete);
183
184 /*
185  * Returns:
186  * NULL with *complete == 0 : call again when select allows (nonbl. only)
187  * NULL with *complete == 1 : fatal error. Abort connection.
188  * non-null                 : operation complete.
189  */
190 const struct zass_presentent *zass_presentresult(ZASS a, int *complete);
191
192 #endif