Exemple #1
0
bool
XDRState<mode>::codeScript(MutableHandleScript scriptp)
{
    RootedScript script(cx());
    if (mode == XDR_DECODE) {
        script = NULL;
        scriptp.set(NULL);
    } else {
        script = scriptp.get();
    }

    if (!VersionCheck(this))
        return false;

    if (!XDRScript(this, NullPtr(), NullPtr(), NullPtr(), &script))
        return false;

    if (mode == XDR_DECODE) {
        JS_ASSERT(!script->compileAndGo);
        js_CallNewScriptHook(cx(), script, NULL);
        Debugger::onNewScript(cx(), script, NULL);
        scriptp.set(script);
    }

    return true;
}
/*
	FUNCTION: WinMain(HINSTANCE, HINSTANCE, LPSTR, int)

	PURPOSE: Start application and process all window messages

	PARAMETERS:
		hInstance		- this application's instance
		hPrevInstance	- previous instance of this application (always NULL)
		lpCmdLine		- command line parameters
		nCmdShow		- code for showing the window

	RETURN:
		1 for success
		0 for failure to start the application
*/
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
	MSG msg;

	// Verify that the program can run on this version of windows
	if (!VersionCheck()) {
		MessageBox(NULL, "Program cannot run on this version of Windows.",
			NULL, MB_OK | MB_ICONSTOP);
		return 0;
	}

	// Attempt to initialize the application and create the main window and class
	if (!InitApp(hInstance, nCmdShow)) {
		MessageBox(NULL, "Program couldn't start! We don't know why, it just couldn't!",
			NULL, MB_OK | MB_ICONSTOP);
	}

	// Main message loop
	while (GetMessage(&msg, NULL, 0, 0)) {	// Get message from queue
		// Send message to accelerator to check if it is a keyboard command
		if (!TranslateAccelerator(ghWndMain, ghAccel, &msg)) {
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}

	return msg.wParam;	// Exit parameter to be returned to the OS
}
Exemple #3
0
/*********************************************************************
 * Purpose: to initialize the global variables
 * Return: TRUE or FALSE
 *********************************************************************/
