diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2024-04-16 12:57:52 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska@appnovation.com> | 2024-04-16 12:57:52 +0000 |
| commit | 825b80eaa311b0aec4c00614f38f3eb63949d5a7 (patch) | |
| tree | 624f702487d9acdd3cc85060cfe2edc388cf7096 /src/libstddjb/gol_argv.c | |
| parent | bfc53cfde4fdda343647678fcd21b38a44f2de08 (diff) | |
| download | skalibs-825b80eaa311b0aec4c00614f38f3eb63949d5a7.tar.gz | |
Tentative support for old MacOS with no O_CLOEXEC
Also add a prototype for gol, not finished yet.
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/libstddjb/gol_argv.c')
| -rw-r--r-- | src/libstddjb/gol_argv.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/libstddjb/gol_argv.c b/src/libstddjb/gol_argv.c new file mode 100644 index 0000000..2538f5a --- /dev/null +++ b/src/libstddjb/gol_argv.c @@ -0,0 +1,26 @@ +/* ISC license. */ + +#include <string.h> + +#include <skalibs/gol.h> +#include <skalibs/strerr.h> + +unsigned int gol_argv (int argc, char const *const *argv, gol_bool const *b, unsigned int bn, gol_arg const *a, unsigned int an, uint64_t *br, char const **ar) +{ + int problem = 0 ; + int r ; + if (!argc) strerr_diefu1x(100, "gol: invalid argv") ; + if (argc == 1) return 1 ; + r = gol(argv + 1, argc - 1, b, bn, a, an, br, ar, &problem) ; + + if (r < 0) + { + if (problem >= 0) + { + char s[2] = { argv[-r][problem], 0 } ; + strerr_dief4x(100, "unrecognized ", "short", "option: ", s) ; + } + else strerr_dief3x(100, "unrecognized ", "option: ", argv[-r]) ; + } + else return r + 1 ; +} |
