Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
cf39ae89
Commit
cf39ae89
authored
May 02, 2019
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ping: Avoid using getopt().
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
4432405e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
16 deletions
+38
-16
ping_main.c
programs/ping/ping_main.c
+38
-16
No files found.
programs/ping/ping_main.c
View file @
cf39ae89
...
...
@@ -52,14 +52,14 @@ static void usage(void)
int
main
(
int
argc
,
char
**
argv
)
{
unsigned
int
n
=
4
,
i
=
0
,
w
=
4000
,
l
=
32
;
int
optc
,
res
;
unsigned
int
n
=
4
,
i
,
w
=
4000
,
l
=
32
;
int
res
;
int
rec
=
0
,
lost
=
0
,
min
=
INT_MAX
,
max
=
0
;
WSADATA
wsa
;
HANDLE
icmp_file
;
unsigned
long
ipaddr
;
DWORD
retval
,
reply_size
;
char
*
send_data
,
ip
[
100
],
*
hostname
,
rtt
[
16
];
char
*
send_data
,
ip
[
100
],
*
hostname
=
NULL
,
rtt
[
16
];
void
*
reply_buffer
;
struct
in_addr
addr
;
ICMP_ECHO_REPLY
*
reply
;
...
...
@@ -72,12 +72,19 @@ int main(int argc, char** argv)
exit
(
1
);
}
while
((
optc
=
getopt
(
argc
,
argv
,
"n:w:l:tal:fi:v:r:s:j:k:"
))
!=
-
1
)
for
(
i
=
1
;
i
<
argc
;
i
++
)
{
switch
(
optc
)
if
(
argv
[
i
][
0
]
==
'-'
||
argv
[
i
][
0
]
==
'/'
)
{
switch
(
argv
[
i
][
1
])
{
case
'n'
:
n
=
atoi
(
optarg
);
if
(
i
==
argc
-
1
)
{
printf
(
"Missing value for option %s
\n
"
,
argv
[
i
]
);
exit
(
1
);
}
n
=
atoi
(
argv
[
++
i
]);
if
(
n
==
0
)
{
printf
(
"Bad value for option -n, valid range is from 1 to 4294967295.
\n
"
);
...
...
@@ -85,7 +92,12 @@ int main(int argc, char** argv)
}
break
;
case
'w'
:
w
=
atoi
(
optarg
);
if
(
i
==
argc
-
1
)
{
printf
(
"Missing value for option %s
\n
"
,
argv
[
i
]
);
exit
(
1
);
}
w
=
atoi
(
argv
[
++
i
]);
if
(
w
==
0
)
{
printf
(
"Bad value for option -w.
\n
"
);
...
...
@@ -93,7 +105,12 @@ int main(int argc, char** argv)
}
break
;
case
'l'
:
l
=
atoi
(
optarg
);
if
(
i
==
argc
-
1
)
{
printf
(
"Missing value for option %s
\n
"
,
argv
[
i
]
);
exit
(
1
);
}
l
=
atoi
(
argv
[
++
i
]);
if
(
l
==
0
)
{
printf
(
"Bad value for option -l.
\n
"
);
...
...
@@ -107,12 +124,20 @@ int main(int argc, char** argv)
usage
();
WINE_FIXME
(
"this command currently only supports the -n, -w and -l parameters.
\n
"
);
exit
(
1
);
}
}
else
{
if
(
hostname
)
{
printf
(
"Bad argument %s
\n
"
,
argv
[
i
]
);
exit
(
1
);
}
hostname
=
argv
[
i
];
}
}
if
(
argv
[
optind
]
!=
NULL
)
hostname
=
argv
[
optind
];
else
if
(
!
hostname
)
{
printf
(
"Pass a host name.
\n
"
);
return
1
;
...
...
@@ -155,7 +180,7 @@ int main(int argc, char** argv)
}
printf
(
"Pinging %s [%s] with %d bytes of data:
\n
"
,
hostname
,
ip
,
l
);
for
(
;;
)
for
(
i
=
0
;
i
<
n
;
i
++
)
{
SetLastError
(
0
);
retval
=
IcmpSendEcho
(
icmp_file
,
ipaddr
,
send_data
,
l
,
...
...
@@ -184,10 +209,7 @@ int main(int argc, char** argv)
puts
(
"PING: transmit failed. General failure."
);
lost
++
;
}
i
++
;
if
(
i
==
n
)
break
;
Sleep
(
1000
);
if
(
i
<
n
-
1
)
Sleep
(
1000
);
}
printf
(
"
\n
Ping statistics for %s
\n
"
,
ip
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment