chuqui@nsc.UUCP (Chuq) (08/21/84)
These diffs are for 2.10.2 (easily retrofitted to 2.10.1 as well) vnews and readnews. They allow you to use the pathalias database (normally /usr/lib/uucp/alpath) to optimize return paths for replys. This is a modification of Bill Sebok's version previously posted. The code is compile in when the define NETPATHS is defined to the location of the database. Optimized reply paths are generated when the -O (*ack*) flag is given to the program on the command line or on the options line of the newsrc. I've been using pathalias and these hacks for a couple of months and it makes a BIG turnaround on mail. chuq ------- defs.h ------- *** /tmp/d03901 Tue Aug 21 07:45:16 1984 --- defs.h Tue Aug 21 05:14:15 1984 *************** *** 54,59 #define V7MAIL /* Local mail format is V7 ("From ") */ #define SORTACTIVE /* if you want news presented in the order of the .newsrc */ #define ZAPNOTES /*if you want old style notes headers moved into the headers */ #define BSD4_2 /* If you are running 4.2 BSD */ #define MYORG "National Semiconductor, Sunnyvale"/* My organization. Please */ /* include your city (and state, and */ --- 54,60 ----- #define V7MAIL /* Local mail format is V7 ("From ") */ #define SORTACTIVE /* if you want news presented in the order of the .newsrc */ #define ZAPNOTES /*if you want old style notes headers moved into the headers */ + #define NETPATHS "/usr/lib/uucp/alpath" /* compiles in pathalias optimizing code to {read,v}news */ #define BSD4_2 /* If you are running 4.2 BSD */ #define MYORG "National Semiconductor, Sunnyvale"/* My organization. Please */ /* include your city (and state, and */ ------- rparams.h ------- *** /tmp/d03904 Tue Aug 21 07:45:21 1984 --- rparams.h Tue Aug 21 05:31:58 1984 *************** *** 22,27 #define fflag options[11].flag #define uflag options[12].flag #define eflag options[13].flag #define NEXT 0 #define SPEC 1 --- 22,28 ----- #define fflag options[11].flag #define uflag options[12].flag #define eflag options[13].flag + #define Oflag options[14].flag #define NEXT 0 #define SPEC 1 ------- process.c ------- *** /tmp/d03906 Tue Aug 21 07:45:25 1984 --- process.c Tue Aug 21 04:55:03 1984 *************** *** 27,32 'f', '\0', FALSE, OPTION, ANY, UNKNOWN,(char *)NULL, 'u', '\0', FALSE, OPTION, ANY, UNKNOWN,(char *)NULL, 'e', '\0', FALSE, OPTION, ANY, UNKNOWN,(char *)NULL, '\0', '\0', 0, 0, 0, 0, (char *)NULL }; --- 27,33 ----- 'f', '\0', FALSE, OPTION, ANY, UNKNOWN,(char *)NULL, 'u', '\0', FALSE, OPTION, ANY, UNKNOWN,(char *)NULL, 'e', '\0', FALSE, OPTION, ANY, UNKNOWN,(char *)NULL, + 'O', '\0', FALSE, OPTION, ANY, UNKNOWN,(char *)NULL, '\0', '\0', 0, 0, 0, 0, (char *)NULL }; ------- visual.c ------- *** /tmp/d03910 Tue Aug 21 07:45:35 1984 --- visual.c Tue Aug 21 05:51:20 1984 *************** *** 16,21 #include <errno.h> #include "rparams.h" #ifdef BSD4_2 #include "sys/dir.h" #define BIT(_a) (1<<((_a)-1)) --- 16,27 ----- #include <errno.h> #include "rparams.h" + #ifdef NETPATHS + # include <dbm.h> + # ifdef BSD4_2 /* 4.2 <dbm.h> defines NULL, causes redefine message */ + # undef NULL /* in <stdio.h> later. Thank you, Berkeley! */ + # endif BSD4_2 + #endif NETPATHS #ifdef BSD4_2 #include "sys/dir.h" #define BIT(_a) (1<<((_a)-1)) *************** *** 842,847 char subj[132]; char *p; char *replyname(); strcpy(tf, tft); mktemp(tf); --- 848,861 ----- char subj[132]; char *p; char *replyname(); + #ifdef NETPATHS + /* stuff for finding paths in pathalias database */ + static int dbmopen = 0; + static char newspaths[] = NETPATHS; + datum key, result; + register char *p1, *p2; + char sitename[100]; + #endif NETPATHS strcpy(tf, tft); mktemp(tf); *************** *** 872,878 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); --- 886,917 ----- else #endif p = replyname(&h); ! #ifdef NETPATHS ! /* use data base to find return paths - W. Sebok */ ! if (Oflag && dbmopen == 0) ! dbmopen = (dbminit(newspaths) == 0) ? 1 : -1 ; ! ! 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 (dbmopen > 0 && result.dptr != NULL) { ! fprintf(tfp,"To: "); ! fprintf(tfp,result.dptr,p2+1); ! fprintf(tfp,"\n"); ! } 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); ------- readr.c ------- *** /tmp/d03921 Tue Aug 21 07:46:09 1984 --- readr.c Tue Aug 21 07:21:08 1984 *************** *** 6,12 * readr - /bin/mail and msgs interface and associated functions. */ ! #include "rparams.h" #ifdef BSD4_2 #include <sys/dir.h> #else --- 6,29 ----- * readr - /bin/mail and msgs interface and associated functions. */ ! #include "rparams.h ! /* ! * This piece of ugliness is because <dbm.h> defines NULL on 4.2 systems. ! * To keep the compiler happy, we undef it, include <dbm.h>, undef it ! * again, and get the original definition back from <stdio.h>. I'm sure ! * there is an easier way but I don't feel like hacking the news .h ! * files now. Thanks a lot, Berkeley. Wasn't <sys/time.h> enough? ! */ ! #ifdef NETPATHS ! # ifdef BSD4_2 ! # undef NULL ! # include <dbm.h> ! # undef NULL ! # include <stdio.h> ! # else BSD4_2 ! # include <dbm.h> ! # endif BSD4_2 ! #endif NETPATHS #ifdef BSD4_2 #include <sys/dir.h> #else *************** *** 636,642 extern char MAILPARSER[]; struct stat statb; long creatm; ! hptr = &h; while (*bptr && index("d-", *bptr)) { switch (*bptr) { --- 653,667 ----- extern char MAILPARSER[]; struct stat statb; long creatm; ! #ifdef NETPATHS ! /* stuff for finding paths from pathalias database - W. Sebok */ ! static int dbmopen = 0; ! static char newspaths[] = NETPATHS; ! datum key, result; ! register char *p1, *p2; ! char sitename[100]; ! #endif NETPATHS ! hptr = &h; while (*bptr && index("d-", *bptr)) { switch (*bptr) { *************** *** 665,670 *rcbuf = '\0'; *curberk = '\0'; pathptr = replyname(hptr);; ptr = pathptr - 1; i = 0; for (ptr1 = address, ptr2 = pathptr; *ptr2; ptr1++, ptr2++) { --- 690,719 ----- *rcbuf = '\0'; *curberk = '\0'; pathptr = replyname(hptr);; + #ifdef NETPATHS + if (Oflag && dbmopen == 0) + dbmopen = (dbminit(newspaths) == 0) ? 1 : -1; + + 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 (dbmopen > 0 && 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++) { *************** *** 713,718 } else { fprintf(tfp, "To: %s\n", pathptr); fprintf(tfp, "Subject: %s\n", subj); fprintf(tfp, "References: %s\n\n", folbuf); fstat(fileno(tfp), &statb); creatm = statb.st_mtime; --- 762,771 ----- } else { fprintf(tfp, "To: %s\n", pathptr); fprintf(tfp, "Subject: %s\n", subj); + #ifdef NETPATHS + if (dbmopen > 0 && result.dptr != NULL) + fprintf(tfp,"News-path: %s\n",p1); + #endif NETPATHS fprintf(tfp, "References: %s\n\n", folbuf); fstat(fileno(tfp), &statb); creatm = statb.st_mtime; -- From the depths of the Crystal Cavern: Chuq Von Rospach {amd,decwrl,fortune,hplabs,ihnp4}!nsc!chuqui nsc!chuqui@decwrl.ARPA Dreams, dreams, enchanter! Gone with the harp's echo when the strings fall mute; with the flame's shadow when the fire dies. Be still, and listen.