From ba3bcbb86ea0177349bcd021559347248d6ab10a Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Mon, 30 Nov 2020 13:08:04 +0000 Subject: Stash temporary changes. Does not build; is not intended to. --- src/serverlib/s6rc_read_uint.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/serverlib/s6rc_read_uint.c (limited to 'src/serverlib/s6rc_read_uint.c') diff --git a/src/serverlib/s6rc_read_uint.c b/src/serverlib/s6rc_read_uint.c new file mode 100644 index 0000000..1f148ac --- /dev/null +++ b/src/serverlib/s6rc_read_uint.c @@ -0,0 +1,18 @@ +/* ISC license. */ + +#include +#include +#include +#include +#include +#include + +int s6rc_read_uint (char const *file, unsigned int *u) +{ + char buf[UINT_FMT + 1] ; + ssize_t r = openreadnclose(file, buf, UINT_FMT) ; + if (r < 0) return (errno == ENOENT) ? 0 : -1 ; + buf[byte_chr(buf, r, '\n')] = 0 ; + if (!uint0_scan(buf, u)) return (errno = EINVAL, -1) ; + return 1 ; +} -- cgit v1.3.1