Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!usc!ucsd!ucbvax!ziploc!eps From: eps@toaster.SFSU.EDU (Eric P. Scott) Newsgroups: news.newusers.questions Subject: Re: Fetching msgs by their IDs Summary: Maybe something like this will help Message-ID: <172@toaster.SFSU.EDU> Date: 2 Dec 89 11:58:00 GMT References: <566@dftsrv.gsfc.nasa.gov> <5290@omepd.UUCP> Reply-To: eps@cs.SFSU.EDU (Eric P. Scott) Organization: San Francisco State University Lines: 61 This is a quick late-night "10-minute hack" to look up message IDs. It works on my system, it may need a little work on yours. It's faster than searching in rn, and will work even if the referenced article was in a different newsgroup, and redirected followups. (It has to be executed on the machine that keeps the history, so it's not really useful if you are using client NFS or NNTP). -=EPS=- ------- /* * Print B News history record for specified message-ids * Eric P. Scott, SFSU, December 1989 */ #include #include #ifndef HIST #define HIST "/usr/lib/news/history" #endif main(argc, argv) int argc; char *argv[]; { register int i, c; register FILE *f; datum k, d; #ifdef USG char *malloc(); setbuf(stdout, malloc(BUFSIZ)); #endif if (argc<2) { fprintf(stderr, "Usage: %s \"\" ...\n\ \t(note that message-ids are normally folded to lowercase in history)\n", *argv); exit(1); } if (dbminit(HIST)<0) { perror("can't open history database"); exit(1); } f=(FILE *)NULL; i=1; do { k.dsize=strlen(k.dptr=argv[i++])+1; d=fetch(k); if (d.dptr&&(d.dsize==sizeof (long))) { if (!f&&!(f=fopen(HIST, "r"))) { perror(HIST); exit(1); } (void)fseek(f, *(long *)d.dptr, 0); while ((c=getc(f))>=' '||c=='\t') putchar(c); putchar('\n'); } else printf("%s not found\n", k.dptr); } while (i