Ejemplo n.º 1
0
	int urlDecode(const char* in, int inLen, StreamWriter& sw) {
		//XXX: dangerous (potentially exploitable) codepath; please audit
		char* ch = sw.beginWrite(inLen);
		int len = doURLDecode(in, inLen, ch);
		sw.endWrite(len);
		return len;
	}
Ejemplo n.º 2
0
ACE_Message_Block* UdpCmdSyncId::serialize( ACE_UINT32 seqId,ACE_UINT32 chId,PeerID peerId )
{
	UdpCmdBase::serialize(seqId,chId,peerId);
	StreamWriter wr;
	wr.write((char*)&cmd_hdr_,SIZE_OF_CMD_HEADER);

	return wr.get_message_block();
}
Ejemplo n.º 3
0
		void Array2D::serialize(StreamWriter& s) const
		{
			s.setBER( count() );
			for(const_iterator it = begin(); it != end(); ++it) {
				if( !it->second->exists() ) continue;

				s.setBER( it->first );
				it->second->serialize(s);
			}
		}
Ejemplo n.º 4
0
	void Program::Run()
	{
		StreamWriter* sw = new StreamWriter(new String("test.txt"));
		sw->WriteLine(new String("Hi! I'm a stream writer"));
		sw->Flush();
		sw->Close();
		StreamReader* sr = new StreamReader(new String("test.txt"));
		String* text = sr->ReadToEnd();
		sr->Close();
		Console::WriteLine(text);
	}
