diff options
author | Andreas Schneider <asn@samba.org> | 2021-01-14 11:03:12 +0100 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2021-06-20 23:26:32 +0000 |
commit | a8052d70cbbef61a081fe74fd898b5c25c973875 (patch) | |
tree | 8e1fa6d79342a91a0e2f713817c12d158273f412 /librpc | |
parent | 70a09d2cee776dc5a5e99d0bb682e92e90de3f8f (diff) | |
download | samba-a8052d70cbbef61a081fe74fd898b5c25c973875.tar.gz |
librpc:tools: Migrate ndrdump to new cmdline option parser
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'librpc')
-rw-r--r-- | librpc/tools/ndrdump.c | 37 | ||||
-rw-r--r-- | librpc/tools/wscript_build | 2 |
2 files changed, 29 insertions, 10 deletions
diff --git a/librpc/tools/ndrdump.c b/librpc/tools/ndrdump.c index ceccf75145b..ed9198f145d 100644 --- a/librpc/tools/ndrdump.c +++ b/librpc/tools/ndrdump.c @@ -24,7 +24,7 @@ #include "librpc/ndr/libndr.h" #include "librpc/ndr/ndr_table.h" #include "librpc/gen_ndr/ndr_dcerpc.h" -#include "lib/cmdline/popt_common.h" +#include "lib/cmdline/cmdline.h" #include "param/param.h" #include "lib/util/base64.h" @@ -316,11 +316,12 @@ static void ndr_print_dummy(struct ndr_print *ndr, const char *format, ...) "Try to print structures that fail to parse (used to develop parsers, segfaults are likely).", NULL }, POPT_COMMON_SAMBA POPT_COMMON_VERSION - {0} + POPT_TABLEEND }; uint32_t highest_ofs; struct dcerpc_sec_verification_trailer *sec_vt = NULL; - + bool ok; + ndr_table_init(); /* Initialise samba stuff */ @@ -328,10 +329,31 @@ static void ndr_print_dummy(struct ndr_print *ndr, const char *format, ...) setlinebuf(stdout); - setup_logging("ndrdump", DEBUG_STDOUT); + mem_ctx = talloc_init("ndrdump.c/main"); + if (mem_ctx == NULL) { + exit(ENOMEM); + } + + 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, + long_options, + 0); + if (pc == NULL) { + DBG_ERR("Failed to setup popt context!\n"); + TALLOC_FREE(mem_ctx); + exit(1); + } - pc = poptGetContext("ndrdump", argc, argv, long_options, 0); - poptSetOtherOptionHelp( pc, "<pipe|uuid> <format> <in|out|struct> [<filename>]"); @@ -427,9 +449,6 @@ static void ndr_print_dummy(struct ndr_print *ndr, const char *format, ...) } } - - mem_ctx = talloc_init("ndrdump"); - st = talloc_zero_size(mem_ctx, f->struct_size); if (!st) { printf("Unable to allocate %d bytes for %s structure\n", diff --git a/librpc/tools/wscript_build b/librpc/tools/wscript_build index a64747057c7..3f2f95007d5 100644 --- a/librpc/tools/wscript_build +++ b/librpc/tools/wscript_build @@ -3,5 +3,5 @@ bld.SAMBA_BINARY('ndrdump', source='ndrdump.c', manpages='ndrdump.1', - deps='samba-hostconfig samba-util popt POPT_SAMBA ndr-table samba-errors NDR_DCERPC' + deps='samba-hostconfig samba-util popt CMDLINE_S4 ndr-table samba-errors NDR_DCERPC' ) |