home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / C / SMALL_C / FGETC.C < prev    next >
Text File  |  1987-10-04  |  896b  |  35 lines

  1. #define NOCCARGC  /* no argument count passing */
  2. #include stdio.h
  3. #include clib.def
  4. /*
  5. ** Character-stream input of one character from fd.
  6. ** Entry: fd = File descriptor of pertinent file.
  7. ** Returns the next character on success, else EOF.
  8. */
  9. fgetc(fd) int fd; {
  10.   int ch;
  11.   char buff;
  12.   if(Uread(&buff,fd,1)==EOF) {
  13.     Useteof(fd);
  14.         return(EOF);
  15.   }
  16.   ch=buff;
  17.   switch(ch) {
  18.       default:     return (ch);
  19.       case FILEOF:  /* switch(Uchrpos[fd]) {
  20.                      default: --Uchrpos[fd];
  21.                      case 0:
  22.                      case BUFSIZE:
  23.                      }  */
  24.                    Useteof(fd);
  25.                    return (EOF);
  26.       case CR:     return ('\n');
  27.       case LF:    /* NOTE: Uconin() maps LF -> CR */
  28.   }
  29.  }
  30. #asm
  31. _getc EQU   _fgetc
  32.      PUBLIC _getc
  33. #endasm
  34.  
  35.