Ejemplo n.º 5
0
ACE_Message_Block* CmdJoin::serialize(ACE_UINT32 seqId,ACE_UINT32 chId,PeerID peerId)
{
	CmdBase::serialize(seqId,chId,peerId);

	StreamWriter wr;
	wr.write((char*)&cmd_hdr_,SIZE_OF_CMD_HEADER);

	wr.write_uint16(tcp_port_);
	wr.write_uint16(udp_port_);
	wr.write_uint16(version_);

	//加入本机的IP地址列表.what's this mean?

	return wr.get_message_block();
}
Ejemplo n.º 6
0
bool NetMgr_Android_Impl::SendNetMessage(INetMsgBase* pMsg)
{
	StreamWriter writer;
	if (!pMsg->ToStream(&writer))
	{
		LOGE("SendNetMessage %s::ToStream failed", pMsg->GetRtti()->GetTypeName());
		return false;
	}

	int length = writer.GetBufferSize();
	const void* pszBuffer = writer.GetBuffer();
	m_SendBuffer.Write(pszBuffer, length);

	SendOnce();
	return true;
}
Ejemplo n.º 7
0
void WriteFileComment(const WString& name, bool doNotModify, StreamWriter& writer)
{
	writer.WriteLine(L"/***********************************************************************");
	writer.WriteLine(L"Vczh Library++ 3.0");
	writer.WriteLine(L"Developer: Zihan Chen(vczh)");
	writer.WriteLine(L"GacUI::" + name);
	writer.WriteLine(L"");
	writer.WriteLine(L"This file is generated by: Vczh GacUI Resource Code Generator");
	if (doNotModify)
	{
		writer.WriteLine(L"************************************************************************");
		writer.WriteLine(L"DO NOT MODIFY");
	}
	writer.WriteLine(L"***********************************************************************/");
	writer.WriteLine(L"");
}
Ejemplo n.º 8
0
void WriteFileComment(const WString& name, StreamWriter& writer)
{
	writer.WriteLine(L"/***********************************************************************");
	writer.WriteLine(L"Vczh Library++ 3.0");
	writer.WriteLine(L"Developer: Zihan Chen(vczh)");
	writer.WriteLine(L"Parser::"+name);
	writer.WriteLine(L"");
	writer.WriteLine(L"This file is generated by: Vczh Parser Generator");
	writer.WriteLine(L"***********************************************************************/");
	writer.WriteLine(L"");
}
Ejemplo n.º 9
0
WString WriteNamespace(List<WString>& currentNamespaces, List<WString>& namespaces, StreamWriter& writer)
{
	vint common = 0;
	for (vint i = 0; i < currentNamespaces.Count() && i < namespaces.Count(); i++)
	{
		if (currentNamespaces[i] == namespaces[i])
		{
			common++;
		}
		else
		{
			break;
		}
	}

	for (vint i = 0; i < currentNamespaces.Count() - common; i++)
	{
		WString prefix;
		for (vint j = 0; j < currentNamespaces.Count() - i - 1; j++)
		{
			prefix += L"\t";
		}
		writer.WriteLine(prefix + L"}");
	}

	WString prefix;
	FOREACH_INDEXER(WString, ns, i, namespaces)
	{
		if (i >= common)
		{
			writer.WriteLine(prefix + L"namespace " + ns);
			writer.WriteLine(prefix + L"{");
		}
		prefix += L"\t";
	}

	CopyFrom(currentNamespaces, namespaces);
	return prefix;
}
Ejemplo n.º 10
0
void
SessionImpl::WritePackageHistory ()
{
    if (packageHistoryFile.length() == 0)
    {
        return;
    }
    StreamWriter writer (File::Open(packageHistoryFile,
                                    FileMode::Append,
                                    FileAccess::Write));
    for (vector<FileInfoRecord>::const_iterator
            it = fileInfoRecords.begin();
            it != fileInfoRecords.end();
            ++ it)
    {
        if (it->packageName.length() > 0)
        {
            writer.WriteLine (it->packageName);
        }
    }
    writer.Close ();
}
Ejemplo n.º 11
0
int main()
{
	StreamWriter infile ("a.txt",false);
	
	infile.writeChar('e');
	String tmp = "tomorrow is sunday";
	infile.writeChar('\n');
	infile.writeChars(tmp.getCStr(),4);
	for(size_t i = 0; i <= 5; ++i)
	{
		infile.writeChars(tmp.getCStr(),i);
		infile.writeChar('\n');
	}
	infile.writeLine(tmp);
	infile.writeString("this is a aaa test");
	infile.writeChar('\n');
	infile.writeString("jack is a man",' ');
	infile.writeChar('\n');
	
	

	infile.fclose();





	return 0;
}
Ejemplo n.º 12
0
int	main(int argc, char* argv[])
	{
	//open registry	and	delete all values set by FaultIntercepter (Initilize)
	RegistryKey	*LMachine =	RegistryKey::OpenRemoteBaseKey(RegistryHive::LocalMachine, System::Environment::MachineName);			 
	RegistryKey	*SKey =	LMachine->OpenSubKey("SOFTWARE", true);
	RegistryKey	*HKey =	 SKey->OpenSubKey("HolodeckEE",	true);
	try
		{
		HKey->DeleteSubKey("Outcome");
		HKey->DeleteSubKey("FaultIntercepterReady");
		HKey->DeleteSubKey("FaultReady");
		}catch(System::ArgumentException *ArgumentError){}

	String *path = System::Environment::CurrentDirectory;
	int	index =	path->IndexOf("Debug");

	if (index != -1)
		{
		path = path->Substring(0, index-1);
		}

	path = String::Concat(path,"\\Logs\\");
	Console::WriteLine("Logs in	{0}",path);

	//Begin	a streamwriter to output whether a fault has passed	or failed. 
	FileStream *DefaultFileStreamer;
	String *FaultFileLogName = String::Concat(path,	"DefaultLog.Log");
	DefaultFileStreamer	= new FileStream(FaultFileLogName, FileMode::OpenOrCreate, FileAccess::Write  );
	StreamWriter * DefaultWriter = new StreamWriter(DefaultFileStreamer);

	TestFaults *FaultTester	= new TestFaults();

	//load the functions and faults	xml	files to memory
	FaultTester->LoadFaultsXmlFile();
	FaultTester->LoadFunctionsXmlFile();

	//if no	arguments were entered then	notify user	and	exit
	if (argc ==	1)
		{
		Console::WriteLine("Please enter fault names as arguments!");
		Sleep(8000);
		return 0;
		}

	//initilize	detailed log files to record the return	values and errorcodes for each function
	//in a fault.
	String *DetailLogFile =	String::Concat(path,"LastRun-DetailLog.Log");
	FileStream *DetailLogStreamer;
	DetailLogStreamer =	new	FileStream(DetailLogFile, FileMode::OpenOrCreate , FileAccess::Write  );
	StreamWriter * DetailLogWriter = new StreamWriter(DetailLogStreamer);

	bool FaultOutcome =	false;

	for(int	arg=1;arg<argc;arg++)
		{
		//if just one fault	iss	being run then open	a log with the fault name
		if (argc == 2)
			{
			String *FaultFileLogName = String::Concat(path,argv[arg],".Log");
			FileStream *FileStreamer;
			FileStreamer = new FileStream(FaultFileLogName,	FileMode::OpenOrCreate,	FileAccess::Write );
			StreamWriter * Writer =	new	StreamWriter(FileStreamer);
			Console::WriteLine("Currently running {0} fault...", Convert::ToString(argv[arg]));
			FaultOutcome = FaultTester->TestFault(argv[arg],Writer,DetailLogWriter);
			Writer->Close();
			}

		//if more than one argument	then load the default log to store all the faults that are to be run
		if(argc > 2)
			{
			FaultOutcome = FaultTester->TestFault(argv[arg],DefaultWriter,DetailLogWriter);
			}

		RegistryKey	*PassFail =	HKey->CreateSubKey("Outcome");

		if(FaultOutcome	== true)
			{
			PassFail->SetValue("Outcome",static_cast<String	*>("PASS"));
			}
		else 
			{
			PassFail->SetValue("Outcome",static_cast<String	*>("FAIL"));
			}
		FaultOutcome = false;
		}
	//close	all	open writers
	DefaultWriter->Close();
	DetailLogWriter->Close();
	Console::ReadLine();
	return 0;
	}
