Commit 02692970 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

wmic: Use wide-char string literals.

parent 98c67d86
...@@ -31,36 +31,6 @@ ...@@ -31,36 +31,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(wmic); WINE_DEFAULT_DEBUG_CHANNEL(wmic);
static const WCHAR biosW[] =
{'b','i','o','s',0};
static const WCHAR computersystemW[] =
{'c','o','m','p','u','t','e','r','s','y','s','t','e','m',0};
static const WCHAR cpuW[] =
{'c','p','u',0};
static const WCHAR logicaldiskW[] =
{'L','o','g','i','c','a','l','D','i','s','k',0};
static const WCHAR nicW[] =
{'n','i','c',0};
static const WCHAR osW[] =
{'o','s',0};
static const WCHAR processW[] =
{'p','r','o','c','e','s','s',0};
static const WCHAR win32_biosW[] =
{'W','i','n','3','2','_','B','I','O','S',0};
static const WCHAR win32_computersystemW[] =
{'W','i','n','3','2','_','C','o','m','p','u','t','e','r','S','y','s','t','e','m',0};
static const WCHAR win32_logicaldiskW[] =
{'W','i','n','3','2','_','L','o','g','i','c','a','l','D','i','s','k',0};
static const WCHAR win32_networkadapterW[] =
{'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',0};
static const WCHAR win32_operatingsystemW[] =
{'W','i','n','3','2','_','O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
static const WCHAR win32_processW[] =
{'W','i','n','3','2','_','P','r','o','c','e','s','s',0};
static const WCHAR win32_processorW[] =
{'W','i','n','3','2','_','P','r','o','c','e','s','s','o','r',0};
static const struct static const struct
{ {
const WCHAR *alias; const WCHAR *alias;
...@@ -68,13 +38,13 @@ static const struct ...@@ -68,13 +38,13 @@ static const struct
} }
alias_map[] = alias_map[] =
{ {
{ biosW, win32_biosW }, { L"bios", L"Win32_BIOS" },
{ computersystemW, win32_computersystemW }, { L"computersystem", L"Win32_ComputerSystem" },
{ cpuW, win32_processorW }, { L"cpu", L"Win32_Processor" },
{ logicaldiskW, win32_logicaldiskW }, { L"LogicalDisk", L"Win32_LogicalDisk" },
{ nicW, win32_networkadapterW }, { L"nic", L"Win32_NetworkAdapter" },
{ osW, win32_operatingsystemW }, { L"os", L"Win32_OperatingSystem" },
{ processW, win32_processW } { L"process", L"Win32_Process" }
}; };
static const WCHAR *find_class( const WCHAR *alias ) static const WCHAR *find_class( const WCHAR *alias )
...@@ -139,21 +109,20 @@ static int WINAPIV output_string( HANDLE handle, const WCHAR *msg, ... ) ...@@ -139,21 +109,20 @@ static int WINAPIV output_string( HANDLE handle, const WCHAR *msg, ... )
static int output_error( int msg ) static int output_error( int msg )
{ {
static const WCHAR fmtW[] = {'%','s',0};
WCHAR buffer[8192]; WCHAR buffer[8192];
LoadStringW( GetModuleHandleW(NULL), msg, buffer, ARRAY_SIZE(buffer)); LoadStringW( GetModuleHandleW(NULL), msg, buffer, ARRAY_SIZE(buffer));
return output_string( GetStdHandle(STD_ERROR_HANDLE), fmtW, buffer ); return output_string( GetStdHandle(STD_ERROR_HANDLE), L"%s", buffer );
} }
static int output_header( const WCHAR *prop, ULONG column_width ) 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};
int len; int len;
DWORD count; DWORD count;
WCHAR buffer[8192]; WCHAR buffer[8192];
len = swprintf( buffer, ARRAY_SIZE(buffer), fmtW, column_width, prop ); len = swprintf( buffer, ARRAY_SIZE(buffer), L"%-*s\r\n", column_width, prop );
if (!WriteConsoleW( GetStdHandle(STD_OUTPUT_HANDLE), buffer, len, &count, NULL )) /* redirected */ if (!WriteConsoleW( GetStdHandle(STD_OUTPUT_HANDLE), buffer, len, &count, NULL )) /* redirected */
{ {
...@@ -167,15 +136,11 @@ static int output_header( const WCHAR *prop, ULONG column_width ) ...@@ -167,15 +136,11 @@ static int output_header( const WCHAR *prop, ULONG column_width )
static int output_line( const WCHAR *str, ULONG column_width ) 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), L"%-*s\r\n", column_width, str );
return output_string( GetStdHandle(STD_OUTPUT_HANDLE), fmtW, column_width, str );
} }
static int query_prop( const WCHAR *class, const WCHAR *propname ) static int query_prop( const WCHAR *class, const WCHAR *propname )
{ {
static const WCHAR select_allW[] = {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',0};
static const WCHAR cimv2W[] = {'R','O','O','T','\\','C','I','M','V','2',0};
static const WCHAR wqlW[] = {'W','Q','L',0};
HRESULT hr; HRESULT hr;
IWbemLocator *locator = NULL; IWbemLocator *locator = NULL;
IWbemServices *services = NULL; IWbemServices *services = NULL;
...@@ -199,16 +164,16 @@ static int query_prop( const WCHAR *class, const WCHAR *propname ) ...@@ -199,16 +164,16 @@ static int query_prop( const WCHAR *class, const WCHAR *propname )
(void **)&locator ); (void **)&locator );
if (hr != S_OK) goto done; if (hr != S_OK) goto done;
if (!(path = SysAllocString( cimv2W ))) goto done; if (!(path = SysAllocString(L"ROOT\\CIMV2" ))) goto done;
hr = IWbemLocator_ConnectServer( locator, path, NULL, NULL, NULL, 0, NULL, NULL, &services ); hr = IWbemLocator_ConnectServer( locator, path, NULL, NULL, NULL, 0, NULL, NULL, &services );
if (hr != S_OK) goto done; if (hr != S_OK) goto done;
len = lstrlenW( class ) + ARRAY_SIZE(select_allW); len = lstrlenW( class ) + ARRAY_SIZE(L"SELECT * FROM ");
if (!(query = SysAllocStringLen( NULL, len ))) goto done; if (!(query = SysAllocStringLen( NULL, len ))) goto done;
lstrcpyW( query, select_allW ); lstrcpyW( query, L"SELECT * FROM " );
lstrcatW( query, class ); lstrcatW( query, class );
if (!(wql = SysAllocString( wqlW ))) goto done; if (!(wql = SysAllocString(L"WQL" ))) goto done;
hr = IWbemServices_ExecQuery( services, wql, query, flags, NULL, &result ); hr = IWbemServices_ExecQuery( services, wql, query, flags, NULL, &result );
if (hr != S_OK) goto done; if (hr != S_OK) goto done;
...@@ -267,12 +232,6 @@ done: ...@@ -267,12 +232,6 @@ done:
int __cdecl wmain(int argc, WCHAR *argv[]) int __cdecl wmain(int argc, WCHAR *argv[])
{ {
static const WCHAR getW[] = {'g','e','t',0};
static const WCHAR quitW[] = {'q','u','i','t',0};
static const WCHAR exitW[] = {'e','x','i','t',0};
static const WCHAR pathW[] = {'p','a','t','h',0};
static const WCHAR classW[] = {'c','l','a','s','s',0};
static const WCHAR contextW[] = {'c','o','n','t','e','x','t',0};
const WCHAR *class, *value; const WCHAR *class, *value;
int i; int i;
...@@ -282,20 +241,18 @@ int __cdecl wmain(int argc, WCHAR *argv[]) ...@@ -282,20 +241,18 @@ int __cdecl wmain(int argc, WCHAR *argv[])
if (i >= argc) if (i >= argc)
goto not_supported; goto not_supported;
if (!wcsicmp( argv[i], quitW ) || if (!wcsicmp( argv[i], L"quit" ) || !wcsicmp( argv[i], L"exit" ))
!wcsicmp( argv[i], exitW ))
{ {
return 0; return 0;
} }
if (!wcsicmp( argv[i], classW) || if (!wcsicmp( argv[i], L"class") || !wcsicmp( argv[i], L"context" ))
!wcsicmp( argv[i], contextW ))
{ {
WINE_FIXME( "command %s not supported\n", debugstr_w(argv[i]) ); WINE_FIXME( "command %s not supported\n", debugstr_w(argv[i]) );
goto not_supported; goto not_supported;
} }
if (!wcsicmp( argv[i], pathW )) if (!wcsicmp( argv[i], L"path" ))
{ {
if (++i >= argc) if (++i >= argc)
{ {
...@@ -317,7 +274,7 @@ int __cdecl wmain(int argc, WCHAR *argv[]) ...@@ -317,7 +274,7 @@ int __cdecl wmain(int argc, WCHAR *argv[])
if (++i >= argc) if (++i >= argc)
goto not_supported; goto not_supported;
if (!wcsicmp( argv[i], getW )) if (!wcsicmp( argv[i], L"get" ))
{ {
if (++i >= argc) if (++i >= argc)
goto not_supported; goto not_supported;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment