-static void
-usage(int status)
-{
- if(status != 0)
- fprintf(stderr, "Try `%s --help\' for more information.\n", program_name);
- else
- {
- printf("Usage: %s [option]...\n\n", program_name);
- printf(" -c, --config=FILE Read configuration options from FILE.\n"
- " -D, --no-detach Don't fork and detach.\n"
- " -d Increase debug level.\n"
- " -k, --kill Attempt to kill a running tincd and exit.\n"
- " -n, --net=NETNAME Connect to net NETNAME.\n"
- " -t, --timeout=TIMEOUT Seconds to wait before giving a timeout.\n");
- printf(" --help Display this help and exit.\n"
- " --version Output version information and exit.\n\n");
- printf("Report bugs to zarq@iname.com.\n");
- }
- exit(status);
-}
-
-void
-parse_options(int argc, char **argv, char **envp)
-{
- int r;
- int option_index = 0;
- config_t *p;
-
- while((r = getopt_long(argc, argv, "c:Ddkn:t:", long_options, &option_index)) != EOF)
- {
- switch(r)
- {
- case 0: /* long option */
- break;
- case 'c': /* config file */
- configfilename = xmalloc(strlen(optarg)+1);
- strcpy(configfilename, optarg);
- break;
- case 'D': /* no detach */
- do_detach = 0;
- break;
- case 'd': /* inc debug level */
- debug_lvl++;
- break;
- case 'k': /* kill old tincds */
- kill_tincd = 1;
- break;
- case 'n': /* net name given */
- netname = xmalloc(strlen(optarg)+1);
- strcpy(netname, optarg);
- break;
- case 't': /* timeout */
- if(!(p = add_config_val(&config, TYPE_INT, optarg)))
- {
- printf("Invalid timeout value `%s'.\n", optarg);
- usage(1);
- }
- break;
- case '?':
- usage(1);
- default:
- break;
- }
- }
-}