2 Unix SMB/CIFS implementation.
3 Popt routines specifically for registry
5 Copyright (C) Jelmer Vernooij 2007
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "auth/credentials/credentials.h"
23 #include "lib/registry/registry.h"
24 #include "lib/registry/tools/common.h"
26 struct registry_context *reg_common_open_remote(const char *remote,
27 struct cli_credentials *creds)
29 struct registry_context *h;
32 error = reg_open_remote(&h, NULL, creds, remote, NULL);
34 if (!W_ERROR_IS_OK(error)) {
35 fprintf(stderr, "Unable to open remote registry at %s:%s \n",
36 remote, win_errstr(error));
43 struct registry_key *reg_common_open_file(const char *path,
44 struct cli_credentials *creds)
46 struct hive_key *hive_root;
47 struct registry_context *h;
50 error = reg_open_hive(NULL, path, NULL, creds, &hive_root);
52 if(!W_ERROR_IS_OK(error)) {
53 fprintf(stderr, "Unable to open '%s': %s \n",
54 path, win_errstr(error));
58 error = reg_open_local(NULL, &h, NULL, creds);
59 if (!W_ERROR_IS_OK(error)) {
60 fprintf(stderr, "Unable to initialize local registry: %s\n",
65 return reg_import_hive_key(h, hive_root, -1, NULL);
68 struct registry_context *reg_common_open_local(struct cli_credentials *creds, struct loadparm_context *lp_ctx)
71 struct registry_context *h;
73 error = reg_open_samba(NULL, &h, lp_ctx, NULL, creds);
75 if(!W_ERROR_IS_OK(error)) {
76 fprintf(stderr, "Unable to open local registry:%s \n",