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

  1.  
  2. #define NOCCARGC
  3. #include stdio.h
  4. #include clib.def
  5. /*
  6. ** Open file indicated by fn.
  7. ** Entry: fn  = Null-terminated CP/M file name.
  8. **              May be prefixed with letter of drive.
  9. **        mode =  "a"   -append
  10. **                "r"   -read
  11. **                "w"   -write
  12. **                "a+"  -append update
  13. **                "r+"  -read update
  14. **                "w+"  -write update
  15. ** Returns a file descriptor on success, else NULL.
  16. */
  17. fopen(fn, mode) char *fn, *mode; {
  18.   int fd;
  19.   fd = 0; /*skip stdin (= error return) */
  20.   while(++fd < MAXFILES) {
  21.     if(_mode(fd) == NULL) {
  22.       if(_open(fn, mode, fd)!=ERR) return (fd);
  23.       break;
  24.       }
  25.     }
  26.   return (NULL);
  27.   }
  28.  
  29.