]> diplodocus.org Git - nmh/commitdiff
Replaced boilerplate at beginning of each nmh program with new
authorDavid Levine <levinedl@acm.org>
Sat, 25 Jan 2014 15:15:05 +0000 (09:15 -0600)
committerDavid Levine <levinedl@acm.org>
Sat, 25 Jan 2014 15:15:05 +0000 (09:15 -0600)
nmh_init() function.  It sets up an atexit() function and signal
handlers so that all temporary files are removed when the program
terminates, however that happens.  It relies on a call in m_mktemp()
to register each temporary file for removal.  See new "nmh temporary
files" section in README.developers and comments in m_mktemp.c.

56 files changed:
docs/README.developers
h/prototypes.h
sbr/m_mktemp.c
sbr/signals.c
sbr/utils.c
uip/ali.c
uip/anno.c
uip/ap.c
uip/burst.c
uip/comp.c
uip/conflict.c
uip/dist.c
uip/dp.c
uip/flist.c
uip/fmtdump.c
uip/fmttest.c
uip/folder.c
uip/forw.c
uip/inc.c
uip/install-mh.c
uip/mark.c
uip/mhbuild.c
uip/mhfixmsg.c
uip/mhl.c
uip/mhlist.c
uip/mhlsbr.c
uip/mhn.c
uip/mhparam.c
uip/mhpath.c
uip/mhshow.c
uip/mhstore.c
uip/mhtest.c
uip/msgchk.c
uip/msh.c
uip/new.c
uip/packf.c
uip/pick.c
uip/post.c
uip/prompter.c
uip/rcvdist.c
uip/rcvpack.c
uip/rcvstore.c
uip/rcvtty.c
uip/refile.c
uip/repl.c
uip/rmf.c
uip/rmm.c
uip/scan.c
uip/send.c
uip/show.c
uip/slocal.c
uip/sortm.c
uip/viamail.c
uip/whatnow.c
uip/whatnowsbr.c
uip/whom.c

index 76f650dcbad534659bd47dce5998d3afea8b5db0..1d3fd73799c93df756abf0f464ac81e6d7a9e632 100644 (file)
@@ -22,6 +22,15 @@ commit checklist
 8. notify nmh-users?
 
 
 8. notify nmh-users?
 
 
+---------------------------------
+C library/system call usage notes
+---------------------------------
+* Use m_mktemp2() or m_mktemp() instead of mkstemp(3) (see section on
+  nmh temporary files below).
+* Use m_unlink() instead of unlink(3).
+* Use done() instead of _exit(3) except after a fork(3).
+
+
 -------------------------
 autoconf & automake files
 -------------------------
 -------------------------
 autoconf & automake files
 -------------------------
@@ -162,6 +171,21 @@ OS function  nmh-local version to use instead
 getpass()    nmh_getpass()
 
 
 getpass()    nmh_getpass()
 
 
+-------------------
+nmh temporary files
+-------------------
+
+To create a temporary file, use m_mktemp2() or m_mktemp().  They use
+mkstemp(3), but they also register the temporary file for removal on
+program termination.  So, do not use mkstemp() directly.
+
+To further support this, nmh_init() must be called at the beginning of
+main().  And, if a child process is not going to immediately call one
+of the exec(3) functions or _exit(3) after a fork(3), it should call
+unregister_for_removal(0).  Finally, nmh_init() sets up signal handlers
+for several signals:  these signal handlers should not be disabled.
+
+
 --------------
 nmh test suite
 --------------
 --------------
 nmh test suite
 --------------
index 0baa026c3a163a74bac6aa20dd730add7eb26cd9..eefbfec571eb94f0b822eeabe4a6d0c5eafffe79 100644 (file)
@@ -359,3 +359,10 @@ char *construct_build_directive(char *, const char *, int);
  */
 void init_credentials_file ();
 int nmh_get_credentials (char *, char *, int, nmh_creds_t);
  */
 void init_credentials_file ();
 int nmh_get_credentials (char *, char *, int, nmh_creds_t);
+
+/*
+ * temporary file management
+ */
+int nmh_init(const char *argv0, int read_context);
+int m_unlink(const char *);
+void unregister_for_removal(int remove_files);
index 352cb7cd87e77f313279d811b1b8144b6cfee20e..cc9c45f521c347149588f6a2f393a4a7fb44f248 100644 (file)
@@ -7,6 +7,11 @@
  */
 
 #include <h/mh.h>
  */
 
 #include <h/mh.h>
