/*
* $Id$
*
- * Copyright (c) 2000-2009 by the citadel.org development team
- *
* This module dumps and/or loads the Citadel database in XML format.
*
+ * Copyright (c) 1987-2010 by the citadel.org team
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "sysdep.h"
#include "database.h"
#include "msgbase.h"
#include "user_ops.h"
-#include "room_ops.h"
#include "control.h"
#include "euidindex.h"
char *c = str;
while (*c != 0) {
- if (*c == '&') {
- client_write("&", 5);
+ if (*c == '\"') {
+ client_write(""", 4);
+ }
+ else if (*c == '\'') {
+ client_write("'", 4);
}
else if (*c == '<') {
client_write("<", 4);
else if (*c == '>') {
client_write(">", 4);
}
+ else if (*c == '&') {
+ client_write("&", 5);
+ }
else {
client_write(c, 1);
}
cprintf("<QRhighest>%ld</QRhighest>\n", buf->QRhighest);
cprintf("<QRgen>%ld</QRgen>\n", (long)buf->QRgen);
cprintf("<QRflags>%u</QRflags>\n", buf->QRflags);
- client_write("<QRdirname>", 11); xml_strout(buf->QRdirname); client_write("</QRdirname>\n", 13);
+ if (buf->QRflags & QR_DIRECTORY) {
+ client_write("<QRdirname>", 11);
+ xml_strout(buf->QRdirname);
+ client_write("</QRdirname>\n", 13);
+ }
cprintf("<QRinfo>%ld</QRinfo>\n", buf->QRinfo);
cprintf("<QRfloor>%d</QRfloor>\n", buf->QRfloor);
cprintf("<QRmtime>%ld</QRmtime>\n", (long)buf->QRmtime);
/* message list goes inside this tag */
- getroom(&CC->room, buf->QRname);
+ CtdlGetRoom(&CC->room, buf->QRname);
client_write("<room_messages>", 15);
client_write("<FRname>", 8); xml_strout(CC->room.QRname); client_write("</FRname>\n", 10);
client_write("<FRmsglist>", 11);
char cmd[SIZ];
migr_global_message_list = fopen(migr_tempfilename1, "w");
if (migr_global_message_list != NULL) {
- ForEachRoom(migr_export_rooms_backend, NULL);
+ CtdlForEachRoom(migr_export_rooms_backend, NULL);
fclose(migr_global_message_list);
}
* this will be handled by exporting the reference count, not by
* exporting the message multiple times.)
*/
- snprintf(cmd, sizeof cmd, "sort <%s >%s", migr_tempfilename1, migr_tempfilename2);
+ snprintf(cmd, sizeof cmd, "sort -n <%s >%s", migr_tempfilename1, migr_tempfilename2);
if (system(cmd) != 0) CtdlLogPrintf(CTDL_ALERT, "Error %d\n", errno);
snprintf(cmd, sizeof cmd, "uniq <%s >%s", migr_tempfilename2, migr_tempfilename1);
if (system(cmd) != 0) CtdlLogPrintf(CTDL_ALERT, "Error %d\n", errno);
for (i=0; i < MAXFLOORS; ++i) {
client_write("<floor>\n", 8);
cprintf("<f_num>%d</f_num>\n", i);
- getfloor(&qfbuf, i);
+ CtdlGetFloor(&qfbuf, i);
buf = &qfbuf;
cprintf("<f_flags>%u</f_flags>\n", buf->f_flags);
client_write("<f_name>", 8); xml_strout(buf->f_name); client_write("</f_name>\n", 10);
}
+/*
+ * Return nonzero if the supplied string contains only characters which are valid in a sequence set.
+ */
+int is_sequence_set(char *s) {
+ if (!s) return(0);
+
+ char *c = s;
+ char ch;
+ while (ch = *c++, ch) {
+ if (!strchr("0123456789*,:", ch)) {
+ return(0);
+ }
+ }
+ return(1);
+}
+
+
/*
* Traverse the visits file...
*/
void migr_export_visits(void) {
- struct visit vbuf;
+ visit vbuf;
struct cdbdata *cdbv;
cdb_rewind(CDB_VISIT);
while (cdbv = cdb_next_item(CDB_VISIT), cdbv != NULL) {
- memset(&vbuf, 0, sizeof(struct visit));
+ memset(&vbuf, 0, sizeof(visit));
memcpy(&vbuf, cdbv->ptr,
- ((cdbv->len > sizeof(struct visit)) ?
- sizeof(struct visit) : cdbv->len));
+ ((cdbv->len > sizeof(visit)) ?
+ sizeof(visit) : cdbv->len));
cdb_free(cdbv);
client_write("<visit>\n", 8);
cprintf("<v_usernum>%ld</v_usernum>\n", vbuf.v_usernum);
client_write("<v_seen>", 8);
- if (!IsEmptyStr(vbuf.v_seen)) {
+ if ( (!IsEmptyStr(vbuf.v_seen)) && (is_sequence_set(vbuf.v_seen)) ) {
xml_strout(vbuf.v_seen);
}
else {
}
client_write("</v_seen>", 9);
- client_write("<v_answered>", 12); xml_strout(vbuf.v_answered); client_write("</v_answered>\n", 14);
+ if ( (!IsEmptyStr(vbuf.v_answered)) && (is_sequence_set(vbuf.v_answered)) ) {
+ client_write("<v_answered>", 12);
+ xml_strout(vbuf.v_answered);
+ client_write("</v_answered>\n", 14);
+ }
+
cprintf("<v_flags>%u</v_flags>\n", vbuf.v_flags);
cprintf("<v_view>%d</v_view>\n", vbuf.v_view);
client_write("</visit>\n", 9);
char buf[SIZ];
long msgnum;
int count = 0;
- t_context *Ctx;
+ CitContext *Ctx;
Ctx = CC;
migr_global_message_list = fopen(migr_tempfilename1, "r");
void migr_do_export(void) {
struct config *buf;
buf = &config;
- t_context *Ctx;
+ CitContext *Ctx;
Ctx = CC;
cprintf("%d Exporting all Citadel databases.\n", LISTING_FOLLOWS);
char FRname[ROOMNAMELEN];
struct floor flbuf;
int floornum = 0;
-struct visit vbuf;
+visit vbuf;
struct MetaData smi;
long import_msgnum = 0;
char *decoded_msg = NULL;
}
if (citadel_migrate_data != 1) {
- CtdlLogPrintf(CTDL_ALERT, "Out-of-sequence tag <%s> detected. Warning: ODD-DATA!\n");
+ CtdlLogPrintf(CTDL_ALERT, "Out-of-sequence tag <%s> detected. Warning: ODD-DATA!\n", el);
return;
}
else if (!strcasecmp(el, "room")) memset(&qrbuf, 0, sizeof (struct ctdlroom));
else if (!strcasecmp(el, "room_messages")) memset(FRname, 0, sizeof FRname);
else if (!strcasecmp(el, "floor")) memset(&flbuf, 0, sizeof (struct floor));
- else if (!strcasecmp(el, "visit")) memset(&vbuf, 0, sizeof (struct visit));
+ else if (!strcasecmp(el, "visit")) memset(&vbuf, 0, sizeof (visit));
else if (!strcasecmp(el, "message")) {
memset(&smi, 0, sizeof (struct MetaData));
}
-void migr_xml_end(void *data, const char *el, const char **attr) {
+void migr_xml_end(void *data, const char *el) {
char *ptr;
int msgcount = 0;
long msgnum = 0L;
}
if (citadel_migrate_data != 1) {
- CtdlLogPrintf(CTDL_ALERT, "Out-of-sequence tag <%s> detected. Warning: ODD-DATA!\n");
+ CtdlLogPrintf(CTDL_ALERT, "Out-of-sequence tag <%s> detected. Warning: ODD-DATA!\n", el);
return;
}
else if (!strcasecmp(el, "u_fullname")) safestrncpy(usbuf.fullname, migr_chardata, sizeof usbuf.fullname);
else if (!strcasecmp(el, "user")) {
- putuser(&usbuf);
+ CtdlPutUser(&usbuf);
CtdlLogPrintf(CTDL_INFO, "Imported user: %s\n", usbuf.fullname);
}
else if (!strcasecmp(el, "QRdefaultview")) qrbuf.QRdefaultview = atoi(migr_chardata);
else if (!strcasecmp(el, "room")) {
- putroom(&qrbuf);
+ CtdlPutRoom(&qrbuf);
CtdlLogPrintf(CTDL_INFO, "Imported room: %s\n", qrbuf.QRname);
}
}
}
if (msgcount > 0) {
- CtdlSaveMsgPointersInRoom(FRname, msglist, msgcount, 0, NULL);
+ CtdlSaveMsgPointersInRoom(FRname, msglist, msgcount, 0, NULL, 1);
}
free(msglist);
msglist = NULL;
else if (!strcasecmp(el, "f_ep_expire_value")) flbuf.f_ep.expire_value = atoi(migr_chardata);
else if (!strcasecmp(el, "floor")) {
- putfloor(&flbuf, floornum);
+ CtdlPutFloor(&flbuf, floornum);
CtdlLogPrintf(CTDL_INFO, "Imported floor #%d (%s)\n", floornum, flbuf.f_name);
}