From: Andreas Schneider Date: Wed, 13 Jan 2021 08:16:31 +0000 (+0100) Subject: s3:utils: Migrate dbwrap_tool to new cmdline option parser X-Git-Tag: tevent-0.11.0~763 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8e1fe474c9b10e64168e4d473b1203ff4ab2bb3f;p=thirdparty%2Fsamba.git s3:utils: Migrate dbwrap_tool to new cmdline option parser Signed-off-by: Andreas Schneider Reviewed-by: Andrew Bartlett --- diff --git a/source3/utils/dbwrap_tool.c b/source3/utils/dbwrap_tool.c index 5d4791473a0..3c7f39854c8 100644 --- a/source3/utils/dbwrap_tool.c +++ b/source3/utils/dbwrap_tool.c @@ -22,7 +22,7 @@ #include "includes.h" #include "system/filesys.h" -#include "popt_common.h" +#include "lib/cmdline/cmdline.h" #include "dbwrap/dbwrap.h" #include "dbwrap/dbwrap_open.h" #include "messages.h" @@ -382,6 +382,7 @@ int main(int argc, const char **argv) TALLOC_CTX *mem_ctx = talloc_stackframe(); int ret = 1; + bool ok; struct poptOption popt_options[] = { POPT_AUTOHELP @@ -393,6 +394,7 @@ int main(int argc, const char **argv) { "persistent", 0, POPT_ARG_NONE, &persistent, 0, "treat the database as persistent", NULL }, + POPT_COMMON_VERSION POPT_TABLEEND }; int opt; @@ -401,10 +403,29 @@ int main(int argc, const char **argv) poptContext pc; smb_init_locale(); + + setup_logging(argv[0], DEBUG_DEFAULT_STDERR); lp_set_cmdline("log level", "0"); - setup_logging(argv[0], DEBUG_STDERR); - pc = poptGetContext(argv[0], argc, argv, popt_options, POPT_CONTEXT_KEEP_FIRST); + ok = samba_cmdline_init(mem_ctx, + SAMBA_CMDLINE_CONFIG_CLIENT, + false /* require_smbconf */); + if (!ok) { + DBG_ERR("Failed to init cmdline parser!\n"); + TALLOC_FREE(mem_ctx); + exit(1); + } + + pc = samba_popt_get_context(getprogname(), + argc, + argv, + popt_options, + POPT_CONTEXT_KEEP_FIRST); + if (!ok) { + DBG_ERR("Failed to setup popt context!\n"); + TALLOC_FREE(mem_ctx); + exit(1); + } while ((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { @@ -422,8 +443,6 @@ int main(int argc, const char **argv) while (extra_argv[extra_argc]) extra_argc++; } - lp_load_global(get_dyn_CONFIGFILE()); - if ((extra_argc < 2) || (extra_argc > 5)) { d_fprintf(stderr, "USAGE: %s [options] [ [ " diff --git a/source3/utils/wscript_build b/source3/utils/wscript_build index c28fd862b3a..55ad6ee79db 100644 --- a/source3/utils/wscript_build +++ b/source3/utils/wscript_build @@ -135,7 +135,7 @@ bld.SAMBA3_BINARY('dbwrap_tool', source='dbwrap_tool.c', deps=''' talloc - popt_samba3 + CMDLINE_S3 cmdline_contexts ''')