Annotation of 42BSD/usr.lib/libU77/access_.c, revision 1.1.1.1

1.1       root        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/f_errno.h"
                     17: #include <sys/param.h>
                     18: #ifndef        MAXPATHLEN
                     19: #define MAXPATHLEN     128
                     20: #endif
                     21: 
                     22: long access_(name, mode, namlen, modlen)
                     23: char *name, *mode;
                     24: long namlen, modlen;
                     25: {
                     26:        char buf[MAXPATHLEN];
                     27:        int m = 0;
                     28: 
                     29:        if (namlen >= sizeof buf)
                     30:                return((long)(errno=F_ERARG));
                     31:        g_char(name, namlen, buf);
                     32:        if (buf[0] == '\0')
                     33:                return((long)(errno=ENOENT));
                     34:        if (access(buf, 0) < 0)
                     35:                return((long)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((long)errno);
                     52:        return(0L);
                     53: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.