Пример #1
0
  ObjectInfo Resolver::FindPath(const string &path) const
  {
    ObjectInfo oi = ParsePath(path);

    if (oi.object.id != "")
    {
      if (oi.project.id == "")
        oi.project.id = FindProject(oi.project.name);

      DescribeObject(oi.project.id, oi.object.id, oi);

      oi.project.name = GetProjectName(oi.project.id);
    }
    else
    {
      if (oi.project.id == "")
        oi.project.id = FindProject(oi.project.name);
      else
        oi.project.name = GetProjectName(oi.project.id);

      if (oi.project.id != "")
        LookupPath(oi.project.id, oi.object.name, oi.object.folder, oi);
    }
    return oi;
  }
Пример #2
0
/**
  * Start message service in listening thread
  * TODO: Start a new background thread to receive message
  */
bool UNetworkManager::StartMessageService(FSocket* ClientSocket, const FIPv4Endpoint& ClientEndpoint)
{
	if (!this->ConnectionSocket)
	{
		ConnectionSocket = ClientSocket;

		UE_LOG(LogUnrealCV, Warning, TEXT("New client connected from %s"), *ClientEndpoint.ToString());
		// ClientSocket->SetNonBlocking(false); // When this in blocking state, I can not use this socket to send message back
		FString Confirm = FString::Printf(TEXT("connected to %s"), *GetProjectName());
		bool IsSent = this->SendMessage(Confirm); // Send a hello message
		if (!IsSent)
		{
			UE_LOG(LogUnrealCV, Error, TEXT("Failed to send welcome message to client."));
		}

		// TODO: Start a new thread
		while (this->ConnectionSocket) // Listening thread, while the client is still connected
		{
			FArrayReader ArrayReader;
      bool unknown_error = false;
			if (!FSocketMessageHeader::ReceivePayload(ArrayReader, ConnectionSocket, &unknown_error))
				// Wait forever until got a message, or return false when error happened
			{
        if (unknown_error) {
          BroadcastError(FString("ReceivePayload failed with unknown error"));
        }
				this->ConnectionSocket = NULL;
				return false; // false will release the ClientSocket
				break; // Remote socket disconnected
			}

			FString Message = StringFromBinaryArray(ArrayReader);
			BroadcastReceived(Message);
			// Fire raw message received event, use message id to connect request and response
			UE_LOG(LogUnrealCV, Warning, TEXT("Receive message %s"), *Message);
		}
		return false; // TODO: What is the meaning of return value?
	}
	else
	{
		// No response and let the client silently timeout
		UE_LOG(LogUnrealCV, Warning, TEXT("Only one client is allowed, can not allow new connection from %s"), *ClientEndpoint.ToString());
		return false; // Already have a connection
	}
}
//---------------------------------------------------
//
void	TargetNode::WritePDFFileOptions()
{
	OptionNode	*pOption = GetCompileOptions();
	if ( GetType() == TARGET_PROJECT )
		{
		fprintf(filePDF, "* %s", GetProjectName() );
		while ( pOption )
			{
			 fprintf(filePDF, " -%s", pOption->GetOptionText() );
			 pOption= pOption->GetNext();
			}
		fprintf( filePDF, "\n");

		TargetNode	*pTarget = GetFirstChildC();
		while ( pTarget )
			{
			 pTarget->WritePDFFileOptions();
			 pTarget= pTarget->GetNext();
			}
		pTarget = GetFirstChildPRJ();
		while ( pTarget )
			{
			 pTarget->WritePDFFileOptions();
			 pTarget= pTarget->GetNext();
			}
		}

	else if ( GetType() == TARGET_FILE_C  &&  pOption )
		{
		 char				szFilePath[_MAX_PATH];
		 
		 InternalConvertFileName( GetFilePath(), szFilePath );
		 fprintf(filePDF, "%s", szFilePath );
		 while ( pOption )
				{
				 fprintf(filePDF, " -%s", pOption->GetOptionText() );
				 pOption= pOption->GetNext();
				}
		 fprintf( filePDF, "\n");
		}
}
void	TargetNode::SetProjectPath()
{
	if ( GetType() != TARGET_PROJECT )
		return;

	if ( this == GetMakeFileTarget() )
	{
	 m_pszProjectPath = new char [3] ;
	 strcpy( m_pszProjectPath, ".\\" );
	}
	else
	{
	char*		pParentPath = GetParentPRJ()->GetProjectPath();
	char*		pProjectTextBeg = GetProjectName();
	char*		pProjectTextEnd = strchr( pProjectTextBeg, ' ');
	int			nProjectTextLen, nParentTextLen = strlen(pParentPath);

	if ( pProjectTextEnd )
		 nProjectTextLen = pProjectTextEnd - pProjectTextBeg;
	else
		 nProjectTextLen = strlen( pProjectTextBeg );

	m_pszProjectPath = new char [ nParentTextLen + 1 + nProjectTextLen +1 ];
	if ( m_pszProjectPath )
		{
		 strcpy( m_pszProjectPath, pParentPath );
		 memcpy( m_pszProjectPath+ nParentTextLen, pProjectTextBeg, nProjectTextLen);
		 *(m_pszProjectPath+ nParentTextLen + nProjectTextLen ) = '\0';
		 strcat( m_pszProjectPath, "\\" );
		}

	}	// else //if ( this == GetMakeFileTarget() )

	//---------------------------------------------
	TargetNode* pTarget = GetFirstChildPRJ();
	while ( pTarget )
		{
		 pTarget->SetProjectPath();
		 pTarget = pTarget->GetNext();
		}
}
//---------------------------------------------------
//
void	TargetNode::WritePDFTree(int nTabs)
{
	char*		pszTabs;
	int			nTabsNew;
	char		szOptFileName[_MAX_PATH+1], szCmdPath[_MAX_PATH+1];

	if ( GetType() == TARGET_PROJECT )
		{
		pszTabs = new char [ nTabs +PDF_FILE_INDENT+1];
		memset( pszTabs,' ', nTabs );
		*(pszTabs+nTabs) = '\0';

		fprintf( filePDF, "\n");
		if ( GetParentPRJ() == GetMakeFileTarget() )
			fprintf( filePDF, "%s%s\t: %s\t<->\t/%s  {", pszTabs, GetProjectName(), GetFilePath(),
																										GetProjectName() );
		else
			 fprintf( filePDF, "%s%s\t: %s\t<->\t%s  {", pszTabs, GetProjectName(),
																										GetFileName(), GetProjectName() );
		
		fprintf( filePDF, "\n");
		GetDisRegistryStr("DiscoverDir", szOptFileName, sizeof(szOptFileName), "c:\\");
		InternalConvertFileName( szOptFileName, szCmdPath );
		InternalConvertFileName( gszOptFileName, szOptFileName );
		if ( GetSlash() == '\\' )
		{
		fprintf( filePDF, "%s  : (**)/(*).(c*) /%%/.make", pszTabs );
		fprintf( filePDF, " => \"PDFOpt %s %s (1)/(2).(3)\" ", szOptFileName, GetProjectName() );
		}
		else
		{
		fprintf( filePDF, "%s  : /(**)/(*).(c*) /%%/.make", pszTabs );
		fprintf( filePDF, " => \"PDFOpt %s %s /(1)/(2).(3)\" ", szOptFileName, GetProjectName() );
		}
		fprintf( filePDF, "\n");
		delete [] pszTabs;

		GetNodeFILE()->WritePDFTree(nTabs+PDF_FILE_INDENT);

		TargetNode*	pTargetPRJ = GetFirstChildPRJ();
		while ( pTargetPRJ )
			{
			 pTargetPRJ->WritePDFTree( nTabs+PDF_FILE_INDENT );
			 pTargetPRJ = pTargetPRJ->GetNext();
			}
		
		pszTabs = new char [ nTabs +PDF_FILE_INDENT+1];
		memset( pszTabs,' ', nTabs );
		*(pszTabs+nTabs) = '\0';
		fprintf( filePDF, "%s}", pszTabs);
		fprintf( filePDF, "\n");
		delete [] pszTabs;
		}

	//---------------------------------------------------------
	else if ( GetType() == NODE_FILE || GetType() == NODE_FILE_C || GetType() == NODE_FILE_H )
		{
		if ( GetFileName() )
			{
			pszTabs = new char [ nTabs +PDF_FILE_INDENT+1];
			memset( pszTabs,' ', nTabs );
			*(pszTabs+nTabs) = '\0';
			fprintf ( filePDF, "%s%s\n%s{", pszTabs, GetFileName(), pszTabs );
			fprintf( filePDF, "\n");
			nTabsNew = nTabs + 2;
			delete [] pszTabs;
			}
		else 
			nTabsNew = nTabs;

		if ( GetType() == NODE_FILE )
			{
			GetNodeH()->WritePDFTree(nTabsNew);
			GetNodeC()->WritePDFTree(nTabsNew);
			}
		else
			{
			pszTabs = new char [ nTabs +PDF_FILE_INDENT+1];
			memset( pszTabs,' ', nTabs );
			*(pszTabs+nTabs) = '\0';
			TargetNode*	pTarget = GetFirstChildTarget();
			while ( pTarget )
				{
				 if ( pTarget->GetExclusionFlag() )
						{
						 fprintf( filePDF, "%s  ^ %s", pszTabs, pTarget->GetFileName());
						 fprintf( filePDF, "\n");
						}
				 pTarget= pTarget->GetNext();
				}
			pTarget = GetFirstChildTarget();
			while ( pTarget )
				{
				 if ( !pTarget->GetExclusionFlag() )
						{
						 fprintf( filePDF, "%s    %s", pszTabs, pTarget->GetFileName());
						 fprintf( filePDF, "\n");
						}
				 pTarget= pTarget->GetNext();
				}
			}

		if ( GetFileName() )
			{
			pszTabs = new char [ nTabs +PDF_FILE_INDENT+1];
			memset( pszTabs,' ', nTabs );
			*(pszTabs+nTabs) = '\0';
			fprintf ( filePDF, "%s}\n", pszTabs );
			delete [] pszTabs;
			}
		}

}