/*
* Explanation of <progress> tags:
*
- * 0% nothing
- * 2% finished exporting configuration
- * 7% finished exporting users
- * 12% finished exporting openids
- * 17% finished exporting rooms
- * 18% finished exporting floors
- * 25% finished exporting visits
- * 100% finished exporting messages
+ * 0% started
+ * 2% finished exporting configuration
+ * 7% finished exporting users
+ * 12% finished exporting openids
+ * 17% finished exporting rooms
+ * 18% finished exporting floors
+ * 25% finished exporting visits
+ * 26-99% exporting messages
+ * 100% finished exporting messages
+ *
+ * These tags are inserted into the XML stream to give the reader an approximation of its progress.
*/
#include "sysdep.h"
void migr_export_room_msg(long msgnum, void *userdata) {
- cprintf("%ld\n", msgnum);
+ static int count = 0;
+
+ cprintf("%ld,", msgnum);
+ if (++count%10==0) {
+ cprintf("\n");
+ }
fprintf(migr_global_message_list, "%ld\n", msgnum);
}
void migr_export_rooms_backend(struct ctdlroom *buf, void *data) {
client_write(HKEY("<room>\n"));
- client_write(HKEY("<QRname>")); xml_strout(buf->QRname); client_write(HKEY("</QRname>\n"));
- client_write(HKEY("<QRpasswd>")); xml_strout(buf->QRpasswd); client_write(HKEY("</QRpasswd>\n"));
+ client_write(HKEY("<QRname>"));
+ xml_strout(buf->QRname);
+ client_write(HKEY("</QRname>\n"));
+ client_write(HKEY("<QRpasswd>"));
+ xml_strout(buf->QRpasswd);
+ client_write(HKEY("</QRpasswd>\n"));
cprintf("<QRroomaide>%ld</QRroomaide>\n", buf->QRroomaide);
cprintf("<QRhighest>%ld</QRhighest>\n", buf->QRhighest);
cprintf("<QRgen>%ld</QRgen>\n", (long)buf->QRgen);
client_write(HKEY("</room>\n"));
/* message list goes inside this tag */
-
CtdlGetRoom(&CC->room, buf->QRname);
client_write(HKEY("<room_messages>"));
- client_write(HKEY("<FRname>")); xml_strout(CC->room.QRname); client_write(HKEY("</FRname>\n"));
- client_write(HKEY("<FRmsglist>"));
+ client_write(HKEY("<FRname>"));
+ xml_strout(buf->QRname); // buf->QRname rather than CC->room.QRname to guarantee consistency
+ client_write(HKEY("</FRname>\n"));
+ client_write(HKEY("<FRmsglist>\n"));
CtdlForEachMessage(MSGS_ALL, 0L, NULL, NULL, NULL, migr_export_room_msg, NULL);
client_write(HKEY("</FRmsglist>\n"));
client_write(HKEY("</room_messages>\n"));
-
-
}
* exporting the message multiple times.)
*/
snprintf(cmd, sizeof cmd, "sort -n <%s >%s", migr_tempfilename1, migr_tempfilename2);
- if (system(cmd) != 0) syslog(LOG_ALERT, "Error %d", errno);
+ if (system(cmd) != 0) syslog(LOG_ERR, "Error %d", errno);
snprintf(cmd, sizeof cmd, "uniq <%s >%s", migr_tempfilename2, migr_tempfilename1);
- if (system(cmd) != 0) syslog(LOG_ALERT, "Error %d", errno);
+ if (system(cmd) != 0) syslog(LOG_ERR, "Error %d", errno);
snprintf(cmd, sizeof cmd, "wc -l %s", migr_tempfilename1);
/*
* This callback stores up the data which appears in between tags.
*/
-void migr_xml_chardata(void *data, const XML_Char *s, int len)
-{
+void migr_xml_chardata(void *data, const XML_Char *s, int len) {
+
+ char aaa[65536];
+ memcpy(aaa, s, len);
+ aaa[len] = 0;
+ syslog(LOG_DEBUG, "chardata <\033[35m%s\033[0m>", aaa);
+
StrBufAppendBufPlain(migr_chardata, s, len, 0);
}
}
if (citadel_migrate_data != 1) {
- syslog(LOG_ALERT, "Out-of-sequence tag <%s> detected. Warning: ODD-DATA!", el);
+ syslog(LOG_ERR, "Out-of-sequence tag <%s> detected. Warning: ODD-DATA!", el);
return;
}
}
-int migr_userrecord(void *data, const char *el)
-{
+int migr_userrecord(void *data, const char *el) {
if (!strcasecmp(el, "u_version")) usbuf.version = atoi(ChrPtr(migr_chardata));
else if (!strcasecmp(el, "u_uid")) usbuf.uid = atol(ChrPtr(migr_chardata));
else if (!strcasecmp(el, "u_password")) safestrncpy(usbuf.password, ChrPtr(migr_chardata), sizeof usbuf.password);
}
-int migr_roomrecord(void *data, const char *el)
-{
+int migr_roomrecord(void *data, const char *el) {
if (!strcasecmp(el, "QRname")) safestrncpy(qrbuf.QRname, ChrPtr(migr_chardata), sizeof qrbuf.QRname);
else if (!strcasecmp(el, "QRpasswd")) safestrncpy(qrbuf.QRpasswd, ChrPtr(migr_chardata), sizeof qrbuf.QRpasswd);
else if (!strcasecmp(el, "QRroomaide")) qrbuf.QRroomaide = atol(ChrPtr(migr_chardata));
}
-int migr_floorrecord(void *data, const char *el)
-{
+int migr_floorrecord(void *data, const char *el) {
if (!strcasecmp(el, "f_num")) floornum = atoi(ChrPtr(migr_chardata));
else if (!strcasecmp(el, "f_flags")) flbuf.f_flags = atoi(ChrPtr(migr_chardata));
else if (!strcasecmp(el, "f_name")) safestrncpy(flbuf.f_name, ChrPtr(migr_chardata), sizeof flbuf.f_name);
}
-int migr_visitrecord(void *data, const char *el)
-{
+int migr_visitrecord(void *data, const char *el) {
if (!strcasecmp(el, "v_roomnum")) vbuf.v_roomnum = atol(ChrPtr(migr_chardata));
else if (!strcasecmp(el, "v_roomgen")) vbuf.v_roomgen = atol(ChrPtr(migr_chardata));
else if (!strcasecmp(el, "v_usernum")) vbuf.v_usernum = atol(ChrPtr(migr_chardata));
}
-void migr_xml_end(void *data, const char *el)
-{
+void migr_xml_end(void *data, const char *el) {
const char *ptr;
int msgcount = 0;
long msgnum = 0L;
}
if (citadel_migrate_data != 1) {
- syslog(LOG_ALERT, "Out-of-sequence tag <%s> detected. Warning: ODD-DATA!", el);
+ syslog(LOG_ERR, "Out-of-sequence tag <%s> detected. Warning: ODD-DATA!", el);
return;
}
/*** CONFIG ***/
- if (!strcasecmp(el, "config"))
- {
+ if (!strcasecmp(el, "config")) {
syslog(LOG_DEBUG, "Imported config key=%s", ikey);
if (ikey != NULL) {
/*** ROOM MESSAGE POINTERS ***/
- else if (!strcasecmp(el, "FRname")) safestrncpy(FRname, ChrPtr(migr_chardata), sizeof FRname);
+ else if (!strcasecmp(el, "FRname")) {
+ safestrncpy(FRname, ChrPtr(migr_chardata), sizeof FRname);
+ }
else if (!strcasecmp(el, "FRmsglist")) {
if (!IsEmptyStr(FRname)) {
syslog(LOG_DEBUG, "Message list for: %s", FRname);
ptr = ChrPtr(migr_chardata);
+ syslog(LOG_DEBUG, "\033[31m%s\033[0m", ptr);
while (*ptr != 0) {
while ((*ptr != 0) && (!isdigit(*ptr))) {
++ptr;
msglist = realloc(msglist, sizeof(long) * msglist_alloc);
}
msglist[msgcount++] = msgnum;
+ syslog(LOG_DEBUG, "\033[32mmsgnum %ld , count is now %d\033[0m", msgnum, msgcount);
}
}
while ((*ptr != 0) && (isdigit(*ptr))) {
else if (!strcasecmp(el, "msg_meta_rfc822_length")) smi.meta_rfc822_length = atoi(ChrPtr(migr_chardata));
else if (!strcasecmp(el, "msg_meta_content_type")) safestrncpy(smi.meta_content_type, ChrPtr(migr_chardata), sizeof smi.meta_content_type);
- else if (!strcasecmp(el, "msg_text"))
- {
+ else if (!strcasecmp(el, "msg_text")) {
long rc;
struct CtdlMessage *msg;
StrBuf *PlainMessageBuf = NULL;
HashList *UsedMessageIDS = NULL;
-int migr_restore_message_metadata(long msgnum, int refcount)
-{
+int migr_restore_message_metadata(long msgnum, int refcount) {
struct MetaData smi;
struct CtdlMessage *msg;
char *mptr = NULL;
);
PutMetaData(&smi);
-
CM_Free(msg);
-
return 0;
}
void migr_check_rooms_backend(struct ctdlroom *buf, void *data) {
-
/* message list goes inside this tag */
-
CtdlGetRoom(&CC->room, buf->QRname);
CtdlForEachMessage(MSGS_ALL, 0L, NULL, NULL, NULL, migr_check_room_msg, NULL);
}
* exporting the message multiple times.)
*/
snprintf(cmd, sizeof cmd, "sort -n <%s >%s", migr_tempfilename1, migr_tempfilename2);
- if (system(cmd) != 0) syslog(LOG_ALERT, "Error %d", errno);
+ if (system(cmd) != 0) syslog(LOG_ERR, "Error %d", errno);
RoomNames = NewStrBuf();
Ctx = CC;
//
// Here's where our NNTP session begins its happy day.
//
-void nntp_greeting(void)
-{
+void nntp_greeting(void) {
strcpy(CC->cs_clientname, "NNTP session");
CC->cs_flags |= CS_STEALTH;
//
// implements the STARTTLS command
//
-void nntp_starttls(void)
-{
+void nntp_starttls(void) {
char ok_response[SIZ];
char nosup_response[SIZ];
char error_response[SIZ];
//
// Implements the CAPABILITY command
//
-void nntp_capabilities(void)
-{
+void nntp_capabilities(void) {
cprintf("101 Capability list:\r\n");
cprintf("IMPLEMENTATION Citadel %d\r\n", REV_LEVEL);
cprintf("VERSION 2\r\n");
//
// Implements the QUIT command
//
-void nntp_quit(void)
-{
+void nntp_quit(void) {
cprintf("221 Goodbye...\r\n");
CC->kill_me = KILLME_CLIENT_LOGGED_OUT;
}
//
// Implements the AUTHINFO USER command (RFC 4643)
//
-void nntp_authinfo_user(const char *username)
-{
+void nntp_authinfo_user(const char *username) {
int a = CtdlLoginExistingUser(username);
switch (a) {
case login_already_logged_in:
//
// Implements the AUTHINFO PASS command (RFC 4643)
//
-void nntp_authinfo_pass(const char *buf)
-{
+void nntp_authinfo_pass(const char *buf) {
int a;
a = CtdlTryPassword(buf, strlen(buf));
//
// Called once per room by nntp_newgroups() to qualify and possibly output a single room
//
-void nntp_newgroups_backend(struct ctdlroom *qrbuf, void *data)
-{
+void nntp_newgroups_backend(struct ctdlroom *qrbuf, void *data) {
int ra;
int view;
time_t thetime = *(time_t *)data;
//
// Called once per room by nntp_list() to qualify and possibly output a single room
//
-void nntp_list_backend(struct ctdlroom *qrbuf, void *data)
-{
+void nntp_list_backend(struct ctdlroom *qrbuf, void *data) {
int ra;
int view;
struct nntp_list_data *nld = (struct nntp_list_data *)data;
// The memory for the returned string is pwnz0red by the caller.
//
char *message_id_from_msgnum(long msgnum) {
-
char *fetched_message_id = NULL;
CC->redirect_buffer = NewStrBufPlain(NULL, SIZ);
CtdlOutputMsg(msgnum,
//
// Main command loop for NNTP server sessions.
//
-void nntp_command_loop(void)
-{
+void nntp_command_loop(void) {
StrBuf *Cmd = NewStrBuf();
char cmdname[16];
// This cleanup function blows away the temporary memory used by
// the NNTP server.
//
-void nntp_cleanup_function(void)
-{
+void nntp_cleanup_function(void) {
/* Don't do this stuff if this is not an NNTP session! */
if (CC->h_command_function != nntp_command_loop) return;