home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 June / SIMTEL_0692.cdr / msdos / c / cc03.arc / PAGE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1984-08-26  |  889 b   |  81 lines

  1. /* page.c */
  2.  
  3. #include "stdio.h"
  4.  
  5. #define LINESIZE 80
  6. #define SCRNSIZE 23
  7.  
  8. /*
  9.  * Global Variables:
  10.  */
  11.  
  12. int byte;  /* the character */
  13. int colcnt, linecnt;    /* the counters */
  14. int fd; /* the descriptor for the alternate keyboard input */
  15.  
  16. main(argc, argv)
  17.  
  18. int argc;
  19. char **argv;
  20.  
  21. {
  22.     colcnt = 1;
  23.     linecnt = 0;
  24.  
  25.     fd = open("kybd:",0);
  26.  
  27.     while ((byte = getchar()) != EOF) {
  28.         putchar(byte);
  29.         more();
  30.     }
  31. }
  32.  
  33. more()
  34.  
  35. {
  36.     if (byte == '\n') {
  37.         linecnt++;
  38.         colcnt = 1;
  39.     }
  40.     else {
  41.         colcnt++;
  42.         if (colcnt == LINESIZE) {
  43.             linecnt++;
  44.             colcnt = 1;
  45.         }
  46.     }
  47.     if (linecnt == SCRNSIZE)
  48.         command();
  49. }
  50.  
  51. command()
  52.  
  53. {
  54.     while (read(fd, &byte, 1) && byte != ' ' && byte != '\n' && byte != EOF)
  55.         ;
  56.  
  57.     if (byte == ' ')
  58.         linecnt = 0;    /* reset counter */
  59.     else if (byte == '\n')
  60.         linecnt--;
  61.     else
  62.         exit();
  63. }
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.