X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=sbr%2Fcontext_read.c;h=5886c5ee30109170dfa6105cc6a4d7ee78685da5;hp=166fe592906174795b39e2d167190f1cea1d095a;hb=cf1205b5cbea2f0cd6ea710ec16c637df85b647c;hpb=d254c5e2ad008f26d5fda43c3f24f0a711c7e851 diff --git a/sbr/context_read.c b/sbr/context_read.c index 166fe59..5886c5e 100644 --- a/sbr/context_read.c +++ b/sbr/context_read.c @@ -29,6 +29,7 @@ #include /* structure for getpwuid() results */ #include #include +#include void context_read(void) @@ -54,7 +55,7 @@ context_read(void) */ if (!(mypath = getenv("HOME"))) { if (!(pw = getpwuid(getuid())) || !*pw->pw_dir) { - adios(NULL, "cannot determine your home directory"); + adios(EX_OSERR, NULL, "cannot determine your home directory"); } mypath = pw->pw_dir; } @@ -65,12 +66,12 @@ context_read(void) if ((cp = getenv("MMH")) && *cp) { mmhpath = getcpy(expanddir(cp)); /* rel to cwd */ if (stat(mmhpath, &st) != -1 && (st.st_mode & S_IFDIR) == 0) { - adios(NULL, "`%s' specified by your MMH environment variable is not a directory", cp); + adios(EX_CONFIG, NULL, "`%s' specified by your MMH environment variable is not a directory", cp); } } else { mmhpath = concat(mypath, "/", mmhdir, NULL); if (stat(mmhpath, &st) == -1 || (st.st_mode & S_IFDIR) == 0) { - adios(NULL, "Doesn't look like mmh is set up for your account. Run `mmh' to do so."); + adios(EX_CONFIG, NULL, "Doesn't look like mmh is set up for your account. Run `mmh' to do so."); } } @@ -86,15 +87,15 @@ context_read(void) defpath = concat(mmhpath, "/", cp, NULL); } if (stat(defpath, &st) != -1 && (st.st_mode & S_IFREG) == 0) { - adios(NULL, "Your profile `%s', specified by the MMHP environment variable, is not a normal file", cp); + 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(NULL, "Unable to read your profile `%s', specified by the MMHP environment variable", defpath); + 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(NULL, "No profile found. Please create `%s' first.", defpath); + adios(EX_CONFIG, NULL, "No profile found. Please create `%s' first.", defpath); } cp = profile; } @@ -107,10 +108,10 @@ context_read(void) ** to an absolute one rooted in the home directory. */ if ((cp = context_find("path")) == NULL) { - adios(NULL, "Your profile `%s' does not contain the required path entry.", defpath); + adios(EX_CONFIG, NULL, "Your profile `%s' does not contain the required path entry.", defpath); } if (!*cp) { - adios(NULL, "The Path entry of your profile `%s' must be non-empty.", defpath); + adios(EX_CONFIG, NULL, "The Path entry of your profile `%s' must be non-empty.", defpath); } if (*cp == '/') { nd = cp; @@ -119,18 +120,18 @@ context_read(void) } if (stat(nd, &st) == -1) { if (errno != ENOENT) { - adios(nd, "error opening"); + adios(EX_IOERR, nd, "error opening"); } cp = concat("Your mail storage directory `", nd, "' doesn't exist; Create it? ", NULL); if (!getanswer(cp)) { - adios(NULL, "Unable to access the mail storage directory `%s'", nd); + adios(EX_NOPERM, NULL, "Unable to access the mail storage directory `%s'", nd); } free(cp); if (!makedir(nd)) { - adios(nd, "unable to create"); + adios(EX_CANTCREAT, nd, "unable to create"); } } else if ((st.st_mode & S_IFDIR) == 0) { - adios(NULL, "Your mail storage `%s' is not a directory", nd); + adios(EX_DATAERR, NULL, "Your mail storage `%s' is not a directory", nd); } /* ** Create the default folder (inbox) @@ -138,10 +139,10 @@ context_read(void) cp = toabsdir(defaultfolder); if (stat(cp, &st) == -1) { if (!makedir(cp)) { - adios(cp, "Unable to create the default folder"); + adios(EX_CANTCREAT, cp, "Unable to create the default folder"); } } else if ((st.st_mode & S_IFDIR) == 0) { - adios(NULL, "The default folder `%s' is not a directory", cp); + adios(EX_DATAERR, NULL, "The default folder `%s' is not a directory", cp); } /*