From 840ef082514bbf3f0897b5172b7d30af1bb279a9 Mon Sep 17 00:00:00 2001 From: Michael Santos Date: Fri, 9 Sep 2022 08:25:02 -0400 Subject: [PATCH] 0.14.4: standardize exit status * 2: usage errors * 0: usage (-h) --- src/xmppipe.c | 15 ++++++++++----- src/xmppipe.h | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/xmppipe.c b/src/xmppipe.c index f8adfd5..e6bb196 100644 --- a/src/xmppipe.c +++ b/src/xmppipe.c @@ -150,8 +150,10 @@ int main(int argc, char **argv) { state->format = XMPPIPE_FMT_TEXT; else if (strcmp(optarg, "csv") == 0) state->format = XMPPIPE_FMT_CSV; - else + else { usage(state); + exit(2); + } break; case 'x': @@ -214,6 +216,7 @@ int main(int argc, char **argv) { case 'h': default: usage(state); + exit(0); } } @@ -225,11 +228,15 @@ int main(int argc, char **argv) { state->room = xmppipe_strdup(argv[0]); } - if (jid == NULL) + if (jid == NULL) { usage(state); + exit(2); + } - if (state->encode && BASE64_LENGTH(state->bufsz) + 1 > 0xffff) + if (state->encode && BASE64_LENGTH(state->bufsz) + 1 > 0xffff) { usage(state); + exit(2); + } state->server = xmppipe_servername(jid); @@ -595,6 +602,4 @@ static void usage(xmppipe_state_t *state) { " --no-tls-verify disable TLS certificate " "verification\n", __progname); - - exit(EXIT_FAILURE); } diff --git a/src/xmppipe.h b/src/xmppipe.h index d4460f0..bb0678a 100644 --- a/src/xmppipe.h +++ b/src/xmppipe.h @@ -27,7 +27,7 @@ #include "strtonum.h" #endif -#define XMPPIPE_VERSION "0.14.3" +#define XMPPIPE_VERSION "0.14.4" #define XMPPIPE_RESOURCE "xmppipe" #define XMPPIPE_STREQ(a, b) (strcmp((a), (b)) == 0)