static void cli_parse(int argc, char * const argv[], int *foreground, int *force_debug, struct qdevice_advanced_settings *advanced_settings) { int ch; *foreground = 0; *force_debug = 0; while ((ch = getopt(argc, argv, "dfhS:")) != -1) { switch (ch) { case 'd': *force_debug = 1; break; case 'f': *foreground = 1; break; case 'S': cli_parse_long_opt(advanced_settings, optarg); break; case 'h': case '?': usage(); exit(1); break; } } }
static void cli_parse(int argc, char * const argv[], char **host_addr, uint16_t *host_port, int *foreground, int *debug_log, int *bump_log_priority, enum tlv_tls_supported *tls_supported, int *client_cert_required, size_t *max_clients, PRIntn *address_family, struct qnetd_advanced_settings *advanced_settings) { int ch; char *ep; long long int tmpll; *host_addr = NULL; *host_port = QNETD_DEFAULT_HOST_PORT; *foreground = 0; *debug_log = 0; *bump_log_priority = 0; *tls_supported = QNETD_DEFAULT_TLS_SUPPORTED; *client_cert_required = QNETD_DEFAULT_TLS_CLIENT_CERT_REQUIRED; *max_clients = QNETD_DEFAULT_MAX_CLIENTS; *address_family = PR_AF_UNSPEC; while ((ch = getopt(argc, argv, "46dfhvc:l:m:p:S:s:")) != -1) { switch (ch) { case '4': *address_family = PR_AF_INET; break; case '6': *address_family = PR_AF_INET6; break; case 'f': *foreground = 1; break; case 'd': if (*debug_log) { *bump_log_priority = 1; } *debug_log = 1; break; case 'c': if ((*client_cert_required = utils_parse_bool_str(optarg)) == -1) { errx(1, "client_cert_required should be on/yes/1, off/no/0"); } break; case 'l': free(*host_addr); *host_addr = strdup(optarg); if (*host_addr == NULL) { errx(1, "Can't alloc memory for host addr string"); } break; case 'm': errno = 0; tmpll = strtoll(optarg, &ep, 10); if (tmpll < 0 || errno != 0 || *ep != '\0') { errx(1, "max clients value %s is invalid", optarg); } *max_clients = (size_t)tmpll; break; case 'p': *host_port = strtol(optarg, &ep, 10); if (*host_port <= 0 || *host_port > ((uint16_t)~0) || *ep != '\0') { errx(1, "host port must be in range 0-65535"); } break; case 'S': cli_parse_long_opt(advanced_settings, optarg); break; case 's': if (strcasecmp(optarg, "on") == 0) { *tls_supported = QNETD_DEFAULT_TLS_SUPPORTED; } else if (strcasecmp(optarg, "off") == 0) { *tls_supported = TLV_TLS_UNSUPPORTED; } else if (strcasecmp(optarg, "req") == 0) { *tls_supported = TLV_TLS_REQUIRED; } else { errx(1, "tls must be one of on, off, req"); } break; case 'v': display_version(); exit(1); break; case 'h': case '?': usage(); exit(1); break; } } }