From 06b8829b42c804c3dabb3d673834f22eb5b214b0 Mon Sep 17 00:00:00 2001 From: Hennes Rohling Date: Mon, 12 Mar 2001 11:16:12 +0000 Subject: #84390# Added wrapper executables --- desktop/win32/source/lwrapa.cxx | 2 + desktop/win32/source/lwrapw.cxx | 3 + desktop/win32/source/main.h | 13 +++ desktop/win32/source/makefile.mk | 90 ++++++++++++++++++++ desktop/win32/source/rwrapa.cxx | 2 + desktop/win32/source/rwrapw.cxx | 3 + desktop/win32/source/sowrapper.cxx | 10 +++ desktop/win32/source/wrapper.h | 167 +++++++++++++++++++++++++++++++++++++ desktop/win32/source/wrappera.cxx | 1 + desktop/win32/source/wrapperw.cxx | 2 + 10 files changed, 293 insertions(+) create mode 100644 desktop/win32/source/lwrapa.cxx create mode 100644 desktop/win32/source/lwrapw.cxx create mode 100644 desktop/win32/source/main.h create mode 100644 desktop/win32/source/makefile.mk create mode 100644 desktop/win32/source/rwrapa.cxx create mode 100644 desktop/win32/source/rwrapw.cxx create mode 100644 desktop/win32/source/sowrapper.cxx create mode 100644 desktop/win32/source/wrapper.h create mode 100644 desktop/win32/source/wrappera.cxx create mode 100644 desktop/win32/source/wrapperw.cxx diff --git a/desktop/win32/source/lwrapa.cxx b/desktop/win32/source/lwrapa.cxx new file mode 100644 index 000000000000..e69c0e3d4477 --- /dev/null +++ b/desktop/win32/source/lwrapa.cxx @@ -0,0 +1,2 @@ +#define LOCAL +#include "wrapper.h" \ No newline at end of file diff --git a/desktop/win32/source/lwrapw.cxx b/desktop/win32/source/lwrapw.cxx new file mode 100644 index 000000000000..ea0c8a5dac58 --- /dev/null +++ b/desktop/win32/source/lwrapw.cxx @@ -0,0 +1,3 @@ +#define LOCAL +#define UNICODE +#include "wrapper.h" \ No newline at end of file diff --git a/desktop/win32/source/main.h b/desktop/win32/source/main.h new file mode 100644 index 000000000000..01a32ace68bb --- /dev/null +++ b/desktop/win32/source/main.h @@ -0,0 +1,13 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +int MainA(); +int MainW(); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + diff --git a/desktop/win32/source/makefile.mk b/desktop/win32/source/makefile.mk new file mode 100644 index 000000000000..40d0d3266429 --- /dev/null +++ b/desktop/win32/source/makefile.mk @@ -0,0 +1,90 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: hro $ $Date: 2001-03-12 12:16:12 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (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.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/.. + +PRJNAME=desktop +TARGET=sowrap +LIBTARGET=NO +AUTOSEG=true + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk +.INCLUDE : $(UPD)minor.mk + +# --- Files -------------------------------------------------------- + +OBJFILES = \ + $(OBJ)$/wrappera.obj \ + $(OBJ)$/wrapperw.obj \ + $(OBJ)$/lwrapa.obj \ + $(OBJ)$/lwrapw.obj \ + $(OBJ)$/rwrapa.obj \ + $(OBJ)$/rwrapw.obj \ + $(OBJ)$/sowrapper.obj + +# --- Targets ------------------------------------------------------ + + +.INCLUDE : target.mk + diff --git a/desktop/win32/source/rwrapa.cxx b/desktop/win32/source/rwrapa.cxx new file mode 100644 index 000000000000..451e9bab9411 --- /dev/null +++ b/desktop/win32/source/rwrapa.cxx @@ -0,0 +1,2 @@ +#define REMOTE +#include "wrapper.h" \ No newline at end of file diff --git a/desktop/win32/source/rwrapw.cxx b/desktop/win32/source/rwrapw.cxx new file mode 100644 index 000000000000..85d79e21346b --- /dev/null +++ b/desktop/win32/source/rwrapw.cxx @@ -0,0 +1,3 @@ +#define REMOTE +#define UNICODE +#include "wrapper.h" \ No newline at end of file diff --git a/desktop/win32/source/sowrapper.cxx b/desktop/win32/source/sowrapper.cxx new file mode 100644 index 000000000000..19009514c523 --- /dev/null +++ b/desktop/win32/source/sowrapper.cxx @@ -0,0 +1,10 @@ +#include +#include "main.h" + +int APIENTRY WinMain( HINSTANCE, HINSTANCE, LPSTR, int ) +{ + if ( (LONG)GetVersion() < 0 ) + return MainA(); + else + return MainW(); +} diff --git a/desktop/win32/source/wrapper.h b/desktop/win32/source/wrapper.h new file mode 100644 index 000000000000..faacb6cb8aac --- /dev/null +++ b/desktop/win32/source/wrapper.h @@ -0,0 +1,167 @@ +#pragma once +#ifndef __cplusplus +#error Need C++ to compile +#endif + +#include "main.h" + +#ifndef _WINDOWS_ +# include +#endif + + +#ifndef _INC_TCHAR +# ifdef UNICODE +# define _UNICODE +# endif +# include +#endif + +#ifdef UNICODE +# define Main MainW +# define GetArgv( pArgc ) CommandLineToArgvW( GetCommandLine(), pArgc ) +# define PROCESS_CREATIONFLAGS CREATE_UNICODE_ENVIRONMENT +#else +# define GetArgv( pArgc ) (*pArgc = __argc, __argv) +# define PROCESS_CREATIONFLAGS 0 +# define Main MainA +#endif + +#define BIN_EXT_STR TEXT(".bin") +#define PARAM_LIBPATH_STR TEXT("-libpath=") +#define PARAM_LOCAL_STR TEXT("-local") +#define PARAM_REMOTE_STR TEXT("-remote") + +#if defined( REMOTE ) +#define DEFAULT_LIBPATH TEXT("remote;") +#elif defined( LOCAL ) +#define DEFAULT_LIBPATH TEXT("local;") +#endif + +extern "C" int Main() +{ + // Retreive startup info + + STARTUPINFO aStartupInfo; + + ZeroMemory( &aStartupInfo, sizeof(aStartupInfo) ); + aStartupInfo.cb = sizeof( aStartupInfo ); + GetStartupInfo( &aStartupInfo ); + + // Retrieve command line + + LPTSTR lpCommandLine = GetCommandLine(); + + LPTSTR *ppArguments = NULL; + int nArguments = 0; + + ppArguments = GetArgv( &nArguments ); + + // Calculate application name + + + TCHAR szApplicationName[MAX_PATH]; + TCHAR szDrive[MAX_PATH]; + TCHAR szDir[MAX_PATH]; + TCHAR szFileName[MAX_PATH]; + TCHAR szExt[MAX_PATH]; + + GetModuleFileName( NULL, szApplicationName, MAX_PATH ); + _tsplitpath( szApplicationName, szDrive, szDir, szFileName, szExt ); + _tmakepath( szApplicationName, szDrive, szDir, szFileName, BIN_EXT_STR ); + + // Retreive actual environment + + TCHAR szBuffer[1024]; + TCHAR szPathValue[1024] = TEXT(""); + +#ifdef DEFAULT_LIBPATH + _tmakepath( szPathValue, szDrive, szDir, DEFAULT_LIBPATH, TEXT("") ); +#endif + + for ( int argn = 1; argn < nArguments; argn++ ) + { + if ( 0 == _tcscmp( ppArguments[argn], PARAM_REMOTE_STR ) ) + { + _tmakepath( szPathValue, szDrive, szDir, TEXT("remote;"), TEXT("") ); + break; + } + else if ( 0 == _tcscmp( ppArguments[argn], PARAM_LOCAL_STR ) ) + { + _tmakepath( szPathValue, szDrive, szDir, TEXT("local;"), TEXT("") ); + break; + } + else if ( 0 == _tcsncmp( ppArguments[argn], PARAM_LIBPATH_STR, _tcslen(PARAM_LIBPATH_STR) ) ) + { + LPTSTR pFileSpec = NULL; + + GetFullPathName( ppArguments[argn] + _tcslen(PARAM_LIBPATH_STR), sizeof(szPathValue) / sizeof(TCHAR), szPathValue, &pFileSpec ); + _tcscat( szPathValue, TEXT(";") ); + break; + } + } + + GetEnvironmentVariable( TEXT("PATH"), szBuffer, sizeof(szBuffer) ); + _tcscat( szPathValue, szBuffer ); + SetEnvironmentVariable( TEXT("PATH"), szPathValue); + + LPVOID lpEnvironment = GetEnvironmentStrings(); + + + // Retrieve current directory + + TCHAR szCurrentDirectory[MAX_PATH]; + GetCurrentDirectory( MAX_PATH, szCurrentDirectory ); + + // Set the Flags + + DWORD dwCreationFlags = PROCESS_CREATIONFLAGS; + + PROCESS_INFORMATION aProcessInfo; + + BOOL fSuccess = CreateProcess( + szApplicationName, + lpCommandLine, + NULL, + NULL, + TRUE, + dwCreationFlags, + lpEnvironment, + szCurrentDirectory, + &aStartupInfo, + &aProcessInfo ); + + if ( fSuccess ) + { + DWORD dwExitCode; + + WaitForSingleObject( aProcessInfo.hProcess, INFINITE ); + fSuccess = GetExitCodeProcess( aProcessInfo.hProcess, &dwExitCode ); + + return dwExitCode; + } + + DWORD dwError = GetLastError(); + + LPVOID lpMsgBuf; + + FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM, + NULL, + dwError, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language + (LPTSTR)&lpMsgBuf, + 0, + NULL + ); + + // Display the string. + MessageBox( NULL, (LPCTSTR)lpMsgBuf, NULL, MB_OK | MB_ICONERROR ); + + // Free the buffer. + LocalFree( lpMsgBuf ); + + return GetLastError(); +} + diff --git a/desktop/win32/source/wrappera.cxx b/desktop/win32/source/wrappera.cxx new file mode 100644 index 000000000000..375fd913f466 --- /dev/null +++ b/desktop/win32/source/wrappera.cxx @@ -0,0 +1 @@ +#include "wrapper.h" \ No newline at end of file diff --git a/desktop/win32/source/wrapperw.cxx b/desktop/win32/source/wrapperw.cxx new file mode 100644 index 000000000000..a13a69ef01b3 --- /dev/null +++ b/desktop/win32/source/wrapperw.cxx @@ -0,0 +1,2 @@ +#define UNICODE +#include "wrapper.h" \ No newline at end of file -- cgit v1.2.3