X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/2b83f27e1980a6c5de752bd55c0ff76f53ec15f6..42db3a2c36e26e0106b1e480407e32d3c8c09bef:/uip/mkstemp.c diff --git a/uip/mkstemp.c b/uip/mkstemp.c index 7028d43a..b7fa5ae0 100644 --- a/uip/mkstemp.c +++ b/uip/mkstemp.c @@ -11,7 +11,7 @@ #endif /* ! NMH */ #ifdef HAVE_CONFIG_H -# include +# include "config.h" #endif /* HAVE_CONFIG_H */ #include #include @@ -34,7 +34,8 @@ static void process_args(int, char **, const char **, const char **, const char */ int -main(int argc, char *argv[]) { +main(int argc, char *argv[]) +{ const char *directory = "", *prefix = "", *suffix = ""; size_t suffix_len; int fd; @@ -67,7 +68,8 @@ main(int argc, char *argv[]) { static char * -build_template(const char *directory, const char *prefix, const char *suffix) { +build_template(const char *directory, const char *prefix, const char *suffix) +{ const char pattern[] = "XXXXXX"; size_t len, directory_len, pathsep_len, prefix_len, suffix_len; char *template; @@ -117,9 +119,15 @@ build_template(const char *directory, const char *prefix, const char *suffix) { #if NMH -#include +#include "h/mh.h" +#include "sbr/getarguments.h" +#include "sbr/smatch.h" +#include "sbr/ambigsw.h" +#include "sbr/print_version.h" +#include "sbr/print_help.h" +#include "sbr/error.h" #include "h/done.h" -#include +#include "h/utils.h" #if HAVE_MKSTEMPS # define MHFIXMSG_SWITCHES \ @@ -146,13 +154,14 @@ DEFINE_SWITCH_ARRAY(MHFIXMSG, switches); static void process_args(int argc, char **argv, const char **directory, - const char **prefix, const char **suffix) { + const char **prefix, const char **suffix) +{ char **argp, **arguments, *cp, buf[100]; # if ! HAVE_MKSTEMPS NMH_UNUSED(suffix); # endif /* ! HAVE_MKSTEMPS */ - if (nmh_init(argv[0], 2)) { done(1); } + if (nmh_init(argv[0], true, false)) { done(1); } arguments = getarguments (invo_name, argc, argv, 1); argp = arguments; @@ -181,7 +190,7 @@ process_args(int argc, char **argv, const char **directory, case DIRECTORYSW: /* Allow the directory to start with '-'. */ if ((cp = *argp++) == NULL) { - adios(NULL, "missing argument to %s", argp[-2]); + die("missing argument to %s", argp[-2]); } *directory = cp; continue; @@ -189,7 +198,7 @@ process_args(int argc, char **argv, const char **directory, case PREFIXSW: /* Allow the prefix to start with '-'. */ if ((cp = *argp++) == NULL) { - adios(NULL, "missing argument to %s", argp[-2]); + die("missing argument to %s", argp[-2]); } *prefix = cp; continue; @@ -198,7 +207,7 @@ process_args(int argc, char **argv, const char **directory, case SUFFIXSW: /* Allow the suffix to start with '-'. */ if ((cp = *argp++) == NULL) { - adios(NULL, "missing argument to %s", argp[-2]); + die("missing argument to %s", argp[-2]); } *suffix = cp; continue; @@ -210,7 +219,8 @@ process_args(int argc, char **argv, const char **directory, #else /* ! NMH */ static void process_args(int argc, char **argv, const char **directory, - const char **prefix, const char **suffix) { + const char **prefix, const char **suffix) +{ # if HAVE_MKSTEMPS const char usage[] = "usage: %s [-h] [-d directory] [-p prefix] [-s suffix]\n";