source: MondoRescue/branches/stable/mindi-busybox/networking/libiproute/ip_parse_common_args.c@ 821

Last change on this file since 821 was 821, checked in by Bruno Cornec, 18 years ago

Addition of busybox 1.2.1 as a mindi-busybox new package
This should avoid delivering binary files in mindi not built there (Fedora and Debian are quite serious about that)

File size: 1.6 KB
Line 
1/*
2 * ip.c "ip" utility frontend.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 *
9 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
10 *
11 *
12 * Changes:
13 *
14 * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses
15 */
16
17#include <string.h>
18
19#include "libbb.h"
20#include "utils.h"
21#include "ip_common.h"
22
23
24int preferred_family = AF_UNSPEC;
25int oneline = 0;
26char * _SL_ = NULL;
27
28void ip_parse_common_args(int *argcp, char ***argvp)
29{
30 int argc = *argcp;
31 char **argv = *argvp;
32
33 while (argc > 1) {
34 char *opt = argv[1];
35
36 if (strcmp(opt,"--") == 0) {
37 argc--; argv++;
38 break;
39 }
40
41 if (opt[0] != '-')
42 break;
43
44 if (opt[1] == '-')
45 opt++;
46
47 if (matches(opt, "-family") == 0) {
48 argc--;
49 argv++;
50 if (! argv[1])
51 bb_show_usage();
52 if (strcmp(argv[1], "inet") == 0)
53 preferred_family = AF_INET;
54 else if (strcmp(argv[1], "inet6") == 0)
55 preferred_family = AF_INET6;
56 else if (strcmp(argv[1], "link") == 0)
57 preferred_family = AF_PACKET;
58 else
59 invarg(argv[1], "protocol family");
60 } else if (strcmp(opt, "-4") == 0) {
61 preferred_family = AF_INET;
62 } else if (strcmp(opt, "-6") == 0) {
63 preferred_family = AF_INET6;
64 } else if (strcmp(opt, "-0") == 0) {
65 preferred_family = AF_PACKET;
66 } else if (matches(opt, "-oneline") == 0) {
67 ++oneline;
68 } else {
69 bb_show_usage();
70 }
71 argc--; argv++;
72 }
73 _SL_ = oneline ? "\\" : "\n" ;
74 *argcp = argc;
75 *argvp = argv;
76}
Note: See TracBrowser for help on using the repository browser.