s3:registry: add a new function regval_ctr_value_byname()
authorMichael Adam <obnox@samba.org>
Fri, 30 Mar 2012 12:39:50 +0000 (14:39 +0200)
committerKarolin Seeger <kseeger@samba.org>
Thu, 10 May 2012 09:15:04 +0000 (11:15 +0200)
This is like regval_ctr_key_exists() but does not return bool,
but the regval_blob instead, if found, and NULL if not found.
(cherry picked from commit b037d5461a7a9a2e51a3dd2794fcc47dfcff4468)

source3/registry/reg_objects.c
source3/registry/reg_objects.h

index de0de2c5d0c383c4ab6b69fefe14a1dee85a941b..693ea7402d69a3f7ebfab2e1e80b4eb6f2842d4a 100644 (file)
@@ -458,6 +458,24 @@ bool regval_ctr_value_exists(struct regval_ctr *ctr, const char *value)
        return False;
 }
 
+/**
+ * Get a value by its name
+ */
+struct regval_blob *regval_ctr_value_byname(struct regval_ctr *ctr,
+                                           const char *value)
+{
+       int i;
+
+       for (i=0; i<ctr->num_values; i++) {
+               if (strequal(ctr->values[i]->valuename,value)) {
+                       return ctr->values[i];
+               }
+       }
+
+       return NULL;
+}
+
+
 /***********************************************************************
  * compose a struct regval_blob from input data
  **********************************************************************/
index 0599bfeedd4ee2a4a62d1ca8e365755c63634daf..406c8b82e3289474ebb129a5c74af891f9f74bbf 100644 (file)
@@ -55,6 +55,8 @@ char* regval_name(struct regval_blob *val);
 uint32_t regval_type(struct regval_blob *val);
 struct regval_blob* regval_ctr_specific_value(struct regval_ctr *ctr,
                                              uint32_t idx);
+struct regval_blob *regval_ctr_value_byname(struct regval_ctr *ctr,
+                                           const char *value);
 bool regval_ctr_value_exists(struct regval_ctr *ctr, const char *value);
 struct regval_blob *regval_compose(TALLOC_CTX *ctx, const char *name,
                                   uint32_t type,