2b3e8d71e1b18153f6675d882bbb4ed397b9a961
[egate.git] / include / zaccess.h
1 /*
2  * Europagate, 1995
3  *
4  * $Log: zaccess.h,v $
5  * Revision 1.12  1995/04/20 15:25:25  quinn
6  * Asynch. API
7  *
8  * Revision 1.11  1995/04/19  12:55:41  quinn
9  * Added auth
10  *
11  * Revision 1.10  1995/04/17  11:27:24  quinn
12  * Smallish
13  *
14  * Revision 1.9  1995/02/23  08:32:12  adam
15  * Changed header.
16  *
17  * Revision 1.7  1995/02/17  13:59:06  quinn
18  * Added header.
19  *
20  */
21
22 #ifndef ZACCESS_H
23 #define ZACCESS_H
24
25 #define ZASS_DEBUG GW_LOG_DEBUGN(9)
26 #define ZASS_TYPE "zass"
27
28 #define ZASS_ID "EUROPAGATE/DTV/ID"
29 #define ZASS_NAME "EUROPAGATE E-mail/Z39.50 gateway"
30 #define ZASS_VERSION "development 0.2"
31
32 #define ZASS_MAXRECORDSIZE  40000
33 #define ZASS_PREFERREDMESSAGESIZE 40000
34
35 typedef struct zass *ZASS;
36
37 enum present_status
38 {
39     ZASS_PRES_SUCCESS,        /* all records available */
40     ZASS_PRES_PARTIAL_1,      /* subset only 'cause of access control */
41     ZASS_PRES_PARTIAL_2,      /* subset 'cause of max msg size constraints*/
42     ZASS_PRES_PARTIAL_3,      /* subset 'cause of resource control org */
43     ZASS_PRES_PARTIAL_4,      /* subset 'cause of resource control trg */
44     ZASS_PRES_FAILURE         /* check errcode */
45 };
46
47 typedef struct zass_searchent
48 {
49     int num;      /* # hits */
50     int status;   /* status - boolean - qualified by setstatus */
51     enum present_status setstatus; /* consult if status. Value according to Z proto */
52
53     /* These two fields provide info from a diagnostic rec returned with 
54        response */
55     int errcode;           /* bib 1 assumed here. -1 if none provided */
56     char errstring[512];   /* Additional info from diagnostic rec, or "" */
57 } zass_searchent;
58
59 typedef struct zass_record
60 {
61     enum
62     {
63         ZASS_REC_UNKNOWN=-1,
64         ZASS_REC_DIAG=0,
65         ZASS_REC_USMARC=10
66     } which;      /* 0 = diagnostic, others according to z3950v3 */
67     char *record;   /* marc or other */
68
69     int errcode;    /* Only valid if which == 0 */
70     char errstring[200];
71
72     struct zass_record *next;
73 } zass_record;
74
75 typedef struct zass_presentent
76 {
77     int num;             /* # of recs returned */
78     int nextpos;         /* next resultset position. 1==first record */
79     enum present_status presentstatus;   /* status of set */
80     struct zass_record *records;
81 } zass_presentent;
82
83 /*
84  * open a connection to the target. If complete is NULL, the connection
85  * will be blocking, and complete will be ignored by the following
86  * primitives. If complete is not null, the connection will be non-blocking.
87  * if the connection cannot be established immediately, *complete will
88  * be set to zero, and the user should call openresult when select signals
89  * that I/O is possible. Returns NULL on a fatal error in the connection
90  * establishment.
91  */
92 ZASS zass_open(char *host, int port, int *complete, char *auth);
93
94 /*
95  * second half of connection establishment in nonblocking mode.
96  * Returns:
97  * -1 with *complete == 0   : call again when select allows.
98  * -1 with *complete == 1   : fatal error. Abort connection.
99  * 0                        : success. 
100  */
101 int zass_openresult(ZASS a, int *complete);
102
103 /*
104  * Return the file handle of the association (for select() & other fun.
105  */
106 int zass_fileno(ZASS a);
107
108 /*
109  * Returns:
110  * NULL with *complete == 0 : call searchresult when select allows (nonbl. only)
111  * NULL with *complete == 1 : fatal error. Abort connection.
112  * non-null                 : operation complete.
113  */
114 const struct zass_searchent *zass_search(ZASS a, struct ccl_rpn_node *query,
115     char *resname, char *databases, int *complete);
116
117 /*
118  * Returns:
119  * NULL with *complete == 0 : call again when select allows (nonbl. only)
120  * NULL with *complete == 1 : fatal error. Abort connection.
121  * non-null                 : operation complete.
122  */
123 const struct zass_searchent *zass_searchresult(ZASS a, int *complete);
124
125 /*
126  * Returns:
127  * NULL with *complete == 0 : call presentresult when select ok (nonbl. only)
128  * NULL with *complete == 1 : fatal error. Abort connection.
129  * non-null                 : operation complete.
130  */
131 const struct zass_presentent *zass_present(ZASS a, char *resname, int start,
132     int num, int *complete);
133
134 /*
135  * Returns:
136  * NULL with *complete == 0 : call again when select allows (nonbl. only)
137  * NULL with *complete == 1 : fatal error. Abort connection.
138  * non-null                 : operation complete.
139  */
140 const struct zass_presentent *zass_presentresult(ZASS a, int *complete);
141
142 #endif