summaryrefslogtreecommitdiff
path: root/desktop/win32
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2017-09-14 20:57:33 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2017-09-15 06:19:39 +0200
commitd2bf7caff23c875f7c058e07b4f18b3d76da0b0c (patch)
tree721cbf33e2031363e78b5e0ec69a02f8e8ba04b6 /desktop/win32
parent4830592796cdc42ca1f111840b5cc31a220b50d7 (diff)
loader: don't use 8-bit string functions
Change-Id: I13f4fcf86dd385cecfa0a8cfd34037352a42253f Reviewed-on: https://gerrit.libreoffice.org/42302 Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'desktop/win32')
-rw-r--r--desktop/win32/source/guiloader/genericloader.cxx41
-rw-r--r--desktop/win32/source/loader.cxx14
-rw-r--r--desktop/win32/source/loader.hxx8
-rw-r--r--desktop/win32/source/officeloader/officeloader.cxx63
4 files changed, 31 insertions, 95 deletions
diff --git a/desktop/win32/source/guiloader/genericloader.cxx b/desktop/win32/source/guiloader/genericloader.cxx
index db66ee39445b..8beb240c0316 100644
--- a/desktop/win32/source/guiloader/genericloader.cxx
+++ b/desktop/win32/source/guiloader/genericloader.cxx
@@ -17,42 +17,21 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#define UNICODE
-#define _UNICODE
-
-#define WIN32_LEAN_AND_MEAN
-#if defined _MSC_VER
-#pragma warning(push, 1)
-#endif
-#include <windows.h>
-#include <shellapi.h>
-#if defined _MSC_VER
-#pragma warning(pop)
-#endif
-
-#include <tchar.h>
-
-#include <malloc.h>
-#include <string.h>
-#include <stdlib.h>
-#include <systools/win32/uwinapi.h>
-
#include <tools/pathutils.hxx>
#include "../loader.hxx"
-
static int GenericMain()
{
- TCHAR szTargetFileName[MAX_PATH];
- TCHAR szIniDirectory[MAX_PATH];
- STARTUPINFO aStartupInfo;
+ WCHAR szTargetFileName[MAX_PATH];
+ WCHAR szIniDirectory[MAX_PATH];
+ STARTUPINFOW aStartupInfo;
desktop_win32::extendLoaderEnvironment(szTargetFileName, szIniDirectory);
ZeroMemory( &aStartupInfo, sizeof(aStartupInfo) );
aStartupInfo.cb = sizeof(aStartupInfo);
- GetStartupInfo( &aStartupInfo );
+ GetStartupInfoW( &aStartupInfo );
DWORD dwExitCode = (DWORD)-1;
@@ -70,9 +49,9 @@ static int GenericMain()
tools::buildPath(
redirect, szIniDirectory, szIniDirectory + iniDirLen,
MY_STRING(L"redirect.ini")) != nullptr &&
- (GetBinaryType(redirect, &dummy) || // cheaper check for file existence?
+ (GetBinaryTypeW(redirect, &dummy) || // cheaper check for file existence?
GetLastError() != ERROR_FILE_NOT_FOUND);
- LPTSTR cl1 = GetCommandLine();
+ LPWSTR cl1 = GetCommandLineW();
WCHAR * cl2 = new WCHAR[
wcslen(cl1) +
(hasRedirect
@@ -98,7 +77,7 @@ static int GenericMain()
}
desktop_win32::commandLineAppend(p, MY_STRING(L"\""));
- BOOL fSuccess = CreateProcess(
+ BOOL fSuccess = CreateProcessW(
szTargetFileName,
cl2,
nullptr,
@@ -127,7 +106,7 @@ static int GenericMain()
{
MSG msg;
- PeekMessage( &msg, nullptr, 0, 0, PM_REMOVE );
+ PeekMessageW( &msg, nullptr, 0, 0, PM_REMOVE );
}
} while ( WAIT_OBJECT_0 + 1 == dwWaitResult );
@@ -141,12 +120,12 @@ static int GenericMain()
return dwExitCode;
}
-int WINAPI _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int )
+int WINAPI wWinMain( HINSTANCE, HINSTANCE, LPWSTR, int )
{
return GenericMain();
}
-int __cdecl _tmain()
+int __cdecl wmain()
{
return GenericMain();
}
diff --git a/desktop/win32/source/loader.cxx b/desktop/win32/source/loader.cxx
index 9cb133d1d573..72bcafc50457 100644
--- a/desktop/win32/source/loader.cxx
+++ b/desktop/win32/source/loader.cxx
@@ -17,22 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <sal/config.h>
-
-#define WIN32_LEAN_AND_MEAN
-#if defined _MSC_VER
-#pragma warning(push, 1)
-#endif
-#include <windows.h>
-#include <shlwapi.h>
-#if defined _MSC_VER
-#pragma warning(pop)
-#endif
-
#include <tools/pathutils.hxx>
-
#include "loader.hxx"
-
#include <cassert>
namespace {
diff --git a/desktop/win32/source/loader.hxx b/desktop/win32/source/loader.hxx
index 365afa637ffe..059fae479958 100644
--- a/desktop/win32/source/loader.hxx
+++ b/desktop/win32/source/loader.hxx
@@ -20,11 +20,9 @@
#ifndef INCLUDED_DESKTOP_WIN32_SOURCE_LOADER_HXX
#define INCLUDED_DESKTOP_WIN32_SOURCE_LOADER_HXX
-#include <sal/config.h>
-
-#include <cstddef>
-
-#include <tchar.h>
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <string.h>
#define MY_LENGTH(s) (sizeof (s) / sizeof *(s) - 1)
#define MY_STRING(s) (s), MY_LENGTH(s)
diff --git a/desktop/win32/source/officeloader/officeloader.cxx b/desktop/win32/source/officeloader/officeloader.cxx
index 78c4bc1bfcec..c6987a72ec99 100644
--- a/desktop/win32/source/officeloader/officeloader.cxx
+++ b/desktop/win32/source/officeloader/officeloader.cxx
@@ -17,50 +17,23 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#define UNICODE
-#define _UNICODE
-
#include <cstddef>
-#include <cwchar>
-
-#define WIN32_LEAN_AND_MEAN
-#if defined _MSC_VER
-#pragma warning(push, 1)
-#endif
-#include <windows.h>
-#if defined _MSC_VER
-#pragma warning(pop)
-#endif
-
-#include <tchar.h>
-#include <string.h>
-#include <stdlib.h>
#include <systools/win32/uwinapi.h>
-
#include <desktop/exithelper.h>
-#include <rtl/string.h>
-#include <sal/macros.h>
#include "../loader.hxx"
-#include <config_version.h>
-
-static LPTSTR *GetCommandArgs( int *pArgc )
+static LPWSTR *GetCommandArgs( int *pArgc )
{
-#ifdef UNICODE
return CommandLineToArgvW( GetCommandLineW(), pArgc );
-#else
- *pArgc = __argc;
- return __argv;
-#endif
}
-int WINAPI _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int )
+int WINAPI wWinMain( HINSTANCE, HINSTANCE, LPWSTR, int )
{
- TCHAR szTargetFileName[MAX_PATH] = TEXT("");
- TCHAR szIniDirectory[MAX_PATH];
- STARTUPINFO aStartupInfo;
+ WCHAR szTargetFileName[MAX_PATH] = {};
+ WCHAR szIniDirectory[MAX_PATH];
+ STARTUPINFOW aStartupInfo;
desktop_win32::extendLoaderEnvironment(szTargetFileName, szIniDirectory);
@@ -69,7 +42,7 @@ int WINAPI _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int )
// Create process with same command line, environment and stdio handles which
// are directed to the created pipes
- GetStartupInfo(&aStartupInfo);
+ GetStartupInfoW(&aStartupInfo);
// If this process hasn't its stdio handles set, then check if its parent
// has a console (i.e. this process is launched from command line), and if so,
@@ -81,9 +54,9 @@ int WINAPI _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int )
DWORD dwExitCode = (DWORD)-1;
BOOL fSuccess = FALSE;
- LPTSTR lpCommandLine = nullptr;
+ LPWSTR lpCommandLine = nullptr;
int argc = 0;
- LPTSTR * argv = nullptr;
+ LPWSTR * argv = nullptr;
bool bFirst = true;
WCHAR cwd[MAX_PATH];
DWORD cwdLen = GetCurrentDirectoryW(MAX_PATH, cwd);
@@ -126,8 +99,8 @@ int WINAPI _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int )
desktop_win32::commandLineAppend(p, MY_STRING(L"\""));
bFirst = false;
- TCHAR szParentProcessId[64]; // This is more than large enough for a 128 bit decimal value
- BOOL bHeadlessMode( FALSE );
+ WCHAR szParentProcessId[64]; // This is more than large enough for a 128 bit decimal value
+ BOOL bHeadlessMode( FALSE );
{
// Check command line arguments for "--headless" parameter. We only
@@ -135,8 +108,8 @@ int WINAPI _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int )
// mode as self-destruction of the soffice.bin process can lead to
// certain side-effects (log-off can result in data-loss, ".lock" is not deleted.
// See 138244 for more information.
- int argc2;
- LPTSTR *argv2 = GetCommandArgs( &argc2 );
+ int argc2;
+ LPWSTR *argv2 = GetCommandArgs( &argc2 );
if ( argc2 > 1 )
{
@@ -144,8 +117,8 @@ int WINAPI _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int )
for ( n = 1; n < argc2; n++ )
{
- if ( 0 == _tcsnicmp( argv2[n], _T("-headless"), 9 ) ||
- 0 == _tcsnicmp( argv2[n], _T("--headless"), 10 ) )
+ if ( 0 == wcsnicmp( argv2[n], L"-headless", 9 ) ||
+ 0 == wcsnicmp( argv2[n], L"--headless", 10 ) )
{
bHeadlessMode = TRUE;
}
@@ -153,12 +126,12 @@ int WINAPI _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int )
}
}
- if ( _ltot( (long)GetCurrentProcessId(),szParentProcessId, 10 ) && bHeadlessMode )
- SetEnvironmentVariable( TEXT("ATTACHED_PARENT_PROCESSID"), szParentProcessId );
+ if ( _ltow( (long)GetCurrentProcessId(),szParentProcessId, 10 ) && bHeadlessMode )
+ SetEnvironmentVariableW( L"ATTACHED_PARENT_PROCESSID", szParentProcessId );
PROCESS_INFORMATION aProcessInfo;
- fSuccess = CreateProcess(
+ fSuccess = CreateProcessW(
szTargetFileName,
lpCommandLine,
nullptr,
@@ -185,7 +158,7 @@ int WINAPI _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int )
{
MSG msg;
- PeekMessage( &msg, nullptr, 0, 0, PM_REMOVE );
+ PeekMessageW( &msg, nullptr, 0, 0, PM_REMOVE );
}
} while ( WAIT_OBJECT_0 + 1 == dwWaitResult );