示例#1
0
S32 LLSDNotationParser::parseMap(std::istream& istr, LLSD& map) const
{
	// map: { string:object, string:object }
	map = LLSD::emptyMap();
	S32 parse_count = 0;
	char c = get(istr);
	if(c == '{')
	{
		// eat commas, white
		bool found_name = false;
		std::string name;
		c = get(istr);
		while(c != '}' && istr.good())
		{
			if(!found_name)
			{
				if((c == '\"') || (c == '\'') || (c == 's'))
				{
					putback(istr, c);
					found_name = true;
					int count = deserialize_string(istr, name, mMaxBytesLeft);
					if(PARSE_FAILURE == count) return PARSE_FAILURE;
					account(count);
				}
				c = get(istr);
			}
			else
			{
				if(isspace(c) || (c == ':'))
				{
					c = get(istr);
					continue;
				}
				putback(istr, c);
				LLSD child;
				S32 count = doParse(istr, child);
				if(count > 0)
				{
					// There must be a value for every key, thus
					// child_count must be greater than 0.
					parse_count += count;
					map.insert(name, child);
				}
				else
				{
					return PARSE_FAILURE;
				}
				found_name = false;
				c = get(istr);
			}
		}
		if(c != '}')
		{
			map.clear();
			return PARSE_FAILURE;
		}
	}
	return parse_count;
}
示例#2
0
bool LLSDNotationParser::parseString(std::istream& istr, LLSD& data) const
{
	std::string value;
	int count = deserialize_string(istr, value, mMaxBytesLeft);
	if(PARSE_FAILURE == count) return false;
	account(count);
	data = value;
	return true;
}
示例#3
0
void Cacher::read_header(void){
  if (file.is_open()) file.close();
  file.open(m_cacheFilename.c_str(), ios::in|ios::binary);
  deserialize_uint8(&read_major_version);
  deserialize_uint8(&read_minor_version);
  deserialize_string(&m_baseName);
  deserialize_nl();
  bool b=(read_major_version==CACHER_MAJOR_VERSION) &&
    (read_minor_version==CACHER_MINOR_VERSION);
  assert(b && "Cacher version mismatch");
	 
}
示例#4
0
文件: Audio.c 项目: Remmy/afterstep
void
process_message (send_data_type type, send_data_type *body)
{
	time_t        now = 0;
	static time_t last_time = 0;
	int code = -1 ;
	
    LOCAL_DEBUG_OUT( "received message %lX", type );
		
	if( type == M_PLAY_SOUND ) 
	{
		CARD32 *pbuf = &(body[4]);
       	char *new_name = deserialize_string( &pbuf, NULL );
  		SetupSoundEntry( EVENT_PlaySound, new_name);
		free( new_name );
		code = EVENT_PlaySound ;
	}else if( (type&WINDOW_PACKET_MASK) != 0 )
	{
		struct ASWindowData *wd = fetch_window_by_id( body[0] );
		WindowPacketResult res ;
        /* saving relevant client info since handle_window_packet could destroy the actuall structure */
		ASFlagType old_state = wd?wd->state_flags:0 ; 
        show_activity( "message %lX window %X data %p", type, body[0], wd );
		res = handle_window_packet( type, body, &wd );
		LOCAL_DEBUG_OUT( "result = %d", res );
        if( res == WP_DataCreated )
		{	
			code = EVENT_WindowAdded ;
		}else if( res == WP_DataChanged )
		{	
			
		}else if( res == WP_DataDeleted )
        {
			code = EVENT_WindowDestroyed ;
        }
    }else if( type == M_NEW_DESKVIEWPORT )
    {
		code = EVENT_DeskViewportChanged ;
	}else if( type == M_NEW_CONFIG )
	{
	 	code = EVENT_Config ;
	}else if( type == M_NEW_MODULE_CONFIG )
	{
		code = EVENT_ModuleConfig ;
	}
    now = time (0);
	if( code >= 0 )
	    if ( now >= (last_time + (time_t) Config->delay))
			if( audio_play ( code ) )
    	    	last_time = now;
}