+
+static void main_parse_arguments() {
+ int c;
+ struct option options[] = {
+ {"show", 1, 0, 's'},
+ {"foreground", 0, 0, 'f'},
+ {"config", 1, 0, 'c'},
+ {"pid", 1, 0, 'p'},
+ {"help", 0, 0, 'h'},
+ {"version", 0, 0, 'v'},
+ {0, 0, 0, 0}
+ };
+ while ((c = getopt_long(process_state.argc, process_state.argv, "s:fvh", options, NULL)) != -1) {
+ switch (c) {
+ case 'c':
+ strncpy(process_state.config, optarg, MAXLEN-1);
+ break;
+ case 'p':
+ strncpy(process_state.pidfile, optarg, MAXLEN-1);
+ break;
+ case 's':
+ process_state.loglevel = atoi(optarg);
+ break;
+ case 'f':
+ process_state.run_as_daemon = 0;
+ break;
+ case 'v':
+ printf("Version: %s.%d (%s)\n", NEONSERV_VERSION, patchlevel, (strcmp(revision, "") ? revision : "-"));
+ printf("Build: #%s %s (%s lines, " COMPILER ")\n", compilation, creation, codelines);
+ exit(0);
+ break;
+ case 'h':
+ printf("Usage: ./neonserv [-c neonserv.conf] [-p neonserv.pid] [-s loglevel] [-f] [-h|-v]\n");
+ printf(" -c, --config use this configuration file.\n");
+ printf(" -f, --foreground run NeonServ in the foreground.\n");
+ printf(" -h, --help prints this usage message.\n");
+ printf(" -p, --pid use this pid file.\n");
+ printf(" -s, --show show log lines matching loglevel in stdout.\n");
+ printf(" -v, --version prints this program's version.\n");
+ exit(0);
+ break;
+ }
+ }