| 10 |  |  | 
| 11 |  | #define  NULL           0 | 
| 12 |  |  | 
| 13 | + | #ifndef  NIX | 
| 14 |  | #include  <pwd.h> | 
| 15 | + | #endif | 
| 16 |  |  | 
| 17 | + | #ifndef DIRSEP | 
| 18 | + | #define DIRSEP          '/' | 
| 19 | + | #endif | 
| 20 | + | #ifndef PATHSEP | 
| 21 | + | #define PATHSEP         ':' | 
| 22 | + | #endif | 
| 23 | + |  | 
| 24 |  | extern char  *strcpy(), *strcat(), *getenv(); | 
| 25 |  | extern struct passwd  *getpwnam(); | 
| 26 |  |  | 
| 31 |  | register char  *searchpath; | 
| 32 |  | int  mode; | 
| 33 |  | { | 
| 34 | < | static char  pname[256]; | 
| 34 | > | #ifndef  NIX | 
| 35 |  | struct passwd  *pwent; | 
| 36 | + | #endif | 
| 37 | + | static char  pname[256]; | 
| 38 |  | register char  *cp; | 
| 39 |  |  | 
| 40 |  | if (fname == NULL) | 
| 41 |  | return(NULL); | 
| 42 |  |  | 
| 43 |  | switch (*fname) { | 
| 44 | < | case '/':                               /* relative to root */ | 
| 44 | > | case DIRSEP:                            /* relative to root */ | 
| 45 |  | case '.':                               /* relative to cwd */ | 
| 46 |  | strcpy(pname, fname); | 
| 47 |  | return(pname); | 
| 48 | + | #ifndef NIX | 
| 49 |  | case '~':                               /* relative to home directory */ | 
| 50 |  | fname++; | 
| 51 | < | if (*fname == '\0' || *fname == '/') {          /* ours */ | 
| 51 | > | if (*fname == '\0' || *fname == DIRSEP) {       /* ours */ | 
| 52 |  | if ((cp = getenv("HOME")) == NULL) | 
| 53 |  | return(NULL); | 
| 54 |  | strcpy(pname, cp); | 
| 58 |  | cp = pname;                                     /* user */ | 
| 59 |  | do | 
| 60 |  | *cp++ = *fname++; | 
| 61 | < | while (*fname && *fname != '/'); | 
| 61 | > | while (*fname && *fname != DIRSEP); | 
| 62 |  | *cp = '\0'; | 
| 63 |  | if ((pwent = getpwnam(pname)) == NULL) | 
| 64 |  | return(NULL); | 
| 65 |  | strcpy(pname, pwent->pw_dir); | 
| 66 |  | strcat(pname, fname); | 
| 67 |  | return(pname); | 
| 68 | + | #endif | 
| 69 |  | } | 
| 70 |  |  | 
| 71 |  | if (searchpath == NULL) {                       /* don't search */ | 
| 75 |  | /* check search path */ | 
| 76 |  | do { | 
| 77 |  | cp = pname; | 
| 78 | < | while (*searchpath && (*cp = *searchpath++) != ':') | 
| 78 | > | while (*searchpath && (*cp = *searchpath++) != PATHSEP) | 
| 79 |  | cp++; | 
| 80 | < | if (cp > pname && cp[-1] != '/') | 
| 81 | < | *cp++ = '/'; | 
| 80 | > | if (cp > pname && cp[-1] != DIRSEP) | 
| 81 | > | *cp++ = DIRSEP; | 
| 82 |  | strcpy(cp, fname); | 
| 83 |  | if (access(pname, mode) == 0)           /* file accessable? */ | 
| 84 |  | return(pname); |