epsilon@wet.UUCP (Eric P. Scott) (12/04/89)
This lets you type !newshist "[ESC]R" in rn and make sense of the References: line. Your netnews must use dbm/dbz; it won't work with with USG history. If you have dbz but not dbm.h, you'll have to get the definition of datum and the declarations for dbminit, dbmclose, and fetch from the dbz source. Define DBZ if you are using dbz (or have dbmclose available). Define BSD if stdio does something more or less reasonable when stdout is a terminal. -=EPS=- ------- #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # newshist.c # newshist.1 # This archive created: Sun Dec 3 22:49:31 1989 export PATH; PATH=/bin:$PATH echo shar: extracting "'newshist.c'" '(1630 characters)' if test -f 'newshist.c' then echo shar: will not over-write existing file "'newshist.c'" else sed 's/^X//' << \SHAR_EOF > 'newshist.c' X/* X * Print B News history record for specified message-ids X * Eric P. Scott, Wetware Diversions, December 1989 X * thanks to David C. Lawrence <tale@cs.rpi.edu> X */ X#include <stdio.h> X#include <dbm.h> X#ifndef HIST X#define HIST "/usr/lib/news/history" X#endif X X#ifndef lint Xstatic char sccsid[]="@(#)newshist.c 1.1 (Wet) 12/03/89"; X#endif X Xmain(argc, argv) Xint argc; Xchar *argv[]; X{ X register char *p, *q; X register int i, c; X register char *a; X register FILE *f; X datum k, d; X char buf[BUFSIZ]; X X#ifndef BSD X char *malloc(); X setbuf(stdout, malloc(BUFSIZ)); X#endif X if (argc<2) { X fprintf(stderr, "Usage: %s message-id ...\n", *argv); X exit(1); X } X if (dbminit(HIST)<0) { X perror("can't open history database"); X exit(1); X } X f=(FILE *)NULL; X i=1; do { X q=argv[i++]; X do { X a=q; p=buf; X if (*q!='<') { X *p++='<'; X while (*q) { X if (*q>='A'&&*q<='Z') *p++= *q++ +32; X else *p++= *q++; X } X *p++='>'; X } X else { /* so we're easy to call from rn */ X *p++= *q++; X do { X if (*q>='A'&&*q<='Z') *p++= *q++ +32; X else { X *p++= *q; X if (*q++=='>') break; X } X } while (*q); X } X *p='\0'; X k.dptr=buf; X k.dsize=p-buf+1; X d=fetch(k); X if (d.dptr&&(d.dsize==sizeof (long))) { X if (!f&&!(f=fopen(HIST, "r"))) { X perror(HIST); X exit(1); X } X (void)fseek(f, *(long *)d.dptr, 0); X while ((c=getc(f))>=' '||c=='\t') putchar(c); X putchar('\n'); X } X else printf("%s not found\n", k.dptr); X#ifndef BSD X fflush(stdout); X#endif X while (*q==' ') q++; X } while (*q); X } while (i<argc); X if (f) fclose(f); X#ifdef DBZ X dbmclose(); X#endif X exit(0); X} SHAR_EOF if test 1630 -ne "`wc -c < 'newshist.c'`" then echo shar: error transmitting "'newshist.c'" '(should have been 1630 characters)' fi fi # end of overwriting check echo shar: extracting "'newshist.1'" '(971 characters)' if test -f 'newshist.1' then echo shar: will not over-write existing file "'newshist.1'" else sed 's/^X//' << \SHAR_EOF > 'newshist.1' X.TH NEWSHIST 1 LOCAL X.SH NAME Xnewshist \- display history information for a given message-id X.SH SYNOPSIS X.B newshist X.I message-id X\&... X.SH DESCRIPTION X.if t .ad b XEvery usenet article is assigned a unique Message-ID by the Xnetnews software. X.I inews Xkeeps a history of Message-IDs it's seen so duplicate articles Xcan be identified and rejected. When following up to an article, Xits Message-ID is normally appended to the References: line of Xthe followup, and cited in quoted material. X.PP XThe arguments to X.I newshist Xare a list of Message-IDs. The enclosing <>s can be omitted if Xdesired, but, if used, will require quoting to avoid shell Xinterpretation. X.PP XTo find the most recent reference in X.I rn, Xsay X.br X.B !newshist X\f3"\fPESCr\f3"\fP X.SH FILES X/usr/lib/news/history* X.SH AUTHOR XEric P. Scott X.SH SEE ALSO Xexpire(8), inews(8), rn(1) X.SH BUGS X.I Newshist Xneeds direct access to the history database; it won't work in XNNTP-only or certain NFS configurations. SHAR_EOF if test 971 -ne "`wc -c < 'newshist.1'`" then echo shar: error transmitting "'newshist.1'" '(should have been 971 characters)' fi fi # end of overwriting check # End of shell archive exit 0