NS_LogRelease(void* aPtr, nsrefcnt aRefcnt, const char* aClazz)
{
#ifdef NS_IMPL_REFCNT_LOGGING
  ASSERT_ACTIVITY_IS_LEGAL;
  if (!gInitialized)
    InitTraceLog();
  if (gLogging) {
    LOCK_TRACELOG();

    if (gBloatLog) {
      BloatEntry* entry = GetBloatEntry(aClazz, 0);
      if (entry) {
        entry->Release(aRefcnt);
      }
    }

    bool loggingThisType = (!gTypesToLog || LogThisType(aClazz));
    intptr_t serialno = 0;
    if (gSerialNumbers && loggingThisType) {
      serialno = GetSerialNumber(aPtr, false);
      NS_ASSERTION(serialno != 0,
                   "Serial number requested for unrecognized pointer!  "
                   "Are you memmoving a refcounted object?");
      int32_t* count = GetRefCount(aPtr);
      if(count)
        (*count)--;

    }

    bool loggingThisObject = (!gObjectsToLog || LogThisObj(serialno));
    if (gRefcntsLog && loggingThisType && loggingThisObject) {
      if (gLogToLeaky) {
        (*leakyLogRelease)(aPtr, aRefcnt + 1, aRefcnt);
      }
      else {
          // Can't use PR_LOG(), b/c it truncates the line
          fprintf(gRefcntsLog,
                  "\n<%s> 0x%08X %ld Release %d\n", aClazz, NS_PTR_TO_INT32(aPtr), serialno, aRefcnt);
          nsTraceRefcntImpl::WalkTheStack(gRefcntsLog);
          fflush(gRefcntsLog);
      }
    }

    // Here's the case where MOZ_COUNT_DTOR was not used,
    // yet we still want to see deletion information:

    if (aRefcnt == 0 && gAllocLog && loggingThisType && loggingThisObject) {
      fprintf(gAllocLog,
              "\n<%s> 0x%08X %ld Destroy\n",
              aClazz, NS_PTR_TO_INT32(aPtr), serialno);
      nsTraceRefcntImpl::WalkTheStack(gAllocLog);
    }

    if (aRefcnt == 0 && gSerialNumbers && loggingThisType) {
      RecycleSerialNumberPtr(aPtr);
    }

    UNLOCK_TRACELOG();
  }
#endif
}
 /// \brief
 ///   Notification function which will be called when the child is disconnected from the parent
 ///   Any class derived from VRefCounter (e.g. resources) should override this function and
 ///   decrement the refcounter instead of deleting it
 VISION_APIFUNC virtual void ModSysNotifyFunctionOnDisconnect(BOOL bDestroy)
 { 
   if (bDestroy && GetRefCount()==0)
     delete this;
 }
