Move messages.c to libbb. Make each string in messages.c be its own .o file.
[oweals/busybox.git] / ifconfig.c
index daf1894581c248682bd65f137c0b607f5ff03b47..61d73f56bf925986713af9526b62e1487efc790d 100644 (file)
@@ -15,7 +15,7 @@
  * Foundation;  either  version 2 of the License, or  (at
  * your option) any later version.
  *
- * $Id: ifconfig.c,v 1.6 2001/03/09 23:06:15 mjn3 Exp $
+ * $Id: ifconfig.c,v 1.10 2001/03/26 16:26:16 mjn3 Exp $
  *
  */
 
@@ -26,7 +26,7 @@
  * converting to a table-driven approach.  Added several (optional)
  * args missing from initial port.
  *
- * Still missing:  media.
+ * Still missing:  media, tunnel.
  */
 
 #include <stdio.h>
@@ -234,7 +234,8 @@ static int in_ether(char *bufp, struct sockaddr *sap);
 #endif
 
 #ifdef BB_FEATURE_IFCONFIG_STATUS
-extern int display_interfaces(void);
+extern int interface_opt_a;
+extern int display_interfaces(char *ifname);
 #endif
 
 /*
@@ -261,11 +262,23 @@ int ifconfig_main(int argc, char **argv)
        goterr = 0;
        did_flags = 0;
 
-       if(argc < 2) {
+       /* skip argv[0] */
+       ++argv;
+       --argc;
+
+#ifdef BB_FEATURE_IFCONFIG_STATUS
+       if ((argc > 0) && (strcmp(*argv,"-a") == 0)) {
+               interface_opt_a = 1;
+               --argc;
+               ++argv;
+       }
+#endif
+
+       if(argc <= 1) {
 #ifdef BB_FEATURE_IFCONFIG_STATUS
-               return(display_interfaces());
+               return display_interfaces(argc ? *argv : NULL);
 #else
-               show_usage();
+               error_msg_and_die( "ifconfig was not compiled with interface status display support.");
 #endif
        }
 
@@ -274,10 +287,6 @@ int ifconfig_main(int argc, char **argv)
                perror_msg_and_die("socket");
        }
 
-       /* skip argv[0] */
-       argc--;
-       argv++;
-
        /* get interface name */
        safe_strncpy(ifr.ifr_name, *argv, IFNAMSIZ);
 
@@ -290,7 +299,7 @@ int ifconfig_main(int argc, char **argv)
                        mask = M_MASK;          /*    set the appropriate mask. */
                }
                for (op = OptArray ; op->name ; op++) { /* Find table entry. */
-                       if (!strcmp(p,op->name)) { /* If name matches... */
+                       if (strcmp(p,op->name) == 0) { /* If name matches... */
                                if ((mask &= op->flags)) { /* set the mask and go. */
                                    goto FOUND_ARG;;
                                }
@@ -463,9 +472,9 @@ in_ether(char *bufp, struct sockaddr *sap)
                        if (c >= '0' && c <= '9') {
                                c -= '0';
                        } else if (c >= 'a' && c <= 'f') {
-                               c -= ('a' + 10);
+                               c -= ('a' - 10);
                        } else if (c >= 'A' && c <= 'F') {
-                               c -= ('A' + 10);
+                               c -= ('A' - 10);
                        } else if (j && (c == ':' || c == 0)) {
                                break;
                        } else {