s3-registry: add reg_querymultiplevalues() to reg_api.
authorGünther Deschner <gd@samba.org>
Wed, 30 Jun 2010 00:02:43 +0000 (02:02 +0200)
committerGünther Deschner <gd@samba.org>
Wed, 30 Jun 2010 19:46:08 +0000 (21:46 +0200)
Guenther

source3/include/registry.h
source3/registry/reg_api.c

index 703176f3391c10c52f248b53433476d8cb14d89d..00c27cf0216606e0f5a1c56e91c47c466266ffe6 100644 (file)
@@ -163,6 +163,12 @@ WERROR reg_enumvalue(TALLOC_CTX *mem_ctx, struct registry_key *key,
                     uint32 idx, char **pname, struct registry_value **pval);
 WERROR reg_queryvalue(TALLOC_CTX *mem_ctx, struct registry_key *key,
                      const char *name, struct registry_value **pval);
+WERROR reg_querymultiplevalues(TALLOC_CTX *mem_ctx,
+                              struct registry_key *key,
+                              uint32_t num_names,
+                              const char **names,
+                              uint32_t *pnum_vals,
+                              struct registry_value **pvals);
 WERROR reg_queryinfokey(struct registry_key *key, uint32_t *num_subkeys,
                        uint32_t *max_subkeylen, uint32_t *max_subkeysize,
                        uint32_t *num_values, uint32_t *max_valnamelen,
index 79b9a1eb2bcfd687867b77ac984d67495309e018..1954fb50419b65b25cfdc90e18d02a7d11506510 100644 (file)
@@ -402,6 +402,56 @@ WERROR reg_queryvalue(TALLOC_CTX *mem_ctx, struct registry_key *key,
        return WERR_BADFILE;
 }
 
+WERROR reg_querymultiplevalues(TALLOC_CTX *mem_ctx,
+                              struct registry_key *key,
+                              uint32_t num_names,
+                              const char **names,
+                              uint32_t *pnum_vals,
+                              struct registry_value **pvals)
+{
+       WERROR err;
+       uint32_t i, n, found = 0;
+       struct registry_value *vals;
+
+       if (num_names == 0) {
+               return WERR_OK;
+       }
+
+       if (!(key->key->access_granted & KEY_QUERY_VALUE)) {
+               return WERR_ACCESS_DENIED;
+       }
+
+       if (!(W_ERROR_IS_OK(err = fill_value_cache(key)))) {
+               return err;
+       }
+
+       vals = talloc_zero_array(mem_ctx, struct registry_value, num_names);
+       if (vals == NULL) {
+               return WERR_NOMEM;
+       }
+
+       for (n=0; n < num_names; n++) {
+               for (i=0; i < regval_ctr_numvals(key->values); i++) {
+                       struct regval_blob *blob;
+                       blob = regval_ctr_specific_value(key->values, i);
+                       if (strequal(regval_name(blob), names[n])) {
+                               struct registry_value *v;
+                               err = reg_enumvalue(mem_ctx, key, i, NULL, &v);
+                               if (!W_ERROR_IS_OK(err)) {
+                                       return err;
+                               }
+                               vals[n] = *v;
+                               found++;
+                       }
+               }
+       }
+
+       *pvals = vals;
+       *pnum_vals = found;
+
+       return WERR_OK;
+}
+
 WERROR reg_queryinfokey(struct registry_key *key, uint32_t *num_subkeys,
                        uint32_t *max_subkeylen, uint32_t *max_subkeysize, 
                        uint32_t *num_values, uint32_t *max_valnamelen,