Code

store: Added sdb_store_parse_object_type().
authorSebastian Harl <sh@tokkee.org>
Thu, 23 Oct 2014 19:29:16 +0000 (21:29 +0200)
committerSebastian Harl <sh@tokkee.org>
Thu, 23 Oct 2014 19:29:16 +0000 (21:29 +0200)
This function parses an object type name (singular) and returns the type ID.

src/core/store_lookup.c
src/include/core/store.h

index 9c2a68d21a4acce7a3abecbc6fa9067bd1ef21c7..180d17931d2c603fb0e295b5b06f4c9637d5cb8a 100644 (file)
@@ -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)
 {
index ab12162115b6d9d56d7011ae225871c488fc322f..5d5995f56d6685003b87064a5bbfe2ab7f4a4293 100644 (file)
@@ -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.