From d1559e5f8f655b4fd0366b2c01243c30b76ceace Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Thu, 23 Oct 2014 21:29:16 +0200 Subject: [PATCH] store: Added sdb_store_parse_object_type(). This function parses an object type name (singular) and returns the type ID. --- src/core/store_lookup.c | 14 ++++++++++++++ src/include/core/store.h | 11 +++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/core/store_lookup.c b/src/core/store_lookup.c index 9c2a68d..180d179 100644 --- a/src/core/store_lookup.c +++ b/src/core/store_lookup.c @@ -786,6 +786,20 @@ sdb_store_parse_matcher_op(const char *op) return NULL; } /* sdb_store_parse_matcher_op */ +int +sdb_store_parse_object_type(const char *name) +{ + if (! strcasecmp(name, "host")) + return SDB_HOST; + else if (! strcasecmp(name, "service")) + return SDB_SERVICE; + else if (! strcasecmp(name, "metric")) + return SDB_METRIC; + else if (! strcasecmp(name, "attribute")) + return SDB_ATTRIBUTE; + return -1; +} /* sdb_store_parse_object_type */ + int sdb_store_parse_object_type_plural(const char *name) { diff --git a/src/include/core/store.h b/src/include/core/store.h index ab12162..5d5995f 100644 --- a/src/include/core/store.h +++ b/src/include/core/store.h @@ -457,6 +457,17 @@ typedef sdb_store_matcher_t *(*sdb_store_matcher_op_cb) sdb_store_matcher_op_cb sdb_store_parse_matcher_op(const char *op); +/* + * sdb_store_parse_object_type: + * Parse the type name of a stored object. + * + * Returns: + * - the object type on success + * - a negative value else + */ +int +sdb_store_parse_object_type(const char *name); + /* * sdb_store_parse_object_type_plural: * Parse the type name (plural) of a stored object. -- 2.30.2