+int read_options (int argc, char **argv)
+{
+ int option;
+
+ while ((option = getopt (argc, argv, "i:o:p:P:s:t:m:h")) != -1)
+ {
+ switch (option)
+ {
+ case 'i':
+ {
+ if (initial_input_file != NULL)
+ free (initial_input_file);
+ initial_input_file = strdup (optarg);
+ break;
+ }
+
+ case 'o':
+ {
+ if (best_output_file != NULL)
+ free (best_output_file);
+ best_output_file = strdup (optarg);
+ break;
+ }
+
+ case 'p':
+ {
+ int tmp = atoi (optarg);
+ if (tmp > 0)
+ {
+ max_population_size = tmp;
+ population_set_size (population, (size_t) max_population_size);
+ }
+ break;
+ }
+
+ case 'P':
+ {
+ int status;
+
+ status = population_add_peer (population, optarg, /* port = */ NULL);
+ if (status != 0)
+ {
+ fprintf (stderr, "population_add_peer failed with status %i.\n",
+ status);
+ }
+ break;
+ }
+
+ case 's':
+ {
+ int tmp = atoi (optarg);
+ if (tmp > 0)
+ stats_interval = tmp;
+ break;
+ }
+
+ case 't':
+ {
+ int tmp = atoi (optarg);
+ if (tmp >= 1)
+ evolution_threads_num = tmp;
+ break;
+ }
+
+ case 'm':
+ {
+ if (strcasecmp ("oddeven", optarg) == 0)
+ selected_merger = MERGER_ODDEVEN;
+ else if (strcasecmp ("bitonic", optarg) == 0)
+ selected_merger = MERGER_BITONIC;
+ else if (strcasecmp ("random", optarg) == 0)
+ selected_merger = MERGER_RANDOM;
+ else
+ fprintf (stderr, "Not a valid merging strategy: \"%s\"\n", optarg);
+ break;
+ }
+
+ case 'h':
+ default:
+ exit_usage (argv[0]);
+ }
+ }
+
+ return (0);
+} /* int read_options */
+