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