From 39a6d231592ba69b8a0b5630f7fd2f4ffbc1f58c Mon Sep 17 00:00:00 2001 From: David Wasley Date: Thu, 12 Feb 1981 05:50:29 -0800 Subject: [PATCH] date and time created 81/02/11 21:50:29 by dlw SCCS-vsn: usr.bin/f77/libU77/access_.c 1.1 --- usr/src/usr.bin/f77/libU77/access_.c | 47 ++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 usr/src/usr.bin/f77/libU77/access_.c diff --git a/usr/src/usr.bin/f77/libU77/access_.c b/usr/src/usr.bin/f77/libU77/access_.c new file mode 100644 index 0000000000..bf8b2c7995 --- /dev/null +++ b/usr/src/usr.bin/f77/libU77/access_.c @@ -0,0 +1,47 @@ +/* +char id_access[] = "@(#)access_.c 1.1"; + * + * determine accessability of a file + * + * calling format: + * integer access + * ierror = access(filename, mode) + * where: + * ierror will be 0 for successful access; an error number otherwise. + * filename is a character string + * mode is a character string which may include any combination of + * 'r', 'w', 'x', ' '. (' ' => test for existence) + */ + +#include "../libI77/f_errno.h" + +long access_(name, mode, namlen, modlen) +char *name, *mode; +long namlen, modlen; +{ + char buf[128]; + int m = 0; + + g_char(name, namlen, buf); + if (buf[0] == '\0') + return((long)(errno=F_ERARG)); + if (access(buf, 0) < 0) + return((long)errno); + while (modlen--) switch(*mode++) + { + case 'x': + m |= 1; + break; + + case 'w': + m |= 2; + break; + + case 'r': + m |= 4; + break; + } + if (m > 0 && access(buf, m) < 0) + return((long)errno); + return(0L); +} -- 2.20.1