r18915: fix usage of popt, do make -W setting the recursive flag on SuSE 10.1
authorStefan Metzmacher <metze@samba.org>
Tue, 26 Sep 2006 10:34:40 +0000 (10:34 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:20:21 +0000 (14:20 -0500)
metze

source/utils/nmblookup.c

index 3192b0924c3d2dc11bf590b3a1c79df21e553949..e9c8c221669f067614171c4a8924bcb58313ca8e 100644 (file)
@@ -258,45 +258,84 @@ static BOOL process_one(const char *name)
 /*
   main program
 */
-int main(int argc,char *argv[])
+int main(int argc, const char *argv[])
 {
        BOOL ret = True;
        poptContext pc;
+       int opt;
+       enum {
+               OPT_BROADCAST_ADDRESS   = 1000,
+               OPT_UNICAST_ADDRESS,
+               OPT_FIND_MASTER,
+               OPT_WINS_LOOKUP,
+               OPT_NODE_STATUS,
+               OPT_ROOT_PORT,
+               OPT_LOOKUP_BY_IP,
+               OPT_CASE_SENSITIVE
+       };
        struct poptOption long_options[] = {
                POPT_AUTOHELP
-               { "broadcast", 'B', POPT_ARG_STRING, &options.broadcast_address, 
-                 'B', "Specify address to use for broadcasts", "BROADCAST-ADDRESS" },
+               { "broadcast", 'B', POPT_ARG_STRING, NULL, OPT_BROADCAST_ADDRESS,
+                 "Specify address to use for broadcasts", "BROADCAST-ADDRESS" },
 
-               { "unicast", 'U', POPT_ARG_STRING, &options.unicast_address, 
-                 'U', "Specify address to use for unicast" },
+               { "unicast", 'U', POPT_ARG_STRING, NULL, OPT_UNICAST_ADDRESS,
+                 "Specify address to use for unicast", NULL },
 
-               { "master-browser", 'M', POPT_ARG_VAL, &options.find_master, 
-                 True, "Search for a master browser" },
+               { "master-browser", 'M', POPT_ARG_NONE, NULL, OPT_FIND_MASTER,
+                 "Search for a master browser", NULL },
 
-               { "wins", 'W', POPT_ARG_VAL, &options.wins_lookup, True, "Do a WINS lookup" },
+               { "wins", 'W', POPT_ARG_NONE, NULL, OPT_WINS_LOOKUP,
+                 "Do a WINS lookup", NULL },
 
-               { "status", 'S', POPT_ARG_VAL, &options.node_status
-                 True, "Lookup node status as well" },
+               { "status", 'S', POPT_ARG_NONE, NULL, OPT_NODE_STATUS
+                 "Lookup node status as well", NULL },
 
-               { "root-port", 'r', POPT_ARG_VAL, &options.root_port
-                 True, "Use root port 137 (Win95 only replies to this)" },
+               { "root-port", 'r', POPT_ARG_NONE, NULL, OPT_ROOT_PORT
+                 "Use root port 137 (Win95 only replies to this)", NULL },
 
-               { "lookup-by-ip", 'A', POPT_ARG_VAL, &options.lookup_by_ip
-                 True, "Do a node status on <name> as an IP Address" },
+               { "lookup-by-ip", 'A', POPT_ARG_NONE, NULL, OPT_LOOKUP_BY_IP
+                 "Do a node status on <name> as an IP Address", NULL },
 
-               { "case-sensitive", 0, POPT_ARG_VAL, &options.case_sensitive
-                 True, "Don't uppercase the name before sending" },
+               { "case-sensitive", 0, POPT_ARG_NONE, NULL, OPT_CASE_SENSITIVE
+                 "Don't uppercase the name before sending", NULL },
 
                POPT_COMMON_SAMBA
                { 0, 0, 0, 0 }
        };
        
-       pc = poptGetContext("nmblookup", argc, (const char **)argv, long_options, 
+       pc = poptGetContext("nmblookup", argc, argv, long_options, 
                            POPT_CONTEXT_KEEP_FIRST);
-       
+
        poptSetOtherOptionHelp(pc, "<NODE> ...");
 
-       while ((poptGetNextOpt(pc) != -1)) /* noop */ ;
+       while ((opt = poptGetNextOpt(pc)) != -1) {
+               switch(opt) {
+               case OPT_BROADCAST_ADDRESS:
+                       options.broadcast_address = poptGetOptArg(pc);
+                       break;
+               case OPT_UNICAST_ADDRESS:
+                       options.unicast_address = poptGetOptArg(pc);
+                       break;
+               case OPT_FIND_MASTER:
+                       options.find_master = True;
+                       break;
+               case OPT_WINS_LOOKUP:
+                       options.wins_lookup = True;
+                       break;
+               case OPT_NODE_STATUS:
+                       options.node_status = True;
+                       break;
+               case OPT_ROOT_PORT:
+                       options.root_port = True;
+                       break;
+               case OPT_LOOKUP_BY_IP:
+                       options.lookup_by_ip = True;
+                       break;
+               case OPT_CASE_SENSITIVE:
+                       options.case_sensitive = True;
+                       break;
+               }
+       }
 
        /* swallow argv[0] */
        poptGetArg(pc);