X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fbasic%2Fstring-util.h;h=1209e1e2e14c11853b526891d31b34584c36db68;hb=9facc64034a98d593cf5b577e979aa78e3b184bf;hp=ad0c813761ed9dc81dd9aa254b54421719cc0b20;hpb=07045a1a92c839fd2af80bd0c060a595021bc3b3;p=elogind.git diff --git a/src/basic/string-util.h b/src/basic/string-util.h index ad0c81376..1209e1e2e 100644 --- a/src/basic/string-util.h +++ b/src/basic/string-util.h @@ -37,6 +37,7 @@ #define UPPERCASE_LETTERS "ABCDEFGHIJKLMNOPQRSTUVWXYZ" #define LETTERS LOWERCASE_LETTERS UPPERCASE_LETTERS #define ALPHANUMERICAL LETTERS DIGITS +#define HEXDIGITS DIGITS "abcdefABCDEF" #define streq(a,b) (strcmp((a),(b)) == 0) #define strneq(a, b, n) (strncmp((a), (b), (n)) == 0) @@ -65,6 +66,10 @@ static inline bool isempty(const char *p) { return !p || !p[0]; } +static inline const char *empty_to_null(const char *p) { + return isempty(p) ? NULL : p; +} + static inline char *startswith(const char *s, const char *prefix) { size_t l;