s3:registry: add functions to conveniently create registry_values
authorGregor Beck <gbeck@sernet.de>
Mon, 30 Apr 2012 08:27:56 +0000 (10:27 +0200)
committerMichael Adam <obnox@samba.org>
Tue, 26 Jun 2012 17:57:18 +0000 (19:57 +0200)
Pair-Programmed-With: Michael Adam <obnox@samba.org>

source3/registry/reg_api_util.c
source3/registry/reg_api_util.h

index f2a31833c64dddbb7d89543da147f451ef83691d..42aaa00c61b1052cec761e2257fd8ec5249a40d8 100644 (file)
@@ -26,6 +26,7 @@
 #include "registry.h"
 #include "reg_api.h"
 #include "reg_api_util.h"
+#include "libcli/registry/util_reg.h"
 
 /**
  * Utility function to open a complete registry path including the hive prefix.
@@ -176,3 +177,63 @@ WERROR reg_delete_path(const struct security_token *token,
        TALLOC_FREE(hive);
        return err;
 }
+
+struct registry_value *registry_value_dw(TALLOC_CTX *mem_ctx, uint32_t dw)
+{
+       struct registry_value *ret;
+
+       ret = talloc_zero(mem_ctx, struct registry_value);
+       if (ret == NULL) {
+               return NULL;
+       }
+
+       ret->data = data_blob_talloc(ret, NULL, sizeof(uint32_t));
+       if (ret->data.data == NULL) {
+               talloc_free(ret);
+               return NULL;
+       }
+
+       ret->type = REG_DWORD;
+
+       SIVAL(ret->data.data, 0, dw);
+
+       return ret;
+}
+
+struct registry_value *registry_value_sz(TALLOC_CTX *mem_ctx, const char *str)
+{
+       struct registry_value *ret;
+
+       ret = talloc_zero(mem_ctx, struct registry_value);
+       if (ret == NULL) {
+               return NULL;
+       }
+
+       if (!push_reg_sz(ret, &ret->data, str)) {
+               talloc_free(ret);
+               return NULL;
+       }
+
+       ret->type = REG_SZ;
+
+       return ret;
+}
+
+struct registry_value *registry_value_multi_sz(TALLOC_CTX *mem_ctx, const char **str)
+{
+       struct registry_value *ret;
+
+       ret = talloc_zero(mem_ctx, struct registry_value);
+       if (ret == NULL) {
+               return NULL;
+       }
+
+       if (!push_reg_multi_sz(ret, &ret->data, str)) {
+               talloc_free(ret);
+               return NULL;
+       }
+
+       ret->type = REG_MULTI_SZ;
+
+       return ret;
+}
index a70fa725618b25ab85aef8a0d43bb8a88a374890..7009794bebaf078623c260a8e1c2c62ad9f75f98 100644 (file)
@@ -40,4 +40,8 @@ WERROR reg_create_path(TALLOC_CTX *mem_ctx, const char *orig_path,
 WERROR reg_delete_path(const struct security_token *token,
                       const char *orig_path);
 
+struct registry_value *registry_value_dw(TALLOC_CTX *mem_ctx, uint32_t dw);
+struct registry_value *registry_value_sz(TALLOC_CTX *mem_ctx, const char *str);
+struct registry_value *registry_value_multi_sz(TALLOC_CTX *mem_ctx, const char **str);
+
 #endif /* _REG_API_UTIL_H */