r21333: fix POPT handling in ndrdump
authorStefan Metzmacher <metze@samba.org>
Wed, 14 Feb 2007 13:22:09 +0000 (13:22 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:48:14 +0000 (14:48 -0500)
make --validate, --dump-data work again

metze

source/utils/ndrdump.c

index 0261a1c6dfdbd4c921fd91a8e6bb9af228bd77ad..9e224c8137ee494aedf2907a656b4bf1aea8c7e0 100644 (file)
@@ -143,16 +143,18 @@ const struct dcerpc_interface_table *load_iface_from_plugin(const char *plugin,
        void *v_st;
        const char *ctx_filename = NULL;
        const char *plugin = NULL;
-       BOOL validate = False;
-       BOOL dumpdata = False;
+       bool validate = false;
+       bool dumpdata = false;
        int opt;
+       enum {OPT_CONTEXT_FILE=1000, OPT_VALIDATE, OPT_DUMP_DATA, OPT_LOAD_DSO};
        struct poptOption long_options[] = {
-               {"context-file", 'c', POPT_ARG_STRING, &ctx_filename, 0, "In-filename to parse first", "CTX-FILE" },
-               {"validate", 0, POPT_ARG_NONE, &validate, 0, "try to validate the data", NULL },        
-               {"dump-data", 0, POPT_ARG_NONE, &dumpdata, 0, "dump the hex data", NULL },      
-               {"load-dso", 'l', POPT_ARG_STRING, &plugin, 0, "load from shared object file", NULL },
-               POPT_COMMON_SAMBA
                POPT_AUTOHELP
+               {"context-file", 'c', POPT_ARG_STRING, NULL, OPT_CONTEXT_FILE, "In-filename to parse first", "CTX-FILE" },
+               {"validate", 0, POPT_ARG_NONE, NULL, OPT_VALIDATE, "try to validate the data", NULL },  
+               {"dump-data", 0, POPT_ARG_NONE, NULL, OPT_DUMP_DATA, "dump the hex data", NULL },       
+               {"load-dso", 'l', POPT_ARG_STRING, NULL, OPT_LOAD_DSO, "load from shared object file", NULL },
+               POPT_COMMON_SAMBA
+               POPT_COMMON_VERSION
                { NULL }
        };
 
@@ -164,6 +166,20 @@ const struct dcerpc_interface_table *load_iface_from_plugin(const char *plugin,
                pc, "<pipe|uuid> <function> <inout> [<filename>]");
 
        while ((opt = poptGetNextOpt(pc)) != -1) {
+               switch (opt) {
+               case OPT_CONTEXT_FILE:
+                       ctx_filename = poptGetOptArg(pc);
+                       break;
+               case OPT_VALIDATE:
+                       validate = true;
+                       break;
+               case OPT_DUMP_DATA:
+                       dumpdata = true;
+                       break;
+               case OPT_LOAD_DSO:
+                       plugin = poptGetOptArg(pc);
+                       break;
+               }
        }
 
        pipe_name = poptGetArg(pc);