s4: popt: Global replace of cmdline_credentials -> popt_get_cmdline_credentials().
[Samba.git] / source4 / lib / registry / tools / regpatch.c
blob50195fe084c30b03a89727377254aca6f5e85bf5
1 /*
2 Unix SMB/CIFS implementation.
3 simple registry frontend
5 Copyright (C) 2004-2007 Jelmer Vernooij, jelmer@samba.org
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/>.
21 #include "includes.h"
22 #include "lib/events/events.h"
23 #include "lib/registry/registry.h"
24 #include "lib/cmdline/popt_common.h"
25 #include "lib/registry/tools/common.h"
26 #include "param/param.h"
27 #include "events/events.h"
29 int main(int argc, const char **argv)
31 int opt;
32 poptContext pc;
33 const char *patch;
34 struct registry_context *h;
35 const char *file = NULL;
36 const char *remote = NULL;
37 struct tevent_context *ev_ctx;
38 struct poptOption long_options[] = {
39 POPT_AUTOHELP
40 {"remote", 'R', POPT_ARG_STRING, &remote, 0, "connect to specified remote server", NULL},
41 {"file", 'F', POPT_ARG_STRING, &file, 0, "file path", NULL },
42 POPT_COMMON_SAMBA
43 POPT_COMMON_CREDENTIALS
44 { NULL }
47 pc = poptGetContext(argv[0], argc, argv, long_options,0);
49 while((opt = poptGetNextOpt(pc)) != -1) {
52 ev_ctx = s4_event_context_init(NULL);
54 if (remote) {
55 h = reg_common_open_remote (remote, ev_ctx, cmdline_lp_ctx,
56 popt_get_cmdline_credentials());
57 } else {
58 h = reg_common_open_local (popt_get_cmdline_credentials(),
59 ev_ctx, cmdline_lp_ctx);
62 if (h == NULL)
63 return 1;
65 patch = poptGetArg(pc);
66 if (patch == NULL) {
67 poptPrintUsage(pc, stderr, 0);
68 return 1;
71 poptFreeContext(pc);
73 reg_diff_apply(h, patch);
75 return 0;