Esempio n. 1
0
int main(int argc, char **argv)
{
    char szVersionString[255] = {0,};
    cetime_t t;
    int opt;

    time(&t);
    srandom((unsigned int)t);

    GetVersionString(szVersionString);
    printf("AIMIR MCU Agent 4.3 2015-10-28 for SWAMM %s\r\n", szVersionString);
    printf(COPYRIGHT "\r\n");

    no_cld_wait();
    signal(SIGTERM, SIG_IGN);
//  xproc_signal(SIGCHLD, zombie_handler);
    xproc_signal(SIGSEGV, segmentfault_handler);

    while((opt=getopt(argc, argv, "dh")) != -1) {
        switch(opt) {
            case 'd': m_nDebugLevel = 0; break;
            case 'h':
            default :
                usage(argv[0]);
        }
    }

    CAgentService    svc;
    svc.Startup();
    svc.Shutdown();
}
Esempio n. 2
0
/*!
	Retreive the global details of this ACM driver

	\param a_DriverDetail will be filled with all the corresponding data
*/
inline DWORD ACM::OnDriverDetails(const HDRVR hdrvr, LPACMDRIVERDETAILS a_DriverDetail)
{
	if (my_hIcon == NULL)
		my_hIcon = LoadIcon(GetDriverModuleHandle(hdrvr), MAKEINTRESOURCE(IDI_ICON));
	a_DriverDetail->hicon       = my_hIcon;

	a_DriverDetail->fccType     = ACMDRIVERDETAILS_FCCTYPE_AUDIOCODEC;
	a_DriverDetail->fccComp     = ACMDRIVERDETAILS_FCCCOMP_UNDEFINED;

	/// \note this is an explicit hack of the FhG values
	/// \note later it could be a new value when the decoding is done
	a_DriverDetail->wMid        = MM_FRAUNHOFER_IIS;
	a_DriverDetail->wPid        = MM_FHGIIS_MPEGLAYER3;

	a_DriverDetail->vdwACM      = VERSION_MSACM;
	a_DriverDetail->vdwDriver   = VERSION_ACM_DRIVER;
	a_DriverDetail->fdwSupport  = ACMDRIVERDETAILS_SUPPORTF_CODEC;
	a_DriverDetail->cFormatTags = FORMAT_TAG_MAX_NB; // 2 : MP3 and PCM
//	a_DriverDetail->cFormatTags = 1; // 2 : MP3 and PCM
	a_DriverDetail->cFilterTags = FILTER_TAG_MAX_NB;

	lstrcpyW( a_DriverDetail->szShortName, L"LAME MP3" );
	char tmpStr[128];
	wsprintf(tmpStr, "LAME MP3 Codec v%s", GetVersionString());
	int u = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, tmpStr, -1, a_DriverDetail->szLongName, 0);
	MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, tmpStr, -1, a_DriverDetail->szLongName, u);
	lstrcpyW( a_DriverDetail->szCopyright, L"2002 Steve Lhomme" );
	lstrcpyW( a_DriverDetail->szLicensing, L"LGPL (see gnu.org)" );
	/// \todo update this part when the code changes
	lstrcpyW( a_DriverDetail->szFeatures , L"only CBR implementation" );

    return MMSYSERR_NOERROR;  // Can also return DRVCNF_CANCEL
}
Esempio n. 3
0
BOOL CALLBACK IWADBoxCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	HWND ctrl;
	int i;

	switch (message)
	{
	case WM_INITDIALOG:
		// Add our program name to the window title
		{
			TCHAR label[256];
			FString newlabel;

			GetWindowText(hDlg, label, countof(label));
			newlabel.Format(GAMESIG " %s: %s", GetVersionString(), label);
			SetWindowText(hDlg, newlabel.GetChars());
		}
		// Populate the list with all the IWADs found
		ctrl = GetDlgItem(hDlg, IDC_IWADLIST);
		for (i = 0; i < NumWads; i++)
		{
			FString work;
			const char *filepart = strrchr(WadList[i].Path, '/');
			if (filepart == NULL)
				filepart = WadList[i].Path;
			else
				filepart++;
			work.Format("%s (%s)", WadList[i].Name.GetChars(), filepart);
			SendMessage(ctrl, LB_ADDSTRING, 0, (LPARAM)work.GetChars());
			SendMessage(ctrl, LB_SETITEMDATA, i, (LPARAM)i);
		}
		SendMessage(ctrl, LB_SETCURSEL, DefaultWad, 0);
		SetFocus(ctrl);
		// Set the state of the "Don't ask me again" checkbox
		ctrl = GetDlgItem(hDlg, IDC_DONTASKIWAD);
		SendMessage(ctrl, BM_SETCHECK, queryiwad ? BST_UNCHECKED : BST_CHECKED, 0);
		// Make sure the dialog is in front. If SHIFT was pressed to force it visible,
		// then the other window will normally be on top.
		SetForegroundWindow(hDlg);
		break;

	case WM_COMMAND:
		if (LOWORD(wParam) == IDCANCEL)
		{
			EndDialog (hDlg, -1);
		}
		else if (LOWORD(wParam) == IDOK ||
			(LOWORD(wParam) == IDC_IWADLIST && HIWORD(wParam) == LBN_DBLCLK))
		{
			SetQueryIWad(hDlg);
			ctrl = GetDlgItem (hDlg, IDC_IWADLIST);
			EndDialog(hDlg, SendMessage (ctrl, LB_GETCURSEL, 0, 0));
		}
		break;
	}
	return FALSE;
}
Esempio n. 4
0
void CMonitorService::DisplaySplash()
{
    char szVersionString[255] = {0,};

    GetVersionString(szVersionString);

	printf("AIMIR System Monitor %s\r\n", szVersionString);
	printf(COPYRIGHT "\r\n");
	printf("\r\n");
}
Esempio n. 5
0
//
// WritePNGfile
//
void WritePNGfile (FileWriter *file, const BYTE *buffer, const PalEntry *palette,
				   ESSType color_type, int width, int height, int pitch)
{
	char software[100];
	mysnprintf(software, countof(software), GAMENAME " %s", GetVersionString());
	if (!M_CreatePNG (file, buffer, palette, color_type, width, height, pitch) ||
		!M_AppendPNGText (file, "Software", software) ||
		!M_FinishPNG (file))
	{
		Printf ("Could not create screenshot.\n");
	}
}
Esempio n. 6
0
static int DoomSpecificInfo (char *buffer, char *end)
{
	const char *arg;
	int size = end-buffer-2;
	int i, p;

	p = 0;
	p += snprintf (buffer+p, size-p, GAMENAME" version %s (%s)\n", GetVersionString(), GetGitHash());
#ifdef __VERSION__
	p += snprintf (buffer+p, size-p, "Compiler version: %s\n", __VERSION__);
#endif
	p += snprintf (buffer+p, size-p, "\nCommand line:");
	for (i = 0; i < Args->NumArgs(); ++i)
	{
		p += snprintf (buffer+p, size-p, " %s", Args->GetArg(i));
	}
	p += snprintf (buffer+p, size-p, "\n");
	
	for (i = 0; (arg = Wads.GetWadName (i)) != NULL; ++i)
	{
		p += snprintf (buffer+p, size-p, "\nWad %d: %s", i, arg);
	}

	if (gamestate != GS_LEVEL && gamestate != GS_TITLELEVEL)
	{
		p += snprintf (buffer+p, size-p, "\n\nNot in a level.");
	}
	else
	{
		char name[9];

		strncpy (name, level.mapname, 8);
		name[8] = 0;
		p += snprintf (buffer+p, size-p, "\n\nCurrent map: %s", name);

		if (!viewactive)
		{
			p += snprintf (buffer+p, size-p, "\n\nView not active.");
		}
		else
		{
			p += snprintf (buffer+p, size-p, "\n\nviewx = %d", (int)viewx);
			p += snprintf (buffer+p, size-p, "\nviewy = %d", (int)viewy);
			p += snprintf (buffer+p, size-p, "\nviewz = %d", (int)viewz);
			p += snprintf (buffer+p, size-p, "\nviewangle = %x", (unsigned int)viewangle);
		}
	}
	buffer[p++] = '\n';
	buffer[p++] = '\0';

	return p;
}
Esempio n. 7
0
BOOL CLauncherService::LoadSetting()
{
    FILE    *fp;

    fp = fopen(VARCONF_FILENAME, "rb");
    if (fp == NULL)
    {

        fp = fopen(VARCONF_OLD_FILENAME, "rb");
        if (fp == NULL)
        {
            system("rm -rf /app/data/*");
            system("rm -rf /app/sensor/*");
            system("rm -rf /app/member/*");
            system("rm -rf /app/log/*");

            SetFileValue("/app/conf/ethernet.type", ETHER_TYPE_PPP);
            SetFileValue("/app/conf/mobile.type", MOBILE_TYPE_GSM);
            SetFileValue("/app/conf/mobile.mode", MOBILE_MODE_CSD);
            SetFileString("/app/conf/server.addr", "0.0.0.0");    // Server address

        }
        else
        {
            fclose(fp);
        }
    }
    else
    {
        fclose(fp);
    }


    GetVersionString(fullVersionString);

    SetFileString("/app/conf/version", fullVersionString);
    GetFileValue("/app/conf/ethernet.type", &m_nEthernetType);
    GetFileValue("/app/conf/mobile.type", &m_nMobileType);
    GetFileValue("/app/conf/mobile.mode", &m_nMobileMode);
    GetFileValue("/app/conf/mobile.vendor", &m_nMobileVendor);
    GetFileString("/app/conf/server.addr", m_szServer, sizeof(m_szServer));
    GetFileValue("/app/conf/powertype.mcu", (int *)&m_nPowerType);

    /** Issue #109 
     *  Database 관련 정리를 위한 Script 실행 
     */
    system("/app/sw/script/RunAllTask.script 2> /dev/null");
    system("/app/sw/script/CheckTask.script & 2> /dev/null");

    return TRUE;
}
EVENT_END

