123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- #include "conf.h"
-
- void usage()
- {
- static const struct option opts[] = PYFCGI_LONG_OPT;
- static const char *help[][2] = PYFCGI_OPT_HELP;
- size_t i;
- dprintf(2, "Usage : %s -e PYMODULE -E PYFUN [OPTIONS]\n", PYFCGI_NAME);
- dprintf(2, "\nOptions list :\n");
- i=0;
- while(opts[i].name)
- {
- dprintf(2, "\t-%c, --%s", opts[i].val, opts[i].name);
- switch(opts[i].has_arg)
- {
- case required_argument:
- dprintf(2, "=%s\n",
- help[i][1]?help[i][1]:"ARG");
- break;
- case optional_argument:
- dprintf(2, "[=%s]\n",
- help[i][1]?help[i][1]:"ARG");
- break;
- default: //no_argument
- dprintf(2, "\n");
- }
- printf("\t\t%s\n\n", help[i][0]);
- i++;
- }
- dprintf(2, "%s", PYFCGI_HELP_TEXT);
- }
-
- void print_version(int fd)
- {
- dprintf(fd, "%s\n", PACKAGE_STRING);
- }
-
- int parse_args(int argc, char *argv[])
- {
- static const struct option long_options[] = PYFCGI_LONG_OPT;
- int c, opt_i;
- while(1)
- {
- c = getopt_long(argc, argv, PYFCGI_SHORT_OPT, long_options,
- &opt_i);
- if(c == -1) { break; }
- switch(c)
- {
- case 'v':
- print_version(1);
- exit(0);
- case 'C':
- dprintf(2, "Config parser not yet implemented :'(\n");
- exit(1);
- case 'e':
- PyFCGI_conf.py_entrymod = strdup(optarg);
- break;
- case 'E':
- PyFCGI_conf.py_entryfun = strdup(optarg);
- break;
- case 'w':
- PyFCGI_conf.min_wrk = atoi(optarg);
- break;
- case 'W':
- PyFCGI_conf.max_wrk = atoi(optarg);
- break;
- case 'm':
- PyFCGI_conf.max_reqs = atoi(optarg);
- if(PyFCGI_conf.max_reqs < 0)
- {
- PyFCGI_conf.max_reqs = 0;
- }
- break;
- case 'L':
- if(parse_optlog(optarg))
- {
- exit(1);
- }
- break;
- case 'S':
- PyFCGI_conf.logs.flags |= PYFCGI_LOG_FSYSLOG;
- break;
- case 'P':
- PyFCGI_conf.context.pidfile = strdup(optarg);
- break;
- case 'h':
- usage();
- exit(0);
- default:
- usage();
- exit(1);
- }
- }
- if(optind < argc)
- {
- for(opt_i=optind; opt_i<argc; opt_i++)
- {
- dprintf(2, "Unkown argument '%s'\n", argv[opt_i]);
- }
- usage();
- exit(1);
- }
- return 0;
- }
-
- int parse_optlog(const char* logspec)
- {
- return 0;
- }
|