Example #3
0
UINT __stdcall
ingres_set_rep_reg_entries (MSIHANDLE ihnd)
{
    HKEY		hKey;
    char		KeyName[256];
    int			status = 0;
    DWORD		dwSize, dwDisposition, dwType;
    TCHAR		tchValue[2048];
    INSTALLSTATE	iInstalled, iAction;
    BOOL    	bInstalled, bVer25, bVersion9X;
    char szID[3], szComponentGUID[39], szProductGUID[39];
	
    bInstalled=bVer25=bVersion9X=FALSE;

    if (!MsiGetFeatureState(ihnd, "IngresReplicator", &iInstalled, &iAction))
    {
	if (iInstalled==INSTALLSTATE_ABSENT && iAction==INSTALLSTATE_UNKNOWN) 
	    return ERROR_SUCCESS;
    }
    else 
	return ERROR_SUCCESS;

    dwSize = sizeof(tchValue);
    if (MsiGetProperty( ihnd, "II_INSTALLATION", tchValue,
			&dwSize ) != ERROR_SUCCESS)
    {
	return (ERROR_INSTALL_FAILURE);
    }
    else
    {
	sprintf(KeyName,
		"Software\\IngresCorporation\\Ingres\\%s_Installation",
		tchValue);
	status = RegCreateKeyEx(HKEY_LOCAL_MACHINE, KeyName, 0, NULL,
				REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
				&hKey, &dwDisposition);
    }

    if (iInstalled == INSTALLSTATE_LOCAL)
    {
	/*
	** Set up the InstalledFeatures registry key for possible use.
	*/
	dwType = REG_SZ;
	dwSize = sizeof(tchValue);
	if (RegQueryValueEx(hKey, "InstalledFeatures", NULL, &dwType,
			    tchValue, &dwSize) != ERROR_SUCCESS)
	{
	    strcpy(tchValue, "REP");
	}
	else if (!strstr(tchValue, "REP"))
	    strcat(tchValue, ",REP");

	status = RegSetValueEx( hKey, "InstalledFeatures", 0, REG_SZ,
				tchValue, strlen(tchValue) + 1 );
    }

    dwSize=sizeof(szID);
    MsiGetProperty(ihnd, "II_INSTALLATION", szID, &dwSize);
    if (!_stricmp(szID, "II"))
	strcpy(szComponentGUID, "{531C8AD8-2F05-11D5-BDFC-00B0D0AD4485}");
    else
    {
	int idx;

	idx = (toupper(szID[0]) - 'A') * 26 + toupper(szID[1]) - 'A';
	if (idx <= 0) 
	    idx = (toupper(szID[0]) - 'A') * 26 + toupper(szID[1]) - '0';
	sprintf(szComponentGUID, "{531C8AD8-2F05-11D5-%04X-%012X}", idx, idx*idx);
    }

    dwSize=sizeof(szProductGUID);
    MsiGetProperty(ihnd, "ProductCode", szProductGUID, &dwSize);

    if (iAction==INSTALLSTATE_ABSENT && GetRefCount(szComponentGUID, szProductGUID)==0)
    {
	/*
	** Set up the RemovedFeatures registry key for use later on.
	*/
	dwType = REG_SZ;
	dwSize = sizeof(tchValue);
	if (RegQueryValueEx(hKey, "RemovedFeatures", NULL, &dwType,
			    tchValue, &dwSize) != ERROR_SUCCESS)
	{
	    strcpy(tchValue, "REP");
	}
	else if (!strstr(tchValue, "REP"))
	    strcat(tchValue, ",REP");

	status = RegSetValueEx( hKey, "RemovedFeatures", 0, REG_SZ,
				tchValue, strlen(tchValue) + 1 );

	RegCloseKey(hKey);
	return (status==ERROR_SUCCESS ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE);
    }
    else if (iInstalled == INSTALLSTATE_LOCAL || iAction != INSTALLSTATE_LOCAL)
    {
	dwSize = sizeof(tchValue);
	if (!MsiGetProperty(ihnd, "INGRES_UPGRADE", tchValue, &dwSize) && strcmp(tchValue, "2"))
	{
	    RegCloseKey(hKey);
	    return (ERROR_SUCCESS);
	}
    }

    strcpy(tchValue, "TRUE");
    status = RegSetValueEx( hKey, "Ingres/Replicator", 0, REG_SZ, 
			    (CONST BYTE *)&tchValue, strlen(tchValue) + 1 );

    dwType = REG_SZ;
    dwSize = sizeof(tchValue);
    if (RegQueryValueEx(hKey, "PostInstallationNeeded", NULL, &dwType,
			tchValue, &dwSize) != ERROR_SUCCESS)
    {
	dwSize = sizeof(tchValue);
	if (status ||
	    MsiGetProperty( ihnd, "INGRES_SERVICEAUTO", tchValue,
			    &dwSize ) != ERROR_SUCCESS)
	{
	    return (ERROR_INSTALL_FAILURE);
	}
	else
	{
	    char szBuf[MAX_PATH+1];
	    sprintf(szBuf, "Ingres_Database_%s", szID);
	    if (CheckServiceExists(szBuf))
	    {
	         if (IsServiceStartupTypeAuto(szBuf))
		    sprintf(tchValue, "1");
		 else
		    sprintf(tchValue, "0");
  	         
		 status = RegSetValueEx( hKey, "serviceauto", 0, REG_SZ, 
				    tchValue, strlen(tchValue) + 1 );
		
	    }
	    else
	    	 status = RegSetValueEx( hKey, "serviceauto", 0, REG_SZ, 
				    tchValue, strlen(tchValue) + 1 );
	}

	dwSize = sizeof(tchValue);
	if (status ||
	    MsiGetProperty( ihnd, "INGRES_SERVICELOGINID", tchValue,
			    &dwSize ) != ERROR_SUCCESS)
	{
	    return (ERROR_INSTALL_FAILURE);
	}
	else
	{
	    status = RegSetValueEx( hKey, "serviceloginid", 0, REG_SZ, 
				    tchValue, strlen(tchValue) + 1 );
	}

	dwSize = sizeof(tchValue);
	if (status ||
	    MsiGetProperty( ihnd, "INGRES_SERVICEPASSWORD", tchValue,
			    &dwSize ) != ERROR_SUCCESS)
	{
	    return (ERROR_INSTALL_FAILURE);
	}
	else
	{
	    /* Clear the password from the property table. */
	    MsiSetProperty(ihnd, "INGRES_SERVICEPASSWORD", "");
	    MsiSetProperty(ihnd, "INGRES_SERVICEPASSWORD2", "");

	    status = RegSetValueEx( hKey, "servicepassword", 0, REG_SZ, 
				    tchValue, strlen(tchValue) + 1 );
	}

	strcpy(tchValue, "YES");
	status = RegSetValueEx( hKey, "PostInstallationNeeded", 0, REG_SZ, 
				tchValue, strlen(tchValue) + 1 );
	MsiSetProperty(ihnd, "INGRES_POSTINSTALLATIONNEEDED", "1");

	dwSize = sizeof(tchValue);
	MsiGetProperty(ihnd, "INGRES_RSP_LOC", tchValue, &dwSize);
	if (tchValue[0] && strcmp(tchValue, "0"))
	{
	    strcpy(tchValue, "YES");
	    RegSetValueEx( hKey, "SilentInstall", 0, REG_SZ, (CONST BYTE *)&tchValue, strlen(tchValue) + 1 );
	}

	dwSize = sizeof(tchValue);
	MsiGetProperty(ihnd, "Installed", tchValue, &dwSize);
	if (tchValue[0])
	    bInstalled=TRUE;
	dwSize = sizeof(tchValue);
	MsiGetProperty(ihnd, "INGRES_VER25", tchValue, &dwSize);
	if (tchValue[0] && !strcmp(tchValue, "1"))
	    bVer25=0;
	dwSize=sizeof(tchValue);
	MsiGetProperty(ihnd, "Version9X", tchValue, &dwSize);
	if (tchValue[0])
	    bVersion9X=TRUE;
	if (!bInstalled && !bVer25 && bVersion9X)
	{
	    strcpy(tchValue, "YES");
	    RegSetValueEx( hKey, "RebootNeeded", 0, REG_SZ, (CONST BYTE *)&tchValue, strlen(tchValue) + 1 );
	}
    }

    return (status == ERROR_SUCCESS ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE);
}
void VHTTPServerProject::SaveToBag (XBOX::VValueBag& outBag)
{
	outBag.SetLong (NSHTTPServerProject::refCount, GetRefCount());
	outBag.SetLong (NSHTTPServerProject::taskID, fServerTaskID);
	outBag.SetTime (NSHTTPServerProject::startingTime, fStartingTime);
	outBag.SetBool (NSHTTPServerProject::acceptRequests, fAcceptIncommingRequests);
	outBag.SetLong (NSHTTPServerProject::hitCount, GetHitsCount());
	outBag.SetLong (NSHTTPServerProject::runningRequests, GetRunningRequestsCount());
	outBag.SetBool (NSHTTPServerProject::securityComponentAvailable, (NULL != fSecurityManager));
	outBag.SetBool (NSHTTPServerProject::authenticationManagerAvailable, (NULL != fAuthenticationManager));

	XBOX::VBagArray *bagArray = new XBOX::VBagArray();
	if (NULL != bagArray)
	{
		XBOX::VTaskLock lock (&fRequestHandlersLock);
		for (VectorOfRequestHandler::const_iterator it = fRequestHandlers.begin(); it != fRequestHandlers.end(); ++it)
		{
			XBOX::VString string;
			XBOX::VectorOfVString patterns;
			(*it)->GetPatterns (&patterns);

			for (XBOX::VectorOfVString::const_iterator itString = patterns.begin(); itString != patterns.end(); ++itString)
			{
				string.AppendString (*itString);
				string.AppendUniChar (CHAR_SEMICOLON);
			}

			XBOX::VValueBag *handlerBag = new XBOX::VValueBag();
			if (NULL != handlerBag)
			{
				handlerBag->SetLong (NSHTTPServerProject::requestHandlers::refCount, (*it)->GetRefCount());
				handlerBag->SetString (NSHTTPServerProject::requestHandlers::patterns, string);
				handlerBag->SetBool (NSHTTPServerProject::requestHandlers::enabled, (*it)->GetEnable());
				bagArray->AddTail (handlerBag);
				XBOX::QuickReleaseRefCountable (handlerBag);
			}
		}

		outBag.SetElements (L"requestHandlers", bagArray);
		XBOX::QuickReleaseRefCountable (bagArray);
	}

	XBOX::VValueBag *settingsBag = new XBOX::VValueBag();
	if (NULL != settingsBag)
	{
		fSettings->SaveToBag (settingsBag);
		outBag.AddElement (L"settings", settingsBag);
		XBOX::QuickReleaseRefCountable (settingsBag);
	}

	XBOX::VValueBag *serverBag = new XBOX::VValueBag();
	if (NULL != serverBag)
	{
		serverBag->SetLong (NSHTTPServerProject::serverInfos::refCount, fHTTPServer->GetRefCount());
		serverBag->SetBool (NSHTTPServerProject::serverInfos::zipComponentAvailable, fHTTPServer->GetZipComponentAvailable());

		outBag.AddElement (L"server", serverBag);
		XBOX::QuickReleaseRefCountable (serverBag);
	}

	bagArray = new XBOX::VBagArray();
	if (NULL != bagArray)
	{
		XBOX::VTaskLock lock (&fVirtualHostsLock);
		for (std::vector<VVirtualHost *>::const_iterator it = fVirtualHosts.begin(); it != fVirtualHosts.end(); ++it)
		{
			XBOX::VValueBag *virtualHostBag = new XBOX::VValueBag();
			if (NULL != virtualHostBag)
			{
				(*it)->SaveToBag (*virtualHostBag);
				bagArray->AddTail (virtualHostBag);
				XBOX::QuickReleaseRefCountable (virtualHostBag);
			}
		}

		outBag.SetElements (L"virtualHosts", bagArray);
		XBOX::QuickReleaseRefCountable (bagArray);
	}

	bagArray = new XBOX::VBagArray();
	if (NULL != bagArray)
	{
		if ((NULL != fAuthenticationManager) && (NULL != fAuthenticationManager->GetAuthenticationReferee()))
		{
			XBOX::VValueBag *authResourcesBag = new XBOX::VValueBag();
			if (NULL != authResourcesBag)
			{
				fAuthenticationManager->GetAuthenticationReferee()->SaveToBag (authResourcesBag);
				bagArray->AddTail (authResourcesBag);
				XBOX::QuickReleaseRefCountable (authResourcesBag);
			}
		}

		if (bagArray->GetCount() > 0)
			outBag.SetElements (L"authResources", bagArray);

		XBOX::QuickReleaseRefCountable (bagArray);
	}
}
XBOX::VError VHTTPServerProjectSettings::SaveToBag (XBOX::VValueBag *outBag)
{
	if (NULL == outBag)
		return XBOX::VE_INVALID_PARAMETER;

	XBOX::VValueBag *projectSettings = new XBOX::VValueBag ();
	if (projectSettings)
	{
		XBOX::VString	ipString;
		XBOX::VString	authTypeString;

#if WITH_DEPRECATED_IPV4_API
		ServerNetTools::GetIPAdress (fListeningAddress, ipString);
#else
		ipString.FromString (fListeningAddress);
#endif
		HTTPServerTools::GetAuthenticationMethodName (fAuthType, authTypeString);

		projectSettings->SetLong (RIASettingsKeys::Project::refCount, GetRefCount());
		projectSettings->SetString (RIASettingsKeys::Project::listen, ipString);
		projectSettings->SetString (RIASettingsKeys::Project::hostName, fHostName);
#if HTTP_SERVER_USE_PROJECT_PATTERNS
		projectSettings->SetString (RIASettingsKeys::Project::pattern, fProjectPattern);
#endif
		projectSettings->SetString (RIASettingsKeys::Project::realm, fRealm);
		projectSettings->SetString (RIASettingsKeys::Project::authType, authTypeString);
		outBag->AddElement (RIASettingsKeys::Project::kXmlElement, projectSettings);
		XBOX::ReleaseRefCountable (&projectSettings);
	}

	XBOX::VValueBag *httpSettings = new XBOX::VValueBag ();
	if (httpSettings)
	{
		XBOX::VString posixPath;

		httpSettings->SetLong (RIASettingsKeys::HTTP::port, fPort);
		httpSettings->SetBool (RIASettingsKeys::HTTP::allowSSL, fAllowSSL);
		httpSettings->SetBool (RIASettingsKeys::HTTP::SSLMandatory, fSSLMandatory);
		httpSettings->SetLong (RIASettingsKeys::HTTP::SSLPort, fSSLPort);

		if (fSSLCertificatesFolderPath.IsValid())
		{
			fSSLCertificatesFolderPath.GetPosixPath (posixPath);
			httpSettings->SetString (RIASettingsKeys::HTTP::SSLCertificatePath, posixPath);
		}

		XBOX::VString charSetName;
		VTextConverters::Get()->GetNameFromCharSet (fDefaultCharSet, charSetName);
		httpSettings->SetString (RIASettingsKeys::HTTP::standardSet, charSetName);

		/* cache settings */
		httpSettings->SetBool (RIASettingsKeys::HTTP::useCache, fEnableCache);
		httpSettings->SetLong (RIASettingsKeys::HTTP::pageCacheSize, fCacheMaxSize);
		httpSettings->SetLong (RIASettingsKeys::HTTP::cachedObjectMaxSize, fCachedObjectMaxSize);

		/* compression settings */
		httpSettings->SetBool (RIASettingsKeys::HTTP::allowCompression, fEnableCompression);
		httpSettings->SetLong (RIASettingsKeys::HTTP::compressionMinThreshold, fCompressionMinThreshold);
		httpSettings->SetLong (RIASettingsKeys::HTTP::compressionMaxThreshold, fCompressionMaxThreshold);

		/* Keep-Alive settings */
		httpSettings->SetBool (RIASettingsKeys::HTTP::acceptKeepAliveConnections, fEnableKeepAlive);
		httpSettings->SetLong (RIASettingsKeys::HTTP::maximumTimeout, fKeepAliveTimeout);
		httpSettings->SetLong (RIASettingsKeys::HTTP::maximumRequestsByConnection, fKeepAliveMaxConnections);

		/* Log settings */
		XBOX::VString logFormatName;
		HTTPServerTools::GetLogFormatName ((EHTTPServerLogFormat)fLogFormat, logFormatName);
		posixPath.Clear();
		fLogFolderPath.GetPosixPath (posixPath);
		httpSettings->SetString (RIASettingsKeys::HTTP::logFormat, logFormatName);
		httpSettings->SetString (RIASettingsKeys::HTTP::logPath, posixPath);
		httpSettings->SetString (RIASettingsKeys::HTTP::logFileName, fLogFileName);
		httpSettings->SetLong (RIASettingsKeys::HTTP::logMaxSize, GetLogMaxSize());

		/* Log Tokens settings */
		XBOX::VBagArray *logTokenSettings = new XBOX::VBagArray ();
		if (NULL != logTokenSettings)
		{
			XBOX::VTaskLock lock (&fLogTokensVectorLock);
			XBOX::VString	tokenName;

			for (VectorOfLogToken::const_iterator it = fLogTokensVector.begin(); it != fLogTokensVector.end(); ++it)
			{
				XBOX::VValueBag *bag = new XBOX::VValueBag ();
				if (NULL != bag)
				{
					HTTPServerTools::GetLogTokenName (*it, tokenName);
					bag->SetString (RIASettingsKeys::HTTP::Log::field, tokenName);
					logTokenSettings->AddTail (bag);
					bag->Release();
				}
			}

			if (logTokenSettings->GetCount())
				httpSettings->SetElements (RIASettingsKeys::HTTP::Log::kXmlElement, logTokenSettings);

			XBOX::ReleaseRefCountable (&logTokenSettings);
		}

		outBag->AddElement (RIASettingsKeys::HTTP::kXmlElement, httpSettings);
		XBOX::ReleaseRefCountable (&httpSettings);
	}

	/* Web App settings */
	XBOX::VValueBag *webAppSettings = new XBOX::VValueBag ();
	if (webAppSettings)
	{
		XBOX::VString posixPath;
		fWebFolderPath.GetPosixPath (posixPath);
		webAppSettings->SetString (RIASettingsKeys::WebApp::documentRoot, posixPath);
		webAppSettings->SetString (RIASettingsKeys::WebApp::directoryIndex, fIndexPageName);

		outBag->AddElement (RIASettingsKeys::WebApp::kXmlElement, webAppSettings);
		XBOX::ReleaseRefCountable (&webAppSettings);
	}

	/* Resources settings */
	XBOX::VBagArray *resourcesSettings = new XBOX::VBagArray ();
	if (resourcesSettings)
	{
		XBOX::VTaskLock lock (&fResourcesVectorLock);

		for (VHTTPResourcesVector::const_iterator it = fResourcesVector.begin(); it != fResourcesVector.end(); ++it)
		{
			if (!it->IsNull())
			{
				XBOX::VValueBag *bag = new XBOX::VValueBag ();
				if (bag)
				{
					(*it)->SaveToBag (*bag);
					resourcesSettings->AddTail (bag);
					bag->Release();
				}
			}
		}

		if (resourcesSettings->GetCount())
			outBag->SetElements (RIASettingsKeys::Resources::kXmlElement, resourcesSettings);

		XBOX::ReleaseRefCountable (&resourcesSettings);
	}

#if 0 /*VERSIONDEBUG*/
	XBOX::VString xmlString ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
	outBag->DumpXML (xmlString, CVSTR ("settings"), true);
#endif

	return XBOX::VE_OK;
}
StringBuffer *StringBufferASCII::Replace(const char szOld[], uint32 nOldLength, const char szNew[], uint32 nNewLength, uint32 &nReplaced)
{
	// [TODO] Use the string buffer manager

	// Check for only character replace
	if (nOldLength == 1 && nNewLength == 1)
		return Replace(szOld[0], szNew[0], nReplaced);

	// First, get the number of substrings to replace
	nReplaced = 0;
	const char *pszString = m_pszString;
	const char *pszEnd    = m_pszString + m_nLength;
	while (pszString<pszEnd) {
		if (!strncmp(pszString, szOld, nOldLength)) {
			nReplaced++;
			pszString += nOldLength;
		} else {
			pszString++;
		}
	}

	// Jipi, no substrings, no further work to do :)
	if (!nReplaced)
		return this; // Nothing was changed and we can just return this string buffer

	// Get and check the new length
	const uint32 nFinalLength = m_nLength + (nNewLength - nOldLength)*nReplaced;
	if (!nFinalLength)
		return nullptr; // The string is now empty!

	// Create the new string
	char *pszNewString  = new char[nFinalLength + 1];
	char *pszNewStringT = pszNewString;
	uint32 nSkipped = 0;
	pszString = m_pszString;
	for (uint32 i=0; i<nReplaced; i++) {
		// Find substring
		while (strncmp(pszString, szOld, nOldLength)) {
			pszString++;
			nSkipped++;
		}

		// Copy previous none substring characters
		if (nSkipped) {
			memcpy(pszNewStringT, pszString - nSkipped, nSkipped);
			pszNewStringT += nSkipped;
		}

		// Insert new substring
		memcpy(pszNewStringT, szNew, nNewLength);
		pszNewStringT += nNewLength;
		pszString += nOldLength;
		nSkipped = 0;
	}

	// Copy the rest of the old string to the new string
	if (*pszString != '\0') {
		uint32 i = static_cast<uint32>(pszNewString + nFinalLength - pszNewStringT);
		memcpy(pszNewStringT, pszString, i);
		pszNewStringT += i;
	}

	// Add terminating zero
	*pszNewStringT = '\0';

	// Return the new string buffer
	if (GetRefCount() > 1) {
		return new StringBufferASCII(pszNewString, nFinalLength, nFinalLength);
	} else {
		// Just modify and return this string buffer
		SetString(pszNewString, nFinalLength);
		return this;
	}
}
Example #7
0
    int32 rwmain( Interface *engineInterface )
    {
        // Matrix test.
        {
            static RwMatrix newMat =
            {
                { 1, 2, 3, 4 },
                { 6, 5, 3, 7 },
                { 2, 7, 5, 4 },
                { 2, 5, 4, 6 }
            };

            static RwMatrix srcIdent =
            {
                { 4, 5, 3, 4 },
                { 8, 3, 7, 5 },
                { 2, 1, 6, 3 },
                { 5, 8, 4, 5 }
            };

            static RwMatrix target( newMat * srcIdent );

            target *= 4.5;

            __debugbreak();
        }

        // Give information about the running application to the runtime.
        softwareMetaInfo metaInfo;
        metaInfo.applicationName = "RenderWare Sample";
        metaInfo.applicationVersion = "test";
        metaInfo.description = "A test application for the rwtools runtime";

        engineInterface->SetApplicationInfo( metaInfo );

        // Create a window and render into it.
        Window *rwWindow = MakeWindow( engineInterface, 640, 480 );

        if ( !rwWindow )
            return -1;

        // We hold an extra reference.
        AcquireObject( rwWindow );

        // Handle the window closing event.
        RegisterEventHandler( rwWindow, event_t::WINDOW_CLOSING, window_closing_event_handler );
        RegisterEventHandler( rwWindow, event_t::WINDOW_QUIT, window_closing_event_handler );

        // Show the window, since we have set it up by now.
        rwWindow->SetVisible( true );
        
        // Create the game renderer.
        Driver *d3dDriver = CreateDriver( engineInterface, "Direct3D12" );

        assert( d3dDriver != NULL );

        // Set up the game resources.
        DriverSwapChain *swapChain = d3dDriver->CreateSwapChain( rwWindow, 2 ); // we want to double-buffer.

        DrawingLayer2D *guiContext = CreateDrawingLayer2D( d3dDriver );

        // We have to get the ref count over here, because the swap chain increases the ref count as well.
        uint32 wndBaseRefCount = GetRefCount( rwWindow );

        // Execute the main loop
        while ( GetRefCount( rwWindow ) >= wndBaseRefCount )   // we wait until somebody requested to destroy the window.
        {
            // Draw the game scene.
            {
                // Set render states.
                guiContext->SetRenderState( DrawingLayer2D::RWSTATE_UTEXADDRESSMODE, RWTEXADDRESS_WRAP );
                guiContext->SetRenderState( DrawingLayer2D::RWSTATE_VTEXADDRESSMODE, RWTEXADDRESS_WRAP );
                guiContext->SetRenderState( DrawingLayer2D::RWSTATE_ZWRITEENABLE, true );
                guiContext->SetRenderState( DrawingLayer2D::RWSTATE_TEXFILTER, RWFILTER_POINT );
                guiContext->SetRenderState( DrawingLayer2D::RWSTATE_SRCBLEND, RWBLEND_ONE );
                guiContext->SetRenderState( DrawingLayer2D::RWSTATE_DSTBLEND, RWBLEND_ZERO );
                guiContext->SetRenderState( DrawingLayer2D::RWSTATE_ALPHABLENDENABLE, true );
                guiContext->SetRenderState( DrawingLayer2D::RWSTATE_ALPHAFUNC, RWCMP_ALWAYS );
                guiContext->SetRenderState( DrawingLayer2D::RWSTATE_ALPHAREF, 0 );

#if 0
                // Execute draws.
                guiContext->Begin();

                guiContext->DrawRect( 50, 50, 100, 100 );
                guiContext->DrawRect( 60, 60, 80, 80 );
                guiContext->DrawLine( 10, 10, 290, 150 );

                guiContext->End();
#endif
            }

            // Give cycles to the window manager.
            // In the multi-threaded environment, this will effectively be a no-op.
            PulseWindowingSystem( engineInterface );

            // We want to give some cycles to the OS.
            // Otherwise our thread would starve everything.
            YieldExecution( 1 );
        }

        // Hide the window.
        // Do this because terminating resources takes some time and
        // the user already knows this application is terminating.
        rwWindow->SetVisible( false );

        // Destroy drawing contexts.
        DeleteDrawingLayer2D( guiContext );

        // Release the swap chain device resource.
        d3dDriver->DestroySwapChain( swapChain );

        // Terminate the driver.
        DestroyDriver( engineInterface, d3dDriver );

        // Release our window reference.
        // This will destroy it.
        engineInterface->DeleteRwObject( rwWindow );

        return 0;
    }
