]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/migrate/serv_migrate.c
In the XML export, move the 100% progress tag inside the final closing tag.
[citadel.git] / citadel / modules / migrate / serv_migrate.c
index d55f8e9de1c9ad8f424318a93a72d6e299e75a4a..99377ee914ec874c482ea3b79f7ab5b7214bb02c 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This module dumps and/or loads the Citadel database in XML format.
  *
- * Copyright (c) 1987-2018 by the citadel.org team
+ * Copyright (c) 1987-2021 by the citadel.org team
  *
  * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 3.
 #include <pwd.h>
 #include <errno.h>
 #include <sys/types.h>
-
-#if TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <time.h>
-# endif
-#endif
-
+#include <time.h>
 #include <sys/wait.h>
 #include <string.h>
 #include <ctype.h>
 #include "euidindex.h"
 #include "ctdl_module.h"
 
-#define END_OF_MESSAGE "---eom---dbd---"
-
 char migr_tempfilename1[PATH_MAX];
 char migr_tempfilename2[PATH_MAX];
 FILE *migr_global_message_list;
 int total_msgs = 0;
 char *ikey = NULL;                     // If we're importing a config key we store it here.
 
-
 /******************************************************************************
  *        Code which implements the export appears in this section            *
  ******************************************************************************/
@@ -114,21 +100,30 @@ void xml_strout(char *str) {
 /*
  * Export a user record as XML
  */
-void migr_export_users_backend(struct ctdluser *buf, void *data) {
+void migr_export_users_backend(char *username, void *data) {
+
+       struct ctdluser u;
+       if (CtdlGetUser(&u, username) != 0) {
+               return;
+       }
+
        client_write(HKEY("<user>\n"));
-       cprintf("<u_version>%d</u_version>\n", buf->version);
-       cprintf("<u_uid>%ld</u_uid>\n", (long)buf->uid);
-       client_write(HKEY("<u_password>"));     xml_strout(buf->password);              client_write(HKEY("</u_password>\n"));
-       cprintf("<u_flags>%u</u_flags>\n", buf->flags);
-       cprintf("<u_timescalled>%ld</u_timescalled>\n", buf->timescalled);
-       cprintf("<u_posted>%ld</u_posted>\n", buf->posted);
-       cprintf("<u_axlevel>%d</u_axlevel>\n", buf->axlevel);
-       cprintf("<u_usernum>%ld</u_usernum>\n", buf->usernum);
-       cprintf("<u_lastcall>%ld</u_lastcall>\n", (long)buf->lastcall);
-       cprintf("<u_USuserpurge>%d</u_USuserpurge>\n", buf->USuserpurge);
-       client_write(HKEY("<u_fullname>"));     xml_strout(buf->fullname);              client_write(HKEY("</u_fullname>\n"));
-       cprintf("<u_msgnum_bio>%ld</u_msgnum_bio>\n", buf->msgnum_bio);
-       cprintf("<u_msgnum_pic>%ld</u_msgnum_pic>\n", buf->msgnum_pic);
+       cprintf("<u_version>%d</u_version>\n", u.version);
+       cprintf("<u_uid>%ld</u_uid>\n", (long)u.uid);
+       client_write(HKEY("<u_password>"));     xml_strout(u.password);         client_write(HKEY("</u_password>\n"));
+       cprintf("<u_flags>%u</u_flags>\n", u.flags);
+       cprintf("<u_timescalled>%ld</u_timescalled>\n", u.timescalled);
+       cprintf("<u_posted>%ld</u_posted>\n", u.posted);
+       cprintf("<u_axlevel>%d</u_axlevel>\n", u.axlevel);
+       cprintf("<u_usernum>%ld</u_usernum>\n", u.usernum);
+       cprintf("<u_lastcall>%ld</u_lastcall>\n", (long)u.lastcall);
+       cprintf("<u_USuserpurge>%d</u_USuserpurge>\n", u.USuserpurge);
+       client_write(HKEY("<u_fullname>"));     xml_strout(u.fullname);         client_write(HKEY("</u_fullname>\n"));
+       cprintf("<u_msgnum_bio>%ld</u_msgnum_bio>\n", u.msgnum_bio);
+       cprintf("<u_msgnum_pic>%ld</u_msgnum_pic>\n", u.msgnum_pic);
+       cprintf("<u_emailaddrs>%s</u_emailaddrs>\n", u.emailaddrs);
+       cprintf("<u_msgnum_inboxrules>%ld</u_msgnum_inboxrules>\n", u.msgnum_inboxrules);
+       cprintf("<u_lastproc_inboxrules>%ld</u_lastproc_inboxrules>\n", u.lastproc_inboxrules);
        client_write(HKEY("</user>\n"));
 }
 
@@ -320,7 +315,7 @@ void migr_export_message(long msgnum) {
 
        /* Ok, here we go ... */
 
-       msg = CtdlFetchMessage(msgnum, 1, 0);
+       msg = CtdlFetchMessage(msgnum, 1);
        if (msg == NULL) return;        /* fail silently */
 
        client_write(HKEY("<message>\n"));
@@ -468,8 +463,8 @@ void migr_do_export(void) {
        if (Ctx->kill_me == 0)  migr_export_visits();
        cprintf("<progress>%d</progress>\n", 25);
        if (Ctx->kill_me == 0)  migr_export_messages();
-       client_write(HKEY("</citadel_migrate_data>\n"));
        cprintf("<progress>%d</progress>\n", 100);
+       client_write(HKEY("</citadel_migrate_data>\n"));
        client_write(HKEY("000\n"));
        Ctx->dont_term = 0;
 }
@@ -580,6 +575,9 @@ int migr_userrecord(void *data, const char *el)
        else if (!strcasecmp(el, "u_fullname"))                 safestrncpy(usbuf.fullname, ChrPtr(migr_chardata), sizeof usbuf.fullname);
        else if (!strcasecmp(el, "u_msgnum_bio"))               usbuf.msgnum_bio = atol(ChrPtr(migr_chardata));
        else if (!strcasecmp(el, "u_msgnum_pic"))               usbuf.msgnum_pic = atol(ChrPtr(migr_chardata));
+       else if (!strcasecmp(el, "u_emailaddrs"))               safestrncpy(usbuf.emailaddrs, ChrPtr(migr_chardata), sizeof usbuf.emailaddrs);
+       else if (!strcasecmp(el, "u_msgnum_inboxrules"))        usbuf.msgnum_inboxrules = atol(ChrPtr(migr_chardata));
+       else if (!strcasecmp(el, "u_lastproc_inboxrules"))      usbuf.lastproc_inboxrules = atol(ChrPtr(migr_chardata));
        else return 0;
        return 1;
 }
@@ -939,7 +937,7 @@ int migr_restore_message_metadata(long msgnum, int refcount)
 
        /* Ok, here we go ... */
 
-       msg = CtdlFetchMessage(msgnum, 1, 0);
+       msg = CtdlFetchMessage(msgnum, 1);
        if (msg == NULL) {
                return 1;
        }