X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/de06ed5f176a5fa3eb5522bb9a9741f9c3f1d0f4..670a0d84c25b458bbb348d2a1ecee178cfa6c226:/sbr/context_read.c diff --git a/sbr/context_read.c b/sbr/context_read.c index a8d14202..499dba41 100644 --- a/sbr/context_read.c +++ b/sbr/context_read.c @@ -21,11 +21,19 @@ * environment variable or by the profile. */ -#include /* mh internals */ +#include "h/mh.h" +#include "read_yes_or_no_if_tty.h" +#include "concat.h" +#include "context_read.h" +#include "context_find.h" +#include "readconfig.h" +#include "path.h" +#include "error.h" #include "lock_file.h" #include "m_maildir.h" #include "makedir.h" -#include /* structure for getpwuid() results */ +#include +#include "h/utils.h" void context_read (void) @@ -52,7 +60,7 @@ context_read (void) if ((mypath = getenv("HOME")) == NULL) { if ((pw = getpwuid(getuid())) == NULL || *pw->pw_dir == '\0') - adios(NULL, "cannot determine your home directory"); + die("cannot determine your home directory"); mypath = pw->pw_dir; } @@ -69,16 +77,16 @@ context_read (void) /* defpath is an absolute path; make sure that always MH is, too. */ setenv("MH", defpath, 1); if (stat(defpath, &st) != -1 && (st.st_mode & S_IFREG) == 0) - adios(NULL, "`%s' specified by your MH environment variable is not a normal file", cp); + die("`%s' specified by your MH environment variable is not a normal file", cp); if ((ib = fopen(defpath, "r")) == NULL) - adios(NULL, "unable to read the `%s' profile specified by your MH environment variable", defpath); + die("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")) == NULL) - adios(NULL, "Doesn't look like nmh is installed. Run install-mh to do so."); + die("Doesn't look like nmh is installed. Run install-mh to do so."); cp = mh_profile; } @@ -92,10 +100,10 @@ context_read (void) */ if ((cp = context_find ("path")) == NULL) - adios(NULL, "Your %s file does not contain a path entry.", defpath); + die("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); + die("Your `%s' profile file does not contain a valid path entry.", defpath); if (*cp != '/') (void)snprintf (nd = buf, sizeof(buf), "%s/%s", mypath, cp); @@ -109,16 +117,16 @@ context_read (void) cp = concat ("Your MH-directory \"", nd, "\" doesn't exist; Create it? ", NULL); if (!read_yes_or_no_if_tty(cp)) - adios (NULL, "unable to access MH-directory \"%s\"", nd); + die("unable to access MH-directory \"%s\"", nd); free (cp); if (!makedir (nd)) - adios (NULL, "unable to create %s", nd); + die("unable to create %s", nd); } else if ((st.st_mode & S_IFDIR) == 0) - adios (NULL, "`%s' is not a directory", nd); + die("`%s' is not a directory", nd); /* * Open and read user's context file. The name of the context file comes from the @@ -137,7 +145,7 @@ context_read (void) return; } - ctxpath = getcpy (m_maildir (cp)); + ctxpath = mh_xstrdup(m_maildir(cp)); if ((ib = lkfopendata (ctxpath, "r", &failed_to_lock))) { readconfig(NULL, ib, cp, 1);