home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / enterprs / cpm / utils / s / smc21lib.lzh / FGETC.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-25  |  768 b   |  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.