rpass

Strong password generator for humans
git clone git://git.sgregoratto.me/rpass
Log | Files | Refs | README

commit 8f142ada73e569dda4a99ff9946e3fcbee3d22ea
parent bc3fb18c4df3456512921af2cb369a4c73909daf
Author: Tim Kuijsten <info+git@netsend.nl>
Date:   Fri, 13 Dec 2019 18:27:42 +0100

add -V option to print the version

Diffstat:
MMakefile | 8+++++++-
Mrpass.1 | 3+++
Mrpass.c | 20++++++++++++++++++--
3 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile @@ -13,8 +13,14 @@ INSTALL_DIR= install -dm 755 INSTALL_BIN= install -m 555 INSTALL_MAN= install -m 444 +VERSION_MAJOR = 0 +VERSION_MINOR = 2 +VERSION_PATCH = 0 + rpass: rpass.c - ${CC} ${CFLAGS} rpass.c -o $@ -lm + ${CC} ${CFLAGS} -DVERSION_MAJOR=${VERSION_MAJOR} \ + -DVERSION_MINOR=${VERSION_MINOR} -DVERSION_PATCH=${VERSION_PATCH} \ + rpass.c -o $@ -lm rpass.1.html: rpass.1 mandoc -T html -O style=man.css rpass.1 > rpass.1.html diff --git a/rpass.1 b/rpass.1 @@ -20,6 +20,7 @@ .Nd strong password generator for humans .Sh SYNOPSIS .Nm +.Op Fl V .Op Ar bitlen .Sh DESCRIPTION .Nm @@ -29,6 +30,8 @@ The passwords are case-insensitive so that there is no alternation between keyboards when typing the password and blanks can be inserted at arbitrary places to enhance visual representation. .Bl -tag -width Ds +.It Fl V +Print the version of rpass. .It Ar bitlen Use a key space of the specified bit length, defaults to 40. .El diff --git a/rpass.c b/rpass.c @@ -20,6 +20,12 @@ #include <stdlib.h> #include <unistd.h> +#ifndef VERSION_MAJOR +#define VERSION_MAJOR 0 +#define VERSION_MINOR 0 +#define VERSION_PATCH 0 +#endif + /* * Dutch three letter "words" that are both visually and phonetically * unambiguous. @@ -31,10 +37,17 @@ static const char third[] = "fhjklmnprstxz"; /* drop b, c, d, g, q, v, w, static const char *progname; +void +printversion(int d) +{ + dprintf(d, "%s v%d.%d.%d\n", progname, VERSION_MAJOR, VERSION_MINOR, + VERSION_PATCH); +} + static void printusage(int d) { - dprintf(d, "usage: %s [bitlen]\n", progname); + dprintf(d, "usage: %s [-V] [bitlen]\n", progname); } int @@ -48,8 +61,11 @@ main(int argc, char **argv) exit(1); } - while ((c = getopt(argc, argv, "h")) != -1) + while ((c = getopt(argc, argv, "Vh")) != -1) switch (c) { + case 'V': + printversion(STDOUT_FILENO); + exit(0); case 'h': printusage(STDOUT_FILENO); exit(0);