-char *
-etcpath (char *file)
-{
- static char epath[PATH_MAX];
- char *cp;
- char *pp;
- struct passwd *pw;
-
- context_read();
- if (*file == '~') {
- /* Expand ~username */
- if ((cp = strchr(pp = file + 1, '/')))
- *cp++ = '\0';
- if (*pp == '\0') {
- pp = mypath;
- } else {
- if ((pw = getpwnam (pp)))
- pp = pw->pw_dir;
- else {
- if (cp)
- *--cp = '/';
- goto try_it;
- }
- }
-
- snprintf (epath, sizeof(epath), "%s/%s", pp, cp ? cp : "");
- if (cp)
- *--cp = '/';
-
- if (access (epath, R_OK) != NOTOK)
- return epath; /* else fall */
- }
-
-try_it:
- if (*file == '/') {
- /* If already absolute pathname, return it */
- return file;
- }
-
- /* Check nmh Mail directory */
- strncpy(epath, toabsdir(file), sizeof epath);
- if (access (epath, R_OK) != NOTOK)
- return epath;
-
- /* Check nmh `etc' directory */
- snprintf (epath, sizeof(epath), NMHETCDIR"/%s", file);
- return (access (epath, R_OK) != NOTOK ? epath : file);
-}
-