X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/c6f2d14d9c38345075629af3487c2de491584ca1..e605596f06f250775f89ddfe3f7f2c8fcfda1c4e:/sbr/context_read.c?ds=sidebyside diff --git a/sbr/context_read.c b/sbr/context_read.c index adaa172b..8350b98d 100644 --- a/sbr/context_read.c +++ b/sbr/context_read.c @@ -1,5 +1,4 @@ -/* - * context_read.c -- find and read profile and context files +/* context_read.c -- find and read profile and context files * * This code is Copyright (c) 2002, by the authors of nmh. See the * COPYRIGHT file in the root directory of the nmh distribution for @@ -23,6 +22,9 @@ */ #include /* mh internals */ +#include "lock_file.h" +#include "m_maildir.h" +#include "makedir.h" #include /* structure for getpwuid() results */ void @@ -37,7 +39,7 @@ context_read (void) int failed_to_lock = 0; /* - * If this routine _is_ called again (despite the wanings in the + * If this routine _is_ called again (despite the warnings in the * comments above), return immediately. */ if ( m_defs != 0 ) @@ -48,11 +50,10 @@ context_read (void) * the home directory field in the password file if that's not found. */ - if ((mypath = getenv("HOME")) == (char *)0) { - if ((pw = getpwuid(getuid())) == (struct passwd *)0 || *pw->pw_dir == '\0') + if ((mypath = getenv("HOME")) == NULL) { + if ((pw = getpwuid(getuid())) == NULL || *pw->pw_dir == '\0') adios(NULL, "cannot determine your home directory"); - else - mypath = pw->pw_dir; + mypath = pw->pw_dir; } /* @@ -68,16 +69,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((char *)0, "`%s' specified by your MH environment variable is not a normal file", cp); + adios(NULL, "`%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); + if ((ib = fopen(defpath, "r")) == NULL) + adios(NULL, "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."); + if ((ib = fopen(defpath, "r")) == NULL) + adios(NULL, "Doesn't look like nmh is installed. Run install-mh to do so."); cp = mh_profile; } @@ -90,7 +91,7 @@ context_read (void) * Convert a relative path name to an absolute one rooted in the home directory. */ - if ((cp = context_find ("path")) == (char *)0) + if ((cp = context_find ("path")) == NULL) adios(NULL, "Your %s file does not contain a path entry.", defpath); if (*cp == '\0') @@ -117,19 +118,19 @@ context_read (void) } else if ((st.st_mode & S_IFDIR) == 0) - adios ((char *)0, "`%s' is not a directory", nd); + adios (NULL, "`%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') + if ((cp = getenv ("MHCONTEXT")) == NULL || *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 this wasn't special-cased then the locking would be liable to fail) */ if (!cp || (strcmp(cp,"/dev/null") == 0)) { ctxpath = NULL; @@ -142,6 +143,4 @@ context_read (void) readconfig ((struct node **) 0, ib, cp, 1); lkfclosedata (ib, ctxpath); } - - return; }