]> git.proxmox.com Git - mirror_corosync.git/commitdiff
icmap: Add func to test equality of two key values
authorJan Friesse <jfriesse@redhat.com>
Tue, 10 Sep 2013 14:02:41 +0000 (16:02 +0200)
committerJan Friesse <jfriesse@redhat.com>
Tue, 10 Sep 2013 15:02:12 +0000 (17:02 +0200)
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
exec/icmap.c
include/corosync/icmap.h

index cfc49cae756a143ce7b1357b3589031489d33f3c..337a560cfcc6d9eb286e3907ad2d6bf058218a3f 100644 (file)
@@ -396,6 +396,28 @@ static int icmap_item_eq(const struct icmap_item *item, const void *value, size_
        return (0);
 }
 
+int icmap_key_value_eq(
+       const icmap_map_t map1,
+       const char *key_name1,
+       const icmap_map_t map2,
+       const char *key_name2)
+{
+       struct icmap_item *item1, *item2;
+
+       if (map1 == NULL || key_name1 == NULL || map2 == NULL || key_name2 == NULL) {
+               return (0);
+       }
+
+       item1 = qb_map_get(map1->qb_map, key_name1);
+       item2 = qb_map_get(map2->qb_map, key_name2);
+
+       if (item1 == NULL || item2 == NULL) {
+               return (0);
+       }
+
+       return (icmap_item_eq(item1, item2->value, item2->value_len, item2->type));
+}
+
 cs_error_t icmap_set_r(
        const icmap_map_t map,
        const char *key_name,
index 8026c88dd615e78d34ea678836c62b761e0a5fbd..a952ef648671768517ed0e6bb4e611640f0dbf18 100644 (file)
@@ -151,6 +151,19 @@ extern void icmap_fini_r(const icmap_map_t map);
  */
 extern icmap_map_t icmap_get_global_map(void);
 
+/*
+ * Compare value of key with name key_name1 in map1 with key with name key_name2
+ * in map2. Two values must have same type, length and value to be considered equal.
+ * Function returns 0 when any of map1, key_name1, map2, key_name2 are NULL, or
+ * key_name is not found in map, or keys are not equal. != 0 is returned when
+ * values are equal.
+ */
+extern int icmap_key_value_eq(
+       const icmap_map_t map1,
+       const char *key_name1,
+       const icmap_map_t map2,
+       const char *key_name2);
+
 /*
  * Store value with value_len length and type as key_name name in global icmap.
  */