home *** CD-ROM | disk | FTP | other *** search
- /* page.c */
-
- #include "stdio.h"
-
- #define LINESIZE 80
- #define SCRNSIZE 23
-
- /*
- * Global Variables:
- */
-
- int byte; /* the character */
- int colcnt, linecnt; /* the counters */
- int fd; /* the descriptor for the alternate keyboard input */
-
- main(argc, argv)
-
- int argc;
- char **argv;
-
- {
- colcnt = 1;
- linecnt = 0;
-
- fd = open("kybd:",0);
-
- while ((byte = getchar()) != EOF) {
- putchar(byte);
- more();
- }
- }
-
- more()
-
- {
- if (byte == '\n') {
- linecnt++;
- colcnt = 1;
- }
- else {
- colcnt++;
- if (colcnt == LINESIZE) {
- linecnt++;
- colcnt = 1;
- }
- }
- if (linecnt == SCRNSIZE)
- command();
- }
-
- command()
-
- {
- while (read(fd, &byte, 1) && byte != ' ' && byte != '\n' && byte != EOF)
- ;
-
- if (byte == ' ')
- linecnt = 0; /* reset counter */
- else if (byte == '\n')
- linecnt--;
- else
- exit();
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-