コード例 #1
0
ファイル: CppCheck.cpp プロジェクト: wiesyk/wiesyk
int CppCheck::Execute()
{
    WriteToLog(_("Running cppcheck/vera++ analysis... please wait..."));

    if ( !CheckRequirements() )
        return -1;

    cbProject* Project = Manager::Get()->GetProjectManager()->GetActiveProject();
    if (Project->GetFilesCount() < 1)
        return 0;

    const wxString BasePath = Project->GetBasePath();
    AppendToLog(_T("Switching working directory to : ") + BasePath);
    ::wxSetWorkingDirectory(BasePath);


    ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("cppcheck"));
    int choice = cfg->ReadInt(_T("operation"), 0);

    int result_cppcheck = 0;
    int result_vera     = 0;

    if ((0==choice) || (2==choice))
      result_cppcheck = ExecuteCppCheck(Project);

    if ((1==choice) || (2==choice))
      result_vera = ExecuteVera(Project);

    return ((0==result_cppcheck) && (0==result_vera)) ? 0 : -1;
}
コード例 #2
0
//-----------------------------------------------------------------------------
// Purpose: Checks the map for problems.
//-----------------------------------------------------------------------------
void CMapCheckDlg::DoCheck(void)
{
	CMapWorld *pWorld = GetActiveWorld();

	// clear error list
	KillErrorList();

	// perform checks
	CheckRequirements(&m_Errors, pWorld);
	CheckMixedFaces(&m_Errors, pWorld);
	CheckTargets(&m_Errors, pWorld);
//	CheckDuplicatePlanes(&m_Errors, pWorld);
	CheckDuplicateFaceIDs(&m_Errors, pWorld);
	CheckDuplicateNodeIDs(&m_Errors, pWorld);
	CheckSolidIntegrity(&m_Errors, pWorld);
	CheckSolidContents(&m_Errors, pWorld);
	CheckInvalidTextures(&m_Errors, pWorld);
	CheckUnusedKeyvalues(&m_Errors, pWorld);
	CheckEmptyEntities(&m_Errors, pWorld);
	CheckDuplicateKeys(&m_Errors, pWorld);
	CheckLightmapSizeOnDisplacement( &m_Errors, pWorld );

	if(!m_Errors.GetCount())
	{
		AfxMessageBox("No errors were found.");
		EndDialog(IDOK);
	}
}
コード例 #3
0
ファイル: Serial.cpp プロジェクト: FelGel/BlueMagic
LONG CSerial::Write (LPCSTR pString, DWORD* pdwWritten, LPOVERLAPPED lpOverlapped, DWORD dwTimeout)
{
	// Check if time-outs are supported
	CheckRequirements(lpOverlapped,dwTimeout);

	// Determine the length of the string
	return Write(pString,strlen(pString),pdwWritten,lpOverlapped,dwTimeout);
}
コード例 #4
0
ファイル: MoveSystem.cpp プロジェクト: ElBedeawi/mu-server-ex
// --------------------------------------------------------------------------------------------------------------------------------------------------
void CMoveSystem::RandWarp(int aIndex, int MapNumber) // Random Warping
{	
	LPOBJ lpObj = &gObj[aIndex];
	// -----
	if ( !OBJMAX_RANGE(aIndex) )
	{
		CLog.LogAddC(TColor.Red(), "Error: Protocol Index wrong!", lpObj->AccountID, lpObj->Name);
		return;
	}
	// -----
	if (GateC.iX1[MOVSTR[MapNumber].TargetGate] == GateC.iX2[MOVSTR[MapNumber].TargetGate])
	{
		GateC.iX2[MOVSTR[MapNumber].TargetGate]++;
	}
	// -----
	if (GateC.iY1[MOVSTR[MapNumber].TargetGate] == GateC.iY2[MOVSTR[MapNumber].TargetGate]) 
	{
		GateC.iY2[MOVSTR[MapNumber].TargetGate]++;
	}
	// -----
	MOVSTR->FinalX = min(GateC.iX1[MOVSTR[MapNumber].TargetGate],GateC.iX2[MOVSTR[MapNumber].TargetGate])+rand()%(max(GateC.iX1[MOVSTR[MapNumber].TargetGate],GateC.iX2[MOVSTR[MapNumber].TargetGate])-min(GateC.iX1[MOVSTR[MapNumber].TargetGate],GateC.iX2[MOVSTR[MapNumber].TargetGate]));
	MOVSTR->FinalY = min(GateC.iY1[MOVSTR[MapNumber].TargetGate],GateC.iY2[MOVSTR[MapNumber].TargetGate])+rand()%(max(GateC.iY1[MOVSTR[MapNumber].TargetGate],GateC.iY2[MOVSTR[MapNumber].TargetGate])-min(GateC.iY1[MOVSTR[MapNumber].TargetGate],GateC.iY2[MOVSTR[MapNumber].TargetGate]));
	// -----
	BYTE  TeleportMap	= GateC.iMapNum[MOVSTR[MapNumber].TargetGate];
	int	  TotalZen		= MOVSTR[MapNumber].Money;
	// -----
	CheckRequirements(aIndex, TeleportMap, MOVSTR->FinalX, MOVSTR->FinalY);
	// -----
	lpObj->m_State		= 32;
	lpObj->X			= MOVSTR->FinalX;
	lpObj->Y			= MOVSTR->FinalY;
	lpObj->Money	   -= TotalZen;
	// -----
	lpObj->TX			= MOVSTR->FinalX;
	lpObj->TY			= MOVSTR->FinalY;
	// -----
	lpObj->MapNumber	= TeleportMap;
	lpObj->PathCount	= 0;
	lpObj->Teleport		= 0;
	// -----
	gObjClearViewport(lpObj);
	GCTeleportSend(lpObj, 1, TeleportMap, lpObj->X, lpObj->Y, lpObj->Dir);
	GCMoneySend(aIndex, lpObj->Money);
	// -----
	if(lpObj->m_Change >= 0)
	{
		gObjViewportListProtocolCreate(lpObj);
	}
	// -----
	lpObj->RegenMapNumber	= TeleportMap;
	lpObj->RegenMapX		= MOVSTR->FinalX;
	lpObj->RegenMapY		= MOVSTR->FinalY;
	lpObj->RegenOk			= 1;
	// -----
	//-- Log Message for Successful Moving
	CLog.LogAddC(TColor.Green(), "[MoveSystem] CheckRandomdMove() - MapServer Check OK [%s][%s]: MAP-[%d] (%d)(%d)", lpObj->AccountID,
		lpObj->Name, TeleportMap, MOVSTR->FinalX, MOVSTR->FinalY);
}
コード例 #5
0
ファイル: MoveSystem.cpp プロジェクト: ElBedeawi/mu-server-ex
// --------------------------------------------------------------------------------------------------------------------------------------------------
void CMoveSystem::SpecWarp(int aIndex, int MapNumber, BYTE X, BYTE Y) // Specified Warping
{
	LPOBJ lpObj = &gObj[aIndex];
	// -----
	if ( !OBJMAX_RANGE(aIndex) )
	{
		CLog.LogAddC(TColor.Red(), "Error: Protocol Index wrong!", lpObj->AccountID, lpObj->Name);
		return;
	}
	// -----
	CheckRequirements(aIndex, MapNumber, X, Y);
	// -----
	BYTE  TeleportMap	= GateC.iMapNum[MOVSTR[MapNumber].TargetGate];
	// -----
	lpObj->m_State		= 32;
	lpObj->X			= X;
	lpObj->Y			= Y;
	// -----
	lpObj->TX			= X;
	lpObj->TY			= Y;
	// -----
	lpObj->MapNumber	= TeleportMap;
	lpObj->PathCount	= 0;
	lpObj->Teleport		= 0;
	// -----
	gObjClearViewport(lpObj);
	GCTeleportSend(lpObj, 1, TeleportMap, lpObj->X, lpObj->Y, lpObj->Dir);
	GCMoneySend(aIndex, lpObj->Money);
	// -----
	if(lpObj->m_Change >= 0)
	{
		gObjViewportListProtocolCreate(lpObj);
	}
	// -----
	lpObj->RegenMapNumber	= TeleportMap;
	lpObj->RegenMapX		= X;
	lpObj->RegenMapY		= Y;
	lpObj->RegenOk			= 1;
	// -----
	//-- Log Message for Successful Moving
	CLog.LogAddC(TColor.Green(), "[MoveSystem] CheckSpecifiedMove() - MapServer Check OK [%s][%s]: MAP-[%d] (%d)(%d)", lpObj->AccountID,
		lpObj->Name, TeleportMap, X, Y);
}
コード例 #6
0
ファイル: Serial.cpp プロジェクト: FelGel/BlueMagic
LONG CSerial::Write (const void* pData, size_t iLen, DWORD* pdwWritten, LPOVERLAPPED lpOverlapped, DWORD dwTimeout)
{
	// Check if time-outs are supported
	CheckRequirements(lpOverlapped,dwTimeout);

	// Overlapped operation should specify the pdwWritten variable
	_ASSERTE(!lpOverlapped || pdwWritten);

	// Reset error state
	m_lLastError = ERROR_SUCCESS;

	// Use our own variable for read count
	DWORD dwWritten;
	if (pdwWritten == 0)
	{
		pdwWritten = &dwWritten;
	}

	// Reset the number of bytes written
	*pdwWritten = 0;

	// Check if the device is open
	if (m_hFile == 0)
	{
		// Set the internal error code
		m_lLastError = ERROR_INVALID_HANDLE;

		// Issue an error and quit
		_RPTF0(_CRT_WARN,"CSerial::Write - Device is not opened\n");
		return m_lLastError;
	}

#ifndef SERIAL_NO_OVERLAPPED

	// Check if an overlapped structure has been specified
	if (!m_hevtOverlapped && (lpOverlapped || (dwTimeout != INFINITE)))
	{
		// Set the internal error code
		m_lLastError = ERROR_INVALID_FUNCTION;

		// Issue an error and quit
		_RPTF0(_CRT_WARN,"CSerial::Write - Overlapped I/O is disabled, specified parameters are illegal.\n");
		return m_lLastError;
	}

	// Wait for the event to happen
	OVERLAPPED ovInternal;
	if (!lpOverlapped && m_hevtOverlapped)
	{
		// Setup our own overlapped structure
		memset(&ovInternal,0,sizeof(ovInternal));
		ovInternal.hEvent = m_hevtOverlapped;

		// Use our internal overlapped structure
		lpOverlapped = &ovInternal;
	}

	// Make sure the overlapped structure isn't busy
	_ASSERTE(!m_hevtOverlapped || HasOverlappedIoCompleted(lpOverlapped));

	// Write the data
	if (!::WriteFile(m_hFile,pData,iLen,pdwWritten,lpOverlapped))
	{
		// Set the internal error code
		long lLastError = ::GetLastError();

		// Overlapped operation in progress is not an actual error
		if (lLastError != ERROR_IO_PENDING)
		{
			// Save the error
			m_lLastError = lLastError;

			// Issue an error and quit
			_RPTF0(_CRT_WARN,"CSerial::Write - Unable to write the data\n");
			return m_lLastError;
		}

		// We need to block if the client didn't specify an overlapped structure
		if (lpOverlapped == &ovInternal)
		{
			// Wait for the overlapped operation to complete
			switch (::WaitForSingleObject(lpOverlapped->hEvent,dwTimeout))
			{
			case WAIT_OBJECT_0:
				// The overlapped operation has completed
				if (!::GetOverlappedResult(m_hFile,lpOverlapped,pdwWritten,FALSE))
				{
					// Set the internal error code
					m_lLastError = ::GetLastError();

					_RPTF0(_CRT_WARN,"CSerial::Write - Overlapped completed without result\n");
					return m_lLastError;
				}
				break;

			case WAIT_TIMEOUT:
				// Cancel the I/O operation
				CancelCommIo();

				// The operation timed out. Set the internal error code and quit
				m_lLastError = ERROR_TIMEOUT;
				return m_lLastError;

			default:
				// Set the internal error code
				m_lLastError = ::GetLastError();

				// Issue an error and quit
				_RPTF0(_CRT_WARN,"CSerial::Write - Unable to wait until data has been sent\n");
				return m_lLastError;
			}
		}
	}
	else
	{
		// The operation completed immediatly. Just to be sure
		// we'll set the overlapped structure's event handle.
		if (lpOverlapped)
			::SetEvent(lpOverlapped->hEvent);
	}

#else

	// Write the data
	if (!::WriteFile(m_hFile,pData,iLen,pdwWritten,0))
	{
		// Set the internal error code
		m_lLastError = ::GetLastError();

		// Issue an error and quit
		_RPTF0(_CRT_WARN,"CSerial::Write - Unable to write the data\n");
		return m_lLastError;
	}

#endif

	// Return successfully
	return m_lLastError;
}
コード例 #7
0
ファイル: Valgrind.cpp プロジェクト: stahta01/EmBlocks
void Valgrind::OnCachegrind(wxCommandEvent& )
{
	wxString ExeTarget;
	wxString CommandLineArguments;
	if(!CheckRequirements(ExeTarget, CommandLineArguments))
	{
		return;
	}
	DoValgrindVersion();
//	wxString CommandLine = _("valgrind --tool=cachegrind --cachegrind-out-file=\"./") + ExeTarget + _(".cachegrind.out\" \"") + ExeTarget + _("\" ") + CommandLineArguments;
	wxString CommandLine = _T("valgrind --tool=cachegrind \"") + ExeTarget + _T("\" ") + CommandLineArguments;
	AppendToLog(CommandLine);
	wxArrayString Output, Errors;
	wxString CurrentDirName = ::wxGetCwd();
	wxDir CurrentDir(CurrentDirName);
	wxArrayString CachegrindFiles;
	if(CurrentDir.IsOpened())
	{
		wxString File;
		if(CurrentDir.GetFirst(&File, _T("cachegrind.out.*"), wxDIR_FILES))
		{
			CachegrindFiles.Add(File);
			while(CurrentDir.GetNext(&File))
			{
				CachegrindFiles.Add(File);
			} // end while
		}
	}
	wxExecute(CommandLine, Output, Errors);
	size_t Count = Output.GetCount();
	for(size_t idxCount = 0; idxCount < Count; ++idxCount)
	{
		AppendToLog(Output[idxCount]);
	} // end for : idx: idxCount
	Count = Errors.GetCount();
	for(size_t idxCount = 0; idxCount < Count; ++idxCount)
	{
		AppendToLog(Errors[idxCount]);
	} // end for : idx: idxCount
	// try to find out how the file is named --> cachegrind.out.21807 [cachegrind.out.pid]
	// or To use an output file name other than the default cachegrind.out, use the --cachegrind-out-file  switch.
	// http://docs.wxwidgets.org/stable/wx_wxdir.html#wxdirgetfirst
	// idea : store all cachegrind.out.* filenames, and at finish do the same thing, and when one
	// is not in that list --> the new one
	wxString TheCachegrindFile;
	if(CurrentDir.IsOpened())
	{
		wxString File;
		if(CurrentDir.GetFirst(&File, _T("cachegrind.out.*"), wxDIR_FILES))
		{
			if(CachegrindFiles.Index(File) == wxNOT_FOUND)
			{
				TheCachegrindFile = File;
			}
			while(CurrentDir.GetNext(&File) && TheCachegrindFile.IsEmpty())
			{
				if(CachegrindFiles.Index(File) == wxNOT_FOUND)
				{
					TheCachegrindFile = File;
					AppendToLog(File);
				}
			} // end while
		}
	}
	CommandLine = _T("kcachegrind ") + TheCachegrindFile;
	wxExecute(CommandLine);
} // end of OnCachegrind
コード例 #8
0
ファイル: Valgrind.cpp プロジェクト: stahta01/EmBlocks
void Valgrind::OnMemCheck(wxCommandEvent& )
{
	wxString ExeTarget;
	wxString CommandLineArguments;
	if(!CheckRequirements(ExeTarget, CommandLineArguments))
	{
		return;
	}
	long Version = DoValgrindVersion();
	const wxString XmlOutputFile = _T("ValgrindOut.xml");
	wxString XmlOutputCommand;
	if(Version >= 350)
	{
		XmlOutputCommand = _T(" --xml-file=") + XmlOutputFile;
	}
	const bool UseXml = true;
	wxString CommandLine = _T("valgrind --leak-check=yes --xml=yes") + XmlOutputCommand + _T(" \"")
		+ ExeTarget + _T("\" ") + CommandLineArguments;
//	CommandLine = _("valgrind --leak-check=yes \"") + ExeTarget + _("\" ") + CommandLineArguments;
	AppendToLog(CommandLine);
	wxArrayString Output, Errors;
	wxExecute(CommandLine, Output, Errors);
	size_t Count = Output.GetCount();
	for(size_t idxCount = 0; idxCount < Count; ++idxCount)
	{
		// EXTRA NOTE : it seems the output from valgrind comes on the error channel, not here !!!
		// it seems that all valgrind stuff starts with == (in case of not xml)
		// filter on that, so we can remove regular output from the tested exe
//		if(Output[idxCount].StartsWith(_("==")))
		{
			AppendToLog(Output[idxCount]);
		}
	} // end for : idx: idxCount
	wxString Xml;
	Count = Errors.GetCount();
	for(size_t idxCount = 0; idxCount < Count; ++idxCount)
	{
		Xml += Errors[idxCount];
		AppendToLog(Errors[idxCount]);
	} // end for : idx: idxCount
	if(UseXml)
	{
		TiXmlDocument Doc;
		if(Version >= 350)
		{
			Doc.LoadFile(XmlOutputFile.ToAscii());
		}
		else
		{
			Doc.Parse(Xml.ToAscii());
		}
		if(!Doc.Error())
		{
			bool ErrorsPresent = false;
			TiXmlHandle Handle(&Doc);
			Handle = Handle.FirstChildElement("valgrindoutput");
			for(const TiXmlElement* Error = Handle.FirstChildElement("error").ToElement(); Error;
					Error = Error->NextSiblingElement("error"))
			{
				ErrorsPresent = true;
				wxString WhatValue;
				if(const TiXmlElement* What = Error->FirstChildElement("xwhat"))
				{	// style use since Valgrind 3.5.0
					if(const TiXmlElement* Text = What->FirstChildElement("text"))
					{
						WhatValue = wxString::FromAscii(Text->GetText());
					}
				}
				else if(const TiXmlElement* What = Error->FirstChildElement("what"))
				{
					WhatValue = wxString::FromAscii(What->GetText());
				}
				// process the first stack
				if(const TiXmlElement* Stack = Error->FirstChildElement("stack"))
				{
					ProcessStack(*Stack, WhatValue);
				}
			} // end for
			if(ErrorsPresent)
			{
				if(Manager::Get()->GetLogManager())
				{
					CodeBlocksLogEvent evtSwitch(cbEVT_SWITCH_TO_LOG_WINDOW, m_ListLog);
					Manager::Get()->ProcessEvent(evtSwitch);
				}
			}
		}
		// loop over the errors
	}
} // end of OnMemCheck
コード例 #9
0
ファイル: Serial.cpp プロジェクト: igusGmbH/igusMotionEditor
LONG CSerial::WaitEvent (DWORD dwTimeout, LPOVERLAPPED lpOverlapped)
{
	// Check if time-outs are supported
	CheckRequirements(lpOverlapped,dwTimeout);

	// Reset error state
	m_lLastError = ERROR_SUCCESS;

	// Check if the device is open
	if (m_hFile == 0)
	{
		// Set the internal error code
		m_lLastError = ERROR_INVALID_HANDLE;

		// Issue an error and quit
		qDebug() << ("CSerial::WaitEvent - Device is not opened\n");
		return m_lLastError;
	}

#ifndef SERIAL_NO_OVERLAPPED

	// Check if an overlapped structure has been specified
	if (!m_hevtOverlapped && (lpOverlapped || (dwTimeout != INFINITE)))
	{
		// Set the internal error code
		m_lLastError = ERROR_INVALID_FUNCTION;

		// Issue an error and quit
		qDebug() << ("CSerial::WaitEvent - Overlapped I/O is disabled, specified parameters are illegal.\n");
		return m_lLastError;
	}

	// Wait for the event to happen
	OVERLAPPED ovInternal;
	if (!lpOverlapped && m_hevtOverlapped)
	{
		// Setup our own overlapped structure
		memset(&ovInternal,0,sizeof(ovInternal));
		ovInternal.hEvent = m_hevtOverlapped;

		// Use our internal overlapped structure
		lpOverlapped = &ovInternal;
	}

	// Make sure the overlapped structure isn't busy
	//_ASSERTE(!m_hevtOverlapped || HasOverlappedIoCompleted(lpOverlapped));

	// Wait for the COM event
	if (!::WaitCommEvent(m_hFile,LPDWORD(&m_eEvent),lpOverlapped))
	{
		// Set the internal error code
		long lLastError = ::GetLastError();

		// Overlapped operation in progress is not an actual error
		if (lLastError != ERROR_IO_PENDING)
		{
			// Save the error
			m_lLastError = lLastError;

			// Issue an error and quit
			//qDebug() << ("CSerial::WaitEvent - Unable to wait for COM event\n");
			return m_lLastError;
		}

		// We need to block if the client didn't specify an overlapped structure
		if (lpOverlapped == &ovInternal)
		{
			// Wait for the overlapped operation to complete
			switch (::WaitForSingleObject(lpOverlapped->hEvent,dwTimeout))
			{
			case WAIT_OBJECT_0:
				// The overlapped operation has completed
				break;

			case WAIT_TIMEOUT:
				// Cancel the I/O operation
				CancelCommIo();

				// The operation timed out. Set the internal error code and quit
				m_lLastError = ERROR_TIMEOUT;
				return m_lLastError;

			default:
				// Set the internal error code
				m_lLastError = ::GetLastError();

				// Issue an error and quit
				qDebug() << ("CSerial::WaitEvent - Unable to wait until COM event has arrived\n");
				return m_lLastError;
			}
		}
	}
	else
	{
		// The operation completed immediatly. Just to be sure
		// we'll set the overlapped structure's event handle.
		if (lpOverlapped)
			::SetEvent(lpOverlapped->hEvent);
	}
#else

	// Wait for the COM event
	if (!::WaitCommEvent(m_hFile,LPDWORD(&m_eEvent),0))
	{
		// Set the internal error code
		m_lLastError = ::GetLastError();

		// Issue an error and quit
		qDebug() << ("CSerial::WaitEvent - Unable to wait for COM event\n");
		return m_lLastError;
	}

#endif

	// Return successfully
	return m_lLastError;
}
コード例 #10
0
ファイル: Serial.cpp プロジェクト: igusGmbH/igusMotionEditor
int CSerial::read(void* pData, size_t iLen, DWORD* pdwRead, LPOVERLAPPED lpOverlapped, DWORD dwTimeout)
{
	// Check if time-outs are supported
	CheckRequirements(lpOverlapped,dwTimeout);

	// Overlapped operation should specify the pdwRead variable
	//_ASSERTE(!lpOverlapped || pdwRead);

	// Reset error state
	m_lLastError = ERROR_SUCCESS;

	// Use our own variable for read count
	DWORD dwRead;
	if (pdwRead == 0)
	{
		pdwRead = &dwRead;
	}

	// Reset the number of bytes read
	*pdwRead = 0;

	// Check if the device is open
	if (m_hFile == 0)
	{
		// Set the internal error code
		m_lLastError = ERROR_INVALID_HANDLE;

		// Issue an error and quit
		qDebug() << ("CSerial::Read - Device is not opened\n");
		//return m_lLastError;
		return -1;
	}

#ifdef _DEBUG
	// The debug version fills the entire data structure with
	// 0xDC bytes, to catch buffer errors as soon as possible.
	memset(pData,0xDC,iLen);
#endif

#ifndef SERIAL_NO_OVERLAPPED

	// Check if an overlapped structure has been specified
	if (!m_hevtOverlapped && (lpOverlapped || (dwTimeout != INFINITE)))
	{
		// Set the internal error code
		m_lLastError = ERROR_INVALID_FUNCTION;

		// Issue an error and quit
		qDebug() << ("CSerial::Read - Overlapped I/O is disabled, specified parameters are illegal.\n");
		//return m_lLastError;
		return -1;
	}

	// Wait for the event to happen
	OVERLAPPED ovInternal;
	if (lpOverlapped == 0)
	{
		// Setup our own overlapped structure
		memset(&ovInternal,0,sizeof(ovInternal));
		ovInternal.hEvent = m_hevtOverlapped;

		// Use our internal overlapped structure
		lpOverlapped = &ovInternal;
	}

	// Make sure the overlapped structure isn't busy
	//_ASSERTE(!m_hevtOverlapped || HasOverlappedIoCompleted(lpOverlapped));
	
	// Read the data
	if (!::ReadFile(m_hFile,pData,iLen,pdwRead,lpOverlapped))
	{
		// Set the internal error code
		long lLastError = ::GetLastError();

		int bytesRead = *pdwRead;

		// Overlapped operation in progress is not an actual error
		if (lLastError != ERROR_IO_PENDING)
		{
			// Save the error
			m_lLastError = lLastError;

			// Issue an error and quit
			qDebug() << ("CSerial::Read - Unable to read the data\n");
			//return m_lLastError;
			return -1;
		}

		// We need to block if the client didn't specify an overlapped structure
		if (lpOverlapped == &ovInternal)
		{
			// Wait for the overlapped operation to complete
			switch (::WaitForSingleObject(lpOverlapped->hEvent,dwTimeout))
			{
				case WAIT_OBJECT_0:

					// The overlapped operation has completed
					if (!::GetOverlappedResult(m_hFile,lpOverlapped,pdwRead,FALSE))
					{
						// Set the internal error code
						m_lLastError = ::GetLastError();

						qDebug() << ("CSerial::Read - Overlapped completed without result\n");
						//return m_lLastError;
					}


					return bytesRead;

				case WAIT_TIMEOUT:

					// Cancel the I/O operation
					CancelCommIo();

					// The operation timed out. Set the internal error code and quit
					m_lLastError = ERROR_TIMEOUT;
					//return m_lLastError;
					return bytesRead;

				default:

					// Set the internal error code
					m_lLastError = ::GetLastError();

					// Issue an error and quit
					qDebug() << ("CSerial::Read - Unable to wait until data has been read\n");
					//return m_lLastError;
					return -1;
			}
		}
	}
	else
	{
		// The operation completed immediately. Just to be sure
		// we'll set the overlapped structure's event handle.
		if (lpOverlapped)
			::SetEvent(lpOverlapped->hEvent);

		return *pdwRead;
	}

#else
	
	// Read the data
	if (!::ReadFile(m_hFile,pData,iLen,pdwRead,0))
	{
		// Set the internal error code
		m_lLastError ::GetLastError()));

		// Issue an error and quit
		qDebug() << ("CSerial::Read - Unable to read the data\n");
		return m_lLastError;
	}
