s3/docs: Fix typo.
[Samba/gebeck_regimport.git] / source3 / lib / util_reg.c
blob1e1bcfeb10336fb2fc70d6aa2567b7504329d14d
1 /*
2 * Unix SMB/CIFS implementation.
3 * Registry helper routines
4 * Copyright (C) Volker Lendecke 2006
5 *
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)
9 * any later version.
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
14 * more details.
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/>.
20 #include "includes.h"
22 #undef DBGC_CLASS
23 #define DBGC_CLASS DBGC_REGISTRY
25 extern struct registry_ops smbconf_reg_ops;
27 const char *reg_type_lookup(enum winreg_Type type)
29 const char *result;
31 switch(type) {
32 case REG_NONE:
33 result = "REG_NONE";
34 break;
35 case REG_SZ:
36 result = "REG_SZ";
37 break;
38 case REG_EXPAND_SZ:
39 result = "REG_EXPAND_SZ";
40 break;
41 case REG_BINARY:
42 result = "REG_BINARY";
43 break;
44 case REG_DWORD:
45 result = "REG_DWORD";
46 break;
47 case REG_DWORD_BIG_ENDIAN:
48 result = "REG_DWORD_BIG_ENDIAN";
49 break;
50 case REG_LINK:
51 result = "REG_LINK";
52 break;
53 case REG_MULTI_SZ:
54 result = "REG_MULTI_SZ";
55 break;
56 case REG_RESOURCE_LIST:
57 result = "REG_RESOURCE_LIST";
58 break;
59 case REG_FULL_RESOURCE_DESCRIPTOR:
60 result = "REG_FULL_RESOURCE_DESCRIPTOR";
61 break;
62 case REG_RESOURCE_REQUIREMENTS_LIST:
63 result = "REG_RESOURCE_REQUIREMENTS_LIST";
64 break;
65 case REG_QWORD:
66 result = "REG_QWORD";
67 break;
68 default:
69 result = "REG TYPE IS UNKNOWN";
70 break;
72 return result;
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;
79 *num_values = 0;
82 * Make sure that a talloc context for the strings retrieved exists
85 if (!(*values = TALLOC_ARRAY(mem_ctx, char *, 1))) {
86 return WERR_NOMEM;
89 len /= 2; /* buf is a set of UCS2 strings */
91 while (len > 0) {
92 char *val;
93 size_t dstlen, thislen;
95 thislen = strnlen_w(p, len) + 1;
96 if (!convert_string_talloc(*values, CH_UTF16LE, CH_UNIX,
97 p, thislen*2, (void *)&val, &dstlen, true)) {
98 TALLOC_FREE(*values);
99 return WERR_NOMEM;
102 ADD_TO_ARRAY(*values, char *, val, values, num_values);
103 if (*values == NULL) {
104 return WERR_NOMEM;
107 p += thislen;
108 len -= thislen;
111 return WERR_OK;