r24418: Adding reg_deleteallvalues().
authorGünther Deschner <gd@samba.org>
Tue, 14 Aug 2007 15:29:42 +0000 (15:29 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:29:44 +0000 (12:29 -0500)
Guenther

source/registry/reg_api.c

index b7f79c151914e53ac58f1538e19284d6c33ce957..1d863ec93efb13bc1210475a7357197eab4f3a3c 100644 (file)
@@ -618,6 +618,30 @@ WERROR reg_deletevalue(struct registry_key *key, const char *name)
        return WERR_OK;
 }
 
+WERROR reg_deleteallvalues(struct registry_key *key)
+{
+       WERROR err;
+       int i;
+
+       if (!(key->key->access_granted & SEC_RIGHTS_SET_VALUE)) {
+               return WERR_ACCESS_DENIED;
+       }
+
+       if (!W_ERROR_IS_OK(err = fill_value_cache(key))) {
+               return err;
+       }
+
+       for (i=0; i<key->values->num_values; i++) {
+               regval_ctr_delvalue(key->values, key->values->values[i]->valuename);
+       }
+
+       if (!store_reg_values(key->key, key->values)) {
+               TALLOC_FREE(key->values);
+               return WERR_REG_IO_FAILURE;
+       }
+
+       return WERR_OK;
+}
 
 /*
  * Utility function to open a complete registry path including the hive