clang-cl loplugin: desktop
Change-Id: If2f5bfa6c05098c5362cd6c7b546520dc01ee821 Reviewed-on: https://gerrit.libreoffice.org/29871 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
@@ -2070,7 +2070,7 @@ void Desktop::OpenClients()
|
|||||||
#if defined UNX
|
#if defined UNX
|
||||||
aHelpURLBuffer.append("&System=UNX");
|
aHelpURLBuffer.append("&System=UNX");
|
||||||
#elif defined WNT
|
#elif defined WNT
|
||||||
aHelpURLBuffer.appendAscii("&System=WIN");
|
aHelpURLBuffer.append("&System=WIN");
|
||||||
#endif
|
#endif
|
||||||
Application::GetHelp()->Start(
|
Application::GetHelp()->Start(
|
||||||
aHelpURLBuffer.makeStringAndClear(), nullptr);
|
aHelpURLBuffer.makeStringAndClear(), nullptr);
|
||||||
@@ -2664,7 +2664,7 @@ void Desktop::CheckFirstRun( )
|
|||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
if ( ERROR_SUCCESS == RegOpenKey( HKEY_LOCAL_MACHINE, "Software\\LibreOffice", &hKey ) )
|
if ( ERROR_SUCCESS == RegOpenKey( HKEY_LOCAL_MACHINE, "Software\\LibreOffice", &hKey ) )
|
||||||
{
|
{
|
||||||
if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("RunQuickstartAtFirstStart"), NULL, NULL, (LPBYTE)szValue, &nValueSize ) )
|
if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("RunQuickstartAtFirstStart"), nullptr, nullptr, reinterpret_cast<LPBYTE>(szValue), &nValueSize ) )
|
||||||
{
|
{
|
||||||
css::uno::Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
|
css::uno::Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
|
||||||
css::office::Quickstart::createAutoStart(xContext, true/*Quickstart*/, true/*bAutostart*/);
|
css::office::Quickstart::createAutoStart(xContext, true/*Quickstart*/, true/*bAutostart*/);
|
||||||
|
@@ -173,12 +173,12 @@ namespace desktop
|
|||||||
RTL_TEXTENCODING_ASCII_US).getStr());
|
RTL_TEXTENCODING_ASCII_US).getStr());
|
||||||
#else
|
#else
|
||||||
// rest gets a dialog box
|
// rest gets a dialog box
|
||||||
CmdlineHelpDialog aDlg;
|
ScopedVclPtrInstance<CmdlineHelpDialog> aDlg;
|
||||||
aDlg.m_pftHead->SetText(aHelpMessage_version + aHelpMessage_head);
|
aDlg->m_pftHead->SetText(aHelpMessage_version + aHelpMessage_head);
|
||||||
aDlg.m_pftLeft->SetText(aHelpMessage_left);
|
aDlg->m_pftLeft->SetText(aHelpMessage_left);
|
||||||
aDlg.m_pftRight->SetText(aHelpMessage_right);
|
aDlg->m_pftRight->SetText(aHelpMessage_right);
|
||||||
aDlg.m_pftBottom->SetText(aHelpMessage_bottom);
|
aDlg->m_pftBottom->SetText(aHelpMessage_bottom);
|
||||||
aDlg.Execute();
|
aDlg->Execute();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,24 +190,38 @@ namespace desktop
|
|||||||
fprintf(stdout, "%s", OUStringToOString(aVersionMsg, RTL_TEXTENCODING_ASCII_US).getStr());
|
fprintf(stdout, "%s", OUStringToOString(aVersionMsg, RTL_TEXTENCODING_ASCII_US).getStr());
|
||||||
#else
|
#else
|
||||||
// Just re-use the help dialog for now.
|
// Just re-use the help dialog for now.
|
||||||
CmdlineHelpDialog aDlg;
|
ScopedVclPtrInstance<CmdlineHelpDialog> aDlg;
|
||||||
aDlg.m_pftHead->SetText(aVersionMsg);
|
aDlg->m_pftHead->SetText(aVersionMsg);
|
||||||
aDlg.m_pftLeft->SetText("");
|
aDlg->m_pftLeft->SetText("");
|
||||||
aDlg.m_pftRight->SetText("");
|
aDlg->m_pftRight->SetText("");
|
||||||
aDlg.m_pftBottom->SetText("");
|
aDlg->m_pftBottom->SetText("");
|
||||||
aDlg.Execute();
|
aDlg->Execute();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef UNX
|
#ifndef UNX
|
||||||
CmdlineHelpDialog::CmdlineHelpDialog()
|
CmdlineHelpDialog::CmdlineHelpDialog()
|
||||||
: ModalDialog( NULL, "CmdLineHelp", "desktop/ui/cmdlinehelp.ui" )
|
: ModalDialog( nullptr, "CmdLineHelp", "desktop/ui/cmdlinehelp.ui" )
|
||||||
{
|
{
|
||||||
get(m_pftHead, "header");
|
get(m_pftHead, "header");
|
||||||
get(m_pftLeft, "left");
|
get(m_pftLeft, "left");
|
||||||
get(m_pftRight, "right");
|
get(m_pftRight, "right");
|
||||||
get(m_pftBottom, "bottom");
|
get(m_pftBottom, "bottom");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CmdlineHelpDialog::~CmdlineHelpDialog()
|
||||||
|
{
|
||||||
|
disposeOnce();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CmdlineHelpDialog::dispose()
|
||||||
|
{
|
||||||
|
m_pftHead.disposeAndClear();
|
||||||
|
m_pftLeft.disposeAndClear();
|
||||||
|
m_pftRight.disposeAndClear();
|
||||||
|
m_pftBottom.disposeAndClear();
|
||||||
|
ModalDialog::dispose();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -34,10 +34,15 @@ namespace desktop
|
|||||||
public:
|
public:
|
||||||
CmdlineHelpDialog();
|
CmdlineHelpDialog();
|
||||||
|
|
||||||
|
~CmdlineHelpDialog() override;
|
||||||
|
|
||||||
VclPtr<FixedText> m_pftHead;
|
VclPtr<FixedText> m_pftHead;
|
||||||
VclPtr<FixedText> m_pftLeft;
|
VclPtr<FixedText> m_pftLeft;
|
||||||
VclPtr<FixedText> m_pftRight;
|
VclPtr<FixedText> m_pftRight;
|
||||||
VclPtr<FixedText> m_pftBottom;
|
VclPtr<FixedText> m_pftBottom;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void dispose() override;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@@ -1136,7 +1136,7 @@ bool IpcThread::process(OString const & arguments, bool * waitProcessed) {
|
|||||||
#if defined UNX
|
#if defined UNX
|
||||||
aHelpURLBuffer.append("&System=UNX");
|
aHelpURLBuffer.append("&System=UNX");
|
||||||
#elif defined WNT
|
#elif defined WNT
|
||||||
aHelpURLBuffer.appendAscii("&System=WIN");
|
aHelpURLBuffer.append("&System=WIN");
|
||||||
#endif
|
#endif
|
||||||
ApplicationEvent* pAppEvent = new ApplicationEvent(
|
ApplicationEvent* pAppEvent = new ApplicationEvent(
|
||||||
ApplicationEvent::Type::OpenHelpUrl,
|
ApplicationEvent::Type::OpenHelpUrl,
|
||||||
|
@@ -682,7 +682,7 @@ void ExtensionCmdQueue::Thread::execute()
|
|||||||
//Needed for use of the service "com.sun.star.system.SystemShellExecute" in
|
//Needed for use of the service "com.sun.star.system.SystemShellExecute" in
|
||||||
//DialogHelper::openWebBrowser
|
//DialogHelper::openWebBrowser
|
||||||
CoUninitialize();
|
CoUninitialize();
|
||||||
(void) CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
(void) CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
|
||||||
#endif
|
#endif
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
@@ -471,7 +471,7 @@ void writeConsoleWithStream(OUString const & sText, HANDLE stream)
|
|||||||
{
|
{
|
||||||
DWORD nWrittenChars = 0;
|
DWORD nWrittenChars = 0;
|
||||||
WriteFile(stream, sText.getStr(),
|
WriteFile(stream, sText.getStr(),
|
||||||
sText.getLength() * 2, &nWrittenChars, NULL);
|
sText.getLength() * 2, &nWrittenChars, nullptr);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void writeConsoleWithStream(OUString const & sText, FILE * stream)
|
void writeConsoleWithStream(OUString const & sText, FILE * stream)
|
||||||
@@ -506,7 +506,7 @@ OUString readConsole()
|
|||||||
sal_Unicode aBuffer[1024];
|
sal_Unicode aBuffer[1024];
|
||||||
DWORD dwRead = 0;
|
DWORD dwRead = 0;
|
||||||
//unopkg.com feeds unopkg.exe with wchar_t|s
|
//unopkg.com feeds unopkg.exe with wchar_t|s
|
||||||
if (ReadFile( GetStdHandle(STD_INPUT_HANDLE), &aBuffer, sizeof(aBuffer), &dwRead, NULL ) )
|
if (ReadFile( GetStdHandle(STD_INPUT_HANDLE), &aBuffer, sizeof(aBuffer), &dwRead, nullptr ) )
|
||||||
{
|
{
|
||||||
OSL_ASSERT((dwRead % 2) == 0);
|
OSL_ASSERT((dwRead % 2) == 0);
|
||||||
OUString value( aBuffer, dwRead / 2);
|
OUString value( aBuffer, dwRead / 2);
|
||||||
|
@@ -46,9 +46,9 @@ static OString impl_getHostname()
|
|||||||
prevent windows from connecting to the net to get its own
|
prevent windows from connecting to the net to get its own
|
||||||
hostname by using the netbios name
|
hostname by using the netbios name
|
||||||
*/
|
*/
|
||||||
sal_Int32 sz = MAX_COMPUTERNAME_LENGTH + 1;
|
DWORD sz = MAX_COMPUTERNAME_LENGTH + 1;
|
||||||
char* szHost = new char[sz];
|
char* szHost = new char[sz];
|
||||||
if (GetComputerName(szHost, (LPDWORD)&sz))
|
if (GetComputerName(szHost, &sz))
|
||||||
aHost = OString(szHost);
|
aHost = OString(szHost);
|
||||||
else
|
else
|
||||||
aHost = OString("UNKNOWN");
|
aHost = OString("UNKNOWN");
|
||||||
|
@@ -19,17 +19,32 @@
|
|||||||
|
|
||||||
// QuickStart.cpp : Defines the entry point for the application.
|
// QuickStart.cpp : Defines the entry point for the application.
|
||||||
|
|
||||||
|
#include <sal/config.h>
|
||||||
|
|
||||||
|
#if defined _MSC_VER
|
||||||
|
#pragma warning(push, 1)
|
||||||
|
#endif
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#include <windows.h>
|
||||||
|
#include <shellapi.h>
|
||||||
|
#if defined _MSC_VER
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "StdAfx.h"
|
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#include <systools/win32/uwinapi.h>
|
#include <systools/win32/uwinapi.h>
|
||||||
#include <systools/win32/qswin32.h>
|
#include <systools/win32/qswin32.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
#include <memory.h>
|
||||||
|
#include <tchar.h>
|
||||||
|
|
||||||
bool SofficeRuns()
|
bool SofficeRuns()
|
||||||
{
|
{
|
||||||
// check for soffice by searching the communication window
|
// check for soffice by searching the communication window
|
||||||
return ( FindWindowEx( NULL, NULL, QUICKSTART_CLASSNAME, NULL ) == NULL ) ? false : true;
|
return FindWindowEx( nullptr, nullptr, QUICKSTART_CLASSNAME, nullptr ) != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool launchSoffice( )
|
bool launchSoffice( )
|
||||||
@@ -39,7 +54,7 @@ bool launchSoffice( )
|
|||||||
char filename[_MAX_PATH + 1];
|
char filename[_MAX_PATH + 1];
|
||||||
|
|
||||||
filename[_MAX_PATH] = 0;
|
filename[_MAX_PATH] = 0;
|
||||||
GetModuleFileName( NULL, filename, _MAX_PATH ); // soffice resides in the same dir
|
GetModuleFileName( nullptr, filename, _MAX_PATH ); // soffice resides in the same dir
|
||||||
char *p = strrchr( filename, '\\' );
|
char *p = strrchr( filename, '\\' );
|
||||||
if ( !p )
|
if ( !p )
|
||||||
return false;
|
return false;
|
||||||
@@ -72,7 +87,7 @@ int APIENTRY WinMain(HINSTANCE /*hInstance*/,
|
|||||||
{
|
{
|
||||||
if ( 0 == strcmp( __argv[i], "--killtray" ) )
|
if ( 0 == strcmp( __argv[i], "--killtray" ) )
|
||||||
{
|
{
|
||||||
HWND hwndTray = FindWindow( QUICKSTART_CLASSNAME, NULL );
|
HWND hwndTray = FindWindow( QUICKSTART_CLASSNAME, nullptr );
|
||||||
|
|
||||||
if ( hwndTray )
|
if ( hwndTray )
|
||||||
{
|
{
|
||||||
|
@@ -1,59 +0,0 @@
|
|||||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
||||||
/*
|
|
||||||
* This file is part of the LibreOffice project.
|
|
||||||
*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
*
|
|
||||||
* This file incorporates work covered by the following license notice:
|
|
||||||
*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed
|
|
||||||
* with this work for additional information regarding copyright
|
|
||||||
* ownership. The ASF licenses this file to you under the Apache
|
|
||||||
* License, Version 2.0 (the "License"); you may not use this file
|
|
||||||
* except in compliance with the License. You may obtain a copy of
|
|
||||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
||||||
*/
|
|
||||||
// stdafx.h : include file for standard system include files,
|
|
||||||
// or project specific include files that are used frequently, but
|
|
||||||
// are changed infrequently
|
|
||||||
|
|
||||||
|
|
||||||
#if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
|
|
||||||
#define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma once
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
|
||||||
|
|
||||||
|
|
||||||
// Windows Header Files:
|
|
||||||
#if defined _MSC_VER
|
|
||||||
#pragma warning(push, 1)
|
|
||||||
#endif
|
|
||||||
#include <windows.h>
|
|
||||||
#include <shellapi.h>
|
|
||||||
#if defined _MSC_VER
|
|
||||||
#pragma warning(pop)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// C RunTime Header Files
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
#include <memory.h>
|
|
||||||
#include <tchar.h>
|
|
||||||
|
|
||||||
// Local Header Files
|
|
||||||
|
|
||||||
// TODO: reference additional headers your program requires here
|
|
||||||
|
|
||||||
//{{AFX_INSERT_LOCATION}}
|
|
||||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
|
||||||
|
|
||||||
#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
|
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
|
@@ -43,7 +43,7 @@ extern "C" int APIENTRY _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int )
|
|||||||
LPTSTR lpCommandLine = GetCommandLine();
|
LPTSTR lpCommandLine = GetCommandLine();
|
||||||
|
|
||||||
{
|
{
|
||||||
lpCommandLine = (LPTSTR)_alloca( sizeof(_TCHAR) * (_tcslen(lpCommandLine) + _tcslen(APPLICATION_SWITCH) + 2) );
|
lpCommandLine = static_cast<LPTSTR>(_alloca( sizeof(_TCHAR) * (_tcslen(lpCommandLine) + _tcslen(APPLICATION_SWITCH) + 2) ));
|
||||||
|
|
||||||
_tcscpy( lpCommandLine, GetCommandLine() );
|
_tcscpy( lpCommandLine, GetCommandLine() );
|
||||||
_tcscat( lpCommandLine, _T(" ") );
|
_tcscat( lpCommandLine, _T(" ") );
|
||||||
@@ -59,7 +59,7 @@ extern "C" int APIENTRY _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int )
|
|||||||
TCHAR szFileName[MAX_PATH];
|
TCHAR szFileName[MAX_PATH];
|
||||||
TCHAR szExt[MAX_PATH];
|
TCHAR szExt[MAX_PATH];
|
||||||
|
|
||||||
GetModuleFileName( NULL, szApplicationName, MAX_PATH );
|
GetModuleFileName( nullptr, szApplicationName, MAX_PATH );
|
||||||
_tsplitpath( szApplicationName, szDrive, szDir, szFileName, szExt );
|
_tsplitpath( szApplicationName, szDrive, szDir, szFileName, szExt );
|
||||||
_tmakepath( szApplicationName, szDrive, szDir, _T("soffice"), _T(".exe") );
|
_tmakepath( szApplicationName, szDrive, szDir, _T("soffice"), _T(".exe") );
|
||||||
|
|
||||||
@@ -69,12 +69,12 @@ extern "C" int APIENTRY _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int )
|
|||||||
BOOL fSuccess = CreateProcess(
|
BOOL fSuccess = CreateProcess(
|
||||||
szApplicationName,
|
szApplicationName,
|
||||||
lpCommandLine,
|
lpCommandLine,
|
||||||
NULL,
|
nullptr,
|
||||||
NULL,
|
nullptr,
|
||||||
TRUE,
|
TRUE,
|
||||||
0,
|
0,
|
||||||
NULL,
|
nullptr,
|
||||||
NULL,
|
nullptr,
|
||||||
&aStartupInfo,
|
&aStartupInfo,
|
||||||
&aProcessInfo );
|
&aProcessInfo );
|
||||||
|
|
||||||
@@ -98,16 +98,16 @@ extern "C" int APIENTRY _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int )
|
|||||||
FormatMessage(
|
FormatMessage(
|
||||||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||||
FORMAT_MESSAGE_FROM_SYSTEM,
|
FORMAT_MESSAGE_FROM_SYSTEM,
|
||||||
NULL,
|
nullptr,
|
||||||
dwError,
|
dwError,
|
||||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
||||||
(LPTSTR)&lpMsgBuf,
|
reinterpret_cast<LPTSTR>(&lpMsgBuf),
|
||||||
0,
|
0,
|
||||||
NULL
|
nullptr
|
||||||
);
|
);
|
||||||
|
|
||||||
// Display the string.
|
// Display the string.
|
||||||
MessageBox( NULL, (LPCTSTR)lpMsgBuf, NULL, MB_OK | MB_ICONERROR );
|
MessageBox( nullptr, static_cast<LPCTSTR>(lpMsgBuf), nullptr, MB_OK | MB_ICONERROR );
|
||||||
|
|
||||||
// Free the buffer.
|
// Free the buffer.
|
||||||
LocalFree( lpMsgBuf );
|
LocalFree( lpMsgBuf );
|
||||||
|
@@ -69,7 +69,7 @@ static int GenericMain()
|
|||||||
bool hasRedirect =
|
bool hasRedirect =
|
||||||
tools::buildPath(
|
tools::buildPath(
|
||||||
redirect, szIniDirectory, szIniDirectory + iniDirLen,
|
redirect, szIniDirectory, szIniDirectory + iniDirLen,
|
||||||
MY_STRING(L"redirect.ini")) != NULL &&
|
MY_STRING(L"redirect.ini")) != nullptr &&
|
||||||
(GetBinaryType(redirect, &dummy) || // cheaper check for file existence?
|
(GetBinaryType(redirect, &dummy) || // cheaper check for file existence?
|
||||||
GetLastError() != ERROR_FILE_NOT_FOUND);
|
GetLastError() != ERROR_FILE_NOT_FOUND);
|
||||||
LPTSTR cl1 = GetCommandLine();
|
LPTSTR cl1 = GetCommandLine();
|
||||||
@@ -101,11 +101,11 @@ static int GenericMain()
|
|||||||
BOOL fSuccess = CreateProcess(
|
BOOL fSuccess = CreateProcess(
|
||||||
szTargetFileName,
|
szTargetFileName,
|
||||||
cl2,
|
cl2,
|
||||||
NULL,
|
nullptr,
|
||||||
NULL,
|
nullptr,
|
||||||
TRUE,
|
TRUE,
|
||||||
0,
|
0,
|
||||||
NULL,
|
nullptr,
|
||||||
szIniDirectory,
|
szIniDirectory,
|
||||||
&aStartupInfo,
|
&aStartupInfo,
|
||||||
&aProcessInfo );
|
&aProcessInfo );
|
||||||
@@ -127,7 +127,7 @@ static int GenericMain()
|
|||||||
{
|
{
|
||||||
MSG msg;
|
MSG msg;
|
||||||
|
|
||||||
PeekMessage( &msg, NULL, 0, 0, PM_REMOVE );
|
PeekMessage( &msg, nullptr, 0, 0, PM_REMOVE );
|
||||||
}
|
}
|
||||||
} while ( WAIT_OBJECT_0 + 1 == dwWaitResult );
|
} while ( WAIT_OBJECT_0 + 1 == dwWaitResult );
|
||||||
|
|
||||||
|
@@ -57,7 +57,7 @@ DWORD passOutputToConsole(HANDLE readPipe, HANDLE console)
|
|||||||
|
|
||||||
DWORD dwToRead = sizeof(aBuffer);
|
DWORD dwToRead = sizeof(aBuffer);
|
||||||
BYTE * pBuffer = aBuffer;
|
BYTE * pBuffer = aBuffer;
|
||||||
while ( ReadFile( hReadPipe, pBuffer, dwToRead, &dwRead, NULL ) )
|
while ( ReadFile( hReadPipe, pBuffer, dwToRead, &dwRead, nullptr ) )
|
||||||
{
|
{
|
||||||
//If the previous ReadFile call read an odd number of bytes, then the last one was
|
//If the previous ReadFile call read an odd number of bytes, then the last one was
|
||||||
//put at the front of the buffer. We increase the number of read bytes by one to reflect
|
//put at the front of the buffer. We increase the number of read bytes by one to reflect
|
||||||
@@ -66,13 +66,13 @@ DWORD passOutputToConsole(HANDLE readPipe, HANDLE console)
|
|||||||
dwRead++;
|
dwRead++;
|
||||||
//We must make sure that only complete wchar_t|s are written. WriteConsolse takes
|
//We must make sure that only complete wchar_t|s are written. WriteConsolse takes
|
||||||
//the number of wchar_t|s as argument. ReadFile, however, reads bytes.
|
//the number of wchar_t|s as argument. ReadFile, however, reads bytes.
|
||||||
bIncompleteWchar = (dwRead % 2) ? true : false;
|
bIncompleteWchar = (dwRead % 2) != 0;
|
||||||
if (bIncompleteWchar)
|
if (bIncompleteWchar)
|
||||||
{
|
{
|
||||||
//To test this case, give aBuffer a small odd size, e.g. aBuffer[3]
|
//To test this case, give aBuffer a small odd size, e.g. aBuffer[3]
|
||||||
//The last byte, which is the incomplete wchar_t (half of it), will not be written.
|
//The last byte, which is the incomplete wchar_t (half of it), will not be written.
|
||||||
(void) WriteConsoleW( console, aBuffer,
|
(void) WriteConsoleW( console, aBuffer,
|
||||||
(dwRead - 1) / 2, &dwWritten, NULL );
|
(dwRead - 1) / 2, &dwWritten, nullptr );
|
||||||
|
|
||||||
//Move the last byte to the front of the buffer, so that it is the start of the
|
//Move the last byte to the front of the buffer, so that it is the start of the
|
||||||
//next string
|
//next string
|
||||||
@@ -90,7 +90,7 @@ DWORD passOutputToConsole(HANDLE readPipe, HANDLE console)
|
|||||||
dwToRead = sizeof(aBuffer);
|
dwToRead = sizeof(aBuffer);
|
||||||
pBuffer = aBuffer;
|
pBuffer = aBuffer;
|
||||||
(void) WriteConsoleW( console,
|
(void) WriteConsoleW( console,
|
||||||
aBuffer, dwRead / 2, &dwWritten, NULL );
|
aBuffer, dwRead / 2, &dwWritten, nullptr );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ DWORD passOutputToConsole(HANDLE readPipe, HANDLE console)
|
|||||||
#ifdef UNOPKG
|
#ifdef UNOPKG
|
||||||
DWORD WINAPI OutputThread( LPVOID pParam )
|
DWORD WINAPI OutputThread( LPVOID pParam )
|
||||||
{
|
{
|
||||||
return passOutputToConsole((HANDLE)pParam, GetStdHandle( STD_OUTPUT_HANDLE ));
|
return passOutputToConsole(static_cast<HANDLE>(pParam), GetStdHandle( STD_OUTPUT_HANDLE ));
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@@ -128,7 +128,7 @@ DWORD WINAPI OutputThread( LPVOID pParam )
|
|||||||
#ifdef UNOPKG
|
#ifdef UNOPKG
|
||||||
DWORD WINAPI ErrorThread( LPVOID pParam )
|
DWORD WINAPI ErrorThread( LPVOID pParam )
|
||||||
{
|
{
|
||||||
return passOutputToConsole((HANDLE)pParam, GetStdHandle( STD_ERROR_HANDLE ));
|
return passOutputToConsole(static_cast<HANDLE>(pParam), GetStdHandle( STD_ERROR_HANDLE ));
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@@ -156,7 +156,7 @@ DWORD WINAPI ErrorThread( LPVOID pParam )
|
|||||||
DWORD WINAPI InputThread( LPVOID pParam )
|
DWORD WINAPI InputThread( LPVOID pParam )
|
||||||
{
|
{
|
||||||
DWORD dwRead = 0;
|
DWORD dwRead = 0;
|
||||||
HANDLE hWritePipe = (HANDLE)pParam;
|
HANDLE hWritePipe = static_cast<HANDLE>(pParam);
|
||||||
|
|
||||||
//We need to read in the complete input until we encounter a new line before
|
//We need to read in the complete input until we encounter a new line before
|
||||||
//converting to Unicode. This is necessary because the input string can use
|
//converting to Unicode. This is necessary because the input string can use
|
||||||
@@ -167,19 +167,19 @@ DWORD WINAPI InputThread( LPVOID pParam )
|
|||||||
//Characters may have one or multiple bytes and different byte ordering
|
//Characters may have one or multiple bytes and different byte ordering
|
||||||
//can be used (little and big endian);
|
//can be used (little and big endian);
|
||||||
int cNewLine = WideCharToMultiByte(
|
int cNewLine = WideCharToMultiByte(
|
||||||
GetConsoleCP(), 0, L"\r\n", 2, NULL, 0, NULL, NULL);
|
GetConsoleCP(), 0, L"\r\n", 2, nullptr, 0, nullptr, nullptr);
|
||||||
char * mbBuff = new char[cNewLine];
|
char * mbBuff = new char[cNewLine];
|
||||||
WideCharToMultiByte(
|
WideCharToMultiByte(
|
||||||
GetConsoleCP(), 0, L"\r\n", 2, mbBuff, cNewLine, NULL, NULL);
|
GetConsoleCP(), 0, L"\r\n", 2, mbBuff, cNewLine, nullptr, nullptr);
|
||||||
|
|
||||||
const DWORD dwBufferSize = 256;
|
const DWORD dwBufferSize = 256;
|
||||||
char* readBuf = (char*) malloc(dwBufferSize);
|
char* readBuf = static_cast<char*>(malloc(dwBufferSize));
|
||||||
int readAll = 0;
|
int readAll = 0;
|
||||||
DWORD curBufSize = dwBufferSize;
|
DWORD curBufSize = dwBufferSize;
|
||||||
|
|
||||||
while ( ReadFile( GetStdHandle( STD_INPUT_HANDLE ),
|
while ( ReadFile( GetStdHandle( STD_INPUT_HANDLE ),
|
||||||
readBuf + readAll,
|
readBuf + readAll,
|
||||||
curBufSize - readAll, &dwRead, NULL ) )
|
curBufSize - readAll, &dwRead, nullptr ) )
|
||||||
{
|
{
|
||||||
readAll += dwRead;
|
readAll += dwRead;
|
||||||
int lastBufSize = curBufSize;
|
int lastBufSize = curBufSize;
|
||||||
@@ -187,7 +187,7 @@ DWORD WINAPI InputThread( LPVOID pParam )
|
|||||||
if (readAll > curBufSize * 0.7)
|
if (readAll > curBufSize * 0.7)
|
||||||
{
|
{
|
||||||
curBufSize *= 2;
|
curBufSize *= 2;
|
||||||
readBuf = (char *) realloc(readBuf, curBufSize);
|
readBuf = static_cast<char *>(realloc(readBuf, curBufSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
//If the buffer was filled completely then
|
//If the buffer was filled completely then
|
||||||
@@ -206,7 +206,7 @@ DWORD WINAPI InputThread( LPVOID pParam )
|
|||||||
}
|
}
|
||||||
//Obtain the size of the buffer for the converted string.
|
//Obtain the size of the buffer for the converted string.
|
||||||
int sizeWBuf = MultiByteToWideChar(
|
int sizeWBuf = MultiByteToWideChar(
|
||||||
GetConsoleCP(), MB_PRECOMPOSED, readBuf, readAll, NULL, 0);
|
GetConsoleCP(), MB_PRECOMPOSED, readBuf, readAll, nullptr, 0);
|
||||||
|
|
||||||
wchar_t * wideBuf = new wchar_t[sizeWBuf];
|
wchar_t * wideBuf = new wchar_t[sizeWBuf];
|
||||||
|
|
||||||
@@ -215,7 +215,7 @@ DWORD WINAPI InputThread( LPVOID pParam )
|
|||||||
GetConsoleCP(), MB_PRECOMPOSED, readBuf, readAll, wideBuf, sizeWBuf);
|
GetConsoleCP(), MB_PRECOMPOSED, readBuf, readAll, wideBuf, sizeWBuf);
|
||||||
|
|
||||||
DWORD dwWritten;
|
DWORD dwWritten;
|
||||||
(void)WriteFile( hWritePipe, wideBuf, sizeWBuf * 2, &dwWritten, NULL );
|
(void)WriteFile( hWritePipe, wideBuf, sizeWBuf * 2, &dwWritten, nullptr );
|
||||||
|
|
||||||
delete[] wideBuf;
|
delete[] wideBuf;
|
||||||
readAll = 0;
|
readAll = 0;
|
||||||
@@ -297,7 +297,7 @@ int _tmain( int, _TCHAR ** )
|
|||||||
|
|
||||||
HANDLE hOutputRead, hOutputWrite;
|
HANDLE hOutputRead, hOutputWrite;
|
||||||
|
|
||||||
if ( CreatePipe( &hOutputRead, &hOutputWrite, NULL, 0 ) )
|
if ( CreatePipe( &hOutputRead, &hOutputWrite, nullptr, 0 ) )
|
||||||
{
|
{
|
||||||
HANDLE hTemp;
|
HANDLE hTemp;
|
||||||
|
|
||||||
@@ -312,7 +312,7 @@ int _tmain( int, _TCHAR ** )
|
|||||||
|
|
||||||
HANDLE hErrorRead, hErrorWrite;
|
HANDLE hErrorRead, hErrorWrite;
|
||||||
|
|
||||||
if ( CreatePipe( &hErrorRead, &hErrorWrite, NULL, 0 ) )
|
if ( CreatePipe( &hErrorRead, &hErrorWrite, nullptr, 0 ) )
|
||||||
{
|
{
|
||||||
HANDLE hTemp;
|
HANDLE hTemp;
|
||||||
|
|
||||||
@@ -327,7 +327,7 @@ int _tmain( int, _TCHAR ** )
|
|||||||
|
|
||||||
HANDLE hInputRead, hInputWrite;
|
HANDLE hInputRead, hInputWrite;
|
||||||
|
|
||||||
if ( CreatePipe( &hInputRead, &hInputWrite, NULL, 0 ) )
|
if ( CreatePipe( &hInputRead, &hInputWrite, nullptr, 0 ) )
|
||||||
{
|
{
|
||||||
HANDLE hTemp;
|
HANDLE hTemp;
|
||||||
|
|
||||||
@@ -342,7 +342,7 @@ int _tmain( int, _TCHAR ** )
|
|||||||
|
|
||||||
TCHAR szModuleFileName[MAX_PATH];
|
TCHAR szModuleFileName[MAX_PATH];
|
||||||
|
|
||||||
GetModuleFileName( NULL, szModuleFileName, MAX_PATH );
|
GetModuleFileName( nullptr, szModuleFileName, MAX_PATH );
|
||||||
_TCHAR *lpLastDot = _tcsrchr( szModuleFileName, '.' );
|
_TCHAR *lpLastDot = _tcsrchr( szModuleFileName, '.' );
|
||||||
if ( lpLastDot && 0 == _tcsicmp( lpLastDot, _T(".COM") ) )
|
if ( lpLastDot && 0 == _tcsicmp( lpLastDot, _T(".COM") ) )
|
||||||
{
|
{
|
||||||
@@ -357,12 +357,12 @@ int _tmain( int, _TCHAR ** )
|
|||||||
BOOL fSuccess = CreateProcess(
|
BOOL fSuccess = CreateProcess(
|
||||||
szTargetFileName,
|
szTargetFileName,
|
||||||
GetCommandLine(),
|
GetCommandLine(),
|
||||||
NULL,
|
nullptr,
|
||||||
NULL,
|
nullptr,
|
||||||
TRUE,
|
TRUE,
|
||||||
0,
|
0,
|
||||||
NULL,
|
nullptr,
|
||||||
NULL,
|
nullptr,
|
||||||
&aStartupInfo,
|
&aStartupInfo,
|
||||||
&aProcessInfo );
|
&aProcessInfo );
|
||||||
|
|
||||||
@@ -381,14 +381,14 @@ int _tmain( int, _TCHAR ** )
|
|||||||
|
|
||||||
DWORD dwOutputThreadId, dwErrorThreadId, dwInputThreadId;
|
DWORD dwOutputThreadId, dwErrorThreadId, dwInputThreadId;
|
||||||
|
|
||||||
HANDLE hOutputThread = CreateThread( NULL, 0, OutputThread, (LPVOID)hOutputRead, 0, &dwOutputThreadId );
|
HANDLE hOutputThread = CreateThread( nullptr, 0, OutputThread, static_cast<LPVOID>(hOutputRead), 0, &dwOutputThreadId );
|
||||||
HANDLE hErrorThread = CreateThread( NULL, 0, OutputThread, (LPVOID)hErrorRead, 0, &dwErrorThreadId );
|
HANDLE hErrorThread = CreateThread( nullptr, 0, OutputThread, static_cast<LPVOID>(hErrorRead), 0, &dwErrorThreadId );
|
||||||
HANDLE hInputThread = CreateThread( NULL, 0, InputThread, (LPVOID)hInputWrite, 0, &dwInputThreadId );
|
HANDLE hInputThread = CreateThread( nullptr, 0, InputThread, static_cast<LPVOID>(hInputWrite), 0, &dwInputThreadId );
|
||||||
|
|
||||||
// Create thread that wait until child process entered input idle
|
// Create thread that wait until child process entered input idle
|
||||||
|
|
||||||
DWORD dwWaitForUIThreadId;
|
DWORD dwWaitForUIThreadId;
|
||||||
HANDLE hWaitForUIThread = CreateThread( NULL, 0, WaitForUIThread, (LPVOID)aProcessInfo.hProcess, 0, &dwWaitForUIThreadId );
|
HANDLE hWaitForUIThread = CreateThread( nullptr, 0, WaitForUIThread, static_cast<LPVOID>(aProcessInfo.hProcess), 0, &dwWaitForUIThreadId );
|
||||||
|
|
||||||
HANDLE hObjects[] =
|
HANDLE hObjects[] =
|
||||||
{
|
{
|
||||||
|
@@ -36,12 +36,12 @@
|
|||||||
namespace desktop_win32 {
|
namespace desktop_win32 {
|
||||||
|
|
||||||
void getPaths(WCHAR * binPath, WCHAR * iniDirectory) {
|
void getPaths(WCHAR * binPath, WCHAR * iniDirectory) {
|
||||||
if (!GetModuleFileNameW(NULL, iniDirectory, MAX_PATH)) {
|
if (!GetModuleFileNameW(nullptr, iniDirectory, MAX_PATH)) {
|
||||||
LPWSTR buf = NULL;
|
LPWSTR buf = nullptr;
|
||||||
FormatMessageW(
|
FormatMessageW(
|
||||||
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL,
|
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, nullptr,
|
||||||
GetLastError(), 0, reinterpret_cast< LPWSTR >(&buf), 0, NULL);
|
GetLastError(), 0, reinterpret_cast< LPWSTR >(&buf), 0, nullptr);
|
||||||
MessageBoxW(NULL, buf, NULL, MB_OK | MB_ICONERROR);
|
MessageBoxW(nullptr, buf, nullptr, MB_OK | MB_ICONERROR);
|
||||||
LocalFree(buf);
|
LocalFree(buf);
|
||||||
TerminateProcess(GetCurrentProcess(), 255);
|
TerminateProcess(GetCurrentProcess(), 255);
|
||||||
}
|
}
|
||||||
|
@@ -79,9 +79,9 @@ int WINAPI _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int )
|
|||||||
DWORD dwExitCode = (DWORD)-1;
|
DWORD dwExitCode = (DWORD)-1;
|
||||||
|
|
||||||
BOOL fSuccess = FALSE;
|
BOOL fSuccess = FALSE;
|
||||||
LPTSTR lpCommandLine = NULL;
|
LPTSTR lpCommandLine = nullptr;
|
||||||
int argc = 0;
|
int argc = 0;
|
||||||
LPTSTR * argv = NULL;
|
LPTSTR * argv = nullptr;
|
||||||
bool bFirst = true;
|
bool bFirst = true;
|
||||||
WCHAR cwd[MAX_PATH];
|
WCHAR cwd[MAX_PATH];
|
||||||
DWORD cwdLen = GetCurrentDirectoryW(MAX_PATH, cwd);
|
DWORD cwdLen = GetCurrentDirectoryW(MAX_PATH, cwd);
|
||||||
@@ -159,11 +159,11 @@ int WINAPI _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int )
|
|||||||
fSuccess = CreateProcess(
|
fSuccess = CreateProcess(
|
||||||
szTargetFileName,
|
szTargetFileName,
|
||||||
lpCommandLine,
|
lpCommandLine,
|
||||||
NULL,
|
nullptr,
|
||||||
NULL,
|
nullptr,
|
||||||
TRUE,
|
TRUE,
|
||||||
0,
|
0,
|
||||||
NULL,
|
nullptr,
|
||||||
szIniDirectory,
|
szIniDirectory,
|
||||||
&aStartupInfo,
|
&aStartupInfo,
|
||||||
&aProcessInfo );
|
&aProcessInfo );
|
||||||
@@ -183,7 +183,7 @@ int WINAPI _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int )
|
|||||||
{
|
{
|
||||||
MSG msg;
|
MSG msg;
|
||||||
|
|
||||||
PeekMessage( &msg, NULL, 0, 0, PM_REMOVE );
|
PeekMessage( &msg, nullptr, 0, 0, PM_REMOVE );
|
||||||
}
|
}
|
||||||
} while ( WAIT_OBJECT_0 + 1 == dwWaitResult );
|
} while ( WAIT_OBJECT_0 + 1 == dwWaitResult );
|
||||||
|
|
||||||
|
@@ -39,7 +39,7 @@
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
wchar_t * getBrandPath(wchar_t * path) {
|
wchar_t * getBrandPath(wchar_t * path) {
|
||||||
DWORD n = GetModuleFileNameW(NULL, path, MAX_PATH);
|
DWORD n = GetModuleFileNameW(nullptr, path, MAX_PATH);
|
||||||
if (n == 0 || n >= MAX_PATH) {
|
if (n == 0 || n >= MAX_PATH) {
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@@ -59,7 +59,7 @@ void writePath(
|
|||||||
wchar_t path[MAX_PATH];
|
wchar_t path[MAX_PATH];
|
||||||
wchar_t * end = tools::buildPath(
|
wchar_t * end = tools::buildPath(
|
||||||
path, frontBegin, frontEnd, backBegin, backLength);
|
path, frontBegin, frontEnd, backBegin, backLength);
|
||||||
if (end == NULL) {
|
if (end == nullptr) {
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
std::size_t n = (end - path) * sizeof (wchar_t);
|
std::size_t n = (end - path) * sizeof (wchar_t);
|
||||||
|
Reference in New Issue
Block a user