Ignore:
Timestamp:
Nov 4, 2007, 3:16:40 AM (17 years ago)
Author:
Bruno Cornec
Message:

Update to busybox 1.7.2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.5/mindi-busybox/networking/libiproute/ip_parse_common_args.c

    r821 r1765  
     1/* vi: set sw=4 ts=4: */
    12/*
    23 * ip.c     "ip" utility frontend.
     
    1516 */
    1617
    17 #include <string.h>
    18 
    19 #include "libbb.h"
     18#include "ip_common.h"  /* #include "libbb.h" is inside */
    2019#include "utils.h"
    21 #include "ip_common.h"
    22 
    2320
    2421int preferred_family = AF_UNSPEC;
    25 int oneline = 0;
    26 char * _SL_ = NULL;
     22smallint oneline;
     23char _SL_;
    2724
    2825void ip_parse_common_args(int *argcp, char ***argvp)
     
    3027    int argc = *argcp;
    3128    char **argv = *argvp;
     29    static const char ip_common_commands[] ALIGN1 =
     30        "-family\0""inet\0""inet6\0""link\0"
     31        "-4\0""-6\0""-0\0""-oneline\0";
     32    enum {
     33        ARG_family = 1,
     34        ARG_inet,
     35        ARG_inet6,
     36        ARG_link,
     37        ARG_IPv4,
     38        ARG_IPv6,
     39        ARG_packet,
     40        ARG_oneline
     41    };
     42    smalluint arg;
    3243
    3344    while (argc > 1) {
     
    3546
    3647        if (strcmp(opt,"--") == 0) {
    37             argc--; argv++;
     48            argc--;
     49            argv++;
    3850            break;
    3951        }
    40 
    4152        if (opt[0] != '-')
    4253            break;
    43 
    4454        if (opt[1] == '-')
    4555            opt++;
    46 
    47         if (matches(opt, "-family") == 0) {
     56        arg = index_in_strings(ip_common_commands, opt) + 1;
     57        if (arg == ARG_family) {
    4858            argc--;
    4959            argv++;
    50             if (! argv[1])
    51                 bb_show_usage();
    52             if (strcmp(argv[1], "inet") == 0)
     60            if (!argv[1])
     61                bb_show_usage();
     62            arg = index_in_strings(ip_common_commands, argv[1]) + 1;
     63            if (arg == ARG_inet)
    5364                preferred_family = AF_INET;
    54             else if (strcmp(argv[1], "inet6") == 0)
     65            else if (arg == ARG_inet6)
    5566                preferred_family = AF_INET6;
    56             else if (strcmp(argv[1], "link") == 0)
     67            else if (arg == ARG_link)
    5768                preferred_family = AF_PACKET;
    5869            else
    5970                invarg(argv[1], "protocol family");
    60         } else if (strcmp(opt, "-4") == 0) {
     71        } else if (arg == ARG_IPv4) {
    6172            preferred_family = AF_INET;
    62         } else if (strcmp(opt, "-6") == 0) {
     73        } else if (arg == ARG_IPv6) {
    6374            preferred_family = AF_INET6;
    64         } else if (strcmp(opt, "-0") == 0) {
     75        } else if (arg == ARG_packet) {
    6576            preferred_family = AF_PACKET;
    66         } else if (matches(opt, "-oneline") == 0) {
     77        } else if (arg == ARG_oneline) {
    6778            ++oneline;
    6879        } else {
    6980            bb_show_usage();
    7081        }
    71         argc--; argv++;
     82        argc--;
     83        argv++;
    7284    }
    73     _SL_ = oneline ? "\\" : "\n" ;
     85    _SL_ = oneline ? '\\' : '\n';
    7486    *argcp = argc;
    7587    *argvp = argv;
Note: See TracChangeset for help on using the changeset viewer.