2 * Unix SMB/CIFS implementation.
3 * Registry helper routines
4 * Copyright (C) Volker Lendecke 2006
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 3 of the License, or (at your option)
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * You should have received a copy of the GNU General Public License along with
17 * this program; if not, see <http://www.gnu.org/licenses/>.
23 #define DBGC_CLASS DBGC_REGISTRY
25 extern REGISTRY_OPS smbconf_reg_ops
;
27 const char *reg_type_lookup(enum winreg_Type type
)
39 result
= "REG_EXPAND_SZ";
42 result
= "REG_BINARY";
47 case REG_DWORD_BIG_ENDIAN
:
48 result
= "REG_DWORD_BIG_ENDIAN";
54 result
= "REG_MULTI_SZ";
56 case REG_RESOURCE_LIST
:
57 result
= "REG_RESOURCE_LIST";
59 case REG_FULL_RESOURCE_DESCRIPTOR
:
60 result
= "REG_FULL_RESOURCE_DESCRIPTOR";
62 case REG_RESOURCE_REQUIREMENTS_LIST
:
63 result
= "REG_RESOURCE_REQUIREMENTS_LIST";
69 result
= "REG TYPE IS UNKNOWN";
75 WERROR
reg_pull_multi_sz(TALLOC_CTX
*mem_ctx
, const void *buf
, size_t len
,
76 uint32
*num_values
, char ***values
)
78 const smb_ucs2_t
*p
= (const smb_ucs2_t
*)buf
;
82 * Make sure that a talloc context for the strings retrieved exists
85 if (!(*values
= TALLOC_ARRAY(mem_ctx
, char *, 1))) {
89 len
/= 2; /* buf is a set of UCS2 strings */
93 size_t dstlen
, thislen
;
95 thislen
= strnlen_w(p
, len
) + 1;
96 if (!convert_string_allocate(*values
, CH_UTF16LE
, CH_UNIX
,
97 p
, thislen
*2, (void *)&val
, &dstlen
, true)) {
102 ADD_TO_ARRAY(*values
, char *, val
, values
, num_values
);
103 if (*values
== NULL
) {
114 void normalize_dbkey(char *key
)
116 size_t len
= strlen(key
);
117 string_sub(key
, "\\", "/", len
+1);