+#include <h/utils.h>
+#include <h/signals.h>
+
+static void register_for_removal(const char *);
+
 
 /*  Create a temporary file.  If pfx_in is null, the temporary file
  *  will be created in the temporary directory (more on that later).
 
 /*  Create a temporary file.  If pfx_in is null, the temporary file
  *  will be created in the temporary directory (more on that later).
@@ -56,10 +61,14 @@ m_mktemp (
     }
 
     fd = mkstemp(tmpfil);
     }
 
     fd = mkstemp(tmpfil);
+
     if (fd < 0) {
         umask(oldmode);
         return NULL;
     }
     if (fd < 0) {
         umask(oldmode);
         return NULL;
     }
+
+    register_for_removal(tmpfil);
+
     if (fd_ret != NULL) {
         *fd_ret = fd;
         keep_open = 1;
     if (fd_ret != NULL) {
         *fd_ret = fd;
         keep_open = 1;
@@ -141,3 +150,125 @@ get_temp_dir()
     }
     return m_maildir("");
 }
     }
     return m_maildir("");
 }
+
+
+/*
+ * Array of files (full pathnames) to remove on process exit.
+ * Instead of removing slots from the array, just set to NULL
+ * to indicate that the file should no longer be removed.
+ */
+static svector_t exit_filelist = NULL;
+
+/*
+ * Register a file for removal at program termination.
+ */
+static void
+register_for_removal(const char *pathname) {
+    if (exit_filelist == NULL) exit_filelist = svector_create(20);
+    (void) svector_push_back(exit_filelist, add(pathname, NULL));
+}
+
+/*
+ * Unregister all files that were registered to be removed at program
+ * termination.  When called with remove_files of 0, this function is
+ * intended for use by one of the programs after a fork(3) without a
+ * subsequent call to one of the exec(3) functions or _exit(3).  When
+ * called with non-0 remove_files argument, it is intended for use by
+ * an atexit() function.
+ *
+ * Right after a fork() and before calling exec() or _exit(), if the
+ * child catches one of the appropriate signals, it will remove
+ * all the registered temporary files.  Some of those may be needed by
+ * the parent.  Some nmh programs ignore or block some of the signals
+ * in the child right after fork().  For the other programs, rather
+ * than complicate things by preventing that, just take the chance
+ * that it might happen.  It is harmless to attempt to unlink a
+ * temporary file twice, assuming another one wasn't created too
+ * quickly created with the same name.
+ */
+void
+unregister_for_removal(int remove_files) {
+    if (exit_filelist) {
+        size_t i;
+
+        for (i = 0; i < svector_size(exit_filelist); ++i) {
+            char *filename = svector_at(exit_filelist, i);
+
+            if (filename) {
+                if (remove_files) (void) unlink(filename);
+                free(filename);
+            }
+        }
+
+        svector_free(exit_filelist);
+        exit_filelist = NULL;
+    }
+}
+
+/*
+ * If the file was registered for removal, deregister it.  In
+ * any case, unlink it.
+ */
+int
+m_unlink(const char *pathname) {
+    if (exit_filelist) {
+        char **slot = svector_find(exit_filelist, pathname);
+
+        if (slot  &&  *slot) {
+            free(*slot);
+            *slot = NULL;
+        }
+    }
+
+    return unlink(pathname);
+    /* errno should be set to ENOENT if file was not found */
+}
+
+/*
+ * Remove all registered temporary files.
+ */
+void
+remove_registered_files_atexit() {
+    unregister_for_removal(1);
+}
+
+/*
+ * Remove all registered temporary files.  Suitable for use as a
+ * signal handler.  If the signal is one of the usual process
+ * termination signals, calls exit().  Otherwise, disables itself
+ * by restoring the default action and then re-raises the signal,
+ * in case the use was expecting a core dump.
+ */
+void
+remove_registered_files(int sig) {
+    struct sigaction act;
+
+    /*
+     * Ignore this signal for the duration.  And we either exit() or
+     * disable this signal handler below, so don't restore this handler.
+     */
+    act.sa_handler = SIG_IGN;
+    (void) sigemptyset(&act.sa_mask);
+    act.sa_flags = 0;
+    (void) sigaction(sig, &act, 0);
+
+    if (sig == SIGHUP || sig == SIGINT || sig == SIGQUIT || sig == SIGTERM) {
+        /*
+         * We don't need to call remove_registered_files_atexit() if
+         * it was registered with atexit(), but let's not assume that.
+         * It's harmless to call it twice.
+         */
+        remove_registered_files_atexit();
+
+        exit(1);
+    } else {
+        act.sa_handler = SIG_DFL;
+        (void) sigemptyset(&act.sa_mask);
+        act.sa_flags = 0;
+        (void) sigaction(sig, &act, 0);
+
+        remove_registered_files_atexit();
+
+        (void) raise(sig);
+    }
+}
index eb26e632317be1075936a8981f8fe5a17c90ec71..7645c1ccd52e9a6e591dd5d81b12e6be0ff61ddc 100644 (file)
@@ -10,6 +10,9 @@
 #include <h/mh.h>
 #include <h/signals.h>
 
 #include <h/mh.h>
 #include <h/signals.h>
 
+/* sbr/m_mktemp.c */
+extern void remove_registered_files(int);
+
 
 /*
  * A version of the function `signal' that uses reliable
 
 /*
  * A version of the function `signal' that uses reliable
@@ -78,3 +81,30 @@ SIGNAL2 (int sig, SIGNAL_HANDLER func)
     return (oact.sa_handler);
 }
 
     return (oact.sa_handler);
 }
 
+
+/*
+ * For use by nmh_init().
+ */
+int
+setup_signal_handlers() {
+    /*
+     * Catch HUP, INT, QUIT, and TERM so that we can clean up tmp
+     * files when the user terminates the process early.  And also a
+     * few other common signals that can be thrown due to bugs, stack
+     * overflow, etc.
+     */
+
+    if (SIGNAL(SIGHUP,  remove_registered_files) == SIG_ERR  ||
+        SIGNAL(SIGINT,  remove_registered_files) == SIG_ERR  ||
+        SIGNAL(SIGQUIT, remove_registered_files) == SIG_ERR  ||
+        SIGNAL(SIGTERM, remove_registered_files) == SIG_ERR  ||
+        SIGNAL(SIGILL,  remove_registered_files) == SIG_ERR  ||
+#       ifdef SIGBUS
+        SIGNAL(SIGBUS,  remove_registered_files) == SIG_ERR  ||
+#       endif
+        SIGNAL(SIGSEGV, remove_registered_files) == SIG_ERR) {
+        return NOTOK;
+    }
+
+    return OK;
+}
index 7f0760a0aefa46430c0f96352454b36392e22b45..d17bad94b6c5926f4b322582f60d87def3eb3970 100644 (file)
 #include <h/utils.h>
 #include <fcntl.h>
 
 #include <h/utils.h>
 #include <fcntl.h>
 
