thank god a launcher

This commit is contained in:
benfry
2002-07-29 22:08:10 +00:00
parent b896673692
commit bd1c50dbdc
10 changed files with 591 additions and 0 deletions
@@ -0,0 +1,6 @@
// stdafx.cpp : source file that includes just the standard includes
// Imager.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
@@ -0,0 +1,25 @@
// 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__12C4E5A8_27C5_11D2_BB54_006008DC2F94__INCLUDED_)
#define AFX_STDAFX_H__12C4E5A8_27C5_11D2_BB54_006008DC2F94__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__12C4E5A8_27C5_11D2_BB54_006008DC2F94__INCLUDED_)
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

@@ -0,0 +1,163 @@
// Imager.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "launcher.h"
// The size of all of the strings was made sort of ambiguously large, since
// 1) nothing is hurt by allocating an extra few bytes temporarily and
// 2) if the user has a long path, and it gets copied five times over for the
// classpath, the program runs the risk of crashing. Bad bad.
#define STACKSIZE_ARGS "-mx60m -ms60m "
#define STACKSIZE_MATCH " -mx"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CImagerApp
BEGIN_MESSAGE_MAP(CImagerApp, CWinApp)
//{{AFX_MSG_MAP(CImagerApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CImagerApp construction
CImagerApp::CImagerApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CImagerApp object
CImagerApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CImagerApp initialization
BOOL CImagerApp::InitInstance()
{
// all these malloc statements... things may need to be larger.
// what was passed to this application
char *incoming_cmdline = (char *)malloc(256 * sizeof(char));
strcpy (incoming_cmdline, this->m_lpCmdLine);
// what gets put together to pass to jre
char *outgoing_cmdline = (char *)malloc(2048 * sizeof(char));
char *p = outgoing_cmdline;
// prepend the args for -mx and -ms if they weren't
// specified on the command line by the user
if (strstr(incoming_cmdline, STACKSIZE_MATCH)) {
// need to split stack args and documents
while (true) {
char c = *incoming_cmdline++;
if (c == ' ') {
if (*incoming_cmdline != '-') {
break;
} else {
*p++ = ' ';
}
} else if (c == 0) {
incoming_cmdline--;
*p++ = ' ';
break;
} else {
*p++ = c;
}
}
*p++ = 0;
} else {
strcpy(outgoing_cmdline, STACKSIZE_ARGS);
}
// append the classpath and imager.Application
char *cp = (char *)malloc(1024 * sizeof(char));
char *loaddir = (char *)malloc(MAX_PATH * sizeof(char));
GetModuleFileName(NULL, loaddir, MAX_PATH);
// remove the application name
*(strrchr(loaddir, '\\')) = '\0';
//cp = (char *)malloc(5 * strlen(loaddir) + 200);
// put quotes around contents of cp,
// because %s might have spaces in it.
sprintf(cp,
"-cp \""
"%s\\lib\\imager.jar;"
"%s\\lib\\swing.zip;"
"%s\\lib\\rt.jar;"
"%s\\lib\\i18n.jar;"
"%s\\lib\\classes.zip"
"\" ",
loaddir, loaddir, loaddir, loaddir, loaddir);
//buildClassPath(cp);
strcat(outgoing_cmdline, cp);
// add the name of the class to execute
strcat(outgoing_cmdline, "imager.Application ");
// append additional incoming stuff (document names), if any
strcat(outgoing_cmdline, incoming_cmdline);
//AfxMessageBox(outgoing_cmdline);
char *executable = (char *)malloc(256 * sizeof(char));
// loaddir is the name path to the current application
strcpy(executable, loaddir);
// copy in the path for jrew, relative to imager.exe
strcat(executable, "\\bin\\jrew");
//AfxMessageBox(executable);
char *path = (char *)malloc(1024 * sizeof(char));
char *old_path = (char *)malloc(1024 * sizeof(char));
strcpy(old_path, getenv("PATH"));
// need to add the lib directory to the path, because it contains the
// dll for the dongle, and eventually will also contain magician
strcpy(path, "PATH=");
strcat(path, old_path);
strcat(path, ";");
strcat(path, loaddir);
strcat(path, "\\lib");
//AfxMessageBox(path);
putenv(path);
HINSTANCE result;
result = ShellExecute(NULL, "open", executable,
outgoing_cmdline, NULL, SW_SHOWNORMAL);
if ((int)result <= 32) {
// some type of error occurred
switch ((int)result) {
case ERROR_FILE_NOT_FOUND:
case ERROR_PATH_NOT_FOUND:
AfxMessageBox("A required file could not be found, please re-install Imager.");
break;
case 0:
case SE_ERR_OOM:
AfxMessageBox("Not enough memory or resources to run Imager at this time.");
break;
default:
AfxMessageBox("There is a problem with your Imager installation.\n"
"If the problem persists, re-install Imager.");
break;
}
}
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return TRUE;
}
@@ -0,0 +1,136 @@
# Microsoft Developer Studio Project File - Name="Launcher" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=Launcher - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "Launcher.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "Launcher.mak" CFG="Launcher - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "Launcher - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "Launcher - Win32 Debug" (based on "Win32 (x86) Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "Launcher - Win32 Release"
# PROP BASE Use_MFC 6
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 6
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
# ADD RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
# ADD LINK32 /nologo /subsystem:windows /machine:I386
!ELSEIF "$(CFG)" == "Launcher - Win32 Debug"
# PROP BASE Use_MFC 6
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 6
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /FR /Yu"stdafx.h" /FD /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
# ADD RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
# ADD LINK32 /nologo /subsystem:windows /debug /machine:I386 /out:"launcher.exe" /pdbtype:sept
!ENDIF
# Begin Target
# Name "Launcher - Win32 Release"
# Name "Launcher - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\launcher.cpp
# End Source File
# Begin Source File
SOURCE=.\StdAfx.cpp
# ADD CPP /Yc"stdafx.h"
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\launcher.h
# End Source File
# Begin Source File
SOURCE=.\Resource.h
# End Source File
# Begin Source File
SOURCE=.\StdAfx.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\res\application.ico
# End Source File
# Begin Source File
SOURCE=.\res\document.ico
# End Source File
# Begin Source File
SOURCE=.\res\other.rc2
# End Source File
# End Group
# End Target
# End Project
@@ -0,0 +1,55 @@
// launcher.h : main header file for the LAUNCHER application
//
#if !defined(AFX_IMAGER_H__12C4E5A4_27C5_11D2_BB54_006008DC2F94__INCLUDED_)
#define AFX_IMAGER_H__12C4E5A4_27C5_11D2_BB54_006008DC2F94__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
extern "C" {
int java_main(int argc, char *argv[]);
}
/////////////////////////////////////////////////////////////////////////////
// CImagerApp:
// See Imager.cpp for the implementation of this class
//
class CImagerApp : public CWinApp
{
public:
CImagerApp();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CImagerApp)
public:
virtual BOOL InitInstance();
//}}AFX_VIRTUAL
void CImagerApp::buildClassPath(char*);
// Implementation
//{{AFX_MSG(CImagerApp)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_IMAGER_H__12C4E5A4_27C5_11D2_BB54_006008DC2F94__INCLUDED_)
@@ -0,0 +1,175 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
"#define _AFX_NO_OLE_RESOURCES\r\n"
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
"\r\n"
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
"#ifdef _WIN32\r\n"
"LANGUAGE 9, 1\r\n"
"#pragma code_page(1252)\r\n"
"#endif\r\n"
"#include ""res\\other.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
"#include ""afxres.rc"" // Standard components\r\n"
"#endif\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME ICON DISCARDABLE "res\\application.ico"
IDR_DOCUMENT ICON DISCARDABLE "res\\document.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_IMAGER_DIALOG DIALOGEX 0, 0, 185, 92
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "Launcher"
FONT 8, "MS Sans Serif", 0, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,128,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,128,23,50,14
LTEXT "TODO: Place dialog controls here.",IDC_STATIC,5,34,113,
8
END
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
IDR_MAINFRAME VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904B0"
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "Launcher MFC Application\0"
VALUE "FileVersion", "1, 0, 0, 1\0"
VALUE "InternalName", "Launcher\0"
VALUE "LegalCopyright", "Copyright (C) 1998\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "Launcher.EXE\0"
VALUE "ProductName", "Launcher Application\0"
VALUE "ProductVersion", "1, 0, 0, 1\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
#endif // !_MAC
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_IMAGER_DIALOG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 178
TOPMARGIN, 7
BOTTOMMARGIN, 85
END
END
#endif // APSTUDIO_INVOKED
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE 9, 1
#pragma code_page(1252)
#endif
#include "res\other.rc2" // non-Microsoft Visual C++ edited resources
#include "afxres.rc" // Standard components
#endif
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
@@ -0,0 +1,13 @@
//
// IMAGER.RC2 - resources Microsoft Visual C++ does not edit directly
//
#ifdef APSTUDIO_INVOKED
#error this file is not editable by Microsoft Visual C++
#endif //APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
// Add manually edited resources here...
/////////////////////////////////////////////////////////////////////////////
@@ -0,0 +1,18 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by Imager.rc
//
#define IDD_IMAGER_DIALOG 102
#define IDR_MAINFRAME 128
#define IDR_DOCUMENT 129
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 130
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif