]> diplodocus.org Git - nmh/blobdiff - uip/mkstemp.c
fdcompare.c: Move interface to own file.
[nmh] / uip / mkstemp.c
index 7dc806562a11ea23415157c021c28503947cbaa4..5cc06f223bbf66a214bbd32cab73fd32140c169f 100644 (file)
@@ -11,7 +11,7 @@
 #endif /* ! NMH */
 
 #ifdef HAVE_CONFIG_H
 #endif /* ! NMH */
 
 #ifdef HAVE_CONFIG_H
-#   include <config.h>
+#   include "config.h"
 #endif /* HAVE_CONFIG_H */
 #include <unistd.h>
 #include <stdlib.h>
 #endif /* HAVE_CONFIG_H */
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
 
 #include <string.h>
 #include <stdio.h>
 
-#include <h/utils.h>
-
 #if ! defined HAVE_MKSTEMPS
 #   define HAVE_MKSTEMPS 0
 #endif /* ! HAVE_MKSTEMPS */
 
 #if ! defined HAVE_MKSTEMPS
 #   define HAVE_MKSTEMPS 0
 #endif /* ! HAVE_MKSTEMPS */
 
-char *build_template(const char *, const char *, const char *);
-void process_args(int, char **, const char **, const char **, const char **);
+static char *build_template(const char *, const char *, const char *);
+static void process_args(int, char **, const char **, const char **, const char **);
 
 /*
  * Use a template of the form:
 
 /*
  * Use a template of the form:
@@ -36,7 +34,8 @@ void process_args(int, char **, const char **, const char **, const char **);
  */
 
 int
  */
 
 int
-main(int argc, char *argv[]) {
+main(int argc, char *argv[])
+{
     const char *directory = "", *prefix = "", *suffix = "";
     size_t suffix_len;
     int fd;
     const char *directory = "", *prefix = "", *suffix = "";
     size_t suffix_len;
     int fd;
@@ -68,8 +67,9 @@ main(int argc, char *argv[]) {
 }
 
 
 }
 
 
-char *
-build_template(const char *directory, const char *prefix, const char *suffix) {
+static char *
+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;
     const char pattern[] = "XXXXXX";
     size_t len, directory_len, pathsep_len, prefix_len, suffix_len;
     char *template;
@@ -119,7 +119,13 @@ build_template(const char *directory, const char *prefix, const char *suffix) {
 
 
 #if NMH
 
 
 #if NMH
-#include <h/mh.h>
+#include "h/mh.h"
+#include "sbr/ambigsw.h"
+#include "sbr/print_version.h"
+#include "sbr/print_help.h"
+#include "sbr/error.h"
+#include "h/done.h"
+#include "h/utils.h"
 
 #if HAVE_MKSTEMPS
 #   define MHFIXMSG_SWITCHES \
 
 #if HAVE_MKSTEMPS
 #   define MHFIXMSG_SWITCHES \
@@ -144,15 +150,16 @@ DEFINE_SWITCH_ENUM(MHFIXMSG);
 DEFINE_SWITCH_ARRAY(MHFIXMSG, switches);
 #undef X
 
 DEFINE_SWITCH_ARRAY(MHFIXMSG, switches);
 #undef X
 
-void
+static void
 process_args(int argc, char **argv, const char **directory,
 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 */
 
     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;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
@@ -181,7 +188,7 @@ process_args(int argc, char **argv, const char **directory,
             case DIRECTORYSW:
                 /* Allow the directory to start with '-'. */
                 if ((cp = *argp++) == NULL) {
             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;
                 }
                 *directory = cp;
                 continue;
@@ -189,7 +196,7 @@ process_args(int argc, char **argv, const char **directory,
             case PREFIXSW:
                 /* Allow the prefix to start with '-'. */
                 if ((cp = *argp++) == NULL) {
             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;
                 }
                 *prefix = cp;
                 continue;
@@ -198,7 +205,7 @@ process_args(int argc, char **argv, const char **directory,
             case SUFFIXSW:
                 /* Allow the suffix to start with '-'. */
                 if ((cp = *argp++) == NULL) {
             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;
                 }
                 *suffix = cp;
                 continue;
@@ -208,9 +215,10 @@ process_args(int argc, char **argv, const char **directory,
     }
 }
 #else  /* ! NMH */
     }
 }
 #else  /* ! NMH */
-void
+static void
 process_args(int argc, char **argv, const char **directory,
 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";
 #   if HAVE_MKSTEMPS
     const char usage[] =
         "usage: %s [-h] [-d directory] [-p prefix] [-s suffix]\n";