From 66ce7fde43f8e8306aecda5f8e52d9aef88e7765 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Wed, 21 Mar 2018 11:29:24 +0000 Subject: Add sig_scan, sig0_scan --- NEWS | 3 ++- doc/upgrade.html | 3 ++- package/deps.mak | 3 +++ src/include/skalibs/sig.h | 3 +++ src/libstddjb/sig0_scan.c | 13 +++++++++++++ src/libstddjb/sig_scan.c | 34 ++++++++++++++++++++++++++++++++++ 6 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 src/libstddjb/sig0_scan.c create mode 100644 src/libstddjb/sig_scan.c diff --git a/NEWS b/NEWS index 7d12046..89bc01d 100644 --- a/NEWS +++ b/NEWS @@ -4,7 +4,8 @@ In 2.6.4.0 ---------- - Bugfixes. - - New functions: execvep_loose(), byte_zzero(), openb_read() + - New functions: execvep_loose(), byte_zzero(), openb_read(), +sig_scan(), sig0_scan() - New function family: skalibs/genqdyn.h diff --git a/doc/upgrade.html b/doc/upgrade.html index f14f557..6a24aa9 100644 --- a/doc/upgrade.html +++ b/doc/upgrade.html @@ -20,7 +20,8 @@ diff --git a/package/deps.mak b/package/deps.mak index 7c8e154..34081ff 100644 --- a/package/deps.mak +++ b/package/deps.mak @@ -124,6 +124,7 @@ src/libdatastruct/genqdyn_free.o src/libdatastruct/genqdyn_free.lo: src/libdatas src/libdatastruct/genqdyn_init.o src/libdatastruct/genqdyn_init.lo: src/libdatastruct/genqdyn_init.c src/include/skalibs/genqdyn.h src/include/skalibs/stralloc.h src/libdatastruct/genqdyn_pop.o src/libdatastruct/genqdyn_pop.lo: src/libdatastruct/genqdyn_pop.c src/libdatastruct/genqdyn-internal.h src/include/skalibs/genqdyn.h src/libdatastruct/genqdyn_push.o src/libdatastruct/genqdyn_push.lo: src/libdatastruct/genqdyn_push.c src/include/skalibs/genqdyn.h src/include/skalibs/stralloc.h +src/libdatastruct/genqdyn_unpush.o src/libdatastruct/genqdyn_unpush.lo: src/libdatastruct/genqdyn_unpush.c src/include/skalibs/genqdyn.h src/include/skalibs/stralloc.h src/libdatastruct/genqdyn_zero.o src/libdatastruct/genqdyn_zero.lo: src/libdatastruct/genqdyn_zero.c src/include/skalibs/genqdyn.h src/libdatastruct/genset.o src/libdatastruct/genset.lo: src/libdatastruct/genset.c src/include/skalibs/genset.h src/libdatastruct/genset_iter_nocancel.o src/libdatastruct/genset_iter_nocancel.lo: src/libdatastruct/genset_iter_nocancel.c src/include/skalibs/bitarray.h src/include/skalibs/genset.h @@ -479,6 +480,7 @@ src/libstddjb/selfpipe_trap.o src/libstddjb/selfpipe_trap.lo: src/libstddjb/self src/libstddjb/selfpipe_trapset.o src/libstddjb/selfpipe_trapset.lo: src/libstddjb/selfpipe_trapset.c src/include/skalibs/nonposix.h src/include/skalibs/nsig.h src/libstddjb/selfpipe-internal.h src/include/skalibs/selfpipe.h src/include/skalibs/sig.h src/include/skalibs/sysdeps.h src/libstddjb/selfpipe_untrap.o src/libstddjb/selfpipe_untrap.lo: src/libstddjb/selfpipe_untrap.c src/libstddjb/selfpipe-internal.h src/include/skalibs/selfpipe.h src/include/skalibs/sig.h src/include/skalibs/sysdeps.h src/libstddjb/sgetopt.o src/libstddjb/sgetopt.lo: src/libstddjb/sgetopt.c src/include/skalibs/buffer.h src/include/skalibs/sgetopt.h +src/libstddjb/sig0_scan.o src/libstddjb/sig0_scan.lo: src/libstddjb/sig0_scan.c src/include/skalibs/sig.h src/libstddjb/sig_block.o src/libstddjb/sig_block.lo: src/libstddjb/sig_block.c src/include/skalibs/sig.h src/libstddjb/sig_blocknone.o src/libstddjb/sig_blocknone.lo: src/libstddjb/sig_blocknone.c src/include/skalibs/sig.h src/libstddjb/sig_blockset.o src/libstddjb/sig_blockset.lo: src/libstddjb/sig_blockset.c src/include/skalibs/sig.h @@ -488,6 +490,7 @@ src/libstddjb/sig_number.o src/libstddjb/sig_number.lo: src/libstddjb/sig_number src/libstddjb/sig_pause.o src/libstddjb/sig_pause.lo: src/libstddjb/sig_pause.c src/include/skalibs/sig.h src/libstddjb/sig_push.o src/libstddjb/sig_push.lo: src/libstddjb/sig_push.c src/include/skalibs/sig.h src/libstddjb/sig_restoreto.o src/libstddjb/sig_restoreto.lo: src/libstddjb/sig_restoreto.c src/include/skalibs/sig.h +src/libstddjb/sig_scan.o src/libstddjb/sig_scan.lo: src/libstddjb/sig_scan.c src/include/skalibs/sig.h src/include/skalibs/types.h src/libstddjb/sig_shield.o src/libstddjb/sig_shield.lo: src/libstddjb/sig_shield.c src/include/skalibs/sig.h src/libstddjb/sig_stack.o src/libstddjb/sig_stack.lo: src/libstddjb/sig_stack.c src/include/skalibs/nonposix.h src/include/skalibs/nsig.h src/include/skalibs/sig.h src/libstddjb/sig_table.o src/libstddjb/sig_table.lo: src/libstddjb/sig_table.c src/libstddjb/sig-internal.h diff --git a/src/include/skalibs/sig.h b/src/include/skalibs/sig.h index fa46b00..236257b 100644 --- a/src/include/skalibs/sig.h +++ b/src/include/skalibs/sig.h @@ -3,6 +3,7 @@ #ifndef SIG_H #define SIG_H +#include #include #include @@ -45,5 +46,7 @@ extern void sig_unshield (void) ; extern char const *sig_name (int) ; extern int sig_number (char const *) ; +extern size_t sig_scan (char const *, int *) ; +extern size_t sig0_scan (char const *, int *) ; #endif diff --git a/src/libstddjb/sig0_scan.c b/src/libstddjb/sig0_scan.c new file mode 100644 index 0000000..7714bfc --- /dev/null +++ b/src/libstddjb/sig0_scan.c @@ -0,0 +1,13 @@ +/* ISC license. */ + +#include +#include + +size_t sig0_scan (char const *s, int *sig) +{ + int t ; + size_t len = sig_scan(s, &t) ; + if (!len || s[len]) return 0 ; + *sig = t ; + return len ; +} 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 +#include +#include +#include + +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 ; +} -- cgit v1.2.3