commit - 699d07dde281064877fe7ac92c64d7e191fefe8b
commit + 7ab29a2b12d05fd8c0b29f35be4048a2ae215d53
blob - abe49be3e04acd217cf177e886d17518c3755a63
blob + 4298884bfe9b15ed76eb202a3d82f1c0aa0d843f
--- config.mk
+++ config.mk
#MANPREFIX = $(PREFIX)/share/man
LIBS = -lm -lsodium
-# OpenBSD
+# BSD
#INCS = -I/usr/local/include
#LIBS = -L/usr/local/lib -lm -lsodium
CFLAGS = -std=c99 -Wall -pedantic $(INCS) -O2
LDFLAGS = $(LIBS)
-# Libbsd
-#CFLAGS = -std=c99 -Wall -pedantic -O2 -DLIBBSD_OVERLAY -isystem /usr/include/bsd $(INCS)
-#LDFLAGS = -lbsd $(LIBS)
-
# Debug
#CFLAGS = -std=c99 -Wall -pedantic $(INCS) -Wextra -O0 -g
-# Libbsd+debug
-#CFLAGS = -std=c99 -Wall -pedantic -DLIBBSD_OVERLAY -isystem /usr/include/bsd $(INCS) -Wextra -O0 -g
blob - e6b7c8cce70607c58a34b7ee80822da2ce4858e0
blob + d6eaa6c8f4de5096e2a704a9e135f40610c9ee95
--- gpass.c
+++ gpass.c
+#include <errno.h>
#include <limits.h>
#include <math.h>
#include <stdarg.h>
-#include <stdlib.h>
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <strings.h>
#include <unistd.h>
-#include <err.h>
-
#include <sodium.h>
#define MAXWORDS 128
int plen = 70;
uint32_t nlines = 0;
+void
+errx(int eval, const char *fmt, ...)
+{
+ fputs("gpass: ", stderr);
+ if (fmt != NULL) {
+ va_list argp;
+ va_start(argp, fmt);
+ vfprintf(stderr, fmt, argp);
+ va_end(argp);
+ }
+ fputc('\n', stderr);
+ exit(eval);
+}
+
+void
+err(int eval, const char *fmt, ...)
+{
+ char *e = strerror(errno);
+ fputs("gpass: ", stderr);
+ if (fmt != NULL) {
+ va_list argp;
+ va_start(argp, fmt);
+ vfprintf(stderr, fmt, argp);
+ va_end(argp);
+ }
+ fputs(": ", stderr);
+ fputs(e, stderr);
+ fputc('\n', stderr);
+ exit(eval);
+}
+
int
usage(void)
{
- fprintf(stderr, "%s [-d dict] [-e bits] [-n count]\n", getprogname());
+ fprintf(stderr, "usage: gpass [-d dict] [-e bits] [-n count]\n");
exit(EXIT_FAILURE);
}