4 * This is the "Art Vandelay" module. It is an importer/exporter.
16 #include <sys/types.h>
18 #if TIME_WITH_SYS_TIME
19 # include <sys/time.h>
23 # include <sys/time.h>
33 #include <libcitadel.h>
36 #include "citserver.h"
44 #include "euidindex.h"
47 #include "ctdl_module.h"
52 #define END_OF_MESSAGE "---eom---dbd---"
54 char artv_tempfilename1[PATH_MAX];
55 char artv_tempfilename2[PATH_MAX];
56 FILE *artv_global_message_list;
58 void artv_export_users_backend(struct ctdluser *buf, void *data) {
59 client_write("user\n", 5);
61 #include "artv_serialize.h"
62 #include "dtds/user-defs.h"
63 #include "undef_data.h"
65 cprintf("%d\n", buf->version);
66 cprintf("%ld\n", (long)buf->uid);
67 cprintf("%s\n", buf->password);
68 cprintf("%u\n", buf->flags);
69 cprintf("%ld\n", buf->timescalled);
70 cprintf("%ld\n", buf->posted);
71 cprintf("%d\n", buf->axlevel);
72 cprintf("%ld\n", buf->usernum);
73 cprintf("%ld\n", (long)buf->lastcall);
74 cprintf("%d\n", buf->USuserpurge);
75 cprintf("%s\n", buf->fullname);
76 cprintf("%d\n", buf->USscreenwidth);
77 cprintf("%d\n", buf->USscreenheight);
80 void artv_dump_users_backend(struct ctdluser *buf, void *data) {
81 client_write("user\n", 5);
83 #include "artv_dump.h"
84 #include "dtds/user-defs.h"
85 #include "undef_data.h"
90 INLINE int cprintdot (long *iterations)
94 retval += client_write(".", 1);
96 if ((*iterations) % 64 == 0)
97 retval += client_write("\n", 1);
103 void artv_export_users(void) {
104 ForEachUser(artv_export_users_backend, NULL);
107 void artv_dump_users(void) {
108 ForEachUser(artv_dump_users_backend, NULL);
112 void artv_export_room_msg(long msgnum, void *userdata) {
113 cprintf("%ld\n", msgnum);
114 fprintf(artv_global_message_list, "%ld\n", msgnum);
117 void artv_dump_room_msg(long msgnum, void *userdata) {
118 cprintf(" msgnum: %ld\n", msgnum);
119 fprintf(artv_global_message_list, "%ld\n", msgnum);
124 void artv_export_rooms_backend(struct ctdlroom *buf, void *data) {
125 client_write("room\n", 5);
127 #include "artv_serialize.h"
128 #include "dtds/room-defs.h"
129 #include "undef_data.h"
131 cprintf("%s\n", buf->QRname);
132 cprintf("%s\n", buf->QRpasswd);
133 cprintf("%ld\n", buf->QRroomaide);
134 cprintf("%ld\n", buf->QRhighest);
135 cprintf("%ld\n", (long)buf->QRgen);
136 cprintf("%u\n", buf->QRflags);
137 cprintf("%s\n", buf->QRdirname);
138 cprintf("%ld\n", buf->QRinfo);
139 cprintf("%d\n", buf->QRfloor);
140 cprintf("%ld\n", (long)buf->QRmtime);
141 cprintf("%d\n", buf->QRep.expire_mode);
142 cprintf("%d\n", buf->QRep.expire_value);
143 cprintf("%ld\n", buf->QRnumber);
144 cprintf("%d\n", buf->QRorder);
145 cprintf("%u\n", buf->QRflags2);
146 cprintf("%d\n", buf->QRdefaultview);
148 getroom(&CC->room, buf->QRname);
149 /* format of message list export is all message numbers output
150 * one per line terminated by a 0.
153 getroom(&CC->room, buf->QRname);
154 /* format of message list export is all message numbers output
155 * one per line terminated by a 0.
157 CtdlForEachMessage(MSGS_ALL, 0L, NULL, NULL, NULL,
158 artv_export_room_msg, NULL);
163 void artv_dump_rooms_backend(struct ctdlroom *buf, void *data) {
164 client_write("room\n", 5);
166 #include "artv_dump.h"
167 #include "dtds/room-defs.h"
168 #include "undef_data.h"
170 getroom(&CC->room, buf->QRname);
171 /* format of message list export is all message numbers output
172 * one per line terminated by a 0.
175 getroom(&CC->room, buf->QRname);
176 /* format of message list export is all message numbers output
177 * one per line terminated by a 0.
179 CtdlForEachMessage(MSGS_ALL, 0L, NULL, NULL, NULL,
180 artv_dump_room_msg, NULL);
187 void artv_export_rooms(void) {
189 artv_global_message_list = fopen(artv_tempfilename1, "w");
190 if (artv_global_message_list != NULL) {
191 ForEachRoom(artv_export_rooms_backend, NULL);
192 fclose(artv_global_message_list);
196 * Process the 'global' message list. (Sort it and remove dups.
197 * Dups are ok because a message may be in more than one room, but
198 * this will be handled by exporting the reference count, not by
199 * exporting the message multiple times.)
201 snprintf(cmd, sizeof cmd, "sort <%s >%s", artv_tempfilename1, artv_tempfilename2);
203 snprintf(cmd, sizeof cmd, "uniq <%s >%s", artv_tempfilename2, artv_tempfilename1);
207 void artv_dump_rooms(void) {
209 artv_global_message_list = fopen(artv_tempfilename1, "w");
210 if (artv_global_message_list != NULL) {
211 ForEachRoom(artv_dump_rooms_backend, NULL);
212 fclose(artv_global_message_list);
216 * Process the 'global' message list. (Sort it and remove dups.
217 * Dups are ok because a message may be in more than one room, but
218 * this will be handled by exporting the reference count, not by
219 * exporting the message multiple times.)
221 snprintf(cmd, sizeof cmd, "sort <%s >%s", artv_tempfilename1, artv_tempfilename2);
223 snprintf(cmd, sizeof cmd, "uniq <%s >%s", artv_tempfilename2, artv_tempfilename1);
228 void artv_export_floors(void) {
229 struct floor qfbuf, *buf;
232 for (i=0; i < MAXFLOORS; ++i) {
233 client_write("floor\n", 6);
238 #include "artv_serialize.h"
239 #include "dtds/floor-defs.h"
240 #include "undef_data.h"
242 cprintf("%u\n", buf->f_flags);
243 cprintf("%s\n", buf->f_name);
244 cprintf("%d\n", buf->f_ref_count);
245 cprintf("%d\n", buf->f_ep.expire_mode);
246 cprintf("%d\n", buf->f_ep.expire_value);
251 void artv_dump_floors(void) {
252 struct floor qfbuf, *buf;
255 for (i=0; i < MAXFLOORS; ++i) {
256 client_write("floor\n", 6);
261 #include "artv_serialize.h"
262 #include "dtds/floor-defs.h"
263 #include "undef_data.h"
272 * Traverse the visits file...
274 void artv_export_visits(void) {
276 struct cdbdata *cdbv;
278 cdb_rewind(CDB_VISIT);
280 while (cdbv = cdb_next_item(CDB_VISIT), cdbv != NULL) {
281 memset(&vbuf, 0, sizeof(struct visit));
282 memcpy(&vbuf, cdbv->ptr,
283 ((cdbv->len > sizeof(struct visit)) ?
284 sizeof(struct visit) : cdbv->len));
287 client_write("visit\n", 6);
288 cprintf("%ld\n", vbuf.v_roomnum);
289 cprintf("%ld\n", vbuf.v_roomgen);
290 cprintf("%ld\n", vbuf.v_usernum);
292 if (!IsEmptyStr(vbuf.v_seen)) {
293 cprintf("%s\n", vbuf.v_seen);
296 cprintf("%ld\n", vbuf.v_lastseen);
299 cprintf("%s\n", vbuf.v_answered);
300 cprintf("%u\n", vbuf.v_flags);
301 cprintf("%d\n", vbuf.v_view);
306 * Traverse the visits file...
308 void artv_dump_visits(void) {
310 struct cdbdata *cdbv;
312 cdb_rewind(CDB_VISIT);
314 while (cdbv = cdb_next_item(CDB_VISIT), cdbv != NULL) {
315 memset(&vbuf, 0, sizeof(struct visit));
316 memcpy(&vbuf, cdbv->ptr,
317 ((cdbv->len > sizeof(struct visit)) ?
318 sizeof(struct visit) : cdbv->len));
321 client_write("---visit---\n", 12);
322 cprintf(" Room-Num: %ld\n", vbuf.v_roomnum);
323 cprintf(" Room-Gen%ld\n", vbuf.v_roomgen);
324 cprintf(" User-Num%ld\n", vbuf.v_usernum);
326 if (!IsEmptyStr(vbuf.v_seen)) {
327 cprintf(" Seen: %s\n", vbuf.v_seen);
330 cprintf(" LastSeen: %ld\n", vbuf.v_lastseen);
333 cprintf(" Answered: %s\n", vbuf.v_answered);
334 cprintf(" Flags: %u\n", vbuf.v_flags);
335 cprintf(" View: %d\n", vbuf.v_view);
340 void artv_export_message(long msgnum) {
342 struct CtdlMessage *msg;
346 char tempfile[PATH_MAX];
348 msg = CtdlFetchMessage(msgnum, 1);
349 if (msg == NULL) return; /* fail silently */
351 client_write("message\n", 8);
352 GetMetaData(&smi, msgnum);
353 cprintf("%ld\n", msgnum);
354 cprintf("%d\n", smi.meta_refcount);
355 cprintf("%s\n", smi.meta_content_type);
357 serialize_message(&smr, msg);
358 CtdlFreeMessage(msg);
360 /* write it in base64 */
361 CtdlMakeTempFileName(tempfile, sizeof tempfile);
362 snprintf(buf, sizeof buf, "%s -e >%s", file_base64, tempfile);
363 fp = popen(buf, "w");
364 fwrite(smr.ser, smr.len, 1, fp);
369 fp = fopen(tempfile, "r");
372 while (fgets(buf, sizeof(buf), fp) != NULL) {
373 buf[strlen(buf)-1] = 0;
374 cprintf("%s\n", buf);
378 cprintf("%s\n", END_OF_MESSAGE);
381 void artv_dump_message(long msgnum) {
383 struct CtdlMessage *msg;
385 msg = CtdlFetchMessage(msgnum, 1);
386 if (msg == NULL) return; /* fail silently */
388 client_write("message\n", 8);
389 GetMetaData(&smi, msgnum);
390 cprintf(" MessageNum: %ld\n", msgnum);
391 cprintf(" MetaRefcount: %d\n", smi.meta_refcount);
392 cprintf(" MetaContentType: %s\n", smi.meta_content_type);
394 dump_message(msg, 80);
395 CtdlFreeMessage(msg);
397 cprintf("%s\n", END_OF_MESSAGE);
402 void artv_export_openids(void) {
403 struct cdbdata *cdboi;
406 cdb_rewind(CDB_OPENID);
407 while (cdboi = cdb_next_item(CDB_OPENID), cdboi != NULL) {
408 if (cdboi->len > sizeof(long)) {
409 client_write("openid\n", 7);
410 memcpy(&usernum, cdboi->ptr, sizeof(long));
411 cprintf("%s\n", (cdboi->ptr)+sizeof(long) );
412 cprintf("%ld\n", usernum);
421 void artv_export_messages(void) {
428 artv_global_message_list = fopen(artv_tempfilename1, "r");
429 if (artv_global_message_list != NULL) {
430 CtdlLogPrintf(CTDL_INFO, "Opened %s\n", artv_tempfilename1);
431 while ((Ctx->kill_me != 1) &&
432 (fgets(buf, sizeof(buf), artv_global_message_list) != NULL)) {
435 artv_export_message(msgnum);
439 fclose(artv_global_message_list);
441 if (Ctx->kill_me != 1)
442 CtdlLogPrintf(CTDL_INFO, "Exported %d messages.\n", count);
444 CtdlLogPrintf(CTDL_ERR, "Export aborted due to client disconnect! \n");
447 void artv_dump_messages(void) {
454 artv_global_message_list = fopen(artv_tempfilename1, "r");
455 if (artv_global_message_list != NULL) {
456 CtdlLogPrintf(CTDL_INFO, "Opened %s\n", artv_tempfilename1);
457 while ((Ctx->kill_me != 1) &&
458 (fgets(buf, sizeof(buf), artv_global_message_list) != NULL)) {
461 artv_dump_message(msgnum);
465 fclose(artv_global_message_list);
467 if (Ctx->kill_me != 1)
468 CtdlLogPrintf(CTDL_INFO, "Exported %d messages.\n", count);
470 CtdlLogPrintf(CTDL_ERR, "Export aborted due to client disconnect! \n");
476 void artv_do_export(void) {
482 cprintf("%d Exporting all Citadel databases.\n", LISTING_FOLLOWS);
484 cprintf("version\n%d\n", REV_LEVEL);
486 /* export the config file (this is done using x-macros) */
487 client_write("config\n", 7);
489 #include "artv_serialize.h"
490 #include "dtds/config-defs.h"
491 #include "undef_data.h"
492 client_write("\n", 1);
494 /* Export the control file */
496 client_write("control\n", 8);
497 cprintf("%ld\n", CitControl.MMhighest);
498 cprintf("%u\n", CitControl.MMflags);
499 cprintf("%ld\n", CitControl.MMnextuser);
500 cprintf("%ld\n", CitControl.MMnextroom);
501 cprintf("%d\n", CitControl.version);
502 if (Ctx->kill_me != 1)
504 if (Ctx->kill_me != 1)
505 artv_export_openids();
506 if (Ctx->kill_me != 1)
508 if (Ctx->kill_me != 1)
509 artv_export_floors();
510 if (Ctx->kill_me != 1)
511 artv_export_visits();
512 if (Ctx->kill_me != 1)
513 artv_export_messages();
515 client_write("000\n", 4);
518 void artv_do_dump(void) {
524 cprintf("%d dumping Citadel structures.\n", LISTING_FOLLOWS);
526 cprintf("version\n%d\n", REV_LEVEL);
528 /* export the config file (this is done using x-macros) */
529 client_write("config\n", 7);
531 #include "artv_dump.h"
532 #include "dtds/config-defs.h"
533 #include "undef_data.h"
535 /* Export the control file */
537 client_write("control\n", 8);
538 cprintf(" MMhighest: %ld\n", CitControl.MMhighest);
539 cprintf(" MMflags: %u\n", CitControl.MMflags);
540 cprintf(" MMnextuser: %ld\n", CitControl.MMnextuser);
541 cprintf(" MMnextroom: %ld\n", CitControl.MMnextroom);
542 cprintf(" version: %d\n\n", CitControl.version);
543 if (Ctx->kill_me != 1)
545 if (Ctx->kill_me != 1)
547 if (Ctx->kill_me != 1)
549 if (Ctx->kill_me != 1)
551 if (Ctx->kill_me != 1)
552 artv_dump_messages();
554 client_write("000\n", 4);
559 void artv_import_config(void) {
564 CtdlLogPrintf(CTDL_DEBUG, "Importing config file\n");
566 #include "artv_deserialize.h"
567 #include "dtds/config-defs.h"
568 #include "undef_data.h"
570 config.c_enable_fulltext = 0; /* always disable */
572 CtdlLogPrintf(CTDL_INFO, "Imported config file\n");
576 void artv_import_control(void) {
579 CtdlLogPrintf(CTDL_DEBUG, "Importing control file\n");
580 client_getln(buf, sizeof buf); CitControl.MMhighest = atol(buf);
581 client_getln(buf, sizeof buf); CitControl.MMflags = atoi(buf);
582 client_getln(buf, sizeof buf); CitControl.MMnextuser = atol(buf);
583 client_getln(buf, sizeof buf); CitControl.MMnextroom = atol(buf);
584 client_getln(buf, sizeof buf); CitControl.version = atoi(buf);
585 CitControl.MMfulltext = (-1L); /* always flush */
587 CtdlLogPrintf(CTDL_INFO, "Imported control file\n");
591 void artv_import_user(void) {
593 struct ctdluser usbuf, *buf;
596 #include "artv_deserialize.h"
597 #include "dtds/user-defs.h"
598 #include "undef_data.h"
601 client_getln(cbuf, sizeof cbuf); buf->version = atoi(cbuf);
602 client_getln(cbuf, sizeof cbuf); buf->uid = atoi(cbuf);
603 client_getln(buf->password, sizeof buf->password);
604 client_getln(cbuf, sizeof cbuf); buf->flags = atoi(cbuf);
605 client_getln(cbuf, sizeof cbuf); buf->timescalled = atol(cbuf);
606 client_getln(cbuf, sizeof cbuf); buf->posted = atol(cbuf);
607 client_getln(cbuf, sizeof cbuf); buf->axlevel = atoi(cbuf);
608 client_getln(cbuf, sizeof cbuf); buf->usernum = atol(cbuf);
609 client_getln(cbuf, sizeof cbuf); buf->lastcall = atol(cbuf);
610 client_getln(cbuf, sizeof cbuf); buf->USuserpurge = atoi(cbuf);
611 client_getln(buf->fullname, sizeof buf->fullname);
612 client_getln(cbuf, sizeof cbuf); buf->USscreenwidth = atoi(cbuf);
613 client_getln(cbuf, sizeof cbuf); buf->USscreenheight = atoi(cbuf);
619 void artv_import_room(long *iterations) {
621 struct ctdlroom qrbuf, *buf;
627 #include "artv_deserialize.h"
628 #include "dtds/room-defs.h"
629 #include "undef_data.h"
632 client_getln(buf->QRname, sizeof buf->QRname);
633 client_getln(buf->QRpasswd, sizeof buf->QRpasswd);
634 client_getln(cbuf, sizeof cbuf); buf->QRroomaide = atol(cbuf);
635 client_getln(cbuf, sizeof cbuf); buf->QRhighest = atol(cbuf);
636 client_getln(cbuf, sizeof cbuf); buf->QRgen = atol(cbuf);
637 client_getln(cbuf, sizeof cbuf); buf->QRflags = atoi(cbuf);
638 client_getln(buf->QRdirname, sizeof buf->QRdirname);
639 client_getln(cbuf, sizeof cbuf); buf->QRinfo = atol(cbuf);
640 client_getln(cbuf, sizeof cbuf); buf->QRfloor = atoi(cbuf);
641 client_getln(cbuf, sizeof cbuf); buf->QRmtime = atol(cbuf);
642 client_getln(cbuf, sizeof cbuf); buf->QRep.expire_mode = atoi(cbuf);
643 client_getln(cbuf, sizeof cbuf); buf->QRep.expire_value = atoi(cbuf);
644 client_getln(cbuf, sizeof cbuf); buf->QRnumber = atol(cbuf);
645 client_getln(cbuf, sizeof cbuf); buf->QRorder = atoi(cbuf);
646 client_getln(cbuf, sizeof cbuf); buf->QRflags2 = atoi(cbuf);
647 client_getln(cbuf, sizeof cbuf); buf->QRdefaultview = atoi(cbuf);
650 CtdlLogPrintf(CTDL_INFO, "Imported room <%s>\n", qrbuf.QRname);
651 /* format of message list export is all message numbers output
652 * one per line terminated by a 0.
654 while ((client_getln(cbuf, sizeof cbuf) >= 0) && (msgnum = atol(cbuf))) {
655 CtdlSaveMsgPointerInRoom(qrbuf.QRname, msgnum, 0, NULL);
656 cprintdot(iterations);
658 if (CtdlThreadCheckStop())
661 CtdlLogPrintf(CTDL_INFO, "(%d messages)\n", msgcount);
665 void artv_import_floor(void) {
666 struct floor flbuf, *buf;
671 memset(buf, 0, sizeof(buf));
672 client_getln(cbuf, sizeof cbuf); i = atoi(cbuf);
674 #include "artv_deserialize.h"
675 #include "dtds/floor-defs.h"
676 #include "undef_data.h"
678 client_getln(cbuf, sizeof cbuf); buf->f_flags = atoi(cbuf);
679 client_getln(buf->f_name, sizeof buf->f_name);
680 client_getln(cbuf, sizeof cbuf); buf->f_ref_count = atoi(cbuf);
681 client_getln(cbuf, sizeof cbuf); buf->f_ep.expire_mode = atoi(cbuf);
682 client_getln(cbuf, sizeof cbuf); buf->f_ep.expire_value = atoi(cbuf);
685 CtdlLogPrintf(CTDL_INFO, "Imported floor #%d (%s)\n", i, flbuf.f_name);
689 void artv_import_visit(void) {
693 int is_textual_seen = 0;
695 client_getln(buf, sizeof buf); vbuf.v_roomnum = atol(buf);
696 client_getln(buf, sizeof buf); vbuf.v_roomgen = atol(buf);
697 client_getln(buf, sizeof buf); vbuf.v_usernum = atol(buf);
699 client_getln(buf, sizeof buf);
700 vbuf.v_lastseen = atol(buf);
701 for (i=0; buf[i]; ++i) if (!isdigit(buf[i])) is_textual_seen = 1;
702 if (is_textual_seen) strcpy(vbuf.v_seen, buf);
704 client_getln(vbuf.v_answered, sizeof vbuf.v_answered);
705 client_getln(buf, sizeof buf); vbuf.v_flags = atoi(buf);
706 client_getln(buf, sizeof buf); vbuf.v_view = atoi(buf);
708 CtdlLogPrintf(CTDL_INFO, "Imported visit %ld/%ld/%ld\n",
709 vbuf.v_roomnum, vbuf.v_roomgen, vbuf.v_usernum);
713 void artv_import_openid(void) {
720 client_getln(buf, sizeof buf); usernum = atol(buf);
721 client_getln(openid, sizeof openid);
722 if (IsEmptyStr(openid)) return;
724 data_len = sizeof(long) + strlen(openid) + 1;
725 data = malloc(data_len);
727 memcpy(data, &usernum, sizeof(long));
728 memcpy(&data[sizeof(long)], openid, strlen(openid) + 1);
730 cdb_store(CDB_OPENID, openid, strlen(openid), data, data_len);
733 CtdlLogPrintf(CTDL_INFO, "Imported OpenID %s for user #%ld\n", openid, usernum);
737 void artv_import_message(long *iterations, char **b64buf, size_t *b64size, char **plain, size_t *plain_size) {
746 memset(&smi, 0, sizeof(struct MetaData));
747 client_getln(buf, sizeof buf); msgnum = atol(buf);
748 smi.meta_msgnum = msgnum;
749 client_getln(buf, sizeof buf); smi.meta_refcount = atoi(buf);
750 client_getln(smi.meta_content_type, sizeof smi.meta_content_type);
752 CtdlLogPrintf(CTDL_INFO, "message #%ld\n", msgnum);
754 /* decode base64 message text */
755 while (client_getln(buf, sizeof buf) >= 0 && strcasecmp(buf, END_OF_MESSAGE)) {
756 if (CtdlThreadCheckStop())
759 cprintdot(iterations);
762 * Grow the buffers if we need to
765 if (b64len + mlen > *b64size)
767 tbuf = realloc (*b64buf, *b64size + SIZ);
768 tbuf2 = realloc (*plain, *plain_size + SIZ);
778 CtdlLogPrintf(CTDL_DEBUG, "ARTV import: realloc() failed.\n");
779 cprintf("\nMemory allocation failure.\n");
783 strcat (*b64buf, buf);
788 * FIXME: This is an ideal place for a "sub thread". What we should do is create a new thread
789 * This new thread would be given the base64 encoded message, it would then decode it and store
790 * it. This would allow the thread that is reading from the client to continue doing so, basically
791 * backgrounding the decode and store operation. This would increase the speed of the import from
792 * the users perspective.
796 * Decode and store the message
797 * If this decode and store takes more than 5 seconds the sendcommand WD timer may expire.
799 msglen = CtdlDecodeBase64(*plain, *b64buf, b64len);
800 CtdlLogPrintf(CTDL_DEBUG, "msglen = %ld\n", msglen);
801 cdb_store(CDB_MSGMAIN, &msgnum, sizeof(long), *plain, msglen);
803 CtdlLogPrintf(CTDL_INFO, "Imported message %ld\n", msgnum);
810 void artv_do_import(void) {
818 size_t b64size, plain_size;
822 /* Prepare buffers for base 64 decoding of messages.
824 b64mes = malloc(SIZ);
827 cprintf("%d Malloc failed in import/export.\n",
828 ERROR + RESOURCE_BUSY);
836 cprintf("%d Malloc failed in import/export.\n",
837 ERROR + RESOURCE_BUSY);
844 cprintf("%d sock it to me\n", SEND_LISTING);
848 while (client_getln(buf, sizeof buf) >= 0 && strcmp(buf, "000")) {
849 if (CtdlThreadCheckStop())
850 break; // Should we break or return?
855 CtdlLogPrintf(CTDL_DEBUG, "import keyword: <%s>\n", buf);
856 if ((abuf[0] == '\0') || (strcasecmp(buf, abuf))) {
857 cprintf ("\n\nImporting datatype %s\n", buf);
858 strncpy (abuf, buf, SIZ);
862 cprintdot(&iterations);
865 if (!strcasecmp(buf, "version")) {
866 client_getln(s_version, sizeof s_version);
867 version = atoi(s_version);
868 if ((version<EXPORT_REV_MIN) || (version>REV_LEVEL)) {
869 CtdlLogPrintf(CTDL_ERR, "Version mismatch in ARTV import; aborting\n");
873 else if (!strcasecmp(buf, "config")) artv_import_config();
874 else if (!strcasecmp(buf, "control")) artv_import_control();
875 else if (!strcasecmp(buf, "user")) artv_import_user();
876 else if (!strcasecmp(buf, "room")) artv_import_room(&iterations);
877 else if (!strcasecmp(buf, "floor")) artv_import_floor();
878 else if (!strcasecmp(buf, "visit")) artv_import_visit();
879 else if (!strcasecmp(buf, "openid")) artv_import_openid();
880 else if (!strcasecmp(buf, "message"))
884 artv_import_message(&iterations, &b64mes, &b64size, &plain, &plain_size);
891 CtdlLogPrintf(CTDL_INFO, "Invalid keyword <%s>. Flushing input.\n", buf);
892 while (client_getln(buf, sizeof buf) >= 0 && strcmp(buf, "000")) ;;
893 rebuild_euid_index();
894 rebuild_usersbynumber();
899 void cmd_artv(char *cmdbuf) {
901 static int is_running = 0;
903 if (CtdlAccessCheck(ac_internal)) return;
905 cprintf("%d The importer/exporter is already running.\n",
906 ERROR + RESOURCE_BUSY);
911 CtdlMakeTempFileName(artv_tempfilename1, sizeof artv_tempfilename1);
912 CtdlMakeTempFileName(artv_tempfilename2, sizeof artv_tempfilename2);
914 extract_token(cmd, cmdbuf, 0, '|', sizeof cmd);
915 if (!strcasecmp(cmd, "export")) artv_do_export();
916 else if (!strcasecmp(cmd, "import")) artv_do_import();
917 else if (!strcasecmp(cmd, "dump")) artv_do_dump();
918 else cprintf("%d illegal command\n", ERROR + ILLEGAL_VALUE);
920 unlink(artv_tempfilename1);
921 unlink(artv_tempfilename2);
929 CTDL_MODULE_INIT(vandelay)
933 CtdlRegisterProtoHook(cmd_artv, "ARTV", "import/export data store");
936 /* return our Subversion id for the Log */