From 12085f96264835de7fb2fb607e57edcef603346c Mon Sep 17 00:00:00 2001 From: Olivier Roques Date: Thu, 19 Nov 2020 09:36:59 +0000 Subject: [HICN-657] Remove common.h dependency in collectd plugins In Ubuntu 20.04, the file common.h is not shipped with collectd packages anymore. This patch removes that dependency from the collectd plugins. Change-Id: I234389ee9cbfd1f1820efdb34d532a7b11618206 Signed-off-by: Olivier Roques --- telemetry/vpp-collectd/vpp-hicn/vpp_hicn.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'telemetry/vpp-collectd/vpp-hicn/vpp_hicn.c') diff --git a/telemetry/vpp-collectd/vpp-hicn/vpp_hicn.c b/telemetry/vpp-collectd/vpp-hicn/vpp_hicn.c index 591b8f584..4228ac6e6 100644 --- a/telemetry/vpp-collectd/vpp-hicn/vpp_hicn.c +++ b/telemetry/vpp-collectd/vpp-hicn/vpp_hicn.c @@ -13,25 +13,9 @@ * limitations under the License. */ -#if !HAVE_CONFIG_H -#include -#include - -#ifndef __USE_ISOC99 /* required for NAN */ -#define DISABLE_ISOC99 1 -#define __USE_ISOC99 1 -#endif /* !defined(__USE_ISOC99) */ - -#if DISABLE_ISOC99 -#undef DISABLE_ISOC99 -#undef __USE_ISOC99 -#endif /* DISABLE_ISOC99 */ -#endif /* ! HAVE_CONFIG */ - /* Keep order as it is */ #include #include -#include #include #define counter_t vpp_counter_t @@ -42,6 +26,15 @@ DEFINE_VAPI_MSG_IDS_HICN_API_JSON vapi_ctx_t vapi_ctx; +#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)) + /************** OPTIONS ***********************************/ static const char *config_keys[2] = { "Verbose", @@ -188,6 +181,11 @@ static data_set_t dtx_ds = { /**********************************************************/ /********** UTILITY FUNCTIONS *****************************/ /**********************************************************/ +char *sstrncpy(char *dest, const char *src, size_t n) { + strncpy(dest, src, n); + dest[n - 1] = '\0'; + return dest; +} /* * Utility function used by the read callback to populate a -- cgit 1.2.3-korg