mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-06-06 14:14:11 +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
|
||||
* 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++;
|
||||
|
@ -1,7 +1,3 @@
|
||||
#ifdef __rtems__
|
||||
#define __need_getopt_newlib
|
||||
#include <getopt.h>
|
||||
#endif
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
* 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";
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
#ifdef __rtems__
|
||||
#define __need_getopt_newlib
|
||||
#include <getopt.h>
|
||||
#endif /* __rtems__ */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
@ -283,12 +283,14 @@ main(argc, argv)
|
||||
#endif
|
||||
unsigned char loop, mttl;
|
||||
#ifdef __rtems__
|
||||
struct getopt_data getopt_reent;
|
||||
#define optarg getopt_reent.optarg
|
||||
#define optind getopt_reent.optind
|
||||
#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__ */
|
||||
|
||||
payload = source = NULL;
|
||||
#ifdef IPSEC_POLICY_IPSEC
|
||||
@ -309,21 +311,13 @@ main(argc, argv)
|
||||
alarmtimeout = df = preload = tos = 0;
|
||||
|
||||
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,
|
||||
#endif
|
||||
"Aac:DdfG:g:h:I:i:Ll:M:m:nop:QqRrS:s:T:t:vW:z:"
|
||||
#ifdef IPSEC
|
||||
#ifdef IPSEC_POLICY_IPSEC
|
||||
"P:"
|
||||
#endif /*IPSEC_POLICY_IPSEC*/
|
||||
#endif /*IPSEC*/
|
||||
#ifdef __rtems__
|
||||
, &getopt_reent
|
||||
#endif
|
||||
)) != -1)
|
||||
{
|
||||
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 $ */
|
||||
|
||||
/*
|
||||
@ -110,6 +104,12 @@ static const char rcsid[] =
|
||||
* 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 <sys/uio.h>
|
||||
#include <sys/socket.h>
|
||||
@ -348,8 +348,14 @@ main(argc, argv)
|
||||
int mflag = 0;
|
||||
#endif
|
||||
#ifdef __rtems__
|
||||
struct getopt_data getopt_reent;
|
||||
#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__ */
|
||||
|
||||
/* just to be sure */
|
||||
memset(&smsghdr, 0, sizeof(smsghdr));
|
||||
@ -366,14 +372,8 @@ main(argc, argv)
|
||||
#define ADDOPTS "AE"
|
||||
#endif /*IPSEC_POLICY_IPSEC*/
|
||||
#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,
|
||||
"a:b:c:DdfHg:h:I:i:l:mnNop:qrRS:s:tvwW" ADDOPTS)) != -1) {
|
||||
#endif
|
||||
#undef ADDOPTS
|
||||
switch (ch) {
|
||||
case 'a':
|
||||
|
@ -1,7 +1,3 @@
|
||||
#ifdef __rtems__
|
||||
#define __need_getopt_newlib
|
||||
#include <getopt.h>
|
||||
#endif
|
||||
/*
|
||||
* Copyright (c) 1983, 1989, 1991, 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
|
||||
#include <rtems/bsd/sys/param.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/socket.h>
|
||||
@ -157,22 +157,19 @@ main(argc, argv)
|
||||
{
|
||||
int ch;
|
||||
#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__ */
|
||||
|
||||
if (argc < 2)
|
||||
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)
|
||||
#endif
|
||||
switch(ch) {
|
||||
case 'n':
|
||||
nflag = 1;
|
||||
|
@ -1,7 +1,3 @@
|
||||
#ifdef __rtems__
|
||||
#define __need_getopt_newlib
|
||||
#include <getopt.h>
|
||||
#endif
|
||||
/*-
|
||||
* Copyright (c) 1983, 1988, 1993
|
||||
* 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
|
||||
|
||||
#ifdef __rtems__
|
||||
#define __need_getopt_newlib
|
||||
#include <getopt.h>
|
||||
#endif /* __rtems__ */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
@ -745,21 +745,18 @@ main(int argc, char *argv[])
|
||||
struct protox *tp = NULL; /* for printing cblocks & stats */
|
||||
int ch;
|
||||
#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__ */
|
||||
|
||||
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)
|
||||
#endif
|
||||
switch(ch) {
|
||||
case 'A':
|
||||
Aflag = 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user