* 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);
}
}