|
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 s
Length: 1540 (0x604) Types: TextFile Names: »sop.c«
└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki └─⟦this⟧ »EUUGD11/euug-87hel/sec1/sop/sop.c«
/* * SOP - process .so commands * Bill Davidsen - 8/10/86 * * for those system in which the tbl and eqn processors don't * process .so commands and the included files require pro- * cessing. * * Use: * sop firstfile | tbl | nroff ... */ #include <stdio.h> #define LLEN 256 /* longest line to allow */ FILE *stack[10], /* file stack */ *fp, /* current file pointer */ *fopen (); int index = 0; /* index into file stack */ char line[LLEN]; /* line buffer */ main (argc, argv) int argc; char *argv[]; { switch (argc) { case 1: /* use standard input */ fp = stdin; /* read standard input */ break; case 2: /* got a file to use */ fp = fopen (argv[1], "r"); if (fp == NULL) { /* bad filename */ fprintf (stderr, "Can't open file %s\n", argv[1]); exit (1); } break; default: fprintf (stderr, "Format\n sop\n -or-\n sop filename\n"); exit (1); } while (fp != NULL) { /* read and scan for .so */ if (fgets (line, LLEN, fp) == NULL) { /* end of file on current file */ if (index) fp = stack[--index]; else fp = NULL; continue; } if (strncmp (line, ".so ", 4) == 0) { /* include this file */ stack[index++] = fp; /* set newline to EOL */ line[strlen (line) - 1] = 0; /* open the next file */ fp = fopen (line + 4, "r"); if (fp == NULL) { /* bad include file */ fprintf (stderr, "Can't open include file %s\n", line + 4); exit (1); } continue; } fputs (line, stdout); } }