INT32 UIMenuWndSetupVersion_OnOpen(VControl *pCtrl, UINT32 paramNum, UINT32 *paramArray)
{
    /*if (strlen((char *)GetUIConfigSoftwareVer())<1)
    	{
      UxStatic_SetData(&UIMenuSetupVersionTextCtrl,STATIC_VALUE,Txt_Pointer(GetVersionString()));
    	}
    else
    	{
      UxStatic_SetData(&UIMenuSetupVersionTextCtrl,STATIC_VALUE,Txt_Pointer(GetUIConfigSoftwareVer()));
    	}*/ //henry 20150409
    UxCtrl_SetShow(&UIMenuSetupVersionText2Ctrl, FALSE);
    UxStatic_SetData(&UIMenuSetupVersionTextCtrl,STATIC_VALUE,Txt_Pointer(GetVersionString()));
    //UxStatic_SetData(&UIMenuSetupVersionTextCtrl,STATIC_VALUE,Txt_Pointer(GetUIConfigSoftwareVer()));//henry 20141216
    Ux_DefaultEvent(pCtrl,NVTEVT_OPEN_WINDOW,paramNum,paramArray);
    return NVTEVT_CONSUME;
}
Esempio n. 9
0
void 	SaveConsole (void)
{
	
	_String  	sDP = dialogPrompt;
				
	dialogPrompt = "Save HyPhy console to:";
	
	_String		fileName(WriteFileDialogInput ());
	
	if (fileName.sLength == 0)
		return;
	
	FILE *      f = doFileOpen (fileName.getStr(),"w");
	if (!f)
	{
		fileName = _String ("Could not open '") & fileName & "' for writing.";
		ProblemReport (fileName, (Ptr)hyphyConsoleWindow);
	}
	else
	{
		fileName = GetVersionString () & " console saved on " & GetTimeStamp () & "\n\n";
		fwrite (fileName.sData,1,fileName.sLength, f);
		_String *cS;
		((_HYTextBox*)hyphyConsoleWindow->GetObject (0))->StoreText (cS);	
		#ifdef __WINDOZE__
			for (long k=0; k<cS->sLength; k++)
			{
				char c = cS->sData[k];
				if (c=='\r')
					fprintf (f,"\n");
				else
					fputc (c,f);
			}
		#else
			fprintf (f,"%s",cS->sData);		
		#endif
		fclose (f);
		DeleteObject (cS);
	}
	
	dialogPrompt = sDP;
}
Esempio n. 10
0
INT_PTR CALLBACK AboutDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
	switch (Msg)
	{
	case WM_INITDIALOG:
		{
			HBITMAP hBmp;
			hBmp = (HBITMAP)LoadImage(GetModuleHandle(NULL),
									  MAKEINTRESOURCE(IDB_ABOUT),
									  IMAGE_BITMAP, 0, 0, LR_SHARED);
			SendDlgItemMessage(hDlg, IDC_ABOUT, STM_SETIMAGE,
						(WPARAM)IMAGE_BITMAP, (LPARAM)hBmp);
			win_set_window_text_utf8(GetDlgItem(hDlg, IDC_VERSION), GetVersionString());
		}
		return 1;

	case WM_COMMAND:
		EndDialog(hDlg, 0);
		return 1;
	}
	return 0;
}
Esempio n. 11
0
BOOL _stdcall DllMain(HANDLE hModule, DWORD reason, void* unused)
{
	switch(reason)
	{
	case DLL_PROCESS_ATTACH:
        {
	    //Don't use this anywhere else
	    cLog::mOpenLog();
        char buffer[512];
        HMODULE thisModule = GetModuleHandle("MWSE.DLL");
        int length = GetModuleFileName(thisModule, buffer, sizeof buffer);
        std::string version = GetVersionString(buffer);
		cLog::mLogMessage("MWSE %s loaded\n", version.c_str());
        }
		break;
	case DLL_PROCESS_DETACH:
		cLog::mLogMessage("MWSE Terminated\n");
	    //Don't use this anywhere else
	    cLog::mCloseLog();
		return true;
		break;
	case DLL_THREAD_ATTACH:
		return true;
		break;
	case DLL_THREAD_DETACH:
		return true;
		break;
	default: //in any other case (shouldn't happen)
		cLog::mLogMessage("DLL:Unknown DLL event\n");
		return true;
		break;
	}

	cLog::mLogMessage("DLL:Starting Script Extender\n");
	cMWSEMain::mStartMWSE();

	return true;
}
Esempio n. 12
0
void DoomSpecificInfo (char *buffer, size_t bufflen)
{
	const char *arg;
	char *const buffend = buffer + bufflen - 2;	// -2 for CRLF at end
	int i;

	buffer += mysnprintf (buffer, buffend - buffer, GAMENAME " version %s (%s)", GetVersionString(), GetGitHash());
	buffer += mysnprintf (buffer, buffend - buffer, "\r\nCommand line: %s\r\n", GetCommandLine());

	for (i = 0; (arg = Wads.GetWadName (i)) != NULL; ++i)
	{
		buffer += mysnprintf (buffer, buffend - buffer, "\r\nWad %d: %s", i, arg);
	}

	if (gamestate != GS_LEVEL && gamestate != GS_TITLELEVEL)
	{
		buffer += mysnprintf (buffer, buffend - buffer, "\r\n\r\nNot in a level.");
	}
	else
	{
		buffer += mysnprintf (buffer, buffend - buffer, "\r\n\r\nCurrent map: %s", level.MapName.GetChars());

		if (!viewactive)
		{
			buffer += mysnprintf (buffer, buffend - buffer, "\r\n\r\nView not active.");
		}
		else
		{
			buffer += mysnprintf (buffer, buffend - buffer, "\r\n\r\nviewx = %f", ViewPos.X);
			buffer += mysnprintf (buffer, buffend - buffer, "\r\nviewy = %f", ViewPos.Y);
			buffer += mysnprintf (buffer, buffend - buffer, "\r\nviewz = %f", ViewPos.Z);
			buffer += mysnprintf (buffer, buffend - buffer, "\r\nviewangle = %f", ViewAngle);
		}
	}
	*buffer++ = '\r';
	*buffer++ = '\n';
	*buffer++ = '\0';
}
Esempio n. 13
0
bool pgConn::BackendMinimumVersion(int major, int minor)
{
	if (!majorVersion)
	{
		wxString version = GetVersionString();
		sscanf(version.ToAscii(), "%*s %d.%d.%d", &majorVersion, &minorVersion, &patchVersion);
		isEdb = version.Upper().Matches(wxT("ENTERPRISEDB*"));

		// EnterpriseDB 8.3 beta 1 & 2 and possibly later actually have PostgreSQL 8.2 style
		// catalogs. This is expected to change either before GA, but in the meantime we
		// need to check the catalogue version in more detail, and if we don't see what looks
		// like a 8.3 catalog, force the version number back to 8.2. Yuck.
		if (isEdb && majorVersion == 8 && minorVersion == 3)
		{
			if (ExecuteScalar(wxT("SELECT count(*) FROM pg_attribute WHERE attname = 'proconfig' AND attrelid = 'pg_proc'::regclass")) == wxT("0"))
				minorVersion = 2;
		}

		isGreenplum = version.Upper().Matches(wxT("*GREENPLUM DATABASE*"));
	}

	return majorVersion > major || (majorVersion == major && minorVersion >= minor);
}
Esempio n. 14
0
// Check the backend version
bool dbgPgConn::BackendMinimumVersion(int major, int minor)
{
	if (!m_majorVersion)
	{
		wxString version = GetVersionString();
		sscanf(version.ToAscii(), "%*s %d.%d", &m_majorVersion, &m_minorVersion);
		m_isEdb = version.Upper().Matches(wxT("ENTERPRISEDB*"));

		// EnterpriseDB 8.3 beta 1 & 2 and possibly later actually have PostgreSQL 8.2 style
		// catalogs. This is expected to change either before GA, but in the meantime we
		// need to check the catalogue version in more detail, and if we don't see what looks
		// like a 8.3 catalog, force the version number back to 8.2. Yuck.
		if (m_isEdb && m_majorVersion == 8 && m_minorVersion == 3)
		{
			PGresult *res;
			wxString result;

			res = waitForCommand(wxT( "SELECT count(*) FROM pg_attribute WHERE attname = 'proconfig' AND attrelid = 'pg_proc'::regclass"));

			if (PQresultStatus(res) == PGRES_TUPLES_OK)
			{
				// Retrieve the query result and return it.
				result = wxString(PQgetvalue(res, 0, 0), wxConvUTF8);

				// Cleanup & exit
				PQclear(res);
			}
			if (result == wxT("0"))
				m_minorVersion = 2;
		}
		else
			m_isGreenplum = version.Upper().Matches(wxT("*GREENPLUM DATABASE*"));
	}

	return m_majorVersion > major || (m_majorVersion == major && m_minorVersion >= minor);
}
Esempio n. 15
0
void TranslateToGLSL(HLSLCrossCompilerContext* psContext, GLLang* planguage,const GlExtensions *extensions)
{
    bstring glsl;
    uint32_t i;
    Shader* psShader = psContext->psShader;
    GLLang language = *planguage;
    const uint32_t ui32InstCount = psShader->ui32InstCount;
    const uint32_t ui32DeclCount = psShader->ui32DeclCount;

    psContext->indent = 0;

    if(language == LANG_DEFAULT)
    {
        language = ChooseLanguage(psShader);
        *planguage = language;
    }

    glsl = bfromcstralloc (1024, GetVersionString(language));

    psContext->glsl = glsl;
	psContext->earlyMain = bfromcstralloc (1024, "");
    for(i=0; i<NUM_PHASES;++i)
    {
        psContext->postShaderCode[i] = bfromcstralloc (1024, "");
    }
    psContext->currentGLSLString = &glsl;
    psShader->eTargetLanguage = language;
	psShader->extensions = (const struct GlExtensions*)extensions;
    psContext->currentPhase = MAIN_PHASE;

	if(extensions)
	{
		if(extensions->ARB_explicit_attrib_location)
			bcatcstr(glsl,"#extension GL_ARB_explicit_attrib_location : require\n");
		if(extensions->ARB_explicit_uniform_location)
			bcatcstr(glsl,"#extension GL_ARB_explicit_uniform_location : require\n");
		if(extensions->ARB_shading_language_420pack)
			bcatcstr(glsl,"#extension GL_ARB_shading_language_420pack : require\n");
	}

    ClearDependencyData(psShader->eShaderType, psContext->psDependencies);

    AddVersionDependentCode(psContext);

    if(psContext->flags & HLSLCC_FLAG_UNIFORM_BUFFER_OBJECT)
    {
        bcatcstr(glsl, "layout(std140) uniform;\n");
    }

    //Special case. Can have multiple phases.
    if(psShader->eShaderType == HULL_SHADER)
    {
        int haveInstancedForkPhase = 0;
        uint32_t forkIndex = 0;

        ConsolidateHullTempVars(psShader);

        for(i=0; i < psShader->ui32HSDeclCount; ++i)
        {
            TranslateDeclaration(psContext, psShader->psHSDecl+i);
        }

        //control
        psContext->currentPhase = HS_CTRL_POINT_PHASE;

        if(psShader->ui32HSControlPointDeclCount)
        {
            bcatcstr(glsl, "//Control point phase declarations\n");
            for(i=0; i < psShader->ui32HSControlPointDeclCount; ++i)
            {
                TranslateDeclaration(psContext, psShader->psHSControlPointPhaseDecl+i);
            }
        }

        if(psShader->ui32HSControlPointInstrCount)
        {
			SetDataTypes(psContext, psShader->psHSControlPointPhaseInstr, psShader->ui32HSControlPointInstrCount);

            bcatcstr(glsl, "void control_point_phase()\n{\n");
            psContext->indent++;

                for(i=0; i < psShader->ui32HSControlPointInstrCount; ++i)
                {
                    TranslateInstruction(psContext, psShader->psHSControlPointPhaseInstr+i);
                }
            psContext->indent--;
            bcatcstr(glsl, "}\n");
        }

        //fork
        psContext->currentPhase = HS_FORK_PHASE;
        for(forkIndex = 0; forkIndex < psShader->ui32ForkPhaseCount; ++forkIndex)
        {
            bcatcstr(glsl, "//Fork phase declarations\n");
            for(i=0; i < psShader->aui32HSForkDeclCount[forkIndex]; ++i)
            {
                TranslateDeclaration(psContext, psShader->apsHSForkPhaseDecl[forkIndex]+i);
                if(psShader->apsHSForkPhaseDecl[forkIndex][i].eOpcode == OPCODE_DCL_HS_FORK_PHASE_INSTANCE_COUNT)
                {
                    haveInstancedForkPhase = 1;
                }
            }

            bformata(glsl, "void fork_phase%d()\n{\n", forkIndex);
            psContext->indent++;

			SetDataTypes(psContext, psShader->apsHSForkPhaseInstr[forkIndex], psShader->aui32HSForkInstrCount[forkIndex]-1);

                if(haveInstancedForkPhase)
                {
                    AddIndentation(psContext);
                    bformata(glsl, "for(int forkInstanceID = 0; forkInstanceID < HullPhase%dInstanceCount; ++forkInstanceID) {\n", forkIndex);
                    psContext->indent++;
                }

                    //The minus one here is remove the return statement at end of phases.
                    //This is needed otherwise the for loop will only run once.
                    ASSERT(psShader->apsHSForkPhaseInstr[forkIndex][psShader->aui32HSForkInstrCount[forkIndex]-1].eOpcode == OPCODE_RET);
                    for(i=0; i < psShader->aui32HSForkInstrCount[forkIndex]-1; ++i)
                    {
                        TranslateInstruction(psContext, psShader->apsHSForkPhaseInstr[forkIndex]+i);
                    }

                if(haveInstancedForkPhase)
                {
                    psContext->indent--;
                    AddIndentation(psContext);
                    bcatcstr(glsl, "}\n");

                    if(psContext->havePostShaderCode[psContext->currentPhase])
                    {
#ifdef _DEBUG
                        AddIndentation(psContext);
                        bcatcstr(glsl, "//--- Post shader code ---\n");
#endif
                        bconcat(glsl, psContext->postShaderCode[psContext->currentPhase]);
#ifdef _DEBUG
                        AddIndentation(psContext);
                        bcatcstr(glsl, "//--- End post shader code ---\n");
#endif
                    }
                }

            psContext->indent--;
            bcatcstr(glsl, "}\n");
        }


        //join
        psContext->currentPhase = HS_JOIN_PHASE;
        if(psShader->ui32HSJoinDeclCount)
        {
            bcatcstr(glsl, "//Join phase declarations\n");
            for(i=0; i < psShader->ui32HSJoinDeclCount; ++i)
            {
                TranslateDeclaration(psContext, psShader->psHSJoinPhaseDecl+i);
            }
        }

        if(psShader->ui32HSJoinInstrCount)
        {
			SetDataTypes(psContext, psShader->psHSJoinPhaseInstr, psShader->ui32HSJoinInstrCount);

            bcatcstr(glsl, "void join_phase()\n{\n");
            psContext->indent++;

                for(i=0; i < psShader->ui32HSJoinInstrCount; ++i)
                {
                    TranslateInstruction(psContext, psShader->psHSJoinPhaseInstr+i);
                }

            psContext->indent--;
            bcatcstr(glsl, "}\n");
        }

        bcatcstr(glsl, "void main()\n{\n");

            psContext->indent++;

#ifdef _DEBUG
            AddIndentation(psContext);
            bcatcstr(glsl, "//--- Start Early Main ---\n");
#endif
            bconcat(glsl, psContext->earlyMain);
#ifdef _DEBUG
            AddIndentation(psContext);
            bcatcstr(glsl, "//--- End Early Main ---\n");
#endif

            if(psShader->ui32HSControlPointInstrCount)
            {
                AddIndentation(psContext);
                bcatcstr(glsl, "control_point_phase();\n");

                if(psShader->ui32ForkPhaseCount || psShader->ui32HSJoinInstrCount)
                {
                    AddIndentation(psContext);
                    bcatcstr(glsl, "barrier();\n");
                }
            }
            for(forkIndex = 0; forkIndex < psShader->ui32ForkPhaseCount; ++forkIndex)
            {
                AddIndentation(psContext);
                bformata(glsl, "fork_phase%d();\n", forkIndex);

                if(psShader->ui32HSJoinInstrCount || (forkIndex+1 < psShader->ui32ForkPhaseCount))
                {
                    AddIndentation(psContext);
                    bcatcstr(glsl, "barrier();\n");
                }
            }
            if(psShader->ui32HSJoinInstrCount)
            {
                AddIndentation(psContext);
                bcatcstr(glsl, "join_phase();\n");
            }

            psContext->indent--;

        bcatcstr(glsl, "}\n");

        if(psContext->psDependencies)
        {
            //Save partitioning and primitive type for use by domain shader.
            psContext->psDependencies->eTessOutPrim = psShader->sInfo.eTessOutPrim;

            psContext->psDependencies->eTessPartitioning = psShader->sInfo.eTessPartitioning;
        }

        return;
    }

    if(psShader->eShaderType == DOMAIN_SHADER && psContext->psDependencies)
    {
        //Load partitioning and primitive type from hull shader.
        switch(psContext->psDependencies->eTessOutPrim)
        {
            case TESSELLATOR_OUTPUT_TRIANGLE_CW:
            {
                bcatcstr(glsl, "layout(cw) in;\n");
                break;
            }
            case TESSELLATOR_OUTPUT_POINT:
            {
                bcatcstr(glsl, "layout(point_mode) in;\n");
                break;
            }
            default:
            {
                break;
            }
        }

        switch(psContext->psDependencies->eTessPartitioning)
        {
            case TESSELLATOR_PARTITIONING_FRACTIONAL_ODD:
            {
                bcatcstr(glsl, "layout(fractional_odd_spacing) in;\n");
                break;
            }
            case TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN:
            {
                bcatcstr(glsl, "layout(fractional_even_spacing) in;\n");
                break;
            }
            default:
            {
                break;
            }
        }
    }

    for(i=0; i < ui32DeclCount; ++i)
    {
        TranslateDeclaration(psContext, psShader->psDecl+i);
    }

    bcatcstr(glsl, "void main()\n{\n");

    psContext->indent++;

#ifdef _DEBUG
    AddIndentation(psContext);
    bcatcstr(glsl, "//--- Start Early Main ---\n");
#endif
	bconcat(glsl, psContext->earlyMain);
#ifdef _DEBUG
    AddIndentation(psContext);
    bcatcstr(glsl, "//--- End Early Main ---\n");
#endif

    MarkIntegerImmediates(psContext);

	SetDataTypes(psContext, psShader->psInst, ui32InstCount);

    for(i=0; i < ui32InstCount; ++i)
    {
        TranslateInstruction(psContext, psShader->psInst+i);
    }

    psContext->indent--;

    bcatcstr(glsl, "}\n");
}
Esempio n. 16
0
int I_PickIWad_Gtk (WadStuff *wads, int numwads, bool showwin, int defaultiwad)
{
	GtkWidget *window;
	GtkWidget *vbox;
	GtkWidget *hbox;
	GtkWidget *bbox;
	GtkWidget *widget;
	GtkWidget *tree;
	GtkWidget *check;
	GtkListStore *store;
	GtkCellRenderer *renderer;
	GtkTreeViewColumn *column;
	GtkTreeSelection *selection;
	GtkTreeIter iter, defiter;
	int close_style = 0;
	int i;
	char caption[100];

	// Create the dialog window.
	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	mysnprintf(caption, countof(caption), GAMESIG " %s: Select an IWAD to use", GetVersionString());
	gtk_window_set_title (GTK_WINDOW(window), caption);
	gtk_window_set_position (GTK_WINDOW(window), GTK_WIN_POS_CENTER);
	gtk_container_set_border_width (GTK_CONTAINER(window), 10);
	g_signal_connect (window, "delete_event", G_CALLBACK(gtk_main_quit), NULL);
	g_signal_connect (window, "key_press_event", G_CALLBACK(CheckEscape), NULL);

	// Create the vbox container.
	vbox = gtk_vbox_new (FALSE, 10);
	gtk_container_add (GTK_CONTAINER(window), vbox);

	// Create the top label.
	widget = gtk_label_new ("ZDoom found more than one IWAD\nSelect from the list below to determine which one to use:");
	gtk_box_pack_start (GTK_BOX(vbox), widget, false, false, 0);
	gtk_misc_set_alignment (GTK_MISC(widget), 0, 0);

	// Create a list store with all the found IWADs.
	store = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT);
	for (i = 0; i < numwads; ++i)
	{
		const char *filepart = strrchr (wads[i].Path, '/');
		if (filepart == NULL)
			filepart = wads[i].Path;
		else
			filepart++;
		gtk_list_store_append (store, &iter);
		gtk_list_store_set (store, &iter,
			0, filepart,
			1, wads[i].Name.GetChars(),
			2, i,
			-1);
		if (i == defaultiwad)
		{
			defiter = iter;
		}
	}

	// Create the tree view control to show the list.
	tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL(store));
	renderer = gtk_cell_renderer_text_new ();
	column = gtk_tree_view_column_new_with_attributes ("IWAD", renderer, "text", 0, NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW(tree), column);
	renderer = gtk_cell_renderer_text_new ();
	column = gtk_tree_view_column_new_with_attributes ("Game", renderer, "text", 1, NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW(tree), column);
	gtk_box_pack_start (GTK_BOX(vbox), GTK_WIDGET(tree), true, true, 0);
	g_signal_connect(G_OBJECT(tree), "button_press_event", G_CALLBACK(DoubleClickChecker), &close_style);
	g_signal_connect(G_OBJECT(tree), "key_press_event", G_CALLBACK(AllowDefault), window);

	// Select the default IWAD.
	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(tree));
	gtk_tree_selection_select_iter (selection, &defiter);

	// Create the hbox for the bottom row.
	hbox = gtk_hbox_new (FALSE, 0);
	gtk_box_pack_end (GTK_BOX(vbox), hbox, false, false, 0);

	// Create the "Don't ask" checkbox.
	check = gtk_check_button_new_with_label ("Don't ask me this again");
	gtk_box_pack_start (GTK_BOX(hbox), check, false, false, 0);
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(check), !showwin);

	// Create the OK/Cancel button box.
	bbox = gtk_hbutton_box_new ();
	gtk_button_box_set_layout (GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
	gtk_box_set_spacing (GTK_BOX(bbox), 10);
	gtk_box_pack_end (GTK_BOX(hbox), bbox, false, false, 0);

	// Create the OK button.
	widget = gtk_button_new_from_stock (GTK_STOCK_OK);
	gtk_box_pack_start (GTK_BOX(bbox), widget, false, false, 0);
	GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_DEFAULT);
	gtk_widget_grab_default (widget);
	g_signal_connect (widget, "clicked", G_CALLBACK(ClickedOK), &close_style);
	g_signal_connect (widget, "activate", G_CALLBACK(ClickedOK), &close_style);

	// Create the cancel button.
	widget = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
	gtk_box_pack_start (GTK_BOX(bbox), widget, false, false, 0);
	g_signal_connect (widget, "clicked", G_CALLBACK(gtk_main_quit), &window);

	// Finally we can show everything.
	gtk_widget_show_all (window);

	gtk_main ();

	if (close_style == 1)
	{
		GtkTreeModel *model;
		GValue value = { 0, { {0} } };
		
		// Find out which IWAD was selected.
		gtk_tree_selection_get_selected (selection, &model, &iter);
		gtk_tree_model_get_value (GTK_TREE_MODEL(model), &iter, 2, &value);
		i = g_value_get_int (&value);
		g_value_unset (&value);
		
		// Set state of queryiwad based on the checkbox.
		queryiwad = !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(check));
	}
	else
	{
		i = -1;
	}
	
	if (GTK_IS_WINDOW(window))
	{
		gtk_widget_destroy (window);
		// If we don't do this, then the X window might not actually disappear.
		while (g_main_context_iteration (NULL, FALSE)) {}
	}

	return i;
}
Esempio n. 17
0
int I_PickIWad (WadStuff *wads, int numwads, bool showwin, int defaultiwad)
{
	int i;

	if (!showwin)
	{
		return defaultiwad;
	}

#if !defined(__APPLE__)
	const char *str;
	if((str=getenv("KDE_FULL_SESSION")) && strcmp(str, "true") == 0)
	{
		FString cmd("kdialog --title \"" GAMESIG " ");
		cmd << GetVersionString() << ": Select an IWAD to use\""
		            " --menu \"ZDoom found more than one IWAD\n"
		            "Select from the list below to determine which one to use:\"";

		for(i = 0; i < numwads; ++i)
		{
			const char *filepart = strrchr(wads[i].Path, '/');
			if(filepart == NULL)
				filepart = wads[i].Path;
			else
				filepart++;
			// Menu entries are specified in "tag" "item" pairs, where when a
			// particular item is selected (and the Okay button clicked), its
			// corresponding tag is printed to stdout for identification.
			cmd.AppendFormat(" \"%d\" \"%s (%s)\"", i, wads[i].Name.GetChars(), filepart);
		}

		if(defaultiwad >= 0 && defaultiwad < numwads)
		{
			const char *filepart = strrchr(wads[defaultiwad].Path, '/');
			if(filepart == NULL)
				filepart = wads[defaultiwad].Path;
			else
				filepart++;
			cmd.AppendFormat(" --default \"%s (%s)\"", wads[defaultiwad].Name.GetChars(), filepart);
		}

		FILE *f = popen(cmd, "r");
		if(f != NULL)
		{
			char gotstr[16];

			if(fgets(gotstr, sizeof(gotstr), f) == NULL ||
			   sscanf(gotstr, "%d", &i) != 1)
				i = -1;

			// Exit status = 1 means the selection was canceled (either by
			// Cancel/Esc or the X button), not that there was an error running
			// the program. In that case, nothing was printed so fgets will
			// have failed. Other values can indicate an error running the app,
			// so fall back to whatever else can be used.
			int status = pclose(f);
			if(WIFEXITED(status) && (WEXITSTATUS(status) == 0 || WEXITSTATUS(status) == 1))
				return i;
		}
	}
#endif
#ifndef NO_GTK
	if (GtkAvailable)
	{
		return I_PickIWad_Gtk (wads, numwads, showwin, defaultiwad);
	}
#elif defined(__APPLE__)
	return I_PickIWad_Cocoa (wads, numwads, showwin, defaultiwad);
#endif
	
	printf ("Please select a game wad (or 0 to exit):\n");
	for (i = 0; i < numwads; ++i)
	{
		const char *filepart = strrchr (wads[i].Path, '/');
		if (filepart == NULL)
			filepart = wads[i].Path;
		else
			filepart++;
		printf ("%d. %s (%s)\n", i+1, wads[i].Name.GetChars(), filepart);
	}
	printf ("Which one? ");
	scanf ("%d", &i);
	if (i > numwads)
		return -1;
	return i-1;
}
Esempio n. 18
0
bool    Get_a_URL (_String& urls, _String* fileName)
{
#ifdef __HYPHYCURL__
    CURL *curl;
    CURLcode res ;
    curl = curl_easy_init ();
    FILE   * f = nil;
    _String* s = nil;
    char cErr [CURL_ERROR_SIZE+1];
    if(curl) {
        if (fileName) {
            f = fopen (fileName->sData,"wb");
            if (!f) {
                urls = _String ("Failed to open ") & *fileName & " for writing";
                return false;
            }
        } else {
            s = new _String (8192, true);
            checkPointer (s);
        }

        curl_easy_setopt (curl, CURLOPT_URL, urls.sData );
        curl_easy_setopt (curl, CURLOPT_ERRORBUFFER, cErr);

        //Do not check peer certificate, since we only ever get urls
        curl_easy_setopt (curl, CURLOPT_SSL_VERIFYPEER, 0);
        curl_easy_setopt (curl, CURLOPT_SSL_VERIFYHOST, 0);
        
        if (f) {
            curl_easy_setopt (curl, CURLOPT_FILE, (void*)f);
        } else {
            curl_easy_setopt (curl, CURLOPT_FILE, (void*)s);
        }

        _String ver (GetVersionString());
        curl_easy_setopt (curl, CURLOPT_USERAGENT, ver.sData);
        //curl_easy_setopt (curl, CURLOPT_VERBOSE, 1);
        curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, (void*)(f?url2File:url2String));
        _Parameter vbl = 0.0;
        checkParameter (VerbosityLevelString,vbl,0.0);
        if (vbl<0.5) {
            curl_easy_setopt (curl,CURLOPT_NOPROGRESS,1);
        }
        res = curl_easy_perform (curl);
        curl_easy_cleanup (curl);

        if (f) {
            fclose (f);
        } else {
            s->Finalize();
            urls = *s;
            DeleteObject (s);
        }
        if (!res) {
            return true;
        }
    } else {
        urls = "Failed to initialize CURL object";
        return false;
    }
    urls = _String ("CURL error:") & (long)res & "." & cErr;
    return false;
