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 / FREOPEN.C < prev    next >
Text File  |  2000-06-30  |  768b  |  23 lines

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