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