chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
util: add split_spaces() call
[elogind.git]
/
util.h
diff --git
a/util.h
b/util.h
index 2df67b73df5af2934c5b6edcdf17e7772c43151f..9dfe631b8a5aa3b88c033f4fb394c52ddf781737 100644
(file)
--- a/
util.h
+++ b/
util.h
@@
-41,6
+41,14
@@
static inline const char* strnull(const char *s) {
return s ? s : "(null)";
}
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);
bool endswith(const char *s, const char *postfix);
bool startswith(const char *s, const char *prefix);
@@
-51,4
+59,9
@@
int parse_boolean(const char *v);
int safe_atou(const char *s, unsigned *ret_u);
int safe_atoi(const char *s, int *ret_i);
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
#endif