コード例 #11
0
ファイル: main.c プロジェクト: BackupTheBerlios/geoirc
/* The main installer code */
int main(int argc, char **argv)
{
    int exit_status, get_out = 0;
    int i, c;
    install_state state;
    char *xml_file = SETUP_CONFIG;
    log_level verbosity = LOG_NORMAL;
    char install_path[PATH_MAX];
    char binary_path[PATH_MAX];
	const char *product_prefix = NULL, *str;
    struct enabled_option *enabled_opt;
#if defined(darwin)
    // If we're on Mac OS, we need to make sure the current working directoy
    //  is the same directoy as the .APP is in.  With Mac OS X, running from
    //  the finder and most other places makes the current directory to root.
#define CARBON_MAX_PATH 1024
    char carbon_app_path[CARBON_MAX_PATH];
    carbon_GetAppPath(carbon_app_path, CARBON_MAX_PATH);
    chdir(carbon_app_path);
#endif
    install_path[0] = '\0';
    binary_path[0] = '\0';

    /* Set a good default umask value (022) */
    umask(DEFAULT_UMASK);

	/* Set the locale */
	setlocale (LC_ALL, "");
	bindtextdomain (PACKAGE, LOCALEDIR);
	textdomain (PACKAGE);

	DetectLocale();

    /* Parse the command-line options */
    while ( (c=getopt(argc, argv,
#ifdef RPM_SUPPORT
					  "hnc:f:r:v:Vi:b:mo:p:"
#else
					  "hnc:f:v:Vi:b:o:p:"
#endif
					  )) != EOF ) {
        switch (c) {
		case 'c':
			if ( chdir(optarg) < 0 ) {
				perror(optarg);
				exit(3);
			}
			break;
		case 'f':
			xml_file = optarg;
			break;
		case 'n':
			force_console = 1;
			break;
#ifdef RPM_SUPPORT
		case 'r':
			rpm_root = optarg;
			break;
#endif
		case 'v':
			if ( optarg ) {
				verbosity = atoi(optarg);
				if ( (verbosity < LOG_DEBUG) || (verbosity > LOG_FATAL) ){
					fprintf(stderr,
							_("Out of range value, setting verbosity level to normal.\n"));
					verbosity = LOG_NORMAL;
				}
			} else {
				verbosity = LOG_DEBUG;
			}
			break;
		case 'V':
			printf("Loki Setup version " SETUP_VERSION ", built on "__DATE__"\n");
			exit(0);
	    case 'i':
	        strncpy(install_path, optarg, sizeof(install_path));
			disable_install_path = 1;
 			break;
	    case 'b':
	        strncpy(binary_path, optarg, sizeof(binary_path));
			disable_binary_path = 1;
			break;
		case 'p':
			product_prefix = optarg;
			break;
        case 'o': /* Store the enabled options for later processing */
            enabled_opt = (struct enabled_option *)malloc(sizeof(struct enabled_option));
            enabled_opt->option = strdup(optarg);
            enabled_opt->next = enabled_options;
            enabled_options = enabled_opt;
            break;
#ifdef RPM_SUPPORT
	    case 'm':
	        force_manual = 1;
			break;
#endif
		default:
			print_usage(argv[0]);
			exit(0);
        }
    }

	InitPlugins();
	if ( verbosity == LOG_DEBUG ) {
		DumpPlugins(stderr);
	}

	log_init(verbosity);

    /* Initialize the XML setup configuration */
    info = create_install(xml_file, install_path, binary_path, product_prefix);
    if ( info == NULL ) {
        fprintf(stderr, _("Couldn't load '%s'\n"), xml_file);
        exit(3);
    }

    /* Get the appropriate setup UI */
    for ( i=0; GUI_okay[i]; ++i ) {
        if ( GUI_okay[i](&UI, &argc, &argv) ) {
            break;
        }
    }
    if ( ! GUI_okay[i] ) {
        log_debug(_("No UI drivers available\n"));
        exit(2);
    }

    /* Setup the interrupt handlers */
    state = SETUP_INIT;
    signal(SIGINT, signal_abort);
    signal(SIGQUIT, signal_abort);
    signal(SIGHUP, signal_abort);
    signal(SIGTERM, signal_abort);

    /* Run the little state machine */
    exit_status = 0;
    while ( ! get_out ) {
        char buf[1024];
        int num_cds = 0;

        switch (state) {
            case SETUP_INIT:
                num_cds = GetProductCDROMDescriptions(info);
                /* Check for the presence of a CDROM if required */
                if ( GetProductCDROMRequired(info) ) {
                    if ( ! GetProductCDROMFile(info) ) {
                        log_fatal(_("The 'cdromfile' attribute is now mandatory when using the 'cdrom' attribute."));
                    }
                    add_cdrom_entry(info, info->name, info->desc, GetProductCDROMFile(info));
					++ num_cds;
				}

                state = UI.init(info,argc,argv, enabled_options != NULL);
                if ( state == SETUP_ABORT ) {
                    exit_status = 3;
                }
				/* Check if getcwd() works now */
				if ( getcwd(buf, sizeof(buf)) == NULL ) {
					UI.prompt(_("Unable to determine the current directory.\n"
								"Please check the permissions of the parent directories.\n"), RESPONSE_OK);
					state = SETUP_EXIT;
					continue;
				}
                
				/* Check if we should be root.  Under the Mac, we'll do the standard authorization
                   stuff that most installers do at startup. */
                if ( GetProductRequireRoot(info) && geteuid()!=0 ) {
#if defined(darwin)
                carbon_AuthorizeUser();
                state = SETUP_EXIT;
                break;
#else
					UI.prompt(_("You need to run this installer as the super-user.\n"), RESPONSE_OK);
					state = SETUP_EXIT;
					continue;
#endif
                }

				if ( info->product && GetProductInstallOnce(info) ) {
					UI.prompt(_("\nThis product is already installed.\nUninstall it before running this program again.\n"), RESPONSE_OK);
					state = SETUP_EXIT;
					continue;
				}
				if ( info->product && GetProductReinstall(info) ) {
					UI.prompt(_("Warning: You are about to reinstall\non top of an existing installation.\n"), RESPONSE_OK);
					info->options.reinstalling = 1;
					/* Restore the initial environment */
					loki_put_envvars(info->product);
				}
                /* Check for the presence of the product if we install a component */
                if ( GetProductComponent(info) ) {
                    if ( GetProductNumComponents(info) > 0 ) {
                        UI.prompt(_("\nIllegal installation: do not mix components with a component installation.\n"), RESPONSE_OK);
                        state = SETUP_EXIT;
						continue;
                    } else if ( info->product ) {
                        if ( ! info->component ) {
                            snprintf(buf, sizeof(buf), _("\nThe %s component is already installed.\n"
                                                         "Please uninstall it beforehand.\n"),
                                     GetProductComponent(info));
                            UI.prompt(buf, RESPONSE_OK);
                            state = SETUP_EXIT;
							continue;
                        }
                    } else {                        
                        snprintf(buf, sizeof(buf), _("\nYou must install %s before running this\n"
													 "installation program.\n"),
                                info->desc);
                        UI.prompt(buf, RESPONSE_OK);
                        state = SETUP_EXIT;
						continue;
                    }
                }

                /* Check for the presence of a CDROM if required */
				if ( num_cds > 0) {
                    detect_cdrom(info);
                }
                if ( GetProductCDROMRequired(info) && ! get_cdrom(info, info->name) ) {
					state = SETUP_EXIT;
					break;
                }

				if ( ! CheckRequirements(info) ) {
					state = SETUP_ABORT;
					break;
				}

                if ( enabled_options ) {
                    enabled_opt = enabled_options;
                    while ( enabled_opt ) {
                        if ( enable_option(info, enabled_opt->option) == 0 ) {
                            log_warning(_("Could not enable option: %s"), enabled_opt->option);
                        }
                        enabled_opt = enabled_opt->next;
                    }
                    state = SETUP_INSTALL;
                }
                break;
	    case SETUP_CLASS:
			state = UI.pick_class(info);
		break;
            case SETUP_LICENSE:
                state = UI.license(info);
                break;
            case SETUP_README:
                state = UI.readme(info);
                break;
            case SETUP_OPTIONS:
                state = UI.setup(info);
                break;
            case SETUP_INSTALL:
                install_preinstall(info);
                state = install(info, UI.update);
                install_postinstall(info);
                break;
            case SETUP_WEBSITE:
                state = UI.website(info);
                break;
            case SETUP_COMPLETE:
                state = UI.complete(info);
				/* Check for a post-install message */
				str = GetProductPostInstallMsg(info);
				if ( str ) {
					UI.prompt(str, RESPONSE_OK);
				}
                break;
            case SETUP_PLAY:
		if ( UI.shutdown ) 
		    UI.shutdown(info);
                state = launch_game(info);
                break;
            case SETUP_ABORT:
                abort_install();
                break;
            case SETUP_EXIT:
                /* Optional cleanup */
				if ( UI.exit ) {
					UI.exit(info);
				}
				get_out = 1;
                break;
        }
    }

    /* Free enabled_options */
    while ( enabled_options ) {
        enabled_opt = enabled_options;
        enabled_options = enabled_options->next;
        free(enabled_opt->option);
        free(enabled_opt);
    }

    exit_setup(exit_status);
    return 0;
}
コード例 #12
0
void Valgrind::OnMemCheckRun(wxCommandEvent& /*event*/)
{
	wxString ExeTarget;
	wxString CommandLineArguments;
	wxString WorkDir;
	wxString DynamicLinkerPath;

	if(!CheckRequirements(ExeTarget, WorkDir, CommandLineArguments, DynamicLinkerPath))
	{
		return;
	}
	long Version = DoValgrindVersion();

	cbProject* Project = Manager::Get()->GetProjectManager()->GetActiveProject();

	const wxString XmlOutputFile = Project->GetBasePath() + _T("ValgrindOut.xml");
	wxString XmlOutputCommand;
	if(Version >= 350)
	{
		XmlOutputCommand = _T(" --xml-file=") + XmlOutputFile;
	}
	const bool UseXml = true;
    wxString CommandLine = BuildMemCheckCmd() + wxT(" --xml=yes") + XmlOutputCommand + _T(" \"");
    CommandLine += ExeTarget + _T("\" ") + CommandLineArguments;

	wxString OldWorkDir = wxGetCwd();
	wxSetWorkingDirectory(WorkDir);

    wxString OldLinkerPath;
    wxGetEnv(CB_LIBRARY_ENVVAR, &OldLinkerPath);
    DynamicLinkerPath = cbMergeLibPaths(OldLinkerPath, DynamicLinkerPath);
    wxSetEnv(CB_LIBRARY_ENVVAR, DynamicLinkerPath);
    AppendToLog(_("Setting dynamic linker path to: ") + DynamicLinkerPath);

	AppendToLog(_("Executing command: ") + CommandLine);
	AppendToLog(wxString(wxT("\n-------------- ")) + _("Application output") + wxT(" --------------"));
	wxArrayString Output, Errors;
	wxExecute(CommandLine, Output, Errors);

	wxSetWorkingDirectory(OldWorkDir);
    wxSetEnv(CB_LIBRARY_ENVVAR, OldLinkerPath);

	size_t Count = Output.GetCount();
	for(size_t idxCount = 0; idxCount < Count; ++idxCount)
	{
		// EXTRA NOTE : it seems the output from valgrind comes on the error channel, not here !!!
		// it seems that all valgrind stuff starts with == (in case of not xml)
		// filter on that, so we can remove regular output from the tested exe
//		if(Output[idxCount].StartsWith(_("==")))
		{
			AppendToLog(Output[idxCount]);
		}
	} // end for : idx: idxCount
	wxString Xml;
	Count = Errors.GetCount();
	for(size_t idxCount = 0; idxCount < Count; ++idxCount)
	{
		Xml += Errors[idxCount];
		AppendToLog(Errors[idxCount]);
	} // end for : idx: idxCount
	if(UseXml)
	{
        TiXmlDocument Doc;
        if(Version >= 350)
        {
            Doc.LoadFile(XmlOutputFile.ToAscii());
        }
        else
        {
            Doc.Parse(Xml.ToAscii());
        }
        ParseMemCheckXML(Doc);
	}
} // end of OnMemCheck
コード例 #13
0
ファイル: Cccc.cpp プロジェクト: stahta01/codeblocks_r7456
int Cccc::Execute()
{
    if(!CheckRequirements())
    {
        return -1;
    }

    cbProject* Project = Manager::Get()->GetProjectManager()->GetActiveProject();
    ::wxSetWorkingDirectory(Project->GetBasePath());
    const long Files = Project->GetFilesCount();
    wxString ListOfFileNames;
    for (int File = 0; File < Files; ++File)
    {
        ProjectFile* pf = Project->GetFile(File);
        ListOfFileNames += _T("\"") + pf->relativeFilename + _T("\" ");
    }

    wxString CommandLine = m_CcccApp + _T(" ") + ListOfFileNames.Trim();
    AppendToLog(CommandLine);
    wxArrayString Output, Errors;
    long pid = -1;
    {
        wxWindowDisabler disableAll;
        wxBusyInfo running(_("Running cccc... please wait (this may take several minutes)..."),
                           Manager::Get()->GetAppWindow());
        pid = wxExecute(CommandLine, Output, Errors);
    } // end lifetime of wxWindowDisabler, wxBusyInfo
    if (pid==-1)
    {
        bool failed = true;
        if (cbMessageBox(_("Failed to lauch cccc.\nDo you want to select the cccc executable?"),
                         _("Question"), wxICON_QUESTION | wxYES_NO, Manager::Get()->GetAppWindow()) == wxID_YES)
        {
            wxString filename = wxFileSelector(_("Select the cccc executable"));
            if (!filename.empty()) // otherwise the user selected cancel
            {
                // try again using the user-provided executable
                CommandLine = filename + _T(" ") + ListOfFileNames.Trim();
                AppendToLog(CommandLine);
                {
                    wxWindowDisabler disableAll;
                    wxBusyInfo running(_("Running cccc... please wait (this may take several minutes)..."),
                                       Manager::Get()->GetAppWindow());
                    pid = wxExecute(CommandLine, Output, Errors);
                } // end lifetime of wxWindowDisabler, wxBusyInfo
                if (pid==-1)
                {
                    failed = true;
                }
                else
                {
                    m_CcccApp = filename;
                    failed = false;
                }
            }
        }
        if (failed)
        {
            AppendToLog(_("Failed to lauch cccc."));
            cbMessageBox(_("Failed to lauch cccc."), _("Error"), wxICON_ERROR | wxOK, Manager::Get()->GetAppWindow());
            return -1;
        }
    }

    size_t Count = Output.GetCount();
    for(size_t idxCount = 0; idxCount < Count; ++idxCount)
    {
        AppendToLog(Output[idxCount]);
    } // end for : idx: idxCount
    Count = Errors.GetCount();
    for(size_t idxCount = 0; idxCount < Count; ++idxCount)
    {
        AppendToLog(Errors[idxCount]);
    } // end for : idx: idxCount
    const wxString FileName = _T("./.cccc/cccc.html");
    if(wxFile::Exists(FileName))
    {
        if (cbMimePlugin* p = Manager::Get()->GetPluginManager()->GetMIMEHandlerForFile(FileName))
        {
            p->OpenFile(FileName);
        }
    }

    return 0;
} // end of Execute