]> code.citadel.org Git - citadel.git/commitdiff
* Starting some work on network zap (supersede) mode for replication
authorArt Cancro <ajc@citadel.org>
Wed, 13 Oct 1999 01:36:39 +0000 (01:36 +0000)
committerArt Cancro <ajc@citadel.org>
Wed, 13 Oct 1999 01:36:39 +0000 (01:36 +0000)
citadel/ChangeLog
citadel/citadel.h
citadel/netproc.c
citadel/serv_vcard.c

index 6ef0bb94e0c5bea148967f2bec225fc247f9cd59..cb9c376a3239dad7a6583ce3bc443a9152773634 100644 (file)
@@ -1,4 +1,7 @@
 $Log$
+Revision 1.382  1999/10/13 01:36:39  ajc
+* Starting some work on network zap (supersede) mode for replication
+
 Revision 1.381  1999/10/08 02:55:57  ajc
 * More vCard-related debugging
 
@@ -1301,4 +1304,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * Initial CVS import 
-
index 268243462a9ef6d151197e543cbf9a5d4178a595..e079dc58ba6859d4eaced3fa47ddfdb1b790de45 100644 (file)
@@ -263,6 +263,7 @@ struct minfo {
        char S[512];
        long T;
        char U[512];
+       char Z[512];
        char nexthop[512];
        };
 
index d66159e2c8ce74103749a6def1958158dd9ae0ac..f6fbce515ff6fa7c4589752844cd3da985dd7820 100644 (file)
 /* Path to the 'uudecode' utility (needed for network file transfers) */
 #define UUDECODE       "/usr/bin/uudecode"
 
+/* Files used by the networker */
+#define ZAPLIST                "./network/zaplist"
+#define MAILSYSINFO    "./network/mail.sysinfo"
+
 /* Uncomment the DEBUG def to see noisy traces */
 #define DEBUG 1
 
@@ -117,7 +121,7 @@ void strip_trailing_whitespace(char *buf)
 
 
 /*
- * we also load the network/mail.sysinfo table into memory, make changes
+ * we also load the mail.sysinfo table into memory, make changes
  * as we learn more about the network from incoming messages, and write
  * the table back to disk when we're done.
  */
@@ -128,7 +132,7 @@ int load_syslist(void)
        char insys = 0;
        char buf[128];
 
-       fp = fopen("network/mail.sysinfo", "r");
+       fp = fopen(MAILSYSINFO, "r");
        if (fp == NULL)
                return (1);
 
@@ -233,7 +237,7 @@ void rewrite_syslist(void)
        time_t now;
 
        time(&now);
