X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fbasic%2Fparse-util.h;h=e9e270904e77ce2aa2d3d0ea6271842cc3785f6f;hb=d8f8fe03ac45bad693329c78dd71d4b1acc9df1b;hp=a0277def9d918c8bbb848b27a59cd5ff051b8ef8;hpb=2b5cdb47b5a4a367bc2be8fe4457423f785884f0;p=elogind.git diff --git a/src/basic/parse-util.h b/src/basic/parse-util.h index a0277def9..e9e270904 100644 --- a/src/basic/parse-util.h +++ b/src/basic/parse-util.h @@ -1,5 +1,3 @@ -/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ - #pragma once /*** @@ -37,7 +35,6 @@ int parse_mode(const char *s, mode_t *ret); int parse_ifindex(const char *s, int *ret); int parse_size(const char *t, uint64_t base, uint64_t *size); - #if 0 /// UNNEEDED by elogind int parse_range(const char *t, unsigned *lower, unsigned *upper); @@ -95,6 +92,21 @@ static inline int safe_atoli(const char *s, long int *ret_u) { } #endif +#if SIZE_MAX == UINT_MAX +static inline int safe_atozu(const char *s, size_t *ret_u) { + assert_cc(sizeof(size_t) == sizeof(unsigned)); + return safe_atou(s, (unsigned *) ret_u); +} +#else +static inline int safe_atozu(const char *s, size_t *ret_u) { + assert_cc(sizeof(size_t) == sizeof(long unsigned)); + return safe_atolu(s, ret_u); +} +#endif + int safe_atod(const char *s, double *ret_d); int parse_fractional_part_u(const char **s, size_t digits, unsigned *res); + +int parse_percent_unbounded(const char *p); +int parse_percent(const char *p);