#else
    urls = "This feature requires libcurl";
    return false;
#endif
}
const GLubyte * PACKSPU_APIENTRY packspu_GetString( GLenum name )
{
    GET_CONTEXT(ctx);

    switch(name)
    {
        case GL_EXTENSIONS:
            return GetExtensions();
        case GL_VERSION:
#if 0 && defined(WINDOWS)
            if (packspuRunningUnderWine())
            {
                GetString(GL_REAL_VERSION, ctx->pszRealVersion);
                return ctx->pszRealVersion;               
            }
            else
#endif
            {
                char *oldlocale;
                float version;

                oldlocale = setlocale(LC_NUMERIC, NULL);
                oldlocale = crStrdup(oldlocale);
                setlocale(LC_NUMERIC, "C");

                version = GetVersionString();
                sprintf((char*)ctx->glVersion, "%.1f Chromium %s", version, CR_VERSION_STRING);

                if (oldlocale)
                {
                    setlocale(LC_NUMERIC, oldlocale);
                    crFree(oldlocale);
                }

                return ctx->glVersion;
            }
        case GL_VENDOR:
#ifdef WINDOWS
            if (packspuRunningUnderWine())
            {
                GetString(GL_REAL_VENDOR, ctx->pszRealVendor);
                return ctx->pszRealVendor;
            }
            else
#endif
            {
                return crStateGetString(name);
            }
        case GL_RENDERER:
#ifdef WINDOWS
            if (packspuRunningUnderWine())
            {
                GetString(GL_REAL_RENDERER, ctx->pszRealRenderer);
                return ctx->pszRealRenderer;
            }
            else
#endif
            {
                return crStateGetString(name);
            }

#ifdef CR_OPENGL_VERSION_2_0
        case GL_SHADING_LANGUAGE_VERSION:
        {
            static GLboolean fInitialized = GL_FALSE;
            if (!fInitialized)
            {
                GetString(GL_SHADING_LANGUAGE_VERSION, gpszShadingVersion);
                fInitialized = GL_TRUE;
            }
            return gpszShadingVersion;
        }
#endif
#ifdef GL_CR_real_vendor_strings
        case GL_REAL_VENDOR:
            GetString(GL_REAL_VENDOR, ctx->pszRealVendor);
            return ctx->pszRealVendor;
        case GL_REAL_VERSION:
            GetString(GL_REAL_VERSION, ctx->pszRealVersion);
            return ctx->pszRealVersion;
        case GL_REAL_RENDERER:
            GetString(GL_REAL_RENDERER, ctx->pszRealRenderer);
            return ctx->pszRealRenderer;
#endif
        default:
            return crStateGetString(name);
    }
}
Esempio n. 20
0
BOOL UI_LoadCfgFile(void)
{
    ER erReturn;
    UINT32 i;

    char *SysParam_Sector;
    UINT32      uiFileSize;
    UINT8       *BgBuf;
    PSTORE_SECTION_HANDLE* pSecHdl;


    strcpy(gUIConfigInfo.strMakerString, (CHAR *)GetMakerString());
    strcpy(gUIConfigInfo.strModelString,(CHAR *)GetModelString());
    strcpy(gUIConfigInfo.strSoftwareVer,(CHAR *)GetVersionString());

    gUIConfigInfo.uiSizeDefaultIndex        = DEFAULT_PHOTO_SIZE;
    gUIConfigInfo.uiMovieSizeDefaultIndex   = DEFAULT_MOVIE_SIZE;
    gUIConfigInfo.uiLanguageDefaultIndex    = DEFAULT_LANGUAGE;
    gUIConfigInfo.uiFreqDefaultIndex        = DEFAULT_FREQUENCY;
    gUIConfigInfo.uiTVModeDefaultIndex      = DEFAULT_TV_MODE;
    gUIConfigInfo.uiDateImprintDefaultIndex = DEFAULT_MOVIE_DATEIMPRINT;
    gUIConfigInfo.uiBeepDefaultIndex        = DEFAULT_BEEP;
    gUIConfigInfo.uiVideoAudioDefaultIndex  = DEFAULT_MOVIE_AUDIO;


    BgBuf = (UINT8 *)OS_GetMempoolAddr(POOL_ID_APP);
    //PStore_EnablePS();
    pSecHdl = PStore_OpenSection(PS_BG_CFG, PS_RDONLY);

    if (pSecHdl == E_PS_SECHDLER)
    {
        debug_err(("UserPS_ReadCfgFile: Section open fail\r\n"));
        goto err_ret;
    }

    erReturn = PStore_ReadSection(BgBuf, 0, 4, pSecHdl);

    if (erReturn != E_PS_OK)
    {
        debug_err(("UserPS_ReadCfgFile: PStore read error\r\n"));
        goto err_ret;
    }

    uiFileSize = MAKE_LONG(MAKE_WORD(BgBuf[0],BgBuf[1]),MAKE_WORD(BgBuf[2],BgBuf[3]));

    USE_MSG(("UserPS_ReadCfgFile: cfg filesize=%d\r\n", uiFileSize));

    if (uiFileSize > CFG_MAX_FILESIZE)
    {
        debug_err(("UserPS_ReadCfgFile: file size error\n\r"));
        goto err_ret;
    }

    erReturn = PStore_ReadSection(BgBuf, 0, (uiFileSize+4), pSecHdl);
    if (erReturn != E_PS_OK)
    {
        debug_err(("UserPS_ReadCfgFile: PStore read error\r\n"));
        goto err_ret;
    }
    PStore_CloseSection(pSecHdl);
    //PStore_DisablePS();

    SysParam_Sector = (char *)(BgBuf + ((uiFileSize+4+4-1)/4)*4);

    memset((UINT8 *)SysParam_Sector,0,SYSPARAM_SYSFLAG_LEN);
    if (!get_key_value((char *)&BgBuf[4],(char*)SysParam_Sector))
    {
        debug_err(("UserPS_ReadCfgFile: Read cfg file error\r\n"));
        return FALSE;//goto err_ret;
    }

    i = 0;
    while(TRUE)
    {
        if (SysParam_Sector[0] == '\0')
        {
             debug_err(("sysflag is null\r\n"));
             break;
        }
        if (i*KEY_VALUE_LEN >= SYSPARAM_SYSFLAG_LEN)
        {
            break;
        }
        if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN, "beep"))
        {
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "yes"))
            {
                USE_MSG(("beep yes\r\n"));
                UI_SetBeepDefaultIndex(BEEP_ON);
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "no"))
            {
                USE_MSG(("beep no\r\n"));
                UI_SetBeepDefaultIndex(BEEP_OFF);
            }
        }

        if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN, "videoaudio"))
        {
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "yes"))
            {
                USE_MSG(("videoaudio yes\r\n"));
                UI_SetVideoAudioDefaultIndex(MOVIE_AUDIO_ON);
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "no"))
            {
                USE_MSG(("videoaudio no\r\n"));
                UI_SetVideoAudioDefaultIndex(MOVIE_AUDIO_OFF);
            }
        }

        if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN, "hz"))
        {
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "50hz"))
            {
                USE_MSG(("50hz\r\n"));
                UI_SetFreqDefaultIndex(FREQUENCY_50HZ);
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "60hz"))
            {
                USE_MSG(("60hz\r\n"));
                UI_SetFreqDefaultIndex(FREQUENCY_60HZ);
            }
        }
        if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN, "tvmode"))
        {
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "pal"))
            {
                USE_MSG(("tvmode pal\r\n"));
                UI_SetTVModeDefaultIndex(TV_MODE_PAL);
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "ntsc"))
            {
                USE_MSG(("tvmode  ntsc\r\n"));
                UI_SetTVModeDefaultIndex(TV_MODE_NTSC);
            }
        }
        if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN, "date"))
        {
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "yes"))
            {
                USE_MSG(("date_time on\r\n"));
                UI_SetDateImprintDefaultIndex(DATE_TIME_ON);
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "no"))
            {
                USE_MSG(("date_time off\r\n"));
                UI_SetDateImprintDefaultIndex(DATE_TIME_OFF);
            }
        }
        if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN, "moviesize"))
        {
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "1080p"))
            {
                USE_MSG(("moviesize-1080p\r\n"));
                gTM_OPTIONS_MOVIE_SIZE[MOVIE_SIZE_1080P].TextId = IDS_MOVIE_SIZE_1080FHD;
                gTM_OPTIONS_MOVIE_SIZE[MOVIE_SIZE_1080P].IconId = IDI_MOVIE_SIZE_1080FHD;
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "720p"))
            {
                USE_MSG(("moviesize-720p\r\n"));
                gTM_OPTIONS_MOVIE_SIZE[MOVIE_SIZE_720P].TextId = IDS_MOVIE_SIZE_720P;
                gTM_OPTIONS_MOVIE_SIZE[MOVIE_SIZE_720P].IconId = IDI_MOVIE_SIZE_720P;
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "wvga"))
            {
                USE_MSG(("moviesize-wvga\r\n"));
                gTM_OPTIONS_MOVIE_SIZE[MOVIE_SIZE_WVGA].TextId = IDS_MOVIE_SIZE_WVGA;
                gTM_OPTIONS_MOVIE_SIZE[MOVIE_SIZE_WVGA].IconId = IDI_MOVIE_SIZE_WVGA;
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "vga"))
            {
                USE_MSG(("moviesize-vga\r\n"));
                gTM_OPTIONS_MOVIE_SIZE[MOVIE_SIZE_VGA].TextId = IDS_MOVIE_SIZE_VGA;
                gTM_OPTIONS_MOVIE_SIZE[MOVIE_SIZE_VGA].IconId = IDI_MOVIE_SIZE_VGA;
            }
        }
        if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN, "photosize"))
        {
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "12m"))
            {
                USE_MSG(("photosize-12m\r\n"));
                gTM_OPTIONS_PHOTO_SIZE[PHOTO_SIZE_12M].TextId = IDS_PHOTO_SIZE_12M;
                gTM_OPTIONS_PHOTO_SIZE[PHOTO_SIZE_12M].IconId = IDI_PHOTO_SIZE_12M;
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "10m"))
            {
                USE_MSG(("photosize-10m\r\n"));
                gTM_OPTIONS_PHOTO_SIZE[PHOTO_SIZE_10M].TextId = IDS_PHOTO_SIZE_10M;
                gTM_OPTIONS_PHOTO_SIZE[PHOTO_SIZE_10M].IconId = IDI_PHOTO_SIZE_10M;
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "8m"))
            {
                USE_MSG(("photosize-8m\r\n"));
                gTM_OPTIONS_PHOTO_SIZE[PHOTO_SIZE_8M].TextId = IDS_PHOTO_SIZE_8M;
                gTM_OPTIONS_PHOTO_SIZE[PHOTO_SIZE_8M].IconId = IDI_PHOTO_SIZE_8M;
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "5m"))
            {
                USE_MSG(("photosize-5m\r\n"));
                gTM_OPTIONS_PHOTO_SIZE[PHOTO_SIZE_5M].TextId = IDS_PHOTO_SIZE_5M;
                gTM_OPTIONS_PHOTO_SIZE[PHOTO_SIZE_5M].IconId = IDI_PHOTO_SIZE_5M;
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "3m"))
            {
                USE_MSG(("photosize-3m\r\n"));
                gTM_OPTIONS_PHOTO_SIZE[PHOTO_SIZE_3M].TextId = IDS_PHOTO_SIZE_3M;
                gTM_OPTIONS_PHOTO_SIZE[PHOTO_SIZE_3M].IconId = IDI_PHOTO_SIZE_3M;
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "2m169"))
            {
                USE_MSG(("photosize-2m9\r\n"));
                gTM_OPTIONS_PHOTO_SIZE[PHOTO_SIZE_2MHD].TextId = IDS_PHOTO_SIZE_2MHD;
                gTM_OPTIONS_PHOTO_SIZE[PHOTO_SIZE_2MHD].IconId = IDI_PHOTO_SIZE_2MHD;
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "vga"))
            {
                USE_MSG(("photosize-vgam\r\n"));
                gTM_OPTIONS_PHOTO_SIZE[PHOTO_SIZE_VGA].TextId = IDS_PHOTO_SIZE_VGA;
                gTM_OPTIONS_PHOTO_SIZE[PHOTO_SIZE_VGA].IconId = IDI_PHOTO_SIZE_VGA;
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "1m"))
            {
                USE_MSG(("photosize-1m\r\n"));
                gTM_OPTIONS_PHOTO_SIZE[PHOTO_SIZE_1M].TextId = IDS_PHOTO_SIZE_1M;
                gTM_OPTIONS_PHOTO_SIZE[PHOTO_SIZE_1M].IconId = IDI_PHOTO_SIZE_1M;
            }
        }
        if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN, "defaultmoviesize"))
        {
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "1080p"))
            {
                USE_MSG(("defaultmoviesize-1080p\r\n"));
                UI_SetMovieSizeDefaultIndex(MOVIE_SIZE_1080P);
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "720p"))
            {
                USE_MSG(("defaultmoviesize-720p\r\n"));
                UI_SetMovieSizeDefaultIndex(MOVIE_SIZE_720P);
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "wvga"))
            {
                USE_MSG(("defaultmoviesize-wvga\r\n"));
                UI_SetMovieSizeDefaultIndex(MOVIE_SIZE_WVGA);
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "vga"))
            {
                USE_MSG(("defaultmoviesize-vga\r\n"));
                UI_SetMovieSizeDefaultIndex(MOVIE_SIZE_VGA);
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "qvga"))
            {
                USE_MSG(("defaultmoviesize-qvga\r\n"));
                UI_SetMovieSizeDefaultIndex(MOVIE_SIZE_QVGA);
            }
        }
        if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN, "defaultphotosize"))
        {
            #if (UPDATE_CFG == UPDATE_CFG_YES)
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "vga"))
            {
                USE_MSG(("defaultphotosize-vga\r\n"));
                UI_SetSizeDefaultIndex(PHOTO_SIZE_VGA);
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "2m169"))
            {
                USE_MSG(("defaultphotosize-2m169\r\n"));
                UI_SetSizeDefaultIndex(PHOTO_SIZE_2MHD);
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "2m"))
            {
                USE_MSG(("defaultphotosize-2m\r\n"));
                UI_SetSizeDefaultIndex(PHOTO_SIZE_2M);
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "3m"))
            {
                USE_MSG(("defaultphotosize-3m\r\n"));
                UI_SetSizeDefaultIndex(PHOTO_SIZE_3M);
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "5m"))
            {
                USE_MSG(("defaultphotosize-5m\r\n"));
                UI_SetSizeDefaultIndex(PHOTO_SIZE_5M);
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "8m"))
            {
                USE_MSG(("defaultphotosize-8m\r\n"));
                UI_SetSizeDefaultIndex(PHOTO_SIZE_8M);
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "9m"))
            {
                USE_MSG(("defaultphotosize-9m\r\n"));
                //UI_SetSizeDefaultIndex(PHOTO_SIZE_10M);
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "10m"))
            {
                USE_MSG(("defaultphotosize-10m\r\n"));
                UI_SetSizeDefaultIndex(PHOTO_SIZE_10M);
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "12m"))
            {
                USE_MSG(("defaultphotosize-12m\r\n"));
                UI_SetSizeDefaultIndex(PHOTO_SIZE_12M);
            }
            #endif
        }

        if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN, "language"))
        {
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "en"))
            {
                USE_MSG(("language-en\r\n"));
                gTM_OPTIONS_LANGUAGE[LANG_EN].TextId = IDS_LANG_EN;
                gTM_OPTIONS_LANGUAGE[LANG_EN].IconId = IDI_LANG_EN;
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "de"))
            {
                USE_MSG(("language-de\r\n"));
                gTM_OPTIONS_LANGUAGE[LANG_DE].TextId = IDS_LANG_DE;
                gTM_OPTIONS_LANGUAGE[LANG_DE].IconId = IDI_LANG_DE;
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "es"))
            {
                USE_MSG(("language-es\r\n"));
                gTM_OPTIONS_LANGUAGE[LANG_ES].TextId = IDS_LANG_ES;
                gTM_OPTIONS_LANGUAGE[LANG_ES].IconId = IDI_LANG_ES;
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "it"))
            {
                USE_MSG(("language-it\r\n"));
                gTM_OPTIONS_LANGUAGE[LANG_IT].TextId = IDS_LANG_IT;
                gTM_OPTIONS_LANGUAGE[LANG_IT].IconId = IDI_LANG_IT;
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "ru"))
            {
                USE_MSG(("language-ru\r\n"));
                gTM_OPTIONS_LANGUAGE[LANG_RU].TextId = IDS_LANG_RU;
                gTM_OPTIONS_LANGUAGE[LANG_RU].IconId = IDI_LANG_RU;
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "fr"))
            {
                USE_MSG(("language-fr\r\n"));
                gTM_OPTIONS_LANGUAGE[LANG_FR].TextId = IDS_LANG_FR;
                gTM_OPTIONS_LANGUAGE[LANG_FR].IconId = IDI_LANG_FR;
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "sc"))
            {
                USE_MSG(("language-sc\r\n"));
                gTM_OPTIONS_LANGUAGE[LANG_SC].TextId = IDS_LANG_SC;
                gTM_OPTIONS_LANGUAGE[LANG_SC].IconId = IDI_LANG_SC;
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "tc"))
            {
                USE_MSG(("language-tc\r\n"));
                gTM_OPTIONS_LANGUAGE[LANG_TC].TextId = IDS_LANG_TC;
                gTM_OPTIONS_LANGUAGE[LANG_TC].IconId = IDI_LANG_TC;
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "jp"))
            {
                USE_MSG(("language-jp\r\n"));
                gTM_OPTIONS_LANGUAGE[LANG_JP].TextId = IDS_LANG_JP;
                gTM_OPTIONS_LANGUAGE[LANG_JP].IconId = IDI_LANG_JP;
            }
        }
        if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN, "defaultlanguage"))
        {
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "en"))
            {
                USE_MSG(("defaultlanguage-en\r\n"));
                UI_SetLanguageDefaultIndex(LANG_EN);
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "fr"))
            {
                USE_MSG(("defaultlanguage-fr\r\n"));
                UI_SetLanguageDefaultIndex(LANG_FR);
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "de"))
            {
                USE_MSG(("defaultlanguage-de\r\n"));
                UI_SetLanguageDefaultIndex(LANG_DE);
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "es"))
            {
                USE_MSG(("defaultlanguage-es\r\n"));\
                UI_SetLanguageDefaultIndex(LANG_ES);
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "ru"))
            {
                USE_MSG(("defaultlanguage-ru\r\n"));
                UI_SetLanguageDefaultIndex(LANG_RU);
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "it"))
            {
                USE_MSG(("defaultlanguage-it\r\n"));
                UI_SetLanguageDefaultIndex(LANG_IT);
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "sc"))
            {
                USE_MSG(("defaultlanguage-sc\r\n"));
                UI_SetLanguageDefaultIndex(LANG_SC);
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "tc"))
            {
                USE_MSG(("defaultlanguage-tc\r\n"));
                UI_SetLanguageDefaultIndex(LANG_TC);
            }
            if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "jp"))
            {
                USE_MSG(("defaultlanguage-jp\r\n"));
                UI_SetLanguageDefaultIndex(LANG_JP);
            }
        }

        if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN, "maker"))
        {

            USE_MSG(("maker:%s\r\n",SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN));
            strcpy(gUIConfigInfo.strMakerString,SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN);
        }

        if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN, "model"))
        {

            USE_MSG(("model:%s\r\n",SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN));
            strcpy(gUIConfigInfo.strModelString,SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN);
        }

        if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN, "version"))
        {

            USE_MSG(("verion:%s\r\n",SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN));
            strcpy(gUIConfigInfo.strSoftwareVer,SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN);
        }
        if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN, "ImageDescription"))
        {

            USE_MSG(("sImageDescription:%s\r\n",SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN));
            strcpy(gUIConfigInfo.strImageDescription,SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN);
        }

        i++;
    }

    return TRUE;
