Source
const char *zbx_json_decodevalue_dyn(const char *p, char **string, size_t *string_alloc, zbx_json_type_t *type)
/*
** Zabbix
** Copyright (C) 2001-2023 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: return string describing json error *
* *
* Return value: pointer to the null terminated string *
* *
******************************************************************************/
static ZBX_THREAD_LOCAL char zbx_json_strerror_message[ZBX_JSON_MAX_STRERROR];
const char *zbx_json_strerror(void)
{
return zbx_json_strerror_message;
}
void zbx_set_json_strerror(const char *fmt, ...)
{
size_t sz;
va_list args;
va_start(args, fmt);
sz = zbx_vsnprintf(zbx_json_strerror_message, sizeof(zbx_json_strerror_message), fmt, args);
if (sizeof(zbx_json_strerror_message) - 1 == sz)
{
/* ensure that the string is not cut in the middle of UTF-8 sequence */
size_t idx = sz - 1;
while (0x80 == (0xc0 & zbx_json_strerror_message[idx]) && 0 < idx)
idx--;
if (zbx_utf8_char_len(zbx_json_strerror_message + idx) != sz - idx)
zbx_json_strerror_message[idx] = '\0';
}
va_end(args);
}