home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / apple2 / 38 < prev    next >
Encoding:
Text File  |  1990-12-02  |  1.6 KB  |  99 lines

  1. Path: wuarchive!usc!rutgers!aramis.rutgers.edu!paul.rutgers.edu!yoko.rutgers.edu!jac
  2. From: jac@yoko.rutgers.edu (Jonathan A. Chandross)
  3. Newsgroups: comp.sources.apple2
  4. Subject: v001SRC014:  more -- Display A File One Page At A Time
  5. Message-ID: <Dec.1.16.50.13.1990.24718@yoko.rutgers.edu>
  6. Date: 1 Dec 90 21:50:14 GMT
  7. Organization: Rutgers Univ., New Brunswick, N.J.
  8. Lines: 88
  9. Approved: jac@paul.rutgers.edu
  10.  
  11.  
  12. Submitted-by: NONE
  13. Posting-number: Volume 1, Source:14
  14. Archive-name: util/more
  15. Architecture: ANY_2
  16. Version-number: 1.00
  17.  
  18. This program is like the page program I posted earlier; it allows you
  19. to view a file one page at a time.
  20.  
  21. Enjoy.
  22.  
  23. =more.c
  24. -/*
  25. - *
  26. - * more.c
  27. - *
  28. - * Display file one page at a time.
  29. - *
  30. - * Usage:
  31. - *     more file_1 [file_2] [file_3] [...]
  32. - *
  33. - * Contributed Anonymously.  Written: November 1983
  34. - *
  35. - * Version 1.00
  36. - *
  37. - */
  38. -
  39. -
  40. -#include "stdio.h"
  41. -#include <kbctl.h>
  42. -
  43. -#define NL    '\n'
  44. -#define PAGESIZE 24
  45. -
  46. -int lines ;
  47. -
  48. -main(argc, argv)
  49. -int argc ;
  50. -char *argv[] ;
  51. -{
  52. -    FILE *input ;
  53. -
  54. -
  55. -    argc-- ; argv++ ;
  56. -
  57. -    lines = 0 ;
  58. -
  59. -    for( ; argc > 0 ; argc--, argv++ )
  60. -        if( (input=fopen(*argv,"r")) == NULL ) {
  61. -            fprintf(stderr, "more: can't open %s\n", *argv) ;
  62. -            exit(1) ;
  63. -        }
  64. -        else {
  65. -            more( input ) ;
  66. -            fclose( input ) ;
  67. -        }
  68. -
  69. -    exit(0) ;
  70. -
  71. -} /* end main */
  72. -
  73. -
  74. -/* more - print file page at time */
  75. -
  76. -more( in )
  77. -FILE *in ;
  78. -{
  79. -    int c ;
  80. -
  81. -    while( (c=agetc(in)) != EOF ) {
  82. -        aputc(c, stdout) ;
  83. -        if( c == NL )
  84. -            lines++ ;
  85. -        if( lines >= PAGESIZE ) {
  86. -            lines = 1 ;
  87. -            printf("MORE") ;
  88. -            c = agetc(stdin) ;
  89. -            ioctl(1, 18, 0) ;
  90. -            if( c == 'q' )
  91. -                exit(0) ;
  92. -        }
  93. -    }
  94. -
  95. -} /* end more */
  96. -
  97. -
  98. + END OF ARCHIVE
  99.