Ignore:
Timestamp:
Feb 25, 2011, 9:26:54 PM (13 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
File:
1 edited

Legend:

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

    r1765 r2725  
    11/* vi: set sw=4 ts=4: */
    22/*
    3  * ip.c     "ip" utility frontend.
     3 * This program is free software; you can redistribute it and/or
     4 * modify it under the terms of the GNU General Public License
     5 * as published by the Free Software Foundation; either version
     6 * 2 of the License, or (at your option) any later version.
    47 *
    5  *      This program is free software; you can redistribute it and/or
    6  *      modify it under the terms of the GNU General Public License
    7  *      as published by the Free Software Foundation; either version
    8  *      2 of the License, or (at your option) any later version.
    9  *
    10  * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
    11  *
     8 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
    129 *
    1310 * Changes:
    1411 *
    15  * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses
     12 * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses
    1613 */
    1714
     
    1916#include "utils.h"
    2017
    21 int preferred_family = AF_UNSPEC;
     18family_t preferred_family = AF_UNSPEC;
    2219smallint oneline;
    2320char _SL_;
    2421
    25 void ip_parse_common_args(int *argcp, char ***argvp)
     22char** FAST_FUNC ip_parse_common_args(char **argv)
    2623{
    27     int argc = *argcp;
    28     char **argv = *argvp;
    2924    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";
     25        "oneline" "\0"
     26        "family" "\0"
     27        "4" "\0"
     28        "6" "\0"
     29        "0" "\0"
     30        ;
    3231    enum {
    33         ARG_family = 1,
    34         ARG_inet,
    35         ARG_inet6,
    36         ARG_link,
     32        ARG_oneline,
     33        ARG_family,
    3734        ARG_IPv4,
    3835        ARG_IPv6,
    3936        ARG_packet,
    40         ARG_oneline
    4137    };
    42     smalluint arg;
     38    static const family_t af_numbers[] = { AF_INET, AF_INET6, AF_PACKET };
     39    int arg;
    4340
    44     while (argc > 1) {
    45         char *opt = argv[1];
     41    while (*argv) {
     42        char *opt = *argv;
    4643
    47         if (strcmp(opt,"--") == 0) {
    48             argc--;
    49             argv++;
    50             break;
    51         }
    5244        if (opt[0] != '-')
    5345            break;
    54         if (opt[1] == '-')
     46        opt++;
     47        if (opt[0] == '-') {
    5548            opt++;
    56         arg = index_in_strings(ip_common_commands, opt) + 1;
     49            if (!opt[0]) { /* "--" */
     50                argv++;
     51                break;
     52            }
     53        }
     54        arg = index_in_substrings(ip_common_commands, opt);
     55        if (arg < 0)
     56            bb_show_usage();
     57        if (arg == ARG_oneline) {
     58            oneline = 1;
     59            argv++;
     60            continue;
     61        }
    5762        if (arg == ARG_family) {
    58             argc--;
     63            static const char families[] ALIGN1 =
     64                "inet" "\0" "inet6" "\0" "link" "\0";
    5965            argv++;
    60             if (!argv[1])
     66            if (!*argv)
    6167                bb_show_usage();
    62             arg = index_in_strings(ip_common_commands, argv[1]) + 1;
    63             if (arg == ARG_inet)
    64                 preferred_family = AF_INET;
    65             else if (arg == ARG_inet6)
    66                 preferred_family = AF_INET6;
    67             else if (arg == ARG_link)
    68                 preferred_family = AF_PACKET;
    69             else
    70                 invarg(argv[1], "protocol family");
    71         } else if (arg == ARG_IPv4) {
    72             preferred_family = AF_INET;
    73         } else if (arg == ARG_IPv6) {
    74             preferred_family = AF_INET6;
    75         } else if (arg == ARG_packet) {
    76             preferred_family = AF_PACKET;
    77         } else if (arg == ARG_oneline) {
    78             ++oneline;
     68            arg = index_in_strings(families, *argv);
     69            if (arg < 0)
     70                invarg(*argv, "protocol family");
     71            /* now arg == 0, 1 or 2 */
    7972        } else {
    80             bb_show_usage();
     73            arg -= ARG_IPv4;
     74            /* now arg == 0, 1 or 2 */
    8175        }
    82         argc--;
     76        preferred_family = af_numbers[arg];
    8377        argv++;
    8478    }
    8579    _SL_ = oneline ? '\\' : '\n';
    86     *argcp = argc;
    87     *argvp = argv;
     80    return argv;
    8881}
Note: See TracChangeset for help on using the changeset viewer.