int D2GSVarsInitialize(void)
{
    DWORD	val;

    ZeroMemory(&d2gsconf, sizeof(d2gsconf));
    bGERunning = FALSE;

    /* calculate file checksum */
    val = VersionCheck();
    if (!val) {
        D2GSEventLog("D2GSVarsInitialize", "Failed calculating file checksum");
        return FALSE;
    }
    d2gsconf.checksum = val;

    /* initialize char list table */
    if (charlist_init(DEFAULT_HASHTBL_LEN)!=0) {
        D2GSEventLog("D2GSVarsInitialize", "Failed initialize charlist table");
        return FALSE;
    }

    /* initialize the CriticalSection Objects */
    InitializeCriticalSection(&csGameList);

    if (CleanupRoutineInsert(CleanupRoutineForVars, "Global Variables")) {
        return TRUE;
    } else {
        /* do some cleanup before quiting */
        CleanupRoutineForVars();
        return FALSE;
    }

} /* End of D2GSVarsInitialize() */
bool
XDRState<mode>::codeFunction(JSObject **objp)
{
    if (mode == XDR_DECODE)
        *objp = NULL;
        
    return VersionCheck(this) && XDRInterpretedFunction(this, objp, NULL);
}
Exemple #5
0
BOOL CUpdateUtil::CompareFileVersion(CItemList* pItemListSourceCmp, CItemList* pItemListDestCmp)
{
//	UPDATE_DATA* tmpClientSection = NULL;
//	UPDATE_DATA* tmpServerSection = NULL;

//	memset(tmpClientSection, 0, sizeof(UPDATE_DATA));
//	memset(tmpServerSection, 0, sizeof(UPDATE_DATA));
	
	CPtrList* pPLClient = pItemListDestCmp->GetPtrList();
	CPtrList* pPLServer = pItemListSourceCmp->GetPtrList();
	BOOL bExist = FALSE;
	UPDATE_DATA *psiServer = NULL;
	UPDATE_DATA *psiClient = NULL;
	CString strFilePath = "";

	UTIL_CANCEL();
	if(pPLClient->GetCount() == 0)
	{
		// Server xml File check
		POSITION posServer= pPLServer->GetHeadPosition();
		psiServer = NULL;
		strFilePath = "";
		while(posServer)
		{	
			bExist = FALSE;

			psiServer = (UPDATE_DATA *)pPLServer->GetNext(posServer);
			strFilePath.Format("%s\\%s", psiServer->DownPath, psiServer->Name);

			switch (VersionCheck(strFilePath, "0", psiServer->Version, psiServer->DownURL, psiServer->CheckSum, psiServer->Size))
			{
			case UPDATE_FLAG_NORMAL:
				TRACE("%s File : Do not anything  because %s == %s\n", strFilePath, psiServer->Version, psiServer->Version);
				psiServer->UpdateFlag = UPDATE_FLAG_NORMAL;
				break;
			case UPDATE_FLAG_NEW:
				TRACE("%s File : New  because not exsist\n", strFilePath);
				psiServer->UpdateFlag = UPDATE_FLAG_NEW;
				break;
			case UPDATE_FLAG_UPDATE:
				TRACE("%s File : Update  because %s < %s\n", strFilePath, psiServer->Version, psiServer->Version);
				psiServer->UpdateFlag = UPDATE_FLAG_UPDATE;
				break;
			case UPDATE_FLAG_DIFFERENT:
				TRACE("%s File : Update because different between xml version file and exist file\n", strFilePath);
				psiServer->UpdateFlag = UPDATE_FLAG_UPDATE;
				break;
			}
		}
	}
	else
	{
		return	CompareFileVersion2(pItemListSourceCmp, pItemListDestCmp);
	}

	return TRUE;
}
Exemple #6
0
bool
XDRState<mode>::codeFunction(JSMutableHandleObject objp)
{
    if (mode == XDR_DECODE)
        objp.set(NULL);

    if (!VersionCheck(this))
        return false;

    return XDRInterpretedFunction(this, NullPtr(), NullPtr(), objp);
}
//---------------------------- PRIVATE          -----------------------------//
void *wxServerConnectionThread::Entry()
{
	bool valid = true;

	// It's ok to block this thread waiting for data.
	mSocket->SetFlags(wxSOCKET_WAITALL);

	try
	{
		// If we pass the check, but return false, it means we got hit by the
		// site requesting a host check.

		if(false == Cities3DCheck())
		{
            static const wxString stReceivedAHostCheck = _("Received a host check from the site.");
    
			wxRuleEvent event(shNetworkRuleSystemMessage, 
				DataObject(stReceivedAHostCheck, wxDateTime::Now()));
			mHandler->AddPendingEvent(event);

			valid = false;
			goto error;
		}
		VersionCheck();

		ReceiveSpectator();

		SendSpectators();
		SendGame();
		SendRNG();
	}
	catch(const std::exception &e)
	{
		valid = false;

		wxLogDebug(HashString(e.what()).wx_str());
	}

error:
	if(true == valid)
	{
		// This socket is complete and ready for data.
		mSocket->mIsComplete = true;
	}
	else
	{
		mSocket->Destroy();
		mSocket = NULL;
	}

	return NULL;
}
bool
XDRState<mode>::codeScript(JSScript **scriptp)
{
    JSScript *script;
    if (mode == XDR_DECODE) {
        script = NULL;
        *scriptp = NULL;
    } else {
        script = *scriptp;
    }

    if (!VersionCheck(this) || !XDRScript(this, &script, NULL))
        return false;

    if (mode == XDR_DECODE) {
        JS_ASSERT(!script->compileAndGo);
        script->globalObject = GetCurrentGlobal(cx());
        js_CallNewScriptHook(cx(), script, NULL);
        Debugger::onNewScript(cx(), script, NULL);
        *scriptp = script;
    }

    return true;
}
/*
	FUNCTION: WinMain(HINSTANCE, HINSTANCE, LPSTR, int)

	PURPOSE: Start application and process all window messages

	PARAMETERS:
		hInstance		- this application's instance
		hPrevInstance	- previous instance of this application (always NULL)
		lpCmdLine		- command line parameters
		nCmdShow		- code for showing the window

	RETURN:
		1 for success
		0 for failure to start the application
*/
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
	MSG msg;

	// Verify that the program can run on this version of windows
	if (!VersionCheck()) {
		MessageBox(NULL, TEXT("Program cannot run on this version of Windows."),
			NULL, MB_OK | MB_ICONSTOP);
		return 0;
	}

	// Attempt to initialize the application and create the main window and class
	if (!InitApp(hInstance, nCmdShow)) {
		MessageBox(NULL, TEXT("Program couldn't start! We don't know why, it just couldn't!"),
			NULL, MB_OK | MB_ICONSTOP);
	}

	// Main message loop
	while (GetMessage(&msg, NULL, 0, 0)) {	// Get message from queue
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

	return (int)msg.wParam;	// Exit parameter to be returned to the OS
}
sbError
sbiTunesAgentProcessor::ProcessTaskFile()
{
  int retry = 60;

  if (!OpenResultsFile()) {
    return sbError("Failed to open results file to check for start!");
  }
  
  if (OpenResultsFile().tellp() == std::ofstream::pos_type(0)) {
    OpenResultsFile() << '[' << SCHEMA_VERSION << ":2]\n"
                      << '[' << ADDED_MEDIA_ITEMS << "]\n";
  }

  // Keep process all files we find
  while (OpenTaskFile(mInputStream)) {
    if (!mInputStream) {
      // Can't open, maybe it's being written to try again
      if (--retry == 0) {
        return sbError("Unable to open the export track file");
      }
      Sleep(1000);
      continue;
    }
    sbError const & error = Initialize();
    if (error && !ErrorHandler(error)) {
      return error;
    }
    std::string line;
    std::string action;
    std::string source;
    int lineno = 0;
    while (std::getline(mInputStream, line)) {
      std::string::size_type const beginBracket = 
        line.find_first_not_of(" \t");
      // Look for the right bracket as first non-whitespace
      if (beginBracket != std::string::npos && line[beginBracket] == '[') {
        std::string::size_type const endBracket = line.find_last_of(']');
        if (endBracket != std::string::npos) {
          std::string task = line.substr(beginBracket + 1, 
                                         endBracket - beginBracket - 1);
          ParseTask(task, action, source);
          if (action == SCHEMA_VERSION) {
            VersionAction const versionAction = VersionCheck(source);
            action.clear();
            source.clear();
            if (versionAction == ABORT) {
              return sbError("Incompatible version encountered");
            }
            else if (versionAction == RETRY) {
              mInputStream.close();
              continue; // Will hit the inner while and it will stop
            }
          }

          sbError error = ProcessPendingTrackBatch();
          SB_ENSURE_ERRORHANDLER(error);
        }
      }
      else {
        // If there is no action then there's nothing to do yet
        if (action.empty()) {
          ++lineno;
          continue;
        }
        std::string::size_type const equalSign = line.find('=');
        if (equalSign != std::string::npos) {
          std::string const & key =
            Strip(line.substr(0, equalSign));
          std::string const & value =
            Unescape(Strip(line.substr(equalSign + 1)));

          // We've been told to add the track
          if (action == ADDED_MEDIA_ITEMS) {
            sbError const & error = AddTrack(source, key, value, ADDED_MEDIA_ITEMS);
            SB_ENSURE_ERRORHANDLER(error);
          }
          else if (action == UPDATED_MEDIA_ITEMS) {
            sbError const & error = UpdateTrack(key, value);
            SB_ENSURE_ERRORHANDLER(error);
          }
          else if (action == ADDED_PLAYLISTS) {
            sbError error = CreatePlaylist(value);
            SB_ENSURE_ERRORHANDLER(error);
          }
          // We've been told to remove the playlist
          else if (action == DELETED_PLAYLISTS) {
            sbError error = RemovePlaylist(value);
            SB_ENSURE_ERRORHANDLER(error);
          }
          else if (action == UPDATED_SMARTPLAYLIST) {
            sbError const & error = AddTrack(source,
                                             key,
                                             value,
                                             UPDATED_SMARTPLAYLIST);
            SB_ENSURE_ERRORHANDLER(error);
          }
          else {
            std::ostringstream msg;
            msg << action << " is an invalid action , ignoring line " 
                << lineno;
            sbError error(msg.str());
            SB_ENSURE_ERRORHANDLER(error);

            action.clear();
          }
        }
        else {
          // If the line wasn't blank then report an error
          if (!Strip(line).empty()) {
            std::ostringstream msg;
            msg << action 
                << " is an invalid action , ignoring line " << lineno;
            sbError error(msg.str());
            SB_ENSURE_ERRORHANDLER(error);
          }
        }
      }
      ++lineno;
      if (ShouldShutdown()) {
        // Notify shutdown done and exit
        ShutdownDone();
        return sbNoError;
      }
    }
    if (!mTrackBatch.empty()) {
      sbError const & error = ProcessPendingTrackBatch();
      SB_ENSURE_ERRORHANDLER(error);
    }
    // Close the stream and remove the file
    mInputStream.close();
    mInputStream.clear();
    RemoveTaskFile();
  }
  return sbNoError;
}
Exemple #11
0
BOOL CUpdateUtil::CompareFileVersion2(CItemList *pItemListSourceCmp, CItemList *pItemListDestCmp)
{
	CPtrList* pPLClient = pItemListDestCmp->GetPtrList();
	CPtrList* pPLServer = pItemListSourceCmp->GetPtrList();
	BOOL bExist = FALSE;
	UPDATE_DATA *psiServer = NULL;
	UPDATE_DATA *psiClient = NULL;
	CString strFilePath = "";

	UTIL_CANCEL();
	// Client xml File check
	POSITION posClient = pPLClient->GetHeadPosition();
	while(posClient)
	{	
		bExist = FALSE;
		psiClient = (UPDATE_DATA *)pPLClient->GetNext(posClient);
		
		UTIL_CANCEL();
		POSITION posServer= pPLServer->GetHeadPosition();
		while(posServer)
		{		
			psiServer = (UPDATE_DATA *)pPLServer->GetNext(posServer);
			if(strcmp(psiClient->Name, psiServer->Name) == 0){
				bExist = TRUE;
				strFilePath.Format("%s\\%s", psiClient->DownPath, psiClient->Name);
				
				UTIL_CANCEL();
				switch (VersionCheck(strFilePath, psiClient->Version, psiServer->Version, psiServer->DownURL, psiServer->CheckSum, psiServer->Size))
				{
				case UPDATE_FLAG_NORMAL:
					TRACE("%s File : Do not anything  because %s == %s\n", strFilePath, psiClient->Version, psiServer->Version);
					psiServer->UpdateFlag = UPDATE_FLAG_NORMAL;
					break;
				case UPDATE_FLAG_NEW:
					TRACE("%s File : New  because not exsist\n", strFilePath);
					psiServer->UpdateFlag = UPDATE_FLAG_NEW;
					break;
				case UPDATE_FLAG_UPDATE:
					TRACE("%s File : Update  because %s < %s\n", strFilePath, psiClient->Version, psiServer->Version);
					psiServer->UpdateFlag = UPDATE_FLAG_UPDATE;
					break;
				case UPDATE_FLAG_DIFFERENT:
					TRACE("%s File : Update because different between xml version file and exist file\n", strFilePath);
					psiServer->UpdateFlag = UPDATE_FLAG_UPDATE;
					break;
				}
			}
			
			if(bExist)
				break;
		}
		
		if(!bExist){
			TRACE("%s File : Delete\n", psiClient->Name);
			psiClient->UpdateFlag = UPDATE_FLAG_DELETE;
		}
	
	}

	UTIL_CANCEL();
	// Server xml File check
	POSITION posServer= pPLServer->GetHeadPosition();
	while(posServer)
	{	
		bExist = FALSE;
		psiServer = (UPDATE_DATA *)pPLServer->GetNext(posServer);
		
		if(strcmp(psiServer->Force, UPDATE_FORCE) == 0){
			TRACE("%s File : Update because forced\n", psiServer->Name);
			psiServer->UpdateFlag = UPDATE_FLAG_UPDATE;
			continue;
		}
		
		UTIL_CANCEL();
		POSITION posClient = pPLClient->GetHeadPosition();
		while(posClient)
		{	
			psiClient = (UPDATE_DATA *)pPLClient->GetNext(posClient);	
			if(strcmp(psiClient->Name, psiServer->Name) == 0){
				bExist = TRUE;
				if(psiServer->UpdateFlag == 0){					
					UTIL_CANCEL();
					strFilePath.Format("%s\\%s", psiServer->DownPath, psiServer->Name);
					switch (VersionCheck(strFilePath, psiClient->Version, psiServer->Version, psiServer->DownURL, psiServer->CheckSum, psiServer->Size))
					{
					case UPDATE_FLAG_NORMAL:
						TRACE("%s File : Do not anything  because %s == %s\n", strFilePath, psiClient->Version, psiServer->Version);
						psiServer->UpdateFlag = UPDATE_FLAG_NORMAL;
						break;
					case UPDATE_FLAG_NEW:
						TRACE("%s File : New  because not exsist\n", strFilePath);
						psiServer->UpdateFlag = UPDATE_FLAG_NEW;
						break;
					case UPDATE_FLAG_UPDATE:
						TRACE("%s File : Update  because %s < %s\n", strFilePath, psiClient->Version, psiServer->Version);
						psiServer->UpdateFlag = UPDATE_FLAG_UPDATE;
						break;
					case UPDATE_FLAG_DIFFERENT:
						TRACE("%s File : Update because different between xml version file and exist file\n", strFilePath);
						psiServer->UpdateFlag = UPDATE_FLAG_UPDATE;
						break;
					}
				}
		
				break;
			}
		}			

		if(!bExist){
			TRACE("%s File : new\n", psiServer->Name);
			psiServer->UpdateFlag = UPDATE_FLAG_NEW;
		}
	}

	// last server update new file check
	UTIL_CANCEL();
	posServer= pPLServer->GetHeadPosition();
	while(posServer)
	{	
		psiServer = (UPDATE_DATA *)pPLServer->GetNext(posServer);
		
		UTIL_CANCEL();
		if(psiServer->UpdateFlag == UPDATE_FLAG_NEW){
			strFilePath.Format("%s\\%s", psiServer->DownPath, psiServer->Name);
			switch (VersionCheck(strFilePath, "0", psiServer->Version, psiServer->DownURL, psiServer->CheckSum, psiServer->Size))
			{
			case UPDATE_FLAG_NORMAL:
				TRACE("%s File : Do not anything  because %s == %s\n", strFilePath, psiServer->Version, psiServer->Version);
				psiServer->UpdateFlag = UPDATE_FLAG_NORMAL;
				break;
			case UPDATE_FLAG_NEW:
				TRACE("%s File : New  because not exsist\n", strFilePath);
				psiServer->UpdateFlag = UPDATE_FLAG_NEW;
				break;
			case UPDATE_FLAG_UPDATE:
				TRACE("%s File : Update  because %s < %s\n", strFilePath, psiServer->Version, psiServer->Version);
				psiServer->UpdateFlag = UPDATE_FLAG_UPDATE;
				break;
			case UPDATE_FLAG_DIFFERENT:
				TRACE("%s File : Update because different between xml version file and exist file\n", strFilePath);
				psiServer->UpdateFlag = UPDATE_FLAG_UPDATE;
				break;
			}
		}
	}

	return TRUE;
}