From f9ff84b0b45c66fd2c437228791e3bcf99255dad Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 26 Jun 2012 13:29:50 +0200 Subject: 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. --- source3/utils/net_registry.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'source3/utils') 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; } /**@}*/ -- cgit