- * Find the user's nmh directory, which is specified by the "path" profile component.
- * Convert a relative path name to an absolute one rooted in the home directory.
- */
-
- if ((cp = context_find ("path")) == (char *)0)
- adios(NULL, "Your %s file does not contain a path entry.", defpath);
-
- if (*cp == '\0')
- adios(NULL, "Your `%s' profile file does not contain a valid path entry.", defpath);
+ ** Find and read user's profile. Check for the existence of
+ ** a non-empty MMHP environment variable first. Look for the
+ ** profile in the mmh directory otherwise.
+ */
+ if ((cp = getenv("MMHP")) && *cp) {
+ if (*cp == '/') {
+ defpath = mh_xstrdup(cp);
+ } else {
+ defpath = concat(mmhpath, "/", cp, NULL);
+ }
+ if (stat(defpath, &st) != -1 && (st.st_mode & S_IFREG) == 0) {
+ adios(EX_CONFIG, NULL, "Your profile `%s', specified by the MMHP environment variable, is not a normal file", cp);
+ }
+ if ((ib = fopen(defpath, "r")) == (FILE *)0) {
+ adios(EX_IOERR, NULL, "Unable to read your profile `%s', specified by the MMHP environment variable", defpath);
+ }
+ } else {
+ defpath = concat(mmhpath, "/", profile, NULL);
+ if ((ib = fopen(defpath, "r")) == (FILE *)0) {
+ adios(EX_CONFIG, NULL, "No profile found. Please create `%s' first.", defpath);
+ }
+ cp = profile;
+ }
+ readconfig(&m_defs, ib, cp, 0);
+ fclose(ib);