X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fshared%2Futil.h;h=fd999bd9426f709b21a4568e8b2dd95c1c04cef7;hp=d9d525e8a51215eedcb815d5f6c8de924602faae;hb=5cb36f41f01cf4b1f4395abfffd1b33116591e58;hpb=ed88bcfb7c15029f9fc95ee2380759a9eb782d46 diff --git a/src/shared/util.h b/src/shared/util.h index d9d525e8a..fd999bd94 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -169,7 +169,7 @@ static inline const char *startswith_no_case(const char *s, const char *prefix) char *endswith(const char *s, const char *postfix) _pure_; -bool first_word(const char *s, const char *word) _pure_; +char *first_word(const char *s, const char *word) _pure_; int close_nointr(int fd); int safe_close(int fd); @@ -192,6 +192,8 @@ int safe_atolli(const char *s, long long int *ret_i); int safe_atod(const char *s, double *ret_d); +int safe_atou8(const char *s, uint8_t *ret); + #if __WORDSIZE == 32 static inline int safe_atolu(const char *s, unsigned long *ret_u) { assert_cc(sizeof(unsigned long) == sizeof(unsigned)); @@ -232,7 +234,7 @@ static inline int safe_atoi64(const char *s, int64_t *ret_i) { return safe_atolli(s, (long long int*) ret_i); } -char *split(const char *c, size_t *l, const char *separator, bool quoted, char **state); +const char* split(const char **state, size_t *l, const char *separator, bool quoted); #define FOREACH_WORD(word, length, s, state) \ _FOREACH_WORD(word, length, s, WHITESPACE, false, state) @@ -247,7 +249,7 @@ char *split(const char *c, size_t *l, const char *separator, bool quoted, char * _FOREACH_WORD(word, length, s, separator, true, state) #define _FOREACH_WORD(word, length, s, separator, quoted, state) \ - for ((state) = NULL, (word) = split((s), &(length), (separator), (quoted), &(state)); (word); (word) = split((s), &(length), (separator), (quoted), &(state))) + for ((state) = (s), (word) = split(&(state), &(length), (separator), (quoted)); (word); (word) = split(&(state), &(length), (separator), (quoted))) pid_t get_parent_of_pid(pid_t pid, pid_t *ppid); int get_starttime_of_pid(pid_t pid, unsigned long long *st);