- /*
- * Find and read user's profile. Check for the existence of an MH environment
- * variable first with non-empty contents. Convert any relative path name
- * found there to an absolute one. Look for the profile in the user's home
- * directory if the MH environment variable isn't set.
- */
-
- if ((cp = getenv("MH")) && *cp != '\0') {
- defpath = path(cp, TFILE);
-
- if (stat(defpath, &st) != -1 && (st.st_mode & S_IFREG) == 0)
- adios((char *)0, "`%s' specified by your MH environment variable is not a normal file", cp);
-
- if ((ib = fopen(defpath, "r")) == (FILE *)0)
- adios((char *)0, "unable to read the `%s' profile specified by your MH environment variable", defpath);
- }
- else {
- defpath = concat(mypath, "/", mh_profile, NULL);
-
- if ((ib = fopen(defpath, "r")) == (FILE *)0)
- adios((char *)0, "Doesn't look like nmh is installed. Run install-mh to do so.");
-
- cp = mh_profile;
- }
-
- readconfig (&m_defs, ib, cp, 0);
- fclose (ib);
-
- /*
- * 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);
-
- if (*cp != '/')
- (void)snprintf (nd = buf, sizeof(buf), "%s/%s", mypath, cp);
- else
- nd = cp;
-
- if (stat(nd, &st) == -1) {
- if (errno != ENOENT)
- adios (nd, "error opening");
-
- cp = concat ("Your MH-directory \"", nd, "\" doesn't exist; Create it? ", NULL);
-
- if (!getanswer(cp))
- adios (NULL, "unable to access MH-directory \"%s\"", nd);
-
- free (cp);
-
- if (!makedir (nd))
- adios (NULL, "unable to create", nd);
- }
-
- else if ((st.st_mode & S_IFDIR) == 0)
- adios ((char *)0, "`%s' is not a directory", nd);
-
- /*
- * Open and read user's context file. The name of the context file comes from the
- * profile unless overridden by the MHCONTEXT environment variable.
- */
-
- if ((cp = getenv ("MHCONTEXT")) == (char *)0 || *cp == '\0')
- cp = context;
-
- /* context is NULL if context_foil() was called to disable use of context
- * We also support users setting explicitly setting MHCONTEXT to /dev/null.
- * (if this wasn't specialcased then the locking would be liable to fail)
- */
- if (!cp || (strcmp(cp,"/dev/null") == 0)) {
- ctxpath = NULL;