zabbix-agent2/src/libs/zbxdbupgrade/dbupgrade_5030.c
/******************************************************************************
 *                                                                            *
 * Function: dbpatch_find_function                                            *
 *                                                                            *
 * Purpose: check if the expression contains specified functionid             *
 *                                                                            *
 ******************************************************************************/
dbpatch_find_function

Purpose: check if the expression contains specified functionid
dbpatch_find_function Purpose : check if the expression contains specified functionid
static int	dbpatch_find_function(const char *expression, zbx_uint64_t functionid)
{
	int		pos = 0;
	zbx_token_t	token;
	zbx_uint64_t	id;
	for (; SUCCEED == zbx_token_find(expression, pos, &token, ZBX_TOKEN_SEARCH_FUNCTIONID |
			ZBX_TOKEN_SEARCH_SIMPLE_MACRO); pos++)
	{
		switch (token.type)
		{
			case ZBX_TOKEN_OBJECTID:
				if (SUCCEED == is_uint64_n(expression + token.data.objectid.name.l,
						token.data.objectid.name.r - token.data.objectid.name.l + 1, &id) &&
						functionid == id)
				{
					return SUCCEED;
				}
				pos = token.loc.r;
				break;
			case ZBX_TOKEN_MACRO:
			case ZBX_TOKEN_USER_MACRO:
			case ZBX_TOKEN_LLD_MACRO:
				pos = token.loc.r;
				break;
		}
	}
	return FAIL;
}
static int dbpatch_find_function ( const char * expression , zbx_uint64_t functionid ) { int pos = 0 ; zbx_token_t token ; zbx_uint64_t id ; for ( ; SUCCEED == zbx_token_find ( expression , pos , & token , ZBX_TOKEN_SEARCH_FUNCTIONID | ZBX_TOKEN_SEARCH_SIMPLE_MACRO ) ; pos ++ ) { switch ( token . type ) { case ZBX_TOKEN_OBJECTID : if ( SUCCEED == is_uint64_n ( expression + token . data . objectid . name . l , token . data . objectid . name . r - token . data . objectid . name . l + 1 , & id ) && functionid == id ) { return SUCCEED ; } pos = token . loc . r ; break ; case ZBX_TOKEN_MACRO : case ZBX_TOKEN_USER_MACRO : case ZBX_TOKEN_LLD_MACRO : pos = token . loc . r ; break ; } } return FAIL ; }
Function: dbpatch_find_function                                            
                                                                            
 Purpose: check if the expression contains specified functionid
Function : dbpatch_find_function Purpose : check if the expression contains specified functionid