Source
xxxxxxxxxx
static void strncpy_alloc(char **str, size_t *alloc_len, size_t *offset, const char *src, size_t n, size_t limit)
/*
** Copyright (C) 2001-2025 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/>.
**/
struct zbx_regexp
{
pcre2_code *pcre2_regexp;
pcre2_match_context *match_ctx;
};
typedef struct
{
int rm_so;
int rm_eo;
}
zbx_regmatch_t;
/* Max number of supported capture groups in regular expressions. */
/* Group \0 contains the matching part of string, groups \1 ...\9 */
/* contain captured groups (substrings). */
ZBX_PTR_VECTOR_IMPL(expression, zbx_expression_t *)
typedef struct
{
zbx_regmatch_t groups[ZBX_REGEXP_GROUPS_MAX];
}
zbx_match_t;
ZBX_PTR_VECTOR_DECL(match, zbx_match_t *)
ZBX_PTR_VECTOR_IMPL(match, zbx_match_t *)
static void zbx_match_free(zbx_match_t *match)
{
zbx_free(match);
}
static char *decode_pcre2_compile_error(int error_code, PCRE2_SIZE error_offset, uint32_t flags)
{
/* 120 code units buffer is recommended in "man pcre2api" */
int ret;