From 187a1978a3e71e1b0fd33a9e90fb488c4d236472 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sat, 15 Jul 2000 06:08:12 +0000 Subject: [PATCH] * vandelay --- citadel/serv_vandelay.c | 128 +++++++++++++++++++++++++++++++++++++++- citadel/user_ops.c | 39 ++++++++---- citadel/user_ops.h | 1 + 3 files changed, 154 insertions(+), 14 deletions(-) diff --git a/citadel/serv_vandelay.c b/citadel/serv_vandelay.c index 5a0d8e9dc..23bc91beb 100644 --- a/citadel/serv_vandelay.c +++ b/citadel/serv_vandelay.c @@ -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(); } diff --git a/citadel/user_ops.c b/citadel/user_ops.c index ec57f6bec..e24cfa956 100644 --- a/citadel/user_ops.c +++ b/citadel/user_ops.c @@ -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 diff --git a/citadel/user_ops.h b/citadel/user_ops.h index d286d4274..79bc46bb5 100644 --- a/citadel/user_ops.h +++ b/citadel/user_ops.h @@ -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); -- 2.39.2