From: Adam Dickmeiss Date: Wed, 3 May 1995 07:37:29 +0000 (+0000) Subject: CCL commands stop/continue implemented. New functions gw_res_{int,bool} X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=eacb1b9bfa1f3be86f23e7426b12abb4b866c6d0;p=egate.git CCL commands stop/continue implemented. New functions gw_res_{int,bool} are used when possible. --- diff --git a/kernel/Makefile b/kernel/Makefile index 6fdbf04..9bbe703 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -2,7 +2,11 @@ # 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 @@ -116,7 +120,7 @@ $(PROG3): $(O3) $(USELIBS3) 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 diff --git a/kernel/default.res b/kernel/default.res index 71105be..6e88ba3 100644 --- a/kernel/default.res +++ b/kernel/default.res @@ -1,5 +1,5 @@ # 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 @@ -8,8 +8,9 @@ gw.reply.tmp.dir: /tmp #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 diff --git a/kernel/eti.c b/kernel/eti.c index f7a1b99..7b028d0 100644 --- a/kernel/eti.c +++ b/kernel/eti.c @@ -2,7 +2,11 @@ * 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 @@ -199,8 +203,8 @@ int main (int argc, char **argv) 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); diff --git a/kernel/kernel.h b/kernel/kernel.h index 40bafaf..a24b5fc 100644 --- a/kernel/kernel.h +++ b/kernel/kernel.h @@ -2,7 +2,11 @@ * 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 @@ -97,6 +101,7 @@ struct gw_kernel_info { char from_str[LINE_MAX+1]; const char *reply_fname; int setno; + int next_position; #if USE_FML Fml fml; #endif @@ -134,6 +139,7 @@ const struct zass_presentent *zass_p_present (ZASS zass, 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" diff --git a/kernel/main.c b/kernel/main.c index 63d6a4f..8a5971c 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -2,7 +2,11 @@ * 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 @@ -104,8 +108,10 @@ static void kernel_events (struct str_queue *queue, int userid) 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); @@ -134,7 +140,7 @@ static void kernel_events (struct str_queue *queue, int 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; } @@ -156,9 +162,11 @@ static void kernel_events (struct str_queue *queue, int userid) 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)) ; @@ -515,8 +523,7 @@ void read_kernel_res (void) 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 @@ -524,8 +531,7 @@ void read_kernel_res (void) 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) @@ -559,8 +565,10 @@ void read_kernel_res (void) 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) { diff --git a/kernel/monitor.c b/kernel/monitor.c index 405369b..84b5896 100644 --- a/kernel/monitor.c +++ b/kernel/monitor.c @@ -2,7 +2,11 @@ * 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 @@ -43,8 +47,8 @@ #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; @@ -67,7 +71,7 @@ static void reread_resources (void) 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 { diff --git a/kernel/persist.c b/kernel/persist.c index 6e4e174..176b17f 100644 --- a/kernel/persist.c +++ b/kernel/persist.c @@ -2,7 +2,11 @@ * 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 @@ -238,6 +242,10 @@ int load_p_state (int userid) 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 @@ -328,9 +336,18 @@ int save_p_state (int userid) 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); +} + diff --git a/kernel/urp.c b/kernel/urp.c index d052151..173f5b5 100644 --- a/kernel/urp.c +++ b/kernel/urp.c @@ -2,7 +2,11 @@ * 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 @@ -106,6 +110,19 @@ * */ +/* + 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 #include #include @@ -178,17 +195,17 @@ static struct command_word { 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 } }; @@ -292,7 +309,6 @@ static int exec_help (struct ccl_token *list) 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 - selects a given target\n")); @@ -309,7 +325,6 @@ static int exec_help (struct ccl_token *list) put_esc_str (gw_res_get (info.kernel_res, "gw.help.show", "show - retrieves and displays " "records\n")); -#endif return 0; } @@ -339,6 +354,9 @@ static int exec_find (struct ccl_token *list, const char *search_str) 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) { @@ -387,8 +405,6 @@ static int exec_find (struct ccl_token *list, const char *search_str) 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; } @@ -429,7 +445,7 @@ static void exec_status_r (struct gw_user_set *sp) 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; } @@ -482,8 +498,7 @@ static void present (const char *set, int offset, int number, 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); @@ -718,12 +733,20 @@ static int exec_show (struct ccl_token *list) 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 */ { @@ -736,11 +759,19 @@ static int exec_show (struct ccl_token *list) 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."))) { @@ -771,8 +802,17 @@ static int exec_command (const char *str) 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: @@ -811,7 +851,7 @@ int urp_start (int continuation, struct str_queue *queue) { 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"); @@ -848,6 +888,7 @@ int urp_start (int continuation, struct str_queue *queue) int urp_command (struct str_queue *queue) { char *cp; + int stop_flag; while (str_queue_deq (queue, line_buf, LINE_MAX)) { @@ -864,7 +905,16 @@ int urp_command (struct str_queue *queue) *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;