Path: wuarchive!usc!rutgers!aramis.rutgers.edu!paul.rutgers.edu!yoko.rutgers.edu!jac From: jac@yoko.rutgers.edu (Jonathan A. Chandross) Newsgroups: comp.sources.apple2 Subject: v001SRC014: more -- Display A File One Page At A Time Message-ID: Date: 1 Dec 90 21:50:14 GMT Organization: Rutgers Univ., New Brunswick, N.J. Lines: 88 Approved: jac@paul.rutgers.edu Submitted-by: NONE Posting-number: Volume 1, Source:14 Archive-name: util/more Architecture: ANY_2 Version-number: 1.00 This program is like the page program I posted earlier; it allows you to view a file one page at a time. Enjoy. =more.c -/* - * - * more.c - * - * Display file one page at a time. - * - * Usage: - * more file_1 [file_2] [file_3] [...] - * - * Contributed Anonymously. Written: November 1983 - * - * Version 1.00 - * - */ - - -#include "stdio.h" -#include - -#define NL '\n' -#define PAGESIZE 24 - -int lines ; - -main(argc, argv) -int argc ; -char *argv[] ; -{ - FILE *input ; - - - argc-- ; argv++ ; - - lines = 0 ; - - for( ; argc > 0 ; argc--, argv++ ) - if( (input=fopen(*argv,"r")) == NULL ) { - fprintf(stderr, "more: can't open %s\n", *argv) ; - exit(1) ; - } - else { - more( input ) ; - fclose( input ) ; - } - - exit(0) ; - -} /* end main */ - - -/* more - print file page at time */ - -more( in ) -FILE *in ; -{ - int c ; - - while( (c=agetc(in)) != EOF ) { - aputc(c, stdout) ; - if( c == NL ) - lines++ ; - if( lines >= PAGESIZE ) { - lines = 1 ; - printf("MORE") ; - c = agetc(stdin) ; - ioctl(1, 18, 0) ; - if( c == 'q' ) - exit(0) ; - } - } - -} /* end more */ - - + END OF ARCHIVE