1: /*
2: char id_access[] = "@(#)access_.c 1.3";
3: *
4: * determine accessability of a file
5: *
6: * calling format:
7: * integer access
8: * ierror = access(filename, mode)
9: * where:
10: * ierror will be 0 for successful access; an error number otherwise.
11: * filename is a character string
12: * mode is a character string which may include any combination of
13: * 'r', 'w', 'x', ' '. (' ' => test for existence)
14: */
15:
16: #include "../libI77/fiodefs.h"
17: #include <sys/param.h>
18: #ifndef MAXPATHLEN
19: #define MAXPATHLEN 128
20: #endif
21:
22: ftnint access_(name, mode, namlen, modlen)
23: char *name, *mode;
24: ftnlen namlen, modlen;
25: {
26: char buf[MAXPATHLEN];
27: int m = 0;
28:
29: if (namlen >= sizeof buf)
30: return((ftnint)(errno=F_ERARG));
31: g_char(name, namlen, buf);
32: if (buf[0] == '\0')
33: return((ftnint)(errno=ENOENT));
34: if (access(buf, 0) < 0)
35: return((ftnint)errno);
36: while (modlen--) switch(*mode++)
37: {
38: case 'x':
39: m |= 1;
40: break;
41:
42: case 'w':
43: m |= 2;
44: break;
45:
46: case 'r':
47: m |= 4;
48: break;
49: }
50: if (m > 0 && access(buf, m) < 0)
51: return((ftnint)errno);
52: return((ftnint) 0);
53: }
Defined functions
Defined macros