# Europagate, 1995
#
# $Log: Makefile,v $
-# Revision 1.13 1995/03/27 12:51:04 adam
+# Revision 1.14 1995/04/17 09:34:23 adam
+# Timeout (idletime) adjustable. Minor changes in kernel.
+#
+# Revision 1.13 1995/03/27 12:51:04 adam
# New log level in use: GW_LOG_ERRNO.
#
# Revision 1.12 1995/03/27 08:23:57 adam
../lib/util.a $(ZLIB) $(REGEXOBJ)
PROG1=kernel
-O1=main.o urp.o ttyemit.o
+O1=main.o urp.o
PROG2=eti
O2=eti.o
depend: depend2
depend1:
- mv Makefile Makefile.tmp
- sed '/^#Depend/q' <Makefile.tmp >Makefile
- $(CPP) $(INCLUDE) -M *.c >>Makefile
- -rm Makefile.tmp
+ sed '/^#Depend/q' <Makefile >Makefile.tmp
+ $(CPP) $(DEFS) -M *.c >>Makefile.tmp
+ mv -f Makefile.tmp Makefile
depend2:
- $(CPP) $(INCLUDE) -M *.c >.depend
+ $(CPP) $(DEFS) -M *.c >.depend
+#GNU make style depend
ifeq (.depend,$(wildcard .depend))
include .depend
endif
# Email gateway - general kernel resources
-# $Id: default.res,v 1.14 1995/03/27 08:23:59 adam Exp $
+# $Id: default.res,v 1.15 1995/04/17 09:34:25 adam Exp $
#
# Important directories, programs, etc.
gw.reply.mta: /usr/lib/sendmail
gw.reply.tmp.dir: /tmp
#gw.path: /home/adam/egate/kernel
gw.marc.log: marc.log
+gw.timeout: 60
# Retrieval settings
gw.ignore.which: 1
# Messages
gw.msg.subject: Your Z39.50 Query...
gw.msg.greeting: Europagate Email-Z39.50 gateway
+gw.msg.cont: Session continued...
gw.msg.from: Email-gateway
gw.err.nullbody: Empty body
ccl.command.find: find f
-/* Gateway kernel
+/* Gateway Email Transport Interface
* Europagate, 1995
*
* $Log: eti.c,v $
- * Revision 1.5 1995/03/31 09:43:13 adam
+ * Revision 1.6 1995/04/17 09:34:27 adam
+ * Timeout (idletime) adjustable. Minor changes in kernel.
+ *
+ * Revision 1.5 1995/03/31 09:43:13 adam
* Removed unused variable.
*
* Revision 1.4 1995/03/28 11:42:34 adam
else
{
gw_log (GW_LOG_FATAL, module, "gw_db_lookup fail");
+ exit (1);
}
sprintf (fifo_server_name, "fifo.s.%d", id);
sprintf (fifo_client_name, "fifo.c.%d", id);
* Europagate, 1995
*
* $Log: kernel.h,v $
- * Revision 1.11 1995/03/28 11:42:34 adam
+ * Revision 1.12 1995/04/17 09:34:29 adam
+ * Timeout (idletime) adjustable. Minor changes in kernel.
+ *
+ * Revision 1.11 1995/03/28 11:42:34 adam
* First use of string-queue utility.
*
* Revision 1.10 1995/03/27 08:24:01 adam
#endif
#include <strqueue.h>
-int urp (struct str_queue *queue);
+#define LINE_MAX 1024
struct gw_user_set {
char *name; /* name of result set */
char *databases;
char *database;
ZASS zass;
+ int command_no;
+ char from_str[LINE_MAX+1];
+ const char *reply_fname;
#if USE_FML
Fml fml;
#endif
extern FILE *reply_fd;
+int urp_start (int continuation, struct str_queue *queue);
+int urp_command (struct str_queue *queue);
+void urp_end (void);
+
void read_kernel_res (void);
struct gw_user_set *user_set_add (const char *name, int hits);
struct gw_user_set *user_set_search (const char *name);
void user_set_init (void);
-void tty_emit (int ch);
-void tty_init (FILE *out, int min, int max);
int lgets (char *buf, int max, int fd);
-/* Gateway kernel
+/* Gateway kernel - Main
* Europagate, 1995
*
* $Log: main.c,v $
- * Revision 1.14 1995/03/28 11:42:34 adam
+ * 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;
+ timeout = atoi(gw_res_get (info.kernel_res, "gw.timeout", "600"));
gw_log (GW_LOG_DEBUG, KERNEL_LOG, "kernel event loop");
sprintf (fifo_client_name, "fifo.c.%d", userid);
{
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);
break;
}
if (FD_ISSET (gip_fd, &set_r))
gw_log (GW_LOG_DEBUG, KERNEL_LOG, "Incoming mail...\n");
while (lgets (line_buf, sizeof(line_buf)-1, gip_fd))
str_queue_enq (queue, line_buf);
- urp (queue);
+ urp_start (continuation, queue);
+ urp_command (queue);
+ urp_end ();
while (str_queue_deq (queue, 0, 0))
;
}
{
gw_log (GW_LOG_WARN, KERNEL_LOG, "Unknown IPC: %s", command);
}
+ continuation = 1;
}
}
gips_close (gip);
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':
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)
char line_buf[512];
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;
}
-/* Gateway kernel
+/* Gateway kernel - User Request Processor
* Europagate, 1995
*
* $Log: urp.c,v $
- * Revision 1.24 1995/03/28 11:42:35 adam
+ * Revision 1.25 1995/04/17 09:34:33 adam
+ * Timeout (idletime) adjustable. Minor changes in kernel.
+ *
+ * Revision 1.24 1995/03/28 11:42:35 adam
* First use of string-queue utility.
*
* Revision 1.23 1995/03/28 08:01:28 adam
#include <unistd.h>
#include <fcntl.h>
+#include <ttyemit.h>
#include <strqueue.h>
#include "kernel.h"
-#define LINE_MAX 1024
static char line_buf[LINE_MAX+1];
static void put_esc_str (const char *s)
return 0;
}
-int urp (struct str_queue *queue)
+int urp_start (int continuation, struct str_queue *queue)
{
- char from_str[128];
char subject_str[128];
- int command_no = 0;
- char *reply_fname = NULL;
- char *cp;
- if (email_header (queue, from_str, subject_str))
+ info.command_no = 0;
+ info.reply_fname = NULL;
+
+ if (email_header (queue, info.from_str, subject_str))
{
gw_log (GW_LOG_WARN, KERNEL_LOG, "No message body");
return -1;
}
tty_init (stdout, 40, 70);
- if (*from_str)
+ if (*info.from_str)
{
- reply_fname = tempnam (gw_res_get (info.kernel_res,
+ info.reply_fname = tempnam (gw_res_get (info.kernel_res,
"gw.reply.tmp.dir", NULL),
gw_res_get (info.kernel_res,
"gw.reply.tmp.prefix", "gwr"));
- reply_fd = fopen (reply_fname, "w");
+ reply_fd = fopen (info.reply_fname, "w");
if (!reply_fd)
{
gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, KERNEL_LOG, "Cannot create %s",
- reply_fname);
+ info.reply_fname);
return -1;
}
tty_init (reply_fd, 0, 0);
"gw.msg.subject",
"Your Query"));
fprintf (reply_fd, "\n");
- gw_log (GW_LOG_ACCT, KERNEL_LOG, "User start %s", from_str);
+ gw_log (GW_LOG_ACCT, KERNEL_LOG, "User start %s", info.from_str);
}
else
gw_log (GW_LOG_WARN, KERNEL_LOG, "No From in email header");
fprintf (reply_fd, "%s\n", gw_res_get (info.kernel_res, "gw.msg.greeting",
"Email->Z39.50 gateway"));
+ if (continuation)
+ fprintf (reply_fd, "%s\n", gw_res_get (info.kernel_res,
+ "gw.msg.cont",
+ "Continued..."));
+ ccl_token_and = gw_res_get (info.kernel_res, "ccl.token.and", "and");
+ ccl_token_or = gw_res_get (info.kernel_res, "ccl.token.or", "or");
+ ccl_token_not = gw_res_get (info.kernel_res, "ccl.token.not", "not");
+ ccl_token_set = gw_res_get (info.kernel_res, "ccl.token.set", "set");
+ return 0;
+}
+
+int urp_command (struct str_queue *queue)
+{
+ char *cp;
+
while (str_queue_deq (queue, line_buf, LINE_MAX))
{
if (line_buf[0] == '\n')
- if (command_no)
+ if (info.command_no)
{
while (str_queue_deq (queue, 0, 0))
;
if ((cp = strchr (line_buf, '\n')))
*cp = '\0';
gw_log (GW_LOG_ACCT, KERNEL_LOG, "cmd: %s", line_buf);
- ccl_token_and = gw_res_get (info.kernel_res, "ccl.token.and", "and");
- ccl_token_or = gw_res_get (info.kernel_res, "ccl.token.or", "or");
- ccl_token_not = gw_res_get (info.kernel_res, "ccl.token.not", "not");
- ccl_token_set = gw_res_get (info.kernel_res, "ccl.token.set", "set");
if (isalpha (line_buf[0]))
exec_command (line_buf);
- command_no++;
+ info.command_no++;
}
- if (!command_no)
+ return 0;
+}
+
+void urp_end (void)
+{
+ if (!info.command_no)
{
- fprintf (reply_fd, "%s\n", gw_res_get (info.kernel_res,
- "gw.err.nullbody",
- "No body"));
+ fprintf (reply_fd, "%s\n",
+ gw_res_get (info.kernel_res, "gw.err.nullbody", "No body"));
help_general ();
}
- if (*from_str)
+ if (*info.from_str)
{
const char *mta;
char cmd[256];
int mta_code;
- assert (reply_fname);
+ assert (info.reply_fname);
fclose (reply_fd);
reply_fd = stdout;
mta = gw_res_get (info.kernel_res, "gw.reply.mta",
- "/usr/lib/sendmail");
- sprintf (cmd, "%s %s < %s", mta, from_str, reply_fname);
+ "/usr/lib/sendmail");
+ sprintf (cmd, "%s %s < %s", mta, info.from_str, info.reply_fname);
mta_code = system (cmd);
if (mta_code)
gw_log (GW_LOG_FATAL, KERNEL_LOG,
"Reply '%s' got exit code %d", cmd, mta_code);
- unlink (reply_fname);
- gw_log (GW_LOG_ACCT, KERNEL_LOG, "User end %s", from_str);
+ else
+ unlink (info.reply_fname);
+ gw_log (GW_LOG_ACCT, KERNEL_LOG, "User end %s", info.from_str);
}
- return 0;
}
+