* Explanation of <progress> tags:
*
* 0% nothing
- * 1% finished exporting config
- * 2% finished exporting control
+ * 2% finished exporting configuration
* 7% finished exporting users
* 12% finished exporting openids
* 17% finished exporting rooms
#include "database.h"
#include "msgbase.h"
#include "user_ops.h"
-#include "control.h"
#include "euidindex.h"
#include "ctdl_module.h"
char migr_tempfilename2[PATH_MAX];
FILE *migr_global_message_list;
int total_msgs = 0;
-int we_are_currently_importing_config = 0;
/*
* Code which implements the export appears in this section
}
+void migr_export_configs(void) {
+ struct cdbdata *cdbcfg;
+ int keylen = 0;
+ char *key = NULL;
+ char *value = NULL;
+
+ cdb_rewind(CDB_CONFIG);
+ while (cdbcfg = cdb_next_item(CDB_CONFIG), cdbcfg != NULL) {
+
+ keylen = strlen(cdbcfg->ptr);
+ key = cdbcfg->ptr;
+ value = cdbcfg->ptr + keylen + 1;
+
+ client_write("<config key=\"", 13);
+ xml_strout(key);
+ client_write("\">", 2);
+ xml_strout(value);
+ client_write("</config>\n", 10);
+ cdb_free(cdbcfg);
+ }
+}
+
+
void migr_export_messages(void) {
cprintf("<version>%d</version>\n", REV_LEVEL);
cprintf("<progress>%d</progress>\n", 0);
- /* export the config file (this is done using x-macros) */
- client_write("<config>\n", 9);
-
- /* FIXME FIXME FIXME FIXME FIXME write a config exporter and put it here */
-
- client_write("</config>\n", 10);
- cprintf("<progress>%d</progress>\n", 1);
-
- /* Export the control file */
- get_control();
- client_write("<control>\n", 10);
- cprintf("<control_highest>%ld</control_highest>\n", CitControl.MMhighest);
- cprintf("<control_flags>%u</control_flags>\n", CitControl.MMflags);
- cprintf("<control_nextuser>%ld</control_nextuser>\n", CitControl.MMnextuser);
- cprintf("<control_nextroom>%ld</control_nextroom>\n", CitControl.MMnextroom);
- cprintf("<control_version>%d</control_version>\n", CitControl.MM_hosted_upgrade_level);
- client_write("</control>\n", 11);
+ /* export the configuration database */
+ migr_export_configs();
cprintf("<progress>%d</progress>\n", 2);
-
+
if (Ctx->kill_me == 0) migr_export_users();
cprintf("<progress>%d</progress>\n", 7);
if (Ctx->kill_me == 0) migr_export_openids();
import_msgnum = 0;
}
else if (!strcasecmp(el, "config")) {
- we_are_currently_importing_config = 1;
+ syslog(LOG_DEBUG, "\033[31m IMPORT OF CONFIG START ELEMENT FIXME\033\0m");
}
}
-int migr_config(void *data, const char *el)
-{
-
- /* FIXME FIXME FIXME FIXME FIXME write a config importer and put it here */
-
- return 0; /* if string was not found */
- return 1; /* if string was found */
-}
-
-
-int migr_controlrecord(void *data, const char *el)
-{
- if (!strcasecmp(el, "control_highest")) CitControl.MMhighest = atol(ChrPtr(migr_chardata));
- else if (!strcasecmp(el, "control_flags")) CitControl.MMflags = atoi(ChrPtr(migr_chardata));
- else if (!strcasecmp(el, "control_nextuser")) CitControl.MMnextuser = atol(ChrPtr(migr_chardata));
- else if (!strcasecmp(el, "control_nextroom")) CitControl.MMnextroom = atol(ChrPtr(migr_chardata));
- else if (!strcasecmp(el, "control_version")) CitControl.MM_hosted_upgrade_level = atoi(ChrPtr(migr_chardata));
-
- else if (!strcasecmp(el, "control")) {
- CitControl.MMfulltext = (-1L); /* always flush */
- put_control();
- syslog(LOG_INFO, "Completed import of control record\n");
- }
- else return 0;
- return 1;
-
-}
-
-
int migr_userrecord(void *data, const char *el)
{
if (!strcasecmp(el, "u_version")) usbuf.version = atoi(ChrPtr(migr_chardata));
if (!strcasecmp(el, "config"))
{
- /* config.c_enable_fulltext = 0; always disable */
- we_are_currently_importing_config = 0;
- syslog(LOG_INFO, "Completed import of server configuration\n");
+ syslog(LOG_DEBUG, "\033[31m IMPORT OF CONFIG END ELEMENT FIXME\033\0m");
+ CtdlSetConfigInt("c_enable_fulltext", 0); /* always disable FIXME put this somewhere more appropriate */
}
- else if (we_are_currently_importing_config)
- {
- migr_config(data, el);
- }
-
- /*** CONTROL ***/
- else if ((!strncasecmp(el, HKEY("control"))) &&
- migr_controlrecord(data, el))
- ; /* Nothing to do anymore */
/*** USER ***/
else if ((!strncasecmp(el, HKEY("u_"))) &&
migr_userrecord(data, el))
if (CtdlTrySingleUser())
{
+ CtdlDisableHouseKeeping();
CtdlMakeTempFileName(migr_tempfilename1, sizeof migr_tempfilename1);
CtdlMakeTempFileName(migr_tempfilename2, sizeof migr_tempfilename2);
unlink(migr_tempfilename1);
unlink(migr_tempfilename2);
-
+
+ CtdlEnableHouseKeeping();
CtdlEndSingleUser();
}
else