chiark / gitweb /
util: don't send SIGCONT following a SIGCONT or SIGKILL in kill_and_sigcont()
[elogind.git] / src / basic / parse-util.h
index 7dac7670d05a072f4bb4915b8fa7e8b675275eb9..1f420c050b9906ba137b440a986be3b405facb11 100644 (file)
@@ -1,5 +1,3 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
 #pragma once
 
 /***
@@ -22,6 +20,9 @@
 ***/
 
 #include <inttypes.h>
+#include <limits.h>
+#include <stddef.h>
+#include <stdint.h>
 #include <sys/types.h>
 
 #include "macro.h"
@@ -34,10 +35,12 @@ 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);
-// UNNEEDED int parse_range(const char *t, unsigned *lower, unsigned *upper);
+#if 0 /// UNNEEDED by elogind
+int parse_range(const char *t, unsigned *lower, unsigned *upper);
 
-// UNNEEDED #define FORMAT_BYTES_MAX 8
-// UNNEEDED char *format_bytes(char *buf, size_t l, uint64_t t);
+#define FORMAT_BYTES_MAX 8
+char *format_bytes(char *buf, size_t l, uint64_t t);
+#endif // 0
 
 int safe_atou(const char *s, unsigned *ret_u);
 int safe_atoi(const char *s, int *ret_i);
@@ -89,4 +92,20 @@ 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(const char *p);