home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 126_01 / rawgetc.c < prev    next >
Text File  |  1985-03-10  |  896b  |  38 lines

  1. #include "bdscio.h"
  2.  
  3. int rawgetc(iobuf)
  4. struct _buf *iobuf;
  5. {
  6.     int nsecs;
  7.  
  8.     /* CONSOLE */
  9.     if (iobuf == 0) return getchar();
  10.  
  11.     /* READER */
  12.     if (iobuf == 3) return bdos(3);
  13.  
  14.     /*  IF THERE ARE NO CHARACTERS LEFT IN THE BUFFER */
  15.     if (!(iobuf->_nleft)) {
  16.  
  17.         /* ATTEMPT TO READ ANOTHER BUFFER FULL (NSECTS SECTORS) */
  18.         if ((nsecs = read(iobuf->_fd, iobuf->_buff, NSECTS)) <= 0) {
  19.  
  20.             /* IF THERE IS NO MORE TO READ, RETURN EOF */
  21.             return(EOF);
  22.         }
  23.         /* IF ADDITIONAL SECTORS WERE READ,
  24.         RESET _nleft AND _nextp FOR NUMBER OF SECTORS READ */
  25.         else {
  26.             iobuf->_nleft = (nsecs * SECSIZ);
  27.             iobuf->_nextp = iobuf->_buff;
  28.         }
  29.     }
  30.     /* DECREMENT _nleft AND
  31.     RETURN NEXT CHARACTER EVEN IF IT IS CPMEOF */
  32.     iobuf->_nleft--;
  33.     return(*iobuf->_nextp++);
  34. }
  35. les differ at %u:\n\t%s = %d = ",cc,argv[1],c1);
  36.             showchar(c1);
  37.             printf("\n\t%s = %d = ",argv[2],c2);
  38.             sh