// Load (restore) the Citadel database from a flat file created by ctdldump
//
-// Copyright (c) 2023-2024 by Art Cancro citadel.org
+// Copyright (c) 2023-2024 by citadel.org (Art Cancro et al.)
//
// This program is open source software. Use, duplication, or disclosure
// is subject to the terms of the GNU General Public License, version 3.
char userkey[USERNAME_SIZE];
char *token;
struct ctdluser *u;
+ int dlen = 0;
u = malloc(sizeof(struct ctdluser));
if (!u) {
u->msgnum_pic = atol(token);
break;
case 12:
- CtdlDecodeBase64(token, token, strlen(token));
- safestrncpy(u->emailaddrs, token, sizeof(u->emailaddrs));
+ dlen = CtdlDecodeBase64(token, token, strlen(token)); // Decode in place
+ if (dlen >= sizeof(u->emailaddrs)) {
+ dlen = sizeof(u->emailaddrs) - 1;
+ }
+ memcpy(u->emailaddrs, token, dlen);
+ u->emailaddrs[dlen] = 0;
break;
case 13:
u->msgnum_inboxrules = atol(token);
++good_rows;
}
else {
+ fprintf(stderr, "bad row: <%s>\n", line);
++bad_rows;
}
}
if (line_len > 0) {
+ if (!strncasecmp(line, HKEY("end|"))) {
+ fprintf(stderr, "\n");
+ end_found = 1;
+ }
if ( (begin_found) && (!end_found) ) {
ingest_one(line, &kv);
}
begin_found = 1;
fprintf(stderr, " good rows / bad rows:\n");
}
- if (!strncasecmp(line, HKEY("end|"))) {
- fprintf(stderr, "\n");
- end_found = 1;
- }
}
} while (ch >= 0);
// display the greeting
fprintf(stderr,
"\033[44m\033[1m╔════════════════════════════════════════════════════════════════════════╗\033[0m\n"
- "\033[44m\033[1m║ DB Load utility for Citadel ║\033[0m\n"
+ "\033[44m\033[1m║ DB Load utility for Citadel version %-4d ║\033[0m\n"
"\033[44m\033[1m║ Copyright (c) 2023-2024 by citadel.org et al. ║\033[0m\n"
"\033[44m\033[1m║ This program is open source software. Use, duplication, or disclosure ║\033[0m\n"
"\033[44m\033[1m║ is subject to the terms of the GNU General Public license v3. ║\033[0m\n"
- "\033[44m\033[1m╚════════════════════════════════════════════════════════════════════════╝\033[0m\n"
+ "\033[44m\033[1m╚════════════════════════════════════════════════════════════════════════╝\033[0m\n",
+ REV_LEVEL
);
// Parse command line