]> git.tuebingen.mpg.de Git - adu.git/blobdiff - adu.c
Use ?:= as the assignement operator for PREFIX.
[adu.git] / adu.c
diff --git a/adu.c b/adu.c
index 9fb70bed1446f41d4a6049db036e28c5bf6d971e..7d8c9abd0191b6d4c84036bcc70e7e91d2cf03f3 100644 (file)
--- a/adu.c
+++ b/adu.c
@@ -12,7 +12,7 @@
  * - Modes of operation: \ref select.c, \ref create.c, \ref interactive.c
  * - User handling: \ref user.c
  * - Error handling: \ref error.h
  * - Modes of operation: \ref select.c, \ref create.c, \ref interactive.c
  * - User handling: \ref user.c
  * - Error handling: \ref error.h
- * - Library-type functions: \ref fd.c, \ref format.c, \ref string.c, \ref portable_io.h
+ * - Library-type functions: \ref fd.c, \ref format.c, \ref string.c, \ref portable_io.h, \ref bloom.c
  */
 
 #include "adu.h"
  */
 
 #include "adu.h"
@@ -259,6 +259,27 @@ static void print_complete_help_and_die(void)
        exit(EXIT_FAILURE);
 }
 
        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.
  *
 /**
  * The main function of adu.
  *
@@ -300,12 +321,7 @@ int main(int argc, char **argv)
        ret = init_signals();
        if (ret < 0)
                goto out;
        ret = init_signals();
        if (ret < 0)
                goto out;
-       ret = -E_SYNTAX;
-       if (conf.database_dir_given)
-               database_dir = adu_strdup(conf.database_dir_arg);
-       else
-               database_dir = make_message("%s%s",
-                       conf.database_root_arg, conf.base_dir_arg);
+       get_database_dir_or_die();
        if (conf.select_given)
                ret = com_select();
        else if (conf.create_given)
        if (conf.select_given)
                ret = com_select();
        else if (conf.create_given)