--- ray/src/common/getpath.c 1991/11/12 16:55:56 2.1 +++ ray/src/common/getpath.c 1992/07/13 16:33:19 2.4 @@ -10,8 +10,17 @@ static char SCCSid[] = "$SunId$ LBL"; #define NULL 0 +#ifndef NIX #include +#endif +#ifndef DIRSEP +#define DIRSEP '/' +#endif +#ifndef PATHSEP +#define PATHSEP ':' +#endif + extern char *strcpy(), *strcat(), *getenv(); extern struct passwd *getpwnam(); @@ -22,21 +31,24 @@ register char *fname; register char *searchpath; int mode; { - static char pname[256]; +#ifndef NIX struct passwd *pwent; +#endif + static char pname[256]; register char *cp; if (fname == NULL) return(NULL); switch (*fname) { - case '/': /* relative to root */ + case DIRSEP: /* relative to root */ case '.': /* relative to cwd */ strcpy(pname, fname); return(pname); +#ifndef NIX case '~': /* relative to home directory */ fname++; - if (*fname == '\0' || *fname == '/') { /* ours */ + if (*fname == '\0' || *fname == DIRSEP) { /* ours */ if ((cp = getenv("HOME")) == NULL) return(NULL); strcpy(pname, cp); @@ -46,13 +58,14 @@ int mode; cp = pname; /* user */ do *cp++ = *fname++; - while (*fname && *fname != '/'); + while (*fname && *fname != DIRSEP); *cp = '\0'; if ((pwent = getpwnam(pname)) == NULL) return(NULL); strcpy(pname, pwent->pw_dir); strcat(pname, fname); return(pname); +#endif } if (searchpath == NULL) { /* don't search */ @@ -62,10 +75,10 @@ int mode; /* check search path */ do { cp = pname; - while (*searchpath && (*cp = *searchpath++) != ':') + while (*searchpath && (*cp = *searchpath++) != PATHSEP) cp++; - if (cp > pname && cp[-1] != '/') - *cp++ = '/'; + if (cp > pname && cp[-1] != DIRSEP) + *cp++ = DIRSEP; strcpy(cp, fname); if (access(pname, mode) == 0) /* file accessable? */ return(pname);