summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorGregor Beck <gbeck@sernet.de>2012-04-30 10:27:56 +0200
committerMichael Adam <obnox@samba.org>2012-06-26 19:57:18 +0200
commite10ea2b3cdfd32f810c6058446efb1392eb157ad (patch)
treef398875a27e33dd32addf239443c7a0a481fd096 /source3
parent35eccd0f53deb59bfdd80589da38d8ae2467fb8d (diff)
downloadsamba-e10ea2b3cdfd32f810c6058446efb1392eb157ad.tar.gz
samba-e10ea2b3cdfd32f810c6058446efb1392eb157ad.tar.bz2
samba-e10ea2b3cdfd32f810c6058446efb1392eb157ad.zip
s3:registry: add functions to conveniently create registry_values
Pair-Programmed-With: Michael Adam <obnox@samba.org>
Diffstat (limited to 'source3')
-rw-r--r--source3/registry/reg_api_util.c61
-rw-r--r--source3/registry/reg_api_util.h4
2 files changed, 65 insertions, 0 deletions
diff --git a/source3/registry/reg_api_util.c b/source3/registry/reg_api_util.c
index f2a31833c6..42aaa00c61 100644
--- a/source3/registry/reg_api_util.c
+++ b/source3/registry/reg_api_util.c
@@ -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;
+}
diff --git a/source3/registry/reg_api_util.h b/source3/registry/reg_api_util.h
index a70fa72561..7009794beb 100644
--- a/source3/registry/reg_api_util.h
+++ b/source3/registry/reg_api_util.h
@@ -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 */