zabbix-agent2/src/libs/zbxdbcache/dbsync.c
/******************************************************************************
 *                                                                            *
 * Function: dbsync_compare_global_macro                                      *
 *                                                                            *
 * Purpose: compares global macro table row with cached configuration data    *
 *                                                                            *
 * Parameter: gmacro - [IN] the cached global macro data                      *
 *            dbrow    - [IN] the database row                                *
 *                                                                            *
 * Return value: SUCCEED - the row matches configuration data                 *
 *               FAIL    - otherwise                                          *
 *                                                                            *
 ******************************************************************************/
dbsync_compare_global_macro

Purpose: compares global macro table row with cached configuration data

Parameter: gmacro - [IN] the cached global macro data
dbrow    - [IN] the database row

Return value: SUCCEED - the row matches configuration data
FAIL    - otherwise
dbsync_compare_global_macro Purpose : compares global macro table row with cached configuration data Parameter : gmacro - [ IN ] the cached global macro data dbrow - [ IN ] the database row Return value : SUCCEED - the row matches configuration data FAIL - otherwise
static int	dbsync_compare_global_macro(const ZBX_DC_GMACRO *gmacro, const DB_ROW dbrow)
{
	char	*macro = NULL, *context = NULL;
	int	ret = FAIL;
	if (FAIL == dbsync_compare_uchar(dbrow[3], gmacro->type))
		return FAIL;
	if (FAIL == dbsync_compare_str(dbrow[2], gmacro->value))
		return FAIL;
	if (SUCCEED != zbx_user_macro_parse_dyn(dbrow[1], &macro, &context, NULL, NULL))
		return FAIL;
	if (0 != strcmp(gmacro->macro, macro))
		goto out;
	if (NULL == context)
	{
		if (NULL != gmacro->context)
			goto out;
		ret = SUCCEED;
		goto out;
	}
	if (NULL == gmacro->context)
		goto out;
	if (0 == strcmp(gmacro->context, context))
		ret = SUCCEED;
out:
	zbx_free(macro);
	zbx_free(context);
	return ret;
}
static int dbsync_compare_global_macro ( const ZBX_DC_GMACRO * gmacro , const DB_ROW dbrow ) { char * macro = NULL , * context = NULL ; int ret = FAIL ; if ( FAIL == dbsync_compare_uchar ( dbrow [ 3 ] , gmacro -> type ) ) return FAIL ; if ( FAIL == dbsync_compare_str ( dbrow [ 2 ] , gmacro -> value ) ) return FAIL ; if ( SUCCEED != zbx_user_macro_parse_dyn ( dbrow [ 1 ] , & macro , & context , NULL , NULL ) ) return FAIL ; if ( 0 != strcmp ( gmacro -> macro , macro ) ) goto out ; if ( NULL == context ) { if ( NULL != gmacro -> context ) goto out ; ret = SUCCEED ; goto out ; } if ( NULL == gmacro -> context ) goto out ; if ( 0 == strcmp ( gmacro -> context , context ) ) ret = SUCCEED ; out : zbx_free ( macro ) ; zbx_free ( context ) ; return ret ; }
Function: dbsync_compare_global_macro                                      
                                                                            
 Purpose: compares global macro table row with cached configuration data    
                                                                            
 Parameter: gmacro - [IN] the cached global macro data                      
            dbrow    - [IN] the database row                                
                                                                            
 Return value: SUCCEED - the row matches configuration data                 
               FAIL    - otherwise
Function : dbsync_compare_global_macro Purpose : compares global macro table row with cached configuration data Parameter : gmacro - [ IN ] the cached global macro data dbrow - [ IN ] the database row Return value : SUCCEED - the row matches configuration data FAIL - otherwise