Example #8
0
UINT __stdcall
ingres_set_dbms_reg_entries (MSIHANDLE ihnd)
{
    HKEY		hKey;
    char		KeyName[256];
    int			status = 0;
    DWORD		dwSize, dwDisposition, dwType;
    TCHAR		tchValue[2048];
    INSTALLSTATE	iInstalled, iAction;
    char szID[3], szComponentGUID[39], szProductGUID[39];

    if (!MsiGetFeatureState(ihnd, "IngresDBMS", &iInstalled, &iAction))
    {
	if (iInstalled==INSTALLSTATE_ABSENT && iAction==INSTALLSTATE_UNKNOWN) 
	    return ERROR_SUCCESS;
    }
    else
	return ERROR_SUCCESS;

    dwSize = sizeof(tchValue);
    if (MsiGetProperty( ihnd, "II_INSTALLATION", tchValue,
			&dwSize ) != ERROR_SUCCESS)
    {
	return (ERROR_INSTALL_FAILURE);
    }
    else
    {
	sprintf(KeyName,
		"Software\\IngresCorporation\\Ingres\\%s_Installation",
		tchValue);
	status = RegCreateKeyEx(HKEY_LOCAL_MACHINE, KeyName, 0, NULL,
				REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
				&hKey, &dwDisposition);
    }

    if (iInstalled == INSTALLSTATE_LOCAL)
    {
	/*
	** Set up the InstalledFeatures registry key for possible use.
	*/
	dwType = REG_SZ;
	dwSize = sizeof(tchValue);
	if (RegQueryValueEx(hKey, "InstalledFeatures", NULL, &dwType,
			    tchValue, &dwSize) != ERROR_SUCCESS)
	{
	    strcpy(tchValue, "DBMS");
	}
	else if (!strstr(tchValue, "DBMS"))
	    strcat(tchValue, ",DBMS");

	status = RegSetValueEx( hKey, "InstalledFeatures", 0, REG_SZ,
				tchValue, strlen(tchValue) + 1 );
    }

    dwSize=sizeof(szID);
    MsiGetProperty(ihnd, "II_INSTALLATION", szID, &dwSize);
    if (!_stricmp(szID, "II"))
	strcpy(szComponentGUID, "{6C233EE5-2D74-11D5-BDFC-00B0D0AD4485}");
    else
    {
	int idx;

	idx = (toupper(szID[0]) - 'A') * 26 + toupper(szID[1]) - 'A';
	if (idx <= 0) 
	    idx = (toupper(szID[0]) - 'A') * 26 + toupper(szID[1]) - '0';
	sprintf(szComponentGUID, "{6C233EE5-2D74-11D5-%04X-%012X}", idx, idx*idx);
    }

    dwSize=sizeof(szProductGUID);
    MsiGetProperty(ihnd, "ProductCode", szProductGUID, &dwSize);

    if (iAction==INSTALLSTATE_ABSENT && GetRefCount(szComponentGUID, szProductGUID)==0)
    {
	/*
	** Set up the RemovedFeatures registry key for use later on.
	*/
	dwType = REG_SZ;
	dwSize = sizeof(tchValue);
	if (RegQueryValueEx(hKey, "RemovedFeatures", NULL, &dwType,
			    tchValue, &dwSize) != ERROR_SUCCESS)
	{
	    strcpy(tchValue, "DBMS");
	}
	else if (!strstr(tchValue, "DBMS"))
	    strcat(tchValue, ",DBMS");

	status = RegSetValueEx( hKey, "RemovedFeatures", 0, REG_SZ,
				tchValue, strlen(tchValue) + 1 );

	RegCloseKey(hKey);
	return (status==ERROR_SUCCESS ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE);
    }
    else if (iInstalled == INSTALLSTATE_LOCAL || iAction != INSTALLSTATE_LOCAL)
    {
	dwSize = sizeof(tchValue);
	if (!MsiGetProperty(ihnd, "INGRES_UPGRADE", tchValue, &dwSize) && strcmp(tchValue, "2"))
	{
	    RegCloseKey(hKey);
	    return (ERROR_SUCCESS);
	}
    }

    /*
    ** If this is an upgrade install, then checkpoint the databases
    ** if INGRES_CKPDBS is set.
    */

    dwSize = sizeof(tchValue);
    if (status ||
	MsiGetProperty( ihnd, "INGRES_LOGFILESIZE", tchValue,
			&dwSize ) != ERROR_SUCCESS)
    {
	return (ERROR_INSTALL_FAILURE);
    }
    else
    {
	status = RegSetValueEx( hKey, "logfilesize", 0, REG_SZ, tchValue,
				strlen(tchValue) + 1 );
    }

    dwSize = sizeof(tchValue);
    if (status ||
	MsiGetProperty( ihnd, "INGRES_ENABLEDUALLOG", tchValue,
			&dwSize ) != ERROR_SUCCESS)
    {
	return (ERROR_INSTALL_FAILURE);
    }
    else
    {
	status = RegSetValueEx( hKey, "enableduallogging", 0, REG_SZ, tchValue,
				strlen(tchValue) + 1 );
    }

    dwSize = sizeof(tchValue);
    if (status ||
	MsiGetProperty( ihnd, "INGRES_ENABLESQL92", tchValue,
			&dwSize ) != ERROR_SUCCESS)
    {
	return (ERROR_INSTALL_FAILURE);
    }
    else
    {
	status = RegSetValueEx( hKey, "enablesql92", 0, REG_SZ, tchValue,
				strlen(tchValue) + 1 );
    }

    dwSize = sizeof(tchValue);
    if (status ||
	MsiGetProperty( ihnd, "INGRES_DATADIR", tchValue,
			&dwSize ) != ERROR_SUCCESS)
    {
	return (ERROR_INSTALL_FAILURE);
    }
    else
    {
	if (tchValue[strlen(tchValue)-1] == '\\')
	    tchValue[strlen(tchValue)-1] = '\0';
	status = RegSetValueEx( hKey, "iidatabasedir", 0, REG_SZ, tchValue,
				strlen(tchValue) + 1 );
    }

    dwSize = sizeof(tchValue);
    if (status ||
	MsiGetProperty( ihnd, "INGRES_CKPDIR", tchValue,
			&dwSize ) != ERROR_SUCCESS)
    {
	return (ERROR_INSTALL_FAILURE);
    }
    else
    {
	if (tchValue[strlen(tchValue)-1] == '\\')
	    tchValue[strlen(tchValue)-1] = '\0';
	status = RegSetValueEx( hKey, "iicheckpointdir", 0, REG_SZ, tchValue,
				strlen(tchValue) + 1 );
    }

    dwSize = sizeof(tchValue);
    if (status ||
	MsiGetProperty( ihnd, "INGRES_JNLDIR", tchValue,
			&dwSize ) != ERROR_SUCCESS)
    {
	return (ERROR_INSTALL_FAILURE);
    }
    else
    {
	if (tchValue[strlen(tchValue)-1] == '\\')
	    tchValue[strlen(tchValue)-1] = '\0';
	status = RegSetValueEx( hKey, "iijournaldir", 0, REG_SZ, tchValue,
				strlen(tchValue) + 1 );
    }

    dwSize = sizeof(tchValue);
    if (status ||
	MsiGetProperty( ihnd, "INGRES_DMPDIR", tchValue,
			&dwSize ) != ERROR_SUCCESS)
    {
	return (ERROR_INSTALL_FAILURE);
    }
    else
    {
	if (tchValue[strlen(tchValue)-1] == '\\')
	    tchValue[strlen(tchValue)-1] = '\0';
	status = RegSetValueEx( hKey, "iidumpdir", 0, REG_SZ, tchValue,						strlen(tchValue) + 1 );
    }

    dwSize = sizeof(tchValue);
    if (status ||
	MsiGetProperty( ihnd, "INGRES_WORKDIR", tchValue,
			&dwSize ) != ERROR_SUCCESS)
    {
	return (ERROR_INSTALL_FAILURE);
    }
    else
    {
	if (tchValue[strlen(tchValue)-1] == '\\')
	    tchValue[strlen(tchValue)-1] = '\0';
	status = RegSetValueEx( hKey, "iiworkdir", 0, REG_SZ, tchValue,
				strlen(tchValue) + 1 );
    }

    dwSize = sizeof(tchValue);
    if (status ||
	MsiGetProperty( ihnd, "INGRES_PRIMLOGDIR", tchValue,
			&dwSize ) != ERROR_SUCCESS)
    {
	return (ERROR_INSTALL_FAILURE);
    }
    else
    {
	if (tchValue[strlen(tchValue)-1] == '\\')
	    tchValue[strlen(tchValue)-1] = '\0';
	status = RegSetValueEx( hKey, "primarylogdir", 0, REG_SZ, tchValue,
				strlen(tchValue) + 1 );
    }

    dwSize = sizeof(tchValue);
    if (status ||
	MsiGetProperty( ihnd, "INGRES_DUALLOGDIR", tchValue,
			&dwSize ) != ERROR_SUCCESS)
    {
	return (ERROR_INSTALL_FAILURE);
    }
    else
    {
	if (tchValue[strlen(tchValue)-1] == '\\')
	    tchValue[strlen(tchValue)-1] = '\0';
	status = RegSetValueEx( hKey, "duallogdir", 0, REG_SZ, tchValue,
				strlen(tchValue) + 1 );
    }

    dwSize = sizeof(tchValue);
    if (status ||
	MsiGetProperty( ihnd, "INGRES_DESTROYTXLOGFILE", tchValue,
			&dwSize ) != ERROR_SUCCESS)
    {
	return (ERROR_INSTALL_FAILURE);
    }
    else
    {
	status = RegSetValueEx( hKey, "destroytxlogfile", 0, REG_SZ, tchValue,
				strlen(tchValue) + 1 );
    }

    dwSize = sizeof(tchValue);
    if (status ||
	MsiGetProperty( ihnd, "INGRES_UPGRADEUSERDBS", tchValue,
			&dwSize ) != ERROR_SUCCESS)
    {
	return (ERROR_INSTALL_FAILURE);
    }
    else
    {
	status = RegSetValueEx( hKey, "upgradeuserdatabases", 0, REG_SZ, 
				tchValue, strlen(tchValue) + 1 );
    }

    dwSize = sizeof(tchValue);
    if (status ||
	MsiGetProperty( ihnd, "INGRES_CLUSTER_INSTALL", tchValue,
			&dwSize ) != ERROR_SUCCESS || !tchValue[0])
    {
    }
    else
    {
	status = RegSetValueEx( hKey, 
				"clusterinstall", 
				0, REG_SZ, (CONST BYTE *)&tchValue, 
				strlen(tchValue) + 1 );

    }

    dwSize = sizeof(tchValue);
    if (status ||
	MsiGetProperty( ihnd, "INGRES_CLUSTER_RESOURCE", tchValue,
			&dwSize ) != ERROR_SUCCESS || !tchValue[0])
    {
    }
    else
    {
	status = RegSetValueEx( hKey, 
				"clusterresource", 
				0, REG_SZ, (CONST BYTE *)&tchValue, 
				strlen(tchValue) + 1 );

    }

    dwSize = sizeof(tchValue);
    if (status ||
	MsiGetProperty( ihnd, "INGRES_MDB_INSTALL", tchValue,
			&dwSize ) != ERROR_SUCCESS || !tchValue[0])
    {
    }
    else
    {
	status = RegSetValueEx( hKey, 
				"mdbinstall", 
				0, REG_SZ, (CONST BYTE *)&tchValue, 
				strlen(tchValue) + 1 );

    }

    dwSize = sizeof(tchValue);
    if (status ||
	MsiGetProperty( ihnd, "INGRES_MDB_NAME", tchValue,
			&dwSize ) != ERROR_SUCCESS || !tchValue[0])
    {
    }
    else
    {
	status = RegSetValueEx( hKey, 
				"mdbname", 
				0, REG_SZ, (CONST BYTE *)&tchValue, 
				strlen(tchValue) + 1 );

    }

    dwSize = sizeof(tchValue);
    if (status ||
	MsiGetProperty( ihnd, "INGRES_MDB_SIZE", tchValue,
			&dwSize ) != ERROR_SUCCESS || !tchValue[0])
    {
    }
    else
    {
	status = RegSetValueEx( hKey, 
				"mdbsize", 
				0, REG_SZ, (CONST BYTE *)&tchValue, 
				strlen(tchValue) + 1 );

    }

    dwSize = sizeof(tchValue);
    if (status ||
	MsiGetProperty( ihnd, "INGRES_MDB_DEBUG", tchValue,
			&dwSize ) != ERROR_SUCCESS || !tchValue[0])
    {
    }
    else
    {
	status = RegSetValueEx( hKey, 
				"mdbdebug", 
				0, REG_SZ, (CONST BYTE *)&tchValue, 
				strlen(tchValue) + 1 );

    }

    strcpy(tchValue, "TRUE");
    status = RegSetValueEx( hKey, "Ingres DBMS Server", 0, REG_SZ, 
			    (CONST BYTE *)&tchValue, strlen(tchValue) + 1 );

    return (status == ERROR_SUCCESS ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE);
}