X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Futil.h;h=81831e277154996b76be4e11dbf1edb5f8748963;hb=01f83c1c765db13e20a241a48733333360457718;hp=11d28665b6ba5144d5b81fae22124ace9e1ceda5;hpb=9d9951a460a90ef0e1e0384742cefdcf85193f8c;p=elogind.git diff --git a/src/shared/util.h b/src/shared/util.h index 11d28665b..81831e277 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -531,7 +531,11 @@ char *strjoin(const char *x, ...) _sentinel_; bool is_main_thread(void); -bool in_charset(const char *s, const char* charset) _pure_; +static inline bool _pure_ in_charset(const char *s, const char* charset) { + assert(s); + assert(charset); + return s[strspn(s, charset)] == '\0'; +} int block_get_whole_disk(dev_t d, dev_t *ret); @@ -813,6 +817,19 @@ int unlink_noerrno(const char *path); _c_; \ }) +#define strappenda3(a, b, c) \ + ({ \ + const char *_a_ = (a), *_b_ = (b), *_c_ = (c); \ + char *_d_; \ + size_t _x_, _y_, _z_; \ + _x_ = strlen(_a_); \ + _y_ = strlen(_b_); \ + _z_ = strlen(_c_); \ + _d_ = alloca(_x_ + _y_ + _z_ + 1); \ + strcpy(stpcpy(stpcpy(_d_, _a_), _b_), _c_); \ + _d_; \ + }) + #define procfs_file_alloca(pid, field) \ ({ \ pid_t _pid_ = (pid); \