1. Changed jsharp files to java files
2. Added CommandLauncher to allow java classes to be invoked from msi install
This commit is contained in:
@@ -0,0 +1,136 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <conio.h>
|
||||
#include <process.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define ERROR_NO_ERROR 0
|
||||
#define ERROR_MEMORY_ALLOCATION_FAILED -1
|
||||
#define ERROR_INVALID_NUMBER_OF_PARAMETERS -2
|
||||
#define ERROR_EXEC_E2BIG -3
|
||||
#define ERROR_EXEC_EACCES -4
|
||||
#define ERROR_EXEC_EINVAL -5
|
||||
#define ERROR_EXEC_EMFILE -6
|
||||
#define ERROR_EXEC_ENOENT -7
|
||||
#define ERROR_EXEC_ENOEXEC -8
|
||||
#define ERROR_EXEC_ENOMEM -9
|
||||
#define ERROR_EXEC_UNKNOWN -10
|
||||
|
||||
|
||||
char * errorMessage(int err)
|
||||
{
|
||||
switch (err)
|
||||
{
|
||||
case ERROR_NO_ERROR:
|
||||
return "No error\n";
|
||||
case ERROR_MEMORY_ALLOCATION_FAILED:
|
||||
return "Memory allocation failed\n";
|
||||
case ERROR_INVALID_NUMBER_OF_PARAMETERS:
|
||||
return "Invalid number of parameters\n";
|
||||
case ERROR_EXEC_E2BIG:
|
||||
return "_exec: The space required for the arguments and environment settings exceeds 32 KB.\n";
|
||||
case ERROR_EXEC_EACCES:
|
||||
return "_exec: The specified file has a locking or sharing violation.\n";
|
||||
case ERROR_EXEC_EINVAL:
|
||||
return "_exec: Invalid parameter.\n";
|
||||
case ERROR_EXEC_EMFILE:
|
||||
return "_exec: Too many files open (the specified file must be opened to determine whether it is executable).\n";
|
||||
case ERROR_EXEC_ENOENT:
|
||||
return "_exec: The file or path not found.\n";
|
||||
case ERROR_EXEC_ENOEXEC:
|
||||
return "_exec: The specified file is not executable or has an invalid executable-file format.\n";
|
||||
case ERROR_EXEC_ENOMEM:
|
||||
return "_exec: Not enough memory is available to execute the new process; the available memory has been corrupted; or an invalid block exists, indicating that the calling process was not allocated properly.\n";
|
||||
case ERROR_EXEC_UNKNOWN:
|
||||
return "Unknown _exec error.\n";
|
||||
default:
|
||||
return "Unknown error.\n";
|
||||
}
|
||||
}
|
||||
|
||||
int main( int cArg, char* rgArg[] )
|
||||
{
|
||||
int cArgCommand = cArg; // Take one off for the name of this exe, then add
|
||||
// one for the null at the end of the arg list.
|
||||
int i; // Looping variable
|
||||
int rc = ERROR_NO_ERROR; // Return code
|
||||
char **rgArgCommand; // An array for the command args
|
||||
|
||||
// Make sure we got enough parameters to execute.
|
||||
if( cArg < 4)
|
||||
{
|
||||
fprintf(stderr, errorMessage(ERROR_MEMORY_ALLOCATION_FAILED));
|
||||
fprintf( stderr, "Usage: %s <full path path to java.exe> <-cp classpath> <class> [arg1 [arg2 [...]]]\n", rgArg[0] );
|
||||
return ERROR_INVALID_NUMBER_OF_PARAMETERS;
|
||||
}
|
||||
|
||||
// Allocate room to the arglist for the cal to exec
|
||||
rgArgCommand = (char **)malloc(sizeof(char *)*cArgCommand);
|
||||
|
||||
// Did the memory allocation succeed?
|
||||
if (NULL == rgArgCommand)
|
||||
{
|
||||
fprintf(stderr, errorMessage(ERROR_MEMORY_ALLOCATION_FAILED));
|
||||
return ERROR_MEMORY_ALLOCATION_FAILED;
|
||||
}
|
||||
|
||||
fprintf( stderr, "Arg count = %d\n", cArg);
|
||||
fprintf( stderr, "Command arg count = %d\n", cArgCommand);
|
||||
|
||||
// copy over the arguments for the command
|
||||
for (i = 1; i < cArg; i++)
|
||||
{
|
||||
fprintf(stderr, "rgArgCommand[%d] = rgArg[%d] (%s)\n", (i - 1), i, rgArg[i]);
|
||||
rgArgCommand[i - 1] = rgArg[i];
|
||||
}
|
||||
|
||||
// null out the command arg array
|
||||
fprintf( stderr, "null out rgArgCommand[%d]\n",i);
|
||||
rgArgCommand[cArgCommand - 1] = (char *)0;
|
||||
|
||||
// exec the command
|
||||
if (-1 == _execv( rgArg[1], rgArgCommand))
|
||||
{
|
||||
switch (errno)
|
||||
{
|
||||
case E2BIG: // The space required for the arguments and environment settings exceeds 32 KB.
|
||||
rc = ERROR_EXEC_E2BIG;
|
||||
break;
|
||||
|
||||
case EACCES: // The specified file has a locking or sharing violation.
|
||||
rc = ERROR_EXEC_EACCES;
|
||||
break;
|
||||
|
||||
case EINVAL: // Invalid parameter.
|
||||
rc = ERROR_EXEC_EINVAL;
|
||||
break;
|
||||
|
||||
case EMFILE: // Too many files open (the specified file must be opened to determine whether it is executable).
|
||||
rc = ERROR_EXEC_EMFILE;
|
||||
break;
|
||||
|
||||
case ENOENT: // The file or path not found.
|
||||
rc = ERROR_EXEC_ENOENT;
|
||||
break;
|
||||
|
||||
case ENOEXEC: // The specified file is not executable or has an invalid executable-file format.
|
||||
rc = ERROR_EXEC_ENOEXEC;
|
||||
break;
|
||||
|
||||
case ENOMEM: // Not enough memory is available to execute the new process; the available memory has been
|
||||
// corrupted; or an invalid block exists, indicating that the calling process was not allocated
|
||||
// properly.
|
||||
rc = ERROR_EXEC_ENOMEM;
|
||||
break;
|
||||
|
||||
default:
|
||||
rc = ERROR_EXEC_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
free(rgArgCommand);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Name="CommandLauncher"
|
||||
ProjectGUID="{B52EF84A-D745-4637-9F59-DBD6E21C179C}"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="./bin"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="./bin"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\CommandLauncher.c"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
@@ -0,0 +1,69 @@
|
||||
#######################################################################
|
||||
#
|
||||
# Copyright (C) 2004 Novell, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program 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
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
#
|
||||
# Author: Greg Richardson <grichardson@novell.com>
|
||||
#
|
||||
#######################################################################
|
||||
|
||||
SUBDIRS =
|
||||
|
||||
DIST_SUBDIRS =
|
||||
|
||||
EXTRA_DIST = CommandLauncher.vcproj CommandLauncher.c
|
||||
|
||||
if DEBUG
|
||||
TARGET_CFG = Debug
|
||||
else
|
||||
TARGET_CFG = Release
|
||||
endif
|
||||
|
||||
PACKAGE = CommandLauncher
|
||||
TARGET_FILE = $(PACKAGE).exe
|
||||
LOG_FILE = $(PACKAGE).log
|
||||
|
||||
.PHONY: package package-clean package-install package-uninstall devenv
|
||||
|
||||
package: $(TARGET_FILE)
|
||||
|
||||
devenv:
|
||||
@if ! test -x "$(VSINSTALLDIR)/Common7/IDE/devenv.exe"; then echo "Error: Microsoft Visual Studio .NET is currently required to build MSI and MSM packages"; exit 1; fi
|
||||
|
||||
$(TARGET_FILE): devenv
|
||||
@rm -f $(LOG_FILE) $@
|
||||
@CMD='"$(VSINSTALLDIR)/Common7/IDE/devenv.exe" ../server-java_msi/server-java_msi.sln /build $(TARGET_CFG) /project $(PACKAGE) /out $(LOG_FILE)'; \
|
||||
echo $$CMD; \
|
||||
if eval $$CMD; then \
|
||||
ls -l bin/$(TARGET_FILE); \
|
||||
else \
|
||||
grep -a "ERROR:" $(LOG_FILE); \
|
||||
fi
|
||||
|
||||
package-clean clean-local:
|
||||
rm -rf Release/* Release Debug/* Debug*/Release */Debug *.log *.suo
|
||||
|
||||
clean:
|
||||
rm -rf Release/* Release Debug/* Debug */Release */Debug *.log *.suo
|
||||
|
||||
distclean-local: package-clean
|
||||
rm -f Makefile
|
||||
|
||||
maintainer-clean-local:
|
||||
rm -f Makefile.in
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user