[Top][All Lists]
[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: |
Fri, 6 Apr 2007 02:05:01 +0530 |
Here (http://glug-nith.org/~rishi/download/src/ifconfig-argp.diff) is
the final state of the patch for the time being:
diff -urNp inetutils/ifconfig/Makefile.am inetutils-build/ifconfig/Makefile.am
--- inetutils/ifconfig/Makefile.am 2006-10-12 15:25:06.000000000 +0530
+++ inetutils-build/ifconfig/Makefile.am 2007-04-02 22:47:27.000000000
+0530
@@ -1,4 +1,4 @@
-# Copyright (C) 2005 Free Software Foundation, Inc.
+# Copyright (C) 2005, 2007 Free Software Foundation, Inc.
# This file is part of GNU Inetutils.
#
# GNU Inetutils is free software; you can redistribute it and/or modify
@@ -28,5 +28,5 @@ noinst_HEADERS = ifconfig.h if_index.h f
@PATHDEFS_MAKE@
-INCLUDES = -I$(top_srcdir)/lib -I../lib
+INCLUDES = -I$(top_srcdir)/libinetutils -I$(top_srcdir)/lib -I../lib
LDADD = -L../libinetutils -linetutils ../lib/libgnu.a
diff -urNp inetutils/ifconfig/changeif.c inetutils-build/ifconfig/changeif.c
--- inetutils/ifconfig/changeif.c 2006-10-21 20:54:20.000000000 +0530
+++ inetutils-build/ifconfig/changeif.c 2007-04-06 01:00:44.000000000 +0530
@@ -1,6 +1,6 @@
/* changeif.c -- change the configuration of a network interface
- Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002, 2007 Free Software Foundation, Inc.
Written by Marcus Brinkmann.
@@ -50,13 +50,14 @@
if (!err) \
{ \
fprintf (stderr, "%s: `%s' is not a valid address\n", \
- program_name, addr); \
+ program_invocation_short_name, addr); \
return -1; \
} \
err = ioctl (sfd, SIOCSIF##type, ifr); \
if (err < 0) \
{ \
- fprintf (stderr, "%s: %s failed: %s\n", program_name, \
+ fprintf (stderr, "%s: %s failed: %s\n", \
+ program_invocation_short_name, \
"SIOCSIF" #type, strerror (errno)); \
return -1; \
}
@@ -72,7 +73,7 @@ set_address (int sfd, struct ifreq *ifr,
#ifndef SIOCSIFADDR
fprintf (stderr,
"%s: Don't know how to set an interface address on this system.\n",
- program_name);
+ program_invocation_short_name);
return -1;
#else
char *addr;
@@ -80,14 +81,15 @@ set_address (int sfd, struct ifreq *ifr,
if (!host)
{
- fprintf (stderr, "%s: can not resolve `%s': ", program_name, address);
+ fprintf (stderr, "%s: can not resolve `%s': ",
+ program_invocation_short_name, address);
herror (NULL);
return -1;
}
if (host->h_addrtype != AF_INET)
{
fprintf (stderr, "%s: `%s' refers to an unknown address type",
- program_name, address);
+ program_invocation_short_name, address);
return -1;
}
@@ -107,7 +109,7 @@ set_netmask (int sfd, struct ifreq *ifr,
{
#ifndef SIOCSIFNETMASK
printf ("%s: Don't know how to set an interface netmask on this system.\n",
- program_name);
+ program_invocation_short_name);
return -1;
#else
@@ -124,7 +126,7 @@ set_dstaddr (int sfd, struct ifreq *ifr,
#ifndef SIOCSIFDSTADDR
printf
("%s: Don't know how to set an interface peer address on this system.\n",
- program_name);
+ program_invocation_short_name);
return -1;
#else
SIOCSIF (DSTADDR, dstaddr) if (verbose)
@@ -139,8 +141,8 @@ set_brdaddr (int sfd, struct ifreq *ifr,
{
#ifndef SIOCSIFBRDADDR
printf
- ("%s: Don't know how to set an interface broadcast address on
this system.\n",
- program_name);
+ ("%s: Don't know how to set an interface broadcast address on this "
+ "system.\n", program_invocation_short_name);
return -1;
#else
SIOCSIF (BRDADDR, brdaddr) if (verbose)
@@ -155,7 +157,7 @@ set_mtu (int sfd, struct ifreq *ifr, int
{
#ifndef SIOCSIFMTU
printf ("%s: Don't know how to set the interface mtu on this system.\n",
- program_name);
+ program_invocation_short_name);
return -1;
#else
int err = 0;
@@ -165,7 +167,7 @@ set_mtu (int sfd, struct ifreq *ifr, int
if (err < 0)
{
fprintf (stderr, "%s: SIOCSIFMTU failed: %s\n",
- program_name, strerror (errno));
+ program_invocation_short_name, strerror (errno));
return -1;
}
if (verbose)
@@ -179,7 +181,7 @@ set_metric (int sfd, struct ifreq *ifr,
{
#ifndef SIOCSIFMETRIC
printf ("%s: Don't know how to set the interface metric on this system.\n",
- program_name);
+ program_invocation_short_name);
return -1;
#else
int err = 0;
@@ -189,7 +191,7 @@ set_metric (int sfd, struct ifreq *ifr,
if (err < 0)
{
fprintf (stderr, "%s: SIOCSIFMETRIC failed: %s\n",
- program_name, strerror (errno));
+ program_invocation_short_name, strerror (errno));
return -1;
}
if (verbose)
diff -urNp inetutils/ifconfig/ifconfig.c inetutils-build/ifconfig/ifconfig.c
--- inetutils/ifconfig/ifconfig.c 2006-10-21 20:54:20.000000000 +0530
+++ inetutils-build/ifconfig/ifconfig.c 2007-04-06 00:52:19.000000000 +0530
@@ -1,6 +1,6 @@
/* ifconfig.c -- network interface configuration utility
- Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002, 2007 Free Software Foundation, Inc.
Written by Marcus Brinkmann.
@@ -60,14 +60,17 @@ main (int argc, char *argv[])
int sfd;
struct ifconfig *ifp;
- parse_opt (argc, argv);
+ /* Parse command line */
+ if (argp_parse (&argp, argc, argv, ARGP_IN_ORDER, NULL, NULL))
+ exit (1);
sfd = socket (AF_INET, SOCK_STREAM, 0);
if (sfd < 0)
{
fprintf (stderr, "%s: socket error: %s\n",
- program_name, strerror (errno));
- exit (1);
+ program_invocation_short_name,
+ strerror (errno));
+ exit (EXIT_FAILURE);
}
ifp = ifs;
diff -urNp inetutils/ifconfig/options.c inetutils-build/ifconfig/options.c
--- inetutils/ifconfig/options.c 2006-10-21 20:54:20.000000000 +0530
+++ inetutils-build/ifconfig/options.c 2007-04-06 01:50:58.000000000 +0530
@@ -1,6 +1,6 @@
/* options.c -- process the command line options
- Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002, 2007 Free Software Foundation, Inc.
Written by Marcus Brinkmann.
@@ -44,14 +44,64 @@
#include <sys/socket.h>
#include <net/if.h>
+#include "libinetutils.h"
#include "ifconfig.h"
+struct argp_state *state;
+
+ARGP_PROGRAM_DATA("ifconfig", "2007", "Marcus Brinkmann")
+
+const char args_doc[] = "[SYSTEM OPTION...]";
+const char doc[] = "Configure network interfaces.";
+
+/* Define keys for long options that do not have short counterparts. */
+enum {
+ ARG_BRDADDR = 256,
+ ARG_METRIC,
+ ARG_FORMAT
+};
+
+static struct argp_option argp_options[] = {
+#define GRP 0
+ {NULL, 0, NULL, 0, "Options are:", GRP},
+ {"address", 'a', "ADDR", 0, "Set interface address to ADDR", GRP+1},
+ {"interface", 'i', "NAME", 0, "Configure network interface NAME", GRP+1},
+ {"dstaddr", 'd', "DSTADDR", 0, "Set destination (peer) address to DSTADDR",
+ GRP+1},
+ {"peer", 'p', "DSTADDR", OPTION_ALIAS, "", GRP+1},
+ {"broadcast", 'b', "BRDADDR", 0, "Set broadcast address to BRDADDR", GRP+1},
+ {"brdaddr", ARG_BRDADDR, "BRDADDR", OPTION_ALIAS, "", GRP+1},
+ {"mtu", 'M', "N", 0, "Set mtu of interface to N", GRP+1},
+ {"metric", ARG_METRIC, "N", 0, "Set metric of interface to N", GRP+1},
+ {"netmask", 'm', "MASK", 0, "Set netmask to MASK", GRP+1},
+ {"format", ARG_FORMAT, "FORMAT", 0, "Select output format (or set back to "
+ "default)", GRP+1},
+ {"verbose", 'v', NULL, 0, "Output information when configuring interface.",
+ GRP+1},
+#undef GRP
+#ifdef SYSTEM_LONG_OPTIONS
+# define GRP 10
+ {NULL, 0, NULL, 0, "System options are:", GRP},
+ SYSTEM_LONG_OPTIONS
+# undef GRP
+#endif
+#ifdef SYSTEM_OLD_INTERFACE
+# define GRP 20
+ {NULL, 0, NULL, 0, "Alternative, backward compatible interface
(discouraged):", GRP},
+ SYSTEM_OLD_INTERFACE
+# undef GRP
+#endif
+ {NULL}
+};
+
/* Be verbose about actions. */
int verbose;
/* Array of all interfaces on the command line. */
struct ifconfig *ifs;
+static struct ifconfig *ifp;
+
/* Size of IFS. */
int nifs;
@@ -135,77 +185,6 @@ struct format formats[] = {
/* Default format. */
const char *default_format;
-/* The "+" is necessary to avoid parsing of system specific pseudo options
- like `-promisc'. */
-static const char *short_options = "+i:a:m:d:p:b:M:vV";
-
-static struct option long_options[] = {
-#ifdef SYSTEM_LONG_OPTIONS
- SYSTEM_LONG_OPTIONS
-#endif
- {"verbose", no_argument, 0, 'v'},
- {"version", no_argument, 0, 'V'},
- {"help", no_argument, 0, '&'},
- {"interface", required_argument, 0, 'i'},
- {"address", required_argument, 0, 'a'},
- {"netmask", required_argument, 0, 'm'},
- {"dstaddr", required_argument, 0, 'd'},
- {"peer", required_argument, 0, 'p'},
- {"brdaddr", required_argument, 0, 'b'},
- {"broadcast", required_argument, 0, 'B'},
- {"mtu", required_argument, 0, 'M'},
- {"metric", required_argument, 0, '3'},
- {"format", optional_argument, 0, '4'},
- {0, 0, 0, 0}
-};
-
-void
-usage (int err)
-{
- if (err != EXIT_SUCCESS)
- {
- fprintf (stderr, "Usage: %s [OPTION]...%s\n", program_name,
- system_help ? " [SYSTEM OPTION]..." : "");
- fprintf (stderr, "Try `%s --help' for more information.\n",
- program_name);
- }
- else
- {
- fprintf (stdout, "Usage: %s [OPTION]...%s\n", program_name,
- system_help ? " [SYSTEM OPTION]..." : "");
- puts ("Configure network interfaces.\n\n\
-Options are:\n\
- -i, --interface NAME Configure network interface NAME\n\
- -a, --address ADDR Set interface address to ADDR\n\
- -m, --netmask MASK Set netmask to MASK\n\
- -d, --dstaddr DSTADDR,\n\
- -p, --peer DSTADDR Set destination (peer) address to DSTADDR\n\
- -b, --broadcast BRDADDR,\n\
- --brdaddr BRDADDR Set broadcast address to BRDADDR\n\
- -M, --mtu N Set mtu of interface to N\n\
- --metric N Set metric of interface to N\n\
- --format=FORMAT Select output format (or set back to default)");
-
- if (system_help_options)
- puts (system_help_options);
- puts ("\
- -v, --verbose Output information when configuring interface.\n\
- --help Display this help and exit\n\
- -V, --version Output version information and exit");
-
- if (system_help)
- {
- puts ("\nSystem options are:");
- puts (system_help);
- puts ("\
-The system options provide an alternative, backward compatible command line\n\
-interface. It is discouraged and should not be used.");
- }
- fprintf (stdout, "\nSubmit bug reports to %s.\n", PACKAGE_BUGREPORT);
- }
- exit (err);
-}
-
struct ifconfig *
parse_opt_new_ifs (char *name)
{
@@ -213,11 +192,10 @@ parse_opt_new_ifs (char *name)
ifs = realloc (ifs, ++nifs * sizeof (struct ifconfig));
if (!ifs)
- {
- fprintf (stderr, "%s: can't get memory for interface "
- "configuration: %s\n", program_name, strerror (errno));
- exit (EXIT_FAILURE);
- }
+ argp_failure (state, EXIT_FAILURE, errno,
+ "can't get memory for interface configuration: %s",
+ strerror (errno));
+
ifp = &ifs[nifs - 1];
*ifp = ifconfig_initializer;
ifp->name = name;
@@ -229,18 +207,11 @@ void
\
parse_opt_set_##field (struct ifconfig *ifp, char *addr) \
{ \
if (!ifp) \
- { \
- fprintf (stderr, "%s: no interface specified for " #fname \
- " `%s'\n", program_name, addr); \
- usage (EXIT_FAILURE); \
- } \
+ argp_error (state, "no interface specified for " #fname \
+ " `%s'", addr); \
if (ifp->valid & IF_VALID_##fvalid) \
- { \
- fprintf (stderr, "%s: only one " #fname \
- " allowed for interface `%s'\n", \
- program_name, ifp->name); \
- usage (EXIT_FAILURE); \
- } \
+ argp_error (state, "only one " #fname \
+ " allowed for interface `%s'", ifp->name); \
ifp->field = addr; \
ifp->valid |= IF_VALID_##fvalid; \
}
@@ -255,26 +226,15 @@ parse_opt_set_##field (struct ifconfig *
{ \
char *end; \
if (!ifp) \
- { \
- fprintf (stderr, "%s: no interface specified for " #fname \
- " `%s'\n", program_name, arg); \
- usage (EXIT_FAILURE); \
- } \
+ argp_error (state, "no interface specified for " #fname \
+ " `%s'", arg); \
if (ifp->valid & IF_VALID_##fvalid) \
- { \
- fprintf (stderr, "%s: only one " #fname \
- " allowed for interface `%s'\n", \
- program_name, ifp->name); \
- usage (EXIT_FAILURE); \
- } \
+ argp_error (state, "only one " #fname \
+ " allowed for interface `%s'", ifp->name); \
ifp->field = strtol (arg, &end, 0); \
if (*arg == '\0' || *end != '\0') \
- { \
- fprintf (stderr, "%s: mtu value `%s' for interface `%s' " \
- "is not a number.\n", \
- program_name, optarg, ifp->name); \
- exit (EXIT_FAILURE); \
- } \
+ argp_error (state, "mtu value `%s' for interface `%s' " \
+ "is not a number", arg, ifp->name); \
ifp->valid |= IF_VALID_##fvalid; \
}
PARSE_OPT_SET_INT (mtu, mtu value, MTU)
@@ -282,20 +242,15 @@ PARSE_OPT_SET_INT (metric, metric value,
void parse_opt_set_af (struct ifconfig *ifp, char *af)
{
if (!ifp)
- {
- fprintf (stderr, "%s: no interface specified for address"
- " family `%s'\n", program_name, af);
- usage (EXIT_FAILURE);
- }
+ argp_error (state, "no interface specified for address "
+ "family `%s'", af);
if (!strcasecmp (af, "inet"))
ifp->af = AF_INET;
else
- {
- fprintf (stderr, "%s: unknown address family `%s' for interface `%s'"
- " is not a number.\n", program_name, optarg, ifp->name);
- exit (EXIT_FAILURE);
- }
+ argp_failure (state, EXIT_FAILURE, 0,
+ "unknown address family `%s' for interface `%s' "
+ "is not a number", af, ifp->name);
ifp->valid |= IF_VALID_AF;
}
@@ -335,90 +290,11 @@ parse_opt_finalize (struct ifconfig *ifp
}
}
-char *program_name;
-
void
-parse_opt (int argc, char *argv[])
+parse_opt_success (void)
{
- int option;
- struct ifconfig *ifp = ifs;
-
- program_name = argv[0];
-
- parse_opt_set_default_format (NULL);
-
- while ((option = getopt_long (argc, argv, short_options,
- long_options, 0)) != EOF)
- {
- /* XXX: Allow new ifs be created by system_parse_opt. Provide
- helper function for that (esp necessary for system specific
- parsing of remaining args. */
- if (system_parse_opt (&ifp, option, optarg))
- continue;
-
- switch (option)
- {
- case 'i': /* Interface name. */
- parse_opt_finalize (ifp);
- ifp = parse_opt_new_ifs (optarg);
- break;
-
- case 'a': /* Interface address. */
- parse_opt_set_address (ifp, optarg);
- break;
-
- case 'm': /* Interface netmask. */
- parse_opt_set_netmask (ifp, optarg);
- break;
-
- case 'd': /* Interface dstaddr. */
- case 'p':
- parse_opt_set_dstaddr (ifp, optarg);
- break;
-
- case 'b': /* Interface broadcast address. */
- case 'B':
- parse_opt_set_brdaddr (ifp, optarg);
- break;
-
- case 'M': /* Interface MTU. */
- parse_opt_set_mtu (ifp, optarg);
- break;
-
- case '3': /* Interface metric. */
- parse_opt_set_metric (ifp, optarg);
- break;
-
- case '4': /* Output format. */
- parse_opt_set_default_format (optarg);
- break;
-
- case 'v': /* Verbose. */
- verbose = 1;
- break;
-
- case '&': /* Help. */
- usage (EXIT_SUCCESS);
- /* Not reached. */
-
- case 'V': /* Version. */
- printf ("ifconfig (%s) %s\n", PACKAGE_NAME, PACKAGE_VERSION);
- exit (EXIT_SUCCESS);
-
- case '?':
- default:
- usage (EXIT_FAILURE);
- /* Not reached. */
- }
- }
parse_opt_finalize (ifp);
- if (optind < argc)
- {
- if (!system_parse_opt_rest (&ifp, argc - optind, &argv[optind]))
- usage (EXIT_FAILURE);
- parse_opt_finalize (ifp);
- }
if (!ifs)
{
/* No interfaces specified. Get a list of all interfaces. */
@@ -431,11 +307,10 @@ parse_opt (int argc, char *argv[])
ifs = realloc (ifs, ++nifs * sizeof (struct ifconfig));
if (!ifs)
- {
- fprintf (stderr, "%s: can't get memory for interface "
- "configuration: %s\n", program_name, strerror (errno));
- exit (EXIT_FAILURE);
- }
+ argp_failure (state, EXIT_FAILURE, errno,
+ "can't get memory for interface "
+ "configuration: %s\n", strerror (errno));
+
ifp = &ifs[nifs - 1];
*ifp = ifconfig_initializer;
ifp->name = ifnxp->if_name;
@@ -448,3 +323,74 @@ parse_opt (int argc, char *argv[])
(if->if_name) here. */
}
}
+
+error_t
+parse_opt (int key, char *arg, struct argp_state *st)
+{
+ state = st;
+
+ switch (key)
+ {
+ case ARGP_KEY_INIT:
+ ifp = ifs;
+ parse_opt_set_default_format (NULL);
+ break;
+
+ case 'a':
+ parse_opt_set_address (ifp, arg);
+ break;
+
+ case 'b':
+ case 'B':
+ parse_opt_set_brdaddr (ifp, arg);
+ break;
+
+ case 'd':
+ case 'p':
+ parse_opt_set_dstaddr (ifp, arg);
+ break;
+
+ case 'i':
+ parse_opt_finalize (ifp);
+ ifp = parse_opt_new_ifs (arg);
+ break;
+
+ case 'm':
+ parse_opt_set_netmask (ifp, arg);
+ break;
+
+ case 'M':
+ parse_opt_set_mtu (ifp, arg);
+ break;
+
+ case 'v':
+ verbose = 1;
+ break;
+
+ case ARG_METRIC:
+ parse_opt_set_metric (ifp, arg);
+ break;
+
+ case ARG_FORMAT:
+ parse_opt_set_default_format (arg);
+ break;
+
+ case ARGP_KEY_ARG:
+ system_parse_opt_rest (&ifp, arg);
+ break;
+
+ case ARGP_KEY_SUCCESS:
+ parse_opt_success ();
+ break;
+
+ default:
+ if (system_parse_opt (&ifp, key, arg))
+ return 0;
+ else
+ return ARGP_ERR_UNKNOWN;
+ }
+
+ return 0;
+}
+
+struct argp argp = {argp_options, parse_opt, args_doc, doc};
diff -urNp inetutils/ifconfig/options.h inetutils-build/ifconfig/options.h
--- inetutils/ifconfig/options.h 2006-10-21 20:54:20.000000000 +0530
+++ inetutils-build/ifconfig/options.h 2007-04-06 01:04:48.000000000 +0530
@@ -22,6 +22,8 @@
#ifndef IFCONFIG_OPTIONS_H
# define IFCONFIG_OPTIONS_H
+#include <argp.h>
+
# include <sys/types.h>
# include <sys/socket.h>
@@ -60,9 +62,6 @@ struct format
extern struct format formats[];
-/* The name of the program, as invoked on the command line. */
-extern char *program_name;
-
/* Array of interfaces mentioned on the command line. */
extern struct ifconfig *ifs;
extern int nifs;
@@ -70,7 +69,8 @@ extern int nifs;
/* Be verbose about what we do. */
extern int verbose;
-void usage (int err);
+extern struct argp argp;
+
void parse_opt_set_address (struct ifconfig *ifp, char *addr);
void parse_opt_set_brdaddr (struct ifconfig *ifp, char *addr);
void parse_opt_set_dstaddr (struct ifconfig *ifp, char *addr);
@@ -80,6 +80,4 @@ void parse_opt_set_metric (struct ifconf
void parse_opt_set_default_format (const char *format);
void parse_opt_finalize (struct ifconfig *ifp);
-void parse_opt (int argc, char *argv[]);
-
#endif
diff -urNp inetutils/ifconfig/printif.c inetutils-build/ifconfig/printif.c
--- inetutils/ifconfig/printif.c 2006-10-21 20:54:20.000000000 +0530
+++ inetutils-build/ifconfig/printif.c 2007-04-06 01:00:54.000000000 +0530
@@ -1,6 +1,6 @@
/* printif.c -- print an interface configuration
- Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002, 2007 Free Software Foundation, Inc.
Written by Marcus Brinkmann.
@@ -417,7 +417,7 @@ fh_error (format_data_t form, int argc,
void
fh_progname (format_data_t form, int argc, char *argv[])
{
- put_string (form, program_name);
+ put_string (form, program_invocation_short_name);
}
void
@@ -451,7 +451,7 @@ fh_index (format_data_t form, int argc,
if (indx == 0)
{
fprintf (stderr, "%s: No index number found for interface `%s': %s\n",
- program_name, form->name, strerror (errno));
+ program_invocation_short_name, form->name, strerror (errno));
exit (EXIT_FAILURE);
}
*column += printf ("%i", indx);
@@ -476,7 +476,8 @@ fh_addr (format_data_t form, int argc, c
if (ioctl (form->sfd, SIOCGIFADDR, form->ifr) < 0)
{
fprintf (stderr, "%s: SIOCGIFADDR failed for interface `%s': %s\n",
- program_name, form->ifr->ifr_name, strerror (errno));
+ program_invocation_short_name, form->ifr->ifr_name,
+ strerror (errno));
exit (EXIT_FAILURE);
}
else
@@ -505,7 +506,8 @@ fh_netmask (format_data_t form, int argc
if (ioctl (form->sfd, SIOCGIFNETMASK, form->ifr) < 0)
{
fprintf (stderr, "%s: SIOCGIFNETMASK failed for interface `%s': %s\n",
- program_name, form->ifr->ifr_name, strerror (errno));
+ program_invocation_short_name, form->ifr->ifr_name,
+ strerror (errno));
exit (EXIT_FAILURE);
}
else
@@ -545,7 +547,8 @@ fh_brdaddr (format_data_t form, int argc
if (ioctl (form->sfd, SIOCGIFBRDADDR, form->ifr) < 0)
{
fprintf (stderr, "%s: SIOCGIFBRDADDR failed for interface `%s': %s\n",
- program_name, form->ifr->ifr_name, strerror (errno));
+ program_invocation_short_name, form->ifr->ifr_name,
+ strerror (errno));
exit (EXIT_FAILURE);
}
else
@@ -585,7 +588,8 @@ fh_dstaddr (format_data_t form, int argc
if (ioctl (form->sfd, SIOCGIFDSTADDR, form->ifr) < 0)
{
fprintf (stderr, "%s: SIOCGIFDSTADDR failed for interface `%s': %s\n",
- program_name, form->ifr->ifr_name, strerror (errno));
+ program_invocation_short_name, form->ifr->ifr_name,
+ strerror (errno));
exit (EXIT_FAILURE);
}
else
@@ -614,7 +618,8 @@ fh_mtu (format_data_t form, int argc, ch
if (ioctl (form->sfd, SIOCGIFMTU, form->ifr) < 0)
{
fprintf (stderr, "%s: SIOCGIFMTU failed for interface `%s': %s\n",
- program_name, form->ifr->ifr_name, strerror (errno));
+ program_invocation_short_name, form->ifr->ifr_name,
+ strerror (errno));
exit (EXIT_FAILURE);
}
else
@@ -643,7 +648,8 @@ fh_metric (format_data_t form, int argc,
if (ioctl (form->sfd, SIOCGIFMETRIC, form->ifr) < 0)
{
fprintf (stderr, "%s: SIOCGIFMETRIC failed for interface `%s': %s\n",
- program_name, form->ifr->ifr_name, strerror (errno));
+ program_invocation_short_name, form->ifr->ifr_name,
+ strerror (errno));
exit (EXIT_FAILURE);
}
else
@@ -672,7 +678,8 @@ fh_flags (format_data_t form, int argc,
if (ioctl (form->sfd, SIOCGIFFLAGS, form->ifr) < 0)
{
fprintf (stderr, "%s: SIOCGIFFLAGS failed for interface `%s': %s\n",
- program_name, form->ifr->ifr_name, strerror (errno));
+ program_invocation_short_name, form->ifr->ifr_name,
+ strerror (errno));
exit (EXIT_FAILURE);
}
else
diff -urNp inetutils/ifconfig/system.h inetutils-build/ifconfig/system.h
--- inetutils/ifconfig/system.h 2006-10-21 20:54:20.000000000 +0530
+++ inetutils-build/ifconfig/system.h 2007-04-05 23:41:51.000000000 +0530
@@ -1,6 +1,6 @@
/* system.h
- Copyright (C) 2001 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2007 Free Software Foundation, Inc.
Written by Marcus Brinkmann.
@@ -47,7 +47,7 @@ extern const char *system_help_options;
it in IFP. You may create a new struct ifconfig if appropriate,
and store its pointer in IFP to make it the current one.
Return 0 if option was not recognized, otherwise 1. */
-extern int system_parse_opt (struct ifconfig **ifp, char option,
+extern int system_parse_opt (struct ifconfig **ifp, int option,
char *optarg);
/* Parse remaining ARGC arguments ARGV on the command line. IFP has
@@ -55,8 +55,7 @@ extern int system_parse_opt (struct ifco
post-processing, so you are not reliefed from setting IPF is
appropriate.)
Return 0 if all options were not recognized, otherwise 1. */
-extern int system_parse_opt_rest (struct ifconfig **ifp, int argc,
- char *argv[]);
+extern void system_parse_opt_rest (struct ifconfig **ifp, char *arg);
/* Output format support. */
diff -urNp inetutils/ifconfig/system/generic.c
inetutils-build/ifconfig/system/generic.c
--- inetutils/ifconfig/system/generic.c 2006-10-21 20:54:20.000000000 +0530
+++ inetutils-build/ifconfig/system/generic.c 2007-04-04
20:47:03.000000000 +0530
@@ -1,6 +1,6 @@
/* generic.c -- generic system code for ifconfig
- Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002, 2007 Free Software Foundation, Inc.
Written by Marcus Brinkmann.
@@ -39,7 +39,7 @@ const char *system_help;
const char *system_help_options;
int
-system_parse_opt (struct ifconfig **ifp, char option, char *optarg)
+system_parse_opt (struct ifconfig **ifp, int option, char *optarg)
{
return 0;
}
diff -urNp inetutils/ifconfig/system/hpux.c
inetutils-build/ifconfig/system/hpux.c
--- inetutils/ifconfig/system/hpux.c 2006-10-21 20:54:20.000000000 +0530
+++ inetutils-build/ifconfig/system/hpux.c 2007-04-06 02:04:15.000000000
+0530
@@ -1,6 +1,6 @@
/* hpux.c -- HPUX specific code for ifconfig
- Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002, 2007 Free Software Foundation, Inc.
Written by Marcus Brinkmann.
@@ -62,16 +62,8 @@ const char *system_default_format "unix"
const char *system_help_options;
-/* Argument parsing stuff. */
-
-const char *system_help = "\
- NAME [AF]
-or
- NAME AF [ADDR [DSTADDR]] [broadcast BRDADDR]\n\
- [netmask MASK] [metric N]";
-
int
-system_parse_opt (struct ifconfig **ifp, char option, char *optarg)
+system_parse_opt (struct ifconfig **ifp, int option, char *optarg)
{
return 0;
}
@@ -145,17 +137,17 @@ system_parse_opt_rest (struct ifconfig *
{
case EXPECT_BROADCAST:
fprintf (stderr, "%s: option `broadcast' requires an argument\n",
- program_name);
+ program_invocation_short_name);
break;
case EXPECT_NETMASK:
fprintf (stderr, "%s: option `netmask' requires an argument\n",
- program_name);
+ program_invocation_short_name);
break;
case EXPECT_METRIC:
fprintf (stderr, "%s: option `metric' requires an argument\n",
- program_name);
+ program_invocation_short_name);
break;
case EXPECT_NAME:
diff -urNp inetutils/ifconfig/system/hpux.h
inetutils-build/ifconfig/system/hpux.h
--- inetutils/ifconfig/system/hpux.h 2006-10-21 20:54:20.000000000 +0530
+++ inetutils-build/ifconfig/system/hpux.h 2007-04-06 02:04:25.000000000
+0530
@@ -1,6 +1,6 @@
/* hpux.h
- Copyright (C) 2001 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2007 Free Software Foundation, Inc.
Written by Marcus Brinkmann.
@@ -35,6 +35,16 @@ struct system_ifconfig
};
+#define SYSTEM_OLD_INTERFACE \
+ {"ADDR [DSTADDR]", 0, "", OPTION_DOC, "Set interface address to ADDR, " \
+ "and set destination address to DSTADDR (optional)", GRP+1}, \
+ {"AF", 0, "", OPTION_DOC, "Set address family to AF", GRP+1}, \
+ {"NAME", 0, "", OPTION_DOC, "Configure network interface NAME", GRP+1}, \
+ {"broadcast BRDADDR", 0, "", OPTION_DOC, "Set broadcast address to " \
+ "BRDADDR", GRP+1}, \
+ {"netmask MASK", 0, "", OPTION_DOC, "Set netmask to MASK", GRP+1}, \
+ {"metric N", 0, "", OPTION_DOC, "Set metric of interface to N", GRP+1},
+
/* Output format support. */
# define SYSTEM_FORMAT_HANDLER \
diff -urNp inetutils/ifconfig/system/linux.c
inetutils-build/ifconfig/system/linux.c
--- inetutils/ifconfig/system/linux.c 2006-10-21 20:54:20.000000000 +0530
+++ inetutils-build/ifconfig/system/linux.c 2007-04-06 01:47:53.000000000
+0530
@@ -1,6 +1,6 @@
/* linux.c -- Linux specific code for ifconfig
- Copyright (C) 2001, 2002, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002, 2005, 2007 Free Software Foundation, Inc.
Written by Marcus Brinkmann.
@@ -25,6 +25,7 @@
#endif
#include <sys/stat.h>
+#include <stdbool.h>
#include <stdio.h>
#include <errno.h>
@@ -351,7 +352,7 @@ system_fh_hwaddr (format_data_t form, in
if (ioctl (form->sfd, SIOCGIFHWADDR, form->ifr) < 0)
{
fprintf (stderr, "%s: SIOCGIFHWADDR failed for interface `%s': %s\n",
- program_name, form->ifr->ifr_name, strerror (errno));
+ program_invocation_short_name, form->ifr->ifr_name, strerror
(errno));
exit (EXIT_FAILURE);
}
else
@@ -388,7 +389,7 @@ system_fh_hwtype (format_data_t form, in
if (ioctl (form->sfd, SIOCGIFHWADDR, form->ifr) < 0)
{
fprintf (stderr, "%s: SIOCGIFHWADDR failed for interface `%s': %s\n",
- program_name, form->ifr->ifr_name, strerror (errno));
+ program_invocation_short_name, form->ifr->ifr_name, strerror
(errno));
exit (EXIT_FAILURE);
}
else
@@ -425,7 +426,7 @@ system_fh_txqlen (format_data_t form, in
if (ioctl (form->sfd, SIOCGIFTXQLEN, form->ifr) < 0)
{
fprintf (stderr, "%s: SIOCGIFTXQLEN failed for interface `%s': %s\n",
- program_name, form->ifr->ifr_name, strerror (errno));
+ program_invocation_short_name, form->ifr->ifr_name, strerror
(errno));
exit (EXIT_FAILURE);
}
else
@@ -437,16 +438,6 @@ system_fh_txqlen (format_data_t form, in
}
-/* Argument parsing stuff. */
-
-const char *system_help = "\
- NAME [ADDR] [broadcast BRDADDR]\n\
- [pointopoint|dstaddr DSTADDR] [netmask MASK]\n\
- [metric N] [mtu N] [txqueuelen N]";
-
-const char *system_help_options =
- " --txqlen N Set transmit queue length to N";
-
void
system_parse_opt_set_txqlen (struct ifconfig *ifp, char *arg)
{
@@ -455,8 +446,8 @@ system_parse_opt_set_txqlen (struct ifco
if (!ifp)
{
fprintf (stderr, "%s: no interface specified for txqlen"
- " `%s'\n", program_name, arg);
- usage (EXIT_FAILURE);
+ " `%s'\n", program_invocation_short_name, arg);
+ exit (EXIT_FAILURE);
}
if (!(ifp->valid & IF_VALID_SYSTEM))
@@ -465,7 +456,7 @@ system_parse_opt_set_txqlen (struct ifco
if (!ifp->system)
{
fprintf (stderr, "%s: can't get memory for system interface "
- "configuration: %s\n", program_name, strerror (errno));
+ "configuration: %s\n", program_invocation_short_name,
strerror (errno));
exit (EXIT_FAILURE);
}
ifp->system->valid = 0;
@@ -474,28 +465,28 @@ system_parse_opt_set_txqlen (struct ifco
if (ifp->system->valid & IF_VALID_TXQLEN)
{
fprintf (stderr, "%s: only one txqlen allowed for interface `%s'\n",
- program_name, ifp->name);
- usage (EXIT_FAILURE);
+ program_invocation_short_name, ifp->name);
+ exit (EXIT_FAILURE);
}
ifp->system->txqlen = strtol (arg, &end, 0);
if (*arg == '\0' || *end != '\0')
{
fprintf (stderr, "%s: txqlen value `%s' for interface `%s' "
- "is not a number.\n", program_name, arg, ifp->name);
+ "is not a number.\n", program_invocation_short_name, arg,
ifp->name);
exit (EXIT_FAILURE);
}
ifp->system->valid |= IF_VALID_TXQLEN;
}
int
-system_parse_opt (struct ifconfig **ifpp, char option, char *arg)
+system_parse_opt (struct ifconfig **ifpp, int option, char *arg)
{
struct ifconfig *ifp = *ifpp;
switch (option)
{
- case 'T': /* txqlen */
- system_parse_opt_set_txqlen (ifp, optarg);
+ case ARG_TXQLEN: /* txqlen */
+ system_parse_opt_set_txqlen (ifp, arg);
break;
default:
@@ -504,114 +495,40 @@ system_parse_opt (struct ifconfig **ifpp
return 1;
}
-int
-system_parse_opt_rest (struct ifconfig **ifp, int argc, char *argv[])
+void
+system_parse_opt_rest (struct ifconfig **ifp, char *arg)
{
- int i = 0;
- enum
- {
- EXPECT_NOTHING,
- EXPECT_BROADCAST,
- EXPECT_DSTADDR,
- EXPECT_NETMASK,
- EXPECT_MTU,
- EXPECT_METRIC,
- EXPECT_TXQLEN
- } expect = EXPECT_NOTHING;
-
- *ifp = parse_opt_new_ifs (argv[0]);
+ static is_ifs = true;
+ static void (*parse_opt_set_foo) (struct ifconfig *ifp, char *arg) = NULL;
- while (++i < argc)
+ if (!*ifp)
{
- switch (expect)
- {
- case EXPECT_BROADCAST:
- parse_opt_set_brdaddr (*ifp, argv[i]);
- break;
-
- case EXPECT_DSTADDR:
- parse_opt_set_dstaddr (*ifp, argv[i]);
- break;
-
- case EXPECT_NETMASK:
- parse_opt_set_netmask (*ifp, argv[i]);
- break;
-
- case EXPECT_MTU:
- parse_opt_set_mtu (*ifp, argv[i]);
- break;
-
- case EXPECT_METRIC:
- parse_opt_set_metric (*ifp, argv[i]);
- break;
-
- case EXPECT_TXQLEN:
- system_parse_opt_set_txqlen (*ifp, argv[i]);
- break;
-
- case EXPECT_NOTHING:
- break;
- }
-
- if (expect != EXPECT_NOTHING)
- expect = EXPECT_NOTHING;
- else if (!strcmp (argv[i], "broadcast"))
- expect = EXPECT_BROADCAST;
- else if (!strcmp (argv[i], "dstaddr")
- || !strcmp (argv[i], "pointopoint"))
- expect = EXPECT_DSTADDR;
- else if (!strcmp (argv[i], "netmask"))
- expect = EXPECT_NETMASK;
- else if (!strcmp (argv[i], "metric"))
- expect = EXPECT_METRIC;
- else if (!strcmp (argv[i], "mtu"))
- expect = EXPECT_MTU;
- else if (!strcmp (argv[i], "txqueuelen"))
- expect = EXPECT_TXQLEN;
+ *ifp = parse_opt_new_ifs (arg);
+ is_ifs = false;
+ }
+
+ else if (parse_opt_set_foo == NULL)
+ {
+ if (!strcmp (arg, "broadcast"))
+ parse_opt_set_foo = parse_opt_set_brdaddr;
+ else if (!strcmp (arg, "dstaddr") || !strcmp (arg, "pointopoint"))
+ parse_opt_set_foo = parse_opt_set_dstaddr;
+ else if (!strcmp (arg, "netmask"))
+ parse_opt_set_foo = parse_opt_set_netmask;
+ else if (!strcmp (arg, "metric"))
+ parse_opt_set_foo = parse_opt_set_metric;
+ else if (!strcmp (arg, "mtu"))
+ parse_opt_set_foo = parse_opt_set_mtu;
+ else if (!strcmp (arg, "txqueuelen"))
+ parse_opt_set_foo = system_parse_opt_set_txqlen;
else
- parse_opt_set_address (*ifp, argv[i]);
+ parse_opt_set_address (*ifp, arg);
}
-
- switch (expect)
+ else
{
- case EXPECT_BROADCAST:
- fprintf (stderr, "%s: option `broadcast' requires an argument\n",
- program_name);
- break;
-
- case EXPECT_DSTADDR:
- fprintf (stderr,
- "%s: option `pointopoint' (`dstaddr') requires an argument\n",
- program_name);
- break;
-
- case EXPECT_NETMASK:
- fprintf (stderr, "%s: option `netmask' requires an argument\n",
- program_name);
- break;
-
- case EXPECT_METRIC:
- fprintf (stderr, "%s: option `metric' requires an argument\n",
- program_name);
- break;
-
- case EXPECT_MTU:
- fprintf (stderr, "%s: option `mtu' requires an argument\n",
- program_name);
- break;
-
- case EXPECT_TXQLEN:
- fprintf (stderr, "%s: option `txqueuelen' requires an argument\n",
- program_name);
- break;
-
- case EXPECT_NOTHING:
- break;
+ (*parse_opt_set_foo) (*ifp, arg);
+ parse_opt_set_foo = false;
}
- if (expect != EXPECT_NOTHING)
- usage (EXIT_FAILURE);
-
- return 1;
}
@@ -622,7 +539,7 @@ system_configure (int sfd, struct ifreq
{
#ifndef SIOCSIFTXQLEN
printf ("%s: Don't know how to set the txqlen on this system.\n",
- program_name);
+ program_invocation_short_name);
return -1;
#else
int err = 0;
@@ -632,7 +549,7 @@ system_configure (int sfd, struct ifreq
if (err < 0)
{
fprintf (stderr, "%s: SIOCSIFTXQLEN failed: %s\n",
- program_name, strerror (errno));
+ program_invocation_short_name, strerror (errno));
return -1;
}
if (verbose)
diff -urNp inetutils/ifconfig/system/linux.h
inetutils-build/ifconfig/system/linux.h
--- inetutils/ifconfig/system/linux.h 2006-10-21 20:54:20.000000000 +0530
+++ inetutils-build/ifconfig/system/linux.h 2007-04-06 01:57:16.000000000
+0530
@@ -1,6 +1,6 @@
/* linux.h
- Copyright (C) 2001 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2007 Free Software Foundation, Inc.
Written by Marcus Brinkmann.
@@ -36,8 +36,28 @@ struct system_ifconfig
int txqlen;
};
+enum {
+ ARG_TXQLEN = 1024
+};
+
# define SYSTEM_LONG_OPTIONS \
- {"txqlen", required_argument, 0, 'T'},
+ {"txqlen", ARG_TXQLEN, "LENGTH", 0, "Set transmit queue length to LENGTH", \
+ GRP+1},
+
+#define SYSTEM_OLD_INTERFACE \
+ {"ADDR", 0, "", OPTION_DOC, "Set interface address to ADDR", GRP+1}, \
+ {"NAME", 0, "", OPTION_DOC, "Configure network interface NAME", GRP+1}, \
+ {"broadcast BRDADDR", 0, "", OPTION_DOC, "Set broadcast address to " \
+ "BRDADDR", GRP+1}, \
+ {"dstaddr DSTADDR", 0, "", OPTION_DOC, "Set destination (peer) address " \
+ "to DSTADDR", GRP+1}, \
+ {"pointopoint DSTADDR", 0, "", OPTION_ALIAS | OPTION_DOC, "Set " \
+ "destination (peer) address to DSTADDR", GRP+1}, \
+ {"netmask MASK", 0, "", OPTION_DOC, "Set netmask to MASK", GRP+1}, \
+ {"metric N", 0, "", OPTION_DOC, "Set metric of interface to N", GRP+1}, \
+ {"mtu N", 0, "", OPTION_DOC, "Set mtu of interface to N", GRP+1}, \
+ {"txqueuelen N", 0, "", OPTION_DOC, "Set transmit queue length to " \
+ "LENGTH", GRP+1},
/* Output format support. */
diff -urNp inetutils/ifconfig/system/osf.c inetutils-build/ifconfig/system/osf.c
--- inetutils/ifconfig/system/osf.c 2006-10-21 20:54:20.000000000 +0530
+++ inetutils-build/ifconfig/system/osf.c 2007-04-06 02:05:45.000000000
+0530
@@ -1,6 +1,6 @@
/* system/osf.c -- OSF specific code for ifconfig
- Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002, 2007 Free Software Foundation, Inc.
Written by Marcus Brinkmann.
@@ -58,16 +58,9 @@
/* Output format stuff. */
const char *system_default_format "osf"/* Argument parsing stuff. */
-const char *system_help = "\
- NAME [AF]
-or
- NAME AF [ADDR [DSTADDR]] [broadcast BRDADDR]\n\
- [netmask MASK] [metric N]";
-
-const char *system_help_options;
int
-system_parse_opt (struct ifconfig **ifp, char option, char *optarg)
+system_parse_opt (struct ifconfig **ifp, int option, char *optarg)
{
return 0;
}
@@ -141,17 +134,17 @@ system_parse_opt_rest (struct ifconfig *
{
case EXPECT_BROADCAST:
fprintf (stderr, "%s: option `broadcast' requires an argument\n",
- program_name);
+ program_invocation_short_name);
break;
case EXPECT_NETMASK:
fprintf (stderr, "%s: option `netmask' requires an argument\n",
- program_name);
+ program_invocation_short_name);
break;
case EXPECT_METRIC:
fprintf (stderr, "%s: option `metric' requires an argument\n",
- program_name);
+ program_invocation_short_name);
break;
case EXPECT_NAME:
diff -urNp inetutils/ifconfig/system/osf.h inetutils-build/ifconfig/system/osf.h
--- inetutils/ifconfig/system/osf.h 2006-10-21 20:54:20.000000000 +0530
+++ inetutils-build/ifconfig/system/osf.h 2007-04-06 02:05:18.000000000
+0530
@@ -1,6 +1,6 @@
/* osf.h
- Copyright (C) 2001 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2007 Free Software Foundation, Inc.
Written by Marcus Brinkmann.
@@ -35,6 +35,16 @@ struct system_ifconfig
};
+#define SYSTEM_OLD_INTERFACE \
+ {"ADDR [DSTADDR]", 0, "", OPTION_DOC, "Set interface address to ADDR, " \
+ "and set destination address to DSTADDR (optional)", GRP+1}, \
+ {"AF", 0, "", OPTION_DOC, "Set address family to AF", GRP+1}, \
+ {"NAME", 0, "", OPTION_DOC, "Configure network interface NAME", GRP+1}, \
+ {"broadcast BRDADDR", 0, "", OPTION_DOC, "Set broadcast address to " \
+ "BRDADDR", GRP+1}, \
+ {"netmask MASK", 0, "", OPTION_DOC, "Set netmask to MASK", GRP+1}, \
+ {"metric N", 0, "", OPTION_DOC, "Set metric of interface to N", GRP+1},
+
/* Output format support. */
# define SYSTEM_FORMAT_HANDLER \
diff -urNp inetutils/ifconfig/system/qnx.c inetutils-build/ifconfig/system/qnx.c
--- inetutils/ifconfig/system/qnx.c 2006-10-21 20:54:20.000000000 +0530
+++ inetutils-build/ifconfig/system/qnx.c 2007-04-06 02:00:18.000000000
+0530
@@ -1,6 +1,6 @@
/* generic.c -- generic system code for ifconfig
- Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002, 2007 Free Software Foundation, Inc.
Written by Marcus Brinkmann.
@@ -45,14 +45,8 @@
const char *system_default_format = "unix";
-/* Argument parsing stuff. */
-
-const char *system_help;
-
-const char *system_help_options;
-
int
-system_parse_opt (struct ifconfig **ifp, char option, char *optarg)
+system_parse_opt (struct ifconfig **ifp, int option, char *optarg)
{
return 0;
}
diff -urNp inetutils/ifconfig/system/solaris.c
inetutils-build/ifconfig/system/solaris.c
--- inetutils/ifconfig/system/solaris.c 2006-10-21 20:54:20.000000000 +0530
+++ inetutils-build/ifconfig/system/solaris.c 2007-04-06
01:58:59.000000000 +0530
@@ -1,6 +1,6 @@
/* solaris.c -- Solaris specific code for ifconfig
- Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002, 2007 Free Software Foundation, Inc.
Written by Marcus Brinkmann.
@@ -62,16 +62,8 @@
const char *system_default_format = "unix";
-/* Argument parsing stuff. */
-
-const char *system_help = "\
- NAME [ADDR [DSTADDR]] [broadcast BRDADDR]\n\
- [netmask MASK] [metric N] [mtu N]";
-
-const char *system_help_options;
-
int
-system_parse_opt (struct ifconfig **ifp, char option, char *optarg)
+system_parse_opt (struct ifconfig **ifp, int option, char *optarg)
{
return 0;
}
@@ -142,22 +134,22 @@ system_parse_opt_rest (struct ifconfig *
{
case EXPECT_BROADCAST:
fprintf (stderr, "%s: option `broadcast' requires an argument\n",
- program_name);
+ program_invocation_short_name);
break;
case EXPECT_NETMASK:
fprintf (stderr, "%s: option `netmask' requires an argument\n",
- program_name);
+ program_invocation_short_name);
break;
case EXPECT_METRIC:
fprintf (stderr, "%s: option `metric' requires an argument\n",
- program_name);
+ program_invocation_short_name);
break;
case EXPECT_MTU:
fprintf (stderr, "%s: option `mtu' requires an argument\n",
- program_name);
+ program_invocation_short_name);
break;
case EXPECT_NOTHING:
@@ -177,7 +169,7 @@ system_configure (int sfd, struct ifreq
{
# ifndef SIOCSIFTXQLEN
printf ("%s: Don't know how to set the txqlen on this system.\n",
- program_name);
+ program_invocation_short_name);
return -1;
# else
int err = 0;
@@ -187,7 +179,7 @@ system_configure (int sfd, struct ifreq
if (err < 0)
{
fprintf (stderr, "%s: SIOCSIFTXQLEN failed: %s\n",
- program_name, strerror (errno));
+ program_invocation_short_name, strerror (errno));
return -1;
}
if (verbose)
diff -urNp inetutils/ifconfig/system/solaris.h
inetutils-build/ifconfig/system/solaris.h
--- inetutils/ifconfig/system/solaris.h 2006-10-21 20:54:20.000000000 +0530
+++ inetutils-build/ifconfig/system/solaris.h 2007-04-06
02:03:59.000000000 +0530
@@ -1,6 +1,6 @@
/* solaris.h
- Copyright (C) 2001 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2007 Free Software Foundation, Inc.
Written by Marcus Brinkmann.
@@ -42,6 +42,16 @@ struct system_ifconfig
};
+#define SYSTEM_OLD_INTERFACE \
+ {"ADDR [DSTADDR]", 0, "", OPTION_DOC, "Set interface address to ADDR, " \
+ "and set destination address to DSTADDR (optional)", GRP+1}, \
+ {"NAME", 0, "", OPTION_DOC, "Configure network interface NAME", GRP+1}, \
+ {"broadcast BRDADDR", 0, "", OPTION_DOC, "Set broadcast address to " \
+ "BRDADDR", GRP+1}, \
+ {"netmask MASK", 0, "", OPTION_DOC, "Set netmask to MASK", GRP+1}, \
+ {"metric N", 0, "", OPTION_DOC, "Set metric of interface to N", GRP+1}, \
+ {"mtu N", 0, "", OPTION_DOC, "Set mtu of interface to N", GRP+1},
+
/* Output format support. */
# define SYSTEM_FORMAT_HANDLER \
Comments?
Happy hacking,
Debarshi
--
GPG key ID: 63D4A5A7
Key server: pgp.mit.edu
- Re: [bug-inetutils] Argpifying ifconfig., (continued)
- Re: [bug-inetutils] Argpifying ifconfig., Alfred M. Szmidt, 2007/04/02
- Re: [bug-inetutils] Argpifying ifconfig., Sergey Poznyakoff, 2007/04/03
- Re: [bug-inetutils] Argpifying ifconfig., Debarshi 'Rishi' Ray, 2007/04/04
- Re: [bug-inetutils] Argpifying ifconfig., Sergey Poznyakoff, 2007/04/04
- Re: [bug-inetutils] Argpifying ifconfig., Alfred M. Szmidt, 2007/04/05
- Re: [bug-inetutils] Argpifying ifconfig., Sergey Poznyakoff, 2007/04/05
- Re: [bug-inetutils] Argpifying ifconfig., Alfred M. Szmidt, 2007/04/05
- Re: [bug-inetutils] Argpifying ifconfig., Debarshi 'Rishi' Ray, 2007/04/05
- Re: [bug-inetutils] Argpifying ifconfig., Alfred M. Szmidt, 2007/04/05
- Re: [bug-inetutils] Argpifying ifconfig., Debarshi 'Rishi' Ray, 2007/04/05
- Re: [bug-inetutils] Argpifying ifconfig.,
Debarshi 'Rishi' Ray <=
- Re: [bug-inetutils] Argpifying ifconfig., Alfred M. Szmidt, 2007/04/07
- Re: [bug-inetutils] Argpifying ifconfig., Sergey Poznyakoff, 2007/04/08
- Re: [bug-inetutils] Argpifying ifconfig., Debarshi 'Rishi' Ray, 2007/04/08
- Re: [bug-inetutils] Argpifying ifconfig., Sergey Poznyakoff, 2007/04/10