chiark / gitweb /
implement proper binding on ports
[elogind.git] / util.h
diff --git a/util.h b/util.h
index 5d9ef39e04ad2e510e49b59742f713ebe8e412e8..67314146f3a7516dd6e38dbe52468a78fca3e243 100644 (file)
--- a/util.h
+++ b/util.h
@@ -7,6 +7,7 @@
 #include <time.h>
 #include <sys/time.h>
 #include <stdbool.h>
+#include <stdlib.h>
 
 typedef uint64_t usec_t;
 
@@ -41,9 +42,27 @@ static inline const char* strnull(const char *s) {
         return s ? s : "(null)";
 }
 
+static inline const char *strna(const char *s) {
+        return s ? s : "n/a";
+}
+
+static inline bool is_path_absolute(const char *p) {
+        return *p == '/';
+}
+
 bool endswith(const char *s, const char *postfix);
 bool startswith(const char *s, const char *prefix);
 
-int nointr_close(int fd);
+int close_nointr(int fd);
+
+int parse_boolean(const char *v);
+
+int safe_atou(const char *s, unsigned *ret_u);
+int safe_atoi(const char *s, int *ret_i);
+
+char *split_spaces(const char *c, size_t *l, char **state);
+
+#define FOREACH_WORD(word, length, s, state)    \
+        for ((state) = NULL, (word) = split_spaces((s), &(l), &(state)); (word); (word) = split_spaces((s), &(l), &(state)))
 
 #endif