diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2014-01-14 21:33:11 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2014-01-14 21:33:11 +0000 |
commit | bc9b06950f7646205f50f81f78be78d11bd9be64 (patch) | |
tree | 23e2b30a93bbc318eecd3d2ff93af8faa6102348 /usr.bin | |
parent | 094cd0c5921045409e9bdbb804bd8d630a6477de (diff) |
rearrange the bottom of main so it is less of a "zoo". ok deraadt
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/signify/signify.c | 57 |
1 files changed, 27 insertions, 30 deletions
diff --git a/usr.bin/signify/signify.c b/usr.bin/signify/signify.c index 5f3cb9248f4..a4e5bc2c9e9 100644 --- a/usr.bin/signify/signify.c +++ b/usr.bin/signify/signify.c @@ -1,4 +1,4 @@ -/* $OpenBSD: signify.c,v 1.35 2014/01/14 17:25:06 tedu Exp $ */ +/* $OpenBSD: signify.c,v 1.36 2014/01/14 21:33:10 tedu Exp $ */ /* * Copyright (c) 2013 Ted Unangst <tedu@openbsd.org> * @@ -519,42 +519,39 @@ main(int argc, char **argv) if (argc != 0) usage(NULL); - if (verb == NONE) - usage(NULL); + if (!sigfile && msgfile) { + if (strcmp(msgfile, "-") == 0) + errx(1, "must specify sigfile with - message"); + if (snprintf(sigfilebuf, sizeof(sigfilebuf), "%s.sig", + msgfile) >= sizeof(sigfilebuf)) + errx(1, "path too long"); + sigfile = sigfilebuf; + } + switch (verb) { #ifndef VERIFYONLY - if (verb == GENERATE) { + case GENERATE: if (!pubkeyfile || !seckeyfile) usage("need pubkey and seckey"); generate(pubkeyfile, seckeyfile, rounds, comment); - } else if (verb == INSPECT) { + break; + case INSPECT: inspect(seckeyfile, pubkeyfile, sigfile); - } else + break; + case SIGN: + if (!msgfile || !seckeyfile) + usage("need message and seckey"); + sign(seckeyfile, msgfile, sigfile, embedded); + break; #endif - { - if (!msgfile) - usage("need message"); - - if (!sigfile) { - if (strcmp(msgfile, "-") == 0) - errx(1, "must specify sigfile with - message"); - if (snprintf(sigfilebuf, sizeof(sigfilebuf), "%s.sig", - msgfile) >= sizeof(sigfilebuf)) - errx(1, "path too long"); - sigfile = sigfilebuf; - } -#ifndef VERIFYONLY - if (verb == SIGN) { - if (!seckeyfile) - usage("need seckey"); - sign(seckeyfile, msgfile, sigfile, embedded); - } else -#endif - if (verb == VERIFY) { - if (!pubkeyfile) - usage("need pubkey"); - verify(pubkeyfile, msgfile, sigfile, embedded); - } + case VERIFY: + if (!msgfile || !pubkeyfile) + usage("need message and pubkey"); + verify(pubkeyfile, msgfile, sigfile, embedded); + break; + default: + usage(NULL); + break; } return 0; |