コード例 #1
0
ファイル: Pipe.cpp プロジェクト: DKlaper/gsw-DepParser
void Pipe::Initialize() {
  CreateDictionary();
  CreateReader();
  CreateWriter();
  CreateDecoder();
  parameters_ = new Parameters;
}
コード例 #2
0
NullPhysicsComponent::NullPhysicsComponent(game::GameEntityManager*m)
{
	m_root=0;
	CPropertieDictionary* dic;
	if(CreateDictionary(&dic))
	{
		dic->addPropertie(&PropertyTypePosition::instance);
		dic->addPropertie(&PropertyTypeRotation::instance);
	}
}
コード例 #3
0
tTJSVariant* tTJSBinarySerializer::ReadDictionary( const tjs_uint8* buff, const tjs_uint size, const tjs_uint count, tjs_uint& index ) {
	if( index > size ) return NULL;

	tTJSDictionaryObject* dic = CreateDictionary( count );
	for( tjs_uint i = 0; i < count; i++ ) {
		tjs_uint8 type = buff[index];
		index++;
		// 最初に文字を読む
		tTJSVariantString* name = NULL;
		switch( type ) {
		case TYPE_STRING8: {
			if( (index+sizeof(tjs_uint8)) > size ) TJS_eTJSError( TJSReadError );
			tjs_uint8 len = buff[index]; index++;
			if( (index+(len*sizeof(tjs_char))) > size ) TJS_eTJSError( TJSReadError );
			name = ReadString( buff, len, index );
			break;
		}
		case TYPE_STRING16: {
			if( (index+sizeof(tjs_uint16)) > size ) TJS_eTJSError( TJSReadError );
			tjs_uint16 len = Read16( buff, index );
			if( (index+(len*sizeof(tjs_char))) > size ) TJS_eTJSError( TJSReadError );
			name = ReadString( buff, len, index );
			break;
		}
		case TYPE_STRING32: {
			if( (index+sizeof(tjs_uint32)) > size ) TJS_eTJSError( TJSReadError );
			tjs_uint32 len = Read32( buff, index );
			if( (index+(len*sizeof(tjs_char))) > size ) TJS_eTJSError( TJSReadError );
			name = ReadString( buff, len, index );
			break;
		}
		default:
			if( type >= TYPE_FIX_STRING_MIN && type <= TYPE_FIX_STRING_MAX ) {
				tjs_int len = type - TYPE_FIX_STRING_MIN;
				if( (len*sizeof(tjs_char)+index) > size ) TJS_eTJSError( TJSReadError );
				name = ReadString( buff, len, index );
			} else { // Dictionary形式の場合、最初に文字列がこないといけない
				 TJS_eTJSError( TJSReadError );
			}
			break;
		}
		// 次に要素を読む
		tTJSVariant* value = ReadBasicType( buff, size, index );
		AddDictionary( dic, name, value );
		delete value;
		name->Release();
	}
	tTJSVariant* ret = new tTJSVariant( dic, dic );
	dic->Release();
	return ret;
}
コード例 #4
0
GUICheckBox::GUICheckBox(IGUIManager* creator)
	:IGUICheckBox(creator)
{
	m_component=new GUICheckBoxComponent();
	m_component->owner=this;

	SetText(core::string(mT("CheckBox")));

	CPropertieDictionary* dic=0;
	if(CreateDictionary(&dic))
	{
		dic->addPropertie(&PropertyTypeText::instance);
	}
}
コード例 #5
0
int HandleClientHTTPRequest(char* szHttpRequest, int nRequestSize, SOCKET scClientSocket)
{
	int nReturnValue = 0;
	Dictionary *dictHttpReq = 0;
	
	LogMessage(LOG_DEBUG, "Started handling client http request");

	if (nRequestSize <= 0 || szHttpRequest == 0)
	{
		LogMessage(LOG_ERROR, "Invalid http request");
		return ERR_INVALID_PARAMETERS;
	}

	LogMessage(LOG_DEBUG, "Creating the dictionary for http request");
	dictHttpReq = CreateDictionary(10);
	if (dictHttpReq == 0)
	{
		LogMessage(LOG_ERROR, "Failed to create dictionary, returning");
		return ERR_INVALID_MEMORY_OPERATION;
	}

	LogMessage(LOG_DEBUG, "Populate the dictionary from http request");
	nReturnValue = GenerateHttpRequestDictionary(szHttpRequest, nRequestSize, dictHttpReq);
	if (nReturnValue != 0)
	{
		//Error has occured while adding elements to dictHttpReq
		LogMessage(LOG_ERROR, "Failed to add elements to the http request dictionary");
		return nReturnValue;
	}

	//Handle Method
	LogMessage(LOG_DEBUG, "Get the type of http request method");
	nReturnValue = GetTypeOfMethod(GetValueFromDictionary(dictHttpReq, "METHOD"));
	switch (nReturnValue)
	{
		case METHOD_OPTIONS:
		{
			//Handle Options
			nReturnValue = Handle_Options(szHttpRequest, nRequestSize, scClientSocket);
			break;
		}
		case METHOD_GET:
		{
			//Handle Get
			//printf_s("BHS:INFO:Got GET method\n");
			nReturnValue = Handle_Get(dictHttpReq, scClientSocket);
			break;
		}
		case METHOD_HEAD:
		{
			//Handle Head
			nReturnValue = Handle_Head(dictHttpReq, scClientSocket);
			break;
		}
		case METHOD_POST:
		{
			//Handle Post
			nReturnValue = Handle_Post(szHttpRequest, nRequestSize, scClientSocket);
			break;
		}
		case METHOD_PUT:
		{
			//Handle Put
			nReturnValue = Handle_Put(szHttpRequest, nRequestSize, scClientSocket);
			break;
		}
		case METHOD_DELETE:
		{
			//Handle Delete
			nReturnValue = Handle_Delete(dictHttpReq, scClientSocket);
			break;
		}
		case METHOD_TRACE:
		{
			//Handle Trace
			nReturnValue = Handle_Trace(szHttpRequest, nRequestSize, scClientSocket);
			break;
		}
		case METHOD_CONNECT:
		{
			//Handle Connect
			nReturnValue = Handle_Connect(szHttpRequest, nRequestSize, scClientSocket);
			break;
		}
		case METHOD_EXTEND_METHODS:
		{
			//Handle extended-methods
			nReturnValue = Handle_ExtMethods(szHttpRequest, nRequestSize, scClientSocket);
			break;
		}
		default:
		{
			LogMessage(LOG_ERROR, "Invalid type of method");
			//Handle the error
			break;
		}
	}
	

	/*nReturnValue = send(scClientSocket, sTestMessage, 35, 0);
	if (nReturnValue == SOCKET_ERROR)
	{
		printf_s("BHS:ERROR:send to client failed %d\n", WSAGetLastError());
		nReturnValue = ERR_SENDTOCLIENTFAILED;
		closesocket(scClientSocket);
		scClientSocket = INVALID_SOCKET;
		WSACleanup();
		return nReturnValue;
	}*/
	//closesocket(scClientSocket);
	//WSACleanup();

	LogMessage(LOG_DEBUG, "Delete the created http request dictionary");
	DeleteDictionary(dictHttpReq);
	dictHttpReq = 0;

	LogMessage(LOG_DEBUG, "Returning after handling client http request");
	return nReturnValue;
}
コード例 #6
0
ファイル: inifile.cpp プロジェクト: NyouB/4t4c
IniFile::IniFile(std::wstring& FileName)
{
	// this is the parser for ini files. This function is called, providing the name of the file
	// to be read. It returns a dictionary object that should not be accessed directly, but
	// through accessor functions instead.

	FILE *fp;
	int fieldstart;
	int fieldstop;
	int length;
	int i;
	wchar_t line_buffer[1024];
	wchar_t section[256];
	wchar_t entry[256];
	wchar_t value[256];

	//we create the dictionnary 1st that way we guarantee  that it is non-null
	Dictionary = CreateDictionary (0);

	// try to open the INI file in ASCII read-only mode
	fp = _wfsopen (FileName.c_str(), L"r", _SH_DENYNO);
	if (fp == NULL)
		return; // cancel if file not found


	// set the default section for orphaned entries and add it to the dictionary
	wcscpy_s (section, 256, INIFile_default_section);
	WriteEntryAsString (section, NULL, NULL);

	// read line per line...
	while (fgetws (line_buffer, 1024, fp) != NULL)
	{
		length = (int) wcslen (line_buffer); // get line length

		while ((length > 0) && ((line_buffer[length - 1] == L'\n') || (line_buffer[length - 1] == L'\r')))
			length--; // discard trailing newlines

		fieldstart = 0; // let's now strip leading blanks
		while ((fieldstart < length) && iswspace ((unsigned char) line_buffer[fieldstart]))
			fieldstart++; // ignore any tabs or spaces, going forward from the start

		fieldstop = length - 1; // let's now strip trailing blanks
		while ((fieldstop >= 0) && iswspace ((unsigned char) line_buffer[fieldstop]))
			fieldstop--; // ignore any tabs or spaces, going backwards from the end

		for (i = fieldstart; i <= fieldstop; i++)
			line_buffer[i - fieldstart] = line_buffer[i]; // recopy line buffer without the spaces
		line_buffer[i - fieldstart] = 0; // and terminate the string

		if ((line_buffer[0] == ';') || (line_buffer[0] == '#') || (line_buffer[0] == 0))
			continue; // skip comment lines

		// is it a valid section name ?
		if (swscanf_s (line_buffer, L"[%[^]]", section, sizeof (section)) == 1)
		{
			length = (int) wcslen (section); // get the section string length

			fieldstart = 0; // let's now strip leading blanks
			while ((fieldstart < length) && iswspace ((unsigned char) section[fieldstart]))
				fieldstart++; // ignore any tabs or spaces, going forward from the start

			fieldstop = length - 1; // let's now strip trailing blanks
			while ((fieldstop >= 0) && iswspace ((unsigned char) section[fieldstop]))
				fieldstop--; // ignore any tabs or spaces, going backwards from the end

			for (i = fieldstart; i <= fieldstop; i++)
				section[i - fieldstart] = section[i]; // recopy section name w/out spaces
			section[i - fieldstart] = 0; // and terminate the string

			WriteEntryAsString (section, NULL, NULL); // add to dictionary
		}

		// else is it a valid entry/value pair that is enclosed between quotes?
		else if (swscanf_s (line_buffer, L"%[^=] = \"%[^\"]\"", entry, sizeof (entry), value, sizeof (value)) == 2)
		{
			length = (int) wcslen (entry); // get the entry string length

			fieldstart = 0; // let's now strip leading blanks
			while ((fieldstart < length) && iswspace ((unsigned char) entry[fieldstart]))
				fieldstart++; // ignore any tabs or spaces, going forward from the start

			fieldstop = length - 1; // let's now strip trailing blanks
			while ((fieldstop >= 0) && iswspace ((unsigned char) entry[fieldstop]))
				fieldstop--; // ignore any tabs or spaces, going backwards from the end

			for (i = fieldstart; i <= fieldstop; i++)
				entry[i - fieldstart] = towlower (entry[i]); // recopy entry name w/out spaces
			entry[i - fieldstart] = 0; // and terminate the string

			// when value is enclosed between quotes, DO NOT strip the blanks

			// sscanf cannot handle "" or '' as empty value, this is done here
			if ((wcscmp (value, L"\"\"") == 0) || (wcscmp (value, L"''") == 0))
				value[0] = 0; // empty string

			WriteEntryAsString (section, entry, value); // add to dictionary
		}

		// else is it a valid entry/value pair without quotes ?
		else if ((swscanf_s (line_buffer, L"%[^=] = '%[^\']'", entry, sizeof (entry), value, sizeof (value)) == 2)
			|| (swscanf_s (line_buffer, L"%[^=] = %[^;#]", entry, sizeof (entry), value, sizeof (value)) == 2))
		{
			length = (int) wcslen (entry); // get the entry string length

			fieldstart = 0; // let's now strip leading blanks
			while ((fieldstart < length) && iswspace ((unsigned short) entry[fieldstart]))
				fieldstart++; // ignore any tabs or spaces, going forward from the start

			fieldstop = length - 1; // let's now strip trailing blanks
			while ((fieldstop >= 0) && iswspace ((unsigned short) entry[fieldstop]))
				fieldstop--; // ignore any tabs or spaces, going backwards from the end

			for (i = fieldstart; i <= fieldstop; i++)
				entry[i - fieldstart] = towlower (entry[i]); // recopy entry name w/out spaces
			entry[i - fieldstart] = 0; // and terminate the string

			length = (int) wcslen (value); // get the value string length

			fieldstart = 0; // let's now strip leading blanks
			while ((fieldstart < length) && iswspace ((unsigned short) value[fieldstart]))
				fieldstart++; // ignore any tabs or spaces, going forward from the start

			fieldstop = length - 1; // let's now strip trailing blanks
			while ((fieldstop >= 0) && iswspace ((unsigned short) value[fieldstop]))
				fieldstop--; // ignore any tabs or spaces, going backwards from the end

			for (i = fieldstart; i <= fieldstop; i++)
				value[i - fieldstart] = value[i]; // recopy entry name w/out spaces
			value[i - fieldstart] = 0; // and terminate the string

			// sscanf cannot handle "" or '' as empty value, this is done here
			if ((wcscmp (value, L"\"\"") == 0) || (wcscmp (value, L"''") == 0))
				value[0] = 0; // empty string

			WriteEntryAsString (section, entry, value); // add to dictionary
		}
	}

	fclose (fp); // finished, close the file
};
コード例 #7
0
ファイル: inifile.cpp プロジェクト: NyouB/4t4c
IniFile::IniFile(void)
{
	Dictionary=CreateDictionary(0);
};