From 4fb4eaecb937e3eddd8804c85ce20c80cc753480 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Tue, 25 Aug 2015 23:14:00 +0000 Subject: Some refactor + add servicedir copy functions in libs6rc --- src/libs6rc/s6rc_read_uint.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/libs6rc/s6rc_read_uint.c (limited to 'src/libs6rc/s6rc_read_uint.c') diff --git a/src/libs6rc/s6rc_read_uint.c b/src/libs6rc/s6rc_read_uint.c new file mode 100644 index 0000000..6953190 --- /dev/null +++ b/src/libs6rc/s6rc_read_uint.c @@ -0,0 +1,16 @@ +/* ISC license. */ + +#include +#include +#include +#include + +int s6rc_read_uint (char const *file, unsigned int *u) +{ + char buf[UINT_FMT + 1] ; + register int 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