From f6fba0ac6b301b15573d1f1f8b9522b5c27b051b Mon Sep 17 00:00:00 2001 From: Nick Chambers Date: Sun, 19 Jun 2022 04:02:11 -0500 Subject: [PATCH] Skip argv 0 by default --- include/gargoyle.h | 4 +++- src/gargoyle.c | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/gargoyle.h b/include/gargoyle.h index 1feef88..85024be 100644 --- a/include/gargoyle.h +++ b/include/gargoyle.h @@ -5,6 +5,8 @@ #include #include -uint8_t gargoyle_digest_args(uint16_t optc, struct gargoyle_opt *optv, int *argc, char ***argv); +const uint8_t GARGOYLE_DIGEST_ALL = 1 << 0; + +uint8_t gargoyle_digest_args(uint16_t optc, struct gargoyle_opt *optv, int *argc, char ***argv, uint8_t flags); #endif diff --git a/src/gargoyle.c b/src/gargoyle.c index 9555a9a..5609abd 100644 --- a/src/gargoyle.c +++ b/src/gargoyle.c @@ -1,7 +1,12 @@ #include #include -uint8_t gargoyle_digest_args(uint16_t optc, struct gargoyle_opt *optv, int *argc, char ***argv) { +uint8_t gargoyle_digest_args(uint16_t optc, struct gargoyle_opt *optv, int *argc, char ***argv, uint8_t flags) { + if(!(flags & GARGOYLE_DIGEST_ALL)) { + *argc -= 1; + *argv += 1; + } + while(1) { const char *arg = **argv;