The gateway doesn't try to reconnect if it is already known that
[egate.git] / kernel / kernel.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 /* Gateway kernel
45  * Europagate, 1995
46  *
47  * $Log: kernel.h,v $
48  * Revision 1.21  1996/02/12 10:04:52  adam
49  * The gateway doesn't try to reconnect if it is already known that
50  * it will fail (connect_fail flag introduced).
51  *
52  * Revision 1.20  1995/07/28  10:51:08  adam
53  * Bug fix: account from previous session had effect when new target command
54  * was executed.
55  *
56  * Revision 1.19  1995/07/11  11:49:12  adam
57  * LINE_MAX renamed to STR_LINE_MAX.
58  *
59  * Revision 1.18  1995/05/16  09:40:42  adam
60  * LICENSE. Setting of CCL token names (and/or/not/set) in read_kernel_res.
61  *
62  * Revision 1.17  1995/05/03  16:34:18  adam
63  * CCL def command, i.e. user definitions - saved as resource files.
64  *
65  * Revision 1.16  1995/05/03  07:37:37  adam
66  * CCL commands stop/continue implemented. New functions gw_res_{int,bool}
67  * are used when possible.
68  *
69  * Revision 1.15  1995/04/19  13:19:08  adam
70  * New command: account - for authentication.
71  *
72  * Revision 1.14  1995/04/19  10:46:18  adam
73  * Persistency works much better now. New command: status - history-like
74  *
75  * Revision 1.13  1995/04/19  07:31:04  adam
76  * First work on Z39.50 persistence.
77  *
78  * Revision 1.12  1995/04/17  09:34:29  adam
79  * Timeout (idletime) adjustable. Minor changes in kernel.
80  *
81  * Revision 1.11  1995/03/28  11:42:34  adam
82  * First use of string-queue utility.
83  *
84  * Revision 1.10  1995/03/27  08:24:01  adam
85  * First use of gip interface and gw-db.
86  * First work on eti program.
87  *
88  * Revision 1.9  1995/03/03  17:19:13  adam
89  * Smarter presentation. Bug fix in email header interpretation.
90  *
91  * Revision 1.8  1995/03/01  14:32:24  adam
92  * Better diagnostics. Default is, that only one database selected when
93  * several are known.
94  *
95  * Revision 1.7  1995/02/23  08:32:16  adam
96  * Changed header.
97  *
98  * Revision 1.5  1995/02/22  15:22:32  adam
99  * Much more checking of run-time state. Show command never retrieves
100  * more records than indicated by the previous search request. Help
101  * command available. The maximum number of records retrieved can be
102  * controlled now.
103  *
104  * Revision 1.4  1995/02/20  21:16:18  adam
105  * FML support. Bug fixes. Profile for drewdb.
106  *
107  * Revision 1.3  1995/02/16  18:35:08  adam
108  * First use of Zdist library. Search requests are supported.
109  * Present requests are not supported yet.
110  *
111  * Revision 1.2  1995/02/16  13:20:59  adam
112  * Organization of resource files for targets and conversion
113  * language implemented.
114  *
115  * Revision 1.1  1995/02/15  17:45:29  adam
116  * First version of email gateway kernel. Email requests are read
117  * from stdin. The output is transferred to an MTA if 'From' is
118  * found in the header - or stdout if absent. No Z39.50 client is used.
119  *
120  */
121
122 #include <gw-res.h>
123 #include <gw-log.h>
124 #include <ccl.h>
125 #include <zaccess.h>
126
127 #include <iso2709.h>
128 #if USE_FML
129 #include <fmlmarc.h>
130 #endif
131 #include <strqueue.h>
132
133 #define STR_LINE_MAX 1024
134
135 struct gw_user_set {
136     char   *name;               /* name of result set */
137     int    hits;                /* -1 on error */
138     char   *database;           /* database(s) in which we search */
139     struct ccl_rpn_node *rpn;   /* rpn request */
140     int    present_flag;        /* present in target (presistency) */
141     char   *search_str;         /* find request string */
142     struct gw_user_set *prev;
143 };
144
145 struct gw_kernel_info {
146     CCL_bibset bibset;
147     GwRes kernel_res;
148     const char *default_res; 
149     const char *override_res;
150     char target[128];
151     char hostname[128];
152     char account[128];
153     int  account_in_session;
154     int  port;
155     int  connect_failed;
156     const char *lang;
157     const char *override_portno;
158     const char *override_hostname;
159     char *databases;
160     char *database;
161     ZASS  zass;
162     int command_no;
163     char  from_str[STR_LINE_MAX+1];
164     const char *reply_fname;
165     int setno;
166     int next_position;
167     int userid;
168 #if USE_FML
169     Fml   fml;
170 #endif
171     struct gw_user_set *sets;
172 };
173
174 extern struct gw_kernel_info info;
175
176 extern FILE *reply_fd;
177
178 int  urp_start   (int continuation, struct str_queue *queue);
179 int  urp_command (struct str_queue *queue);
180 void urp_end     (void);
181
182 void read_kernel_res (void);
183
184 struct gw_user_set *user_set_add (const char *name, int hits,
185                                   const char *database,
186                                   struct ccl_rpn_node *rpn,
187                                   int present_flag,
188                                   const char *search_str);
189 struct gw_user_set *user_set_search (const char *name);
190 void user_set_init (void);
191
192 int lgets (char *buf, int max, int fd);
193
194 const struct zass_searchent *zass_p_search (ZASS zass, 
195                                       struct ccl_rpn_node *rpn,
196                                       const char *result_set,
197                                       const char *database,
198                                       struct gw_user_set *sets);
199 const struct zass_presentent *zass_p_present (ZASS zass,
200                                       const char *result_set,
201                                       int offset, int number);
202
203 int load_p_state (int userid);
204 int save_p_state (int userid);
205 void del_p_state (int userid);
206 int reopen_target (void);
207
208 #define KERNEL_LOG "kernel"