Beispiel #1
0
static void parse_args_pre(int argc, char *argv[])
{
	DBG("Parsing arguments pre state");

	for (;;)
	{
		char *gostr = "+:hvVf:";

		struct option long_opts[] = {
			{"help", 0, 0, 'h'},
			{"version", 0, 0, 'v'},
			{"configfile", 1, 0, 'f'},
			{0, 0, 0, 0},
		};
		int c = getopt_long(argc, argv, gostr, long_opts, NULL);
		if (c == -1)
			break;
		
		switch (c)
		{
			case 'f':
				set_configfile(optarg);
				break;

			case 'h':
				print_version();
				printf("\n%s", usage_text);
				exit(1);
			case 'V':
			case 'v':
				print_version();
				exit(0);
		}
	}
}
Beispiel #2
0
static void parse_args_pre(int argc, char *argv[])
{
	for (;;)
	{
		char *gostr = "+:hvVf:";

#ifdef HAVE_GETOPT_LONG
		struct option long_opts[] = {
			{"help", 0, 0, 'h'},
			{"version", 0, 0, 'v'},
			{"configfile", 1, 0, 'f'},
			{0, 0, 0, 0},
		};
		int c = getopt_long(argc, argv, gostr, long_opts, NULL);
#else
		int c = getopt(argc, argv, gostr;
#endif

		if (c == -1)
			break;
		
		switch (c)
		{
			case 'f':
				set_configfile(optarg);
				break;

			case 'h':
				print_version();
				printf("\n%s", usage_text);
				exit(1);
			case 'V':
			case 'v':
				print_version();
				exit(0);
		}
	}
}
Beispiel #3
0
static void parse_cmd_line(int argc, const char * const *argv)
{
    const char *opt_arg;
    apr_status_t rv;
    apr_getopt_t *opt;
    int ch;

    static const apr_getopt_option_t options[] = {
        { "help", 'h', 0, "print help" },
        { "foreground", 'f', 0, "run in foreground" },
        { "stop", 's', 0, "stop a running instance" },
//	{ "reload", 'r', 0, "reload configuration of a running instance" },
        { "conf", 'c', 1, "configuration file" },
        { "verify", 'v', 0, "verify configuration file syntax" },
        { "install", 'i', 0, "install service available to service manager" },
        { "uninstall", 'u', 0, "uninstall service" },
        { NULL, 0, 1, NULL },
    };

    apr_getopt_init(&opt, nxlog.pool, argc, argv);
    while ( (rv = apr_getopt_long(opt, options, &ch, &opt_arg)) == APR_SUCCESS )
    {
        switch ( ch )
        {
        case 'c':	/* configuration file */
            nxlog.cfgfile = apr_pstrdup(nxlog.pool, opt_arg);
            break;
        case 'f':	/* foreground */
            nxlog.foreground = TRUE;
            break;
        case 'h':	/* help */
            print_usage();
            exit(-1);
        case 's':	/* stop */
            nxlog.do_stop = TRUE;
            break;
        /*
        	    case 'r':	// reload
        		nxlog.do_restart = TRUE;
        		break;
        */
        case 'v':	/* verify */
            nxlog.verify_conf = TRUE;
            nxlog.ctx->ignoreerrors = FALSE;
            break;
        case 'i':	/* install */
            do_install = TRUE;
            break;
        case 'u':	/* uninstall */
            do_uninstall = TRUE;
            break;
        default:
            print_usage();
            exit(-1);
        }
    }

    set_configfile();

    if ( (rv != APR_SUCCESS) && (rv != APR_EOF) )
    {
        throw(rv, "Could not parse options");
    }
}