pscan: new applet (portscanner). ~1350 bytes. By Tito <farmatito@tiscali.it>
[oweals/busybox.git] / networking / libiproute / ip_parse_common_args.c
index ac9d9491639f0724fe027c4140e52d52c56aafe2..cea5b47539d55cb4ce9ed027cae1de5f80006512 100644 (file)
@@ -1,3 +1,4 @@
+/* vi: set sw=4 ts=4: */
 /*
  * ip.c                "ip" utility frontend.
  *
  * Rani Assaf <rani@magic.metawire.com> 980929:        resolve addresses
  */
 
-#include <string.h>
-
+#include "ip_common.h"  /* #include "libbb.h" is inside */
 #include "utils.h"
-#include "ip_common.h"
-
-#include "busybox.h"
 
 int preferred_family = AF_UNSPEC;
-int oneline = 0;
-char * _SL_ = NULL;
+smallint oneline;
+char _SL_;
 
 void ip_parse_common_args(int *argcp, char ***argvp)
 {
@@ -34,7 +31,8 @@ void ip_parse_common_args(int *argcp, char ***argvp)
                char *opt = argv[1];
 
                if (strcmp(opt,"--") == 0) {
-                       argc--; argv++;
+                       argc--;
+                       argv++;
                        break;
                }
 
@@ -47,6 +45,8 @@ void ip_parse_common_args(int *argcp, char ***argvp)
                if (matches(opt, "-family") == 0) {
                        argc--;
                        argv++;
+                       if (!argv[1])
+                               bb_show_usage();
                        if (strcmp(argv[1], "inet") == 0)
                                preferred_family = AF_INET;
                        else if (strcmp(argv[1], "inet6") == 0)
@@ -54,7 +54,7 @@ void ip_parse_common_args(int *argcp, char ***argvp)
                        else if (strcmp(argv[1], "link") == 0)
                                preferred_family = AF_PACKET;
                        else
-                               invarg(argv[1], "invalid protocol family");
+                               invarg(argv[1], "protocol family");
                } else if (strcmp(opt, "-4") == 0) {
                        preferred_family = AF_INET;
                } else if (strcmp(opt, "-6") == 0) {
@@ -64,9 +64,12 @@ void ip_parse_common_args(int *argcp, char ***argvp)
                } else if (matches(opt, "-oneline") == 0) {
                        ++oneline;
                } else {
-                       show_usage();
+                       bb_show_usage();
                }
-               argc--; argv++;
+               argc--;
+               argv++;
        }
-       _SL_ = oneline ? "\\" : "\n" ;
+       _SL_ = oneline ? '\\' : '\n' ;
+       *argcp = argc;
+       *argvp = argv;
 }