-/* Gateway kernel
+/* Gateway kernel - Main
* Europagate, 1995
*
* $Log: main.c,v $
- * Revision 1.14 1995/03/28 11:42:34 adam
+ * Revision 1.22 1995/05/03 07:37:39 adam
+ * CCL commands stop/continue implemented. New functions gw_res_{int,bool}
+ * are used when possible.
+ *
+ * Revision 1.21 1995/05/01 16:26:56 adam
+ * More work on resource monitor.
+ *
+ * Revision 1.20 1995/05/01 12:43:32 adam
+ * First work on resource monitor program.
+ *
+ * Revision 1.19 1995/04/19 16:01:58 adam
+ * Some hacks to get the FIFO communication work!! Isn't reliable.
+ * Resource gw.account added - default account info.
+ *
+ * Revision 1.18 1995/04/19 13:19:09 adam
+ * New command: account - for authentication.
+ *
+ * Revision 1.17 1995/04/19 10:46:18 adam
+ * Persistency works much better now. New command: status - history-like
+ *
+ * Revision 1.16 1995/04/19 07:31:07 adam
+ * First work on Z39.50 persistence.
+ *
+ * Revision 1.15 1995/04/17 09:34:30 adam
+ * Timeout (idletime) adjustable. Minor changes in kernel.
+ *
+ * Revision 1.14 1995/03/28 11:42:34 adam
* First use of string-queue utility.
*
* Revision 1.13 1995/03/28 08:01:25 adam
fd_set set_r;
int r, gip_fd;
struct timeval tv;
+ int timeout;
+ int continuation = 0;
+ int extra_fd;
+ int persist_flag;
- gw_log (GW_LOG_DEBUG, KERNEL_LOG, "kernel event loop");
+ persist_flag = gw_res_bool (info.kernel_res, "gw.persist", 0);
+ timeout = gw_res_int (info.kernel_res, "gw.timeout", 600);
+ gw_log (GW_LOG_DEBUG, KERNEL_LOG, "event loop");
sprintf (fifo_client_name, "fifo.c.%d", userid);
sprintf (fifo_server_name, "fifo.s.%d", userid);
gip = gips_initialize (fifo_server_name);
gips_open (gip, fifo_client_name);
gip_fd = gip_infileno (gip);
+ extra_fd = open (fifo_server_name, O_WRONLY);
while (1)
{
FD_ZERO (&set_r);
FD_SET (gip_fd, &set_r);
- tv.tv_sec = 60;
+ tv.tv_sec = timeout;
tv.tv_usec = 0;
gw_log (GW_LOG_DEBUG, KERNEL_LOG, "IPC select");
}
if (r == 0)
{
- gw_log (GW_LOG_STAT, KERNEL_LOG, "Timeout");
+ gw_log (GW_LOG_STAT, KERNEL_LOG, "Timeout after %d seconds",
+ timeout);
+ if (info.zass && persist_flag)
+ save_p_state (userid);
break;
}
if (FD_ISSET (gip_fd, &set_r))
gw_log (GW_LOG_STAT, KERNEL_LOG, "IPC: %s", command);
if (!strcmp (command, "mail"))
{
- gw_log (GW_LOG_DEBUG, KERNEL_LOG, "Incoming mail...\n");
+ gw_log (GW_LOG_DEBUG, KERNEL_LOG, "Incoming mail");
while (lgets (line_buf, sizeof(line_buf)-1, gip_fd))
str_queue_enq (queue, line_buf);
- urp (queue);
+ urp_start (continuation, queue);
+ if (persist_flag && !continuation)
+ load_p_state (userid);
+ r = urp_command (queue);
+ if (persist_flag && r == 1)
+ del_p_state (userid);
+ urp_end ();
while (str_queue_deq (queue, 0, 0))
;
}
{
gw_log (GW_LOG_WARN, KERNEL_LOG, "Unknown IPC: %s", command);
}
+ continuation = 1;
}
}
+ close (extra_fd);
gips_close (gip);
gips_destroy (gip);
unlink (fifo_client_name);
info.default_res = "default.res";
info.override_res = NULL;
*info.target = 0;
+ *info.account = 0;
info.lang = NULL;
info.bibset = NULL;
info.zass = NULL;
info.override_hostname = NULL;
info.databases = NULL;
info.database = NULL;
+ info.setno = -1;
#if USE_FML
info.fml = NULL;
#endif
fprintf (stderr, "Options:\n");
fprintf (stderr, " -d Enable debugging log\n");
fprintf (stderr, " -t target Open target immediately\n");
- fprintf (stderr, " -l lang Set language\n");
+ fprintf (stderr, " -g lang Set language\n");
fprintf (stderr, " -o resource Override with resource\n");
fprintf (stderr, " -h host Override host\n");
fprintf (stderr, " -p port Override port\n");
- fprintf (stderr, " -g log Set Log file\n");
+ fprintf (stderr, " -l log Set Log file\n");
fprintf (stderr, " -i id Set IPC userid\n");
exit (1);
case 'd':
+ gw_log_level (GW_LOG_ALL & ~RES_DEBUG);
+ break;
+ case 'D':
gw_log_level (GW_LOG_ALL);
break;
case 't':
exit (1);
}
break;
- case 'l':
+ case 'g':
if (argv[0][2])
info.lang = argv[0]+2;
else if (argc > 0)
exit (1);
}
break;
- case 'g':
+ case 'l':
if (argv[0][2])
gw_log_file (GW_LOG_ALL, argv[0]+2);
else if (argc > 0)
else
info.default_res = *argv;
}
- read_kernel_res ();
if (!(queue = str_queue_mk ()))
{
gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, KERNEL_LOG, "str_queue_mk");
exit (1);
}
if (userid != -1)
+ {
+ read_kernel_res ();
kernel_events (queue, userid);
+ }
else
{
char line_buf[512];
+ read_kernel_res ();
while (lgets (line_buf, sizeof(line_buf)-1, 0))
str_queue_enq (queue, line_buf);
- urp (queue);
+ urp_start (0, queue);
+ urp_command (queue);
+ urp_end ();
}
return 0;
}
-struct gw_user_set *user_set_add (const char *name, int hits)
+struct gw_user_set *user_set_add (const char *name, int hits,
+ const char *database,
+ struct ccl_rpn_node *rpn,
+ int present_flag,
+ const char *search_str)
{
struct gw_user_set *s;
s->name = gw_strdup (name);
s->hits = hits;
+ s->database = gw_strdup (database);
+ s->rpn = rpn;
+ s->present_flag = present_flag;
+ s->search_str = gw_strdup (search_str);
s->prev = info.sets;
info.sets = s;
return s;
for (s = info.sets; s; s = s1)
{
free (s->name);
+ free (s->database);
+ ccl_rpn_delete (s->rpn);
s1 = s->prev;
free (s);
}
if (*info.target && ! gw_res_get (info.kernel_res, resource_name, NULL))
{
/* target is there, and there is no sub-resource for it... */
- char *split;
+ const char *split;
if ((split = strchr (info.target, ':')))
- *split++ = '\0';
- strncpy (info.hostname, info.target, sizeof(info.hostname)-1);
- if (split)
- info.port = atoi (split);
+ {
+ memcpy (info.hostname, info.target, split-info.target);
+ info.hostname[split-info.target] = '\0';
+ info.port = atoi (split+1);
+ }
else
- info.port = atoi (gw_res_get
- (info.kernel_res, "gw.portno", "210"));
+ {
+ strcpy (info.hostname, info.target);
+ info.port = gw_res_int (info.kernel_res, "gw.portno", 210);
+ }
}
else
{
strncpy (info.hostname, gw_res_get (info.kernel_res,
"gw.hostname", "localhost"),
sizeof(info.hostname)-1);
- info.port = atoi (gw_res_get (info.kernel_res,
- "gw.portno", "210"));
+ info.port = gw_res_int (info.kernel_res, "gw.portno", 210);
+ strcpy (info.account, gw_res_get (info.kernel_res, "gw.account", ""));
}
if (info.databases)
free (info.databases);
if (info.override_hostname)
strncpy (info.hostname, info.override_hostname,
sizeof(info.hostname)-1);
+ if (gw_res_bool (info.kernel_res, "gw.result.set", 1))
+ info.setno = 0;
+ else
+ info.setno = -1;
#if USE_FML
if (!info.fml)
{