diff options
author | C. Davis <cd.rattan@gmail.com> | 2012-07-06 03:08:17 -0700 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2013-04-29 13:05:43 +0200 |
commit | 6c881e285b4a130bddd15f7d740e4c64a33e0de3 (patch) | |
tree | b1a858b3b8376936e460cea79d4203d9bbd6f595 /source3 | |
parent | 44f7d1b67337684f2d65b32042900c200c5ae209 (diff) | |
download | samba-6c881e285b4a130bddd15f7d740e4c64a33e0de3.tar.gz samba-6c881e285b4a130bddd15f7d740e4c64a33e0de3.tar.bz2 samba-6c881e285b4a130bddd15f7d740e4c64a33e0de3.zip |
regedit: Add regedit main source file
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'source3')
-rw-r--r-- | source3/utils/regedit.c | 95 | ||||
-rwxr-xr-x | source3/wscript_build | 4 |
2 files changed, 99 insertions, 0 deletions
diff --git a/source3/utils/regedit.c b/source3/utils/regedit.c new file mode 100644 index 0000000000..9c117e346e --- /dev/null +++ b/source3/utils/regedit.c @@ -0,0 +1,95 @@ +/* + * Samba Unix/Linux SMB client library + * Registry Editor + * Copyright (C) Christopher Davis 2012 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "includes.h" +#include "popt_common.h" +#include "lib/util/data_blob.h" +#include "lib/registry/registry.h" +#include "regedit.h" + +int main(int argc, char **argv) +{ + struct poptOption long_options[] = { + POPT_AUTOHELP + /* ... */ + POPT_COMMON_SAMBA + POPT_COMMON_CONNECTION + POPT_COMMON_CREDENTIALS + POPT_TABLEEND + }; + int opt; + poptContext pc; + struct user_auth_info *auth_info; + TALLOC_CTX *frame; + struct registry_context *ctx; + struct registry_key *hklm; + struct registry_key *smbconf; + uint32_t n; + WERROR rv; + + frame = talloc_stackframe(); + + setup_logging("regedit", DEBUG_DEFAULT_STDERR); + lp_set_cmdline("log level", "0"); + lp_load_global(get_dyn_CONFIGFILE()); + + /* process options */ + auth_info = user_auth_info_init(frame); + if (auth_info == NULL) { + exit(1); + } + popt_common_set_auth_info(auth_info); + pc = poptGetContext("regedit", argc, (const char **)argv, long_options, 0); + + while ((opt = poptGetNextOpt(pc)) != -1) { + /* TODO */ + } + + /* some simple tests */ + + rv = reg_open_samba3(frame, &ctx); + SMB_ASSERT(W_ERROR_IS_OK(rv)); + + rv = reg_get_predefined_key_by_name(ctx, "HKEY_LOCAL_MACHINE", &hklm); + SMB_ASSERT(W_ERROR_IS_OK(rv)); + + printf("contents of hklm/SOFTWARE/Samba/smbconf...\n"); + + rv = reg_open_key(ctx, hklm, "SOFTWARE\\Samba\\smbconf", &smbconf); + SMB_ASSERT(W_ERROR_IS_OK(rv)); + + printf("subkeys...\n"); + + for (n = 0; ;++n) { + const char *name, *klass; + NTTIME modified; + + rv = reg_key_get_subkey_by_index(ctx, smbconf, n, &name, + &klass, &modified); + if (!W_ERROR_IS_OK(rv)) { + break; + } + + printf("%u: %s\n", (unsigned)n, name); + } + + TALLOC_FREE(frame); + + return 0; +} diff --git a/source3/wscript_build b/source3/wscript_build index 09c84fae44..269b29aec7 100755 --- a/source3/wscript_build +++ b/source3/wscript_build @@ -1641,6 +1641,10 @@ bld.SAMBA3_PYTHON('pylibsmb', realname='samba/samba3/libsmb_samba_internal.so' ) +bld.SAMBA3_BINARY('regedit', + source='utils/regedit.c utils/regedit_samba3.c utils/regedit_wrap.c', + deps='registry param popt_samba3 smbregistry') + swat_dir = os.path.join(bld.curdir, '../swat') swat_files = recursive_dirlist(swat_dir, swat_dir, '*') swat_msg_dir = os.path.join(bld.curdir, 'po') |