zabbix-agent2/src/libs/zbxdbcache/dbconfig.c
/******************************************************************************
 *                                                                            *
 * Function: DCget_expressions_by_names                                       *
 *                                                                            *
 * Purpose: retrieves global expression data from cache                       *
 *                                                                            *
 * Parameters: expressions  - [OUT] a vector of expression data pointers      *
 *             names        - [IN] a vector containing expression names       *
 *             names_num    - [IN] the number of items in names vector        *
 *                                                                            *
 * Comment: The expressions vector contains allocated data, which must be     *
 *          freed afterwards with zbx_regexp_clean_expressions() function.    *
 *                                                                            *
 ******************************************************************************/
DCget_expressions_by_names

Purpose: retrieves global expression data from cache

Parameters: expressions  - [OUT] a vector of expression data pointers
names        - [IN] a vector containing expression names
names_num    - [IN] the number of items in names vector

Comment: The expressions vector contains allocated data, which must be
freed afterwards with zbx_regexp_clean_expressions() function.
DCget_expressions_by_names Purpose : retrieves global expression data from cache Parameters : expressions - [ OUT ] a vector of expression data pointers names - [ IN ] a vector containing expression names names_num - [ IN ] the number of items in names vector Comment : The expressions vector contains allocated data which must be freed afterwards with zbx_regexp_clean_expressions () function .
void	DCget_expressions_by_names(zbx_vector_ptr_t *expressions, const char * const *names, int names_num)
{
	int			i, iname;
	const ZBX_DC_EXPRESSION	*expression;
	const ZBX_DC_REGEXP	*regexp;
	ZBX_DC_REGEXP		search_regexp;
	RDLOCK_CACHE;
	for (iname = 0; iname < names_num; iname++)
	{
		search_regexp.name = names[iname];
		if (NULL != (regexp = (const ZBX_DC_REGEXP *)zbx_hashset_search(&config->regexps, &search_regexp)))
		{
			for (i = 0; i < regexp->expressionids.values_num; i++)
			{
				zbx_uint64_t		expressionid = regexp->expressionids.values[i];
				zbx_expression_t	*rxp;
				if (NULL == (expression = (const ZBX_DC_EXPRESSION *)zbx_hashset_search(&config->expressions, &expressionid)))
					continue;
				rxp = (zbx_expression_t *)zbx_malloc(NULL, sizeof(zbx_expression_t));
				rxp->name = zbx_strdup(NULL, regexp->name);
				rxp->expression = zbx_strdup(NULL, expression->expression);
				rxp->exp_delimiter = expression->delimiter;
				rxp->case_sensitive = expression->case_sensitive;
				rxp->expression_type = expression->type;
				zbx_vector_ptr_append(expressions, rxp);
			}
		}
	}
	UNLOCK_CACHE;
}
void DCget_expressions_by_names ( zbx_vector_ptr_t * expressions , const char * const * names , int names_num ) { int i , iname ; const ZBX_DC_EXPRESSION * expression ; const ZBX_DC_REGEXP * regexp ; ZBX_DC_REGEXP search_regexp ; RDLOCK_CACHE ; for ( iname = 0 ; iname < names_num ; iname ++ ) { search_regexp . name = names [ iname ] ; if ( NULL != ( regexp = ( const ZBX_DC_REGEXP * ) zbx_hashset_search ( & config -> regexps , & search_regexp ) ) ) { for ( i = 0 ; i < regexp -> expressionids . values_num ; i ++ ) { zbx_uint64_t expressionid = regexp -> expressionids . values [ i ] ; zbx_expression_t * rxp ; if ( NULL == ( expression = ( const ZBX_DC_EXPRESSION * ) zbx_hashset_search ( & config -> expressions , & expressionid ) ) ) continue ; rxp = ( zbx_expression_t * ) zbx_malloc ( NULL , sizeof ( zbx_expression_t ) ) ; rxp -> name = zbx_strdup ( NULL , regexp -> name ) ; rxp -> expression = zbx_strdup ( NULL , expression -> expression ) ; rxp -> exp_delimiter = expression -> delimiter ; rxp -> case_sensitive = expression -> case_sensitive ; rxp -> expression_type = expression -> type ; zbx_vector_ptr_append ( expressions , rxp ) ; } } } UNLOCK_CACHE ; }
Function: DCget_expressions_by_names                                       
                                                                            
 Purpose: retrieves global expression data from cache                       
                                                                            
 Parameters: expressions  - [OUT] a vector of expression data pointers      
             names        - [IN] a vector containing expression names       
             names_num    - [IN] the number of items in names vector        
                                                                            
 Comment: The expressions vector contains allocated data, which must be     
          freed afterwards with zbx_regexp_clean_expressions() function.
Function : DCget_expressions_by_names Purpose : retrieves global expression data from cache Parameters : expressions - [ OUT ] a vector of expression data pointers names - [ IN ] a vector containing expression names names_num - [ IN ] the number of items in names vector Comment : The expressions vector contains allocated data which must be freed afterwards with zbx_regexp_clean_expressions () function .