2 * Samba Unix/Linux SMB client library
3 * Distributed SMB/CIFS Server Management Utility
4 * registry utility functions
6 * Copyright (C) Michael Adam 2008
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include "utils/net_registry_util.h"
25 #include "utils/net.h"
27 void print_registry_key(const char *keyname
, NTTIME
*modtime
)
29 d_printf(_("Keyname = %s\n"), keyname
);
30 d_printf(_("Modtime = %s\n"),
32 ? http_timestring(talloc_tos(), nt_time_to_unix(*modtime
))
37 void print_registry_value(const struct registry_value
*valvalue
, bool raw
)
40 d_printf(_("Type = %s\n"),
41 str_regtype(valvalue
->type
));
43 switch(valvalue
->type
) {
46 d_printf(_("Value = "));
48 d_printf("%d\n", valvalue
->v
.dword
);
53 d_printf(_("Value = \""));
55 d_printf("%s", valvalue
->v
.sz
.str
);
63 for (j
= 0; j
< valvalue
->v
.multi_sz
.num_strings
; j
++) {
65 d_printf(_("Value[%3.3d] = \""), j
);
67 d_printf("%s", valvalue
->v
.multi_sz
.strings
[j
]);
77 d_printf(_("Value = "));
79 d_printf(_("%d bytes\n"), (int)valvalue
->v
.binary
.length
);
83 d_printf(_("Value = "));
85 d_printf(_("<unprintable>\n"));
90 void print_registry_value_with_name(const char *valname
,
91 const struct registry_value
*valvalue
)
93 d_printf(_("Valuename = %s\n"), valname
);
94 print_registry_value(valvalue
, false);
99 * Split path into hive name and subkeyname
100 * normalizations performed:
101 * - if the path contains no '\\' characters,
102 * assume that the legacy format of using '/'
103 * as a separator is used and convert '/' to '\\'
104 * - strip trailing '\\' chars
106 WERROR
split_hive_key(TALLOC_CTX
*ctx
, const char *path
, char **hivename
,
110 const char *tmp_subkeyname
;
112 if ((path
== NULL
) || (hivename
== NULL
) || (subkeyname
== NULL
)) {
113 return WERR_INVALID_PARAM
;
116 if (strlen(path
) == 0) {
117 return WERR_INVALID_PARAM
;
120 if (strchr(path
, '\\') == NULL
) {
121 *hivename
= talloc_string_sub(ctx
, path
, "/", "\\");
123 *hivename
= talloc_strdup(ctx
, path
);
126 if (*hivename
== NULL
) {
130 /* strip trailing '\\' chars */
131 p
= strrchr(*hivename
, '\\');
132 while ((p
!= NULL
) && (p
[1] == '\0')) {
134 p
= strrchr(*hivename
, '\\');
137 p
= strchr(*hivename
, '\\');
139 if ((p
== NULL
) || (*p
== '\0')) {
140 /* just the hive - no subkey given */
144 tmp_subkeyname
= p
+1;
146 *subkeyname
= talloc_strdup(ctx
, tmp_subkeyname
);
147 if (*subkeyname
== NULL
) {