aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsin <sin@2f30.org>2019-08-23 15:52:13 +0100
committersin <sin@2f30.org>2019-08-24 11:25:43 +0100
commit2b8e1ac48a355d0185665bd9f4b1c30d2747b1dd (patch)
tree8da72d4d397e92adcd6fe9ad215474d0b4d8dbc4
parent53c35e6b340b7c135038e00057a198f03cb7d7cf (diff)
downloadnoice-2b8e1ac48a355d0185665bd9f4b1c30d2747b1dd.tar.gz
Use arg.h in nopen(1)
-rw-r--r--Makefile2
-rw-r--r--nopen.c17
2 files changed, 13 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index bd202bd..ff636bc 100644
--- a/Makefile
+++ b/Makefile
@@ -19,7 +19,7 @@ nopen: $(NOPENOBJ)
dprintf.o: util.h
noice.o: arg.h noiceconf.h util.h
-nopen.o: nopenconf.h util.h
+nopen.o: arg.h nopenconf.h util.h
spawn.o: util.h
strlcat.o: util.h
strlcpy.o: util.h
diff --git a/nopen.c b/nopen.c
index 7e74416..d0581bc 100644
--- a/nopen.c
+++ b/nopen.c
@@ -8,6 +8,7 @@
#include <string.h>
#include <unistd.h>
+#include "arg.h"
#include "util.h"
struct assoc {
@@ -19,6 +20,8 @@ struct assoc {
#include "nopenconf.h"
+char *argv0;
+
void
run(struct assoc *assoc, char *arg)
{
@@ -67,7 +70,7 @@ initassocs(void)
}
void
-usage(char *argv0)
+usage(void)
{
fprintf(stderr, "usage: %s file...\n", argv0);
exit(1);
@@ -76,10 +79,14 @@ usage(char *argv0)
int
main(int argc, char *argv[])
{
- if (argc == 1)
- usage(argv[0]);
- argc--;
- argv++;
+ ARGBEGIN {
+ default:
+ usage();
+ } ARGEND
+
+ if (argc == 0)
+ usage();
+
initassocs();
for (; *argv != NULL; argv++) {
struct assoc *assoc;
Un proyecto texto-plano.xyz