From 95a53933a4de0cc3891effcba4949045f4a38fd5 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Wed, 24 Feb 2010 16:53:06 +0100 Subject: [PATCH] src/rrd_format.c: Implemented "cf_to_string". A simple helper function to turn an "enum cf_en" to a string. The returned pointer points to static memory and doesn't need to be freed. --- src/rrd_format.c | 20 ++++++++++++++++++++ src/rrd_tool.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/src/rrd_format.c b/src/rrd_format.c index b533110..9792e74 100644 --- a/src/rrd_format.c +++ b/src/rrd_format.c @@ -84,6 +84,26 @@ enum cf_en cf_conv( return (enum cf_en)(-1); } +const char *cf_to_string (enum cf_en cf) +{ + switch (cf) + { + case CF_AVERAGE: return "AVERAGE"; + case CF_MINIMUM: return "MIN"; + case CF_MAXIMUM: return "MAX"; + case CF_LAST: return "LAST"; + case CF_HWPREDICT: return "HWPREDICT"; + case CF_SEASONAL: return "SEASONAL"; + case CF_DEVPREDICT: return "DEVPREDICT"; + case CF_DEVSEASONAL: return "DEVSEASONAL"; + case CF_FAILURES: return "FAILURES"; + case CF_MHWPREDICT: return "MHWPREDICT"; + + default: + return NULL; + } +} /* char *cf_to_string */ + #undef converter long ds_match( diff --git a/src/rrd_tool.h b/src/rrd_tool.h index ef32758..bd4855a 100644 --- a/src/rrd_tool.h +++ b/src/rrd_tool.h @@ -121,6 +121,8 @@ int rrd_fetch_fn_libdbi(const char *filename, enum cf_en cf_idx, char *a, char *b); + const char *cf_to_string (enum cf_en cf); + #endif /* _RRD_TOOL_H */ #ifdef __cplusplus -- 2.11.0