home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / ENTERPRS / CPM / UTILS / S / SMC21LIB.LZH / FGETC.C < prev    next >
Text File  |  2000-06-30  |  768b  |  31 lines

  1.  
  2. #include stdio.h
  3. #include clib.def
  4. extern int _chrpos[];
  5. /*
  6. ** Character-stream input of one character from fd.
  7. ** Entry: fd = File descriptor of pertinent file
  8. ** Returns the next character on success, else EOF.
  9. */
  10. fgetc(fd) int fd; {
  11.   int ch;
  12.   while(1) {
  13.     switch(ch = _read(fd)) {
  14.       default:  return (ch);
  15.       case CPMEOF:  switch(_chrpos[fd]) {
  16.                       default: --_chrpos[fd];
  17.                       case 0:
  18.                       case BUFSIZE:
  19.                       }
  20.                     _seteof(fd);
  21.                     return(EOF);
  22.       case CR:      return('\n');
  23.       case LF:      /* NOTE: _conin() maps  LF -> CR*/
  24.       }
  25.     }
  26.   }
  27. #asm
  28. getc    equ fgetc
  29.         entry getc
  30. #endasm
  31.