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
ae375252
Commit
ae375252
authored
Jul 24, 2018
by
Michael Stefaniuc
Committed by
Alexandre Julliard
Aug 14, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ipconfig: Use the ARRAY_SIZE() macro.
Signed-off-by:
Michael Stefaniuc
<
mstefani@winehq.org
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
f559c605
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
22 deletions
+18
-22
ipconfig.c
programs/ipconfig/ipconfig.c
+18
-22
No files found.
programs/ipconfig/ipconfig.c
View file @
ae375252
...
@@ -35,7 +35,7 @@ static int ipconfig_vprintfW(const WCHAR *msg, __ms_va_list va_args)
...
@@ -35,7 +35,7 @@ static int ipconfig_vprintfW(const WCHAR *msg, __ms_va_list va_args)
WCHAR
msg_buffer
[
8192
];
WCHAR
msg_buffer
[
8192
];
wlen
=
FormatMessageW
(
FORMAT_MESSAGE_FROM_STRING
,
msg
,
0
,
0
,
msg_buffer
,
wlen
=
FormatMessageW
(
FORMAT_MESSAGE_FROM_STRING
,
msg
,
0
,
0
,
msg_buffer
,
sizeof
(
msg_buffer
)
/
sizeof
(
*
msg_buffer
),
&
va_args
);
ARRAY_SIZE
(
msg_buffer
),
&
va_args
);
ret
=
WriteConsoleW
(
GetStdHandle
(
STD_OUTPUT_HANDLE
),
msg_buffer
,
wlen
,
&
count
,
NULL
);
ret
=
WriteConsoleW
(
GetStdHandle
(
STD_OUTPUT_HANDLE
),
msg_buffer
,
wlen
,
&
count
,
NULL
);
if
(
!
ret
)
if
(
!
ret
)
...
@@ -80,8 +80,7 @@ static int WINAPIV ipconfig_message_printfW(int msg, ...)
...
@@ -80,8 +80,7 @@ static int WINAPIV ipconfig_message_printfW(int msg, ...)
WCHAR
msg_buffer
[
8192
];
WCHAR
msg_buffer
[
8192
];
int
len
;
int
len
;
LoadStringW
(
GetModuleHandleW
(
NULL
),
msg
,
msg_buffer
,
LoadStringW
(
GetModuleHandleW
(
NULL
),
msg
,
msg_buffer
,
ARRAY_SIZE
(
msg_buffer
));
sizeof
(
msg_buffer
)
/
sizeof
(
WCHAR
));
__ms_va_start
(
va_args
,
msg
);
__ms_va_start
(
va_args
,
msg
);
len
=
ipconfig_vprintfW
(
msg_buffer
,
va_args
);
len
=
ipconfig_vprintfW
(
msg_buffer
,
va_args
);
...
@@ -95,8 +94,7 @@ static int ipconfig_message(int msg)
...
@@ -95,8 +94,7 @@ static int ipconfig_message(int msg)
static
const
WCHAR
formatW
[]
=
{
'%'
,
'1'
,
0
};
static
const
WCHAR
formatW
[]
=
{
'%'
,
'1'
,
0
};
WCHAR
msg_buffer
[
8192
];
WCHAR
msg_buffer
[
8192
];
LoadStringW
(
GetModuleHandleW
(
NULL
),
msg
,
msg_buffer
,
LoadStringW
(
GetModuleHandleW
(
NULL
),
msg
,
msg_buffer
,
ARRAY_SIZE
(
msg_buffer
));
sizeof
(
msg_buffer
)
/
sizeof
(
WCHAR
));
return
ipconfig_printfW
(
formatW
,
msg_buffer
);
return
ipconfig_printfW
(
formatW
,
msg_buffer
);
}
}
...
@@ -118,8 +116,7 @@ static const WCHAR *iftype_to_string(DWORD type)
...
@@ -118,8 +116,7 @@ static const WCHAR *iftype_to_string(DWORD type)
msg
=
STRING_UNKNOWN
;
msg
=
STRING_UNKNOWN
;
}
}
LoadStringW
(
GetModuleHandleW
(
NULL
),
msg
,
msg_buffer
,
LoadStringW
(
GetModuleHandleW
(
NULL
),
msg
,
msg_buffer
,
ARRAY_SIZE
(
msg_buffer
));
sizeof
(
msg_buffer
)
/
sizeof
(
WCHAR
));
return
msg_buffer
;
return
msg_buffer
;
}
}
...
@@ -130,10 +127,10 @@ static void print_field(int msg, const WCHAR *value)
...
@@ -130,10 +127,10 @@ static void print_field(int msg, const WCHAR *value)
WCHAR
field
[]
=
{
'.'
,
' '
,
'.'
,
' '
,
'.'
,
' '
,
'.'
,
' '
,
'.'
,
' '
,
'.'
,
' '
,
'.'
,
' '
,
'.'
,
' '
,
'.'
,
WCHAR
field
[]
=
{
'.'
,
' '
,
'.'
,
' '
,
'.'
,
' '
,
'.'
,
' '
,
'.'
,
' '
,
'.'
,
' '
,
'.'
,
' '
,
'.'
,
' '
,
'.'
,
' '
,
'.'
,
' '
,
'.'
,
' '
,
'.'
,
' '
,
'.'
,
' '
,
'.'
,
' '
,
'.'
,
' '
,
'.'
,
' '
,
'.'
,
' '
,
0
};
' '
,
'.'
,
' '
,
'.'
,
' '
,
'.'
,
' '
,
'.'
,
' '
,
'.'
,
' '
,
'.'
,
' '
,
'.'
,
' '
,
'.'
,
' '
,
0
};
WCHAR
name_buffer
[
sizeof
(
field
)
/
sizeof
(
WCHAR
)];
WCHAR
name_buffer
[
ARRAY_SIZE
(
field
)];
LoadStringW
(
GetModuleHandleW
(
NULL
),
msg
,
name_buffer
,
sizeof
(
name_buffer
)
/
sizeof
(
WCHAR
));
LoadStringW
(
GetModuleHandleW
(
NULL
),
msg
,
name_buffer
,
ARRAY_SIZE
(
name_buffer
));
memcpy
(
field
,
name_buffer
,
sizeof
(
WCHAR
)
*
min
(
strlenW
(
name_buffer
),
sizeof
(
field
)
/
sizeof
(
WCHAR
)
-
1
));
memcpy
(
field
,
name_buffer
,
sizeof
(
WCHAR
)
*
min
(
strlenW
(
name_buffer
),
ARRAY_SIZE
(
field
)
-
1
));
ipconfig_printfW
(
formatW
,
field
,
value
);
ipconfig_printfW
(
formatW
,
field
,
value
);
}
}
...
@@ -189,22 +186,22 @@ static void print_basic_information(void)
...
@@ -189,22 +186,22 @@ static void print_basic_information(void)
for
(
addr
=
p
->
FirstUnicastAddress
;
addr
;
addr
=
addr
->
Next
)
for
(
addr
=
p
->
FirstUnicastAddress
;
addr
;
addr
=
addr
->
Next
)
{
{
if
(
addr
->
Address
.
lpSockaddr
->
sa_family
==
AF_INET
&&
if
(
addr
->
Address
.
lpSockaddr
->
sa_family
==
AF_INET
&&
socket_address_to_string
(
addr_buf
,
sizeof
(
addr_buf
)
/
sizeof
(
WCHAR
),
&
addr
->
Address
))
socket_address_to_string
(
addr_buf
,
ARRAY_SIZE
(
addr_buf
),
&
addr
->
Address
))
print_field
(
STRING_IP_ADDRESS
,
addr_buf
);
print_field
(
STRING_IP_ADDRESS
,
addr_buf
);
else
if
(
addr
->
Address
.
lpSockaddr
->
sa_family
==
AF_INET6
&&
else
if
(
addr
->
Address
.
lpSockaddr
->
sa_family
==
AF_INET6
&&
socket_address_to_string
(
addr_buf
,
sizeof
(
addr_buf
)
/
sizeof
(
WCHAR
),
&
addr
->
Address
))
socket_address_to_string
(
addr_buf
,
ARRAY_SIZE
(
addr_buf
),
&
addr
->
Address
))
print_field
(
STRING_IP6_ADDRESS
,
addr_buf
);
print_field
(
STRING_IP6_ADDRESS
,
addr_buf
);
/* FIXME: Output corresponding subnet mask. */
/* FIXME: Output corresponding subnet mask. */
}
}
if
(
p
->
FirstGatewayAddress
)
if
(
p
->
FirstGatewayAddress
)
{
{
if
(
socket_address_to_string
(
addr_buf
,
sizeof
(
addr_buf
)
/
sizeof
(
WCHAR
),
&
p
->
FirstGatewayAddress
->
Address
))
if
(
socket_address_to_string
(
addr_buf
,
ARRAY_SIZE
(
addr_buf
),
&
p
->
FirstGatewayAddress
->
Address
))
print_field
(
STRING_DEFAULT_GATEWAY
,
addr_buf
);
print_field
(
STRING_DEFAULT_GATEWAY
,
addr_buf
);
for
(
gateway
=
p
->
FirstGatewayAddress
->
Next
;
gateway
;
gateway
=
gateway
->
Next
)
for
(
gateway
=
p
->
FirstGatewayAddress
->
Next
;
gateway
;
gateway
=
gateway
->
Next
)
{
{
if
(
socket_address_to_string
(
addr_buf
,
sizeof
(
addr_buf
)
/
sizeof
(
WCHAR
),
&
gateway
->
Address
))
if
(
socket_address_to_string
(
addr_buf
,
ARRAY_SIZE
(
addr_buf
),
&
gateway
->
Address
))
print_value
(
addr_buf
);
print_value
(
addr_buf
);
}
}
}
}
...
@@ -243,8 +240,7 @@ static const WCHAR *nodetype_to_string(DWORD type)
...
@@ -243,8 +240,7 @@ static const WCHAR *nodetype_to_string(DWORD type)
msg
=
STRING_UNKNOWN
;
msg
=
STRING_UNKNOWN
;
}
}
LoadStringW
(
GetModuleHandleW
(
NULL
),
msg
,
msg_buffer
,
LoadStringW
(
GetModuleHandleW
(
NULL
),
msg
,
msg_buffer
,
ARRAY_SIZE
(
msg_buffer
));
sizeof
(
msg_buffer
)
/
sizeof
(
WCHAR
));
return
msg_buffer
;
return
msg_buffer
;
}
}
...
@@ -277,7 +273,7 @@ static const WCHAR *boolean_to_string(int value)
...
@@ -277,7 +273,7 @@ static const WCHAR *boolean_to_string(int value)
static
WCHAR
msg_buffer
[
15
];
static
WCHAR
msg_buffer
[
15
];
LoadStringW
(
GetModuleHandleW
(
NULL
),
value
?
STRING_YES
:
STRING_NO
,
LoadStringW
(
GetModuleHandleW
(
NULL
),
value
?
STRING_YES
:
STRING_NO
,
msg_buffer
,
sizeof
(
msg_buffer
)
/
sizeof
(
WCHAR
));
msg_buffer
,
ARRAY_SIZE
(
msg_buffer
));
return
msg_buffer
;
return
msg_buffer
;
}
}
...
@@ -301,7 +297,7 @@ static void print_full_information(void)
...
@@ -301,7 +297,7 @@ static void print_full_information(void)
{
{
WCHAR
hostnameW
[
MAX_HOSTNAME_LEN
+
4
];
WCHAR
hostnameW
[
MAX_HOSTNAME_LEN
+
4
];
MultiByteToWideChar
(
CP_ACP
,
0
,
info
->
HostName
,
-
1
,
hostnameW
,
sizeof
(
hostnameW
)
/
sizeof
(
hostnameW
[
0
]
));
MultiByteToWideChar
(
CP_ACP
,
0
,
info
->
HostName
,
-
1
,
hostnameW
,
ARRAY_SIZE
(
hostnameW
));
print_field
(
STRING_HOSTNAME
,
hostnameW
);
print_field
(
STRING_HOSTNAME
,
hostnameW
);
/* FIXME: Output primary DNS suffix. */
/* FIXME: Output primary DNS suffix. */
...
@@ -348,22 +344,22 @@ static void print_full_information(void)
...
@@ -348,22 +344,22 @@ static void print_full_information(void)
for
(
addr
=
p
->
FirstUnicastAddress
;
addr
;
addr
=
addr
->
Next
)
for
(
addr
=
p
->
FirstUnicastAddress
;
addr
;
addr
=
addr
->
Next
)
{
{
if
(
addr
->
Address
.
lpSockaddr
->
sa_family
==
AF_INET
&&
if
(
addr
->
Address
.
lpSockaddr
->
sa_family
==
AF_INET
&&
socket_address_to_string
(
addr_buf
,
sizeof
(
addr_buf
)
/
sizeof
(
WCHAR
),
&
addr
->
Address
))
socket_address_to_string
(
addr_buf
,
ARRAY_SIZE
(
addr_buf
),
&
addr
->
Address
))
print_field
(
STRING_IP_ADDRESS
,
addr_buf
);
print_field
(
STRING_IP_ADDRESS
,
addr_buf
);
else
if
(
addr
->
Address
.
lpSockaddr
->
sa_family
==
AF_INET6
&&
else
if
(
addr
->
Address
.
lpSockaddr
->
sa_family
==
AF_INET6
&&
socket_address_to_string
(
addr_buf
,
sizeof
(
addr_buf
)
/
sizeof
(
WCHAR
),
&
addr
->
Address
))
socket_address_to_string
(
addr_buf
,
ARRAY_SIZE
(
addr_buf
),
&
addr
->
Address
))
print_field
(
STRING_IP6_ADDRESS
,
addr_buf
);
print_field
(
STRING_IP6_ADDRESS
,
addr_buf
);
/* FIXME: Output corresponding subnet mask. */
/* FIXME: Output corresponding subnet mask. */
}
}
if
(
p
->
FirstGatewayAddress
)
if
(
p
->
FirstGatewayAddress
)
{
{
if
(
socket_address_to_string
(
addr_buf
,
sizeof
(
addr_buf
)
/
sizeof
(
WCHAR
),
&
p
->
FirstGatewayAddress
->
Address
))
if
(
socket_address_to_string
(
addr_buf
,
ARRAY_SIZE
(
addr_buf
),
&
p
->
FirstGatewayAddress
->
Address
))
print_field
(
STRING_DEFAULT_GATEWAY
,
addr_buf
);
print_field
(
STRING_DEFAULT_GATEWAY
,
addr_buf
);
for
(
gateway
=
p
->
FirstGatewayAddress
->
Next
;
gateway
;
gateway
=
gateway
->
Next
)
for
(
gateway
=
p
->
FirstGatewayAddress
->
Next
;
gateway
;
gateway
=
gateway
->
Next
)
{
{
if
(
socket_address_to_string
(
addr_buf
,
sizeof
(
addr_buf
)
/
sizeof
(
WCHAR
),
&
gateway
->
Address
))
if
(
socket_address_to_string
(
addr_buf
,
ARRAY_SIZE
(
addr_buf
),
&
gateway
->
Address
))
print_value
(
addr_buf
);
print_value
(
addr_buf
);
}
}
}
}
...
...
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