bug-inetutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-inetutils] Argpifying ifconfig.


From: Debarshi 'Rishi' Ray
Subject: Re: [bug-inetutils] Argpifying ifconfig.
Date: Thu, 5 Apr 2007 23:36:46 +0530

Here (http://glug-nith.org/~rishi/download/src/ifconfig-argp.diff) is
the latest version of the 'diff -rNp'.

The good thing about this one is that it is able to parse a mixture of
old-style and new style arguments.

eg., # ifconfig lo netmask 255.255.0.0 172.16.0.1
# ifconfig lo -m 255.255.0.0 -a 172.16.0.1
# ifconfig -i lo netmask 255.255.0.0 172.16.0.1
Will all have the same results.

To do this we need to parse the command line arguments in the same
order in they were passed. Otherwise if the new-style (or optional)
arguments are parsed before the old-style (non-optional) arguments
then it leads to an error. See the second example, where the interface
name is a traditional-style argument. The -m and -a options can not be
parsed before the interface name.

To facilitate this "in order" parsing, we have to modify the way we
were handling these old-style arguments. Previously we were passing
the entire array of unparsed old-style arguments to
system_parse_opt_rest. Since we are parsing "in order" and the old and
new style arguments can be mixed up, we need to parse one old-style
argument at a time. ie. every time we encounter ARGP_KEY_ARG we must
parse the value of arg encountered by parse_opt. This requires a
modification of system_parse_opt_rest. Incidentally this new
system_parse_opt_rest is smaller than the previous one.

I have only made the change for linux.c. If this is agreeable I can do
the same for generic.c, hpux.c, solaris.c, etc..

I changed the second parameter of system_parse_opt to int from char to
handle system options that do not have a character as their short
options.

-extern int system_parse_opt (struct ifconfig **ifp, char option,
+extern int system_parse_opt (struct ifconfig **ifp, int option,
                             char *optarg);

I have some minor modifications, suggested here, to incorporate, but I
thought I will let you have a look at what I have till now.

Happy hacking,
Debarshi
--
GPG key ID: 63D4A5A7
Key server: pgp.mit.edu




reply via email to

[Prev in Thread] Current Thread [Next in Thread]