X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=sbr%2Fcontext_read.c;h=1e1a84e36e8cd280e65419b5cc2cb67f02d35b82;hp=24e6350aa02c0b51fb930529f128c12705370900;hb=ced6090a330d3d83d0bce709f756aa3d7d65fea4;hpb=337338b404931f06f0db2119c9e145e8ca5a9860 diff --git a/sbr/context_read.c b/sbr/context_read.c index 24e6350..1e1a84e 100644 --- a/sbr/context_read.c +++ b/sbr/context_read.c @@ -1,26 +1,26 @@ /* - * 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 - * complete copyright information. - * - * This function must be called early on in any nmh utility, and - * may only be called once. It does the following: - * - * o Sets the global variable "mypath" to the home directory path. - * - * o Sets the global variable "defpath" to the absolute path of - * the profile file. - * - * o Reads in the profile file. Bails out if it can't. - * - * o Makes sure that the mail directory exists, prompting for - * creation if it doesn't. - * - * o Reads the context file either as set by the MHCONTEXT - * environment variable or by the profile. - */ +** 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 +** complete copyright information. +** +** This function must be called early on in any nmh utility, and +** may only be called once. It does the following: +** +** o Sets the global variable "mypath" to the home directory path. +** +** o Sets the global variable "defpath" to the absolute path of +** the profile file. +** +** o Reads in the profile file. Bails out if it can't. +** +** o Makes sure that the mail directory exists, prompting for +** creation if it doesn't. +** +** o Reads the context file either as set by the MHCONTEXT +** environment variable or by the profile. +*/ #include /* mh internals */ #include /* system call errors */ @@ -37,29 +37,30 @@ context_read (void) register FILE *ib; /* profile and context file pointer */ /* - * If this routine _is_ called again (despite the wanings in the - * comments above), return immediately. - */ + ** If this routine _is_ called again (despite the wanings in the + ** comments above), return immediately. + */ if ( m_defs != 0 ) return; /* - * Find user's home directory. Try the HOME environment variable first, - * the home directory field in the password file if that's not found. - */ + ** Find user's home directory. Try the HOME environment variable first, + ** 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') - adios(NULL, "cannot determine your home directory"); - else - mypath = pw->pw_dir; + if ((pw = getpwuid(getuid())) == (struct passwd *)0 || *pw->pw_dir == '\0') + adios(NULL, "cannot determine your home directory"); + else + mypath = pw->pw_dir; } /* - * 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. - */ + ** 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); @@ -82,9 +83,10 @@ context_read (void) 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. - */ + ** 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); @@ -110,17 +112,20 @@ context_read (void) 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. - */ + ** 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) - */ + /* + ** 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; return;