Source
static int prepare_common_parameters(const AGENT_REQUEST *request, AGENT_RESULT *result, zbx_regexp_t **regex_incl,
/*
** Copyright (C) 2001-2024 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** 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 Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
/******************************************************************************
* *
* 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) *
* *
* Return value: SUCCEED - directory is queued, *