Code

store: Added a helper function to parse object type names.
authorSebastian Harl <sh@tokkee.org>
Tue, 30 Sep 2014 12:43:42 +0000 (05:43 -0700)
committerSebastian Harl <sh@tokkee.org>
Tue, 30 Sep 2014 12:45:10 +0000 (05:45 -0700)
src/core/store_lookup.c
src/include/core/store.h

index c3029c75078db3c0ee6d35b0fcbe602a799f41f6..86acd10ea17ccf0a05ca7a7d1faeda5b09c52446 100644 (file)
@@ -857,6 +857,18 @@ sdb_store_isnull_matcher(const char *attr_name)
                                MATCHER_ISNULL, attr_name));
 } /* sdb_store_isnull_matcher */
 
                                MATCHER_ISNULL, attr_name));
 } /* sdb_store_isnull_matcher */
 
+int
+sdb_store_parse_object_type_plural(const char *name)
+{
+       if (! strcasecmp(name, "hosts"))
+               return SDB_HOST;
+       else if (! strcasecmp(name, "services"))
+               return SDB_SERVICE;
+       else if (! strcasecmp(name, "metrics"))
+               return SDB_METRIC;
+       return -1;
+} /* sdb_store_parse_object_type_plural */
+
 int
 sdb_store_parse_field_name(const char *name)
 {
 int
 sdb_store_parse_field_name(const char *name)
 {
index 7c94a974297d46cb4107df7ea8773e036343a8d8..fa974bbd1f7f93656992423ad3891f3b66d6b645 100644 (file)
@@ -397,6 +397,17 @@ sdb_store_ge_matcher(sdb_store_cond_t *cond);
 sdb_store_matcher_t *
 sdb_store_gt_matcher(sdb_store_cond_t *cond);
 
 sdb_store_matcher_t *
 sdb_store_gt_matcher(sdb_store_cond_t *cond);
 
+/*
+ * sdb_store_parse_object_type_plural:
+ * Parse the type name (plural) of a stored object.
+ *
+ * Returns:
+ *  - the object type on success
+ *  - a negative value else
+ */
+int
+sdb_store_parse_object_type_plural(const char *name);
+
 /*
  * sdb_store_parse_field_name:
  * Parse the name of a stored object's queryable field.
 /*
  * sdb_store_parse_field_name:
  * Parse the name of a stored object's queryable field.