- static struct option long_options[]=
- {
- {(OPTIONSTRING)"concurrency", required_argument, NULL, OPT_SLAP_CONCURRENCY},
- {(OPTIONSTRING)"debug", no_argument, &opt_verbose, OPT_DEBUG},
- {(OPTIONSTRING)"quiet", no_argument, NULL, OPT_QUIET},
- {(OPTIONSTRING)"execute-number", required_argument, NULL, OPT_SLAP_EXECUTE_NUMBER},
- {(OPTIONSTRING)"flag", no_argument, &opt_displayflag, OPT_FLAG},
- {(OPTIONSTRING)"flush", no_argument, &opt_flush, OPT_FLUSH},
- {(OPTIONSTRING)"help", no_argument, NULL, OPT_HELP},
- {(OPTIONSTRING)"initial-load", required_argument, NULL, OPT_SLAP_INITIAL_LOAD}, /* Number to load initially */
- {(OPTIONSTRING)"non-blocking", no_argument, &opt_non_blocking_io, OPT_SLAP_NON_BLOCK},
- {(OPTIONSTRING)"servers", required_argument, NULL, OPT_SERVERS},
- {(OPTIONSTRING)"tcp-nodelay", no_argument, &opt_tcp_nodelay, OPT_SLAP_TCP_NODELAY},
- {(OPTIONSTRING)"test", required_argument, NULL, OPT_SLAP_TEST},
- {(OPTIONSTRING)"verbose", no_argument, &opt_verbose, OPT_VERBOSE},
- {(OPTIONSTRING)"version", no_argument, NULL, OPT_VERSION},
- {(OPTIONSTRING)"binary", no_argument, NULL, OPT_BINARY},
- {(OPTIONSTRING)"udp", no_argument, NULL, OPT_UDP},
- {0, 0, 0, 0},
- };
-
- bool opt_help= false;
- bool opt_version= false;
- int option_index= 0;
- while (1)
- {
- int option_rv= getopt_long(argc, argv, "Vhvds:", long_options, &option_index);
-
- if (option_rv == -1) break;
-
- switch (option_rv)
- {
- case 0:
- break;
-
- case OPT_UDP:
- if (opt_test == GET_TEST)
- {
- fprintf(stderr, "You can not run a get test in UDP mode. UDP mode "
- "does not currently support get ops.\n");
- exit(1);
- }
- opt_udp_io= true;
- break;
-
- case OPT_BINARY:
- opt_binary= true;
- break;
-
- case OPT_VERBOSE: /* --verbose or -v */
- opt_verbose= OPT_VERBOSE;
- break;
-
- case OPT_DEBUG: /* --debug or -d */
- opt_verbose= OPT_DEBUG;
- break;
-
- case OPT_VERSION: /* --version or -V */
- opt_version= true;
- break;
-
- case OPT_HELP: /* --help or -h */
- opt_help= true;
- break;
-
- case OPT_SERVERS: /* --servers or -s */
- opt_servers= strdup(optarg);
- break;
-
- case OPT_SLAP_TEST:
- if (strcmp(optarg, "get") == 0)
- {
- if (opt_udp_io == 1)
- {
- fprintf(stderr, "You can not run a get test in UDP mode. UDP mode "
- "does not currently support get ops.\n");
- exit(EXIT_FAILURE);
- }
- opt_test= GET_TEST ;
- }
- else if (strcmp(optarg, "set") == 0)
- {
- opt_test= SET_TEST;
- }
- else if (strcmp(optarg, "mget") == 0)
- {
- opt_test= MGET_TEST;
- }
- else
- {
- fprintf(stderr, "Your test, %s, is not a known test\n", optarg);
- exit(EXIT_FAILURE);
- }
- break;
-
- case OPT_SLAP_CONCURRENCY:
- errno= 0;
- opt_concurrency= (unsigned int)strtoul(optarg, (char **)NULL, 10);
- if (errno != 0)
- {
- fprintf(stderr, "Invalid value for concurrency: %s\n", optarg);
- exit(EXIT_FAILURE);
- }
- break;
-
- case OPT_SLAP_EXECUTE_NUMBER:
- errno= 0;
- opt_execute_number= (unsigned int)strtoul(optarg, (char **)NULL, 10);
- if (errno != 0)
- {
- fprintf(stderr, "Invalid value for execute: %s\n", optarg);
- exit(EXIT_FAILURE);
- }
- break;
-
- case OPT_SLAP_INITIAL_LOAD:
- errno= 0;
- opt_createial_load= (unsigned int)strtoul(optarg, (char **)NULL, 10);
- if (errno != 0)
- {
- fprintf(stderr, "Invalid value for initial load: %s\n", optarg);
- exit(EXIT_FAILURE);