/*
* This module dumps and/or loads the Citadel database in XML format.
*
- * Copyright (c) 1987-2020 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 "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 *
******************************************************************************/
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;
}
* Import begins here
*/
void migr_do_import(void) {
- StrBuf *Buf;
XML_Parser xp;
- int Finished = 0;
+ char buf[SIZ];
unbuffer_output();
migr_chardata = NewStrBufPlain(NULL, SIZ * 20);
migr_MsgData = NewStrBufPlain(NULL, SIZ * 20);
- Buf = NewStrBufPlain(NULL, SIZ);
xp = XML_ParserCreate(NULL);
if (!xp) {
cprintf("%d Failed to create XML parser instance\n", ERROR+INTERNAL_ERROR);
client_set_inbound_buf(SIZ * 10);
- while (!Finished && client_read_random_blob(Buf, -1) >= 0) {
- if ((StrLength(Buf) > 4) && !strcmp(ChrPtr(Buf) + StrLength(Buf) - 4, "000\n")) {
- Finished = 1;
- StrBufCutAt(Buf, StrLength(Buf) - 4, NULL);
- }
+ while (client_getln(buf, sizeof buf) >= 0 && strcmp(buf, "000")) {
+ XML_Parse(xp, buf, strlen(buf), 0);
if (server_shutting_down)
break; // Should we break or return?
-
- if (StrLength(Buf) == 0)
- continue;
-
- XML_Parse(xp, ChrPtr(Buf), StrLength(Buf), 0);
- FlushStrBuf(Buf);
}
XML_Parse(xp, "", 0, 1);
XML_ParserFree(xp);
- FreeStrBuf(&Buf);
FreeStrBuf(&migr_chardata);
FreeStrBuf(&migr_MsgData);
rebuild_euid_index();
int migr_restore_message_metadata(long msgnum, int refcount)
{
- CitContext *CCC = MyContext();
struct MetaData smi;
struct CtdlMessage *msg;
char *mptr = NULL;
}
}
- CCC->redirect_buffer = PlainMessageBuf;
+ CC->redirect_buffer = PlainMessageBuf;
CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_ALL, 0, 1, QP_EADDR);
- smi.meta_rfc822_length = StrLength(CCC->redirect_buffer);
- CCC->redirect_buffer = NULL;
+ smi.meta_rfc822_length = StrLength(CC->redirect_buffer);
+ CC->redirect_buffer = NULL;
syslog(LOG_INFO,
"Setting message #%ld meta data to: refcount=%d, bodylength=%ld, content-type: %s",