Source
static int prepare_common_parameters(const AGENT_REQUEST *request, AGENT_RESULT *result, zbx_regexp_t **regex_incl,
/*
** Zabbix
** Copyright (C) 2001-2022 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
/******************************************************************************
* *
* Purpose: checks if filename matches the include-regexp and doesn't match *
* the exclude-regexp *
* *
* Parameters: fname - [IN] filename to be checked *
* regex_incl - [IN] regexp for filenames to include (NULL means *
* include any file) *
* regex_excl - [IN] regexp for filenames to exclude (NULL means *
* exclude none) *
* *
* Return value: If filename passes both checks, nonzero value is returned. *
* If filename fails to pass, 0 is returned. *
* *
******************************************************************************/
static int filename_matches(const char *fname, const zbx_regexp_t *regex_incl, const zbx_regexp_t *regex_excl)
{
return ((NULL == regex_incl || 0 == zbx_regexp_match_precompiled(fname, regex_incl)) &&
(NULL == regex_excl || 0 != zbx_regexp_match_precompiled(fname, regex_excl)));
}
/******************************************************************************
* *
* Purpose: adds directory to processing queue after checking if current *
* depth is less than 'max_depth' *
* *
* Parameters: list - [IN/OUT] vector used to replace recursion *
* with iterative approach *
* path - [IN] directory path *
* depth - [IN] current traversal depth of directory *
* max_depth - [IN] maximal traversal depth allowed (use -1 *
* for unlimited directory traversal) *
* *