diff options
author | Michael Adam <obnox@samba.org> | 2012-06-26 13:29:50 +0200 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2012-06-26 19:57:19 +0200 |
commit | f9ff84b0b45c66fd2c437228791e3bcf99255dad (patch) | |
tree | 8b7980808364fa7378f490c7192eaef21fa33528 /source3/utils | |
parent | e28b4b10a6d8cc13d7c8046a38d6c221915ff55b (diff) | |
download | samba-f9ff84b0b45c66fd2c437228791e3bcf99255dad.tar.gz samba-f9ff84b0b45c66fd2c437228791e3bcf99255dad.tar.bz2 samba-f9ff84b0b45c66fd2c437228791e3bcf99255dad.zip |
s3:net registry import: move precheck-and-import code to its own function
This is the code that is executed in a registry transaction.
The purpose of the refactoring is to be able to simplify and
untangle the code structure in the sequel.
Diffstat (limited to 'source3/utils')
-rw-r--r-- | source3/utils/net_registry.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/source3/utils/net_registry.c b/source3/utils/net_registry.c index 4716e7afa3..920ddc4fba 100644 --- a/source3/utils/net_registry.c +++ b/source3/utils/net_registry.c @@ -1219,9 +1219,9 @@ static bool import_precheck(const char *fname, const char *parse_options) return true; } - -static int net_registry_import(struct net_context *c, int argc, - const char **argv) +static int import_with_precheck_action(const char *import_fname, + const char *precheck_fname, + const char *parse_options) { TALLOC_CTX *frame = talloc_stackframe(); struct import_ctx import_ctx = { @@ -1240,6 +1240,21 @@ static int net_registry_import(struct net_context *c, int argc, .setval_type = REGISTRY_VALUE, .data = &import_ctx }; + int ret = -1; + + if (import_precheck(precheck_fname, parse_options)) { + ret = reg_parse_file(import_fname, + reg_import_adapter(frame, import_callback), + parse_options); + } + + talloc_free(frame); + return ret; +} + +static int net_registry_import(struct net_context *c, int argc, + const char **argv) +{ const char *parse_options = (argc > 1) ? argv[1] : NULL; int ret = -1; WERROR werr; @@ -1266,11 +1281,8 @@ static int net_registry_import(struct net_context *c, int argc, goto done; } - if (import_precheck(c->opt_precheck, parse_options)) { - ret = reg_parse_file(argv[0], - reg_import_adapter(frame, import_callback), - parse_options); - } + ret = import_with_precheck_action(argv[0], c->opt_precheck, + parse_options); if (ret < 0) { d_printf("Transaction canceled!\n"); @@ -1286,7 +1298,6 @@ static int net_registry_import(struct net_context *c, int argc, regdb_close(); done: - talloc_free(frame); return ret; } /**@}*/ |