+/* sbr/signals.c */
+extern int setup_signal_handlers();
+
+/* sbr/m_mktemp.c */
+extern void remove_registered_files_atexit();
+
+
 /*
  * We allocate space for messages (msgs array)
  * this number of elements at a time.
 /*
  * We allocate space for messages (msgs array)
  * this number of elements at a time.
@@ -317,3 +324,33 @@ nmh_strcasestr (const char *s1, const char *s2) {
 
     return NULL;
 }
 
     return NULL;
 }
+
+
+int
+nmh_init(const char *argv0, int read_context) {
+#ifdef LOCALE
+    setlocale(LC_ALL, "");
+#endif
+
+    invo_name = r1bindex ((char *) argv0, '/');
+
+    if (setup_signal_handlers()) {
+        admonish("sigaction", "unable to set up signal handlers");
+    }
+
+    /* POSIX atexit() does not define any error conditions. */
+    if (atexit(remove_registered_files_atexit)) {
+        admonish("atexit", "unable to register atexit function");
+    }
+
+    if (read_context) {
+        context_read();
+        return OK;
+    } else {
+        int status = context_foil(NULL);
+        if (status != OK) {
+            advise("", "failed to create minimal profile/conext");
+        }
+        return status;
+    }
+}
index dda0a2c1f5907a1d27c4c0342e7027843f36c572..e7c865befee983e6f8ef98e6763b65454aff9402 100644 (file)
--- a/uip/ali.c
+++ b/uip/ali.c
@@ -53,13 +53,7 @@ main (int argc, char **argv)
     char **vec = mh_xmalloc (argc * sizeof (char *)), **arguments;
     struct aka *ak;
 
     char **vec = mh_xmalloc (argc * sizeof (char *)), **arguments;
     struct aka *ak;
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
-
-    /* read user profile/context */
-    context_read();
+    if (nmh_init(argv[0], 1)) { return 1; }
 
     mts_init (invo_name);
     arguments = getarguments (invo_name, argc, argv, 1);
 
     mts_init (invo_name);
     arguments = getarguments (invo_name, argc, argv, 1);
index d18713ae668a3c16f9ff334b201936bee291fdc2..26706edac514e8c51f364104cb2915c30c031e1b 100644 (file)
@@ -94,13 +94,7 @@ main (int argc, char **argv)
     int                list = 0;               /* list header elements if set */
     int                number = 0;             /* delete specific number of like elements if set */
 
     int                list = 0;               /* list header elements if set */
     int                number = 0;             /* delete specific number of like elements if set */
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
-
-    /* read user profile/context */
-    context_read();
+    if (nmh_init(argv[0], 1)) { return 1; }
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
index f0b0baa98f3e408c80f22c1f3a402918b12710a2..c8cf4b25d120327c8df257ed152c4d0f5c1f8861 100644 (file)
--- a/uip/ap.c
+++ b/uip/ap.c
@@ -53,13 +53,7 @@ main (int argc, char **argv)
     char buf[BUFSIZ], **argp;
     char **arguments, *addrs[NADDRS];
 
     char buf[BUFSIZ], **argp;
     char **arguments, *addrs[NADDRS];
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
-
-    /* read user profile/context */
-    context_read();
+    if (nmh_init(argv[0], 1)) { return 1; }
 
     mts_init (invo_name);
     arguments = getarguments (invo_name, argc, argv, 1);
 
     mts_init (invo_name);
     arguments = getarguments (invo_name, argc, argv, 1);
index c3f217103c209067d9ea1a062de494df908d1de9..ff5af237c60f2adba797d03b5b6d215a6343d622 100644 (file)
@@ -75,13 +75,7 @@ main (int argc, char **argv)
     struct smsg *smsgs;
     struct msgs *mp;
 
     struct smsg *smsgs;
     struct msgs *mp;
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
-
-    /* read user profile/context */
-    context_read();
+    if (nmh_init(argv[0], 1)) { return 1; }
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
index 08507299e63c8ffb23785cadfe42ef8013e7179a..02feefaa445765d10c19946004b485cf5f9bb36f 100644 (file)
@@ -83,13 +83,7 @@ main (int argc, char **argv)
     struct format *fmt;
     struct stat st;
 
     struct format *fmt;
     struct stat st;
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
-
-    /* read user profile/context */
-    context_read();
+    if (nmh_init(argv[0], 1)) { return 1; }
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
index a43c70ee2c899edb578d11b1353c94483f4ad724..4c140022345c04285d1ac032186e2c537077c576 100644 (file)
@@ -68,14 +68,7 @@ main (int argc, char **argv)
     char *cp, **argp, **arguments;
     char buf[BUFSIZ], *akv[50];
 
     char *cp, **argp, **arguments;
     char buf[BUFSIZ], *akv[50];
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
-
-    /* foil search of user profile/context */
-    if (context_foil (NULL) == -1)
-       done (1);
+    if (nmh_init(argv[0], 0 /* use context_foil() */)) { return 1; }
 
     mts_init (invo_name);
     arguments = getarguments (invo_name, argc, argv, 0);
 
     mts_init (invo_name);
     arguments = getarguments (invo_name, argc, argv, 0);
