zabbix-agent2/src/libs/zbxdbcache/dbsync.c
/******************************************************************************
 *                                                                            *
 * Function: dbsync_compare_serialized_expression                             *
 *                                                                            *
 * Purpose: compare serialized expression                                     *
 *                                                                            *
 * Parameter: col   - [IN] the base64 encoded expression                      *
 *            data2 - [IN] the serialized expression in cache                 *
 *                                                                            *
 * Return value: SUCCEED - the expressions are identical                      *
 *               FAIL    - otherwise                                          *
 *                                                                            *
 ******************************************************************************/
dbsync_compare_serialized_expression

Purpose: compare serialized expression

Parameter: col   - [IN] the base64 encoded expression
data2 - [IN] the serialized expression in cache

Return value: SUCCEED - the expressions are identical
FAIL    - otherwise
dbsync_compare_serialized_expression Purpose : compare serialized expression Parameter : col - [ IN ] the base64 encoded expression data2 - [ IN ] the serialized expression in cache Return value : SUCCEED - the expressions are identical FAIL - otherwise
static int	dbsync_compare_serialized_expression(const char *col, const unsigned char *data2)
{
	zbx_uint32_t	offset1, len1, offset2, len2;
	unsigned char	*data1;
	int		col_len, data1_len, ret = FAIL;
	if (NULL == data2)
	{
		if (NULL == col || '\0' == *col)
			return SUCCEED;
		return FAIL;
	}
	if (NULL == col || '\0' == *col)
		return FAIL;
	col_len = strlen(col);
	data1 = zbx_malloc(NULL, col_len);
	str_base64_decode(col, (char *)data1, col_len, &data1_len);
	offset1 = zbx_deserialize_uint31_compact((const unsigned char *)data1, &len1);
	offset2 = zbx_deserialize_uint31_compact((const unsigned char *)data2, &len2);
	if (offset1 != offset2 || len1 != len2)
		goto out;
	if (0 != memcmp(data1 + offset1, data2 + offset2, len1))
		goto out;
	ret = SUCCEED;
out:
	zbx_free(data1);
	return ret;
}
static int dbsync_compare_serialized_expression ( const char * col , const unsigned char * data2 ) { zbx_uint32_t offset1 , len1 , offset2 , len2 ; unsigned char * data1 ; int col_len , data1_len , ret = FAIL ; if ( NULL == data2 ) { if ( NULL == col || ' \0 ' == * col ) return SUCCEED ; return FAIL ; } if ( NULL == col || ' \0 ' == * col ) return FAIL ; col_len = strlen ( col ) ; data1 = zbx_malloc ( NULL , col_len ) ; str_base64_decode ( col , ( char * ) data1 , col_len , & data1_len ) ; offset1 = zbx_deserialize_uint31_compact ( ( const unsigned char * ) data1 , & len1 ) ; offset2 = zbx_deserialize_uint31_compact ( ( const unsigned char * ) data2 , & len2 ) ; if ( offset1 != offset2 || len1 != len2 ) goto out ; if ( 0 != memcmp ( data1 + offset1 , data2 + offset2 , len1 ) ) goto out ; ret = SUCCEED ; out : zbx_free ( data1 ) ; return ret ; }
Function: dbsync_compare_serialized_expression                             
                                                                            
 Purpose: compare serialized expression                                     
                                                                            
 Parameter: col   - [IN] the base64 encoded expression                      
            data2 - [IN] the serialized expression in cache                 
                                                                            
 Return value: SUCCEED - the expressions are identical                      
               FAIL    - otherwise
Function : dbsync_compare_serialized_expression Purpose : compare serialized expression Parameter : col - [ IN ] the base64 encoded expression data2 - [ IN ] the serialized expression in cache Return value : SUCCEED - the expressions are identical FAIL - otherwise