X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=kernel%2Fmain.c;h=f1f1694fefb88a82df69c0d0ce0e84d1604303ef;hb=4938d0c2e8f4e1eec397c2bfbbc7e23fd150c369;hp=0f511c73f127317c22bd4e644e0fee43f7e65038;hpb=06f969f8132e7aaa1c6bb559d4611416d4120b59;p=egate.git diff --git a/kernel/main.c b/kernel/main.c index 0f511c7..f1f1694 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -45,7 +45,21 @@ * Europagate, 1995 * * $Log: main.c,v $ - * Revision 1.26 1995/05/18 12:03:08 adam + * Revision 1.30 1996/02/12 10:04:54 adam + * The gateway doesn't try to reconnect if it is already known that + * it will fail (connect_fail flag introduced). + * + * Revision 1.29 1995/07/28 10:51:08 adam + * Bug fix: account from previous session had effect when new target command + * was executed. + * + * Revision 1.28 1995/07/03 08:20:15 adam + * More help information and better diagnostics. + * + * 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 @@ -164,6 +178,7 @@ static void kernel_events (struct str_queue *queue) 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); @@ -173,7 +188,7 @@ static void kernel_events (struct str_queue *queue) 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); @@ -181,7 +196,10 @@ static void kernel_events (struct str_queue *queue) { 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"); @@ -193,8 +211,11 @@ static void kernel_events (struct str_queue *queue) } 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; @@ -235,21 +256,18 @@ static void kernel_events (struct str_queue *queue) 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) @@ -261,6 +279,7 @@ int main (int argc, char **argv) info.override_res = NULL; *info.target = 0; *info.account = 0; + info.account_in_session = 1; info.lang = NULL; info.bibset = NULL; info.zass = NULL; @@ -270,6 +289,7 @@ int main (int argc, char **argv) info.database = NULL; info.setno = -1; info.userid = -1; + info.connect_failed = 0; #if USE_FML info.fml = NULL; #endif @@ -284,8 +304,8 @@ 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"); @@ -403,7 +423,8 @@ int main (int argc, char **argv) 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); } } @@ -497,8 +518,6 @@ static int fml_inf_read (void) void read_kernel_res (void) { - char path_prefix[128]; - char fname[160]; const char *v; char *cp; char resource_name[256]; @@ -529,23 +548,19 @@ void read_kernel_res (void) info.default_res); return; } - strcpy (path_prefix, gw_res_get (info.kernel_res, "gw.path", ".")); - /* fetch target definitions (if defined at all) */ if (*info.target) { sprintf (resource_name, "gw.target.%s", info.target); v = gw_res_get (info.kernel_res, resource_name, NULL); if (v) - { - sprintf (fname, "%s/%s", path_prefix, v); - gw_res_merge (info.kernel_res, fname); - } + gw_res_merge (info.kernel_res, v); } /* fetch user definitions (if user-id is specified) */ if (info.userid >= 0) { - sprintf (fname, "%s/user.%d.r", path_prefix, info.userid); + char fname[250]; + sprintf (fname, "user.%d.r", info.userid); gw_res_merge (info.kernel_res, fname); } /* fetch language definitions (if specified at all) */ @@ -556,18 +571,14 @@ void read_kernel_res (void) v = gw_res_get (info.kernel_res, resource_name, NULL); if (v) { - sprintf (fname, "%s/%s", path_prefix, v); gw_log (GW_LOG_DEBUG, KERNEL_LOG, "Reading language resources %s", - fname); - gw_res_merge (info.kernel_res, fname); + v); + gw_res_merge (info.kernel_res, v); } } /* fetch overriding resources from file (if specified) */ if (info.override_res) - { - sprintf (fname, "%s/%s", path_prefix, info.override_res); - gw_res_merge (info.kernel_res, fname); - } + gw_res_merge (info.kernel_res, info.override_res); /* read bibset definition for ccl */ v = gw_res_get (info.kernel_res, "gw.bibset", NULL); @@ -575,13 +586,12 @@ void read_kernel_res (void) { FILE *bib_inf; - sprintf (fname, "%s/%s", path_prefix, v); - bib_inf = fopen (fname, "r"); + bib_inf = fopen (v, "r"); if (!bib_inf) - gw_log (GW_LOG_WARN, KERNEL_LOG, "cannot open %s", fname); + gw_log (GW_LOG_WARN, KERNEL_LOG, "cannot open %s", v); else { - gw_log (GW_LOG_DEBUG, KERNEL_LOG, "reading bib file %s", fname); + gw_log (GW_LOG_DEBUG, KERNEL_LOG, "reading bib file %s", v); ccl_qual_file (info.bibset, bib_inf); fclose (bib_inf); } @@ -613,6 +623,7 @@ void read_kernel_res (void) sizeof(info.hostname)-1); info.port = gw_res_int (info.kernel_res, "gw.portno", 210); strcpy (info.account, gw_res_get (info.kernel_res, "gw.account", "")); + info.account_in_session = 0; } /* set info.databases (all available databases for target) */ /* set info.database (first database for target) */ @@ -666,11 +677,9 @@ void read_kernel_res (void) if (!info.fml) { v = gw_res_get (info.kernel_res, "gw.fml", "default.fml"); - sprintf (fname, "%s/%s", path_prefix, v); - fml_inf = fopen (fname, "r"); + fml_inf = fopen (v, "r"); if (!fml_inf) - gw_log (GW_LOG_WARN, KERNEL_LOG, - "cannot open fml script %s", fname); + gw_log (GW_LOG_WARN, KERNEL_LOG, "cannot open fml script %s", v); else { info.fml = fml_open ();