are used when possible.
# Europagate, 1995
#
# $Log: Makefile,v $
-# Revision 1.22 1995/05/01 12:43:26 adam
+# Revision 1.23 1995/05/03 07:37:29 adam
+# CCL commands stop/continue implemented. New functions gw_res_{int,bool}
+# are used when possible.
+#
+# Revision 1.22 1995/05/01 12:43:26 adam
# First work on resource monitor program.
#
# Revision 1.21 1995/04/20 16:10:45 adam
clean:
rm -f *.log *.[oa] $(PROG1) $(PROG2)
- rm -f core mon.out gmon.out errlist *~ fifo.*
+ rm -f core mon.out gmon.out errlist *~ fifo.*
depend: depend2
# Email gateway - general kernel resources
-# $Id: default.res,v 1.18 1995/05/02 15:25:59 adam Exp $
+# $Id: default.res,v 1.19 1995/05/03 07:37:32 adam Exp $
#
# Important directories, programs, etc.
gw.reply.mta: /usr/lib/sendmail
#gw.path: /home/adam/egate/kernel
gw.marc.log: marc.log
gw.timeout: 20
-gw.resultset: 0
-gw.max.process: 1
+gw.resultset: 1
+gw.persist: 1
+gw.max.process: 2
# Retrieval settings
gw.ignore.which: 1
* Europagate, 1995
*
* $Log: eti.c,v $
- * Revision 1.11 1995/05/01 16:26:56 adam
+ * Revision 1.12 1995/05/03 07:37:35 adam
+ * CCL commands stop/continue implemented. New functions gw_res_{int,bool}
+ * are used when possible.
+ *
+ * Revision 1.11 1995/05/01 16:26:56 adam
* More work on resource monitor.
*
* Revision 1.10 1995/05/01 12:43:29 adam
exit (1);
}
#if USE_MONITOR
- sprintf (fifo_server_name, "fifo.s");
- sprintf (fifo_client_name, "fifo.c");
+ sprintf (fifo_server_name, "fifo.s.m");
+ sprintf (fifo_client_name, "fifo.c.m");
#else
sprintf (fifo_server_name, "fifo.s.%d", id);
sprintf (fifo_client_name, "fifo.c.%d", id);
* Europagate, 1995
*
* $Log: kernel.h,v $
- * Revision 1.15 1995/04/19 13:19:08 adam
+ * Revision 1.16 1995/05/03 07:37:37 adam
+ * CCL commands stop/continue implemented. New functions gw_res_{int,bool}
+ * are used when possible.
+ *
+ * Revision 1.15 1995/04/19 13:19:08 adam
* New command: account - for authentication.
*
* Revision 1.14 1995/04/19 10:46:18 adam
char from_str[LINE_MAX+1];
const char *reply_fname;
int setno;
+ int next_position;
#if USE_FML
Fml fml;
#endif
int load_p_state (int userid);
int save_p_state (int userid);
+void del_p_state (int userid);
int reopen_target (void);
#define KERNEL_LOG "kernel"
* Europagate, 1995
*
* $Log: main.c,v $
- * Revision 1.21 1995/05/01 16:26:56 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
int timeout;
int continuation = 0;
int extra_fd;
+ int persist_flag;
- timeout = atoi(gw_res_get (info.kernel_res, "gw.timeout", "600"));
+ 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);
{
gw_log (GW_LOG_STAT, KERNEL_LOG, "Timeout after %d seconds",
timeout);
- if (info.zass)
+ if (info.zass && persist_flag)
save_p_state (userid);
break;
}
while (lgets (line_buf, sizeof(line_buf)-1, gip_fd))
str_queue_enq (queue, line_buf);
urp_start (continuation, queue);
- if (!continuation)
+ if (persist_flag && !continuation)
load_p_state (userid);
- urp_command (queue);
+ r = urp_command (queue);
+ if (persist_flag && r == 1)
+ del_p_state (userid);
urp_end ();
while (str_queue_deq (queue, 0, 0))
;
else
{
strcpy (info.hostname, info.target);
- info.port = atoi (gw_res_get
- (info.kernel_res, "gw.portno", "210"));
+ 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)
if (info.override_hostname)
strncpy (info.hostname, info.override_hostname,
sizeof(info.hostname)-1);
- v = gw_res_get (info.kernel_res, "gw.result.set", NULL);
- info.setno = v ? -1 : 0;
+ if (gw_res_bool (info.kernel_res, "gw.result.set", 1))
+ info.setno = 0;
+ else
+ info.setno = -1;
#if USE_FML
if (!info.fml)
{
* Europagate, 1995
*
* $Log: monitor.c,v $
- * Revision 1.4 1995/05/02 15:26:00 adam
+ * Revision 1.5 1995/05/03 07:37:42 adam
+ * CCL commands stop/continue implemented. New functions gw_res_{int,bool}
+ * are used when possible.
+ *
+ * Revision 1.4 1995/05/02 15:26:00 adam
* Monitor observes death of child (email kernel). The number
* of simultanous processes is controlled now. Email requests are
* queued if necessary. This scheme should only be forced if no kernels
#define LINE_MAX 1024
-#define MONITOR_FIFO_S "fifo.s"
-#define MONITOR_FIFO_C "fifo.c"
+#define MONITOR_FIFO_S "fifo.s.m"
+#define MONITOR_FIFO_C "fifo.c.m"
static char *module = "monitor";
static jmp_buf retry_jmp;
default_res);
exit (1);
}
- max_process = atoi (gw_res_get (monitor_res, "gw.max.process", "10"));
+ max_process = gw_res_int (monitor_res, "gw.max.process", 10);
}
struct ke_info {
* Europagate, 1995
*
* $Log: persist.c,v $
- * Revision 1.5 1995/05/02 15:26:00 adam
+ * Revision 1.6 1995/05/03 07:37:44 adam
+ * CCL commands stop/continue implemented. New functions gw_res_{int,bool}
+ * are used when possible.
+ *
+ * Revision 1.5 1995/05/02 15:26:00 adam
* Monitor observes death of child (email kernel). The number
* of simultanous processes is controlled now. Email requests are
* queued if necessary. This scheme should only be forced if no kernels
return -1;
if (sscanf (fline, "%d", &info.setno) != 1)
return -1;
+ if (!fgetsx (fline, 1024, inf))
+ return -1;
+ if (sscanf (fline, "%d", &info.next_position) != 1)
+ return -1;
gw_log (GW_LOG_DEBUG, KERNEL_LOG,
"Reading persistence file %s (2)", fname);
#if 0
return -1;
}
gw_log (GW_LOG_DEBUG, KERNEL_LOG, "Writing persistence file %s", fname);
- fprintf (of, "%s\n%s\n%s\n%d\n", info.target, info.account,
- info.database, info.setno);
+ fprintf (of, "%s\n%s\n%s\n%d\n%d\n", info.target, info.account,
+ info.database, info.setno, info.next_position);
save_sets (of, info.sets);
fclose (of);
return 0;
}
+
+void del_p_state (int userid)
+{
+ char fname[128];
+
+ sprintf (fname, "persist.%d", userid);
+ unlink (fname);
+}
+
* Europagate, 1995
*
* $Log: urp.c,v $
- * Revision 1.31 1995/05/01 12:43:38 adam
+ * Revision 1.32 1995/05/03 07:37:46 adam
+ * CCL commands stop/continue implemented. New functions gw_res_{int,bool}
+ * are used when possible.
+ *
+ * Revision 1.31 1995/05/01 12:43:38 adam
* First work on resource monitor program.
*
* Revision 1.30 1995/04/20 16:10:47 adam
*
*/
+/*
+ Todo:
+ stop/continue commands
+ info/status (other name?)
+ per-user definitions
+ better persistence diagnostics
+ show - position continuation
+ resource gw.path - use chdir call instead
+
+ Optional:
+ automatic information about target-aliases: name, query-support, etc.
+ */
+
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
char *resource_suffix;
} command_tab [] =
{
-{ "find", "find"},
-{ "show", "show"},
-{ "base", "base" },
-{ "help", "help" },
-{ "info", "info" },
+{ "find", "find"},
+{ "show", "show"},
+{ "base", "base" },
+{ "help", "help" },
+{ "info", "info" },
{ "continue", "continue" },
-{ "status", "status" },
-{ "cancel", "cancel" },
-{ "target", "target" },
-{ "stop", "stop" },
-{ "account", "account" },
+{ "status", "status" },
+{ "stop", "stop" },
+{ "target", "target" },
+{ "cancel", "cancel" },
+{ "account", "account" },
{ NULL, NULL }
};
static char *sep = "-------------------------------\\n";
help_general ();
-#if 1
put_esc_str (sep);
put_esc_str (gw_res_get (info.kernel_res, "gw.help.target",
"target <name> - selects a given target\n"));
put_esc_str (gw_res_get (info.kernel_res, "gw.help.show",
"show <spec> - retrieves and displays "
"records\n"));
-#endif
return 0;
}
strcpy (setname, "Default");
else
sprintf (setname, "%d", info.setno);
+ info.next_position = 1;
+ if (info.setno >= 0)
+ info.setno++;
rpn = ccl_find (info.bibset, list, &error, &pos);
if (!rpn)
{
gw_res_get (info.kernel_res, "gw.msg.hits", "hit(s)"));
us = user_set_add (setname, p->num, info.database, rpn, 1, search_str);
fprintf (reply_fd, "Result-set %s created\n", setname);
- if (info.setno >= 0)
- info.setno++;
return 0;
}
static int exec_status (struct ccl_token *list)
{
- fprintf (reply_fd, " Name Hits Database Find\n");
+ fprintf (reply_fd, " Name Hits Database Find\n");
exec_status_r (info.sets);
return 0;
}
int max_number;
char format_str[16];
- max_number = atoi (gw_res_get (info.kernel_res, "gw.max.show",
- "200"));
+ max_number = gw_res_int (info.kernel_res, "gw.max.show", 200);
if (number > max_number)
number = max_number;
gw_log (GW_LOG_DEBUG, KERNEL_LOG, "present in set %s", set);
us = user_set_search (NULL);
if (us && us->hits != -1) /* proper result-set? */
{
- default_show = atoi (gw_res_get (info.kernel_res,
- "gw.default.show", "20"));
- if (us->hits > default_show)
- present (us->name, 1, default_show, format_token);
- else if (us->hits > 0)
- present (us->name, 1, us->hits, format_token);
+ default_show = gw_res_int (info.kernel_res, "gw.default.show", 20);
+ if (us->hits >= info.next_position + default_show)
+ {
+ present (us->name, info.next_position, default_show,
+ format_token);
+ info.next_position += default_show;
+ }
+ else if (us->hits >= info.next_position)
+ {
+ present (us->name, info.next_position,
+ us->hits - info.next_position + 1,
+ format_token);
+ info.next_position = us->hits + 1;
+ }
}
else /* display error message */
{
return 0;
}
-static int exec_command (const char *str)
+/*
+ * exec_command: parse and execute ccl command in str.
+ * str: ccl command string
+ * stop_flag pointer to integer. On completion the integer
+ * is 1 (stop) or 2 (continue); 0 (other command)
+ * return: 0 success; non-zero otherwise
+ */
+static int exec_command (const char *str, int *stop_flag)
{
struct ccl_token *cmd = ccl_tokenize (str);
int no;
+ *stop_flag = 0;
if (cmd->kind != CCL_TOK_EOL &&
(no = command_search (command_tab, cmd, "ccl.command.")))
{
return exec_base (cmd->next);
case 4:
return exec_help (cmd->next);
+ case 6: /* continue */
+ *stop_flag = 2;
+ return 0;
case 7:
return exec_status (cmd->next);
+ case 8: /* stop */
+ info.zass = NULL;
+ *info.target = 0;
+ *stop_flag = 1;
+ read_kernel_res();
+ return 0;
case 9:
return exec_target (cmd->next);
case 11:
{
info.reply_fname = tempnam (gw_res_get (info.kernel_res,
"gw.reply.tmp.dir", NULL),
- gw_res_get (info.kernel_res,
+ gw_res_get (info.kernel_res,
"gw.reply.tmp.prefix", "gwr"));
reply_fd = fopen (info.reply_fname, "w");
int urp_command (struct str_queue *queue)
{
char *cp;
+ int stop_flag;
while (str_queue_deq (queue, line_buf, LINE_MAX))
{
*cp = '\0';
gw_log (GW_LOG_ACCT, KERNEL_LOG, "cmd: %s", line_buf);
if (isalpha (line_buf[0]))
- exec_command (line_buf);
+ {
+ exec_command (line_buf, &stop_flag);
+ if (stop_flag)
+ {
+ info.command_no++; /* prevent help! */
+ while (str_queue_deq (queue, line_buf, LINE_MAX))
+ ;
+ return stop_flag;
+ }
+ }
info.command_no++;
}
return 0;