mclure (03/09/83)
#N:sri-unix:1000041:000:9020 sri-unix!mclure Mar 8 14:09:00 1983 We have installed Notes 1.2 and have a few mods/diffs and comments. 1) When stepping through notesfiles, it is nice to avoid the 'nfname...' repetition since it scrolls the screen and looks ugly. harpo!ber's suggestion of staying in place and overwriting is elegant and our users like it. Mods to two modules are necessary, control.c and cursor.c. Since all our terminals have ceol ability, we didn't bother to put in a check for using the 'nfname...' scheme for terminals that don't have the capability. 2) Included in the diff listing below for cursor.c is a fix which caused notes to not send control codes to terminals with capability strings longer than 60 bytes (!). Making the buffer 1024 bytes long seems sufficient. This was first noticed on an Ambassador with predictably unpleasant results. 3) A third mod is in dsply.c and prtind.c. We run Berkeley 2.8 and it has the FIONREAD ioctl capability for determining if anything awaits on the input queue for the current terminal. This is extremely useful when put into dsply.c and prtind.c so that people can type-ahead to notes and notes will heed their commands without finishing the entire screen display. On 1200 baud Ambassador length 60 home terminals, this saves considerable time in reading notes. I believe Berkeley 4.1 and 4.1a have the same FIONREAD, so I added them to the #if's. 4) The entry for the E command in read.help seems wrong. It states: E Edit the text of a note/response. Only the current page of continued notes is modified. However, the name of a tempfile with the entire note is passed to the editor and apparently the entire editted note replaces the old note. Looks like read.help should simply delete the second sentence above. 5) The -s option of nfpipe seems to have mysteriously disappeared. This was very useful! We have a local bulletin board called bboard which is extremely simple-minded and meant for naive users who don't want to take the time to learn notes. However, we want anything sent to bboard also put into the 'general' notefile and the msgs newsgroup. To do this, our mailer pipes the output of mail sent to bboard to 'delivermail msgs' and to nfmail. Nfmail was provided to me by Ray (we made some local enhancements) but doesn't seem to be on the normal distribution. Nfmail searches the standard input for 'Subject: foobar' and 'From: whoever' and passes these to 'nfpipe -s whoever -t foobar' with the appropriate notefile name, in this case 'general'. The -s makes the note appear as if is from the correct person (it is actually being written by the super-user mail process) with the correct subject. Below is a diff which puts the -s back into nfpipe.c and also I've included the useful nfmail program and the corresponding Makefile diff to include handling nfmail. Stuart Cracraft Usenet: ucbvax!menlo70!sri-unix!mclure Arpanet: mclure@sri-unix ******************** diff control.c.new control.c.old ******************** 91,93c91 < putchar('\r'); /* Suggested by harpo!ber */ < ceol(); < printf("%s",nfname); --- > printf ("%s...", nfname); ******************** diff cursor.c.new cursor.c.old ******************** 17c17 < static char bufspace[1024]; /* term capabilities */ --- > static char bufspace[60]; /* term capabilities */ 19d18 < static char *ce; /* clear to eol */ 95,102d93 < ceol() < { < if (ttyinit == 0) < cursget (); < if (ce[0] != 0) < tputs (ce, 1, charout); < } < 135d125 < ce = tgetstr ("ce", &q); /* ceol */ ******************** diff dsply.c.new dsply.c.old ******************** 2,4d1 < #if defined(BSD28) || defined(BSD41) || defined(BSD41A) < #include <sys/ioctl.h> < #endif defined(BSD28) || defined(BSD41) || defined(BSD41A) 235,237d231 < #if defined(BSD28) || defined(BSD41) || defined(BSD41A) < long retval = 0; < #endif defined(BSD28) || defined(BSD41) || defined(BSD41A) 261,266d254 < #if defined(BSD28) || defined(BSD41) || defined(BSD41A) < if (ioctl(0,FIONREAD,&retval)) /* If this call fails */ < ; /* Assume no input waiting */ < else if (retval) < goto exisho; /* Otherwise, he typed */ < #endif defined(BSD28) || defined(BSD41) || defined(BSD41A) 296,298d283 < #if defined(BSD28) || defined(BSD41) || defined(BSD41A) < exisho: < #endif defined(BSD28) || defined(BSD41) || defined(BSD41A) ******************** diff prtind.c.new prtind.c.old ******************** 2,4d1 < #if defined(BSD28) || defined(BSD41) || defined(BSD41A) < #include <sys/ioctl.h> < #endif defined(BSD28) || defined(BSD41) || defined(BSD41A) 29,31d25 < #if defined(BSD28) || defined(BSD41) || defined(BSD41A) < long retval = 0; < #endif defined(BSD28) || defined(BSD41) || defined(BSD41A) 96,101d90 < #if defined(BSD28) || defined(BSD41) || defined(BSD41A) < if (ioctl(0,FIONREAD,&retval)) /* If this call fails */ < ; /* Assume no input waiting */ < else if (retval) < return; /* Otherwise, he typed */ < #endif defined(BSD28) || defined(BSD41) || defined(BSD41A) ******************** diff nfpipe.c.new nfpipe.c.old ******************** 27,28c27 < *ntitle, < *nsender; --- > *ntitle; 38c37 < printf ("Usage: %s notefile [-s sender] [-t title] [-d] [-a]\n", argv[0]); --- > printf ("Usage: %s notefile [-t title] [-d] [-a]\n", argv[0]); 43d41 < nsender = NULL; /* No sender */ 54,56d51 < case 's': /* sender */ < nsender = argv[++i]; < break; 87,93c82 < if (globuid == 0 && nsender != NULL) /* superuser wants some sender */ < { < strncpy(auth.aname,nsender,NAMESZ); < auth.aid = 0; < } < else < getname (&auth, anon); /* grab name */ --- > getname (&auth, anon); /* grab name */ ******************** nfmail.c ******************** #include <stdio.h> #define FALSE 0 #define TRUE 1 #define NFPIPE "/usr/local/nfpipe" char *getadr(); FILE * popen (); main (argc, argv) char **argv; { register FILE * Ftmp; char command[BUFSIZ], tmpname[BUFSIZ], title[BUFSIZ], from[BUFSIZ], buf[BUFSIZ]; int gotsubj = FALSE, gotfrom = FALSE; argc--; argv++; if (!argc) { fprintf (stderr, "Usage: nfmail <topic>\n"); exit (1); } sprintf (tmpname, "/tmp/nfm%05d%\0", getpid ()); if ((Ftmp = fopen (tmpname, "w")) == NULL) { sprintf (command, "%s %s%\0", NFPIPE, *argv); dopipe (command, stdin); fprintf (stderr, "nfmail: can't fopen temp file, but the mail gets thru\n"); } while (gets (buf) != NULL) if (!buf[0]) break; else if (!strncmp (buf, "Subject: ", 9)) { if (!gotsubj) { strcpy (title, &buf[9]); gotsubj = TRUE; } } else if (!strncmp (buf, "From: ", 6)) { if (!gotfrom) { strcpy(from, &buf[6]); gotfrom = TRUE; } } copy (stdin, Ftmp); fclose (Ftmp); if (!gotsubj) title[0] = '\0'; if ((Ftmp = fopen (tmpname, "r")) == NULL) { fprintf (stderr, "nfmail: can't re-fopen temp file?!\n"); exit (2); } sprintf (command, "%s %s -t \"%s\" -s \"%s\"%\0", NFPIPE, *argv, title, getadr(from)); dopipe (command, Ftmp); fclose (Ftmp); unlink (tmpname); exit (0); } dopipe (command, File) char *command; FILE * File; { register FILE * Pipe; if ((Pipe = popen (command, "w")) == NULL) { fprintf (stderr, "nfmail: can't popen (%s)!?\n", command); exit (2); } copy (File, Pipe); fclose (Pipe); } copy (From, To) FILE * From, *To; { register int c; while ((c = getc (From)) != EOF) putc (c, To); } char * getadr(str) char *str; { static char buf[100]; register char *bp, *bp1; bp1=buf; bp=str; for(;;) { while ((*bp != '\0') && (*bp != '(') && (*bp != '<')) *bp1++ = *bp++; if (*bp == '\0') return (buf); if (*bp == '<') { bp1 = buf; bp++; while ((*bp != '\0') && (*bp != '>')) *bp1++ = *bp++; *bp1 = '\0'; return(buf); } while ((*bp != '\0') && (*bp != ')')) bp++; bp++; } } ******************** diff Makefile.new Makefile.old ******************** 92c92 < user: main nfpipe nfmail nfprint nfstats checknotes --- > user: main nfpipe nfprint nfstats checknotes 116,118c116,117 < echo > $(BIN)/nfmail < -chown $(NOTES) $(BIN)/notes $(BIN)/nfprint $(BIN)/nfstats $(BIN)/nfpipe $(BIN)/checknotes $(BIN)/nfmail < -chgrp $(NOTESGRP) $(BIN)/notes $(BIN)/nfprint $(BIN)/nfstats $(BIN)/nfpipe $(BIN)/checknotes $(BIN)/nfmail --- > -chown $(NOTES) $(BIN)/notes $(BIN)/nfprint $(BIN)/nfstats $(BIN)/nfpipe $(BIN)/checknotes > -chgrp $(NOTESGRP) $(BIN)/notes $(BIN)/nfprint $(BIN)/nfstats $(BIN)/nfpipe $(BIN)/checknotes 173,176d171 < cp nfmail $(BIN)/nfmail < -chown $(NOTES) $(BIN)/nfmail < -chgrp $(NOTESGRP) $(BIN)/nfmail < chmod 4711 $(BIN)/nfmail 315,318d309 < nfmail: nfmail.o < @echo loading nfmail < @cc $(CFLAGS) $(LFLAGS) -o nfmail nfmail.o < 745d735 < nfmail.o :