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

  1. #define NOCCARGC  /* no argument count passing */
  2. #include stdio.h
  3. /*
  4. ** Close previously opened fd and reopen it. 
  5. ** Entry: fn   = Null-terminated CP/M file name.
  6. **               May be prefixed by letter of drive.
  7. **               May be just CON:, RDR:, PUN:, or LST:.
  8. **        mode = "a"  - append
  9. **               "r"  - read
  10. **               "w"  - write
  11. **               "u"  -  update
  12. **        fd   = File descriptor of pertinent file.
  13. ** Returns the original fd on success, else NULL.
  14. */
  15. freopen(fn, mode, fd) char *fn, *mode; int fd; {
  16.   if(fclose(fd)) return (NULL);
  17.   if((fd=Uopen(fn, mode, fd))==ERR) return (NULL);
  18.   return (fd);
  19.   }
  20.