Source
int sb_parse_line(zbx_send_buffer_t *buf, const char *line, size_t line_alloc, int send_mode, struct zbx_json **out,
/*
** 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/>.
**/
typedef struct
{
char *host;
int values_num;
struct zbx_json *json;
}
zbx_send_batch_t;
static zbx_hash_t send_batch_hash(const void *d)
{
const zbx_send_batch_t *b = (const zbx_send_batch_t *)d;
return ZBX_DEFAULT_STRING_HASH_ALGO(b->host, strlen(b->host), ZBX_DEFAULT_HASH_SEED);
}
static int send_batch_compare(const void *d1, const void *d2)
{
const zbx_send_batch_t *b1 = (const zbx_send_batch_t *)d1;
const zbx_send_batch_t *b2 = (const zbx_send_batch_t *)d2;
return strcmp(b1->host, b2->host);
}
/******************************************************************************
* *
* Purpose: initialize send buffer *
* *
******************************************************************************/
void sb_init(zbx_send_buffer_t *buf, int group_mode, const char *host, int with_clock, int with_ns)
{
buf->group_mode = group_mode;
buf->with_clock = with_clock;
buf->with_ns = with_ns;
buf->host = (NULL == host ? NULL : zbx_strdup(NULL, host));
buf->key = NULL;
buf->value = NULL;
buf->kv_alloc = 0;
zbx_hashset_create(&buf->batches, 100, send_batch_hash, send_batch_compare);
}
/******************************************************************************
* *
* Purpose: destroy send buffer *