#endif /* HAVE_CONFIG_H */
#include <unistd.h>
#include <stdlib.h>
+#include <stdbool.h>
#include <string.h>
#include <stdio.h>
# 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:
process_args(argc, argv, &directory, &prefix, &suffix);
if ((template = build_template(directory, prefix, suffix)) == NULL) {
- return -1;
+ return 1;
}
if ((suffix_len = strlen(suffix)) > 0) {
free(template);
- return fd >= 0 ? 0 : -1;
+ return fd >= 0 ? 0 : 1;
}
-char *
+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;
#if NMH
#include <h/mh.h>
+#include <h/utils.h>
#if HAVE_MKSTEMPS
# define MHFIXMSG_SWITCHES \
DEFINE_SWITCH_ARRAY(MHFIXMSG, switches);
#undef X
-void
+static void
process_args(int argc, char **argv, const char **directory,
const char **prefix, const char **suffix) {
char **argp, **arguments, *cp, buf[100];
NMH_UNUSED(suffix);
# endif /* ! HAVE_MKSTEMPS */
- if (nmh_init(argv[0], 2)) { done(NOTOK); }
+ if (nmh_init(argv[0], 2)) { done(1); }
arguments = getarguments (invo_name, argc, argv, 1);
argp = arguments;
switch (smatch(++cp, switches)) {
case AMBIGSW:
ambigsw(cp, switches);
- done(NOTOK);
+ done(1);
case UNKWNSW:
inform("-%s unknown", cp);
(void) snprintf(buf, sizeof buf, "%s [switches]", invo_name);
print_help(buf, switches, 1);
- done(NOTOK);
+ done(1);
case HELPSW:
(void) snprintf(buf, sizeof buf, "%s [switches]", invo_name);
print_help(buf, switches, 1);
}
}
#else /* ! NMH */
-void
+static void
process_args(int argc, char **argv, const char **directory,
const char **prefix, const char **suffix) {
# if HAVE_MKSTEMPS
exit(0);
default:
(void) fprintf(stderr, usage, argv[0]);
- exit(-1);
+ exit(1);
}
}
}