ctdldump/ctdlload: -h now specifies the top-level Citadel directory, just like all...
authorArt Cancro <ajc@citadel.org>
Tue, 1 Aug 2023 02:32:29 +0000 (17:32 -0900)
committerArt Cancro <ajc@citadel.org>
Tue, 1 Aug 2023 02:32:29 +0000 (17:32 -0900)
citadel/utils/ctdldump.c
citadel/utils/ctdlload.c

index f340509b35045ed86bac81d156e70f5ea1fe2768..ccd6c18cc41ff254376e8a43027afd845bc3e0b7 100644 (file)
@@ -497,8 +497,7 @@ void export_table(int which_cdb, DB_ENV *src_dbenv) {
 
 int main(int argc, char **argv) {
        int i = 0;
-       char *src_dir = NULL;
-       char *dst_dir = NULL;
+       char src_dir[PATH_MAX];
        int confirmed = 0;
        static DB_ENV *src_dbenv;               // Source DB environment (global)
 
@@ -510,18 +509,21 @@ int main(int argc, char **argv) {
                        "\033[44m\033[33m\033[1m is subject to the terms of the GNU General Public license v3. \033[K\033[0m\n"
                        "\033[44m\033[33m\033[1m \033[K\033[0m\n");
 
+       // Default source directory unless overridden
+       snprintf(src_dir, sizeof(src_dir), "%s/data", CTDLDIR);
+
        // Parse command line
        int a;
        while ((a = getopt(argc, argv, "h:y")) != EOF) {
                switch (a) {
                case 'h':
-                       src_dir = optarg;
+                       snprintf(src_dir, sizeof(src_dir), "%s/data", optarg);
                        break;
                case 'y':
                        confirmed = 1;
                        break;
                default:
-                       fprintf(stderr, "%s: usage: %s -s source_dir [>dumpfile]\n", argv[0], argv[0]);
+                       fprintf(stderr, "%s: usage: %s -s citadel_dir [>dumpfile]\n", argv[0], argv[0]);
                        exit(2);
                }
        }
@@ -535,8 +537,8 @@ int main(int argc, char **argv) {
                fprintf(stderr, "ctdldump: You have specified the [-y] flag, so processing will continue.\n");
        }
        else {
-               fprintf(stderr, "ctdldump: usage: ctdldump -y -h[data_dir] >[dump_file]\n");
-               fprintf(stderr, "          [data_dir] is your database directory, usually /usr/local/citadel/data\n");
+               fprintf(stderr, "ctdldump: usage: ctdldump -y -h[citadel_dir] >[dump_file]\n");
+               fprintf(stderr, "          [citadel_dir] is your database directory, usually /usr/local/citadel\n");
                fprintf(stderr, "          Please read [ https://www.citadel.org/dump-and-load.html ] to learn how to proceed.\n");
                exit(1);
        }
index 5c660dab7e6b2d0d1f5d198b6bf438cc266f3db4..59cc9b785ce91e8f94a97aa609cdd0f749cac610 100644 (file)
@@ -822,7 +822,7 @@ void ingest(DB_ENV *dst_dbenv) {
 
 // Main entry point
 int main(int argc, char **argv) {
-       char *dst_dir = NULL;
+       char dst_dir[PATH_MAX];
        int confirmed = 0;
        static DB_ENV *dst_dbenv;               // Target DB environment
 
@@ -834,12 +834,15 @@ int main(int argc, char **argv) {
                        "\033[44m\033[33m\033[1m is subject to the terms of the GNU General Public license v3. \033[K\033[0m\n"
                        "\033[44m\033[33m\033[1m \033[K\033[0m\n");
 
+       // Default destination directory unless overridden
+       snprintf(dst_dir, sizeof(dst_dir), "%s/data", CTDLDIR);
+
        // Parse command line
        int a;
        while ((a = getopt(argc, argv, "h:y")) != EOF) {
                switch (a) {
                case 'h':
-                       dst_dir = optarg;
+                       snprintf(dst_dir, sizeof(dst_dir), "%s/data", optarg);
                        break;
                case 'y':
                        confirmed = 1;