index d3ceaec25a480e4cf591570a0b8b9b086198892b..5a35e59a7385b052b918a9f3b47b81f2ac308114 100644 (file)
@@ -83,13 +83,7 @@ main (int argc, char **argv)
     struct msgs *mp = NULL;
     struct stat st;
 
     struct msgs *mp = NULL;
     struct stat st;
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
-
-    /* read user profile/context */
-    context_read();
+    if (nmh_init(argv[0], 1)) { return 1; }
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
index 67eef06189310e92b5942924febf5c7944379013..dabdd74c84adde9eb358988a2b5aa1e64def9e13 100644 (file)
--- a/uip/dp.c
+++ b/uip/dp.c
@@ -51,13 +51,7 @@ main (int argc, char **argv)
     char buf[BUFSIZ], **argp, **arguments;
     char *dates[NDATES];
 
     char buf[BUFSIZ], **argp, **arguments;
     char *dates[NDATES];
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
-
-    /* read user profile/context */
-    context_read();
+    if (nmh_init(argv[0], 1)) { return 1; }
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
index fe3dcebde92c74cd0e7a13bf24b6ed8507cd6bde..829500d625c69f0fa60e3f5fc4c053f30adb982a 100644 (file)
@@ -115,13 +115,7 @@ main(int argc, char **argv)
     char **arguments;
     char buf[BUFSIZ];
 
     char **arguments;
     char buf[BUFSIZ];
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex(argv[0], '/');
-
-    /* read user profile/context */
-    context_read();
+    if (nmh_init(argv[0], 1)) { return 1; }
 
     /*
      * If program was invoked with name ending
 
     /*
      * If program was invoked with name ending
index 653581684c1c87f82aeafa0a7fbe8f2114e87cad..f1df6f35f758dd0ba292c6f127ad9a9ec479570d 100644 (file)
@@ -51,13 +51,7 @@ main (int argc, char **argv)
     char buf[BUFSIZ], *nfs, **argp, **arguments;
     struct format *fmt;
 
     char buf[BUFSIZ], *nfs, **argp, **arguments;
     struct format *fmt;
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
-
-    /* read user profile/context */
-    context_read();
+    if (nmh_init(argv[0], 1)) { return 1; }
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
index b39d0d527b4a753c5698b9059456f18207f1d9c8..2f45e7b5363b96b5b0f7aee34c5837f94da42615 100644 (file)
@@ -121,13 +121,7 @@ main (int argc, char **argv)
     int dat[5];
     struct fmt_callbacks cb, *cbp = NULL;
 
     int dat[5];
     struct fmt_callbacks cb, *cbp = NULL;
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
-
-    /* read user profile/context */
-    context_read();
+    if (nmh_init(argv[0], 1)) { return 1; }
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
index 9fa298402e0268e1ed9aa18315d9b0d7fa33d06f..98ecde68d70f27ac102083dfb6012e8e04a799a7 100644 (file)
@@ -101,13 +101,7 @@ main (int argc, char **argv)
     char *cp, *dp, *msg = NULL, *argfolder = NULL;
     char **ap, **argp, buf[BUFSIZ], **arguments;
 
     char *cp, *dp, *msg = NULL, *argfolder = NULL;
     char **ap, **argp, buf[BUFSIZ], **arguments;
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
-
-    /* read user profile/context */
-    context_read();
+    if (nmh_init(argv[0], 1)) { return 1; }
 
     /*
      * If program was invoked with name ending
 
     /*
      * If program was invoked with name ending
index 45fb740f771c1276e2a6d151cbaca6794ee2b4f5..2139d35cffa5a8c5c1bbf17fe253f64ef4ca8d42 100644 (file)
@@ -116,16 +116,9 @@ main (int argc, char **argv)
     char **argp, **arguments;
     struct stat st;
     struct msgs_array msgs = { 0, 0, NULL };
     char **argp, **arguments;
     struct stat st;
     struct msgs_array msgs = { 0, 0, NULL };
-
     int buildsw = 0;
 
     int buildsw = 0;
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
-
-    /* read user profile/context */
-    context_read();
+    if (nmh_init(argv[0], 1)) { return 1; }
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
index 0e527442d8c7a1a30dfbcdb4b93ca91befec3742..bf8216f4061f8122b9d5164ede9727afeac1a5c9 100644 (file)
--- a/uip/inc.c
+++ b/uip/inc.c
@@ -197,13 +197,7 @@ main (int argc, char **argv)
     SAVEGROUPPRIVS();
     TRYDROPGROUPPRIVS();
 
     SAVEGROUPPRIVS();
     TRYDROPGROUPPRIVS();
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
-
-    /* read user profile/context */
-    context_read();
+    if (nmh_init(argv[0], 1)) { return 1; }
 
     mts_init (invo_name);
     arguments = getarguments (invo_name, argc, argv, 1);
 
     mts_init (invo_name);
     arguments = getarguments (invo_name, argc, argv, 1);
index 2921d2619ccc0bd74f2f9e285ae4e08da05c8ce9..12377352a8c71ea6c4ca5fc824602d938fc4d0f2 100644 (file)
@@ -42,10 +42,8 @@ main (int argc, char **argv)
     FILE *in, *out;
     int                check;
 
     FILE *in, *out;
     int                check;
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
+    if (nmh_init(argv[0], 0 /* use context_foil() */ )) { return 1; }
+
     arguments = getarguments (invo_name, argc, argv, 0);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 0);
     argp = arguments;
 
