* vandelay
authorArt Cancro <ajc@citadel.org>
Sat, 15 Jul 2000 06:08:12 +0000 (06:08 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 15 Jul 2000 06:08:12 +0000 (06:08 +0000)
citadel/serv_vandelay.c
citadel/user_ops.c
citadel/user_ops.h

index 5a0d8e9dca8efbec49c523124f26139773d54d7f..23bc91bebf9a341d51da9dcae10042b03cf96bb5 100644 (file)
@@ -138,7 +138,7 @@ void artv_export_floors(void) {
 
 
 /* 
- *  Traverse the room file...
+ *  Traverse the visits file...
  */
 void artv_export_visits(void) {
        struct visit vbuf;
@@ -344,6 +344,127 @@ void artv_import_control(void) {
 }
 
 
+void artv_import_user(void) {
+       char buf[256];
+       struct usersupp usbuf;
+
+       client_gets(buf);       usbuf.version = atoi(buf);
+       client_gets(buf);       usbuf.uid = atoi(buf);
+       client_gets(usbuf.password);
+       client_gets(buf);       usbuf.flags = atoi(buf);
+       client_gets(buf);       usbuf.timescalled = atol(buf);
+       client_gets(buf);       usbuf.posted = atol(buf);
+       client_gets(buf);       usbuf.axlevel = atoi(buf);
+       client_gets(buf);       usbuf.usernum = atol(buf);
+       client_gets(buf);       usbuf.lastcall = atol(buf);
+       client_gets(buf);       usbuf.USuserpurge = atoi(buf);
+       client_gets(usbuf.fullname);
+       client_gets(buf);       usbuf.USscreenwidth = atoi(buf);
+       client_gets(buf);       usbuf.USscreenheight = atoi(buf);
+       client_gets(buf);       usbuf.moderation_filter = atoi(buf);
+       putuser(&usbuf);
+}
+
+
+void artv_import_room(void) {
+       char buf[256];
+       struct quickroom qrbuf;
+       long msgnum;
+       int msgcount = 0;
+
+       client_gets(qrbuf.QRname);
+       client_gets(qrbuf.QRpasswd);
+       client_gets(buf);       qrbuf.QRroomaide = atol(buf);
+       client_gets(buf);       qrbuf.QRhighest = atol(buf);
+       client_gets(buf);       qrbuf.QRgen = atol(buf);
+       client_gets(buf);       qrbuf.QRflags = atoi(buf);
+       client_gets(qrbuf.QRdirname);
+       client_gets(buf);       qrbuf.QRinfo = atol(buf);
+       client_gets(buf);       qrbuf.QRfloor = atoi(buf);
+       client_gets(buf);       qrbuf.QRmtime = atol(buf);
+       client_gets(buf);       qrbuf.QRep.expire_mode = atoi(buf);
+       client_gets(buf);       qrbuf.QRep.expire_value = atoi(buf);
+       client_gets(buf);       qrbuf.QRnumber = atol(buf);
+       client_gets(buf);       qrbuf.QRorder = atoi(buf);
+       putroom(&qrbuf);
+       lprintf(7, "Imported room <%s>\n", qrbuf.QRname);
+       /* format of message list export is all message numbers output
+        * one per line terminated by a 0.
+        */
+       while (client_gets(buf), msgnum = atol(buf), msgnum > 0) {
+               CtdlSaveMsgPointerInRoom(qrbuf.QRname, msgnum, 0);
+               ++msgcount;
+       }
+       lprintf(7, "(%d messages)\n", msgcount);
+}
+
+
+void artv_import_floor(void) {
+        struct floor flbuf;
+        int i;
+       char buf[256];
+
+       serv_gets(buf);         i = atoi(buf);
+       serv_gets(buf);         flbuf.f_flags = atoi(buf);
+       serv_gets(flbuf.f_name);
+       serv_gets(buf);         flbuf.f_ref_count = atoi(buf);
+       serv_gets(buf);         flbuf.f_ep.expire_mode = atoi(buf);
+       serv_gets(buf);         flbuf.f_ep.expire_value = atoi(buf);
+       putfloor(&flbuf, i);
+       lprintf(7, "Imported floor #%d (%s)\n", i, flbuf.f_name);
+}
+
+
+/* 
+ */
+void artv_import_visit(void) {
+       struct visit vbuf;
+       char buf[256];
+
+       client_gets(buf);       vbuf.v_roomnum = atol(buf);
+       client_gets(buf);       vbuf.v_roomgen = atol(buf);
+       client_gets(buf);       vbuf.v_usernum = atol(buf);
+       client_gets(buf);       vbuf.v_lastseen = atol(buf);
+       client_gets(buf);       vbuf.v_flags = atoi(buf);
+       put_visit(&vbuf);
+       lprintf(7, "Imported visit %ld/%ld/%ld\n",
+               vbuf.v_roomnum, vbuf.v_roomgen, vbuf.v_usernum);
+}
+
+
+
+void artv_import_message(void) {
+       struct SuppMsgInfo smi;
+       struct CtdlMessage *msg;
+       long msgnum;
+       int msglen;
+       FILE *fp;
+       char buf[256];
+       char tempfile[256];
+
+       memset(&smi, 0, sizeof(struct SuppMsgInfo));
+       client_gets(buf);       msgnum = atol(buf);
+       client_gets(buf);       smi.smi_refcount = atoi(buf);
+       client_gets(smi.smi_content_type);
+       client_gets(buf);       smi.smi_mod = atoi(buf);
+
+       PutSuppMsgInfo(&smi, msgnum) FIXME get syntax and move to end
+
+       /* decode base64 message text */
+       strcpy(tempfile, tmpnam(NULL));
+       sprintf(buf, "./base64 -d >%s", tempfile);
+       fp = popen(buf, "w");
+       while (client_gets(buf), strcasecmp(buf, END_OF_MESSAGE)) {
+               fprintf(fp, "%s\n", buf);
+       }
+       msglen = ftell(fp);
+       fclose(fp);
+
+       fp = fopen(tempfile, "rb");
+       FIXME do the rest of this
+       fclose(fp);
+}
+
 
 
 
@@ -355,6 +476,11 @@ void artv_do_import(void) {
 
                if (!strcasecmp(buf, "config")) artv_import_config();
                else if (!strcasecmp(buf, "control")) artv_import_control();
+               else if (!strcasecmp(buf, "user")) artv_import_user();
+               else if (!strcasecmp(buf, "room")) artv_import_room();
+               else if (!strcasecmp(buf, "floor")) artv_import_floor();
+               else if (!strcasecmp(buf, "visit")) artv_import_visit();
+               else if (!strcasecmp(buf, "message")) artv_import_message();
 
 
        }
index ec57f6becd92ea9f926506d5243c951b506b1b13..e24cfa9562f9761496657b54fbc41c58aa1d0ad9 100644 (file)
@@ -141,6 +141,30 @@ int GenerateRelationshipIndex(     char *IndexBuf,
        return(sizeof(TheIndex));
        }
 
+
+
+/*
+ * Back end for CtdlSetRelationship()
+ */
+void put_visit(struct visit *newvisit) {
+       char IndexBuf[32];
+       int IndexLen;
+
+       /* Generate an index */
+       IndexLen = GenerateRelationshipIndex(IndexBuf,
+               newvisit->v_roomnum,
+               newvisit->v_roomgen,
+               newvisit->v_usernum);
+
+       /* Store the record */
+       cdb_store(CDB_VISIT, IndexBuf, IndexLen,
+               newvisit, sizeof(struct visit)
+               );
+}
+
+
+
+
 /*
  * Define a relationship between a user and a room
  */
@@ -148,8 +172,6 @@ void CtdlSetRelationship(struct visit *newvisit,
                        struct usersupp *rel_user,
                        struct quickroom *rel_room) {
 
-       char IndexBuf[32];
-       int IndexLen;
 
        /* We don't use these in Citadel because they're implicit by the
         * index, but they must be present if the database is exported.
@@ -158,17 +180,8 @@ void CtdlSetRelationship(struct visit *newvisit,
         newvisit->v_roomgen = rel_room->QRgen;
         newvisit->v_usernum = rel_user->usernum;
 
-       /* Generate an index */
-       IndexLen = GenerateRelationshipIndex(IndexBuf,
-               rel_room->QRnumber,
-               rel_room->QRgen,
-               rel_user->usernum);
-
-       /* Store the record */
-       cdb_store(CDB_VISIT, IndexBuf, IndexLen,
-               newvisit, sizeof(struct visit)
-               );
-       }
+       put_visit(newvisit);
+}
 
 /*
  * Locate a relationship between a user and a room
index d286d42748df37a9247e1e98633038997b12ffd5..79bc46bb52d6ff645de2160e7a6ac3f891617630 100644 (file)
@@ -31,6 +31,7 @@ void cmd_qusr (char *who);
 void cmd_agup (char *cmdbuf);
 void cmd_asup (char *cmdbuf);
 int NewMailCount(void);
+void put_visit(struct visit *newvisit);
 void CtdlGetRelationship(struct visit *vbuf,
                         struct usersupp *rel_user,
                         struct quickroom *rel_room);