+ case 'b':
+ {
+ size_t len;
+
+ if (config_base_dir != NULL)
+ free (config_base_dir);
+ config_base_dir = strdup (optarg);
+ if (config_base_dir == NULL)
+ {
+ fprintf (stderr, "read_options: strdup failed.\n");
+ return (3);
+ }
+
+ len = strlen (config_base_dir);
+ while ((len > 0) && (config_base_dir[len - 1] == '/'))
+ {
+ config_base_dir[len - 1] = 0;
+ len--;
+ }
+
+ if (len < 1)
+ {
+ fprintf (stderr, "Invalid base directory: %s\n", optarg);
+ return (4);
+ }
+ }
+ break;
+
+ case 'p':
+ {
+ if (config_pid_file != NULL)
+ free (config_pid_file);
+ config_pid_file = strdup (optarg);
+ if (config_pid_file == NULL)
+ {
+ fprintf (stderr, "read_options: strdup failed.\n");
+ return (3);
+ }
+ }
+ break;
+