📄 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. NOTE WELL: These are very different from the patches supplied earlier in the file MH-patches. You should revert your MH sources back to their original condition and then apply the patches here... The user specifies a name by bracketing a WhitePages query between '<<' and '>>' using the user-friendly naming syntax, e.g., To: << rose, psi, us >> 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 '>>', the DA-server 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 returns to what-now level. Note that expansion can occur only if whom/send is invoked interactively. If you use push, then the expansion will fail because the DA-server 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 will not work if you have options BERK in your config file. Specifying this option will disable the WP option. Finally, you must run a DA-server. The Administrator's Guide says how to do this. Basically: 1. start /usr/etc/dad from /etc/rc.local 2. (optionally) add set server hostname to your /usr/etc/fredrc file, where "hostname" is the domain-name or IP-address of the machine running dad. 3. tell your MH users to add da-server: hostname to their MH profile./mtrcd /wp2/home/src/uci/mh-6.6diff -c sbr/addrsbr.c.orig sbr/addrsbr.cdiff -c sbr/m_whatnow.c.orig sbr/m_whatnow.cdiff -c uip/post.c.orig uip/post.cdiff -c uip/whatnowsbr.c.orig uip/whatnowsbr.cdiff -c uip/whom.c.orig uip/whom.cdiff -c zotnet/mf/mf.c.orig zotnet/mf/mf.cdiff -c zotnet/mts/client.c.orig zotnet/mts/client.c*** sbr/addrsbr.c.orig Thu Jan 10 02:12:32 1991--- sbr/addrsbr.c Thu Jan 10 03:53:04 1991****************** 4,12 **** #include "../h/addrsbr.h" #include "../zotnet/mf.h" #include <stdio.h>! #ifdef BERK #include <ctype.h>! #endif BERK /* High level parsing of addresses: --- 4,12 ---- #include "../h/addrsbr.h" #include "../zotnet/mf.h" #include <stdio.h>! #if defined(BERK) || defined(WP) #include <ctype.h>! #endif /* High level parsing of addresses: ****************** 103,108 ****--- 103,117 ---- char *getusr (); + + #ifdef BERK+ #undef WP+ #endif+ + #ifdef WP+ int do_wp = 0;+ #endif+ /* */ char *getname (addrs)****************** 824,826 ****--- 833,1211 ---- return 0; }+ + /* */+ + #ifdef WP+ #include <setjmp.h>+ #include <signal.h>+ #include <sys/ioctl.h>+ + + static char das_response[BUFSIZ];+ static char das_host[BUFSIZ];+ static char das_port[BUFSIZ];+ + static FILE *das_input = NULL;+ static FILE *das_output;+ + static int armed = 0;+ static int interrupted;+ static jmp_buf intrenv;+ + int intrser ();+ + + extern int errno;+ + /* */+ + char *wp_expand (query, error)+ char *query,+ *error;+ {+ int result,+ (*istat) ();+ char buffer[BUFSIZ];+ + if (error)+ (void) strcpy (error, "unable to expand WhitePages query: ");+ + if (!isatty (fileno (stdout))) {+ if (error)+ (void) strcat (error, "not a tty");+ + return NULLCP;+ }+ + if (das_input == NULL && das_init () == NOTOK) {+ if (error)+ (void) strcat (error, das_response);+ + return NULLCP;+ }+ + fprintf (stderr, "\n[ Expanding %s ]\n", query);+ (void) fflush (stderr);+ + (void) sprintf (buffer, "fred -ufn -mailbox,%s", query);+ + setsigx (istat, SIGINT, intrser);+ interrupted = 0;+ + result = das_lookup (buffer);+ + (void) signal (SIGINT, istat);+ + if (result == NOTOK) {+ if (error)+ (void) strcat (error, das_response);+ + return NULLCP;+ }+ + if (error)+ error[0] = NULL;+ return (getcpy (das_response));+ }+ + /* */+ + static int das_init ()+ {+ int fd1,+ fd2;+ char *daserver = m_find ("da-server");+ + if (!daserver && !(daserver = getenv ("DA-SERVER"))) {+ (void) strcpy (das_response, "no entry for DA-server in MH-profile");+ return NOTOK;+ }+ + if ((fd1 = client (daserver, "tcp", "411", 0, das_response)) == NOTOK)+ return NOTOK;+ (void) ioctl (fd1, FIOCLEX, NULLCP);+ + if ((fd2 = dup (fd1)) == NOTOK) {+ (void) sprintf (das_response,+ "unable to dup connection descriptor: Errno %d",+ errno);+ (void) close (fd1);+ return NOTOK;+ }+ (void) ioctl (fd2, FIOCLEX, NULLCP);+ + if ((das_input = fdopen (fd1, "r")) == NULL+ || (das_output = fdopen (fd2, "w")) == NULL) {+ (void) strcpy (das_response, "fdopen failed on connection descriptor");+ if (das_input)+ (void) fclose (das_input), das_input = NULL;+ else+ (void) close (fd1);+ (void) close (fd2);+ return NOTOK;+ }+ + (void) signal (SIGPIPE, SIG_IGN);+ + switch (getline (das_response, sizeof das_response, das_input)) {+ case OK: + if (*das_response == '+') {+ int a[5];+ + if (sscanf (das_response + sizeof "+OK " - 1,+ "%d.%d.%d.%d %u", a, a + 1, a + 2, a + 3, a + 4)+ != 5) {+ (void) strcpy (das_host, das_response);+ (void) sprintf (das_response,+ "malformed response from DA-server (%s)",+ das_host);+ goto losing;+ }+ (void) sprintf (das_host, "%d.%d.%d.%d",+ a[0], a[1], a[2], a[3]);+ (void) sprintf (das_port, "%u", a[4]);+ + return OK;+ }+ /* else fall... */+ + case NOTOK: + case DONE: + losing: ;+ (void) fclose (das_input);+ (void) fclose (das_output);+ das_input = das_output = NULL;+ return NOTOK;+ }+ /* NOTREACHED */+ }+ + /* */+ + static int das_lookup (who)+ char *who;+ {+ int fd1,+ fd2;+ FILE *in,+ *out;+ + if ((fd1 = client (das_host, "tcp", das_port, 0, das_response)) == NOTOK) {+ losing: ;+ (void) fclose (das_input);+ (void) fclose (das_output);+ das_input = das_output = NULL;+ return NOTOK;+ }+ + if ((fd2 = dup (fd1)) == NOTOK) {+ (void) sprintf (das_response,+ "unable to dup connection descriptor: Errno %d",+ errno);+ (void) close (fd1);+ goto losing;+ }+ + if ((in = fdopen (fd1, "r")) == NULL+ || (out = fdopen (fd2, "w")) == NULL) {+ (void) strcpy (das_response, "fdopen failed on connection descriptor");+ if (in)+ (void) fclose (in);+ else+ (void) close (fd1);+ (void) close (fd2);+ goto losing;+ }+ + if (putline (who, out) == NOTOK) {+ real_losing: ;+ (void) fclose (in);+ (void) fclose (out);+ goto losing;+ }+ + for (;;) {+ char c,+ input[BUFSIZ];+ + if (getline (input, sizeof input, in) != OK)+ goto real_losing;+ + switch (c = input[0]) {+ case 'm':+ fprintf (stdout, "\n%s\n", input + 1);+ (void) strcpy (input, "m");+ goto stuff_it;+ + case 'y':+ fprintf (stdout, "%s", input + 1);+ (void) fflush (stdout);+ switch (yesno ()) {+ case DONE:+ (void) strcpy (das_response, "interrupted");+ goto real_losing;+ + case NOTOK:+ default:+ input[0] = 'n';+ break;+ + case OK:+ input[0] = 'y';+ break;+ }+ input[1] = NULL;+ stuff_it: ;+ if (putline (input, out) == NOTOK)+ goto real_losing;+ continue;+ + case 'e':+ case 'p':+ case 'L':+ case 'l':+ case 'd':+ unexpected: ;+ (void) sprintf (das_response,+ "unexpected response from DAP-listener: %c",+ c);+ goto real_losing;+ + case '1':+ (void) strcpy (das_response, input + 1);+ (void) fclose (in);+ (void) fclose (out);+ return OK;+ + case '2':+ (void) strcpy (das_response, input + 1);+ goto real_losing;+ + default:+ if (isdigit (c))+ goto unexpected;+ + (void) sprintf (das_response,+ "unknown response from DAP-listener: %c", c);+ goto real_losing;+ }+ }+ }+ + /* */+ + static int getline (s, n, iop)+ char *s;+ int n;+ FILE * iop;+ {+ int c;+ char *p;+ + p = s;+ while (--n > 0 && (c = fgetc (iop)) != EOF)+ if ((*p++ = c) == '\n')+ break;+ if (ferror (iop) && c != EOF) {+ (void) strcpy (das_response, "error on connection");+ return NOTOK;+ }+ if (c == EOF && p == s) {+ (void) strcpy (das_response, "connection closed by foreign host");+ return DONE;+ }+ *p = NULL;+ if (*--p == '\n')+ *p = NULL;+ if (*--p == '\r')+ *p = NULL;+ + return OK;+ }+ + + static putline (s, iop)+ char *s;+ FILE * iop;+ {+ (void) fprintf (iop, "%s\n", s);+ (void) fflush (iop);+ if (ferror (iop)) {+ (void) strcpy (das_response, "lost connection");+ return NOTOK;+ }+ + return OK;+ }+ + /* */+ + static int yesno () {+ int x,+ y,+ result;+ + if (interrupted) {+ interrupted = 0;+ return DONE;+ }+ + switch (setjmp (intrenv)) {+ case OK: + armed++;+ break;+ + case NOTOK: + default: + printf ("\n");+ armed = 0;+ return DONE;+ }+ + again: ;+ x = y = getc (stdin);+ while (y != '\n' && y != EOF)+ y = getc (stdin);+ + switch (x) {+ case 'y': + case '\n':+ result = OK;+ break;+ + case 'n': + result = NOTOK;+ break;+ + case EOF: + result = DONE;+ clearerr (stdin);+ break;+ + default: + printf ("Please type 'y' or 'n': ");+ goto again;+ }+ + armed = 0;+ + return result;+ }+ + + /* ARGSUSED */+ + static int intrser (i)+ int i;+ {+ #ifndef BSD42+ (void) signal (SIGINT, intrser);+ #endif+ + if (armed)+ longjmp (intrenv, NOTOK);+ + interrupted++;+ }+ #endif*** sbr/m_whatnow.c.orig Thu Oct 29 15:00:45 1987--- sbr/m_whatnow.c Thu Jan 10 02:46:15 1991****************** 27,32 ****--- 27,34 ---- vec[vecp++] = r1bindex (whatnowproc, '/'); vec[vecp] = NULL; + if (bp = m_find ("da-server"))+ (void) putenv ("DA-SERVER", bp); (void) putenv ("mhdraft", file); if (mp) (void) putenv ("mhfolder", mp -> foldpath);*** uip/post.c.orig Thu Jan 10 02:14:15 1991--- uip/post.c Wed Jan 9 14:26:56 1991****************** 122,127 ****--- 122,130 ---- #define SNOOPSW 29 "snoop", -5, + #define FILLSW 30+ "fill-in file", -7,+ NULL, NULL }; ****************** 284,289 ****--- 287,302 ---- static int encryptsw = 0; /* encrypt it */ + #ifdef BERK+ #undef WP+ #endif+ + #ifdef WP+ extern int do_wp; /* fill-in white pages queries */+ #endif+ static char *fill_in = NULLCP;+ + long lseek (), time (); /* MAIN */****************** 486,491 ****--- 499,511 ---- 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 ****--- 514,522 ---- } (void) alias (AliasFile);+ #ifdef WP+ do_wp++;+ #endif /* */ ****************** 534,540 **** else #endif MHMTS if (whomsw) {! if ((out = fopen ("/dev/null", "w")) == NULL) adios ("/dev/null", "unable to open"); } else {--- 557,563 ---- else #endif MHMTS if (whomsw) {! if ((out = fopen (fill_in ? fill_in : "/dev/null", "w")) == NULL) adios ("/dev/null", "unable to open"); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -