2 * Samba Unix/Linux SMB client library
4 * Copyright (C) Christopher Davis 2012
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "popt_common.h"
22 #include "lib/util/data_blob.h"
23 #include "lib/registry/registry.h"
26 int main(int argc, char **argv)
28 struct poptOption long_options[] = {
32 POPT_COMMON_CONNECTION
33 POPT_COMMON_CREDENTIALS
38 struct user_auth_info *auth_info;
40 struct registry_context *ctx;
41 struct registry_key *hklm;
42 struct registry_key *smbconf;
46 frame = talloc_stackframe();
48 setup_logging("regedit", DEBUG_DEFAULT_STDERR);
49 lp_set_cmdline("log level", "0");
50 lp_load_global(get_dyn_CONFIGFILE());
53 auth_info = user_auth_info_init(frame);
54 if (auth_info == NULL) {
57 popt_common_set_auth_info(auth_info);
58 pc = poptGetContext("regedit", argc, (const char **)argv, long_options, 0);
60 while ((opt = poptGetNextOpt(pc)) != -1) {
64 /* some simple tests */
66 rv = reg_open_samba3(frame, &ctx);
67 SMB_ASSERT(W_ERROR_IS_OK(rv));
69 rv = reg_get_predefined_key_by_name(ctx, "HKEY_LOCAL_MACHINE", &hklm);
70 SMB_ASSERT(W_ERROR_IS_OK(rv));
72 printf("contents of hklm/SOFTWARE/Samba/smbconf...\n");
74 rv = reg_open_key(ctx, hklm, "SOFTWARE\\Samba\\smbconf", &smbconf);
75 SMB_ASSERT(W_ERROR_IS_OK(rv));
77 printf("subkeys...\n");
80 const char *name, *klass;
83 rv = reg_key_get_subkey_by_index(ctx, smbconf, n, &name,
85 if (!W_ERROR_IS_OK(rv)) {
89 printf("%u: %s\n", (unsigned)n, name);