|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T m
Length: 1140 (0x474) Types: TextFile Names: »more.c«
└─⟦87ddcff64⟧ Bits:30001253 CPHDIST85 Tape, 1985 Autumn Conference Copenhagen └─⟦this⟧ »cph85dist/stat/src/more.c«
#include "unixstat.h" PGM(more,Paginate Output,5.0,1984) #define LINES 24 /* how many lines on the screen */ #include <sgtty.h> static struct sgttyb Normtty, Rawtty; init () { gtty (2, &Normtty); gtty (2, &Rawtty); Rawtty.sg_flags &= ~ECHO; Rawtty.sg_flags |= RAW; } rawgetc () { char C; putc (7, stderr); fflush (stderr); stty (2, &Rawtty); read (2, &C, 1); stty (2, &Normtty); return (C); } main (argc, argv) char **argv; { init (); if (argc == 1) more ("-"); else while (--argc) more (*++argv); exit (0); } more (file) char *file; { char line[BUFSIZ]; FILE *ioptr; int window = LINES-1; int linecount = 0; int C; if (!strcmp (file, "-")) { ioptr = stdin; file = "Standard Input"; } else ioptr = fopen (file, "r"); if (ioptr) { fprintf (stderr, "more: file=%s\n", file); while (fgets (line, BUFSIZ, ioptr)) { if (++linecount == window) { linecount = 0; C = rawgetc (); if (C == 'q') exit (0); if (C == 'n') break; } fputs (line, stdout); } if (ioptr != stdin) fclose (ioptr); } else fprintf (stderr, "more: can't open '%s'\n", file); }