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 / CPM / CPM68K / SYSHACKS.LBR / ACCESS.C next >
Text File  |  2000-06-30  |  896b  |  43 lines

  1. /* -*-c,save-*- */
  2. /*
  3.  * access.c - *Real* access function
  4.  * Robert Heller. Created: Sun Apr 13, 1986 16:59:10.47
  5.  * Last Mod: 
  6.  * 
  7.  * (c) Copyright 1986 by Robert Heller
  8.  *     All Rights Reserved
  9.  * 
  10.  * 
  11.  */
  12. #include <stdio.h>
  13. #include <osif.h>
  14. #include <osiferr.h>
  15. #include <errno.h>
  16.  
  17. #define IFEXISTS 0
  18. #define IFEXECUTE 1
  19. #define IFWRITE 2
  20. #define IFREAD 4
  21.  
  22. access(filename,mode)
  23. register char *filename;
  24. register int mode;
  25. {
  26.     register int fd;
  27.     register int status;
  28.     register struct fcbtab *scratchfcb;
  29.  
  30.     fd = open(filename,0);
  31.     if (fd == -1) return(-1);
  32.     scratchfcb = (&_fds[fd].fcb.drive);
  33.     if (mode != IFWRITE) {
  34.     close(fd);
  35.     return(0);
  36.     }
  37.     if (isatty(fd) == 1 || (scratchfcb->ftype[0] & 0x0080) == 0) status = 0;
  38.     else status = -1;
  39.     close(fd);
  40.     if (status == -1) errno = EACCES;
  41.     return(status);
  42.     }
  43.