mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-07-22 22:55:44 +08:00
Simplify getopt() to getopt_r() translation
This commit is contained in:
parent
c804e50047
commit
c333babc98
@ -1,7 +1,3 @@
|
|||||||
#ifdef __rtems__
|
|
||||||
#define __need_getopt_newlib
|
|
||||||
#include <getopt.h>
|
|
||||||
#endif
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1983, 1993
|
* Copyright (c) 1983, 1993
|
||||||
* The Regents of the University of California. All rights reserved.
|
* The Regents of the University of California. All rights reserved.
|
||||||
@ -45,6 +41,10 @@ static const char rcsid[] =
|
|||||||
"$FreeBSD$";
|
"$FreeBSD$";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
|
#ifdef __rtems__
|
||||||
|
#define __need_getopt_newlib
|
||||||
|
#include <getopt.h>
|
||||||
|
#endif /* __rtems__ */
|
||||||
#include <rtems/bsd/sys/param.h>
|
#include <rtems/bsd/sys/param.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
@ -204,12 +204,14 @@ main(int argc, char *argv[])
|
|||||||
#endif
|
#endif
|
||||||
size_t iflen;
|
size_t iflen;
|
||||||
#ifdef __rtems__
|
#ifdef __rtems__
|
||||||
struct getopt_data getopt_reent;
|
struct getopt_data getopt_data;
|
||||||
#define optind getopt_reent.optind
|
memset(&getopt_data, 0, sizeof(getopt_data));
|
||||||
#define optarg getopt_reent.optarg
|
#define optind getopt_data.optind
|
||||||
#define opterr getopt_reent.opterr
|
#define optarg getopt_data.optarg
|
||||||
#define optopt getopt_reent.optopt
|
#define opterr getopt_data.opterr
|
||||||
#endif
|
#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;
|
all = downonly = uponly = namesonly = noload = verbose = 0;
|
||||||
|
|
||||||
@ -217,12 +219,7 @@ main(int argc, char *argv[])
|
|||||||
strlcpy(options, "adklmnuv", sizeof(options));
|
strlcpy(options, "adklmnuv", sizeof(options));
|
||||||
for (p = opts; p != NULL; p = p->next)
|
for (p = opts; p != NULL; p = p->next)
|
||||||
strlcat(options, p->opt, sizeof(options));
|
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) {
|
while ((c = getopt(argc, argv, options)) != -1) {
|
||||||
#endif
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'a': /* scan all interfaces */
|
case 'a': /* scan all interfaces */
|
||||||
all++;
|
all++;
|
||||||
|
@ -1,7 +1,3 @@
|
|||||||
#ifdef __rtems__
|
|
||||||
#define __need_getopt_newlib
|
|
||||||
#include <getopt.h>
|
|
||||||
#endif
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1989, 1993
|
* Copyright (c) 1989, 1993
|
||||||
* The Regents of the University of California. All rights reserved.
|
* The Regents of the University of California. All rights reserved.
|
||||||
@ -45,6 +41,10 @@ static const char copyright[] =
|
|||||||
static char sccsid[] = "@(#)ping.c 8.1 (Berkeley) 6/5/93";
|
static char sccsid[] = "@(#)ping.c 8.1 (Berkeley) 6/5/93";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef __rtems__
|
||||||
|
#define __need_getopt_newlib
|
||||||
|
#include <getopt.h>
|
||||||
|
#endif /* __rtems__ */
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__FBSDID("$FreeBSD$");
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
@ -283,12 +283,14 @@ main(argc, argv)
|
|||||||
#endif
|
#endif
|
||||||
unsigned char loop, mttl;
|
unsigned char loop, mttl;
|
||||||
#ifdef __rtems__
|
#ifdef __rtems__
|
||||||
struct getopt_data getopt_reent;
|
struct getopt_data getopt_data;
|
||||||
#define optarg getopt_reent.optarg
|
memset(&getopt_data, 0, sizeof(getopt_data));
|
||||||
#define optind getopt_reent.optind
|
#define optind getopt_data.optind
|
||||||
#define opterr getopt.reent.opterr
|
#define optarg getopt_data.optarg
|
||||||
#define optopt getopt.reent.optopt
|
#define opterr getopt_data.opterr
|
||||||
#endif
|
#define optopt getopt_data.optopt
|
||||||
|
#define getopt(argc, argv, opt) getopt_r(argc, argv, opt, &getopt_data)
|
||||||
|
#endif /* __rtems__ */
|
||||||
|
|
||||||
payload = source = NULL;
|
payload = source = NULL;
|
||||||
#ifdef IPSEC_POLICY_IPSEC
|
#ifdef IPSEC_POLICY_IPSEC
|
||||||
@ -309,21 +311,13 @@ main(argc, argv)
|
|||||||
alarmtimeout = df = preload = tos = 0;
|
alarmtimeout = df = preload = tos = 0;
|
||||||
|
|
||||||
outpack = outpackhdr + sizeof(struct ip);
|
outpack = outpackhdr + sizeof(struct ip);
|
||||||
#ifdef __rtems__
|
|
||||||
memset(&getopt_reent, 0, sizeof(getopt_data));
|
|
||||||
while ((ch = getopt_r(argc, argv,
|
|
||||||
#else
|
|
||||||
while ((ch = getopt(argc, argv,
|
while ((ch = getopt(argc, argv,
|
||||||
#endif
|
|
||||||
"Aac:DdfG:g:h:I:i:Ll:M:m:nop:QqRrS:s:T:t:vW:z:"
|
"Aac:DdfG:g:h:I:i:Ll:M:m:nop:QqRrS:s:T:t:vW:z:"
|
||||||
#ifdef IPSEC
|
#ifdef IPSEC
|
||||||
#ifdef IPSEC_POLICY_IPSEC
|
#ifdef IPSEC_POLICY_IPSEC
|
||||||
"P:"
|
"P:"
|
||||||
#endif /*IPSEC_POLICY_IPSEC*/
|
#endif /*IPSEC_POLICY_IPSEC*/
|
||||||
#endif /*IPSEC*/
|
#endif /*IPSEC*/
|
||||||
#ifdef __rtems__
|
|
||||||
, &getopt_reent
|
|
||||||
#endif
|
|
||||||
)) != -1)
|
)) != -1)
|
||||||
{
|
{
|
||||||
switch(ch) {
|
switch(ch) {
|
||||||
|
@ -1,9 +1,3 @@
|
|||||||
#ifdef __rtems__
|
|
||||||
#define USE_RFC2292BIS
|
|
||||||
|
|
||||||
#define __need_getopt_newlib
|
|
||||||
#include <getopt.h>
|
|
||||||
#endif
|
|
||||||
/* $KAME: ping6.c,v 1.169 2003/07/25 06:01:47 itojun Exp $ */
|
/* $KAME: ping6.c,v 1.169 2003/07/25 06:01:47 itojun Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -110,6 +104,12 @@ static const char rcsid[] =
|
|||||||
* network attached to 1 or more interfaces)
|
* network attached to 1 or more interfaces)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef __rtems__
|
||||||
|
#define __need_getopt_newlib
|
||||||
|
#include <getopt.h>
|
||||||
|
|
||||||
|
#define USE_RFC2292BIS
|
||||||
|
#endif /* __rtems__ */
|
||||||
#include <rtems/bsd/sys/param.h>
|
#include <rtems/bsd/sys/param.h>
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
@ -348,8 +348,14 @@ main(argc, argv)
|
|||||||
int mflag = 0;
|
int mflag = 0;
|
||||||
#endif
|
#endif
|
||||||
#ifdef __rtems__
|
#ifdef __rtems__
|
||||||
struct getopt_data getopt_reent;
|
struct getopt_data getopt_data;
|
||||||
#endif
|
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__ */
|
||||||
|
|
||||||
/* just to be sure */
|
/* just to be sure */
|
||||||
memset(&smsghdr, 0, sizeof(smsghdr));
|
memset(&smsghdr, 0, sizeof(smsghdr));
|
||||||
@ -366,14 +372,8 @@ main(argc, argv)
|
|||||||
#define ADDOPTS "AE"
|
#define ADDOPTS "AE"
|
||||||
#endif /*IPSEC_POLICY_IPSEC*/
|
#endif /*IPSEC_POLICY_IPSEC*/
|
||||||
#endif
|
#endif
|
||||||
#ifdef __rtems__
|
|
||||||
memset(&getopt_reent, 0, sizeof(getopt_data));
|
|
||||||
while ((ch = getopt_r(argc, argv,
|
|
||||||
"a:b:c:DdfHg:h:I:i:l:mnNop:qrRS:s:tvwW" ADDOPTS, &getopt_reent)) != -1) {
|
|
||||||
#else
|
|
||||||
while ((ch = getopt(argc, argv,
|
while ((ch = getopt(argc, argv,
|
||||||
"a:b:c:DdfHg:h:I:i:l:mnNop:qrRS:s:tvwW" ADDOPTS)) != -1) {
|
"a:b:c:DdfHg:h:I:i:l:mnNop:qrRS:s:tvwW" ADDOPTS)) != -1) {
|
||||||
#endif
|
|
||||||
#undef ADDOPTS
|
#undef ADDOPTS
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'a':
|
case 'a':
|
||||||
|
@ -1,7 +1,3 @@
|
|||||||
#ifdef __rtems__
|
|
||||||
#define __need_getopt_newlib
|
|
||||||
#include <getopt.h>
|
|
||||||
#endif
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1983, 1989, 1991, 1993
|
* Copyright (c) 1983, 1989, 1991, 1993
|
||||||
* The Regents of the University of California. All rights reserved.
|
* The Regents of the University of California. All rights reserved.
|
||||||
@ -45,6 +41,10 @@ static const char rcsid[] =
|
|||||||
"$FreeBSD$";
|
"$FreeBSD$";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
|
#ifdef __rtems__
|
||||||
|
#define __need_getopt_newlib
|
||||||
|
#include <getopt.h>
|
||||||
|
#endif
|
||||||
#include <rtems/bsd/sys/param.h>
|
#include <rtems/bsd/sys/param.h>
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
@ -157,22 +157,19 @@ main(argc, argv)
|
|||||||
{
|
{
|
||||||
int ch;
|
int ch;
|
||||||
#ifdef __rtems__
|
#ifdef __rtems__
|
||||||
struct getopt_data getopt_reent;
|
struct getopt_data getopt_data;
|
||||||
#define optind getopt_reent.optind
|
memset(&getopt_data, 0, sizeof(getopt_data));
|
||||||
#define optarg getopt_reent.optarg
|
#define optind getopt_data.optind
|
||||||
#define opterr getopt_reent.opterr
|
#define optarg getopt_data.optarg
|
||||||
#define optopt getopt_reent.optopt
|
#define opterr getopt_data.opterr
|
||||||
#endif
|
#define optopt getopt_data.optopt
|
||||||
|
#define getopt(argc, argv, opt) getopt_r(argc, argv, opt, &getopt_data)
|
||||||
|
#endif /* __rtems__ */
|
||||||
|
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
usage((char *)NULL);
|
usage((char *)NULL);
|
||||||
|
|
||||||
#ifdef __rtems__
|
|
||||||
memset(&getopt_reent, 0, sizeof(getopt_data));
|
|
||||||
while ((ch = getopt_r(argc, argv, "nqdtv", &getopt_reent)) != -1)
|
|
||||||
#else
|
|
||||||
while ((ch = getopt(argc, argv, "nqdtv")) != -1)
|
while ((ch = getopt(argc, argv, "nqdtv")) != -1)
|
||||||
#endif
|
|
||||||
switch(ch) {
|
switch(ch) {
|
||||||
case 'n':
|
case 'n':
|
||||||
nflag = 1;
|
nflag = 1;
|
||||||
|
@ -1,7 +1,3 @@
|
|||||||
#ifdef __rtems__
|
|
||||||
#define __need_getopt_newlib
|
|
||||||
#include <getopt.h>
|
|
||||||
#endif
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1983, 1988, 1993
|
* Copyright (c) 1983, 1988, 1993
|
||||||
* Regents of the University of California. All rights reserved.
|
* Regents of the University of California. All rights reserved.
|
||||||
@ -47,6 +43,10 @@ static char sccsid[] = "@(#)main.c 8.4 (Berkeley) 3/1/94";
|
|||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __rtems__
|
||||||
|
#define __need_getopt_newlib
|
||||||
|
#include <getopt.h>
|
||||||
|
#endif /* __rtems__ */
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__FBSDID("$FreeBSD$");
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
@ -745,21 +745,18 @@ main(int argc, char *argv[])
|
|||||||
struct protox *tp = NULL; /* for printing cblocks & stats */
|
struct protox *tp = NULL; /* for printing cblocks & stats */
|
||||||
int ch;
|
int ch;
|
||||||
#ifdef __rtems__
|
#ifdef __rtems__
|
||||||
struct getopt_data getopt_reent;
|
struct getopt_data getopt_data;
|
||||||
#define optind getopt_reent.optind
|
memset(&getopt_data, 0, sizeof(getopt_data));
|
||||||
#define optarg getopt_reent.optarg
|
#define optind getopt_data.optind
|
||||||
#define opterr getopt_reent.opterr
|
#define optarg getopt_data.optarg
|
||||||
#define optopt getopt_reent.optopt
|
#define opterr getopt_data.opterr
|
||||||
#endif
|
#define optopt getopt_data.optopt
|
||||||
|
#define getopt(argc, argv, opt) getopt_r(argc, argv, opt, &getopt_data)
|
||||||
|
#endif /* __rtems__ */
|
||||||
|
|
||||||
af = AF_UNSPEC;
|
af = AF_UNSPEC;
|
||||||
|
|
||||||
#ifdef __rtems__
|
|
||||||
memset(&getopt_reent, 0, sizeof(getopt_data));
|
|
||||||
while ((ch = getopt_r(argc, argv, "AaBbdf:ghI:iLlM:mN:np:q:rSstuWw:xz", &getopt_reent)) != -1)
|
|
||||||
#else
|
|
||||||
while ((ch = getopt(argc, argv, "AaBbdf:ghI:iLlM:mN:np:q:rSstuWw:xz")) != -1)
|
while ((ch = getopt(argc, argv, "AaBbdf:ghI:iLlM:mN:np:q:rSstuWw:xz")) != -1)
|
||||||
#endif
|
|
||||||
switch(ch) {
|
switch(ch) {
|
||||||
case 'A':
|
case 'A':
|
||||||
Aflag = 1;
|
Aflag = 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user