From: Sebastian Harl Date: Thu, 23 Oct 2014 19:29:16 +0000 (+0200) Subject: store: Added sdb_store_parse_object_type(). X-Git-Tag: sysdb-0.6.0~69 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=d1559e5f8f655b4fd0366b2c01243c30b76ceace;p=sysdb.git store: Added sdb_store_parse_object_type(). This function parses an object type name (singular) and returns the type ID. --- 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.