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
c0f00105
Commit
c0f00105
authored
Oct 08, 2018
by
Hans Leidekker
Committed by
Alexandre Julliard
Oct 08, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wmic: Pad output with spaces.
Signed-off-by:
Hans Leidekker
<
hans@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
46289779
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
17 deletions
+32
-17
main.c
programs/wmic/main.c
+32
-17
No files found.
programs/wmic/main.c
View file @
c0f00105
...
...
@@ -147,14 +147,14 @@ static int output_error( int msg )
return
output_string
(
GetStdHandle
(
STD_ERROR_HANDLE
),
fmtW
,
buffer
);
}
static
int
output_header
(
const
WCHAR
*
prop
)
static
int
output_header
(
const
WCHAR
*
prop
,
ULONG
column_width
)
{
static
const
WCHAR
bomW
[]
=
{
0xfeff
},
fmtW
[]
=
{
'%'
,
's'
,
'\r'
,
'\n'
,
0
};
static
const
WCHAR
bomW
[]
=
{
0xfeff
},
fmtW
[]
=
{
'%'
,
'
-'
,
'*'
,
'
s'
,
'\r'
,
'\n'
,
0
};
int
len
;
DWORD
count
;
WCHAR
buffer
[
8192
];
len
=
snprintfW
(
buffer
,
ARRAY_SIZE
(
buffer
),
fmtW
,
prop
);
len
=
snprintfW
(
buffer
,
ARRAY_SIZE
(
buffer
),
fmtW
,
column_width
,
prop
);
if
(
!
WriteConsoleW
(
GetStdHandle
(
STD_OUTPUT_HANDLE
),
buffer
,
len
,
&
count
,
NULL
))
/* redirected */
{
...
...
@@ -166,10 +166,10 @@ static int output_header( const WCHAR *prop )
return
count
;
}
static
int
output_line
(
const
WCHAR
*
str
)
static
int
output_line
(
const
WCHAR
*
str
,
ULONG
column_width
)
{
static
const
WCHAR
fmtW
[]
=
{
'%'
,
's'
,
'\r'
,
'\n'
,
0
};
return
output_string
(
GetStdHandle
(
STD_OUTPUT_HANDLE
),
fmtW
,
str
);
static
const
WCHAR
fmtW
[]
=
{
'%'
,
'
-'
,
'*'
,
'
s'
,
'\r'
,
'\n'
,
0
};
return
output_string
(
GetStdHandle
(
STD_OUTPUT_HANDLE
),
fmtW
,
column_width
,
str
);
}
static
int
query_prop
(
const
WCHAR
*
class
,
const
WCHAR
*
propname
)
...
...
@@ -186,6 +186,9 @@ static int query_prop( const WCHAR *class, const WCHAR *propname )
WCHAR
*
prop
=
NULL
;
BOOL
first
=
TRUE
;
int
len
,
ret
=
-
1
;
IWbemClassObject
*
obj
;
ULONG
count
,
width
=
0
;
VARIANT
v
;
WINE_TRACE
(
"%s, %s
\n
"
,
debugstr_w
(
class
),
debugstr_w
(
propname
));
...
...
@@ -210,29 +213,41 @@ static int query_prop( const WCHAR *class, const WCHAR *propname )
hr
=
IWbemServices_ExecQuery
(
services
,
wql
,
query
,
flags
,
NULL
,
&
result
);
if
(
hr
!=
S_OK
)
goto
done
;
for
(;;)
for
(;;)
/* get column width */
{
IWbemClassObject
*
obj
;
ULONG
count
;
VARIANT
v
;
IEnumWbemClassObject_Next
(
result
,
WBEM_INFINITE
,
1
,
&
obj
,
&
count
);
if
(
!
count
)
break
;
if
(
!
prop
&&
!
(
prop
=
find_prop
(
obj
,
propname
)))
{
output_error
(
STRING_INVALID_QUERY
);
goto
done
;
}
if
(
IWbemClassObject_Get
(
obj
,
prop
,
0
,
&
v
,
NULL
,
NULL
)
==
WBEM_S_NO_ERROR
)
{
VariantChangeType
(
&
v
,
&
v
,
0
,
VT_BSTR
);
width
=
max
(
strlenW
(
V_BSTR
(
&
v
)
),
width
);
VariantClear
(
&
v
);
}
IWbemClassObject_Release
(
obj
);
}
width
+=
2
;
IEnumWbemClassObject_Reset
(
result
);
for
(;;)
{
IEnumWbemClassObject_Next
(
result
,
WBEM_INFINITE
,
1
,
&
obj
,
&
count
);
if
(
!
count
)
break
;
if
(
first
)
{
if
(
!
(
prop
=
find_prop
(
obj
,
propname
)))
{
output_error
(
STRING_INVALID_QUERY
);
goto
done
;
}
output_header
(
prop
);
output_header
(
prop
,
width
);
first
=
FALSE
;
}
if
(
IWbemClassObject_Get
(
obj
,
prop
,
0
,
&
v
,
NULL
,
NULL
)
==
WBEM_S_NO_ERROR
)
{
VariantChangeType
(
&
v
,
&
v
,
0
,
VT_BSTR
);
output_line
(
V_BSTR
(
&
v
)
);
output_line
(
V_BSTR
(
&
v
)
,
width
);
VariantClear
(
&
v
);
}
IWbemClassObject_Release
(
obj
);
...
...
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