zabbix-agent2/src/libs/zbxeval/misc.c
/******************************************************************************
 *                                                                            *
 * Function: zbx_eval_deserialize                                             *
 *                                                                            *
 * Purpose: deserialize evaluation context from buffer                        *
 *                                                                            *
 * Parameters: ctx        - [OUT] the evaluation context                      *
 *             expression - [IN] the expression the evaluation context was    *
 *                               created from                                 *
 *             rules      - [IN] the composition and evaluation rules         *
 *             data       - [IN] the buffer with serialized context           *
 *                                                                            *
 ******************************************************************************/
zbx_eval_deserialize

Purpose: deserialize evaluation context from buffer

Parameters: ctx        - [OUT] the evaluation context
expression - [IN] the expression the evaluation context was
created from
rules      - [IN] the composition and evaluation rules
data       - [IN] the buffer with serialized context
zbx_eval_deserialize Purpose : deserialize evaluation context from buffer Parameters : ctx - [ OUT ] the evaluation context expression - [ IN ] the expression the evaluation context was created from rules - [ IN ] the composition and evaluation rules data - [ IN ] the buffer with serialized context
void	zbx_eval_deserialize(zbx_eval_context_t *ctx, const char *expression, zbx_uint64_t rules,
		const unsigned char *data)
{
	zbx_uint32_t	i, tokens_num, len, pos;
	memset(ctx, 0, sizeof(zbx_eval_context_t));
	ctx->expression = expression;
	ctx->rules = rules;
	data += zbx_deserialize_uint31_compact(data, &len);
	data += zbx_deserialize_uint31_compact(data, &tokens_num);
	zbx_vector_eval_token_create(&ctx->stack);
	zbx_vector_eval_token_reserve(&ctx->stack, tokens_num);
	ctx->stack.values_num = tokens_num;
	for (i = 0; i < tokens_num; i++)
	{
		zbx_eval_token_t	*token = &ctx->stack.values[i];
		data += zbx_deserialize_value(data, &token->type);
		data += zbx_deserialize_uint31_compact(data, &token->opt);
		data += zbx_deserialize_uint31_compact(data, &pos);
		token->loc.l = pos;
		data += zbx_deserialize_uint31_compact(data, &pos);
		token->loc.r = pos;
		data += deserialize_variant(data, &token->value);
	}
}
void zbx_eval_deserialize ( zbx_eval_context_t * ctx , const char * expression , zbx_uint64_t rules , const unsigned char * data ) { zbx_uint32_t i , tokens_num , len , pos ; memset ( ctx , 0 , sizeof ( zbx_eval_context_t ) ) ; ctx -> expression = expression ; ctx -> rules = rules ; data += zbx_deserialize_uint31_compact ( data , & len ) ; data += zbx_deserialize_uint31_compact ( data , & tokens_num ) ; zbx_vector_eval_token_create ( & ctx -> stack ) ; zbx_vector_eval_token_reserve ( & ctx -> stack , tokens_num ) ; ctx -> stack . values_num = tokens_num ; for ( i = 0 ; i < tokens_num ; i ++ ) { zbx_eval_token_t * token = & ctx -> stack . values [ i ] ; data += zbx_deserialize_value ( data , & token -> type ) ; data += zbx_deserialize_uint31_compact ( data , & token -> opt ) ; data += zbx_deserialize_uint31_compact ( data , & pos ) ; token -> loc . l = pos ; data += zbx_deserialize_uint31_compact ( data , & pos ) ; token -> loc . r = pos ; data += deserialize_variant ( data , & token -> value ) ; } }
Function: zbx_eval_deserialize                                             
                                                                            
 Purpose: deserialize evaluation context from buffer                        
                                                                            
 Parameters: ctx        - [OUT] the evaluation context                      
             expression - [IN] the expression the evaluation context was    
                               created from                                 
             rules      - [IN] the composition and evaluation rules         
             data       - [IN] the buffer with serialized context
Function : zbx_eval_deserialize Purpose : deserialize evaluation context from buffer Parameters : ctx - [ OUT ] the evaluation context expression - [ IN ] the expression the evaluation context was created from rules - [ IN ] the composition and evaluation rules data - [ IN ] the buffer with serialized context