X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fmodules%2Fmigrate%2Fserv_migrate.c;h=ddf52aeea170e40116d9ba22c7859289dda8aede;hb=f927644354ef6b22db16a66d043ef42a056b82ee;hp=d85843dc3d5956f7285671f0a2d3c58134f52cfd;hpb=f7255e95c30ed63d97fc95e8f6e6a44ffa8cd0dc;p=citadel.git diff --git a/citadel/modules/migrate/serv_migrate.c b/citadel/modules/migrate/serv_migrate.c index d85843dc3..ddf52aeea 100644 --- a/citadel/modules/migrate/serv_migrate.c +++ b/citadel/modules/migrate/serv_migrate.c @@ -1,21 +1,15 @@ /* * This module dumps and/or loads the Citadel database in XML format. * - * Copyright (c) 1987-2010 by the citadel.org team + * Copyright (c) 1987-2012 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 of the License, or - * (at your option) any later version. + * 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. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "sysdep.h" @@ -55,12 +49,8 @@ #include "user_ops.h" #include "control.h" #include "euidindex.h" - - #include "ctdl_module.h" - - #define END_OF_MESSAGE "---eom---dbd---" char migr_tempfilename1[PATH_MAX]; @@ -68,14 +58,10 @@ char migr_tempfilename2[PATH_MAX]; FILE *migr_global_message_list; - - /* * Code which implements the export appears in this section */ - - /* * Output a string to the client with these characters escaped: & < > */ @@ -85,10 +71,10 @@ void xml_strout(char *str) { while (*c != 0) { if (*c == '\"') { - client_write(""", 4); + client_write(""", 6); } else if (*c == '\'') { - client_write("'", 4); + client_write("'", 6); } else if (*c == '<') { client_write("<", 4); @@ -373,7 +359,7 @@ void migr_export_messages(void) { migr_global_message_list = fopen(migr_tempfilename1, "r"); if (migr_global_message_list != NULL) { syslog(LOG_INFO, "Opened %s\n", migr_tempfilename1); - while ((Ctx->kill_me != 1) && + while ((Ctx->kill_me == 0) && (fgets(buf, sizeof(buf), migr_global_message_list) != NULL)) { msgnum = atol(buf); if (msgnum > 0L) { @@ -383,7 +369,7 @@ void migr_export_messages(void) { } fclose(migr_global_message_list); } - if (Ctx->kill_me != 1) + if (Ctx->kill_me == 0) syslog(LOG_INFO, "Exported %d messages.\n", count); else syslog(LOG_ERR, "Export aborted due to client disconnect! \n"); @@ -394,8 +380,6 @@ void migr_export_messages(void) { void migr_do_export(void) { - struct config *buf; - buf = &config; CitContext *Ctx; Ctx = CC; @@ -423,7 +407,6 @@ void migr_do_export(void) { cprintf("%d\n", config.c_restrict); client_write("", 17); xml_strout(config.c_site_location); client_write("\n", 19); client_write("", 10); xml_strout(config.c_sysadm); client_write("\n", 12); - cprintf("%d\n", config.c_setup_level); cprintf("%d\n", config.c_maxsessions); client_write("", 11); xml_strout(config.c_ip_addr); client_write("\n", 13); cprintf("%d\n", config.c_port_number); @@ -494,12 +477,12 @@ void migr_do_export(void) { cprintf("%d\n", CitControl.version); client_write("\n", 11); - if (Ctx->kill_me != 1) migr_export_users(); - if (Ctx->kill_me != 1) migr_export_openids(); - if (Ctx->kill_me != 1) migr_export_rooms(); - if (Ctx->kill_me != 1) migr_export_floors(); - if (Ctx->kill_me != 1) migr_export_visits(); - if (Ctx->kill_me != 1) migr_export_messages(); + if (Ctx->kill_me == 0) migr_export_users(); + if (Ctx->kill_me == 0) migr_export_openids(); + if (Ctx->kill_me == 0) migr_export_rooms(); + if (Ctx->kill_me == 0) migr_export_floors(); + if (Ctx->kill_me == 0) migr_export_visits(); + if (Ctx->kill_me == 0) migr_export_messages(); client_write("\n", 24); client_write("000\n", 4); Ctx->dont_term = 0; @@ -658,7 +641,6 @@ void migr_xml_end(void *data, const char *el) { else if (!strcasecmp(el, "c_restrict")) config.c_restrict = atoi(migr_chardata); else if (!strcasecmp(el, "c_site_location")) safestrncpy(config.c_site_location, migr_chardata, sizeof config.c_site_location); else if (!strcasecmp(el, "c_sysadm")) safestrncpy(config.c_sysadm, migr_chardata, sizeof config.c_sysadm); - else if (!strcasecmp(el, "c_setup_level")) config.c_setup_level = atoi(migr_chardata); else if (!strcasecmp(el, "c_maxsessions")) config.c_maxsessions = atoi(migr_chardata); else if (!strcasecmp(el, "c_ip_addr")) safestrncpy(config.c_ip_addr, migr_chardata, sizeof config.c_ip_addr); else if (!strcasecmp(el, "c_port_number")) config.c_port_number = atoi(migr_chardata); @@ -831,7 +813,7 @@ void migr_xml_end(void *data, const char *el) { msglist = NULL; msglist_alloc = 0; syslog(LOG_DEBUG, "Imported %d messages.\n", msgcount); - if (CtdlThreadCheckStop()) { + if (server_shutting_down) { return; } } @@ -932,7 +914,7 @@ void migr_do_import(void) { linelen = strlen(buf); strcpy(&buf[linelen++], "\n"); - if (CtdlThreadCheckStop()) + if (server_shutting_down) break; // Should we break or return? if (buf[0] == '\0') @@ -1017,6 +999,6 @@ CTDL_MODULE_INIT(migrate) CtdlRegisterProtoHook(cmd_migr, "ARTV", "Across-the-wire migration (legacy syntax)"); } - /* return our Subversion id for the Log */ + /* return our module name for the log */ return "migrate"; }