[comp.sources.apple2] v001SRC014: more -- Display A File One Page At A Time

jac@yoko.rutgers.edu (Jonathan A. Chandross) (12/02/90)

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 <kbctl.h>
-
-#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