Ejemplo n.º 13
0
///*************************************************************************
/// Method:		TestFault
/// Description: Tests the fault name specified
///
/// Parameters:
///	faultName - The name of the fault in faults.xml to be tested
///
/// Return Value: true if successful, false otherwise
///*************************************************************************
bool FaultsTest::TestFault(char *faultName){
	//OUTPUT PASSFAIL TO A FILE
	FileStream *FileStreamer;
	FileStreamer = new FileStream("FAULTSTEST.TXT", FileMode::Create  , FileAccess::Write);
	StreamWriter * pWriter = new StreamWriter(FileStreamer);

	Console::WriteLine("---------->TestFault Method Begins<----------\n");

	//Load the Faults xml file in memory using FaultsXMLFramework
	LoadFaultsXmlFile("faults.xml");
	//Load the Functions xml file in memory using FunctionsXMLFramework
	LoadFunctionsXmlFile("functions.xml");

	bool bSuccess=true;

	Hashtable *myHT = new Hashtable();
	myHT=dynamic_cast<Hashtable *>(faultNavigatorInstance->FaultTableByName->Clone());
	IDictionaryEnumerator *faultsEnum=myHT->GetEnumerator();
	Console::WriteLine("OUTPUT FILE:FAULTTEST.TXT\n");

	while (faultsEnum->MoveNext()){
		DWORD ReturnValue=0;
		DWORD ErrorCode=0;

		Fault *fault=dynamic_cast<Fault *>(faultsEnum->get_Value());
		ReturnValue=(Convert::ToInt32(fault->get_ReturnValue()));
		ErrorCode=(Convert::ToInt32(fault->get_ErrorCode()));

		if (System::String::Compare(fault->get_Name(),faultName)==0)
			{
			ArrayList *funcList=fault->Function;
			Console::WriteLine(S"{0} Fault has {1} functions",fault->Name,__box(funcList->Count));
			pWriter->WriteLine("\n-------->   {0} Fault has {1} functions    <-------\n", fault->Name,__box(funcList->Count));
			//cycle through all functions 
			for(int ifuncs=0;ifuncs<funcList->Count;ifuncs++)
				{
				FaultFunction *thisfunc=dynamic_cast<FaultFunction *>(funcList->get_Item(ifuncs));
					{
					//****Search for a specific function--->TEST
					//if (System::String::Compare(thisfunc->get_Name(),"WSARecv")==0)
					//	{
					if(thisfunc->get_OverrideErrorCode()!=NULL){
						ErrorCode=(Convert::ToInt32(thisfunc->get_OverrideErrorCode()));
						}
				if(thisfunc->get_OverrideReturnValue()!=NULL){
					ReturnValue=(Convert::ToInt32(thisfunc->get_OverrideReturnValue()));
					}

			ArrayList *matchArray=thisfunc->get_MatchParams();

			ArrayList *paramsToSendToCallFunction = FillParamArray(convertGCStringToNative(thisfunc->Name),matchArray);

			if (CallFunction(thisfunc->get_Name(),paramsToSendToCallFunction,ReturnValue,ErrorCode) == true)
				{
				//Console::WriteLine("The function {0} has Passed.",thisfunc->Name);
				pWriter->WriteLine("{0} has Passed!",thisfunc->Name);
				bSuccess=true;
				}
			else 
				{	
				//Console::WriteLine("The function {0} has Failed.",thisfunc->Name);
				pWriter->WriteLine("{0} has Failed!",thisfunc->Name);
				bSuccess=false;
				}

					}
				//}
			}
			}
		}

Console::WriteLine("\n---------->TestFault Method Ends<------------\n");
pWriter->Close();
return bSuccess;	
	}
Ejemplo n.º 14
0
	void Cancel::serialize( StreamWriter& writer ) const {
		writer.write(&msgId, sizeof(msgId));
	}