diff options
author | Steven Bennetts <steve@lindenlab.com> | 2008-03-15 01:18:27 +0000 |
---|---|---|
committer | Steven Bennetts <steve@lindenlab.com> | 2008-03-15 01:18:27 +0000 |
commit | 672a76d0ea08a0d0fc824e103ee4c4242b7e03ec (patch) | |
tree | b623a9c884383ad75ed755b2c373db2b90643671 /indra/newview/llappviewerwin32.cpp | |
parent | 04611efae8a3291ceba8a29dd920bdae0d404830 (diff) |
reverting premature commit at 82410.
Diffstat (limited to 'indra/newview/llappviewerwin32.cpp')
-rw-r--r-- | indra/newview/llappviewerwin32.cpp | 83 |
1 files changed, 65 insertions, 18 deletions
diff --git a/indra/newview/llappviewerwin32.cpp b/indra/newview/llappviewerwin32.cpp index fb726e7c97..09bcf6f7cc 100644 --- a/indra/newview/llappviewerwin32.cpp +++ b/indra/newview/llappviewerwin32.cpp @@ -55,13 +55,41 @@ #include "llviewernetwork.h" #include "llmd5.h" -#include "llcommandlineparser.h" +void fill_args(int& argc, char** argv, const S32 max_args, LPSTR cmd_line) +{ + char *token = NULL; + if( cmd_line[0] == '\"' ) + { + // Exe name is enclosed in quotes + token = strtok( cmd_line, "\"" ); + argv[argc++] = token; + token = strtok( NULL, " \t," ); + } + else + { + // Exe name is not enclosed in quotes + token = strtok( cmd_line, " \t," ); + } + while( (token != NULL) && (argc < max_args) ) + { + argv[argc++] = token; + /* Get next token: */ + if (*(token + strlen(token) + 1) == '\"') /* Flawfinder: ignore*/ + { + token = strtok( NULL, "\""); + } + else + { + token = strtok( NULL, " \t," ); + } + } +} + +// *NOTE:Mani - this code is stolen from LLApp, where its never actually used. LONG WINAPI viewer_windows_exception_handler(struct _EXCEPTION_POINTERS *exception_infop) { - // *NOTE:Mani - this code is stolen from LLApp, where its never actually used. - - // Translate the signals/exceptions into cross-platform stuff + // Translate the signals/exceptions into cross-platform stuff // Windows implementation llinfos << "Entering Windows Exception Handler..." << llendl; @@ -116,7 +144,21 @@ int APIENTRY WINMAIN(HINSTANCE hInstance, // *FIX: global gIconResource = MAKEINTRESOURCE(IDI_LL_ICON); - LLAppViewerWin32* viewer_app_ptr = new LLAppViewerWin32(lpCmdLine); + // In Win32, we need to generate argc and argv ourselves... + // Note: GetCommandLine() returns a potentially return a LPTSTR + // which can resolve to a LPWSTR (unicode string). + // (That's why it's different from lpCmdLine which is a LPSTR.) + // We don't currently do unicode, so call the non-unicode version + // directly. + LPSTR cmd_line_including_exe_name = GetCommandLineA(); + + const S32 MAX_ARGS = 100; + int argc = 0; + char* argv[MAX_ARGS]; /* Flawfinder: ignore */ + + fill_args(argc, argv, MAX_ARGS, cmd_line_including_exe_name); + + LLAppViewerWin32* viewer_app_ptr = new LLAppViewerWin32(); // *FIX:Mani This method is poorly named, since the exception // is now handled by LLApp. @@ -138,6 +180,13 @@ int APIENTRY WINMAIN(HINSTANCE hInstance, viewer_app_ptr->setErrorHandler(LLAppViewer::handleViewerCrash); + ok = viewer_app_ptr->tempStoreCommandOptions(argc, argv); + if(!ok) + { + llwarns << "Unable to parse command line." << llendl; + return -1; + } + ok = viewer_app_ptr->init(); if(!ok) { @@ -259,8 +308,7 @@ void create_console() setvbuf( stderr, NULL, _IONBF, 0 ); } -LLAppViewerWin32::LLAppViewerWin32(const char* cmd_line) : - mCmdLine(cmd_line) +LLAppViewerWin32::LLAppViewerWin32() { } @@ -291,11 +339,15 @@ bool LLAppViewerWin32::cleanup() return result; } -void LLAppViewerWin32::initConsole() +bool LLAppViewerWin32::initWindow() { - // pop up debug console - create_console(); - return LLAppViewer::initConsole(); + // pop up debug console if necessary + if (gUseConsole && gSavedSettings.getBOOL("ShowConsoleWindow")) + { + create_console(); + } + + return LLAppViewer::initWindow(); } void write_debug_dx(const char* str) @@ -316,7 +368,7 @@ bool LLAppViewerWin32::initHardwareTest() // Do driver verification and initialization based on DirectX // hardware polling and driver versions // - if (FALSE == gSavedSettings.getBOOL("NoHardwareProbe")) + if (gProbeHardware) { BOOL vram_only = !gSavedSettings.getBOOL("ProbeHardwareOnStartup"); @@ -379,11 +431,6 @@ bool LLAppViewerWin32::initHardwareTest() return true; } -bool LLAppViewerWin32::initParseCommandLine(LLCommandLineParser& clp) -{ - return clp.parseCommandLineString(mCmdLine); -} - void LLAppViewerWin32::handleCrashReporting() { // Windows only behaivor. Spawn win crash reporter. @@ -439,4 +486,4 @@ std::string LLAppViewerWin32::generateSerialNumber() llwarns << "GetVolumeInformation failed" << llendl; } return serial_md5; -} +}
\ No newline at end of file |