|
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: 2403 (0x963) Types: TextFile Names: »manstat.c«
└─⟦87ddcff64⟧ Bits:30001253 CPHDIST85 Tape, 1985 Autumn Conference Copenhagen └─⟦this⟧ »cph85dist/stat/src/manstat.c«
#include "unixstat.h" PGM(manstat,Manual for Statistical Programs,5.0,3/3/85) /* Copyright (c) 1982 Gary Perlman (see Copyright file) */ #include <sys/types.h> #include <sys/stat.h> main (argc, argv) char **argv; { int optind; ARGV0; optind = initial (argc, argv); if (optind == argc) /* no opreands */ { process ("unixstat"); process ("manstat"); } else while (optind < argc) process (argv[optind++]); exit (0); } /* OPTIONS */ #ifndef DOCDIR #define DOCDIR "/usr/local/doc" #endif char *Docdir = DOCDIR; /* manual entries in this directory */ char *Macros = "an"; /* use -man macros by default */ int Update = 0; /* only update catman entries */ #define OPTSTRING "um:d:" initial (argc, argv) char **argv; { extern char *optarg; extern int optind; int errflg = 0; int C; while ((C = getopt (argc, argv, OPTSTRING)) != EOF) switch (C) { case 'd': Docdir = optarg; break; case 'm': Macros = optarg; break; case 'u': Update = 1; break; default: errflg++; break; } if (errflg) USAGE ([-u] [-m macros] [-d docdir] names) return (optind); } process (file) char *file; { struct stat man, cat; char manfile[BUFSIZ]; char catfile[BUFSIZ]; int noman; /* no manual entry on-line */ int nocat; /* no pre-formatted version */ sprintf (manfile, "%s/man/%s.1", Docdir, file); sprintf (catfile, "%s/cat/%s", Docdir, file); noman = stat (manfile, &man); nocat = stat (catfile, &cat); if (cat.st_size == 0) nocat = 1; if (noman & nocat) sysman (file); else { if (nocat || man.st_mtime > cat.st_mtime) newman (manfile, catfile); if (!Update) catman (catfile); } } newman (manfile, catfile) /* format a new manual entry */ char *manfile; /* where the manual entry is kept */ char *catfile; /* where the formatted version is put */ { char command[BUFSIZ]; if (!Update) WARNING (Reformatting manual entry. Please wait...) VOID sprintf (command, "nroff -m%s %s | uniq > %s", Macros, manfile, catfile); VOID system (command); } sysman (name) /* use the system manual program here */ char *name; { char command[BUFSIZ]; VOID sprintf (command, "man %s", name); VOID system (command); } catman (file) char *file; { register FILE *ioptr; register int C; if (ioptr = fopen (file, "r")) { while ((C = getc (ioptr)) != EOF) putc (C, stdout); fclose (ioptr); } else ERROPEN (file) }