index f0f3d7a6b6f1570f39a09bb71ea3f3c9f39f6be2..da25f0b376bfe3e36a8d04aac1d063f61f52b2de 100644 (file)
@@ -52,13 +52,7 @@ main (int argc, char **argv)
     struct msgs_array msgs = { 0, 0, NULL };
     struct msgs *mp;
 
     struct msgs_array msgs = { 0, 0, NULL };
     struct msgs *mp;
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
-
-    /* read user profile/context */
-    context_read();
+    if (nmh_init(argv[0], 1)) { return 1; }
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
index f3dc91c7a5772d5fb5dad69a1c8b1869160f56d9..b0ef72ae4079d5f7c416128d763097b9351cac59 100644 (file)
@@ -110,15 +110,9 @@ main (int argc, char **argv)
     FILE *fp_out = NULL;
     int header_encoding = CE_UNKNOWN;
 
     FILE *fp_out = NULL;
     int header_encoding = CE_UNKNOWN;
 
-    done=unlink_done;
-
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
+    if (nmh_init(argv[0], 1)) { return 1; }
 
 
-    /* read user profile/context */
-    context_read();
+    done=unlink_done;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
index d81337d6e42534ea2eec6b994f4939580a93e454..a59ca5095c74078b2770abb2299d8df369fb72af 100644 (file)
@@ -134,15 +134,9 @@ main (int argc, char **argv) {
     fx.decodetext = CE_8BIT;
     fx.textcodeset = NULL;
 
     fx.decodetext = CE_8BIT;
     fx.textcodeset = NULL;
 
-    done = freects_done;
-
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
+    if (nmh_init(argv[0], 1)) { return 1; }
 
 
-    /* read user profile/context */
-    context_read();
+    done = freects_done;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
index af4cdfa8f4f14d50f5f613bcb66ad4f85332e570..652fb11b1d01adbc61dfa2d680a3f1037daca919 100644 (file)
--- a/uip/mhl.c
+++ b/uip/mhl.c
@@ -13,9 +13,8 @@
 int
 main (int argc, char **argv)
 {
 int
 main (int argc, char **argv)
 {
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
+    if (nmh_init(argv[0], 1)) { return 1; }
+
     done (mhl (argc, argv));
     return 1;
 }
     done (mhl (argc, argv));
     return 1;
 }
index 9cdcdf6bf2dab6d7ee130bc853a84b946a88a8d4..f37041c38f1cb07d01b52a4595296535e3c479c7 100644 (file)
@@ -104,15 +104,9 @@ main (int argc, char **argv)
     struct msgs *mp = NULL;
     CT ct, *ctp;
 
     struct msgs *mp = NULL;
     CT ct, *ctp;
 
-    done=freects_done;
-
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
+    if (nmh_init(argv[0], 1)) { return 1; }
 
 
-    /* read user profile/context */
-    context_read();
+    done=freects_done;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
index 6a1c3db7878ef0e2121c1bc25c8c30fda167e073..f4df180abfb59927e355482b00d3446b25a864aa 100644 (file)
@@ -349,11 +349,6 @@ mhl (int argc, char **argv)
     char buf[BUFSIZ], *files[MAXARGS];
     char **argp, **arguments;
 
     char buf[BUFSIZ], *files[MAXARGS];
     char **argp, **arguments;
 
-    invo_name = r1bindex (argv[0], '/');
-
-    /* read user profile/context */
-    context_read();
-
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
index 49c784b9f19761bb5a589ce4c865db8bfb6e18d1..08405d4d009dbd6f6bcc22f4f19c5d0abf3882c7 100644 (file)
--- a/uip/mhn.c
+++ b/uip/mhn.c
@@ -164,15 +164,9 @@ main (int argc, char **argv)
     CT ct, *ctp;
     FILE *fp;
 
     CT ct, *ctp;
     FILE *fp;
 
-    done=freects_done;
-
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
+    if (nmh_init(argv[0], 1)) { return 1; }
 
 
-    /* read user profile/context */
-    context_read();
+    done=freects_done;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
index b0c119cfa4365a676536d62e9ffc93fbe32c8672..8a276f72402b50ef0a5200903fe74314fc38fb0a 100644 (file)
@@ -131,10 +131,7 @@ main(int argc, char **argv)
     char *cp, buf[BUFSIZ], **argp;
     char **arguments, *comps[MAXARGS];
 
     char *cp, buf[BUFSIZ], **argp;
     char **arguments, *comps[MAXARGS];
 
-    invo_name = r1bindex (argv[0], '/');
-
-    /* read user profile/context */
-    context_read();
+    if (nmh_init(argv[0], 1)) { return 1; }
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
index 3a0a628b6f1e522d387885ee0be5803a8cc72e9d..b9506d7383cc96efe8818bf9d6172be2acdecb1d 100644 (file)
@@ -32,13 +32,7 @@ main(int argc, char **argv)
     struct msgs_array msgs = { 0, 0, NULL };
     struct msgs *mp;
 
     struct msgs_array msgs = { 0, 0, NULL };
     struct msgs *mp;
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
-
-    /* read user profile/context */
-    context_read();
+    if (nmh_init(argv[0], 1)) { return 1; }
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
index 3d1f3e6b86bca92e3abbc001c3b90db1481d0abe..f83236b7433e1f063ef77ce29aa6efb6121c86b1 100644 (file)
@@ -114,15 +114,9 @@ main (int argc, char **argv)
     CT ct, *ctp;
     FILE *fp;
 
     CT ct, *ctp;
     FILE *fp;
 
-    done=freects_done;
-
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
+    if (nmh_init(argv[0], 1)) { return 1; }
 
 
-    /* read user profile/context */
-    context_read();
+    done=freects_done;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
index 050310cfec82c97403ff570d38440d7188d1c210..fb5349faaeba04ac7966226a1a42549755548265 100644 (file)
@@ -103,15 +103,9 @@ main (int argc, char **argv)
     CT ct, *ctp;
     FILE *fp;
 
     CT ct, *ctp;
     FILE *fp;
 
-    done=freects_done;
-
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
+    if (nmh_init(argv[0], 1)) { return 1; }
 
 
-    /* read user profile/context */
-    context_read();
+    done=freects_done;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
index abdfdadfac61aced1eb3b73ee411882700dce6e0..30459136f712413bce2bf7c6e5bafa9b63e99364 100644 (file)
@@ -99,15 +99,9 @@ main (int argc, char **argv)
     struct msgs *mp = NULL;
     CT ct, *ctp;
 
     struct msgs *mp = NULL;
     CT ct, *ctp;
 
-    done=freects_done;
-
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
+    if (nmh_init(argv[0], 1)) { return 1; }
 
 
-    /* read user profile/context */
-    context_read();
+    done=freects_done;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
index 76bb37d8e7be37831fd20f151c112b4b23f9522c..49e758f07be9aa4c37a1dca644df06b624ed4324 100644 (file)
@@ -85,13 +85,7 @@ main (int argc, char **argv)
     char **argp, **arguments, *vec[MAXVEC];
     struct passwd *pw;
 
     char **argp, **arguments, *vec[MAXVEC];
     struct passwd *pw;
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
-
-    /* read user profile/context */
-    context_read();
+    if (nmh_init(argv[0], 1)) { return 1; }
 
     mts_init (invo_name);
 
 
     mts_init (invo_name);
 
index 2fb2b23092553f72dfc69b3de0c0a5b2d5a542e4..fbfb408e007613679fd915cb3db3cf655f8881dd 100644 (file)
--- a/uip/msh.c
+++ b/uip/msh.c
@@ -203,13 +203,7 @@ main (int argc, char **argv)
     char *cp, *file = NULL, *folder = NULL;
     char **argp, **arguments, buf[BUFSIZ];
 
     char *cp, *file = NULL, *folder = NULL;
     char **argp, **arguments, buf[BUFSIZ];
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
-
-    /* read user profile/context */
-    context_read();
+    if (nmh_init(argv[0], 1)) { return 1; }
 
     mts_init (invo_name);
     arguments = getarguments (invo_name, argc,argv, 1);
 
     mts_init (invo_name);
     arguments = getarguments (invo_name, argc,argv, 1);
index 74d4d5122a91dcadecf65304eacbf9deaf831f45..6f9982528c50111ade88551a63ac45616ac6062f 100644 (file)
--- a/uip/new.c
+++ b/uip/new.c
@@ -422,13 +422,7 @@ main(int argc, char **argv)
     char *unseen;
     struct node *folder;
 
     char *unseen;
     struct node *folder;
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex(argv[0], '/');
-
-    /* read user profile/context */
-    context_read();
+    if (nmh_init(argv[0], 1)) { return 1; }
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
index f070f48d81bfe9cf2730348b44ec643275ae6c07..30f0f484059cd234f81e8e8129f9a9805040d836 100644 (file)
@@ -46,15 +46,9 @@ main (int argc, char **argv)
     struct msgs *mp;
     struct stat st;
 
     struct msgs *mp;
     struct stat st;
 
-    done=mbxclose_done;
-
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
+    if (nmh_init(argv[0], 1)) { return 1; }
 
 
-    /* read user profile/context */
-    context_read();
+    done=mbxclose_done;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
index 5f2802437c1acb4701699b91096302dedc00110d..740f6f0a4e9524069b831a1bf88746708aa8a1e7 100644 (file)
@@ -66,15 +66,9 @@ main (int argc, char **argv)
     struct msgs *mp, *mp2;
     register FILE *fp;
 
     struct msgs *mp, *mp2;
     register FILE *fp;
 
-    done=putzero_done;
-
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
+    if (nmh_init(argv[0], 1)) { return 1; }
 
 
-    /* read user profile/context */
-    context_read();
+    done=putzero_done;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
index 2683622e55051115ed8c3af8f2efddcc54c8533a..5d227c40a959b378e355df0adc3faf39edf3f474 100644 (file)
@@ -283,14 +283,7 @@ main (int argc, char **argv)
     FILE *in, *out;
     m_getfld_state_t gstate = 0;
 
     FILE *in, *out;
     m_getfld_state_t gstate = 0;
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
-
-    /* foil search of user profile/context */
-    if (context_foil (NULL) == -1)
-       done (1);
+    if (nmh_init(argv[0], 0 /* use context_foil() */)) { return 1; }
 
     mts_init (invo_name);
     arguments = getarguments (invo_name, argc, argv, 0);
 
     mts_init (invo_name);
     arguments = getarguments (invo_name, argc, argv, 0);
index 0aedc8c1d13417abee8ea92249f27cda3cf7f937..35052e62ae0d8beae5dd1213094c1974011ce130 100644 (file)
@@ -78,13 +78,7 @@ main (int argc, char **argv)
     char *tmpfil;
     m_getfld_state_t gstate = 0;
 
     char *tmpfil;
     m_getfld_state_t gstate = 0;
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
-
-    /* read user profile/context */
-    context_read();
+    if (nmh_init(argv[0], 1)) { return 1; }
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
index 4f7a83f7b30635993d17e9eadc97ea900364891e..a87a5e84d324773b239cb19c908b26a666c2cf09 100644 (file)
@@ -48,15 +48,9 @@ main (int argc, char **argv)
     FILE *fp;
     char *tfile = NULL;
 
     FILE *fp;
     char *tfile = NULL;
 
-    done=unlink_done;
-
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
+    if (nmh_init(argv[0], 1)) { return 1; }
 
 
-    /* read user profile/context */
-    context_read();
+    done=unlink_done;
 
     /*
      * Configure this now, since any unknown switches to rcvdist get
 
     /*
      * Configure this now, since any unknown switches to rcvdist get
index 4725f26cc94a876066bfaf828a863badbc4f461f..bbd0e08e7ff34c10cb5538ef328545948d70352d 100644 (file)
@@ -40,13 +40,7 @@ main (int argc, char **argv)
     char *cp, *file = NULL, buf[BUFSIZ];
     char **argp, **arguments;
 
     char *cp, *file = NULL, buf[BUFSIZ];
     char **argp, **arguments;
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
-
-    /* read user profile/context */
-    context_read();
+    if (nmh_init(argv[0], 1)) { return 1; }
 
     mts_init (invo_name);
     arguments = getarguments (invo_name, argc, argv, 1);
 
     mts_init (invo_name);
     arguments = getarguments (invo_name, argc, argv, 1);
index e6de62b0e9d57f844ed28c7bdefb4aadce02542b..64b4a0072efd80d99e702c9bd94baa9a2dc154b9 100644 (file)
@@ -54,15 +54,9 @@ main (int argc, char **argv)
     struct msgs *mp;
     struct stat st;
 
     struct msgs *mp;
     struct stat st;
 
-    done=unlink_done;
-
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
+    if (nmh_init(argv[0], 1)) { return 1; }
 
 
-    /* read user profile/context */
-    context_read();
+    done=unlink_done;
 
     mts_init (invo_name);
     arguments = getarguments (invo_name, argc, argv, 1);
 
     mts_init (invo_name);
     arguments = getarguments (invo_name, argc, argv, 1);
index 9dd862c7bc6da2e14ec3d00f671bd9c9043c6430..bf140ddd0daf2b16d71ad35098ff6b7f99d2be40 100644 (file)
@@ -81,13 +81,8 @@ main (int argc, char **argv)
     char *cp, *user, buf[BUFSIZ], tty[BUFSIZ];
     char **argp, **arguments, *vec[MAXARGS];
     struct utmpx *utp;
     char *cp, *user, buf[BUFSIZ], tty[BUFSIZ];
     char **argp, **arguments, *vec[MAXARGS];
     struct utmpx *utp;
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
 
 
-    /* read user profile/context */
-    context_read();
+    if (nmh_init(argv[0], 1)) { return 1; }
 
     mts_init (invo_name);
     arguments = getarguments (invo_name, argc, argv, 1);
 
     mts_init (invo_name);
     arguments = getarguments (invo_name, argc, argv, 1);
index 19e12661a1bd16cabd3611a250204abeec15fcb2..1dc2dff40c1c43b5900ce6e2c3a3f168d575064f 100644 (file)
@@ -68,13 +68,7 @@ main (int argc, char **argv)
     struct msgs_array msgs = { 0, 0, NULL };
     struct msgs *mp;
 
     struct msgs_array msgs = { 0, 0, NULL };
     struct msgs *mp;
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
-
-    /* read user profile/context */
-    context_read();
+    if (nmh_init(argv[0], 1)) { return 1; }
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
index 84374569b960aea72bcce6620e5aa0c2c39a6435..7b0ab4a03d55dff683ba1707d75bb3040173407d 100644 (file)
@@ -129,13 +129,7 @@ main (int argc, char **argv)
 
     int buildsw = 0;
 
 
     int buildsw = 0;
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
-
-    /* read user profile/context */
-    context_read();
+    if (nmh_init(argv[0], 1)) { return 1; }
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
index 9e922475c6df63ed8cec4fdb3a1ebb3f661bdc78..765ec9e19851e176413c9c3c05ccc2f7bc687f9e 100644 (file)
--- a/uip/rmf.c
+++ b/uip/rmf.c
@@ -37,13 +37,7 @@ main (int argc, char **argv)
     char *cp, *folder = NULL, newfolder[BUFSIZ];
     char buf[BUFSIZ], **argp, **arguments;
 
     char *cp, *folder = NULL, newfolder[BUFSIZ];
     char buf[BUFSIZ], **argp, **arguments;
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
-
-    /* read user profile/context */
-    context_read();
+    if (nmh_init(argv[0], 1)) { return 1; }
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
index ee602b45bc67c09bf1f51a0a261f1809b2e85701..8644a02fb363c8045c12f662a91d648becb89684 100644 (file)
--- a/uip/rmm.c
+++ b/uip/rmm.c
@@ -37,13 +37,7 @@ main (int argc, char **argv)
     struct msgs_array msgs = { 0, 0, NULL };
     struct msgs *mp;
 
     struct msgs_array msgs = { 0, 0, NULL };
     struct msgs *mp;
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
-
-    /* read user profile/context */
-    context_read();
+    if (nmh_init(argv[0], 1)) { return 1; }
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
index 1f487cdd9a77f1d97e441cc1784f06d07d9850e3..20668691409d0f0a2ac9decb9b84174e774a08c3 100644 (file)
@@ -52,13 +52,7 @@ main (int argc, char **argv)
     struct msgs *mp;
     FILE *in;
 
     struct msgs *mp;
     FILE *in;
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
-
-    /* read user profile/context */
-    context_read();
+    if (nmh_init(argv[0], 1)) { return 1; }
 
     mts_init (invo_name);
     arguments = getarguments (invo_name, argc, argv, 1);
 
     mts_init (invo_name);
     arguments = getarguments (invo_name, argc, argv, 1);
index 2fabe1c368c8855bbd015361198b1bbb4486aaf4..c8ad788bbb960a255051d7f052a5ebaa555bbd45 100644 (file)
@@ -120,13 +120,7 @@ main (int argc, char **argv)
     char *attach = NMH_ATTACH_HEADER;  /* header field name for attachments */
     int attachformat = 1; /* mhbuild format specifier for attachments */
 
     char *attach = NMH_ATTACH_HEADER;  /* header field name for attachments */
     int attachformat = 1; /* mhbuild format specifier for attachments */
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
-
-    /* read user profile/context */
-    context_read();
+    if (nmh_init(argv[0], 1)) { return 1; }
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
index 5a912f6bd1074057e2606a179af728825a5699d1..acd08afb1bc9cbe1e4ae7a1e5475b6a49ed2e25e 100644 (file)
@@ -61,13 +61,7 @@ main (int argc, char **argv)
     struct msgs_array msgs = { 0, 0, NULL };
     struct msgs_array vec = { 0, 0, NULL };
 
     struct msgs_array msgs = { 0, 0, NULL };
     struct msgs_array vec = { 0, 0, NULL };
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
-
-    /* read user profile/context */
-    context_read();
+    if (nmh_init(argv[0], 1)) { return 1; }
 
     if (!strcasecmp (invo_name, "next")) {
        mode = NEXT;
 
     if (!strcasecmp (invo_name, "next")) {
        mode = NEXT;
index 7ffbe57d8d85ef125a1660ae07dc3fe65120116b..6e22076a82817b25fd9f35a31f597c60984f1ff5 100644 (file)
@@ -188,14 +188,7 @@ main (int argc, char **argv)
     char mailbox[BUFSIZ], tmpfil[BUFSIZ];
     char **argp, **arguments;
 
     char mailbox[BUFSIZ], tmpfil[BUFSIZ];
     char **argp, **arguments;
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (*argv, '/');
-
-    /* foil search of user profile/context */
-    if (context_foil (NULL) == -1)
-       done (1);
+    if (nmh_init(argv[0], 0 /* use context_foil() */)) { return 1; }
 
     mts_init (invo_name);
     arguments = getarguments (invo_name, argc, argv, 0);
 
     mts_init (invo_name);
     arguments = getarguments (invo_name, argc, argv, 0);
index 72fe0659600f8927c777404cad0dee1ea3b56388..3df188592fcb86026b6f7a5c821d44fecd59483d 100644 (file)
@@ -78,13 +78,7 @@ main (int argc, char **argv)
     struct smsg **dlist;
     int checksw = 0;
 
     struct smsg **dlist;
     int checksw = 0;
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
-
-    /* read user profile/context */
-    context_read();
+    if (nmh_init(argv[0], 1)) { return 1; }
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
index 198413f293d2439672a4a842cb367741c3b00524..10adf5372f5ae3ef787f58146451bac07f83c4a3 100644 (file)
@@ -58,14 +58,7 @@ main (int argc, char **argv)
     char *cp, buf[BUFSIZ];
     char **argp, **arguments;
 
     char *cp, buf[BUFSIZ];
     char **argp, **arguments;
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
-
-    /* foil search of user profile/context */
-    if (context_foil (NULL) == -1)
-       done (1);
+    if (nmh_init(argv[0], 0 /* use context_foil() */)) { return 1; }
 
     arguments = getarguments (invo_name, argc, argv, 0);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 0);
     argp = arguments;
index be50bc92d603e60fbac1ab56c07d981e0ecdc32e..031ff3c8cac69a9c0c043dae2eda8eb34d4a9791 100644 (file)
@@ -13,8 +13,7 @@
 int
 main (int argc, char **argv)
 {
 int
 main (int argc, char **argv)
 {
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
+    if (nmh_init(argv[0], 1)) { return 1; }
+
     return WhatNow (argc, argv);
 }
     return WhatNow (argc, argv);
 }
index d41413898e3cc23fcab13e9f4bcfbd2878b5734b..3663f4782b2c00c4ff1045d6ea33e20e14502976 100644 (file)
@@ -130,11 +130,6 @@ WhatNow (int argc, char **argv)
     char       *l;                     /* set on -l to alist  command */
     int                n;                      /* set on -n to alist command */
 
     char       *l;                     /* set on -l to alist  command */
     int                n;                      /* set on -n to alist command */
 
-    invo_name = r1bindex (argv[0], '/');
-
-    /* read user profile/context */
-    context_read();
-
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
index eca3946d8b2f8f979c1dabc6c38083c6fea9a796..980cdda5bf38f9db797868b5bb2de6d1523b22b7 100644 (file)
@@ -63,13 +63,7 @@ main (int argc, char **argv)
     char *msg = NULL, **ap, **argp, backup[BUFSIZ];
     char buf[BUFSIZ], **arguments, *vec[MAXARGS];
 
     char *msg = NULL, **ap, **argp, backup[BUFSIZ];
     char buf[BUFSIZ], **arguments, *vec[MAXARGS];
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
-
-    /* read user profile/context */
-    context_read();
+    if (nmh_init(argv[0], 1)) { return 1; }
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;