/* pgcount.c - count number of pages in file */ /* * primitive version - just understands '\f' */ /* ufilter5.c - prototype filter program - line (actually record) oriented */ /* * Modular, fast, record filter skeleton. * Forces FD.CR on output file. * Gets file names from argv[1],[2]. Too hard to use stdin,stdout. * The record has NOTHING (like free '\n's) added to it. * Howlong = the record size in bytes. * Designed for R.VAR files. * Seperate input & output buffers */ #include #include #include #include #include char * inbufp; /* where the input buffer is */ int bufmax; /* maximum record size, needed for recinp() */ #define OUTMAX (100) /* maximum output record size */ FILE *inf; /* input file */ FILE *ouf; /* output file */ FDB * fdbp; /* obsolete kludge */ int howlong; /* char length of this record */ char * otbufp; /* where the output buffer is */ int pagcnt; /* count number of pages */ char * p; /* scan each input record */ char * nd; /* point just past end of an input record */ char temp[200]; /* create a input file print name here */ main(argc,argv) char **argv; BEGIN char * recinp(); /* the record-getter: 0 means end-of-file */ IF ((inf=fopen(argv[1],"urn"))==NULL) THEN error("can't find %s\7",argv[1]); FI fdbp = inf -> io_fdb; IF (!(inbufp=malloc(bufmax=fdbp->f_fatt.f_rsiz))) THEN error("max record size=%d.\7",bufmax); FI IF (argc<3 || !*argv[2]) THEN argv[2] = fgetname(stderr,temp); /* grab stderr */ FI IF (!(otbufp=malloc(OUTMAX))) THEN error("MAX rec siz=%d.\7",OUTMAX); FI IF ((ouf=fopen(argv[2],"uwn"))==NULL) THEN error("can't make %s\7",argv[2]); FI fdbp = ouf -> io_fdb; fdbp -> f_fatt . f_ratt |= fd_cr; /* force fd.cr */ pagcnt = 1; /* assume text precedes 1st '\f', follows last '\f' */ WHILE (recinp(inbufp,bufmax,inf,&howlong)) DO FOR (nd=(p=inbufp)+howlong; p