X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 124e6c,3f0d96a08722ae82,start X-Google-Attributes: gid124e6c,public X-Google-Thread: fbb9d,67924fb16802f2f2 X-Google-Attributes: gidfbb9d,public X-Google-Thread: f996b,3f0d96a08722ae82,start X-Google-Attributes: gidf996b,public X-Google-Thread: 110f55,3f0d96a08722ae82,start X-Google-Attributes: gid110f55,public From: cszwt2@scs.leeds.ac.uk (W Towle) Subject: Software: Viewer Utility Source Date: 1995/04/20 Message-ID: <3n6tka$8qs@gagme.wwa.com> X-Deja-AN: 101250462 approved: boba@wwa.com sender: boba@gagme.wwa.com references: <3mh3cf$jhf@gagme.wwa.com> organization: The University of Leeds, School of Computer Studies newsgroups: rec.arts.ascii,alt.ascii-art,alt.binaries.pictures.ascii,alt.binaries.pictures.utilities Vu v2.0 ... Should compile better than my last effort :-) Better than cat/type; has NEW (albeit limited and basic) file cutting ability. Performs all operations in one pass, so doesn't need to make temporary files. Removes unnecessary whitespace from ends of lines! PS. You don't need to type the entire options, just enough of them! Source is after this here manual page. vu(1) Viewer Utility (v2.0) vu(1) NAME vu - viewer utility for text and animation (.vt) files SYNOPSIS vu [options] [file] [...] DESCRIPTION Vu can be used for working out the maximum dimension of text files and for viewing animation and text files (slowing down the output where appropriate). It has the additional feature of removing unnecessary whitespace, and replaces "important" tabs with whitespace in its output. OPTIONS -count Tells vu to compute width and height of files. There is additional output given if the dimensions of what was printed differed from the full dimensions. -delay millisec Specifies length of time to wait after printing each character of the file -head n Tells vu to only display the first n lines. -length n Tells vu to only display n lines. -list Turns the displaying of the file off. -reset Resets the options to default (for multiple files) -start n Specify the start line by number FILES ~cszwt2/bin/vu ~cszwt2/ascart (.lha files within) AUTHOR William "Wills" Towle, cszwt2@scs.leeds.ac.uk Page 1 (printed 4/20/95) -----start vu.c-----x8 /* * Vu is public domain. No harm should come to your files and * filesystem through its use as a file-to-screen viewer, but I * cannot accept responsibility for loss of files/system damage * caused by careless use. */ #include #include #include #include #include void vu (char *argn, int strt, int lnth, int dlay, int calc, int list) { char *file= argn; FILE *ifPtr; char byte; int show, chop= 0, /* becomes true if we truncate somehow */ lines= 0, lines_a= 0, width_l= 0, width= 0, width_a= 0, space= 0, todo= lnth, pipe= 0, chrs, i; /* for -tail function, we need to copy piped input to temporary file */ /* strcpy(tempFile,tempnam("/tmp/", "vu")); */ pipe= (strcmp(file, "-")==0); if ( pipe || ((!pipe) && (ifPtr= fopen(file, "rb"))) ) { while ((pipe)? fread(&byte,sizeof(char),1,stdin) : fread(&byte,sizeof(char),1,ifPtr)) { show= (!(lines_awidth) width= width_l; if (width_l+space>width_a) width_a= width_l+space; width_l= 0; space= 0; } } /* end of file. */ if (space) chop= 1; if (calc) { if (list) printf("--\n"); printf("Lines in file: %d\n", lines_a); printf("Width of file: %d\n", width_a); if (chop) { printf("Lines printed: %d\n", lines); printf("Width printed: %d\n", width); } } } if (!pipe) fclose(ifPtr); } void warn1(const char *w1) { fprintf(stderr,"vu2: warning - %s\n", w1); } int strmatch(const char *s1, const char *s2) { int same=0, i=0; if (strlen(s1)<=strlen(s2)) while ( (i1); } void main(int argc,char** argv) { int arg, strt=1, lnth=0, dlay=0, calc=0, list=1; if (argc == 1) { printf ("%s\n%s %s %s\n", "vu (v2.0) -- by Wm.Towle", "Usage:", argv[0], "[options] {filename | - } [...]"); printf ("\n%s\n\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n%s\n", "Options are:", "-count\t: Work out file size (default: off)", "-delay : Add delay, duration n", "-head : First n lines", "-length : Number of lines to process", "-list\t: Dont list the actual file (default: on)", "-reset\t: Use default options", "-start : Specify start line by number", "Use - on command line to read from a pipe"); exit(0); } for (arg= 1; arg