author | Olivier Brunel
<jjk@jjacky.com> 2023-04-22 12:10:04 UTC |
committer | Olivier Brunel
<jjk@jjacky.com> 2023-04-25 15:02:08 UTC |
parent | cc4f05b728af67e046bef1089bf97deb60cd6e74 |
src/ssp/add.c | +8 | -8 |
src/ssp/edit.c | +10 | -10 |
src/ssp/list.c | +2 | -2 |
src/ssp/show.c | +1 | -1 |
src/ssp/ssp.c | +4 | -4 |
diff --git a/src/ssp/add.c b/src/ssp/add.c index c69fa08..eae60eb 100644 --- a/src/ssp/add.c +++ b/src/ssp/add.c @@ -74,7 +74,7 @@ parse_cmdline(int argc, const char *argv[], const char usage[], struct add *add) while ((c = parseopt(argc, argv, options, 0, &po))) switch (c) { case 'a': { - if (!strcmp(po.arg, "list")) { + if (!strcmp(PO_ARG(&po), "list")) { out("Available algorithms:"); for (r = 0; algos[r]; ++r) out("- ", algos[r]); @@ -82,11 +82,11 @@ parse_cmdline(int argc, const char *argv[], const char usage[], struct add *add) } int first = -1; - r = validate_algo(&first, po.arg, strlen(po.arg)); + r = validate_algo(&first, PO_ARG(&po), strlen(PO_ARG(&po))); if (r < 0) { if (first > -1) list_matches(out_putmsg, OLVL_NORMAL, "did you mean ", - NULL, " or ", " ?", po.arg, strlen(po.arg), + NULL, " or ", " ?", PO_ARG(&po), strlen(PO_ARG(&po)), first, algos); diecmdusage(EX_USAGE, usage, &command_add); } @@ -94,20 +94,20 @@ parse_cmdline(int argc, const char *argv[], const char usage[], struct add *add) } break; case 'c': - add->comments = po.arg; + add->comments = PO_ARG(&po); break; case 'd': - r = validate_digits(po.arg, strlen(po.arg)); + r = validate_digits(PO_ARG(&po), strlen(PO_ARG(&po))); if (r < 0) diecmdusage(EX_USAGE, usage, &command_add); add->otp.type = TYPE_COUNTER; add->otp.digits = r; break; case 't': - if (!po.arg) { + if (!PO_ARG(&po)) { add->otp.precision = 30; } else { - r = validate_precision(po.arg, strlen(po.arg)); + r = validate_precision(PO_ARG(&po), strlen(PO_ARG(&po))); if (r < 0) diecmdusage(EX_USAGE, usage, &command_add); add->otp.precision = r; @@ -120,7 +120,7 @@ parse_cmdline(int argc, const char *argv[], const char usage[], struct add *add) die(EX_SOFTWARE, "unexpected return value ", PUTMSG_INT(c), " from parseopt"); }; - return po.cur; + return PO_CUR(&po); } int diff --git a/src/ssp/edit.c b/src/ssp/edit.c index d368ab0..61965ca 100644 --- a/src/ssp/edit.c +++ b/src/ssp/edit.c @@ -46,7 +46,7 @@ parse_cmdline(int argc, const char *argv[], const char usage[], struct edit *edi while ((c = parseopt(argc, argv, options, 0, &po))) switch (c) { case 'a': { - if (!strcmp(po.arg, "list")) { + if (!strcmp(PO_ARG(&po), "list")) { out("Available algorithms:"); for (r = 0; algos[r]; ++r) out("- ", algos[r]); @@ -54,11 +54,11 @@ parse_cmdline(int argc, const char *argv[], const char usage[], struct edit *edi } int first = -1; - r = validate_algo(&first, po.arg, strlen(po.arg)); + r = validate_algo(&first, PO_ARG(&po), strlen(PO_ARG(&po))); if (r < 0) { if (first > -1) list_matches(out_putmsg, OLVL_NORMAL, "did you mean ", - NULL, " or ", " ?", po.arg, strlen(po.arg), + NULL, " or ", " ?", PO_ARG(&po), strlen(PO_ARG(&po)), first, algos); diecmdusage(EX_USAGE, usage, &command_edit); } @@ -66,13 +66,13 @@ parse_cmdline(int argc, const char *argv[], const char usage[], struct edit *edi } break; case 'c': - edit->comments = po.arg; + edit->comments = PO_ARG(&po); break; case 'd': - if (!po.arg) { + if (!PO_ARG(&po)) { edit->otp.digits = 6; } else { - r = validate_digits(po.arg, strlen(po.arg)); + r = validate_digits(PO_ARG(&po), strlen(PO_ARG(&po))); if (r < 0) diecmdusage(EX_USAGE, usage, &command_edit); edit->otp.digits = r; @@ -80,13 +80,13 @@ parse_cmdline(int argc, const char *argv[], const char usage[], struct edit *edi edit->otp.type = TYPE_COUNTER; break; case 's': - edit->secret = po.arg; + edit->secret = PO_ARG(&po); break; case 't': - if (!po.arg) { + if (!PO_ARG(&po)) { edit->otp.precision = 30; } else { - r = validate_precision(po.arg, strlen(po.arg)); + r = validate_precision(PO_ARG(&po), strlen(PO_ARG(&po))); if (r < 0) diecmdusage(EX_USAGE, usage, &command_edit); edit->otp.precision = r; @@ -99,7 +99,7 @@ parse_cmdline(int argc, const char *argv[], const char usage[], struct edit *edi die(EX_SOFTWARE, "unexpected return value ", PUTMSG_INT(c), " from parseopt"); }; - return po.cur; + return PO_CUR(&po); } int diff --git a/src/ssp/list.c b/src/ssp/list.c index f320d38..9b54909 100644 --- a/src/ssp/list.c +++ b/src/ssp/list.c @@ -59,7 +59,7 @@ parse_cmdline(int argc, const char *argv[], const char usage[], struct list *ctx ctx->options |= OPT_DETAILS | OPT_SECRET; break; case 's': - ctx->sep = po.arg; + ctx->sep = PO_ARG(&po); break; case -1: diecmdusage(EX_USAGE, usage, &command_list); @@ -67,7 +67,7 @@ parse_cmdline(int argc, const char *argv[], const char usage[], struct list *ctx die(EX_SOFTWARE, "unexpected return value ", PUTMSG_INT(c), " from parseopt"); }; - return po.cur; + return PO_CUR(&po); } int diff --git a/src/ssp/show.c b/src/ssp/show.c index cfd2a21..a1a363b 100644 --- a/src/ssp/show.c +++ b/src/ssp/show.c @@ -55,7 +55,7 @@ parse_cmdline(int argc, const char *argv[], const char usage[], struct show *ctx die(EX_SOFTWARE, "unexpected return value ", PUTMSG_INT(c), " from parseopt"); }; - return po.cur; + return PO_CUR(&po); } void diff --git a/src/ssp/ssp.c b/src/ssp/ssp.c index eba3fff..6d456c4 100644 --- a/src/ssp/ssp.c +++ b/src/ssp/ssp.c @@ -94,7 +94,7 @@ parse_cmdline(int *argc, const char **argv[], struct ssp *ctx) int c; while ((c = parseopt(*argc, *argv, options, 0, &po))) switch (c) { case 'D': - ctx->db = po.arg; + ctx->db = PO_ARG(&po); break; case 'h': ctx->options |= OPT_HELP; @@ -108,7 +108,7 @@ parse_cmdline(int *argc, const char **argv[], struct ssp *ctx) }; /* no command specified */ - if (po.cur == *argc) + if (PO_CUR(&po) == *argc) dienocommand(EX_USAGE, usage, (ctx->options & OPT_HELP) ? " -D, --database FILE Use FILE as database\n" "\n" @@ -116,8 +116,8 @@ parse_cmdline(int *argc, const char **argv[], struct ssp *ctx) " --version Show version information and exit\n" : NULL); - *argc -= po.cur; - *argv += po.cur; + *argc -= PO_CUR(&po); + *argv += PO_CUR(&po); return getcommandordie(EX_USAGE, usage, **argv); }