From f23877222f4421d98a83e917ea0d0d2f935cff5b Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Mon, 31 Jul 2023 17:32:29 -0900 Subject: [PATCH] ctdldump/ctdlload: -h now specifies the top-level Citadel directory, just like all the other programs, and defaults to the compiled-in Citadel directory, just like all the other programs --- citadel/utils/ctdldump.c | 14 ++++++++------ citadel/utils/ctdlload.c | 7 +++++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/citadel/utils/ctdldump.c b/citadel/utils/ctdldump.c index f340509b3..ccd6c18cc 100644 --- a/citadel/utils/ctdldump.c +++ b/citadel/utils/ctdldump.c @@ -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); } diff --git a/citadel/utils/ctdlload.c b/citadel/utils/ctdlload.c index 5c660dab7..59cc9b785 100644 --- a/citadel/utils/ctdlload.c +++ b/citadel/utils/ctdlload.c @@ -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; -- 2.39.2