From: Florian Forster Date: Sun, 18 Jan 2009 20:07:36 +0000 (+0100) Subject: src/common.h: Add the IS_TRUE and IS_FALSE macros. X-Git-Tag: collectd-4.6.0~101 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=298e7bff0718eb01c51d671140191e2b99869779;p=collectd.git src/common.h: Add the IS_TRUE and IS_FALSE macros. They should be used to check if a string is "true|yes|on" or "false|no|off" from now on. --- diff --git a/src/common.h b/src/common.h index aefc2cc6..d372872a 100644 --- a/src/common.h +++ b/src/common.h @@ -40,6 +40,13 @@ #define STATIC_ARRAY_SIZE(a) (sizeof (a) / sizeof (*(a))) +#define IS_TRUE(s) ((strcasecmp ("true", (s)) == 0) \ + || (strcasecmp ("yes", (s)) == 0) \ + || (strcasecmp ("on", (s)) == 0)) +#define IS_FALSE(s) ((strcasecmp ("false", (s)) == 0) \ + || (strcasecmp ("no", (s)) == 0) \ + || (strcasecmp ("off", (s)) == 0)) + char *sstrncpy (char *dest, const char *src, size_t n); int ssnprintf (char *dest, size_t n, const char *format, ...); char *sstrdup(const char *s);