Annotation of coherent/a/usr/src/misc/pathn.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * find a file on a path in the environment, or a default path
                      3:  * with an access priveledge.
                      4:  *
                      5:  * example: pathn("helpfile", "LIBPATH", ",,\lib", "r");
                      6:  *
                      7:  * Returns full path name.
                      8:  */
                      9: #include <stdio.h>
                     10: #include <path.h>
                     11: 
                     12: #define PATHSIZE 64
                     13: 
                     14: char   *getenv(), *path(), *strchr();
                     15: char *
                     16: pathn(name, envpath, deflpath, acs)
                     17: char *name, *envpath, *deflpath, *acs;
                     18: {
                     19:        register char *pathptr;
                     20: 
                     21:        if((NULL == envpath) || (NULL == (pathptr = getenv(envpath))))
                     22:                pathptr = deflpath;
                     23: 
                     24:        if(NULL == strchr(acs, 'w')) {
                     25:                if ((pathptr = path(pathptr, name, AREAD)) == NULL)
                     26:                        return(name);
                     27:                else
                     28:                        return(pathptr);
                     29:        }
                     30:        else {
                     31:                register char *p, c;
                     32:                static char fullname[PATHSIZE];
                     33: 
                     34:                if((p = path(pathptr, name, AWRITE)) == NULL) {
                     35:                        for(p = fullname; (c = *pathptr++) && c != LISTSEP;)
                     36:                                *p++ = c;
                     37:                        *p++ = PATHSEP;
                     38:                        strcpy(p, name);
                     39:                        return(fullname);
                     40:                } else
                     41:                        return(p);
                     42:        }
                     43: }

unix.superglobalmegacorp.com

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