Пример #1
0
bool AyflyApp::OnInit()
{
    wxCmdLineParser cmdParser(g_cmdLineDesc, argc, argv);
    int res;
    {
        wxLogNull log;
        // Pass false to suppress auto Usage() message
        res = cmdParser.Parse(false);
    }
    int fileCount = cmdParser.GetParamCount();
    wxArrayString filenames;
    if(fileCount > 0)
    {        
        for(int i = 0; i < fileCount; i++)
        {
            wxString cmdFilename = cmdParser.GetParam(i);
            wxFileName fName(cmdFilename);
            fName.Normalize(wxPATH_NORM_LONG | wxPATH_NORM_DOTS | wxPATH_NORM_TILDE | wxPATH_NORM_ABSOLUTE);
            cmdFilename = fName.GetFullPath();
            filenames.Add(cmdFilename);
        }        
    }
    wxString title = wxT(WINDOW_TEXT);
    AyflyFrame *frame = new AyflyFrame(title.c_str(), filenames);

#ifndef _WIN32_WCE
    wxSize sz = frame->GetSize();
    sz.x = 550;
    sz.y = 400;
    frame->SetSize(sz);
#endif

    frame->Show(true);
    return true;
}
Пример #2
0
int main(int argc, const char *argv[])
{
    // Check arguments and ensure application to load specified
    if(!cmdParser(argc, argv)) {
    	icmMessage("E", PLATFORM, "Command Line parser error");
    	icmExitSimulation(1);
    	return 1;
    }
	// the constructor
	createPlatform();

	icmSimulationStarting();

    addPlatformDocumentation();

    // Ignore specific message that compatibility mode causes
    icmIgnoreMessage("ARM_MORPH_BII");

    // simulate the platform
    icmProcessorP final = icmSimulatePlatform();

    // was simulation interrupted or did it complete
    if(final && (icmGetStopReason(final)==ICM_SR_INTERRUPT)) {
        icmPrintf("*** simulation interrupted\n");
    }

    icmTerminate();

    icmExitSimulation(0);
    return 0;
}
Пример #3
0
int main(int argc, const char *argv[])
{
	// Check arguments and ensure application to load specified
	if(!cmdParser(argc, argv)) {
		icmMessage("E", "platform", "Command Line parser error");
		icmExitSimulation(1);
		return 1;
	}

    icmPrintf("3x cascaded transparent MMC\n");

	// the constructor
	createPlatform();

    icmSimulationStarting();

    // run until exit
    icmSimulatePlatform();

    // free simulation data structures
    icmTerminate();

    icmExitSimulation(0);
    return 0;
}
Пример #4
0
bool QSPApp::GetAutoRunEvent(wxInitEvent& initEvent)
{
	wxCmdLineParser cmdParser(argc, argv);
	if (argc > 1)
	{
		cmdParser.AddParam();
		cmdParser.Parse(false);
		wxFileName path(cmdParser.GetParam());
		path.MakeAbsolute();
		initEvent.SetInitString(path.GetFullPath());
		return true;
	}
	else
	{
		wxFileName autoPath(wxT("auto.qsp"));
		autoPath.MakeAbsolute();
		wxString autoPathString(autoPath.GetFullPath());
		if (wxFileExists(autoPathString))
		{
			initEvent.SetInitString(autoPathString);
			return true;
		}
	}
	return false;
}
Пример #5
0
int main(int argc, const char *argv[])
{
	// Check arguments and ensure application to load specified
	if(!cmdParser(argc, argv)) {
		icmMessage("E", "platform", "Command Line parser error");
		icmExitSimulation(1);
		return 1;
	}

	// the constructor
	createPlatform();

	icmSimulationStarting();

    // Run the processor for 100 instructions
    icmSimulate(handles.processor, 100);

    // Call a command that had been created in a processor model
    // Pointer to the call command result string. This could be any string
    const char *result;

    icmPrintf("\nCall Model Commands\n\n");

    // Setup calling arguments to read COP0 'Config' register
    const char *cmd1Argv[] = {"mipsCOP0", "16", "0"};

    result = icmCallCommand("platform/cpu1",
                            NULL,
                            cmd1Argv[0],
                            3,
                            &cmd1Argv[0]);

    icmPrintf("\nCall Command result '%s'\n", result);

    // Setup calling arguments to read COP0 'PrId' register
    const char *cmd2Argv[] = {"mipsCOP0", "15", "0"};

    result = icmCallCommand("platform/cpu1",
                            NULL,
                            cmd2Argv[0],
                            3,
                            &cmd2Argv[0]);

    icmPrintf("\nCall Command result '%s'\n", result);

    icmPrintf("\nDiscover installed commands\n");
    queryCommands();

    icmPrintf("\nComplete Simulation\n\n");

    // run simulation to completion
    icmSimulate(handles.processor, -1);

    // terminate simulation
    icmTerminate();

    icmExitSimulation(0);
    return 0;
}
Пример #6
0
bool MainApp::OnInit() {
    Settings settings = SettingsLoadFromFile();
	SettingsSetNewValues(settings);
    
    ChangeLanguage(settings.language);
    
	wxString cmdFilename = wxT("");
	wxCmdLineParser cmdParser(g_cmdLineDesc, argc, argv);
	int res;
	{
		wxLogNull log;
		// Pass false to suppress auto Usage() message
		res = cmdParser.Parse(false);
	}

	// Check if the user asked for command-line help
	if (res == -1 || res > 0 || cmdParser.Found(wxT("h")))
	{
		cmdParser.Usage();
		return false;
	}

	// Check if the user asked for the version
	if (cmdParser.Found(wxT("v")))
	{
#ifndef __WXMSW__
		wxLog::SetActiveTarget(new wxLogStderr);
#endif
		wxString msg = wxT("");
		msg << wxT(APP_NAME) << wxT(" ") << wxT(APP_VERSION);

		wxLogMessage(wxT("%s"), msg.c_str());
		return false;
	}

	// Check for a filename
	if (cmdParser.GetParamCount() > 0)
	{
		cmdFilename = cmdParser.GetParam(0);

		// Under Windows when invoking via a document
		// in Explorer, we are passed the short form.
		// So normalize and make the long form.
		wxFileName fName(cmdFilename);
		fName.Normalize(wxPATH_NORM_LONG|wxPATH_NORM_DOTS|wxPATH_NORM_TILDE|wxPATH_NORM_ABSOLUTE);
		cmdFilename = fName.GetFullPath();
	}

    // create the MainFrame
    frame = new MainFrame(cmdFilename);
    frame->Centre();
    frame->Show(true);

    // Our MainFrame is the Top Window
    SetTopWindow(frame);

    // initialization should always succeed
    return true;
}
Пример #7
0
int sc_main (int argc, char *argv[]) {
    if(!cmdParser(argc, (const char **)argv)) {
        return 1;
    }
    if(!postCmdParser())  {
        return 1;
    }
    programControl programControl ("programControl");

    sc_core::sc_start();
    return 0;
}
int sc_main (int argc, char *argv[]) {
    if(!cmdParser(argc, (const char **)argv)) {
        return 1;
    }
    if(!postCmdParser())  {
        return 1;
    }
    AlteraCycloneV_HPS_TLM2 AlteraCycloneV_HPS_TLM2 ("AlteraCycloneV_HPS_TLM2");

    sc_core::sc_start();
    return 0;
}
Пример #9
0
int main(int argc, const char *argv[]) {

    opcInit(OP_VERSION);
    optCmdParserP parser = oppCmdParserNew(MODULE_NAME, OPT_AC_ALL);
    cmdParser(parser);

    char message[1024];
    sprintf(message, "Basic Usage\n  %s\n"
                     "Debug Options\n"
                     "    --port <port number>  : open debug port\n"
                     "    --gbdconsole/--gdbgui : start and connect remote debugger in console or iGui mode\n"
			         "UART Console Options\n"
    		         "    Allows the user to open a port on a uart so that manually can connect a socket program, such as a telnet terminal to the uart"
    		         "    Default operation is to automatically open a console and connect to the UART"
    		         "    --uart0port <port number>  : set port number to open for uart1 sub-system 0\n"
                     "    --uart1port <port number>  : set port number to open for uart1 sub-system 1\n", argv[0]);
    oppCmdUsageMessage(parser, (const char *)message);

    oppCmdParseArgs(parser, argc, argv);

    if (oppCmdArgUsed (parser,"uart0port")) {
        char buf[32];
        snprintf(buf, sizeof(buf), "0x"FMT_6408x, options.uart0port);
        opcParamOverrideString(MODULE_NAME "/sys0/uart1/portnum", buf);					// Override the parameter to cause the UART to open port "portnum"
        opcParamOverrideString(MODULE_NAME "/sys0/uart1/diagnosticlevel", "1");
    } else {
        opcParamOverrideString(MODULE_NAME "/sys0/uart1/console", "1");					// Override the parameter to cause the UART to open a console
    }
    opcParamOverrideString(MODULE_NAME "/sys0/uart1/outfile", "uart0_1.log");			// Override the parameter to the UART log file

    if (oppCmdArgUsed (parser,"uart1port")) {
        char buf[32];
        snprintf(buf, sizeof(buf), "0x"FMT_6408x, options.uart1port);
        opcParamOverrideString(MODULE_NAME "/sys1/uart1/portnum", buf);					// Override the parameter to cause the UART to open port "portnum"
        opcParamOverrideString(MODULE_NAME "/sys1/uart1/diagnosticlevel", "1");
    } else {
        opcParamOverrideString(MODULE_NAME "/sys1/uart1/console", "1");					// Override the parameter to cause the UART to open a console
    }
    opcParamOverrideString(MODULE_NAME "/sys1/uart1/outfile", "uart1_1.log");			// Override the parameter to the UART log file

    optModuleP top = opcRootModuleNew(&modelAttrs, MODULE_NAME, 0);
    oprModuleSimulate(top);
    opcTerminate();
    return 0;
}
Пример #10
0
int
main(int argc, const char *argv[])
{

	// Check arguments and ensure application to load specified
	if(!cmdParser(argc, argv)) {
		icmMessage("E", PLATFORM, "Command Line parser error");
		icmExitSimulation(1);
		return 1;
	}

    // the constructor
    createPlatform();

    // run till the end
    icmSimulatePlatform();

    // finish and clean up
    icmTerminate();

    icmExitSimulation(0);
    return 0;
}
Пример #11
0
// Initialize the application
bool pyuvApp::OnInit()
{
#if 0
    int res;
#endif

	// restore settings
	wxConfig *config = new wxConfig("pyuv");
	pyuvLangCode = 0;
	config->Read("langcode", &pyuvLangCode);
	delete config;

    // Set the English locale
    //wxLocale(wxLANGUAGE_ENGLISH, wxLOCALE_LOAD_DEFAULT);
    initLanguageSupport2(pyuvLangCode);

    // Look for existing clients and set up an IPC server
    {
        pyuvClient* tmp_client = new pyuvClient;
        wxConnectionBase* connection = NULL;

        for(pyuvServno = 0; pyuvServno < MAX_NO_SERVERS; pyuvServno++)
        {
            wxLogNull noLog;

            if(!(connection = tmp_client->MakeConnection(wxEmptyString, wxString::Format(wxT("/tmp/PYUV%02d"), pyuvServno), wxT("intro"))))
            {
                break;
            }
            else
            {
                connection->Disconnect();
                connection = NULL;
            }
        }

        delete connection;
        delete tmp_client;
    }

    // Create the main application window
    frame = new pyuvFrame(pyuvTopbasetitle + wxT(" - a portable YUV player"));

    if(pyuvServno < MAX_NO_SERVERS)
    {
        m_server = new pyuvServer(frame);

        if(!m_server->Create(wxString::Format(wxT("/tmp/PYUV%02d"), pyuvServno)))
        {
            wxLogDebug(wxT("Failed to create an IPC service."));
        }
    }
    else
    {
        wxLogDebug(wxT("Increase number of IPC servers."));
    }

    // Init colors for slaves background
    int i = 0;
    if(i < MAX_NO_SERVERS)
    {
        pyuvSlaveColors[i++] = wxColour(*wxRED);
    }
    if(i < MAX_NO_SERVERS)
    {
        pyuvSlaveColors[i++] = wxColour(*wxBLUE);
    }
    if(i < MAX_NO_SERVERS)
    {
        pyuvSlaveColors[i++] = wxColour(*wxGREEN);
    }
    if(i < MAX_NO_SERVERS)
    {
        pyuvSlaveColors[i++] = wxColour(*wxCYAN);
    }
    if(i < MAX_NO_SERVERS)
    {
        pyuvSlaveColors[i++] = wxColour(wxString(wxT("ORANGE")));
    }
    if(i < MAX_NO_SERVERS)
    {
        pyuvSlaveColors[i++] = wxColour(wxString(wxT("SKY BLUE")));
    }
    if(i < MAX_NO_SERVERS)
    {
        pyuvSlaveColors[i++] = wxColour(wxString(wxT("GOLD")));
    }
    if(i < MAX_NO_SERVERS)
    {
        pyuvSlaveColors[i++] = wxColour(wxString(wxT("MAGENTA")));
    }
    if(i < MAX_NO_SERVERS)
    {
        pyuvSlaveColors[i++] = wxColour(wxString(wxT("AQUAMARINE")));
    }

    for(; i < MAX_NO_SERVERS; i++)
    {
        pyuvSlaveColors[i] = wxColour((uint8_t)(i * 18 + 31), (uint8_t)(i * 19 + 100), (uint8_t)(i * 13 + 200));
    }

    // Show it
    frame->Show(true);
    SetTopWindow(frame);

    // Parse command line
    wxCmdLineParser cmdParser(pyuvCommandLine, argc, argv);

    {
        // suppress disturbing warnings
        wxLogNull log;

        // Pass false to suppress auto Usage() message
#if 0
        res = cmdParser.Parse(false);
#else
        cmdParser.Parse(false);
#endif
    }

    // Check for a sequence filename
    if(cmdParser.GetParamCount() > 0)
    {
        frame->GetFileName() = cmdParser.GetParam(0);

        // Under Windows when invoking via a document
        // in Explorer, we are passed the short form.
        // So normalize and make the long form.
        wxFileName fName(frame->GetFileName());

        fName.Normalize(wxPATH_NORM_LONG|wxPATH_NORM_DOTS|wxPATH_NORM_TILDE|wxPATH_NORM_ABSOLUTE);
        frame->GetFileName() = fName.GetFullPath();

        // open the passed file
        frame->openfile(wxFileName(frame->GetFileName(), wxPATH_NATIVE));
    }

    // Add handler
#if 0
    // the wxBMPHandler is always installed, so no need to do it again
    wxImage::AddHandler(new wxBMPHandler);
#endif

    // Start the event loop
    return true;
}
Пример #12
0
DWORD GetFileListFromCmd(LPCTSTR lpCmd, LPCTSTR lpParam, CAtlArray<CString>& fileArray, LPCTSTR lpCurDir)
{
	if ( lpCmd == NULL || lpParam == NULL )
	{
		return 0;
	}

	LPCTSTR lpFileName = _tcsrchr(lpCmd, _T('\\'));
	if ( lpFileName != NULL )
	{
		lpFileName++;

		CCmdLineParser cmdParser((DWORD)0);
		if ( _tcscmp(lpFileName, _T("mshta.exe")) == 0 )
		{
			if ( cmdParser.DoParser(lpParam, lpCurDir, NULL, _T("hta")) )
			{
				fileArray.Add(cmdParser.GetCmd());
			}
		}
		else if ( _tcsicmp(lpFileName, _T("msiexec.exe")) == 0 )
		{
			LPCTSTR lpNextParam = skip_no_blank(lpParam);

			if ( _tcsnicmp(lpParam, _T("/i"), lpNextParam - lpParam) == 0 )
			{
				lpParam = skip_blank(lpNextParam);
				if ( cmdParser.DoParser(lpParam, lpCurDir, NULL, _T("msi")) )
				{
					fileArray.Add(cmdParser.GetCmd());
				}
			}
		}
		else if ( _tcsicmp(lpFileName, _T("rundll32.exe")) == 0 )
		{
			LPCTSTR lpNextParam = skip_no_blank(lpParam);

			if ( _tcsnicmp(lpParam, _T("shell32.dll,ShellExec_RunDLL"), lpNextParam - lpParam) == 0 )
			{
				lpParam = skip_blank(lpNextParam);
			}

			LPCTSTR lpXX = _tcschr(lpParam, _T(','));
			if ( lpXX != NULL )
			{
				*(LPTSTR)lpXX = 0;
			}

			if ( cmdParser.DoParser(lpParam, lpCurDir, NULL, _T("dll")) )
			{
				fileArray.Add(cmdParser.GetCmd());
			}

			if ( lpXX != NULL )
			{
				*(LPTSTR)lpXX = 0;
			}
		}
		else if ( _tcsicmp(lpFileName, _T("wscript.exe")) == 0 ||
			_tcsicmp(lpFileName, _T("cscript.exe")) == 0
			)
		{
			LPCTSTR lpStr = lpParam;
			while ( *lpStr != 0 )
			{
				lpStr = skip_blank(lpStr);
				if ( *lpStr == _T('/') || *lpStr == _T('-') )
				{
					lpStr = skip_no_blank(lpStr);
				}
				else//
				{
					if ( cmdParser.DoParser(lpStr, lpCurDir, NULL, _T("wsh;vbs;vbe;")) )
					{
						fileArray.Add(cmdParser.GetCmd());
					}
					break;
				}//
			}
		}
		else if ( _tcsicmp(lpFileName, _T("cmd.exe")) == 0 )
		{
			LPCTSTR lpStr = lpParam;
			while ( *lpStr != 0 )
			{
				lpStr = skip_blank(lpStr);
				if ( *lpStr == _T('/') || *lpStr == _T('-') )
				{
					lpStr = skip_no_blank(lpStr);
				}
				else
				{
					if ( cmdParser.DoParser(lpStr, lpCurDir, NULL, _T("bat;cmd;exe;")) )
					{
						fileArray.Add(cmdParser.GetCmd());
						GetFileListFromCmd(cmdParser, fileArray, lpCurDir);
					}
					break;
				}
			}
		}
		else if ( _tcsicmp(lpFileName, _T("regsvr32.exe")) == 0 )
		{
			LPCTSTR lpStr = lpParam;
			while ( *lpStr != 0 )
			{
				lpStr = skip_blank(lpStr);
				if ( *lpStr == _T('/') || *lpStr == _T('-') )
				{
					lpStr = skip_no_blank(lpStr);
				}
				else
				{
					if ( cmdParser.DoParser(lpStr, lpCurDir) )
					{
						fileArray.Add(cmdParser.GetCmd());
					}
					break;
				}
			}
		}
	}

	return (DWORD)fileArray.GetCount();
}
Пример #13
0
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow)
{
    PF_CONSOLE_INIT_ALL()

    // Set global handle
    gHInst = hInst;

    CCmdParser cmdParser(s_cmdLineArgs, arrsize(s_cmdLineArgs));
    cmdParser.Parse();

    bool doIntroDialogs = true;
#ifndef PLASMA_EXTERNAL_RELEASE
    if (cmdParser.IsSpecified(kArgSkipLoginDialog))
        doIntroDialogs = false;
    if (cmdParser.IsSpecified(kArgLocalData))
    {
        gDataServerLocal = true;
        gSkipPreload = true;
    }
    if (cmdParser.IsSpecified(kArgSkipPreload))
        gSkipPreload = true;
#endif

    plFileName serverIni = "server.ini";
    if (cmdParser.IsSpecified(kArgServerIni))
        serverIni = plString::FromWchar(cmdParser.GetString(kArgServerIni));

    // check to see if we were launched from the patcher
    bool eventExists = false;
    // we check to see if the event exists that the patcher should have created
    HANDLE hPatcherEvent = CreateEventW(nil, TRUE, FALSE, L"UruPatcherEvent");
    if (hPatcherEvent != NULL)
    {
        // successfully created it, check to see if it was already created
        if (GetLastError() == ERROR_ALREADY_EXISTS)
        {
            // it already existed, so the patcher is waiting, signal it so the patcher can die
            SetEvent(hPatcherEvent);
            eventExists = true;
        }
    }

#ifdef PLASMA_EXTERNAL_RELEASE
    // if the client was started directly, run the patcher, and shutdown
    STARTUPINFOW si;
    PROCESS_INFORMATION pi; 
    memset(&si, 0, sizeof(si));
    memset(&pi, 0, sizeof(pi));
    si.cb = sizeof(si);

    const char** addrs;
    
    if (!eventExists) // if it is missing, assume patcher wasn't launched
    {
        plStringStream cmdLine;

        GetAuthSrvHostnames(&addrs);
        if (strlen(addrs[0]))
            cmdLine << " /AuthSrv=" << addrs[0];

        GetFileSrvHostnames(&addrs);
        if (strlen(addrs[0]))
            cmdLine << " /FileSrv=" << addrs[0];

        GetGateKeeperSrvHostnames(&addrs);
        if (strlen(addrs[0]))
            cmdLine << " /GateKeeperSrv=" << addrs[0];

        if(!CreateProcessW(s_patcherExeName, (LPWSTR)cmdLine.GetString().ToUtf16().GetData(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
        {
            hsMessageBox("Failed to launch patcher", "Error", hsMessageBoxNormal);
        }
        CloseHandle( pi.hThread );
        CloseHandle( pi.hProcess );
        return PARABLE_NORMAL_EXIT;
    }
#endif

    // Load an optional general.ini
    plFileName gipath = plFileName::Join(plFileSystem::GetInitPath(), "general.ini");
    FILE *generalini = plFileSystem::Open(gipath, "rb");
    if (generalini)
    {
        fclose(generalini);
        pfConsoleEngine tempConsole;
        tempConsole.ExecuteFile(gipath);
    }

#ifdef PLASMA_EXTERNAL_RELEASE
    // If another instance is running, exit.  We'll automatically release our
    // lock on the mutex when our process exits
    HANDLE hOneInstance = CreateMutex(nil, FALSE, "UruExplorer");
    if (WaitForSingleObject(hOneInstance,0) != WAIT_OBJECT_0)
    {
        switch (plLocalization::GetLanguage())
        {
            case plLocalization::kFrench:
                hsMessageBox("Une autre copie d'URU est déjà en cours d'exécution", "Erreur", hsMessageBoxNormal);
                break;
            case plLocalization::kGerman:
                hsMessageBox("URU wird bereits in einer anderen Instanz ausgeführt", "Fehler", hsMessageBoxNormal);
                break;
            case plLocalization::kSpanish:
                hsMessageBox("En estos momentos se está ejecutando otra copia de URU", "Error", hsMessageBoxNormal);
                break;
            case plLocalization::kItalian:
                hsMessageBox("Un'altra copia di URU è già aperta", "Errore", hsMessageBoxNormal);
                break;
            // default is English
            default:
                hsMessageBox("Another copy of URU is already running", "Error", hsMessageBoxNormal);
                break;
        }
        return PARABLE_NORMAL_EXIT;
    }
#endif

    FILE *serverIniFile = plFileSystem::Open(serverIni, "rb");
    if (serverIniFile)
    {
        fclose(serverIniFile);
        pfConsoleEngine tempConsole;
        tempConsole.ExecuteFile(serverIni);
    }
    else
    {
        hsMessageBox("No server.ini file found.  Please check your URU installation.", "Error", hsMessageBoxNormal);
        return PARABLE_NORMAL_EXIT;
    }

    NetCliAuthAutoReconnectEnable(false);

    NetCommSetReadIniAccountInfo(!doIntroDialogs);
    InitNetClientComm();

    curl_global_init(CURL_GLOBAL_ALL);

    bool                needExit = false;
    LoginDialogParam    loginParam;
    memset(&loginParam, 0, sizeof(loginParam));
    LoadUserPass(&loginParam);

    if (!doIntroDialogs && loginParam.remember) {
        ENetError auth;

        NetCommSetAccountUsernamePassword(loginParam.username, loginParam.namePassHash);
        bool cancelled = AuthenticateNetClientComm(&auth, NULL);

        if (IS_NET_ERROR(auth) || cancelled) {
            doIntroDialogs = true;

            loginParam.authError = auth;

            if (cancelled)
            {
                NetCommDisconnect();
            }
        }
    }

    if (doIntroDialogs) {
        needExit = ::DialogBoxParam( hInst, MAKEINTRESOURCE( IDD_URULOGIN_MAIN ), NULL, UruLoginDialogProc, (LPARAM)&loginParam ) <= 0;
    }

    if (doIntroDialogs && !needExit) {
        HINSTANCE hRichEdDll = LoadLibrary("RICHED20.DLL");
        INT_PTR val = ::DialogBoxParam( hInst, MAKEINTRESOURCE( IDD_URULOGIN_EULA ), NULL, UruTOSDialogProc, (LPARAM)hInst);
        FreeLibrary(hRichEdDll);
        if (val <= 0) {
            DWORD error = GetLastError();
            needExit = true;
        }
    }

    curl_global_cleanup();

    if (needExit) {
        DeInitNetClientComm();
        return PARABLE_NORMAL_EXIT;
    }

    NetCliAuthAutoReconnectEnable(true);

    // VERY VERY FIRST--throw up our splash screen
    HWND splashDialog = ::CreateDialog( hInst, MAKEINTRESOURCE( IDD_LOADING ), NULL, SplashDialogProc );

    // Install our unhandled exception filter for trapping all those nasty crashes in release build
#ifndef HS_DEBUGGING
    LPTOP_LEVEL_EXCEPTION_FILTER oldFilter;
    oldFilter = SetUnhandledExceptionFilter( plCustomUnhandledExceptionFilter );
#endif

    //
    // Set up to log errors by using hsDebugMessage
    //
    DebugInit();
    DebugMsgF("Plasma 2.0.%i.%i - %s", PLASMA2_MAJOR_VERSION, PLASMA2_MINOR_VERSION, plProduct::ProductString().c_str());

    for (;;) {
        // Create Window
        if (!WinInit(hInst, nCmdShow) || gClient->GetDone())
            break;

        // Done with our splash now
        ::DestroyWindow( splashDialog );

        if (!gClient)
            break;

        // Show the main window
        ShowWindow(gClient->GetWindowHandle(), SW_SHOW);
            
        // Be really REALLY forceful about being in the front
        BringWindowToTop( gClient->GetWindowHandle() );

        // Update the window
        UpdateWindow(gClient->GetWindowHandle());

        // 
        // Init Application here
        //
        if( !gClient->StartInit() )
            break;
        
        // I want it on top! I mean it!
        BringWindowToTop( gClient->GetWindowHandle() );

        // initialize dinput here:
        if (gClient && gClient->GetInputManager())
            gClient->GetInputManager()->InitDInput(hInst, (HWND)gClient->GetWindowHandle());
        
        // Seriously!
        BringWindowToTop( gClient->GetWindowHandle() );
        
        //
        // Main loop
        //
        MSG msg;
        do
        {   
            gClient->MainLoop();

            if( gClient->GetDone() )
                break;

            // Look for a message
            while (PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ))
            {
                // Handle the message
                TranslateMessage( &msg );
                DispatchMessage( &msg );
            }
        } while (WM_QUIT != msg.message);

        break;
    }

    //
    // Cleanup
    //
    if (gClient)
    {
        gClient->Shutdown(); // shuts down PhysX for us
        gClient = nil;
    }
    hsAssert(hsgResMgr::ResMgr()->RefCnt()==1, "resMgr has too many refs, expect mem leaks");
    hsgResMgr::Shutdown();  // deletes fResMgr
    DeInitNetClientComm();

    // Uninstall our unhandled exception filter, if we installed one
#ifndef HS_DEBUGGING
    SetUnhandledExceptionFilter( oldFilter );
#endif

    // Exit WinMain and terminate the app....
    return PARABLE_NORMAL_EXIT;
}
int main(int argc, char *argv[])
{
    std::vector<std::string> inputFiles;
    int globalRadius = -1;
    int globalBorder = -1;
    bool gridOverlay = false;

    ExPop::CommandlineParser cmdParser(argv[0]);

    cmdParser.addHandler<std::string>(
        "", [&inputFiles](const std::string &filename) {
            inputFiles.push_back(filename);
        });
    cmdParser.addVariableHandler("radius", &globalRadius);
    cmdParser.addVariableHandler("border", &globalBorder);
    cmdParser.addFlagHandler("grid", &gridOverlay);

    if(!cmdParser.handleCommandline(argc, argv)) {
        return cmdParser.getErrorFlag();
    }

    for(size_t i = 0; i < inputFiles.size(); i++) {

        ExPop::Gfx::Image *img = ExPop::Gfx::loadTGAFromFile(inputFiles[i]);
        if(!img) {
            std::cerr << "Could not load TGA: " << inputFiles[i] << std::endl;
            return 1;
        }

        if(img->getWidth() != img->getHeight()) {
            std::cerr << "Image not square: " << inputFiles[i] << std::endl;
            return 1;
        }

        std::string filename;
        std::string extension;
        ExPop::stringSplit(inputFiles[i], ".", filename, extension, true);

        int radius = globalRadius;
        if(globalRadius == -1) {
            radius = img->getWidth() / 2;
        }
        int border = globalBorder;
        if(globalBorder == -1) {
            border = img->getWidth() / 8;
        }

        if(radius < border) {
            radius = border;
        }

        ExPop::Gfx::Image *dstImg = new ExPop::Gfx::Image(img->getWidth() * 5, img->getHeight() * 3);

        // '#' shaped thing on the left. One inner tile, four outer
        // angle tiles, and four edge tiles.
        copyRect(
            img, dstImg,
            -radius, -border,
            img->getWidth() - radius, img->getHeight() - border,
            radius * 2 + img->getWidth(), border * 2);

        copyRect(
            img, dstImg,
            -radius, -border,
            img->getWidth() - radius, img->getHeight() * 2 - border,
            radius * 2 + img->getWidth(), border * 2);

        copyRect(
            img, dstImg,
            -border, -radius,
            img->getWidth() - border, img->getHeight() - radius,
            border * 2, radius * 2 + img->getHeight());

        copyRect(
            img, dstImg,
            -border, -radius,
            img->getWidth() - border + img->getWidth(), img->getHeight() - radius,
            border * 2, radius * 2 + img->getHeight());

        // 'o' on the right. Four inner angle tiles.
        copyRect(
            img, dstImg,
            0, 0,
            img->getWidth() * 3, 0,
            img->getWidth() * 2, img->getHeight() * 2);

        clearRect(dstImg,
            img->getWidth() * 3 + border, border,
            img->getWidth() * 2 - 2 * border,
            img->getHeight() * 2 - 2 * border);

        copyRect(
            img, dstImg,
            0, -border,
            img->getWidth() * 3, img->getHeight() + -border,
            img->getWidth() * 2, border * 2);

        copyRect(
            img, dstImg,
            -border, 0,
            img->getWidth() * 4 - border, 0,
            border * 2, img->getHeight() * 2);

        clearRect(dstImg,
            img->getWidth() * 3 + radius, radius,
            img->getWidth() * 2 - 2 * radius,
            img->getHeight() * 2 - 2 * radius);


        if(gridOverlay) {
            for(int y = 0; y < dstImg->getHeight(); y += img->getHeight()) {
                for(int x = 0; x < dstImg->getWidth(); x++) {
                    ExPop::Gfx::Pixel *p = dstImg->getPixel(x, y);
                    p->rgba.r = p->rgba.g = p->rgba.b = (((x&1)^(y&1))?0xff:0x0);
                    p->rgba.a = 255;
                }
            }
            for(int x = 0; x < dstImg->getWidth(); x += img->getWidth()) {
                for(int y = 0; y < dstImg->getHeight(); y++) {
                    ExPop::Gfx::Pixel *p = dstImg->getPixel(x, y);
                    p->rgba.r = p->rgba.g = p->rgba.b = (((x&1)^(y&1))?0xff:0x0);
                    p->rgba.a = 255;
                }
            }
        }


        saveTGAToFile(dstImg, filename + ".template." + extension);

        delete dstImg;
        delete img;
    }

    return 0;
}
Пример #15
0
//! \brief UnitTest main()
//! \details UnitTest does have a main() function so that we can have tests
//!   calling MPI functions. Thus we are using Charm++'s MPI-interoperation
//!   capability as would have to be done with interoperation with an MPI
//!   library. This is necessary, since MPI_Init() is a bit adamant about
//!   capturing resources it wants and hence it has to be called before Charm is
//!   initialized.
//! \author J. Bakosi
int main( int argc, char **argv ) {

  int peid, numpes;

  // Initialize MPI
  MPI_Init( &argc, &argv );
  MPI_Comm_rank( MPI_COMM_WORLD, &peid );
  MPI_Comm_size( MPI_COMM_WORLD, &numpes );

  // Run serial and Charm++ unit test suite
  CharmLibInit( MPI_COMM_WORLD, argc, argv );
  CharmLibExit();

  // Run MPI test suite
  try {

    tk::Print print;    // quiet output by default using print, see ctor
    unittest::ctr::CmdLine cmdline;
    bool helped;
    unittest::CmdLineParser cmdParser( argc, argv, print, cmdline, helped );

    // Print out help on all command-line arguments if help was requested
    const auto helpcmd = cmdline.get< tag::help >();
    if (peid == 0 && helpcmd)
      print.help< tk::QUIET >( UNITTEST_EXECUTABLE,
                               cmdline.get< tag::cmdinfo >(),
                               "Command-line Parameters:", "-" );

    // Print out verbose help for a single keyword if requested
    const auto helpkw = cmdline.get< tag::helpkw >();
    if (peid == 0 && !helpkw.keyword.empty())
      print.helpkw< tk::QUIET >( UNITTEST_EXECUTABLE, helpkw );

    // Immediately exit if any help was output
    if (helpcmd || !helpkw.keyword.empty()) {
      MPI_Finalize();
      return tk::ErrCode::SUCCESS;
    }

    unittest::UnitTestPrint
      uprint( cmdline.get< tag::verbose >() ? std::cout : std::clog );

    const auto& groups = unittest::g_runner.get().list_groups();

    // Get group name string passed in by -g
    const auto grp = cmdline.get< tag::group >();

    // If only select groups to be run, see if there is any that will run
    bool work = false;
    if (grp.empty())
      work = true;
    else
      for (const auto& g : groups)
        if ( g.find("MPI") != std::string::npos &&  // only consider MPI groups
             g.find(grp) != std::string::npos )
          work = true;

    // Quit if there is no work to be done
    if (!work) {
      if (peid == 0)
        uprint.note( "\nNo MPI test groups to be executed because no test "
                     "group names match '" + grp + "'.\n" );
      MPI_Finalize();
      return tk::ErrCode::SUCCESS;
    }

    if (peid == 0) {
      uprint.endpart();
      uprint.part( "MPI unit test suite" );
      uprint.unithead( "Unit tests computed", cmdline.get< tag::group >() );
    }

    std::size_t nrun=0, ncomplete=0, nwarn=0, nskip=0, nexcp=0, nfail=0;
    tk::Timer timer;  // start new timer measuring the MPI-suite runtime

    // Lambda to fire up all tests in a test group
    auto spawngrp = [&]( const std::string& g ) {
      for (int t=1; t<=unittest::g_maxTestsInGroup; ++t) {
        tut::test_result tr;
        unittest::g_runner.get().run_test( g, t, tr );
        if (peid == 0) {
          ++nrun;
          std::vector< std::string > status
            { tr.group, tr.name, std::to_string(tr.result), tr.message,
              tr.exception_typeid };
          unittest::evaluate( status, ncomplete, nwarn, nskip, nexcp, nfail );
          uprint.test( ncomplete, nfail, status );
        }
      }
    };

    // Fire up all tests in all test groups exercising MPI on rank 0
    for (const auto& g : groups)
      if (g.find("MPI") != std::string::npos) { // only start MPI test groups
        if (grp.empty()) {                        // consider all test groups
          spawngrp( g );
        } else if (g.find(grp) != std::string::npos) {
          // spawn only the groups that match the string specified via -g string
          spawngrp( g );
        }
      }

    if (peid == 0) {
      unittest::assess( uprint, "MPI", nfail, nwarn, nskip, nexcp, ncomplete );
      std::vector< std::pair< std::string, tk::Timer::Watch > > timestamp;
      timestamp.emplace_back( "MPI tests runtime", timer.hms() );
      uprint.time( "MPI test suite timers (h:m:s)", timestamp );
    }

  } catch (...) { tk::processExceptionMPI(); }

  // Finalize MPI
  MPI_Finalize();

  return tk::ErrCode::SUCCESS;
}
Пример #16
0
//
// Virtual platform construction and simulation
//
int main(int argc, const char **argv) {

    // Check arguments
    if(!cmdParser(argc, argv)) {
    	icmMessage("E", PLATFORM, "Command Line parser error");
    	return 1;
    }

    // initialize OVPsim
    unsigned int icmAttrs = ICM_STOP_ON_CTRLC;

    icmInitPlatform(ICM_VERSION, icmAttrs, 0, 0, PLATFORM);

    const char *modelFile    = "model." IMPERAS_SHRSUF;
    const char *semihostFile = icmGetVlnvString(NULL, "ovpworld.org", "modelSupport", "imperasExit", "1.0", "model");

    // create a processor instance
    icmProcessorP procA = icmNewProcessor(
        "procA",            // CPU name
        "or1k",             // CPU type
        0,                  // CPU cpuId
        0,                  // CPU model flags
        32,                 // address bits
        modelFile,          // model file
        "modelAttrs",       // morpher attributes
		MODEL_FLAGS,        // attributes
        0,                  // user-defined attributes
        semihostFile,       // semi-hosting file
        "modelAttrs"        // semi-hosting attributes
    );

    // create the processor bus
    icmBusP busA = icmNewBus("busA", 32);

    // connect the processors onto the busses
    icmConnectProcessorBusses(procA, busA, busA);

    // create memory
    icmMemoryP localA = icmNewMemory("localA", ICM_PRIV_RWX, 0xffffffff);

    // connect the memory onto the busses
    icmConnectMemoryToBus(busA, "mp1", localA, 0x00000000);


    // create a processor instance
    icmProcessorP procB = icmNewProcessor(
        "procB",             // CPU name
        "or1k",             // CPU type
        0,                  // CPU cpuId
        0,                  // CPU model flags
        32,                 // address bits
        modelFile,          // model file
        "modelAttrs",       // morpher attributes
		MODEL_FLAGS,        // attributes
        attrsForB(),        // user-defined attributes
        semihostFile,       // semi-hosting file
        "modelAttrs"        // semi-hosting attributes
    );

    // create the processor bus
    icmBusP busB = icmNewBus("busB", 32);

    // connect the processors onto the busses
    icmConnectProcessorBusses(procB, busB, busB);

    // create memory
    icmMemoryP localB = icmNewMemory("localB", ICM_PRIV_RWX, 0xffffffff);

    // connect the memory onto the busses
    icmConnectMemoryToBus(busB, "mp1", localB, 0x00000000);

    icmNetP n1 = icmNewNet("n1");
    icmNetP n2 = icmNewNet("n2");
    icmNetP n3 = icmNewNet("n3");

    icmConnectProcessorNet(procA, n1, "intr0", ICM_INPUT);
    icmConnectProcessorNet(procB, n2, "intr0", ICM_INPUT);
    icmConnectProcessorNet(procB, n3, "intr1", ICM_INPUT);

    // advance the processors, then interrupt
    icmSimulate(procA, 9);
    icmSimulate(procB, 9);
    icmPrintf("Interrupting A & B\n");
    icmWriteNet(n1, 1);
    icmWriteNet(n3, 1);
    icmSimulate(procA, 1);
    icmSimulate(procB, 1);
    icmWriteNet(n1, 0);
    icmWriteNet(n3, 0);
    icmSimulate(procA, 9);
    icmSimulate(procB, 9);

    icmPrintf("Interrupting B\n");
    icmWriteNet(n2, 1);
    icmSimulate(procA, 1);
    icmSimulate(procB, 1);
    icmWriteNet(n2, 0);
    icmSimulate(procA, 10);
    icmSimulate(procB, 10);

    // report the total number of instructions executed
    icmPrintf(
        "processor A has executed " FMT_64u " instructions\n",
        icmGetProcessorICount(procA)
    );
    icmPrintf(
        "processor B has executed " FMT_64u " instructions\n",
        icmGetProcessorICount(procB)
    );

    icmTerminate();

    return 0;
}
Пример #17
0
int main(int argc, const char *argv[])
{
	// Check arguments and ensure application to load specified
	if(!cmdParser(argc, argv)) {
		icmMessage("E", "platform", "Command Line parser error");
		return 1;
	}

	// the constructor
	createPlatform();

    icmSimulationStarting();

    // apply watchpoints in shared memory
    applyWatchpoints(handles.shared);

    // set register watchpoints for processor0 only
    applyRegWatchpoints(handles.processor0);

    // this is set to step for one instruction
    Bool          stepOver      = False;
    Bool          finished      = False;
    icmProcessorP stopProcessor = NULL;

    // query registers and register groups in processor0
    queryRegisters(handles.processor0);

    while(!finished) {

        // simulate the platform using the default scheduler
        if(stepOver) {
            icmSetICountBreakpoint(stopProcessor, 1);
            stopProcessor = icmSimulatePlatform();
            stepOver = False;
        } else {
            applyBreakpoints(handles.processor0);
            applyBreakpoints(handles.processor1);
            stopProcessor = icmSimulatePlatform();
            clearBreakpoints(handles.processor0);
            clearBreakpoints(handles.processor1);
        }

        switch(icmGetStopReason(stopProcessor)) {

            case ICM_SR_EXIT:
                finished = True;
                break;

            case ICM_SR_FINISH:
                finished = True;
                break;

            case ICM_SR_BP_ICOUNT:
                icmPrintf(
                    "Processor %s icount %u stopped at icount\n",
                     icmGetProcessorName(stopProcessor, "/"),
                    (Uns32)icmGetProcessorICount(stopProcessor)
                );
                break;

            case ICM_SR_BP_ADDRESS:
                icmPrintf(
                    "Processor %s icount %u stopped at address 0x%08x\n",
                    icmGetProcessorName(stopProcessor, "/"),
                    (Uns32)icmGetProcessorICount(stopProcessor),
                    (Uns32)icmGetPC(stopProcessor)
                );
                stepOver = True;
                break;

            case ICM_SR_WATCHPOINT:
                icmPrintf(
                    "Processor %s icount %u stopped at watchpoint\n",
                     icmGetProcessorName(stopProcessor, "/"),
                    (Uns32)icmGetProcessorICount(stopProcessor)
                );
                handleWatchpoints();
                break;

            default:
                icmPrintf(
                    "Processor %s icount %u stopped for reason %u\n",
                    icmGetProcessorName(stopProcessor, "/"),
                    (Uns32)icmGetProcessorICount(stopProcessor),
                    icmGetStopReason(stopProcessor)
                );
                break;
        }
    }

    icmTerminate();

    return 0;
}
Пример #18
0
int main()
{
  signal(SIGINT, &prohandler);
  signal(SIGTERM, &prohandler);
  /** Allocation of the arguments' array */
  char** argumentArray = (char**) malloc(sizeof(char*) * NUM_OF_ARGS);
  
  int i=0;
  for(i=0;i<NUM_OF_ARGS;i++)
  {
    argumentArray[i] = (char*) malloc(sizeof(char) * MAX_ARG_SIZE);
  }
  /** Allocation of the input command array */
  char* command = malloc(MAX_COMMAND_SIZE);
  if (command == NULL)
  {
      printf("No memory \n");
      return 1;
  }
  /** Allocation of the home path array */
  char* home = malloc(1024);
  if (home == NULL)
  {
      printf("No memory \n");
      return 1;
  }
  /** End of allocations */
  /****************************************** MAIN LOOP  ********************************************************************/
  /**************************************************************************************************************************/
  
  //Like a normal shell - user@hostname
  struct passwd *p = getpwuid(getuid());  // Check for NULL!
  char hostname[HOST_NAME_MAX+1];
  
  while(1)
  {
    /**
     * Shell waiting for input. If you just press enter, or enter something starting with a whitespace, the shell will ask for 
     * new entry. If Ctrl-C is pressed while in the loop, the loop breaks.
     */
    
    do
    {
      //printf("User name: %s\n", p->pw_name);
      gethostname(hostname, sizeof(hostname));  // Check the return value!
      //printf("Host name: %s\n", hostname);
      
      //fprintf(stdout, KRED "SuperHackingShell:" RESET);
      fprintf(stdout, KCYN "%s" RESET "@" KGRN "%s:" RESET,p->pw_name,hostname);
      printDir();
      fprintf(stdout, KNRM "$ " RESET);
      fgets(command, MAX_COMMAND_SIZE, stdin);
            
    }while(strFilter(command)==0 );

    /** Check for exit command */
    if (stringCompare(command,"exit"))
      break;
    
    
    /**  Parsing  */
    int args = cmdParser(command, argumentArray, NUM_OF_ARGS);  //args contains the number of arguments the command contained.
    
    /** Executing programs and commands - if no cd command given */
    if(cd(argumentArray) != 0)
    {  
      /** Check for background execution */
      if( *argumentArray[args-1] == 38)  //if last argument of command is "&"(38), execute in background
      {  
        *argumentArray[args-1] = 0; //doesn't appear to create problems NOPE: me ls -l & peos
        //prepei na kopsw to teleutaio argument
        //printf("%s %s",argumentArray[0],argumentArray[1]);//tsekarei an to ekopse
        cmdExecBack(argumentArray);
      }
      /** Normal execution */
      else
        cmdExecute(argumentArray);
    }
  }
  fprintf(stdout, KRED"<1337>...SuperHackingShell...exiting... <1337> \n" RESET);
  free(command);
  free(argumentArray);
  exit(0);
}
Пример #19
0
	XdevLCore* createCore(xdl_int argc,
	                      xdl_char* argv[],
	                      xdl_int xmlBufferSize,
	                      xdl_uint8* xmlBuffer,
	                      xdl_uint numberOfUserData,
	                      XdevLUserData* userDataList[]) {

		std::stringstream vn;
		vn << XDEVL_MAJOR_VERSION << "." << XDEVL_MINOR_VERSION << "." << XDEVL_PATCH_VERSION;
		version_number = vn.str();

		//
		// All command line specified values will override values specified in the
		// xml file or default values. The following values can be overwritten.
		//
		//	- XML filename
		//	- XdevLPlugins plugins path
		// 	- XdevLCore plugins version number
		//

		xdl::XdevLCommandLineParser cmdParser(argc, argv);

		//
		// Set default parameters.
		//
		xdl::XdevLStringParameter versionNumberParameter("v", "The path to the plugins folder.", version_number);
		xdl::XdevLStringParameter pluginsPathParameter("pp", "The path to the plugins folder.", ".");
		xdl::XdevLStringParameter fileNameParameter("f", "The filename of the XML file.", xml_file);

		// Parse the command line arguments.
		cmdParser.add(&versionNumberParameter);
		cmdParser.add(&pluginsPathParameter);
		cmdParser.add(&fileNameParameter);
		cmdParser.parse();

		// Assign the values.
		version_number		= versionNumberParameter.getValue();
		std::cout << "XdevLCore     : " << version_number << std::endl;
		xdevl_plugin_path = pluginsPathParameter.getValue();
		std::cout << "Plugins Folder: " << xdevl_plugin_path << std::endl;
		xml_file 					= fileNameParameter.getValue();

		//
		// Check if there is a main XML file where the user may have specified.
		// XdevLCore related information.
		// TODO The not specified comparision must be changed.
		if(xmlBuffer != nullptr) {

			TiXmlDocument xmlDocument;
			if(!xmlDocument.Parse((char*)xmlBuffer)) {
				std::cerr << "## Couldn't parse the specified XML file." << std::endl;
				exit(-1);
			}

			TiXmlHandle docHandle(&xmlDocument);
			TiXmlElement* root = docHandle.FirstChild("XdevLCoreProperties").ToElement();
			if(!root) {
				std::cerr << "## XML format not correct." << std::endl;
				exit(-1);
			}

			//
			// Do we have a version forces to use by the user?
			//
			if(!versionNumberParameter.getSet()) {
				if(root->Attribute("version")) {
					// Use the one from the xml file.
					version_number = root->Attribute("version");
					std::cout << ">> Using version specified in XML file." << std::endl;
				}
			}
			if(!pluginsPathParameter.getSet()) {
				if(root->Attribute("plugins_path")) {
					// Use the one from the xml file.
					xdevl_plugin_path = root->Attribute("plugins_path");
					std::cout << ">> Using plugins folder specified in XML file." << std::endl;
				}
			}
		}

		//
		// Create the filename.
		//
		createXdevLCoreFilename(xdevl_plugin_path, version_number, xdevlcore_filename);

		// Load the XdevLCore plugin.
		xdl_int ret;
		if((ret = checkLocal(xdevlcore_filename)) != RET_SUCCESS) {
			std::cerr << "## Could not find XdevLCore plugin at all." << std::endl;
			exit(-1);
		}


		//
		// Get the plugins create and delte function pointer.
		//
		create_xdevl_core = (XdevLCreateModuleFunction)(dynamicLibraryLoader.getFunctionAddress("_create"));
		if(!create_xdevl_core) {
			std::cerr << "## XdevLCore plugin method format wrong: CREATE_XDEVL_CORE not found." <<  std::endl;
			exit(-1);
		}
		delete_xdevL_core = (DELETE_XDEVL_CORE)(dynamicLibraryLoader.getFunctionAddress("_delete"));
		if(!delete_xdevL_core) {
			std::cerr << "## XdevLCore plugin method format wrong: DELETE_XDEVL_CORE not found." << std::endl;
			exit(-1);
		}

		//
		// Create the XdevLCore object.
		//
		//	cmdl = new xdl::XdevLCommandLineParser(argc, argv);
		XdevLUserData userData;

		userData.id = XdevLID("XDEVL_COMMAND_LINE_PARSER");
		userData.data = (void*)&cmdParser;


		XdevLModuleCreateParameter parameter;
		XdevLID CoreID("XdevLCoreMain");
		parameter.setPluginName(xdl::XdevLPluginName("XdevLCore"));
		parameter.setModuleName(xdl::XdevLModuleName("XdevLCore"));
		parameter.setUserParameter(&userData);
		parameter.setModuleId(CoreID);

		if(create_xdevl_core(&parameter) != RET_SUCCESS) {
			std::cerr << "## Couldn't create XdevLCore object." << std::endl;
			exit(-1);
		}
		XdevLCore* xdevlCoreObject = static_cast<XdevLCore*>(parameter.getModuleInstance());


		XdevLEvent moduleInit;
		moduleInit.type = XDEVL_MODULE_EVENT;
		moduleInit.module.sender = CoreID.getHashCode();
		moduleInit.module.event = XDEVL_MODULE_INIT;
		xdevlCoreObject->notify(moduleInit);

		//
		// Initialize the XdevLCore system.
		//
		XdevLCoreParameters parameters;
		parameters.xmlBuffer = std::vector<xdl_uint8>(xmlBuffer, xmlBuffer + xmlBufferSize);
		parameters.pluginsPath 			= xdevl_plugin_path;
		parameters.userDataList 		= userDataList;
		parameters.numberOfUserData = numberOfUserData;

		if(xdevlCoreObject->setParameters(parameters) != RET_SUCCESS) {
			std::cerr << "## Couldn't initialize XdevLCore object." << std::endl;
			exit(-1);
		}

		return xdevlCoreObject;
	}
Пример #20
0
bool MyApp::OnInit( void )
{
    try
    {
        SetAppName( APP_NAME );
        SetVendorName( APP_VENDOR );

        respath = wxFindAppPath( argv[0], wxGetCwd(), _T("FNPATH"), _T("fn") );

#ifdef __WXMSW__

        if (respath.Last() != '\\') respath += '\\';
        shaderPath = respath + _T("GLSL\\");
        iconsPath  = respath + _T("icons\\");
        
        int fd;
        FILE *fp;
        AllocConsole();
        fd = _open_osfhandle( (long)GetStdHandle( STD_OUTPUT_HANDLE ), 0);
        fp = _fdopen( fd, "w" );
        *stdout = *fp;
        setvbuf( stdout, NULL, _IONBF, 0 );

// TODO fix may not work.
#elif __WXMAC__

        // If we use the above code to get the same on OSX, I get a segfault somewhere
        // therefore I use the OSX native code here:

        // OSX only: Try to find the resource path...
        CFBundleRef mainBundle = CFBundleGetMainBundle();
        CFURLRef resourcesURL = CFBundleCopyBundleURL( mainBundle );
        CFStringRef str = CFURLCopyFileSystemPath( resourcesURL, kCFURLPOSIXPathStyle );
        CFRelease( resourcesURL );
        char path[ PATH_MAX ];

        CFStringGetCString( str, path, FILENAME_MAX, kCFStringEncodingASCII );
        CFRelease( str );
        fprintf( stderr, "%s", path );

        respath = wxString::FromAscii( path );

        respath += _T( "/Contents/Resources/" );
        shaderPath = respath + _T( "GLSL/" );
        iconsPath = respath + _T( "icons/" );
        std::cout << std::endl << iconsPath << std::endl;

#else
        if ( respath.Last() != '/' )
            respath += '/';
        shaderPath = respath + _T("GLSL/");
        iconsPath = respath + _T("icons/");

#endif

        Logger::getInstance()->print( wxT( "Warning: This version of Fibernavigator is debug compiled." ), LOGLEVEL_DEBUG );
        Logger::getInstance()->print( wxT( "For better performance please compile a Release version."), LOGLEVEL_DEBUG );
        Logger::getInstance()->print( wxString::Format( wxT( "respath: %s" ), respath.c_str() ), LOGLEVEL_DEBUG );
        Logger::getInstance()->print( wxString::Format( wxT( "shader: %s" ), shaderPath.c_str() ), LOGLEVEL_DEBUG );

        // Create the main frame window
        frame = new MainFrame( wxT("Fiber Navigator"), wxPoint( 50, 50 ), wxSize( 800, 600 ) );
        SceneManager::getInstance()->setMainFrame( frame );
        SceneManager::getInstance()->setTreeCtrl( frame->m_pTreeWidget );

#ifdef __WXMSW__
        // Give it an icon (this is ignored in MDI mode: uses resources)
        frame->SetIcon( wxIcon( _T( "sashtest_icn" ) ) );
#endif

        frame->SetMinSize( wxSize( 800, 600 ) );
        frame->SetSize( wxSize( 1024, 768 ) );

        frame->Show( true );
        SetTopWindow( frame );

        wxString cmd;
        wxString cmdFileName;
        wxCmdLineParser cmdParser( desc, argc, argv );
        cmdParser.Parse( false );

        if ( cmdParser.GetParamCount() > 0 )
        {
            Loader loader = Loader(frame, frame->m_pListCtrl );
            for ( size_t i = 0; i < cmdParser.GetParamCount(); ++i )
            {
                cmd = cmdParser.GetParam( i );
                wxFileName fName( cmd );
                fName.Normalize( wxPATH_NORM_LONG | wxPATH_NORM_DOTS | wxPATH_NORM_TILDE | wxPATH_NORM_ABSOLUTE );
                cmdFileName = fName.GetFullPath();

                if ( cmdParser.Found(_T("d")) &&  ( i == 0 ) )
                {
                    loader( cmdFileName );
                    frame->createDistanceMapAndIso();
                }
                else if ( cmdParser.Found( _T( "p" ) ) &&  ( i == cmdParser.GetParamCount() -1 ) )
                {
                    frame->screenshot( wxT( "" ), cmdFileName );
                }
                else
                {
                    loader( cmdFileName );
                }
            }
        }

        if ( cmdParser.Found( _T( "e" ) ) )
        {
            exit( 0 );
        }
        
        return true;

    }
    catch ( ... )
    {
        Logger::getInstance()->print( wxT( "Something went wrong, terribly wrong" ), LOGLEVEL_ERROR );
        return false;
    }
    
    Logger::getInstance()->print( wxT( "End on init main" ), LOGLEVEL_DEBUG );
    wxFrame *the_frame = new wxFrame(NULL, 1, argv[0]);

    the_frame->Show(true);
    return true;
}
Пример #21
0
//
// Virtual platform construction and simulation
//
int main(int argc, const char **argv) {

    // Check arguments
    if(!cmdParser(argc, argv)) {
    	icmMessage("E", PLATFORM, "Command Line parser error");
    	return 1;
    }

    // initialize OVPsim
    unsigned int icmAttrs = ICM_STOP_ON_CTRLC | ICM_GDB_CONSOLE;

    icmInitPlatform(ICM_VERSION, icmAttrs, 0, 0, PLATFORM);

    const char *modelFile    = "model." IMPERAS_SHRSUF;
    const char *semihostFile = icmGetVlnvString(NULL, "ovpworld.org", "modelSupport", "imperasExit", "1.0", "model");

    // create a processor instance
    icmProcessorP processor = icmNewProcessor(
        "cpu1",             // CPU name
        "or1k",             // CPU type
        0,                  // CPU cpuId
        0,                  // CPU model flags
        32,                 // address bits
        modelFile,          // model file
        "modelAttrs",       // morpher attributes
		MODEL_FLAGS,        // attributes
        0,                  // user-defined attributes
        semihostFile,       // semi-hosting file
        "modelAttrs"        // semi-hosting attributes
    );

    // create the processor bus
    icmBusP bus = icmNewBus("bus", 32);

    // connect the processors onto the busses
    icmConnectProcessorBusses(processor, bus, bus);

    // create memory
    icmMemoryP local = icmNewMemory("local", ICM_PRIV_RWX, 0xffffffff);

    // connect the memory onto the busses
    icmConnectMemoryToBus(bus, "mp1", local, 0x00000000);

    icmSimulationStarting();

    // query processor registers, execeptions and modes
    queryRegisters(processor);
    queryExceptions(processor);
    queryModes(processor);

    // run processor until done (no instruction limit)
    while(simulate(processor, -1)) {
        // keep going while processor is still running
    }

    // report the total number of instructions executed
    icmPrintf(
        "processor has executed " FMT_64u " instructions\n",
        icmGetProcessorICount(processor)
    );

    icmTerminate();

    return 0;
}
Пример #22
0
int main(int argc, const char* argv[])
{
	// 分析命令行选项
	CmdArgParser cmdParser("", TCtoC_str(CStrFormat(_T("服务版本: %d.%d.%d"), g_majorVer, g_minorVer, g_thirdVer)));

	CStringA sip;
	VERIFY(cmdParser.AddStr(
			sip, "-ip", "", "IP",
			"服务的TCP监听IP,默认监听本机所有IP"
			));

	int tcpPort = g_serveIPP.port_;
	VERIFY(cmdParser.AddInt(
			tcpPort, "-p",
			1, GET_INT_MAX_VALUE(WORD),
			tcpPort, "port",
			"服务的TCP监听端口"
			));

	if(!cmdParser.RunParse(argc, argv))
		return -1;

	if(!sip.IsEmpty())
	{
		if(!IsValidIP((const char*)sip, &g_serveIPP.ip_))
		{
			NPLogError((_T("非法ip参数: %s"), (LPCTSTR)CtoTC_str((const char*)sip)));
			return -1;
		}
	}
	g_serveIPP.port_ = tcpPort;

	//用户定义_S

	CPCC_Startup pcc;
	int rt_st = pcc.Startup();
	if(rt_st < 0)
	{
		return rt_st;
	}
	//

	//用户定义_E
	// 设置基本系统参数
#if defined(WIN32)
	SetCurrentDirectory(GetExeDir());
#endif
	tcps_SetLogPrint(LogPrint__, NULL);

	// 构造rpc服务对象
	// 可在构造PCC_CenterSessionMaker时传递一 void* 参数给会话对象
	// 如:PCC_CenterSessionMaker sessionMaker(param);
	// 在会话对象中可使用this->m_sessionMaker.m_userParameter获得
	PCC_CenterSessionMaker sessionMaker;
	iscm_IRPCServeMan* rpcMan = NULL;
	TCPSError err = iscm_MakeRPCServeMan(rpcMan, g_serveIPP.port_, g_serveIPP.ip_, &sessionMaker, TCPS_MAX_TOTAL_SESSIONS/2);
	if(TCPS_OK == err)
	{
		// 运行主循环
		NPLogInfo(("Running serve..."));
		struct TCheck
		{
			static BOOL RunCheck(void* /*param*/)
				{	return !g_exitFlag;	}
		};
#if defined(WIN32)
		typedef HWND (WINAPI* FNGetConsoleWindow)();
		FNGetConsoleWindow fnGetConsoleWindow
			= (FNGetConsoleWindow)GetProcAddress(GetModuleHandle(_T("kernel32.dll")), "GetConsoleWindow");
		HWND wnd;
		if(fnGetConsoleWindow && NULL!=(wnd=fnGetConsoleWindow()))
		{
			char ch[1024];
			int l = GetWindowTextA(wnd, ch, sizeof(ch)-16);
			char ippStr[32];
			GetIPPortTxt(g_serveIPP, ippStr);
			sprintf(ch+l, " - %s", ippStr);
			SetWindowTextA(wnd, ch);
		}
#endif
		RunMainLoop(TCheck::RunCheck, NULL);
		g_exitFlag = true;
		NPLogInfo(("Exiting serve..."));
	}
	else
	{
		NPLogError(("iscm_MakeRPCServeMan(%d) failed, %s(%d)", tcpPort, tcps_GetErrTxt(err), err));
	}

	// 析构rpc服务对象
	if(rpcMan)
		rpcMan->DeleteThis();

//#if defined(_NP_IS_X86) || defined(_NP_IS_X64)
//	NPCRT_API_SetPerformancePolicy(false, true);
//#endif

	// 销毁tcps/iscm库中所有的全局对象(拥有线程的)
	tcps_DestroyAllGlobalObjects();

	return 0;
}