X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/64cc8937ff11ffd37736f27ceed5f4ff93161ca7..e0c39ed52fa9c99b4591b5170354d8398ffd787b:/sbr/utils.c?ds=sidebyside diff --git a/sbr/utils.c b/sbr/utils.c index 81620567..d8b060fb 100644 --- a/sbr/utils.c +++ b/sbr/utils.c @@ -9,9 +9,14 @@ #include #include -#include #include -#include + +/* 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) @@ -319,3 +324,31 @@ nmh_strcasestr (const char *s1, const char *s2) { return NULL; } + + +int +nmh_init(const char *argv0, int read_context) { + setlocale(LC_ALL, ""); + + 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; + } +}