|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: M T
Length: 16222 (0x3f5e) Types: TextFile Names: »MH-patches«
└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0 └─⟦35176feda⟧ »EurOpenD22/isode/isode-6.tar.Z« └─⟦de7628f85⟧ └─⟦this⟧ »isode-6.0/others/quipu/uips/fred/MH-patches«
[ MH-patches - Tue Jul 18 00:47:38 1989 - WP patches to MH - /mtr ] Here are patches to MH 6.5 to allow send/whom to expand names into addresses. The user specifies a name by bracketing a WhitePages query between '<<' and '>>' using fred's whois syntax, e.g., To: << rose -org nyser >> At the "What now?" prompt, the user can say "whom" to have the names expanded into addresses. Alternately, the "send" option can be used as well. For each query appearing between '<<' and '>>', fred will be asked to perform a white pages resolution. All matches are printed and the user is asked to select one. If one is not selected, the user remains with fred, to make more queries, until eventually one is selected (or the user exits fred to abort the expansion process). Note that expansion can occur only if whom/send is invoked interactively. If you use push, then the expansion will fail because fred will be unable to query you to select/confirm the right entry to use for the substitution. To enable these patches, add "options WP" to your MH config file, run mhconfig, apply the patches, and then do "make" from the top-level. Note that this code has only been tested with #undef BERK in effect. I believe that it should work okay, but since I don't run with BERK defined, I have no way of knowing. /mtr diff -c sbr/*addrsbr.c diff -c uip/_post.c uip/post.c diff -c uip/*whom.c diff -c uip/*whatnowsbr.c diff -c zotnet/mf/*mf.c *** sbr/:addrsbr.c Mon Oct 30 17:22:49 1989 --- sbr/addrsbr.c Sat Nov 4 22:18:39 1989 *************** *** 103,108 **** --- 103,117 ---- char *getusr (); + + #ifdef WP + int do_wp = 0; + + #ifdef BERK + char *wp_expand (); + #endif + #endif + /* \f */ char *getname (addrs) *************** *** 171,176 **** --- 180,214 ---- while ( (c = *addrs++) == ',' || isspace(c)) ; + #ifdef WP + if (do_wp && c == '<' && *addrs == '<') { + register char *cp, + *dp, + *ep; + + if (cp = index (++addrs, '>')) { + *++cp = NULL; + if (dp = wp_expand (addrs, NULLCP)) { + *(addrs - 1) = NULL; + ep = concat (saved_addr, dp, cp, NULLCP); + addrs = ep + strlen (saved_addr); + while ((c = *addrs++) == ',' || isspace (c)) + continue; + free (saved_addr); + saved_addr = ep; + free (dp); + } + else { + err = "unable to expand WhitePages query"; + (void) strcpy (adrtext, addrs); + addrs = cp; + goto out; + } + + } + } + #endif + *nxtout = *adrcopy = '\0'; while (state != EOA) { *adrcopy++ = c; *************** *** 267,280 **** * addr points to where we should start scanning next time. */ *(nxtout-1) = *(adrcopy-1) = '\0'; if (*adr && !err) { adr_ptr = addrs-1; - return adrtext; } else { free (saved_addr); adr_ptr = NULL; - return NULL; } #else not BERK register struct adrx *ap; --- 305,320 ---- * addr points to where we should start scanning next time. */ *(nxtout-1) = *(adrcopy-1) = '\0'; + #ifdef WP + out: ; + #endif if (*adr && !err) { adr_ptr = addrs-1; } else { free (saved_addr); adr_ptr = NULL; } + return adrtext; #else not BERK register struct adrx *ap; *************** *** 825,827 **** --- 865,1013 ---- return 0; } + + /* \f */ + + #ifdef WP + #include <signal.h> + + + static char *fredproc = NULL; + + + char *wp_expand (query, error) + char *query, + *error; + { + register int cc, + i, + vecp; + int (*istat) (), (*qstat) (), (*pstat) (); + register char *bp, + *cp; + char *ep, + buffer[BUFSIZ], + fds[10], + *vec[10]; + static int child_id = NOTOK, + pdi[2], + pdo[2]; + + if (error) + (void) strcpy (error, "unable to expand WhitePages query: "); + + if (child_id == NOTOK || kill (child_id, 0) == NOTOK) { + if (!isatty (fileno (stdout))) { + if (error) + (void) strcat (error, "not a tty"); + return NULLCP; + } + + if (fredproc == NULL && (fredproc = m_find ("fredproc")) == NULL) + fredproc = "fred"; + + if (pipe (pdi) == NOTOK) { + if (error) + (void) strcat (error, "unable to pipe"); + + return NULLCP; + } + + if (pipe (pdo) == NOTOK) { + if (error) + (void) strcat (error, "unable to pipe"); + + losing: ; + (void) close (pdi[0]); + (void) close (pdi[1]); + return NULLCP; + } + + for (i = 0; (child_id = vfork ()) == NOTOK && i < 5; i++) + sleep (5); + + switch (child_id) { + case NOTOK: + if (error) + (void) strcat (error, "unable to fork"); + + (void) close (pdo[0]); + (void) close (pdo[1]); + goto losing; + + case OK: + (void) close (pdi[0]); + (void) close (pdo[1]); + (void) sprintf (fds, "%d %d", pdo[0], pdi[1]); + vecp = 0; + vec[vecp++] = r1bindex (fredproc, '/'); + vec[vecp++] = "-q"; + vec[vecp++] = fds; + vec[vecp] = NULL; + execvp (fredproc, vec); + _exit (-1); /* NOTREACHED */ + + default: + (void) close (pdi[1]); + (void) close (pdo[0]); + break; + } + } + + istat = signal (SIGINT, SIG_IGN); + qstat = signal (SIGQUIT, SIG_IGN); + + pstat = signal (SIGPIPE, SIG_IGN); + + (void) sprintf (buffer, "%s\n", query); + cc = write (pdo[1], buffer, i = strlen (buffer)); + + (void) signal (SIGPIPE, pstat); + + if (cc != i) { + if (error) + (void) strcat (error, "write to pipe failed"); + + lost_child: ; + (void) kill (child_id, SIGTERM); + (void) close (pdi[0]); + (void) close (pdo[1]); + + child_id = NOTOK; + return NULLCP; + } + + for (ep = (bp = buffer) + sizeof buffer - 1; + (i = read (pdi[0], bp, ep - bp)) > 0; ) { + for (cp = bp + i; bp < cp; bp++) + if (*bp == '\n') + break; + if (bp < cp) + break; + } + + (void) signal (SIGINT, istat); + (void) signal (SIGQUIT, qstat); + + if (i == NOTOK) { + if (error) + (void) strcat (error, "read from pipe failed"); + goto lost_child; + } + if (i == 0) { + if (error) + (void) sprintf (error + strlen (error), "%s exited prematurely", + fredproc); + goto lost_child; + } + *bp = NULL; + + if (error) + if (bp != buffer) + error[0] = NULL; + else + (void) strcpy (error, "unable to expand WhitePages query"); + + return (*buffer ? getcpy (buffer) : NULLCP); + } + #endif *** uip/_post.c Mon Oct 30 17:22:54 1989 --- uip/post.c Tue Aug 8 20:28:58 1989 *************** *** 91,97 **** #define NWATCSW 17 "nowatch", 0, ! #define WHOMSW 18 /* interface from whom */ "whom", -4, #define WIDTHSW 19 --- 91,97 ---- #define NWATCSW 17 "nowatch", 0, ! #define WHOMSW 18 /* interface from whom */ "whom", -4, #define WIDTHSW 19 *************** *** 122,127 **** --- 122,130 ---- #define SNOOPSW 29 "snoop", -5, + #define FILLSW 30 + "fill-in file", -7, + NULL, NULL }; *************** *** 284,289 **** --- 287,298 ---- static int encryptsw = 0; /* encrypt it */ + #ifdef WP + extern int do_wp; /* fill-in white pages queries */ + #endif + static char *fill_in = NULLCP; + + long lseek (), time (); /* \f MAIN */ *************** *** 486,491 **** --- 495,507 ---- snoop++; continue; #endif SENDMTS + + case FILLSW: + #ifdef WP + if (!(fill_in = *argp++) || *fill_in == '-') + adios (NULLCP, "missing argument to %s", argp[-2]); + #endif + continue; } if (msg) adios (NULLCP, "only one message at a time!"); *************** *** 494,499 **** --- 510,518 ---- } (void) alias (AliasFile); + #ifdef WP + do_wp++; + #endif /* \f */ *************** *** 534,540 **** else #endif MHMTS if (whomsw) { ! if ((out = fopen ("/dev/null", "w")) == NULL) adios ("/dev/null", "unable to open"); } else { --- 553,559 ---- else #endif MHMTS if (whomsw) { ! if ((out = fopen (fill_in ? fill_in : "/dev/null", "w")) == NULL) adios ("/dev/null", "unable to open"); } else { *************** *** 575,581 **** case BODY: case BODYEOF: finish_headers (out); ! if (whomsw) break; fprintf (out, "\n%s", buf); while (state == BODY) { --- 594,600 ---- case BODY: case BODYEOF: finish_headers (out); ! if (whomsw && !fill_in) break; fprintf (out, "\n%s", buf); while (state == BODY) { *************** *** 699,709 **** } hdr = &hdrtab[i]; ! if (hdr -> flags & HIGN) return; if (hdr -> flags & HBAD) { ! advise (NULLCP, "illegal header line -- %s:", name); ! badmsg++; return; } msgflags |= (hdr -> set & ~(MVIS | MINV)); --- 718,735 ---- } hdr = &hdrtab[i]; ! if (hdr -> flags & HIGN) { ! if (fill_in) ! fprintf (out, "%s: %s", name, str); return; + } if (hdr -> flags & HBAD) { ! if (fill_in) ! fprintf (out, "%s: %s", name, str); ! else { ! advise (NULLCP, "illegal header line -- %s:", name); ! badmsg++; ! } return; } msgflags |= (hdr -> set & ~(MVIS | MINV)); *************** *** 711,716 **** --- 737,747 ---- if (hdr -> flags & HSUB) subject = subject ? add (str, add ("\t", subject)) : getcpy (str); if (hdr -> flags & HFCC) { + if (fill_in) { + fprintf (out, "%s: %s", name, str); + return; + } + if (cp = rindex (str, '\n')) *cp = NULL; for (cp = pp = str; cp = index (pp, ','); pp = cp) { *************** *** 759,765 **** nameoutput = linepos = 0; (void) sprintf (namep, "%s%s", ! (hdr -> flags & HMNG) ? "Original-" : "", name); for (grp = 0, mp = tmpaddrs.m_next; mp; mp = np) if (mp -> m_nohost) { /* also used to test (hdr -> flags & HTRY) */ --- 790,797 ---- nameoutput = linepos = 0; (void) sprintf (namep, "%s%s", ! !fill_in && (hdr -> flags & HMNG) ? "Original-" : "", ! name); for (grp = 0, mp = tmpaddrs.m_next; mp; mp = np) if (mp -> m_nohost) { /* also used to test (hdr -> flags & HTRY) */ *************** *** 810,817 **** advise (NULLCP, "%s: field does not allow groups", name); badmsg++; } ! if (linepos) (void) putc ('\n', out); } /* \f */ --- 842,852 ---- advise (NULLCP, "%s: field does not allow groups", name); badmsg++; } ! if (linepos) { ! if (fill_in && grp > 0) ! (void) putc (';', out); (void) putc ('\n', out); + } } /* \f */ *************** *** 942,948 **** if (mp -> m_mbox == NULL || ((flags & HTRY) && !insert (mp))) return 0; ! if ((flags & HBCC) || mp -> m_ingrp) return 1; if (!nameoutput) { --- 977,983 ---- if (mp -> m_mbox == NULL || ((flags & HTRY) && !insert (mp))) return 0; ! if (!fill_in && ((flags & HBCC) || mp -> m_ingrp)) return 1; if (!nameoutput) { *************** *** 953,959 **** if (*aka && mp -> m_type != UUCPHOST && !mp -> m_pers) mp -> m_pers = getcpy (aka); if (format) { ! if (mp -> m_gname) (void) sprintf (cp = buffer, "%s;", mp -> m_gname); else cp = adrformat (mp); --- 988,994 ---- if (*aka && mp -> m_type != UUCPHOST && !mp -> m_pers) mp -> m_pers = getcpy (aka); if (format) { ! if (mp -> m_gname && !fill_in) (void) sprintf (cp = buffer, "%s;", mp -> m_gname); else cp = adrformat (mp); *************** *** 987,1004 **** int len; char *cp; ! if (flags & HBCC) return; if (!nameoutput) { fprintf (out, "%s: ", name); linepos += (nameoutput = strlen (name) + 2); } ! cp = concat (group, ";", NULLCP); len = strlen (cp); ! if (linepos != nameoutput) if (len + linepos + 2 > outputlinelen) { fprintf (out, ",\n%*s", nameoutput, ""); linepos = nameoutput; --- 1022,1041 ---- int len; char *cp; ! if (!fill_in && (flags & HBCC)) return; if (!nameoutput) { fprintf (out, "%s: ", name); linepos += (nameoutput = strlen (name) + 2); + if (fill_in) + linepos -= strlen (group); } ! cp = fill_in ? group : concat (group, ";", NULLCP); len = strlen (cp); ! if (linepos > nameoutput) if (len + linepos + 2 > outputlinelen) { fprintf (out, ",\n%*s", nameoutput, ""); linepos = nameoutput; *** uip/_whom.c Mon Oct 30 17:22:52 1989 --- uip/whom.c Mon Jul 17 09:22:31 1989 *************** *** 35,40 **** --- 35,43 ---- #define SNOOPSW 10 "snoop", -5, + #define FILLSW 11 + "fill-in file", -7, + NULL, NULL }; *************** *** 125,130 **** --- 128,134 ---- case ALIASW: case CLIESW: case SERVSW: + case FILLSW: vec[vecp++] = --cp; if (!(cp = *argp++) || *cp == '-') adios (NULLCP, "missing argument to %s", argp[-2]); *** uip/_whatnowsbr.c Mon Oct 30 17:22:57 1989 --- uip/whatnowsbr.c Mon Jul 17 12:04:19 1989 *************** *** 758,764 **** --- 758,773 ---- int pid; register int vecp; char *vec[MAXARGS]; + #ifdef WP + char *cp, + draft[BUFSIZ], + backup[BUFSIZ]; + #endif + #ifdef WP + (void) strcpy (draft, m_scratch (file, invo_name)); + #endif + m_update (); (void) fflush (stdout); *************** *** 774,779 **** --- 783,792 ---- if (arg) while (*arg) vec[vecp++] = *arg++; + #ifdef WP + vec[vecp++] = "-fill-in"; + vec[vecp++] = draft; + #endif vec[vecp] = NULL; execvp (whomproc, vec); *************** *** 782,787 **** --- 795,822 ---- _exit (-1); /* NOTREACHED */ default: + #ifndef WP return (pidwait (pid, NOTOK) & 0377 ? 1 : 0); + #else + if (pidwait (pid, NOTOK)) { + (void) unlink (draft); + return 1; + } + break; + #endif } + + #ifdef WP + if (rename (file, cp = m_backup (file)) == NOTOK) { + advise (cp, "unable to rename %s to", file); + (void) unlink (draft); + return 1; + } + if (rename (draft, file) == NOTOK) { + advise (file, "unable to rename %s to ", draft); + return 1; + } + + return 0; + #endif } *** zotnet/mf/_mf.c Mon Oct 30 17:22:59 1989 --- zotnet/mf/mf.c Mon Oct 30 20:32:38 1989 *************** *** 298,303 **** --- 298,306 ---- #define QUOTE '\\' + #ifdef WP + #define LX_WP (-1) + #endif #define LX_END 0 #define LX_ERR 1 #define LX_ATOM 2 *************** *** 351,361 **** --- 354,375 ---- static struct adrx adrxs2; + + #ifdef WP + char *concat (); + + extern int do_wp; + char *wp_expand (); + #endif + /* \f */ struct adrx *getadrx (addrs) register char *addrs; { + #ifdef WP + int save_lex; + #endif register char *bp; register struct adrx *adrxp = &adrxs2; *************** *** 385,390 **** --- 399,427 ---- return NULL; } + #ifdef WP + bp = cp, save_lex = last_lex; + if (my_lex (adr) == LX_WP) { + register char *ep, + *fp; + + if (fp = wp_expand (adr, err)) { + *bp = NULL; + ep = concat (dp, fp, cp, (char *) NULL); + cp = ep + strlen (dp), last_lex = save_lex; + free (dp); + dp = ep; + free (fp); + } + else { + ap = bp, save_lex = last_lex; + goto out; + } + } + else + cp = bp, last_lex = save_lex; + #endif + switch (parse_address ()) { case DONE: free (dp); *************** *** 409,414 **** --- 446,454 ---- break; } + #ifdef WP + out: ; + #endif if (err[0]) for (;;) { switch (last_lex) { *************** *** 798,803 **** --- 838,858 ---- cp = NULL; return (last_lex = LX_END); } + + #ifdef WP + if (do_wp && c == '<' && *cp == '<') + for (cp++;;) + switch (c = *cp++) { + case '>': + *bp = NULL; + cp++; + return (last_lex = LX_WP); + + default: + *bp++ = c; + continue; + } + #endif if (c == '(') for (*bp++ = c, i = 0;;)