diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2018-03-21 11:29:24 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2018-03-21 11:29:24 +0000 |
commit | 66ce7fde43f8e8306aecda5f8e52d9aef88e7765 (patch) | |
tree | 08662cf0e069877287704912165e69b1a633e75f /src/libstddjb/sig_scan.c | |
parent | 72a273ad3faeb9888a87264d0dd24b9f217aa557 (diff) | |
download | skalibs-66ce7fde43f8e8306aecda5f8e52d9aef88e7765.tar.xz |
Add sig_scan, sig0_scan
Diffstat (limited to 'src/libstddjb/sig_scan.c')
-rw-r--r-- | src/libstddjb/sig_scan.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/libstddjb/sig_scan.c b/src/libstddjb/sig_scan.c new file mode 100644 index 0000000..f037d8c --- /dev/null +++ b/src/libstddjb/sig_scan.c @@ -0,0 +1,34 @@ +/* ISC license. */ + +#include <string.h> +#include <strings.h> +#include <skalibs/types.h> +#include <skalibs/sig.h> + +static size_t sig_scan_norec (char const *s, int *sig) +{ + int r = sig_number(s) ; + if (r) + { + *sig = r ; + return strlen(s) ; + } + { + unsigned int u ; + size_t len = uint_scan(s, &u) ; + if (len) *sig = u ; + return len ; + } +} + +size_t sig_scan (char const *s, int *sig) +{ + size_t len = sig_scan_norec(s, sig) ; + if (len) return len ; + if (!strncasecmp(s, "SIG", 3)) + { + len = sig_scan_norec(s+3, sig) ; + if (len) return 3+len ; + } + return 0 ; +} |