# Europagate, 1995
#
# $Log: Makefile,v $
-# Revision 1.24 1995/05/03 12:18:46 adam
+# Revision 1.25 1995/05/19 13:25:58 adam
+# Bug fixes. Better command line options.
+#
+# Revision 1.24 1995/05/03 12:18:46 adam
# This code ran on dtbsun. Minor changes.
#
# Revision 1.23 1995/05/03 07:37:29 adam
INCLUDE=-I../include
#CFLAGS=-g -Wall
CPP=$(CC) -E
-DEFS=$(INCLUDE) -DUSE_FML=1 -DUSE_MONITOR=1
+DEFS=$(INCLUDE) -DUSE_FML=1
PROG1=kernel
O1=main.o urp.o persist.o
# Email gateway - general kernel resources
-# $Id: default.res,v 1.22 1995/05/17 10:51:32 adam Exp $
+# $Id: default.res,v 1.23 1995/05/19 13:25:58 adam Exp $
#
# Important directories, programs, etc.
-gw.reply.mta: /usr/lib/sendmail
+gw.reply.mta: /usr/lib/sendmailx
gw.reply.tmp.prefix: gwr
gw.reply.tmp.dir: /tmp
#gw.path: /home/adam/egate/kernel
gw.marc.log: marc.log
-gw.timeout: 5
+gw.timeout: 30
gw.resultset: 1
gw.persist: 1
gw.max.process: 3
* Europagate, 1995
*
* $Log: eti.c,v $
- * Revision 1.13 1995/05/16 09:40:41 adam
+ * Revision 1.14 1995/05/19 13:25:59 adam
+ * Bug fixes. Better command line options.
+ *
+ * Revision 1.13 1995/05/16 09:40:41 adam
* LICENSE. Setting of CCL token names (and/or/not/set) in read_kernel_res.
*
* Revision 1.12 1995/05/03 07:37:35 adam
#include <gw-log.h>
#include <gw-db.h>
+#include <gw-res.h>
#include <gip.h>
#include <strqueue.h>
return 1;
}
-#if !USE_MONITOR
static void start_kernel (int argc, char **argv, int id)
{
pid_t pid;
exit (1);
}
}
-#endif
static void deliver (struct str_queue *sq, GIP gip, const char *msg)
{
char fifo_client_name[1024];
char fifo_server_name[1024];
struct str_queue *queue;
+ int monitor_flag = 1;
+ int argno = 0;
gw_log_init (*argv);
- gw_log_level (GW_LOG_ALL);
- gw_log_file (GW_LOG_ALL, "eti.log");
-
+ while (++argno < argc)
+ {
+ if (argv[argno][0] == '-')
+ {
+ if (argv[argno][1] == '-')
+ {
+ monitor_flag = 0;
+ break;
+ }
+ switch (argv[argno][1])
+ {
+ case 'h':
+ case 'H':
+ fprintf (stderr, "eti [options] -- [kernelOptions]\n");
+ fprintf (stderr, "Options:\n");
+ fprintf (stderr, " -l log Set Log file\n");
+ fprintf (stderr, " -d Enable debugging log\n");
+ fprintf (stderr, " -D Enable more debugging log\n");
+ fprintf (stderr, " -- Precedes kernel options "
+ "(kernel is invoked instead of monitor)\n");
+ exit (1);
+ case 'l':
+ if (argv[argno][2])
+ gw_log_file (GW_LOG_ALL, argv[argno]+2);
+ else if (++argno < argc)
+ gw_log_file (GW_LOG_ALL, argv[argno]);
+ else
+ {
+ fprintf (stderr, "%s: missing log filename\n", *argv);
+ exit (1);
+ }
+ break;
+ case 'd':
+ gw_log_level (GW_LOG_ALL & ~RES_DEBUG);
+ break;
+ case 'D':
+ gw_log_level (GW_LOG_ALL);
+ break;
+ default:
+ fprintf (stderr, "%s: unknown option `%s'; use -H for help\n",
+ *argv, argv[argno]);
+ exit (1);
+ }
+ }
+ }
if (!(queue = str_queue_mk ()))
{
gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, module, "str_queue_mk");
gw_log (GW_LOG_FATAL, module, "gw_db_lookup fail");
exit (1);
}
-#if USE_MONITOR
- 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);
-#endif
+ if (monitor_flag)
+ {
+ 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);
+ }
gip = gipc_initialize (fifo_client_name);
signal (SIGPIPE, pipe_handle);
gw_log (GW_LOG_DEBUG, module, "Pass %d", pass);
if (pass == 1)
+ {
+ gipc_close (gip);
r = gipc_open (gip, fifo_server_name, 0);
+ }
else if (pass == 2)
{
-#if USE_MONITOR
- gw_log (GW_LOG_FATAL, module, "Cannot contact monitor");
- exit (1);
-#else
-#if 0
- gipc_close (gip);
- gipc_destroy (gip);
- unlink (fifo_server_name);
- unlink (fifo_client_name);
- gip = gipc_initialize (fifo_client_name);
-#endif
-
+ if (monitor_flag)
+ {
+ gw_log (GW_LOG_FATAL, module, "Cannot contact monitor");
+ exit (1);
+ }
mknod (fifo_server_name, S_IFIFO|0666, 0);
- start_kernel (argc, argv, id);
+ start_kernel (argc-argno, argv+argno, id);
r = gipc_open (gip, fifo_server_name, 1);
}
else if (pass == 3)
{
gw_log (GW_LOG_FATAL, module, "Cannot start kernel");
exit (1);
-#endif
}
if (r < 0)
if (r == -2)
}
/* deliver message ... */
gw_log (GW_LOG_DEBUG, module, "Delivering mail");
-#if USE_MONITOR
- sprintf (msg, "eti %d\n", id);
-#else
- strcpy (msg, "mail\n");
-#endif
+ if (monitor_flag)
+ sprintf (msg, "eti %d\n", id);
+ else
+ strcpy (msg, "mail\n");
deliver (queue, gip, msg);
gw_log (GW_LOG_DEBUG, module, "Closing");
gipc_close (gip);
* Europagate, 1995
*
* $Log: main.c,v $
- * Revision 1.26 1995/05/18 12:03:08 adam
+ * Revision 1.27 1995/05/19 13:25:59 adam
+ * Bug fixes. Better command line options.
+ *
+ * Revision 1.26 1995/05/18 12:03:08 adam
* Bug fixes and minor improvements.
*
* Revision 1.25 1995/05/16 09:40:42 adam
int continuation = 0;
int extra_fd;
int persist_flag;
+ int stop_flag = 0;
persist_flag = gw_res_bool (info.kernel_res, "gw.persist", 0);
timeout = gw_res_int (info.kernel_res, "gw.timeout", 600);
sprintf (fifo_server_name, "fifo.s.%d", info.userid);
gip = gips_initialize (fifo_server_name);
- gips_open (gip, fifo_client_name);
+ gips_open (gip, fifo_client_name, 1);
gip_fd = gip_infileno (gip);
extra_fd = open (fifo_server_name, O_WRONLY);
{
FD_ZERO (&set_r);
FD_SET (gip_fd, &set_r);
- tv.tv_sec = timeout;
+ if (stop_flag)
+ tv.tv_sec = 1;
+ else
+ 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 after %d seconds",
- timeout);
+ if (stop_flag)
+ gw_log (GW_LOG_STAT, KERNEL_LOG, "Stopping");
+ else
+ gw_log (GW_LOG_STAT, KERNEL_LOG, "Timeout after %d seconds",
+ timeout);
if (info.zass && persist_flag)
save_p_state (info.userid);
break;
else if (!strcmp (command, "stop"))
{
gw_log (GW_LOG_DEBUG, KERNEL_LOG, "stop");
- break;
+ while (lgets (line_buf, sizeof(line_buf)-1, gip_fd))
+ ;
+ break;
}
else
- {
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);
- unlink (fifo_server_name);
}
int main (int argc, char **argv)
switch (argv[0][1])
{
case 'H':
- fprintf (stderr, "kernel [option..] [resource]\n");
- fprintf (stderr, "If no resource file is given");
+ fprintf (stderr, "kernel [options] [resourceFile]\n");
+ fprintf (stderr, "If no resource file is specified");
fprintf (stderr, " default.res is used\n");
fprintf (stderr, "Options:\n");
fprintf (stderr, " -d Enable debugging log\n");
gw_log_session (info.userid);
break;
default:
- gw_log (GW_LOG_FATAL, KERNEL_LOG, "unknown option %s", *argv);
+ gw_log (GW_LOG_FATAL, KERNEL_LOG, "unknown option %s;"
+ " use -H for help", *argv);
exit (1);
}
}
* Europagate, 1995
*
* $Log: monitor.c,v $
- * Revision 1.10 1995/05/18 12:03:09 adam
+ * Revision 1.11 1995/05/19 13:26:00 adam
+ * Bug fixes. Better command line options.
+ *
+ * Revision 1.10 1995/05/18 12:03:09 adam
* Bug fixes and minor improvements.
*
* Revision 1.9 1995/05/17 10:51:32 adam
fd_set set_r;
char command[128], *cp;
+ mknod (MONITOR_FIFO_C, S_IFIFO|0666, 0);
+ open (MONITOR_FIFO_C, O_RDONLY|O_NONBLOCK);
gip_m = gips_initialize (MONITOR_FIFO_S);
- r = gips_open (gip_m, MONITOR_FIFO_C);
+ r = gips_open (gip_m, MONITOR_FIFO_C, 0);
gip_m_fd = gip_infileno (gip_m);
- open (MONITOR_FIFO_S, O_WRONLY);
while (1)
{
}
str_queue_enq (ki->queue, "stop\n");
str_queue_enq (ki->queue, "\001");
- gw_log (GW_LOG_DEBUG, module, "Stopping %d", ki->id);
- deliver (argc, argv, ki->id, ki->queue, &ki->gip,
- &ki->pid, 1);
+ r = deliver (argc, argv, ki->id, ki->queue, &ki->gip,
+ &ki->pid, 1);
+ if (r != 1)
+ gw_log (GW_LOG_DEBUG, module,
+ "Stop not sent: %d", r);
str_queue_rm (&ki->queue);
break;
}
{
if (argv[argno][0] == '-')
{
+ if (argv[argno][1] == '-')
+ break;
switch (argv[argno][1])
{
+ case 'h':
case 'H':
- fprintf (stderr, "monitor [option..] [resource]\n");
- fprintf (stderr, "If no resource file is given");
+ fprintf (stderr, "monitor [options] [resourceFile]"
+ " -- [kernelOptions]\n");
+ fprintf (stderr, "If no resource file is specified");
fprintf (stderr, " default.res is used\n");
- fprintf (stderr, "Options are transferred to kernel\n");
+ fprintf (stderr, "Options:\n");
+ fprintf (stderr, " -l log Set Log file\n");
+ fprintf (stderr, " -d Enable debugging log\n");
+ fprintf (stderr, " -D Enable more debugging log\n");
+ fprintf (stderr, " -- Precedes kernel options\n");
+ fprintf (stderr, "Kernel options are transferred to kernel\n");
exit (1);
+ case 'l':
+ if (argv[argno][2])
+ gw_log_file (GW_LOG_ALL, argv[argno]+2);
+ else if (++argno < argc)
+ gw_log_file (GW_LOG_ALL, argv[argno]);
+ else
+ {
+ fprintf (stderr, "%s: missing log filename\n", *argv);
+ exit (1);
+ }
+ break;
case 'd':
gw_log_level (GW_LOG_ALL & ~RES_DEBUG);
break;
case 'D':
gw_log_level (GW_LOG_ALL);
break;
+ default:
+ fprintf (stderr, "%s: unknown option `%s'; use -H for help\n",
+ *argv, argv[argno]);
+ exit (1);
}
}
else
signal (SIGHUP, catch_hup);
signal (SIGTERM, catch_term);
signal (SIGINT, catch_int);
-#if 1
- gw_log_level (GW_LOG_ALL & ~RES_DEBUG);
- gw_log_file (GW_LOG_ALL, "monitor.log");
-#endif
- monitor_events (argc, argv);
+ monitor_events (argc-argno, argv+argno);
exit (0);
}
* Europagate, 1995
*
* $Log: persist.c,v $
- * Revision 1.8 1995/05/16 09:40:43 adam
+ * Revision 1.9 1995/05/19 13:26:00 adam
+ * Bug fixes. Better command line options.
+ *
+ * Revision 1.8 1995/05/16 09:40:43 adam
* LICENSE. Setting of CCL token names (and/or/not/set) in read_kernel_res.
*
* Revision 1.7 1995/05/03 16:34:19 adam
return -1;
gw_log (GW_LOG_DEBUG, KERNEL_LOG,
"Reading persistence file %s (2)", fname);
-#if 0
- reopen_target ();
-#endif
while (fgetsx (fline, 1024, inf))
{
gw_log (GW_LOG_DEBUG, KERNEL_LOG,
gw_log (GW_LOG_DEBUG, KERNEL_LOG, "Search string %s", fline);
set = user_set_add (resultname, hits, database, NULL, 0, fline);
set->rpn = load_rpn (fline, inf);
+#if 0
ccl_pr_tree (set->rpn, stderr);
+#endif
fgetsx (fline, 1024, inf);
}
fclose (inf);
* Europagate, 1995
*
* $Log: urp.c,v $
- * Revision 1.37 1995/05/18 12:03:09 adam
+ * Revision 1.38 1995/05/19 13:26:00 adam
+ * Bug fixes. Better command line options.
+ *
+ * Revision 1.37 1995/05/18 12:03:09 adam
* Bug fixes and minor improvements.
*
* Revision 1.36 1995/05/17 10:51:33 adam
mta = gw_res_get (info.kernel_res, "gw.reply.mta",
"/usr/lib/sendmail");
sprintf (cmd, "%s %s < %s", mta, info.from_str, info.reply_fname);
-#if 0
mta_code = system (cmd);
if (mta_code)
gw_log (GW_LOG_FATAL, KERNEL_LOG,
"Reply '%s' got exit code %d", cmd, mta_code);
else
unlink (info.reply_fname);
-#endif
gw_log (GW_LOG_ACCT, KERNEL_LOG, "User end %s", info.from_str);
}
}