err_ret:

    PStore_CloseSection(pSecHdl);
    //PStore_DisablePS();
    return FALSE;
}
Esempio n. 21
0
bool FBuildPatchAppManifest::IsSameAs(FBuildPatchAppManifestRef Other) const
{
	return this == &Other.Get() || (GetAppID() == Other->GetAppID() && GetAppName() == Other->GetAppName() && GetVersionString() == Other->GetVersionString());
}
Esempio n. 22
0
/*****************************************************************************
lFILEINFO *ParseCommandLine(BOOL *bPipeNecessary)
	bPipeNecessary	: (OUT) true if we were called from the shell extension and
							need to accept pipe input

Return Value:
a filelist to start processing, or NULL if this has been deferred to another instance

Notes:
1) It checks that there are command line parameters
2) If there are, it reads either reads the file names from the command line or signals
   that pipe input from the shell extension neets to be parsed

   If queueing is enabled and there is a previous instance it sends a window message to
   this instance and terminates. The previous instance is then responsible for accepting
   the pipe data/command line
*****************************************************************************/
lFILEINFO *ParseCommandLine(BOOL *bPipeNecessary) {
	INT iNumFiles;
	HWND prevInst;
	TCHAR prevInstTitle[MAX_PATH_EX];

	lFILEINFO *fileList;
	FILEINFO fileinfoTmp = {0};

	fileList = new lFILEINFO;
	fileinfoTmp.parentList = fileList;

	LPTSTR* argv;
	INT argc;
	argv = CommandLineToArgv(GetCommandLine(), &argc);

	*bPipeNecessary = FALSE;
    
	// is there anything to do? (< 2, because 1st element is the path to the executable itself)
	if(argc < 2){
		LocalFree(argv);
		return fileList;
	}
	// use pipe input?
	if( lstrcmpi(argv[1], TEXT("-UsePipeCommunication")) == 0)
	{
		// pipe switches used by the shell extension
		if(argc > 2)
		{
			if(lstrcmpi(argv[2], TEXT("-CreateSFV")) == 0)
			{
				fileList->uiCmdOpts = CMD_SFV;
			}
			else if(lstrcmpi(argv[2], TEXT("-CreateMD5")) == 0)
			{
				fileList->uiCmdOpts = CMD_MD5;
			}
			else if(lstrcmpi(argv[2], TEXT("-CreateSHA1")) == 0)
			{
				fileList->uiCmdOpts = CMD_SHA1;
			}
            else if(lstrcmpi(argv[2], TEXT("-CreateSHA256")) == 0)
			{
				fileList->uiCmdOpts = CMD_SHA256;
			}
            else if(lstrcmpi(argv[2], TEXT("-CreateSHA512")) == 0)
			{
				fileList->uiCmdOpts = CMD_SHA512;
			}
			else if(lstrcmpi(argv[2], TEXT("-PutNAME")) == 0)
			{
				fileList->uiCmdOpts = CMD_NAME;
			}
			else if(lstrcmpi(argv[2], TEXT("-PutNTFS")) == 0)
			{
				fileList->uiCmdOpts = CMD_NTFS;
			}
			else if(lstrcmpi(argv[2], TEXT("-Reparent")) == 0)
			{
				fileList->uiCmdOpts = CMD_REPARENT;
			}
            else if(lstrcmpi(argv[2], TEXT("-HashFilesOnly")) == 0)
			{
				fileList->uiCmdOpts = CMD_ALLHASHES;
			}
            else if(lstrcmpi(argv[2], TEXT("-ForceBSD")) == 0)
			{
				fileList->uiCmdOpts = CMD_FORCE_BSD;
			}
		}
		if(g_program_options.bEnableQueue && GetVersionString(prevInstTitle,MAX_PATH_EX)) {
			prevInst = NULL;
			prevInst = FindWindowEx(NULL,prevInst,TEXT("RapidCrcMainWindow"),prevInstTitle);
			if(prevInst) {
				PostMessage(prevInst,WM_ACCEPT_PIPE,(WPARAM)fileList->uiCmdOpts,NULL);
				delete fileList;
				LocalFree(argv);

				return NULL;
			}
		}

		*bPipeNecessary = TRUE;
	}
	else // not using pipe input => command line parameter are files and folders
	{
		// get number of files
		iNumFiles = argc - 1; // -1 because 1st element is the path to the executable itself

		if(g_program_options.bEnableQueue && GetVersionString(prevInstTitle,MAX_PATH_EX)) {
			prevInst = NULL;
			prevInst = FindWindowEx(NULL,prevInst,TEXT("RapidCrcMainWindow"),prevInstTitle);
			if(prevInst) {
				TCHAR *cmdLine = GetCommandLine();
				COPYDATASTRUCT cdata;
				cdata.dwData = CMDDATA;
				cdata.lpData = cmdLine;
				cdata.cbData = (lstrlen(GetCommandLine()) + 1) * sizeof(TCHAR);

				SendMessage(prevInst,WM_COPYDATA,(WPARAM)0,(LPARAM)&cdata);
				delete fileList;
				LocalFree(argv);
				return NULL;
			}
		}

		for(INT i = 0; i < iNumFiles; ++i){
            fileinfoTmp.szFilename = argv[i+1];
			fileList->fInfos.push_back(fileinfoTmp);
		}
	}

	LocalFree(argv);

	return fileList;
}
Esempio n. 23
0
//__________________________________________________________________________________
long	DisplayListOfChoices (void)
{
	ReadInTemplateFiles();
	
	if (!availableTemplateFiles.lLength) 
		return -1;
	
	long 		choice = -1;
	char 		buffer[2048];
	_String 	fileAbbr, 
				*thisLine;
	_SimpleList categoryDelimiters;
	_List		categoryHeadings;
	
	for (choice = 0; choice< availableTemplateFiles.lLength; choice++)
	{
		thisLine = (_String*)(*(_List*)availableTemplateFiles(choice))(2);
		if (thisLine->sData[0]=='!')
		{
			categoryDelimiters<<choice;
			fileAbbr = *thisLine;
			fileAbbr.Trim (1,-1);
			categoryHeadings && &fileAbbr;
		}
	}
	
	choice = -1;
	if (categoryDelimiters.lLength==0)
	{
		while (choice == -1)
		{
			for (choice = 0; choice<availableTemplateFiles.lLength; choice++)
			{
				printf ("\n\t(%s):%s",((_String*)(*(_List*)availableTemplateFiles(choice))(0))->getStr(),
									  ((_String*)(*(_List*)availableTemplateFiles(choice))(1))->getStr());
			}
			printf ("\n\n Please type in the abbreviation for the file you want to use (or press ENTER to process custom batch file):");
			fgets (buffer,2048,stdin);
			fgets (buffer,2048,stdin);
			fileAbbr = buffer;
			if (fileAbbr.FirstNonSpaceIndex()<0)
				 return -1;
			fileAbbr.UpCase();
			for (choice = 0; choice<availableTemplateFiles.lLength; choice++)
			{
				if (fileAbbr.Equal((_String*)(*(_List*)availableTemplateFiles(choice))(0)))
					break;							  
			}
			if (choice==availableTemplateFiles.lLength) choice=-1;
		}	
	}
	else
	{
		long categNumber = -1;
		while (choice==-1)
		{
			if (categNumber<0)
			{
				_String   header ("***************** TYPES OF STANDARD ANALYSES *****************"),
						  verString (GetVersionString().getStr());
						  
				if (verString.sLength<header.sLength-2)
				{
					_String padder (128,true);
					long    poop = (header.sLength-2-verString.sLength)/2;
					if (!poop) poop = 1;
					for (choice=0; choice<poop; choice++)
						padder << ' ';
					padder.Finalize();
					verString = padder & '/' & verString & "\\" & padder;
				}
						  
				printf ("\n\033[2J\033[H%s\n%s\n\n",verString.getStr(), header.getStr());
				for (choice = 0; choice<categoryHeadings.lLength; choice++)
					printf ("\n\t(%ld) %s",choice+1,((_String*)categoryHeadings(choice))->getStr());

				printf ("\n\n Please select type of analyses you want to list (or press ENTER to process custom batch file):");
				
				
				fgets (buffer,2048,stdin);
				fileAbbr = buffer;
				
				if (logInputMode)
					loggedUserInputs && & fileAbbr;
		
				if (fileAbbr.FirstNonSpaceIndex()<0)
					 return -1;
				
				choice = fileAbbr.toNum();
				
				if ( choice>0 && choice<=categoryHeadings.lLength)
					categNumber = choice-1;
			}
			else
			{
				printf ("\n\033[2J\033[H ***************** FILES IN '%s' ***************** \n\n",((_String*)categoryHeadings(categNumber))->getStr());
				long start = categoryDelimiters.lData[categNumber]+1,
					 end = categNumber==categoryDelimiters.lLength-1?availableTemplateFiles.lLength:categoryDelimiters.lData[categNumber+1];
				
				for (choice = start; choice<end; choice++)
					printf ("\n\t(%ld) %s",choice-start+1,((_String*)(*(_List*)availableTemplateFiles(choice))(1))->getStr());

				printf ("\n\n Please select the file you want to use (or press ENTER to return to the list of analysis types):");
				
				fileAbbr = *StringFromConsole ();
				
				if (logInputMode)
					loggedUserInputs && & fileAbbr;
				
				if (fileAbbr.FirstNonSpaceIndex()<0)
					 categNumber = -1;
				else
				{
					choice = fileAbbr.toNum();
					if ((choice>0 && choice<=end-start))
						return start+choice-1;
				}
					
			}
			choice = -1;
		}
	}
	return choice;
}
Esempio n. 24
0
/****************************************************************************
*
* .b
*   Procedure Name:                 MessageManager
*
*   Abstract:
*       Message_Manager parses the passed request packet and build an
*       appropriate resonse packet and sends it through the serial port.
*
*   INPUTS:
*
*       Globals:
*
*       Constants:
*           TRUE                        TRUE constant
*           FALSE                       FALSE constant
*           STATIC                      identifier for the static fault count
*           DYNAMIC                     identifier for the dynamic fault count
*           ID_PCPTU                    SelfTest origin identifier
*           VERSIONNUMBER               system software version number
*           NUMDEFINEDVARS              number of variables that are defined
*           MODE_SELF_TEST              SelfTest mode identifier
*           STC_CMD_ACK_MSG             SelfTest command identifier
*           STC_NORMAL_ABORT            SelfTest command identifier
*           STC_CMD_ABORT_SES           SelfTest command identifier
*           MAX_CR_TLB_ENTRIES          number of variables used by the chart
*           NUMLOGGEDVARIABLES          number of variables that are datalogged
*           NUMOFDATALOGENTRIES         number of datalog frames
*
*       Procedure Parameters:
*           PassedRequest   Header_t *                  request packet that the
*                                                       response packet is to
*                                                       be build upon
*
*   OUTPUTS
*
*       Globals:
*           None
*
*       Returned Values:
*           None (void)
*
*   Functional Description:
*       Message_Manager enters a switch statement based on the message
*       type that has been passed into it by *PassedRequest.  The switch
*       build a response based on the data passed into it.  The response
*       is then transmitted out the serial port a call to TransmitMessage.
*
* .b
*
*   History : 07/10/94    Creation of Version 3.0             jsl
*             10/5/95     ddp
*             - Removed LZ Huffman compression layer for Streams
*               due to processing time constraints.
*               Instead added a Type Crunching algorithm while Logging Data.
*               This required passing the type of the Stream Variables back
*               to the WPTU as well as computing how much data actually needed
*               to be passed back to the WPTU to maintain a certain
*               Sample Rate.
*             12/14/95     ddp
*             - Changed the UPDATE_WATCH_ELEMENTS case. Now the DataType
*               is a UINT_16.
*             02/21/96     ddp
*             - Changed the READ_VARIABLE_VALUE case. Now the DataType
*               is a UINT_16.
*             03/08/96     ddp
*             - Changed CHANGE_EVENT_LOG and GET_EVENT_LOG to pass back
*               the Data Log Recording info and the Number Of Event Log resp.
*			  11/12/01    RAC
*			  - added Update_EDT_EST_Flags to the SET_TIME_DATE case
*			    of the case statement to update dst flags when the
*			    time is updated through the PTU
*             11/12/2002 Sarfaraz Taher 
*             - Changed code in the case GET_EMBEDDED_INFORMATION to
*               obtain the version string via a function instead of 
*               using the SWVERSIONSTRING directly. This is to allow the
*               version.h file to be located in a separate directory
*               (same filename conflict issue).
*****************************************************************************/
void MessageManager(Header_t *PassedRequest)
{
	UINT_16                 Index;
	UINT_16                 Counter;
	SignedUnion_t           TempSignedUnion;
	UINT_16                 NumberOfBytes;
	UINT_8                  *version_string;

	/*  Set the response type to the request type. */
	Response.PacketType = PassedRequest->PacketType;

	/*  Switch on the request type.  */
	switch (PassedRequest->PacketType)
	{
		case SET_WATCH_ELEMENT:
			TransmitACK();

			GlobalPTUData.WatchElement
				[((SetWatchElementReq_t *)PassedRequest)->ElementIndex] =
				((SetWatchElementReq_t *)PassedRequest)->DictionaryIndex;

			break;

		case SET_WATCH_ELEMENTS:
			TransmitACK();

			for (Index = 0; Index < WATCHSIZE; Index++)
				GlobalPTUData.WatchElement[Index] =
					((SetWatchElementsReq_t *)PassedRequest)->
						WatchElement[Index];

			break;

		case UPDATE_WATCH_ELEMENTS:
			Counter = 0;

			for (Index = 0; Index < WATCHSIZE; Index++)
			{
				if ( (GlobalPTUData.WatchElement[Index] == 0xffff) ||
					 (GlobalPTUData.WatchElement[Index] == 0xfffe) )
					continue;

				GetVariableValue( GlobalPTUData.WatchElement[Index],
								  &TempSignedUnion );

				if ( (TempSignedUnion.Unsigned ==
					  GlobalPTUData.PrevWatchValues[Index].Unsigned) &&
					  !(((UpdateWatchElementsReq_t *)PassedRequest)->ForceFullUpdate) )
					continue;

				((UpdateWatchElementsRes_t *)&Response)->
					WatchElement[Counter].NewValue.Unsigned = TempSignedUnion.Unsigned;

				((UpdateWatchElementsRes_t *)&Response)->
					WatchElement[Counter].Index = Index;

				GlobalPTUData.PrevWatchValues[Index].Unsigned =
					TempSignedUnion.Unsigned;

				switch (VariableDef[GlobalPTUData.WatchElement[Index]].type_id)
				{
					case UINT_8_TYPE:
					case UINT_16_TYPE:
					case UINT_32_TYPE:
						((UpdateWatchElementsRes_t *)&Response)->
							WatchElement[Counter++].DataType = (UINT_16)UNSIGNED;
						break;

					case INT_8_TYPE:
					case INT_16_TYPE:
					case INT_32_TYPE:
						((UpdateWatchElementsRes_t *)&Response)->
							WatchElement[Counter++].DataType = (UINT_16)SIGNED;
						break;
				}
			}

			((UpdateWatchElementsRes_t *)&Response)->NumberOfUpdates = Counter;

			TransmitMessage((Header_t *)&Response,
							(UINT_16)(sizeof(Header_t) + 2 +
									  (sizeof(WatchElement_t) * Counter)));
			break;

		case READ_VARIABLE_VALUE:
			Index = ((ReadVariableReq_t *)PassedRequest)->DictionaryIndex;

			GetVariableValue(Index,
							 &(((ReadVariableRes_t *)&Response)->CurrentValue));

			switch (VariableDef[Index].type_id)
			{
				case UINT_8_TYPE:
				case UINT_16_TYPE:
				case UINT_32_TYPE:
					((ReadVariableRes_t *)&Response)->DataType =
														(UINT_16)UNSIGNED;
					break;

				case INT_8_TYPE:
				case INT_16_TYPE:
				case INT_32_TYPE:
					((ReadVariableRes_t *)&Response)->DataType =
														(UINT_16)SIGNED;
					break;
			}

			TransmitMessage((Header_t *)&Response,
							(UINT_16)sizeof(ReadVariableRes_t));
			break;

		case SEND_VARIABLE_VALUE:
			TransmitACK();

			debugPrintf("SEND_VARIABLE_VALUE\n");

			Index = ((ReadVariableReq_t *)PassedRequest)->DictionaryIndex;

#ifndef COMC_PTU
#ifndef TEST_ON_PC
			if (VariableDef[Index].AttributeFlags & PTUD_BBRAM)
				start_cbram_write();
#endif
#endif
			switch (VariableDef[Index].type_id)
			{
				case UINT_8_TYPE:
					*(UINT_8 *)VariableDef[Index].var_start_addr =
						((SendVariableReq_t *)PassedRequest)->NewValue.Unsigned;
					break;

				case INT_8_TYPE:
					*(INT_8 *)VariableDef[Index].var_start_addr =
						((SendVariableReq_t *)PassedRequest)->NewValue.Signed;
					break;

				case UINT_16_TYPE:
					*(UINT_16 *)VariableDef[Index].var_start_addr =
						((SendVariableReq_t *)PassedRequest)->NewValue.Unsigned;
					break;

				case INT_16_TYPE:
					*(INT_16 *)VariableDef[Index].var_start_addr =
						((SendVariableReq_t *)PassedRequest)->NewValue.Signed;
					break;

				case UINT_32_TYPE:
					*(UINT_32 *)VariableDef[Index].var_start_addr =
						((SendVariableReq_t *)PassedRequest)->NewValue.Unsigned;
					break;

				case INT_32_TYPE:
					*(INT_32 *)VariableDef[Index].var_start_addr =
						((SendVariableReq_t *)PassedRequest)->NewValue.Signed;
					break;
			}

#ifndef TEST_ON_PC
#ifndef COMC_PTU
			if (VariableDef[Index].AttributeFlags & PTUD_BBRAM)
				end_cbram_write();
#endif
            /* added to support the Rhapsody generated code */
            setWV(Index);
#endif
			break;

		case GET_DICTIONARY_SIZE:
			((GetDictionarySizeRes_t *)&Response)->DictionarySize =
				NUMDEFINEDVARS;

			TransmitMessage((Header_t *)&Response,
							(UINT_16)sizeof(GetDictionarySizeRes_t) );
			break;

		case GET_VARIABLE_INFORMATION:
			Index = ((GetVariableInfoReq_t *)PassedRequest)->DictionaryIndex;

			switch (VariableDef[Index].type_id)
			{
				case UINT_8_TYPE:
				case UINT_16_TYPE:
				case UINT_32_TYPE:
					((GetVariableInfoRes_t *)&Response)->DataType =
														(UINT_16)UNSIGNED;
					break;

				case INT_8_TYPE:
				case INT_16_TYPE:
				case INT_32_TYPE:
					((GetVariableInfoRes_t *)&Response)->DataType =
														(UINT_16)SIGNED;
					break;
			}

			((GetVariableInfoRes_t *)&Response)->MaxScale =
							GlobalPTUData.VariableInfo[Index].max_scale;

			((GetVariableInfoRes_t *)&Response)->MinScale =
							GlobalPTUData.VariableInfo[Index].min_scale;

			((GetVariableInfoRes_t *)&Response)->AttributeFlags =
							VariableDef[Index].AttributeFlags;

			TransmitMessage((Header_t *)&Response,
							(UINT_16)sizeof(GetVariableInfoRes_t)   );
			break;

		case GET_EMBEDDED_INFORMATION: 
#ifndef TEST_ON_PC
			version_string = GetVersionString();
#else
			debugPrintf ("Get Embedded Info from PC request\n");

		    version_string = "TOPCVC3508";
#endif
		    strncpy( ((GetEmbeddedInfoRes_t *)&Response)->SoftwareVersion,
					 (const char *)version_string, 40);

#ifndef COMC_PTU
#ifndef TEST_ON_PC
			GetCarID( ((GetEmbeddedInfoRes_t *)&Response)->CarID );
#else
			strcpy( ((GetEmbeddedInfoRes_t *)&Response)->CarID, "1234");
#endif
#endif
			strncpy( ((GetEmbeddedInfoRes_t *)&Response)->SubSystemName,
					 WATCHWINDOWTITLE, 40);

			strncpy( ((GetEmbeddedInfoRes_t *)&Response)->IdentifierString,
					 IDENTIFIERSTRING, 4);

			((GetEmbeddedInfoRes_t *)&Response)->ConfigurationMask =
					PTUCONFIGURATION;

			TransmitMessage( (Header_t *)&Response,
							 (UINT_16)sizeof(GetEmbeddedInfoRes_t));
			break;

		case GET_CHART_MODE:
			((GetChartModeRes_t *)&Response)->CurrentChartMode =
				GlobalPTUData.ChartRecorderMode;

			TransmitMessage( (Header_t *)&Response,
						 (UINT_16)sizeof(GetChartModeRes_t));
			break;

		case SET_CHART_MODE:
			TransmitACK();

			switch (((SetChartModeReq_t *)PassedRequest)->TargetChartMode)
			{
				case DATAMODE:
				case RAMPMODE:
				case ZEROMODE:
				case FULLMODE:
					GlobalPTUData.ChartRecorderMode =
						((SetChartModeReq_t *)PassedRequest)->TargetChartMode;
					break;
			}


			break;

		case GET_CHART_INDEX:
			Index = ((GetChartIndexReq_t*)PassedRequest)->ChartIndex;

			((GetChartIndexRes_t *)&Response)->VariableIndex =
				GlobalPTUData.ChartRecorderElement[Index];

			TransmitMessage((Header_t *)&Response,
							(UINT_16)sizeof(GetChartIndexRes_t) );
            
			break;

		case SET_CHART_INDEX:
			TransmitACK();

			GlobalPTUData.ChartRecorderElement
				[((SetChartIndexReq_t *)PassedRequest)->ChartIndex] =
					((SetChartIndexReq_t *)PassedRequest)->VariableIndex;

			break;

		case SET_CHART_SCALE:
			TransmitACK();

			GlobalPTUData.VariableInfo[
				((SetChartScaleReq_t *)&Request)->DictionaryIndex].max_scale =
					((SetChartScaleReq_t *)&Request)->MaxScale;

			GlobalPTUData.VariableInfo[
				((SetChartScaleReq_t *)&Request)->DictionaryIndex].min_scale =
					((SetChartScaleReq_t *)&Request)->MinScale;


			break;


		case GET_WATCH_VALUES:
			for (Counter = 0; Counter < WATCHSIZE; Counter++)
			{
				Index = ((GetWatchValuesReq_t *)PassedRequest)->WatchIndexes[Counter];

				switch (VariableDef[Index].type_id)
				{
					case UINT_8_TYPE:
					case UINT_16_TYPE:
					case UINT_32_TYPE:
						((GetWatchValuesRes_t *)&Response)->DataTypes[Counter] = UNSIGNED;
						break;

					case INT_8_TYPE:
					case INT_16_TYPE:
					case INT_32_TYPE:
						((GetWatchValuesRes_t *)&Response)->DataTypes[Counter] = SIGNED;
						break;
				}

				GetVariableValue(
					Index,
					&(((GetWatchValuesRes_t *)&Response)->WatchValues[Counter]) );
			}

			TransmitMessage((Header_t *)&Response,
							(UINT_16)sizeof(GetWatchValuesRes_t)    );
			break;

#ifndef TEST_ON_PC
		case GET_TIME_DATE:
			GetTimeDate(&Response);
			
			TransmitMessage((Header_t *)&Response,
							(UINT_16)sizeof(GetTimeDateRes_t)   );
			break;

		case SET_TIME_DATE:
			TransmitACK();
			
			SetTimeDate((MaxRequest_t DATAFARTYPE *)PassedRequest);
			
			/*Added for Daylite savings time - Becki Cirinelli 11-12-01
			this will update the spring & fall flags when the time
			is changed via the PTU*/
			//Update_DST_ST_Flags();
			break;

		case START_CLOCK:
			TransmitACK();

			StartRTC();
			break;

		case STOP_CLOCK:
			TransmitACK();

			StopRTC();
			break;

#ifndef COMC_PTU
		case START_SELF_TEST_TASK:
			TransmitACK();
			Start_self_test_task_req();
			break;

		case SELF_TEST_COMMAND:
			TransmitACK();
			Self_test_cmd_req(PassedRequest);
			break;

		case GET_SELF_TEST_PACKET:
			Get_self_test_packet_req(&Response);
			break;

		case EXIT_SELF_TEST_TASK:
			TransmitACK();
			Exit_self_test_task_req();
			break;
#endif
#endif

		case SET_FAULT_LOG:
			TransmitACK();

			SetFaultLogger( GlobalFaultLog,
							((SetFaultLogReq_t *)PassedRequest)->TargetState);

			break;

		case GET_FAULT_INDICES:
			((GetFaultIndicesRes_t *)&Response)->Oldest =
								GetOldestFaultIndex(GlobalFaultLog);
			((GetFaultIndicesRes_t *)&Response)->Newest =
								GetNewestFaultIndex(GlobalFaultLog);

			TransmitMessage((Header_t *)&Response,
							(UINT_16)sizeof(GetFaultIndicesRes_t)   );
			break;

		case GET_FAULT_DATA:
			Index = GetFaultStructure(
						GlobalFaultLog,
						((GetFaultDataReq_t *)PassedRequest)->FaultIndex,
						((GetFaultDataReq_t *)PassedRequest)->NumberOfFaults,
						((GetFaultDataRes_t *)&Response)->Buffer );

			((GetFaultDataRes_t *)&Response)->BufferSize = Index;

			TransmitMessage((Header_t *)&Response,
							(UINT_16)(sizeof(Header_t) + 2 + Index) );
			break;

		case CLEAR_EVENTLOG:
			TransmitACK();

			PurgeFaultLogger(GlobalFaultLog);
			ClearDataLogger(GlobalDataLog);

			break;

		case INITIALIZE_EVENTLOG:
			TransmitACK();

			InitializeFaultLogger(GlobalFaultLog, GlobalDataLog);
			InitializeDataLogger(GlobalDataLog);

			break;

		case GET_FAULT_FLAG:
			NumberOfBytes = GetEventEnableFlags(
								GlobalFaultLog,
								((GetFaultFlagRes_t *)&Response)->EnableFlag);

			((GetFaultFlagRes_t *)&Response)->BufferSize = NumberOfBytes;

			TransmitMessage( (Header_t *)&Response,
							 (UINT_16)(sizeof(Header_t) + 2 + NumberOfBytes) );
			break;

		case GET_STREAM_FLAG:

			NumberOfBytes = GetDatalogTriggerFlags(
								GlobalFaultLog,
								((GetStreamFlagRes_t *)&Response)->DatalogFlag);

			((GetStreamFlagRes_t *)&Response)->BufferSize = NumberOfBytes;

			TransmitMessage( (Header_t *)&Response,
							 (UINT_16)(sizeof(Header_t) + 2 + NumberOfBytes) );


			break;

		case SET_FAULT_FLAG:
			TransmitACK();

			SetFaultTable( GlobalFaultLog,
						   ((SetFaultFlagReq_t *)&Request)->TaskID,
						   ((SetFaultFlagReq_t *)&Request)->FaultID,
						   ((SetFaultFlagReq_t *)&Request)->EnableFlag );

			SetTriggerTable( GlobalFaultLog,
							 ((SetFaultFlagReq_t *)&Request)->TaskID,
							 ((SetFaultFlagReq_t *)&Request)->FaultID,
							 ((SetFaultFlagReq_t *)&Request)->DatalogFlag);

			break;

		case GET_FAULT_HISTORY:
			((GetFaultHistoryRes_t *)&Response)->DynamicHistory =
				GetDynamicFaultHistory( GlobalFaultLog,
										((GetFaultHistoryReq_t *)&Request)->TaskID,
										((GetFaultHistoryReq_t *)&Request)->FaultID );

			((GetFaultHistoryRes_t *)&Response)->StaticHistory  =
				GetStaticFaultHistory(  GlobalFaultLog,
										((GetFaultHistoryReq_t *)&Request)->TaskID,
										((GetFaultHistoryReq_t *)&Request)->FaultID );

			TransmitMessage((Header_t *)&Response,
							(UINT_16)sizeof(GetFaultHistoryRes_t)   );
			break;

		case GET_DATALOG_STATUS:
			((GetDatalogStatusRes_t *)&Response)->NumberOfDatalogs =
											GetCurrentQueue(GlobalDataLog);

			TransmitMessage((Header_t *)&Response,
							(UINT_16)sizeof(GetDatalogStatusRes_t)  );
			break;

		case GET_DATALOG_BUFFER:
			NumberOfBytes =
				GetDataLogData(
						GlobalDataLog,
						((GetDatalogBufferReq_t *)PassedRequest)->DatalogIndex,
						((GetDatalogBufferRes_t *)&Response)->DatalogBuffer,
						&((GetDatalogBufferRes_t *)&Response)->TimeOrigin);

			((GetDatalogBufferRes_t *)&Response)->BufferSize = NumberOfBytes;

			TransmitMessage( (Header_t *)&Response,
							 (UINT_16)(sizeof(Header_t) + 4 + NumberOfBytes) );


			break;

		case SET_STREAM_INFORMATION:
			TransmitACK();

			SetStreamInformation( GlobalDataLog,
								  &((SetStreamInfoReq_t *)PassedRequest)->Information );

			break;

		case GET_STREAM_INFORMATION:

			GetStreamInformation( GlobalDataLog,
								  ((GetStreamInfoReq_t *)PassedRequest)->StreamNumber,
								  &((GetStreamInfoRes_t *)&Response)->Information     );

			TransmitMessage( (Header_t *)&Response,
							 (UINT_16)sizeof(GetStreamInfoRes_t) );

			break;

		case GET_DEFAULT_STREAM:

			GetDefaultStreamInformation( GlobalDataLog,
										 &((GetStreamInfoRes_t *)&Response)->Information );

			TransmitMessage( (Header_t *)&Response,
							 (UINT_16)sizeof(GetStreamInfoRes_t) );

			break;

		case SET_CARID:
			TransmitACK();
#ifdef TEST_ON_PC
			SetCarID( ((SetCarIDReq_t *)PassedRequest)->NewCarID );
#else
			start_cbram_write();
			SetCarID( ((SetCarIDReq_t *)PassedRequest)->NewCarID );
			end_cbram_write();
#endif

			break;

		case CHANGE_EVENT_LOG:
			ChangeEventLog( ((ChangeEventLogReq_t *)PassedRequest)->NewEventLog,
							&((ChangeEventLogRes_t *)&Response)->ChangeStatus,
							&((ChangeEventLogRes_t *)&Response)->DataRecordingRate,
							&((ChangeEventLogRes_t *)&Response)->MaxTasks,
							&((ChangeEventLogRes_t *)&Response)->MaxEvents);

			TransmitMessage( (Header_t *)&Response,
							 (UINT_16)sizeof(ChangeEventLogRes_t) );
			break;

		case GET_EVENT_LOG :
			((GetEventLogRes_t *)&Response)->CurrentEventLog = CurrentEventLog;
			((GetEventLogRes_t *)&Response)->NumberEventLogs = NUMOFEVENTLOGS;

			TransmitMessage( (Header_t *)&Response,
							 (UINT_16)sizeof(GetEventLogRes_t) );
			break;
		
		case TERMINATECONNECTION:
			/* Intentionally do nothing; TCP server handles a FIN,ACK from the client and closes/
			 * shutdowns the socket
			 */
			break;

		default:
			break;


	}
}
Esempio n. 25
0
bool CServer::Create()
{
	//Create window
	WNDCLASSEX wndclass; 
	wndclass.cbSize=sizeof wndclass; 
	wndclass.style=0; 
	wndclass.lpfnWndProc=WindowProc; 
	wndclass.cbClsExtra=0; 
	wndclass.cbWndExtra=0; 
	wndclass.hInstance=GetModuleHandle(0); 
	wndclass.hIcon=0; 
	wndclass.hCursor=0; 
	wndclass.hbrBackground=0; 
	wndclass.lpszMenuName=0; 
	wndclass.lpszClassName=_T("FileZilla Server Helper Window"); 
	wndclass.hIconSm=0; 
	
	RegisterClassEx(&wndclass);
	
	m_hWnd=CreateWindow(_T("FileZilla Server Helper Window"), _T("FileZilla Server Helper Window"), 0, 0, 0, 0, 0, 0, 0, 0, GetModuleHandle(0));
	if (!m_hWnd)
		return false;
	SetWindowLong(m_hWnd, GWL_USERDATA, (LONG)this);

	hMainWnd = m_hWnd;

	m_pOptions=new COptions;
	m_pFileLogger = new CFileLogger(m_pOptions);
	
	//Create the threads
	int num = (int)m_pOptions->GetOptionVal(OPTION_THREADNUM);
	for (int i=0;i<num;i++)
	{
		CServerThread *pThread = new CServerThread;
		if (pThread->Create(THREAD_PRIORITY_NORMAL, CREATE_SUSPENDED))
		{
			pThread->ResumeThread();
			m_ThreadArray.push_back(pThread);
		}
	}
	
	m_pFileLogger->Log(GetVersionString() + " started");
	m_pFileLogger->Log("Initializing Server.");
	
	m_pListenSocket = new CListenSocket(this);
	m_pListenSocket->m_pThreadList = &m_ThreadArray;
	
	//TODO Start on startup check
	int nPort = (int)m_pOptions->GetOptionVal(OPTION_SERVERPORT);
	CStdString str;
	str.Format("Creating listen socket on port %d...", nPort);
	ShowStatus(str, 0);
	if (!m_pListenSocket->Create(nPort, SOCK_STREAM, FD_ACCEPT, 0) || !m_pListenSocket->Listen())
	{
		str.Format("Failed to create listen socket on port %d. Server is not online!", nPort);
		ShowStatus(str, 1);
		delete m_pListenSocket;
		m_pListenSocket = NULL;
	}
	else
	{
		str.Format("Server online.");
		ShowStatus(str, 0);
		m_nServerState = 1;
	}

	m_nTimerID = SetTimer(m_hWnd, 1234, 10000, NULL);
	ASSERT(m_nTimerID);

	CreateAdminListenSocket();

	return true;
}
Esempio n. 26
0
void ShowErrorPane(const char *text)
{
	if (Window == NULL || ConWindow == NULL)
	{
		if (text != NULL)
		{
			MessageBox (Window, text,
				GAMESIG " Fatal Error", MB_OK|MB_ICONSTOP|MB_TASKMODAL);
		}
		return;
	}

	if (StartScreen != NULL)	// Ensure that the network pane is hidden.
	{
		StartScreen->NetDone();
	}
	if (text != NULL)
	{
		char caption[100];
		mysnprintf(caption, countof(caption), "Fatal Error - " GAMESIG " %s " X64 " (%s)", GetVersionString(), GetGitTime());
		SetWindowText (Window, caption);
		ErrorIcon = CreateWindowEx (WS_EX_NOPARENTNOTIFY, "STATIC", NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | SS_OWNERDRAW, 0, 0, 0, 0, Window, NULL, g_hInst, NULL);
		if (ErrorIcon != NULL)
		{
			SetWindowLong (ErrorIcon, GWL_ID, IDC_ICONPIC);
		}
	}
	ErrorPane = CreateDialogParam (g_hInst, MAKEINTRESOURCE(IDD_ERRORPANE), Window, ErrorPaneProc, (LONG_PTR)NULL);

	if (text != NULL)
	{
		CHARRANGE end;
		CHARFORMAT2 oldformat, newformat;
		PARAFORMAT2 paraformat;

		// Append the error message to the log.
		end.cpMax = end.cpMin = GetWindowTextLength (ConWindow);
		SendMessage (ConWindow, EM_EXSETSEL, 0, (LPARAM)&end);

		// Remember current charformat.
		oldformat.cbSize = sizeof(oldformat);
		SendMessage (ConWindow, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&oldformat);

		// Use bigger font and standout colors.
		newformat.cbSize = sizeof(newformat);
		newformat.dwMask = CFM_BOLD | CFM_COLOR | CFM_SIZE;
		newformat.dwEffects = CFE_BOLD;
		newformat.yHeight = oldformat.yHeight * 5 / 4;
		newformat.crTextColor = RGB(255,170,170);
		SendMessage (ConWindow, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&newformat);

		// Indent the rest of the text to make the error message stand out a little more.
		paraformat.cbSize = sizeof(paraformat);
		paraformat.dwMask = PFM_STARTINDENT | PFM_OFFSETINDENT | PFM_RIGHTINDENT;
		paraformat.dxStartIndent = paraformat.dxOffset = paraformat.dxRightIndent = 120;
		SendMessage (ConWindow, EM_SETPARAFORMAT, 0, (LPARAM)&paraformat);
		SendMessage (ConWindow, EM_REPLACESEL, FALSE, (LPARAM)"\n");

		// Find out where the error lines start for the error icon display control.
		SendMessage (ConWindow, EM_EXGETSEL, 0, (LPARAM)&end);
		ErrorIconChar = end.cpMax;

		// Now start adding the actual error message.
		SendMessage (ConWindow, EM_REPLACESEL, FALSE, (LPARAM)"Execution could not continue.\n\n");

		// Restore old charformat but with light yellow text.
		oldformat.crTextColor = RGB(255,255,170);
		SendMessage (ConWindow, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&oldformat);

		// Add the error text.
		SendMessage (ConWindow, EM_REPLACESEL, FALSE, (LPARAM)text);

		// Make sure the error text is not scrolled below the window.
		SendMessage (ConWindow, EM_LINESCROLL, 0, SendMessage (ConWindow, EM_GETLINECOUNT, 0, 0));
		// The above line scrolled everything off the screen, so pretend to move the scroll
		// bar thumb, which clamps to not show any extra lines if it doesn't need to.
		SendMessage (ConWindow, EM_SCROLL, SB_PAGEDOWN, 0);
	}

	BOOL bRet;
	MSG msg;

	while ((bRet = GetMessage(&msg, NULL, 0, 0)) != 0)
	{
		if (bRet == -1)
		{
			MessageBox (Window, text,
				GAMESIG " Fatal Error", MB_OK|MB_ICONSTOP|MB_TASKMODAL);
			return;
		}
		else if (!IsDialogMessage (ErrorPane, &msg))
		{
			TranslateMessage (&msg);
			DispatchMessage (&msg);
		}
	}
}
Esempio n. 27
0
static OSStatus
RegisterVisualPlugin( PluginMessageInfo *messageInfo )
{
    OSStatus status;
    PlayerMessageInfo playerMessageInfo;

#if TARGET_OS_WIN32
    ClearMemory( &playerMessageInfo.u.registerVisualPluginMessage, 
                 sizeof( playerMessageInfo.u.registerVisualPluginMessage ) );
#else
    memset( &playerMessageInfo.u.registerVisualPluginMessage, 
            0,
            sizeof( playerMessageInfo.u.registerVisualPluginMessage ) );
#endif

#if TARGET_OS_MAC
    const char* pluginName = kVisualPluginName;
    int const n = strlen( pluginName );
    playerMessageInfo.u.registerVisualPluginMessage.name[0] = n;
    memcpy( &playerMessageInfo.u.registerVisualPluginMessage.name[1], &pluginName[0], n );
#else
    // copy in name length byte first
    playerMessageInfo.u.registerVisualPluginMessage.name[0] = lstrlenA( kVisualPluginName );

    // now copy in actual name
    memcpy( &playerMessageInfo.u.registerVisualPluginMessage.name[1],
            kVisualPluginName,
            lstrlenA(kVisualPluginName));
#endif

    SetNumVersion( &playerMessageInfo.u.registerVisualPluginMessage.pluginVersion,
        kVisualPluginMajorVersion,
        kVisualPluginMinorVersion,
        kVisualPluginReleaseStage,
        kVisualPluginNonFinalRelease );

    LOG( 3, "Giving iTunes version number: " + GetVersionString() );

#if TARGET_OS_WIN32
    //FIXME actually, I doubt we want these
    playerMessageInfo.u.registerVisualPluginMessage.options                 = kVisualWantsIdleMessages;
#endif
    playerMessageInfo.u.registerVisualPluginMessage.handler                 = VisualPluginHandler;
    playerMessageInfo.u.registerVisualPluginMessage.registerRefCon          = 0;
    playerMessageInfo.u.registerVisualPluginMessage.creator                 = kVisualPluginCreator;

    // following sets render to be called every 100ms
    playerMessageInfo.u.registerVisualPluginMessage.timeBetweenDataInMS     = 100; // 16 milliseconds = 1 Tick, 0xFFFFFFFF = Often as possible.
    playerMessageInfo.u.registerVisualPluginMessage.numWaveformChannels     = 2;
    playerMessageInfo.u.registerVisualPluginMessage.numSpectrumChannels     = 2;

    playerMessageInfo.u.registerVisualPluginMessage.minWidth                = 64;
    playerMessageInfo.u.registerVisualPluginMessage.minHeight               = 64;
    playerMessageInfo.u.registerVisualPluginMessage.maxWidth                = 32767;
    playerMessageInfo.u.registerVisualPluginMessage.maxHeight               = 32767;
    playerMessageInfo.u.registerVisualPluginMessage.minFullScreenBitDepth   = 0;
    playerMessageInfo.u.registerVisualPluginMessage.maxFullScreenBitDepth   = 0;
    playerMessageInfo.u.registerVisualPluginMessage.windowAlignmentInBytes  = 0;

    messageInfo->u.initMessage.options = 0;
    messageInfo->u.initMessage.refCon = 0;
    
    status = PlayerRegisterVisualPlugin( messageInfo->u.initMessage.appCookie,
                                         messageInfo->u.initMessage.appProc,
                                         &playerMessageInfo );
    return status;
}
Esempio n. 28
0
void TranslateToGLSL(HLSLCrossCompilerContext* psContext, GLLang* planguage,const GlExtensions *extensions)
{
    bstring glsl;
    uint32_t i;
    Shader* psShader = psContext->psShader;
    GLLang language = *planguage;
	uint32_t ui32InstCount = 0;
	uint32_t ui32DeclCount = 0;

    psContext->indent = 0;

	/*psShader->sPhase[MAIN_PHASE].ui32InstanceCount = 1;
	psShader->sPhase[MAIN_PHASE].ppsDecl = hlslcc_malloc(sizeof(Declaration*));
	psShader->sPhase[MAIN_PHASE].ppsInst = hlslcc_malloc(sizeof(Instruction*));
	psShader->sPhase[MAIN_PHASE].pui32DeclCount = hlslcc_malloc(sizeof(uint32_t));
	psShader->sPhase[MAIN_PHASE].pui32InstCount = hlslcc_malloc(sizeof(uint32_t));*/

    if(language == LANG_DEFAULT)
    {
        language = ChooseLanguage(psShader);
        *planguage = language;
    }

		glsl = bfromcstralloc (1024, GetVersionString(language));

    psContext->glsl = glsl;
	psContext->earlyMain = bfromcstralloc (1024, "");
    for(i=0; i<NUM_PHASES;++i)
    {
        psContext->postShaderCode[i] = bfromcstralloc (1024, "");
    }
    psContext->currentGLSLString = &glsl;
    psShader->eTargetLanguage = language;
	psShader->extensions = (const struct GlExtensions*)extensions;
    psContext->currentPhase = MAIN_PHASE;

	if(extensions)
	{
		if(extensions->ARB_explicit_attrib_location)
			bcatcstr(glsl,"#extension GL_ARB_explicit_attrib_location : require\n");
		if(extensions->ARB_explicit_uniform_location)
			bcatcstr(glsl,"#extension GL_ARB_explicit_uniform_location : require\n");
		if(extensions->ARB_shading_language_420pack)
			bcatcstr(glsl,"#extension GL_ARB_shading_language_420pack : require\n");
	}

    ClearDependencyData(psShader->eShaderType, psContext->psDependencies);

    AddVersionDependentCode(psContext);

    if(psContext->flags & HLSLCC_FLAG_UNIFORM_BUFFER_OBJECT)
    {
        bcatcstr(glsl, "layout(std140) uniform;\n");
    }

    //Special case. Can have multiple phases.
    if(psShader->eShaderType == HULL_SHADER)
    {
        int haveInstancedForkPhase = 0;			// Do we have an instanced fork phase?
        int isCurrentForkPhasedInstanced = 0;	// Is the current fork phase instanced?
		const char* asPhaseFuncNames[NUM_PHASES];
		uint32_t ui32PhaseFuncCallOrder[3];
		uint32_t ui32PhaseCallIndex;

		uint32_t ui32Phase;
		uint32_t ui32Instance;

		asPhaseFuncNames[MAIN_PHASE] = "";
		asPhaseFuncNames[HS_GLOBAL_DECL] = "";
		asPhaseFuncNames[HS_FORK_PHASE] = "fork_phase";
		asPhaseFuncNames[HS_CTRL_POINT_PHASE] = "control_point_phase";
		asPhaseFuncNames[HS_JOIN_PHASE] = "join_phase";

        ConsolidateHullTempVars(psShader);

		for(i=0; i < psShader->asPhase[HS_GLOBAL_DECL].pui32DeclCount[0]; ++i)
        {
			TranslateDeclaration(psContext, psShader->asPhase[HS_GLOBAL_DECL].ppsDecl[0]+i);
        }

		for(ui32Phase=HS_CTRL_POINT_PHASE; ui32Phase<NUM_PHASES; ui32Phase++)
		{
			psContext->currentPhase = ui32Phase;
			for(ui32Instance = 0; ui32Instance < psShader->asPhase[ui32Phase].ui32InstanceCount; ++ui32Instance)
			{
				isCurrentForkPhasedInstanced = 0; //reset for each fork phase for cases we don't have a fork phase instance count opcode.
				bformata(glsl, "//%s declarations\n", asPhaseFuncNames[ui32Phase]);
				for(i=0; i < psShader->asPhase[ui32Phase].pui32DeclCount[ui32Instance]; ++i)
				{
					TranslateDeclaration(psContext, psShader->asPhase[ui32Phase].ppsDecl[ui32Instance]+i);
					if(psShader->asPhase[ui32Phase].ppsDecl[ui32Instance][i].eOpcode == OPCODE_DCL_HS_FORK_PHASE_INSTANCE_COUNT)
					{
						haveInstancedForkPhase = 1;
						isCurrentForkPhasedInstanced = 1;
					}
				}

				bformata(glsl, "void %s%d()\n{\n", asPhaseFuncNames[ui32Phase], ui32Instance);
				psContext->indent++;

				SetDataTypes(psContext, psShader->asPhase[ui32Phase].ppsInst[ui32Instance], psShader->asPhase[ui32Phase].pui32InstCount[ui32Instance]-1);

					if(isCurrentForkPhasedInstanced)
					{
						AddIndentation(psContext);
						bformata(glsl, "for(int forkInstanceID = 0; forkInstanceID < HullPhase%dInstanceCount; ++forkInstanceID) {\n", ui32Instance);
						psContext->indent++;
					}

						//The minus one here is remove the return statement at end of phases.
						//This is needed otherwise the for loop will only run once.
						ASSERT(psShader->asPhase[ui32Phase].ppsInst[ui32Instance]  [psShader->asPhase[ui32Phase].pui32InstCount[ui32Instance]-1].eOpcode == OPCODE_RET);
						for(i=0; i < psShader->asPhase[ui32Phase].pui32InstCount[ui32Instance]-1; ++i)
						{
							TranslateInstruction(psContext, psShader->asPhase[ui32Phase].ppsInst[ui32Instance]+i, NULL);
						}

					if(haveInstancedForkPhase)
					{
						psContext->indent--;
						AddIndentation(psContext);

						if(isCurrentForkPhasedInstanced)
						{
							bcatcstr(glsl, "}\n");
						}

						if(psContext->havePostShaderCode[psContext->currentPhase])
						{
	#ifdef _DEBUG
							AddIndentation(psContext);
							bcatcstr(glsl, "//--- Post shader code ---\n");
	#endif
							bconcat(glsl, psContext->postShaderCode[psContext->currentPhase]);
	#ifdef _DEBUG
							AddIndentation(psContext);
							bcatcstr(glsl, "//--- End post shader code ---\n");
	#endif
						}
				}

				psContext->indent--;
				bcatcstr(glsl, "}\n");
			}
		}

        bcatcstr(glsl, "void main()\n{\n");

            psContext->indent++;

#ifdef _DEBUG
            AddIndentation(psContext);
            bcatcstr(glsl, "//--- Start Early Main ---\n");
#endif
            bconcat(glsl, psContext->earlyMain);
#ifdef _DEBUG
            AddIndentation(psContext);
            bcatcstr(glsl, "//--- End Early Main ---\n");
#endif

			ui32PhaseFuncCallOrder[0] = HS_CTRL_POINT_PHASE;
			ui32PhaseFuncCallOrder[1] = HS_FORK_PHASE;
			ui32PhaseFuncCallOrder[2] = HS_JOIN_PHASE;

			for(ui32PhaseCallIndex=0; ui32PhaseCallIndex<3; ui32PhaseCallIndex++)
			{
				ui32Phase = ui32PhaseFuncCallOrder[ui32PhaseCallIndex];
				for(ui32Instance = 0; ui32Instance < psShader->asPhase[ui32Phase].ui32InstanceCount; ++ui32Instance)
				{
					AddIndentation(psContext);
					bformata(glsl, "%s%d();\n", asPhaseFuncNames[ui32Phase], ui32Instance);

					if(ui32Phase == HS_FORK_PHASE)
					{
						if(psShader->asPhase[HS_JOIN_PHASE].ui32InstanceCount ||
							(ui32Instance+1 < psShader->asPhase[HS_FORK_PHASE].ui32InstanceCount))
						{
							AddIndentation(psContext);
							bcatcstr(glsl, "barrier();\n");
						}
					}
				}
			}

            psContext->indent--;

        bcatcstr(glsl, "}\n");

        if(psContext->psDependencies)
        {
            //Save partitioning and primitive type for use by domain shader.
            psContext->psDependencies->eTessOutPrim = psShader->sInfo.eTessOutPrim;

            psContext->psDependencies->eTessPartitioning = psShader->sInfo.eTessPartitioning;
        }

        return;
    }

    if(psShader->eShaderType == DOMAIN_SHADER && psContext->psDependencies)
    {
        //Load partitioning and primitive type from hull shader.
        switch(psContext->psDependencies->eTessOutPrim)
        {
            case TESSELLATOR_OUTPUT_TRIANGLE_CW:
            {
                bcatcstr(glsl, "layout(cw) in;\n");
                break;
            }
            case TESSELLATOR_OUTPUT_POINT:
            {
                bcatcstr(glsl, "layout(point_mode) in;\n");
                break;
            }
            default:
            {
                break;
            }
        }

        switch(psContext->psDependencies->eTessPartitioning)
        {
            case TESSELLATOR_PARTITIONING_FRACTIONAL_ODD:
            {
                bcatcstr(glsl, "layout(fractional_odd_spacing) in;\n");
                break;
            }
            case TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN:
            {
                bcatcstr(glsl, "layout(fractional_even_spacing) in;\n");
                break;
            }
            default:
            {
                break;
            }
        }
    }

	ui32InstCount = psShader->asPhase[MAIN_PHASE].pui32InstCount[0];
	ui32DeclCount = psShader->asPhase[MAIN_PHASE].pui32DeclCount[0];

    for(i=0; i < ui32DeclCount; ++i)
    {
		TranslateDeclaration(psContext, psShader->asPhase[MAIN_PHASE].ppsDecl[0]+i);
    }

	if(psContext->psShader->ui32NumDx9ImmConst)
	{
		bformata(psContext->glsl, "vec4 ImmConstArray [%d];\n", psContext->psShader->ui32NumDx9ImmConst);
	}

    bcatcstr(glsl, "void main()\n{\n");

    psContext->indent++;

#ifdef _DEBUG
    AddIndentation(psContext);
    bcatcstr(glsl, "//--- Start Early Main ---\n");
#endif
	bconcat(glsl, psContext->earlyMain);
#ifdef _DEBUG
    AddIndentation(psContext);
    bcatcstr(glsl, "//--- End Early Main ---\n");
#endif

    MarkIntegerImmediates(psContext);

	SetDataTypes(psContext, psShader->asPhase[MAIN_PHASE].ppsInst[0], ui32InstCount);

    for(i=0; i < ui32InstCount; ++i)
    {
		TranslateInstruction(psContext, psShader->asPhase[MAIN_PHASE].ppsInst[0]+i, i+1 < ui32InstCount ? psShader->asPhase[MAIN_PHASE].ppsInst[0]+i+1 : 0);
    }

    psContext->indent--;

    bcatcstr(glsl, "}\n");
}
Esempio n. 29
0
void DoMain (HINSTANCE hInstance)
{
	LONG WinWidth, WinHeight;
	int height, width, x, y;
	RECT cRect;
	TIMECAPS tc;
	DEVMODE displaysettings;

	try
	{
#ifdef _MSC_VER
		_set_new_handler (NewFailure);
#endif

		Args = new DArgs(__argc, __argv);

		// Load Win32 modules
		Kernel32Module.Load({"kernel32.dll"});
		Shell32Module.Load({"shell32.dll"});
		User32Module.Load({"user32.dll"});

		// Under XP, get our session ID so we can know when the user changes/locks sessions.
		// Since we need to remain binary compatible with older versions of Windows, we
		// need to extract the ProcessIdToSessionId function from kernel32.dll manually.
		HMODULE kernel = GetModuleHandle ("kernel32.dll");

		if (Args->CheckParm("-stdout"))
		{
			// As a GUI application, we don't normally get a console when we start.
			// If we were run from the shell and are on XP+, we can attach to its
			// console. Otherwise, we can create a new one. If we already have a
			// stdout handle, then we have been redirected and should just use that
			// handle instead of creating a console window.

			StdOut = GetStdHandle(STD_OUTPUT_HANDLE);
			if (StdOut != NULL)
			{
				// It seems that running from a shell always creates a std output
				// for us, even if it doesn't go anywhere. (Running from Explorer
				// does not.) If we can get file information for this handle, it's
				// a file or pipe, so use it. Otherwise, pretend it wasn't there
				// and find a console to use instead.
				BY_HANDLE_FILE_INFORMATION info;
				if (!GetFileInformationByHandle(StdOut, &info))
				{
					StdOut = NULL;
				}
			}
			if (StdOut == NULL)
			{
				// AttachConsole was introduced with Windows XP. (OTOH, since we
				// have to share the console with the shell, I'm not sure if it's
				// a good idea to actually attach to it.)
				typedef BOOL (WINAPI *ac)(DWORD);
				ac attach_console = kernel != NULL ? (ac)GetProcAddress(kernel, "AttachConsole") : NULL;
				if (attach_console != NULL && attach_console(ATTACH_PARENT_PROCESS))
				{
					StdOut = GetStdHandle(STD_OUTPUT_HANDLE);
					DWORD foo; WriteFile(StdOut, "\n", 1, &foo, NULL);
					AttachedStdOut = true;
				}
				if (StdOut == NULL && AllocConsole())
				{
					StdOut = GetStdHandle(STD_OUTPUT_HANDLE);
				}
				FancyStdOut = true;
			}
		}

		// Set the timer to be as accurate as possible
		if (timeGetDevCaps (&tc, sizeof(tc)) != TIMERR_NOERROR)
			TimerPeriod = 1;	// Assume minimum resolution of 1 ms
		else
			TimerPeriod = tc.wPeriodMin;

		timeBeginPeriod (TimerPeriod);

		/*
		killough 1/98:

		This fixes some problems with exit handling
		during abnormal situations.

		The old code called I_Quit() to end program,
		while now I_Quit() is installed as an exit
		handler and exit() is called to exit, either
		normally or abnormally.
		*/

		atexit (call_terms);

		atterm (I_Quit);

		// Figure out what directory the program resides in.
		char *program;

#ifdef _MSC_VER
		if (_get_pgmptr(&program) != 0)
		{
			I_FatalError("Could not determine program location.");
		}
#else
		char progbuff[1024];
		GetModuleFileName(0, progbuff, sizeof(progbuff));
		progbuff[1023] = '\0';
		program = progbuff;
#endif

		progdir = program;
		program = progdir.LockBuffer();
		*(strrchr(program, '\\') + 1) = '\0';
		FixPathSeperator(program);
		progdir.Truncate((long)strlen(program));
		progdir.UnlockBuffer();

		HDC screenDC = GetDC(0);
		int dpi = GetDeviceCaps(screenDC, LOGPIXELSX);
		ReleaseDC(0, screenDC);
		width = (512 * dpi + 96 / 2) / 96;
		height = (384 * dpi + 96 / 2) / 96;

		// Many Windows structures that specify their size do so with the first
		// element. DEVMODE is not one of those structures.
		memset (&displaysettings, 0, sizeof(displaysettings));
		displaysettings.dmSize = sizeof(displaysettings);
		EnumDisplaySettings (NULL, ENUM_CURRENT_SETTINGS, &displaysettings);
		x = (displaysettings.dmPelsWidth - width) / 2;
		y = (displaysettings.dmPelsHeight - height) / 2;

		if (Args->CheckParm ("-0"))
		{
			x = y = 0;
		}

		WNDCLASS WndClass;
		WndClass.style			= 0;
		WndClass.lpfnWndProc	= LConProc;
		WndClass.cbClsExtra		= 0;
		WndClass.cbWndExtra		= 0;
		WndClass.hInstance		= hInstance;
		WndClass.hIcon			= LoadIcon (hInstance, MAKEINTRESOURCE(IDI_ICON1));
		WndClass.hCursor		= LoadCursor (NULL, IDC_ARROW);
		WndClass.hbrBackground	= NULL;
		WndClass.lpszMenuName	= NULL;
		WndClass.lpszClassName	= (LPCTSTR)WinClassName;
		
		/* register this new class with Windows */
		if (!RegisterClass((LPWNDCLASS)&WndClass))
			I_FatalError ("Could not register window class");
		
		/* create window */
		char caption[100];
		mysnprintf(caption, countof(caption), "" GAMESIG " %s " X64 " (%s)", GetVersionString(), GetGitTime());
		Window = CreateWindowEx(
				WS_EX_APPWINDOW,
				(LPCTSTR)WinClassName,
				(LPCTSTR)caption,
				WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPCHILDREN,
				x, y, width, height,
				(HWND)   NULL,
				(HMENU)  NULL,
						hInstance,
				NULL);

		if (!Window)
			I_FatalError ("Could not open window");

		if (kernel != NULL)
		{
			typedef BOOL (WINAPI *pts)(DWORD, DWORD *);
			pts pidsid = (pts)GetProcAddress (kernel, "ProcessIdToSessionId");
			if (pidsid != 0)
			{
				if (!pidsid (GetCurrentProcessId(), &SessionID))
				{
					SessionID = 0;
				}
				hwtsapi32 = LoadLibraryA ("wtsapi32.dll");
				if (hwtsapi32 != 0)
				{
					FARPROC reg = GetProcAddress (hwtsapi32, "WTSRegisterSessionNotification");
					if (reg == 0 || !((BOOL(WINAPI *)(HWND, DWORD))reg) (Window, NOTIFY_FOR_THIS_SESSION))
					{
						FreeLibrary (hwtsapi32);
						hwtsapi32 = 0;
					}
					else
					{
						atterm (UnWTS);
					}
				}
			}
		}

		GetClientRect (Window, &cRect);

		WinWidth = cRect.right;
		WinHeight = cRect.bottom;

		CoInitialize (NULL);
		atterm (UnCOM);

		C_InitConsole (((WinWidth / 8) + 2) * 8, (WinHeight / 12) * 8, false);

		I_DetectOS ();
		D_DoomMain ();
	}
	catch (class CNoRunExit &)
	{
		I_ShutdownGraphics();
		if (!batchrun)
		{
			if (FancyStdOut && !AttachedStdOut)
			{ // Outputting to a new console window: Wait for a keypress before quitting.
				DWORD bytes;
				HANDLE stdinput = GetStdHandle(STD_INPUT_HANDLE);

				ShowWindow(Window, SW_HIDE);
				WriteFile(StdOut, "Press any key to exit...", 24, &bytes, NULL);
				FlushConsoleInputBuffer(stdinput);
				SetConsoleMode(stdinput, 0);
				ReadConsole(stdinput, &bytes, 1, &bytes, NULL);
			}
			else if (StdOut == NULL)
			{
				ShowErrorPane(NULL);
			}
		}
		exit(0);
	}
	catch (class CDoomError &error)
	{
		I_ShutdownGraphics ();
		RestoreConView ();
		I_FlushBufferedConsoleStuff();
		if (error.GetMessage ())
		{
			if (!batchrun)
			{
				ShowErrorPane(error.GetMessage());
			}
			else
			{
				Printf("%s\n", error.GetMessage());
			}
		}
		exit (-1);
	}
}
Esempio n. 30
0
int main (int argc, char **argv)
{
#if !defined (__APPLE__)
	{
		int s[4] = { SIGSEGV, SIGILL, SIGFPE, SIGBUS };
		cc_install_handlers(argc, argv, 4, s, "zdoom-crash.log", DoomSpecificInfo);
	}
#endif // !__APPLE__

	printf(GAMENAME" %s - %s - SDL version\nCompiled on %s\n",
		GetVersionString(), GetGitTime(), __DATE__);

	seteuid (getuid ());
    std::set_new_handler (NewFailure);

#if defined(__MACH__) && !defined(NOASM)
	unprotect_rtext();
#endif

	// Set LC_NUMERIC environment variable in case some library decides to
	// clear the setlocale call at least this will be correct.
	// Note that the LANG environment variable is overridden by LC_*
	setenv ("LC_NUMERIC", "C", 1);

#ifndef NO_GTK
	GtkAvailable = gtk_init_check (&argc, &argv);
#endif
	
	setlocale (LC_ALL, "C");

	if (SDL_Init (SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_NOPARACHUTE|SDL_INIT_JOYSTICK) == -1)
	{
		fprintf (stderr, "Could not initialize SDL:\n%s\n", SDL_GetError());
		return -1;
	}
	atterm (SDL_Quit);

	{
		char viddriver[80];

		if (SDL_VideoDriverName(viddriver, sizeof(viddriver)) != NULL)
		{
			printf("Using video driver %s\n", viddriver);
#ifdef USE_XCURSOR
			UseXCursor = (strcmp(viddriver, "x11") == 0);
#endif
		}
		printf("\n");
	}

	char caption[100];
	mysnprintf(caption, countof(caption), GAMESIG " %s (%s)", GetVersionString(), GetGitTime());
	SDL_WM_SetCaption(caption, caption);

#ifdef __APPLE__
	
	const SDL_VideoInfo* videoInfo = SDL_GetVideoInfo();
	if ( NULL != videoInfo )
	{
		EXTERN_CVAR(  Int, vid_defwidth  )
		EXTERN_CVAR(  Int, vid_defheight )
		EXTERN_CVAR(  Int, vid_defbits   )
		EXTERN_CVAR( Bool, vid_vsync     )
		EXTERN_CVAR( Bool, fullscreen    )
		
		vid_defwidth  = videoInfo->current_w;
		vid_defheight = videoInfo->current_h;
		vid_defbits   = videoInfo->vfmt->BitsPerPixel;
		vid_vsync     = true;
		fullscreen    = true;
	}
	
#endif // __APPLE__
	
    try
    {
		Args = new DArgs(argc, argv);

		/*
		  killough 1/98:

		  This fixes some problems with exit handling
		  during abnormal situations.

		  The old code called I_Quit() to end program,
		  while now I_Quit() is installed as an exit
		  handler and exit() is called to exit, either
		  normally or abnormally. Seg faults are caught
		  and the error handler is used, to prevent
		  being left in graphics mode or having very
		  loud SFX noise because the sound card is
		  left in an unstable state.
		*/

		atexit (call_terms);
		atterm (I_Quit);

		// Should we even be doing anything with progdir on Unix systems?
		char program[PATH_MAX];
		if (realpath (argv[0], program) == NULL)
			strcpy (program, argv[0]);
		char *slash = strrchr (program, '/');
		if (slash != NULL)
		{
			*(slash + 1) = '\0';
			progdir = program;
		}
		else
		{
			progdir = "./";
		}

		I_StartupJoysticks();
		C_InitConsole (80*8, 25*8, false);
		D_DoomMain ();
    }
    catch (class CDoomError &error)
    {
		I_ShutdownJoysticks();
		if (error.GetMessage ())
			fprintf (stderr, "%s\n", error.GetMessage ());
		exit (-1);
    }
    catch (...)
    {
		call_terms ();
		throw;
    }
    return 0;
}