-       newfp = fopen("network/mail.sysinfo", "w");
+       newfp = fopen(MAILSYSINFO, "w");
        for (stemp = slist; stemp != NULL; stemp = stemp->next) {
                if (!strcasecmp(stemp->s_name, config.c_nodename)) {
                        time(&stemp->s_lastcontact);
@@ -482,15 +486,10 @@ void fpmsgfind(FILE *fp, struct minfo *buffer)
                syslog(LOG_ERR, "Magic number check failed for this message");
                goto END;
        }
+
+       memset(buffer, 0, sizeof(struct minfo));
        mtype = getc(fp);
        aflag = getc(fp);
-       buffer->I = 0L;
-       buffer->R[0] = 0;
-       buffer->E[0] = 0;
-       buffer->H[0] = 0;
-       buffer->S[0] = 0;
-       buffer->B[0] = 0;
-       buffer->G[0] = 0;
 
 BONFGM:        b = getc(fp);
        if (b < 0)
@@ -549,6 +548,8 @@ BONFGM:     b = getc(fp);
                strcpy(buffer->G, bbb);
        if (b == 'E')
                strcpy(buffer->E, bbb);
+       if (b == 'Z')
+               strcpy(buffer->Z, bbb);
        goto BONFGM;
 
 END:
@@ -815,12 +816,69 @@ void purge_use_table(GDBM_FILE ut) {
 
 
 
+/*
+ * Delete any messages on the zapped list
+ */
+void process_zaplist(void) {
+       FILE *zaplist;
+       char curr_rm[ROOMNAMELEN];
+       char buf[256];
+       char room[256];
+       char id[256];
+       char node[256];
+
+       zaplist = fopen(ZAPLIST, "r");
+       if (zaplist == NULL) {
+               syslog(LOG_ERR, "cannot open %s: %s\n",
+                       ZAPLIST, strerror(errno));
+               return;
+       }
+
+       strcpy(curr_rm, "_nothing_");
+
+       while (fgets(buf, 256, zaplist) != NULL) {
+               buf[strlen(buf) - 1] = 0;
+
+               extract(room, buf, 0);
+               extract(id, buf, 1);
+               extract(node, buf, 2);
+
+               /* Change rooms if we have to */
+               if (strcasecmp(curr_rm, room)) {
+                       sprintf(buf, "GOTO %s", room);
+                       serv_puts(buf);
+                       serv_gets(buf);
+                       if (buf[0] == '2') {
+                               extract(curr_rm, &buf[4], 0);
+                       } else {
+                               syslog(LOG_ERR, "%s", buf);
+                       }
+               }
+
+               /* And only do the zap if we succeeded */
+               if (!strcasecmp(curr_rm, room)) {
+
+
+
+               /* FIX    not finished */
+
+
+               }
+
+       fclose(zaplist);
+
+}
+
+
+
+
+
 /*
  * process incoming files in ./network/spoolin
  */
 void inprocess(void)
 {
-       FILE *fp, *message, *testfp, *ls, *duplist;
+       FILE *fp, *message, *testfp, *ls, *duplist, *zaplist;
        static struct minfo minfo;
        struct recentmsg recentmsg;
        char tname[128], aaa[1024], iname[256], sfilename[256], pfilename[256];
@@ -841,10 +899,12 @@ void inprocess(void)
        /* Make sure we're in the right directory */
        chdir(bbs_home_directory);
 
-
        /* temporary file to contain a log of rejected dups */
        duplist = tmpfile();
 
+       /* Open the zapped-list for appending */
+       zaplist = fopen(ZAPLIST, "a");
+
        /* Let the shell do the dirty work. Get all data from spoolin */
        do {
                sprintf(aaa, "cd %s/network/spoolin; ls", bbs_home_directory);
@@ -911,11 +971,6 @@ NXMSG:     /* Seek to the beginning of the next message */
                        fclose(message);
 
                        /* process the individual mesage */
-                       minfo.D[0] = 0;
-                       minfo.C[0] = 0;
-                       minfo.B[0] = 0;
-                       minfo.G[0] = 0;
-                       minfo.R[0] = 0;
                        msgfind(tname, &minfo);
                        strncpy(recentmsg.RMnodename, minfo.N, 9);
                        recentmsg.RMnodename[9] = 0;
@@ -1012,7 +1067,6 @@ NXMSG:    /* Seek to the beginning of the next message */
 
                        /* otherwise process it as a normal message */
                        else {
-
                                if (!strcasecmp(minfo.R, "postmaster")) {
                                        strcpy(minfo.R, "");
                                        strcpy(minfo.C, "Aide");
@@ -1074,6 +1128,21 @@ NXMSG:   /* Seek to the beginning of the next message */
                                }
 
                                fclose(message);
+                               
+                               /* If this message supersedes an existing one,
+                                * add it to the zap list
+                                */
+                               if (strlen(minfo.Z) > 0) {
+                                       if (strlen(minfo.C) > 0) {
+                                               fprintf(zaplist, "%s", minfo.C);
+                                       } else {
+                                               fprintf(zaplist, "%s", minfo.O);
+                                       }
+                                       extract_token(buf, minfo.Z, 0, '@');
+                                       fprintf(zaplist, "|%s", minfo.Z);
+                                       extract_token(buf, minfo.Z, 1, '@');
+                                       fprintf(zaplist, "|%s\n", minfo.Z);
+                               }
                        }
 
                        unlink(tname);
@@ -1110,6 +1179,12 @@ ENDSTR:                  fclose(fp);
 
        fclose(duplist);
 
+
+       /* Now delete any messages which were zapped (superseded) by
+        * other incoming messages.
+        */
+       fclose(zaplist);
+       process_zaplist();
 }
 
 
index d9fa1da71ddd80a0791cfeea8ff540f6847ad500..9de886616892c2d784fe494b6f35b8ddc480b2cf 100644 (file)
@@ -74,7 +74,6 @@ int vcard_upload_beforesave(struct CtdlMessage *msg) {
         char config_rm[ROOMNAMELEN];
        char buf[256];
 
-       lprintf(9, "entering beforesave hook\n");
 
        /* If this isn't the configuration room, or if this isn't a MIME
         * message, don't bother.
@@ -109,7 +108,6 @@ int vcard_upload_beforesave(struct CtdlMessage *msg) {
                                        phree(msg->cm_fields['Z']);
                                sprintf(buf, "%ld@%s", VC->msgnum, NODENAME);
                                msg->cm_fields['Z'] = strdoop(buf);
-                               lprintf(9, "replacing <%s>\n", buf);
                        }
 
                        CtdlDeleteMessages(config_rm, 0L, "text/x-vcard");
@@ -140,7 +138,6 @@ int vcard_upload_aftersave(struct CtdlMessage *msg) {
        struct quickroom qrbuf;
        char buf[256];
 
-       lprintf(9, "entering aftersave hook\n");
 
        /* If this isn't the configuration room, or if this isn't a MIME
         * message, don't bother.
@@ -158,7 +155,6 @@ int vcard_upload_aftersave(struct CtdlMessage *msg) {
                        /* Bingo!  The user is uploading a new vCard, so
                         * copy it to the Global Address Book room.
                         */
-                       lprintf(9, "activated aftersave hook\n");
 
                        I = atol(msg->cm_fields['I']);
                        if (I < 0L) return(0);
@@ -173,19 +169,14 @@ int vcard_upload_aftersave(struct CtdlMessage *msg) {
                                }
                        }
 
-                       lprintf(9, "calling getroom\n");
                        if (getroom(&qrbuf, ADDRESS_BOOK_ROOM) != 0) return(0);
-                       lprintf(9, "calling AddMessageToRoom\n");
                        AddMessageToRoom(&qrbuf, I);
-                       lprintf(9, "calling AdjRefCount\n");
                        AdjRefCount(I, +1);
 
                        if (Z > 0L) {
-                               lprintf(9, "Deleting the old one\n");
                                CtdlDeleteMessages(ADDRESS_BOOK_ROOM, Z, NULL); 
                        }
 
-                       lprintf(9, "finishing aftersave hook\n");
                        return(0);
                }
 
@@ -193,7 +184,6 @@ int vcard_upload_aftersave(struct CtdlMessage *msg) {
                if (ptr != NULL) ++ptr;
        }
 
-       lprintf(9, "didn't do anything in hook\n");
        return(0);
 }