diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2013-10-17 10:46:42 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2013-10-31 13:18:48 +0100 |
commit | c333babc98347dd8b49def957ed93f5bba55cdd8 (patch) | |
tree | 8886727370c5c484b21fc8f2397a6c650350cb44 /freebsd/sbin/ifconfig/ifconfig.c | |
parent | Update from latest FreeBSD version (diff) | |
download | rtems-libbsd-c333babc98347dd8b49def957ed93f5bba55cdd8.tar.bz2 |
Simplify getopt() to getopt_r() translation
Diffstat (limited to 'freebsd/sbin/ifconfig/ifconfig.c')
-rw-r--r-- | freebsd/sbin/ifconfig/ifconfig.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/freebsd/sbin/ifconfig/ifconfig.c b/freebsd/sbin/ifconfig/ifconfig.c index 5ea94671..c8a296ee 100644 --- a/freebsd/sbin/ifconfig/ifconfig.c +++ b/freebsd/sbin/ifconfig/ifconfig.c @@ -1,7 +1,3 @@ -#ifdef __rtems__ -#define __need_getopt_newlib -#include <getopt.h> -#endif /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -45,6 +41,10 @@ static const char rcsid[] = "$FreeBSD$"; #endif /* not lint */ +#ifdef __rtems__ +#define __need_getopt_newlib +#include <getopt.h> +#endif /* __rtems__ */ #include <rtems/bsd/sys/param.h> #include <sys/ioctl.h> #include <sys/socket.h> @@ -204,12 +204,14 @@ main(int argc, char *argv[]) #endif size_t iflen; #ifdef __rtems__ - struct getopt_data getopt_reent; -#define optind getopt_reent.optind -#define optarg getopt_reent.optarg -#define opterr getopt_reent.opterr -#define optopt getopt_reent.optopt -#endif + struct getopt_data getopt_data; + memset(&getopt_data, 0, sizeof(getopt_data)); +#define optind getopt_data.optind +#define optarg getopt_data.optarg +#define opterr getopt_data.opterr +#define optopt getopt_data.optopt +#define getopt(argc, argv, opt) getopt_r(argc, argv, opt, &getopt_data) +#endif /* __rtems__ */ all = downonly = uponly = namesonly = noload = verbose = 0; @@ -217,12 +219,7 @@ main(int argc, char *argv[]) strlcpy(options, "adklmnuv", sizeof(options)); for (p = opts; p != NULL; p = p->next) strlcat(options, p->opt, sizeof(options)); -#ifdef __rtems__ - memset(&getopt_reent, 0, sizeof(getopt_data)); - while ((c = getopt_r(argc, argv, options, &getopt_reent)) != -1) { -#else while ((c = getopt(argc, argv, options)) != -1) { -#endif switch (c) { case 'a': /* scan all interfaces */ all++; |