- * Find the location of a format or configuration
- * file, and return its absolute pathname.
- *
- * 1) If already absolute pathname, then leave unchanged.
- * 2) Next, if it begins with ~user, then expand it.
- * 3) Next, check in nmh Mail directory.
- * 4) Next, check in nmh `etc' directory.
- *
- */
-
-char *
-etcpath (char *file)
-{
- static char epath[PATH_MAX];
- char *cp;
-#ifdef MHRC
- char *pp;
- struct passwd *pw;
-#endif
-
-#ifdef MHRC
- context_read();
-#endif
-
- switch (*file) {
- case '/':
- /* If already absolute pathname, return it */
- return file;
-
-#ifdef MHRC
- case '~':
- /* 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:
-#endif /* MHRC */
-
- default:
- /* Check nmh Mail directory */
- if (access ((cp = m_mailpath (file)), R_OK) != NOTOK)
- return cp;
- }
-
- /* Check nmh `etc' directory */
- snprintf (epath, sizeof(epath), nmhetcdir(/%s), file);
- return (access (epath, R_OK) != NOTOK ? epath : file);
-}
-
-
-/*
- * Standard yes/no switches structure
- */