From b87c36cb7832910edbe2cff11cd7570b23f8013b Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Fri, 8 Jan 2021 08:27:19 +0100 Subject: [PATCH] s3:param: Migrate test_lp_load to new cmdline option parser Signed-off-by: Andreas Schneider Reviewed-by: Andrew Bartlett --- source3/param/test_lp_load.c | 33 ++++++++++++++++++++++++++------- source3/param/wscript_build | 2 +- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/source3/param/test_lp_load.c b/source3/param/test_lp_load.c index 2a50723b643..b25a54798f8 100644 --- a/source3/param/test_lp_load.c +++ b/source3/param/test_lp_load.c @@ -18,15 +18,16 @@ */ #include "includes.h" -#include "popt_common.h" +#include "lib/cmdline/cmdline.h" int main(int argc, const char **argv) { - const char *config_file = get_dyn_CONFIGFILE(); + const char *config_file = NULL; int ret = 0; poptContext pc; char *count_str = NULL; int i, count = 1; + bool ok; struct poptOption long_options[] = { POPT_AUTOHELP @@ -38,25 +39,43 @@ int main(int argc, const char **argv) .val = 1, .descrip = "Load config number of times" }, - POPT_COMMON_DEBUGLEVEL + POPT_COMMON_DEBUG_ONLY + POPT_COMMON_VERSION POPT_TABLEEND }; TALLOC_CTX *frame = talloc_stackframe(); smb_init_locale(); + + ok = samba_cmdline_init(frame, + SAMBA_CMDLINE_CONFIG_NONE, + false /* require_smbconf */); + if (!ok) { + DBG_ERR("Failed to init cmdline parser!\n"); + TALLOC_FREE(frame); + exit(ENOMEM); + } lp_set_cmdline("log level", "0"); - pc = poptGetContext(NULL, argc, argv, long_options, - POPT_CONTEXT_KEEP_FIRST); + pc = samba_popt_get_context(getprogname(), + argc, + argv, + long_options, + 0); + if (pc == NULL) { + DBG_ERR("Failed to setup popt context!\n"); + TALLOC_FREE(frame); + exit(1); + } poptSetOtherOptionHelp(pc, "[OPTION...] "); while(poptGetNextOpt(pc) != -1); - setup_logging(poptGetArg(pc), DEBUG_STDERR); - if (poptPeekArg(pc)) { config_file = poptGetArg(pc); + } else { + config_file = get_dyn_CONFIGFILE(); } poptFreeContext(pc); diff --git a/source3/param/wscript_build b/source3/param/wscript_build index 22faf5cdcce..c14cf0df651 100644 --- a/source3/param/wscript_build +++ b/source3/param/wscript_build @@ -40,5 +40,5 @@ bld.SAMBA3_BINARY('test_lp_load', deps=''' talloc smbconf - popt_samba3''', + CMDLINE_S3''', install=False) -- 2.47.3