+static void print_complete_help_and_die(void)
+{
+ const char **line;
+
+ printf("%s-%s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION);
+ printf("%s\n\n", gengetopt_args_info_purpose);
+ printf("%s\n\n", gengetopt_args_info_usage);
+
+ if (conf.help_given)
+ line = gengetopt_args_info_help;
+ else
+ line = gengetopt_args_info_detailed_help;
+ for (; *line; line++)
+ printf("%s\n", *line);
+
+ if (conf.help_given)
+ line = select_args_info_help;
+ else
+ line = select_args_info_detailed_help;
+ printf("Select options:\n");
+ for (; *line; line++)
+ printf("%s\n", *line);
+
+ printf("Interactive commands:\n");
+ print_interactive_help();
+ cmdline_parser_free(&conf);
+ select_cmdline_parser_free(&select_conf);
+ exit(EXIT_FAILURE);
+}
+
+static void get_database_dir_or_die(void)
+{
+ char *tmp;
+
+ if (conf.database_dir_given)
+ tmp = adu_strdup(conf.database_dir_arg);
+ else
+ tmp = make_message("%s%s",
+ conf.database_root_arg, conf.base_dir_arg);
+ /*
+ * As we change the cwd during database creation, database_dir
+ * must be an absolute path.
+ */
+ database_dir = absolute_path(tmp);
+ free(tmp);
+ if (database_dir)
+ return;
+ EMERG_LOG("failed to get absolute path of database dir\n");
+ exit(EXIT_FAILURE);
+}
+
+/**
+ * The main function of adu.
+ *
+ * \param argc Usual argument count.
+ * \param argv Usual argument vector.
+ *
+ * Check command line options, init the signal handlers and
+ * call the main function of the selected mode.
+ *
+ * \return \p EXIT_SUCCESS on success, \p EXIT_FAILURE otherwise.
+ */