zabbix-agent2/src/libs/zbxdbcache/dbconfig.c
/******************************************************************************
 *                                                                            *
 * Function: dc_hostgroup_cache_nested_groupids                               *
 *                                                                            *
 * Purpose: cache nested group identifiers                                    *
 *                                                                            *
 ******************************************************************************/
dc_hostgroup_cache_nested_groupids

Purpose: cache nested group identifiers
dc_hostgroup_cache_nested_groupids Purpose : cache nested group identifiers
void	dc_hostgroup_cache_nested_groupids(zbx_dc_hostgroup_t *parent_group)
{
	zbx_dc_hostgroup_t	*group;
	if (0 == (parent_group->flags & ZBX_DC_HOSTGROUP_FLAGS_NESTED_GROUPIDS))
	{
		int	index, len;
		zbx_vector_uint64_create_ext(&parent_group->nested_groupids, __config_mem_malloc_func,
				__config_mem_realloc_func, __config_mem_free_func);
		index = zbx_vector_ptr_bsearch(&config->hostgroups_name, parent_group, dc_compare_hgroups);
		len = strlen(parent_group->name);
		while (++index < config->hostgroups_name.values_num)
		{
			group = (zbx_dc_hostgroup_t *)config->hostgroups_name.values[index];
			if (0 != strncmp(group->name, parent_group->name, len))
				break;
			if ('\0' == group->name[len] || '/' == group->name[len])
				zbx_vector_uint64_append(&parent_group->nested_groupids, group->groupid);
		}
		parent_group->flags |= ZBX_DC_HOSTGROUP_FLAGS_NESTED_GROUPIDS;
	}
}
void dc_hostgroup_cache_nested_groupids ( zbx_dc_hostgroup_t * parent_group ) { zbx_dc_hostgroup_t * group ; if ( 0 == ( parent_group -> flags & ZBX_DC_HOSTGROUP_FLAGS_NESTED_GROUPIDS ) ) { int index , len ; zbx_vector_uint64_create_ext ( & parent_group -> nested_groupids , __config_mem_malloc_func , __config_mem_realloc_func , __config_mem_free_func ) ; index = zbx_vector_ptr_bsearch ( & config -> hostgroups_name , parent_group , dc_compare_hgroups ) ; len = strlen ( parent_group -> name ) ; while ( ++ index < config -> hostgroups_name . values_num ) { group = ( zbx_dc_hostgroup_t * ) config -> hostgroups_name . values [ index ] ; if ( 0 != strncmp ( group -> name , parent_group -> name , len ) ) break ; if ( ' \0 ' == group -> name [ len ] || ' ' == group -> name [ len ] ) zbx_vector_uint64_append ( & parent_group -> nested_groupids , group -> groupid ) ; } parent_group -> flags |= ZBX_DC_HOSTGROUP_FLAGS_NESTED_GROUPIDS ; } }
Function: dc_hostgroup_cache_nested_groupids                               
                                                                            
 Purpose: cache nested group identifiers
Function : dc_hostgroup_cache_nested_groupids Purpose : cache nested group identifiers