+static int parse_options(int argc, char *argv[])
+{
+ const char *optstring = "t:g:i:r:o:";
+ int c, dist_val_set = 0;
+
+ while ((c = getopt(argc, argv, optstring)) != -1) {
+ switch (c) {
+ case 't':
+ if (!strncmp(optarg, "zipf", 4))
+ dist_type = TYPE_ZIPF;
+ else if (!strncmp(optarg, "pareto", 6))
+ dist_type = TYPE_PARETO;
+ else {
+ printf("wrong dist type: %s\n", optarg);
+ return 1;
+ }
+ break;
+ case 'g':
+ gb_size = strtoul(optarg, NULL, 10);
+ break;
+ case 'i':
+ dist_val = atof(optarg);
+ dist_val_set = 1;
+ break;
+ case 'r':
+ nranges = strtoul(optarg, NULL, 10);
+ break;
+ case 'o':
+ output_nranges = strtoul(optarg, NULL, 10);
+ break;
+ default:
+ printf("bad option %c\n", c);
+ return 1;
+ }
+ }
+
+ if (dist_type == TYPE_PARETO) {
+ if ((dist_val >= 1.00 || dist_val < 0.00)) {
+ printf("pareto input must be > 0.00 and < 1.00\n");
+ return 1;
+ }
+ if (!dist_val_set)
+ dist_val = DEF_PARETO_VAL;
+ } else if (dist_type == TYPE_ZIPF) {
+ if (dist_val == 1.0) {
+ printf("zipf input must be different than 1.0\n");
+ return 1;
+ }
+ if (!dist_val_set)
+ dist_val = DEF_ZIPF_VAL;
+ }
+
+ return 0;
+}
+