Quantcast

[PATCH] function to compare two ERP

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH] function to compare two ERP

Prabhakar_Pujeri
checking both ERP matches for address,selectors,uri

Signed-off-by: prabhakar pujeri <[hidden email]>
---
 include/wsman-epr.h |  8 ++++++++
 src/lib/wsman-epr.c | 27 +++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/include/wsman-epr.h b/include/wsman-epr.h
index bee8234..6e2edcd 100644
--- a/include/wsman-epr.h
+++ b/include/wsman-epr.h
@@ -123,6 +123,14 @@ int epr_add_selector_text(epr_t *epr, const char *name, const char *text);
 int epr_add_selector_epr(epr_t *epr, const char *name, epr_t *added_epr);
 
 /**
+ * compare two epr's
+ * @param epr1 Point of epr_t
+ * @param epr2 Point of epr_t
+ * @return 0 for equal, others for failure
+ */
+int epr_compare(epr_t *epr1,epr_t *epr2 );
+
+/**
  * Delete an selector from an epr by name
  * @param epr Point of epr_t
  * @param name Name of selector name
diff --git a/src/lib/wsman-epr.c b/src/lib/wsman-epr.c
index 1b0ef8a..fab2a3f 100644
--- a/src/lib/wsman-epr.c
+++ b/src/lib/wsman-epr.c
@@ -220,6 +220,33 @@ int epr_add_selector_epr(epr_t *epr, const char *name, epr_t *added_epr)
  return epr_add_selector(epr, name, NULL, added_epr);
 }
 
+int epr_compare(epr_t *epr1,erp_t *epr2 )
+{
+    int i,k;
+    int count;
+    key_value_t *selectors;
+    //return if any one epr is NULL
+    if(epr1 == NULL || erp2 == NULL) return 1;
+
+    //compare address
+    if(strcmp(epr1->address,epr2->address==0) return 1;
+
+    //compare selector count
+    if(erp1->refparams.selectorset.count != erp2->refparams.selectorset.count)) return 1;
+    
+    //compare uri
+    if(strcmp(epr1->refparams.uri,epr2->refparams.uri)!=0) return 1;
+
+    //compare selectors
+    for (j=0;j<erp1->refparams.selectorset.count;j++) {
+        for (i=0;i<erp2->refparams.selectorset.count;i++) {
+            if(strcmp(epr1->refparams.selectorset.selectors[j],
+                    epr2->refparams.selectorset.selectors[i])!=0) return 1;
+        }
+    }
+    return 0;
+}
+
 int epr_delete_selector(epr_t *epr, const char *name)
 {
  int i,k;
--
2.4.3


------------------------------------------------------------------------------
_______________________________________________
Openwsman-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openwsman-devel
Loading...