From: Andreas Schneider Date: Wed, 13 Jan 2021 12:32:24 +0000 (+0100) Subject: s3:utils: Migrate spilt_tokens to new cmdline option parser X-Git-Tag: tevent-0.11.0~745 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d8b6e843fb4dbb6f2e5e21015e14136f6103b677;p=thirdparty%2Fsamba.git s3:utils: Migrate spilt_tokens to new cmdline option parser Signed-off-by: Andreas Schneider Reviewed-by: Andrew Bartlett --- diff --git a/source3/utils/split_tokens.c b/source3/utils/split_tokens.c index 39e7396dfb3..6693f010edf 100644 --- a/source3/utils/split_tokens.c +++ b/source3/utils/split_tokens.c @@ -24,15 +24,15 @@ */ #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 *sequence = ""; poptContext pc; char *buff; TALLOC_CTX *ctx = talloc_stackframe(); + bool ok; struct poptOption long_options[] = { POPT_AUTOHELP @@ -42,14 +42,30 @@ int main(int argc, const char *argv[]) smb_init_locale(); - pc = poptGetContext(NULL, argc, argv, long_options, - POPT_CONTEXT_KEEP_FIRST); + ok = samba_cmdline_init(ctx, + SAMBA_CMDLINE_CONFIG_CLIENT, + false /* require_smbconf */); + if (!ok) { + DBG_ERR("Failed to init cmdline parser!\n"); + TALLOC_FREE(ctx); + exit(1); + } + + pc = samba_popt_get_context(getprogname(), + argc, + argv, + long_options, + POPT_CONTEXT_KEEP_FIRST); + if (pc == NULL) { + DBG_ERR("Failed to setup popt context!\n"); + TALLOC_FREE(ctx); + exit(1); + } + poptSetOtherOptionHelp(pc, "[OPTION...] "); while(poptGetNextOpt(pc) != -1); - setup_logging(poptGetArg(pc), DEBUG_STDERR); - sequence = poptGetArg(pc); if (sequence == NULL) { @@ -59,11 +75,6 @@ int main(int argc, const char *argv[]) lp_set_cmdline("log level", "0"); - if (!lp_load_global(config_file)) { - fprintf(stderr,"Error loading services.\n"); - return 1; - } - while(next_token_talloc(ctx, &sequence, &buff, NULL)) { printf("[%s]\n", buff); } diff --git a/source3/utils/wscript_build b/source3/utils/wscript_build index 85bec26536e..640a7fde260 100644 --- a/source3/utils/wscript_build +++ b/source3/utils/wscript_build @@ -152,7 +152,9 @@ bld.SAMBA3_BINARY('split_tokens', source='split_tokens.c', deps=''' talloc - popt_samba3''', + CMDLINE_S3 + smbconf + ''', install=False) bld.SAMBA3_BINARY('samba-regedit',