wls@astrovax.UUCP (11/22/83)
I was about to post this anyway but it is convenient to be able to post it as a followup to something. I have made some modifications to readnews and vnews at our site to use a routing data base rather than the news arrival path to constuct a path for the r(eply) command. The diffs to the files readr.c, visual.c, and Makefile which are needed to implement this change follow this introduction. As implemented here, this requires the dbm (data base management) subroutines and a pairs of files /usr/lib/uucp/alpath.dir and /usr/lib/uucp/alpath.pag , such as that constructed by these dbm routines. The format of the data stored in these files is: using the name of a site as a key, stored under the key is a string of the form site1!site2!...!keysite!%s , where the %s could be replaced by an account name located at that site. Another possible string is site1!site2!...!siten!%s@keysite. The dbm pair of files of this form is output by the version of pathalias that we have. In use, these patches look along the arrival path and substitute a replacement path for the first site that they find in the data base. Thus a new site that has not yet made it into the data base will be handled properly. The original arrival path is still placed in the mail header for reference in a line headed by "News-path: " (sorry Mark, I wasn't able to check if this is a legal thing to do Arpa-wise. It can be changed to some other name if it matters). The "To: " line can still be edited if one notices some obvious goof, i.e. some hop which one knows is bad. (Suggestion: if this occurs, tell your site manager so he can update the data base. If you are site manager, update your data base.) Hopefully, this change can reduce a lot of silly paths. Even though I was aware of the need to edit my paths I would sometimes forget and let loose a reply bouncing all over the net. Note: there are many bug fixes and such in the "original" versions of the files "diff" below. Therefore the "original" line numbers have only vaguely the values they might have in your own versions of these files. indicative. If it is desired to place the routing information is some other location than /usr/lib/uucp/alpath* , redefine the variable NETPATHS in the Makefile (sorry, I gave up on localize.sh a fair while ago). -- Bill Sebok Princeton Univ. Astrophysics {allegra,akgua,burl,cbosgd,decvax,ihnp4,kpno,princeton}!astrovax!wls ------------------------------------------------------------------------ Diff for readr.c *** readr.c.BAK Mon Nov 14 16:39:04 1983 --- readr.c Mon Nov 14 22:04:47 1983 *************** *** 5,12 static char *SccsId = "@(#)readr.c 2.26 6/24/83"; #include "rparams.h" #define FAST static char lbuf[BUFLEN*2]; #define saveart oobit = bit;strcpy(ofilename1, filename);strcpy(ogroupdir, groupdir);hbufcp(&hbuf1, &h);ongsize = pngsize --- 5,15 ----- static char *SccsId = "@(#)readr.c 2.26 6/24/83"; #include "rparams.h" #define FAST + #ifdef NETPATHS + #include <dbm.h> + #endif NETPATHS static char lbuf[BUFLEN*2]; #define saveart oobit = bit;strcpy(ofilename1, filename);strcpy(ogroupdir, groupdir);hbufcp(&hbuf1, &h);ongsize = pngsize *************** *** 613,620 char *replyname(); char subj[100]; char folbuf[BUFLEN]; extern char MAILPARSER[]; hptr = &h; while (*bptr && index("d-", *bptr)) { switch (*bptr) { --- 616,632 ----- char *replyname(); char subj[100]; char folbuf[BUFLEN]; extern char MAILPARSER[]; + #ifdef NETPATHS + /* Stuff for finding path in data base */ + static int dbmopen = 0; + static char newspaths[] = NETPATHS; + datum key, result; + register char *p1, *p2; + char sitename[100]; + /* End Stuff for finding path in data base */ + #endif NETPATHS hptr = &h; while (*bptr && index("d-", *bptr)) { switch (*bptr) { *************** *** 641,649 } *rcbuf = '\0'; *curberk = '\0'; ! pathptr = replyname(hptr);; ptr = pathptr - 1; i = 0; for (ptr1 = address, ptr2 = pathptr; *ptr2; ptr1++, ptr2++) { if (index("\"\\$", *ptr2)) --- 653,688 ----- } *rcbuf = '\0'; *curberk = '\0'; ! pathptr = replyname(hptr); ! #ifdef NETPATHS ! /* Use data Base to Find a reply a Path to a site */ ! /* Nov 13, 1983 W. Sebok */ ! if (dbmopen==0) ! dbmopen = (dbminit(newspaths)==0) ? 1 : -1 ; ! ! result.dptr = NULL; ! if (dbmopen>0) { ! for(p1=pathptr; (p2 = index(p1,'!'))!=NULL; p1=p2+1); ! if (pathptr!=p1) { ! key.dptr = sitename; ! p1--; ! do { ! for (p2=p1; (p1!=pathptr) && (*--p1!='!'); ); ! key.dsize = p2 - p1 ; ! strncpy(sitename, p1+1, key.dsize); ! sitename[key.dsize-1] = '\0'; ! result = fetch(key); ! } while ( (p1!=pathptr) && result.dptr==NULL); ! } ! } ! if (result.dptr != NULL) { ! sprintf(sitename, result.dptr, p2+1); ! p1 = pathptr; ! pathptr = sitename; ! } ! #endif NETPATHS ptr = pathptr - 1; i = 0; for (ptr1 = address, ptr2 = pathptr; *ptr2; ptr1++, ptr2++) { if (index("\"\\$", *ptr2)) *************** *** 687,694 tfp = fopen(tf, "w"); fprintf(tfp, "To: %s\n", pathptr); fprintf(tfp, "Subject: %s\n", subj); fprintf(tfp, "References: %s\n\n", folbuf); fclose(tfp); sprintf(edcmdbuf, "%s %s", ed, tf); --- 726,737 ----- tfp = fopen(tf, "w"); fprintf(tfp, "To: %s\n", pathptr); fprintf(tfp, "Subject: %s\n", subj); + #ifdef NETPATHS + if (result.dptr != NULL) + fprintf(tfp, "News-path: %s\n", p1); + #endif NETPATHS fprintf(tfp, "References: %s\n\n", folbuf); fclose(tfp); sprintf(edcmdbuf, "%s %s", ed, tf); ------------------------------------------------------------ Diffs for visual.c of vnews *** visual.c.BAK Sun Nov 13 22:43:46 1983 --- visual.c Mon Nov 14 22:05:38 1983 *************** *** 49,56 #include "dir.h" #ifdef MYDB #include "db.h" #endif #define ARTWLEN (ROWS-2)/* number of lines used to display article */ #ifdef STATTOP --- 49,59 ----- #include "dir.h" #ifdef MYDB #include "db.h" #endif + #ifdef NETPATHS + #include <dbm.h> /* WLS Nov 13,1983 */ + #endif NETPATHS #define ARTWLEN (ROWS-2)/* number of lines used to display article */ #ifdef STATTOP *************** *** 866,873 char subj[132]; char *p; char *replyname(); strcpy(tf, tft); mktemp(tf); if ((tfp = fopen(tf, "w")) == NULL) { msg("Can't create %s", tf) ; --- 869,886 ----- char subj[132]; char *p; char *replyname(); + #ifdef NETPATHS + /* Stuff for finding path in data base */ + static int dbmopen = 0; + static char newspaths[] = NETPATHS; + datum key, result; + register char *p1, *p2; + char sitename[100]; + /* End Stuff for finding path in data base */ + #endif NETPATHS + strcpy(tf, tft); mktemp(tf); if ((tfp = fopen(tf, "w")) == NULL) { msg("Can't create %s", tf) ; *************** *** 894,905 p = h.sender; else #endif p = replyname(&h); ! fprintf(tfp, "To: %s\n", p); ! fprintf(tfp, "Subject: %s\n", subj); ! if (followup != 2) ! fprintf(tfp, "In-reply-to: your article %s\n", h.ident); arg[1] = REPLYPROG; arg[4] = p; } else { p = h.nbuf; --- 907,954 ----- p = h.sender; else #endif p = replyname(&h); ! ! #ifdef NETPATHS ! /* Use data Base to Find a reply a Path to a site */ ! /* Nov 13, 1983 W. Sebok */ ! if (dbmopen==0) ! dbmopen = (dbminit(newspaths)==0) ? 1 : -1 ; ! ! result.dptr = NULL; ! if (dbmopen>0) { ! for(p1=p; (p2 = index(p1,'!'))!=NULL; p1=p2+1); ! if (p!=p1) { ! key.dptr = sitename; ! p1--; ! do { ! for (p2=p1; (p1!=p) && (*--p1!='!'); ); ! key.dsize = p2 - p1 ; ! strncpy(sitename, p1+1, key.dsize); ! sitename[key.dsize-1] = '\0'; ! result = fetch(key); ! } while ( (p1!=p) && result.dptr==NULL); ! } ! } ! if (result.dptr != NULL) { ! fprintf(tfp, "To: "); ! fprintf(tfp, result.dptr, p2+1); ! fprintf(tfp, "\nSubject: %s\n", subj); ! if (followup != 2) ! fprintf(tfp, "In-reply-to: your article %s\n", ! h.ident); ! fprintf(tfp, "News-path: %s\n", p); ! } else ! #endif NETPATHS ! { ! fprintf(tfp, "To: %s\n", p); ! fprintf(tfp, "Subject: %s\n", subj); ! if (followup != 2) ! fprintf(tfp, "In-reply-to: your article %s\n", ! h.ident); ! } ! /* End Stuff for finding path in data base */ arg[1] = REPLYPROG; arg[4] = p; } else { p = h.nbuf; ---------------------------------------------- diff for Makefile *** Makefile.BAK Mon Nov 21 23:48:59 1983 --- Makefile Mon Nov 14 22:30:08 1983 *************** *** 3,10 # definitions SPOOLDIR = /usr/spool/news LIBDIR = /usr/lib/news BINDIR = /usr/bin DEBUG = # -DDEBUG # -pg CFLAGS = ${DEBUG} -O -DDBM LFLAGS = # -pg NEWSUSR = news --- 3,11 ----- # definitions SPOOLDIR = /usr/spool/news LIBDIR = /usr/lib/news BINDIR = /usr/bin + NETPATHS = /usr/lib/uucp/alpath DEBUG = # -DDEBUG # -pg CFLAGS = ${DEBUG} -O -DDBM LFLAGS = # -pg NEWSUSR = news *************** *** 70,78 inews: Makefile $(IOBJECTS) $(CC) $(LFLAGS) $(IOBJECTS) -o inews -ldbm readnews: Makefile $(ROBJECTS) ! $(CC) $(LFLAGS) $(ROBJECTS) -o readnews funcs.o: funcs.c params.h defs.h $(CC) $(CFLAGS) -c funcs.c --- 71,79 ----- inews: Makefile $(IOBJECTS) $(CC) $(LFLAGS) $(IOBJECTS) -o inews -ldbm readnews: Makefile $(ROBJECTS) ! $(CC) $(LFLAGS) $(ROBJECTS) -o readnews -ldbm funcs.o: funcs.c params.h defs.h $(CC) $(CFLAGS) -c funcs.c *************** *** 107,115 $(CC) $(CFLAGS) -DSPOOLDIR=\"$(SPOOLDIR) -DLIBDIR=\"$(LIBDIR)\ -DNEWSUSR=\"$(NEWSUSR)\" -DNEWSGRP=\"$(NEWSGRP)\" -c rextern.c readr.o: readr.c rparams.h defs.h params.h Makefile ! $(CC) $(CFLAGS) -c readr.c checknews.o: checknews.c defs.h Makefile $(CC) $(CFLAGS) -DSPOOLDIR=\"$(SPOOLDIR) -DLIBDIR=\"$(LIBDIR)\ -DNEWSUSR=\"$(NEWSUSR)\" -DNEWSGRP=\"$(NEWSGRP)\" -c checknews.c --- 108,116 ----- $(CC) $(CFLAGS) -DSPOOLDIR=\"$(SPOOLDIR) -DLIBDIR=\"$(LIBDIR)\ -DNEWSUSR=\"$(NEWSUSR)\" -DNEWSGRP=\"$(NEWSGRP)\" -c rextern.c readr.o: readr.c rparams.h defs.h params.h Makefile ! $(CC) $(CFLAGS) -DNETPATHS=\"$(NETPATHS)\" -c readr.c checknews.o: checknews.c defs.h Makefile $(CC) $(CFLAGS) -DSPOOLDIR=\"$(SPOOLDIR) -DLIBDIR=\"$(LIBDIR)\ -DNEWSUSR=\"$(NEWSUSR)\" -DNEWSGRP=\"$(NEWSGRP)\" -c checknews.c *************** *** 201,206 # Vnews section of makefile VOBJECTS = readnews.o rfuncs.o rfuncs2.o rextern.o process.o rpathinit.o $(OBJECTS) visual.o virtterm.o dir.o vnews: $(VOBJECTS) ! $(CC) $(LFLAGS) $(VOBJECTS) -ltermcap -ljobs -o $@ --- 201,209 ----- # Vnews section of makefile VOBJECTS = readnews.o rfuncs.o rfuncs2.o rextern.o process.o rpathinit.o $(OBJECTS) visual.o virtterm.o dir.o + visual.o: visual.c rparams.h Makefile + $(CC) $(CFLAGS) -DNETPATHS=\"$(NETPATHS)\" -c visual.c + vnews: $(VOBJECTS) ! $(CC) $(LFLAGS) $(VOBJECTS) -ltermcap -ljobs -ldbm -o $@ *************** -- Bill Sebok Princeton Univ. Astrophysics {allegra,akgua,burl,cbosgd,decvax,ihnp4,kpno,princeton}!astrovax!wls