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)
"\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);
}
}
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);
}
// 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
"\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;