]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:utils: Migrate spilt_tokens to new cmdline option parser
authorAndreas Schneider <asn@samba.org>
Wed, 13 Jan 2021 12:32:24 +0000 (13:32 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 25 May 2021 00:23:37 +0000 (00:23 +0000)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/utils/split_tokens.c
source3/utils/wscript_build

index 39e7396dfb3688295c6450cd7469f5ca595a5b1d..6693f010edf8dd39107f4f7e51bef7d87b381de2 100644 (file)
  */
 
 #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...] <sequence-string>");
 
        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);
        }
index 85bec26536e6dccb9eb5953a4de9885f9185c2cc..640a7fde26093802efddcd30f493a288a750a034 100644 (file)
@@ -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',