Date: Thu, 28 Feb 91 03:00:17 CST From: 231b3679@fergvax.unl.edu (Mike Gleason) Subject: [*] skim-digest.c /* skim-digest.c * version 1.0, 28 Feb 91, by Mike Gleason, NCEMRSoft. * * Purpose: To read only selected articles from the Info-Mac digests. * * How to use: Compile this C source code with your favorite C compiler * on your favorite unix host: * * % cc skim-digest.c -O -o skim * * Go out and download a digest from sumex-aim.stanford.edu. Run skim: * * % skim digest50 digest51 digest49 * * It should be fairly straightforward from there. When skim finds an * article in the digest, it will ask you if you want to read it. Type * to skip the article, or just hit to go ahead * and read it. Skim's key commands are similar to the "less" and * "more" text readers; the biggest difference is that Skim only * recognizes a few keys (in other words, fancy-shmancy stuff like * grepping through the digest is not supported [yet]). Once you choose * to read an article, it will pause every screenfull of lines. Hit * to go to the next article, to quit reading * the current digest, or just hit to continue reading. * * Lastly: I'm curious if anyone else out there besides me will use this; * If you do, drop me a line at 231b3679@fergvax.unl.edu. I'm putting * this out into the public domain, so go ahead and submit any revisions * to sumex. */ #define NO_HOT_KEYS #define SCREEN_HEIGHT 24 #define AT_NEW 1 #define QUIT -1 #define NEXT 0 #define NOT_AT_NEW 0 #define CLEARSCREEN printf("\033[2J \033[H") /* Clear screen. */ #ifdef THINK_C # define NO_ANSI # include "stdio.h" #else # include /* # define NO_ANSI */ /* Uncomment the preceding line if your terminal doesn't like ANSI screen control characters. */ #endif int ReadDigest(); int ReadArticle(); char Response(); int StrnEqual(); int main(argc, argv) int argc; char **argv; { char digestName[80]; short i; if (argc < 2) { printf(" digest to read: "); fgets(digestName, sizeof (digestName), stdin); *(digestName + strlen(digestName) - 1) = '\0'; if (digestName) ReadDigest(digestName); } else { for (i=1; i 1) CLEARSCREEN; printf("\033[1mArticle #%d\033[0m:\n%s", articleNum, dateStr); #endif while (fgets(lyne, sizeof(lyne), in)) { if (strlen(lyne) < 5) break; fputs(lyne, stdout); /* Write all the header lines. */ } if (!lyne) { fclose(in); return (0); /* unexpected eof */ } *lyne = Response("\nRead this post? "); switch (*lyne) { case 'n': case 'N': break; case 'q': case 'Q': return (1); break; default: { if ((atNextArticle = ReadArticle(in, dateStr)) < 0) { fclose(in); return (1); } } } } fclose(in); return (1); } /* ReadDigest */ int ReadArticle(in, dateStr) FILE *in; char *dateStr; { char lyne[128]; register short i; while(1) { #ifndef NO_ANSI CLEARSCREEN; #endif for (i=0; i