Source
static int dbsync_compare_itemscript_param(const zbx_dc_scriptitem_param_t *scriptitem_param, const DB_ROW dbrow)
/*
** Zabbix
** 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 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.
**/
typedef struct
{
zbx_hashset_t strpool;
ZBX_DC_CONFIG *cache;
}
zbx_dbsync_env_t;
static zbx_dbsync_env_t dbsync_env;
/* string pool support */
static zbx_hash_t dbsync_strpool_hash_func(const void *data)
{
return ZBX_DEFAULT_STRING_HASH_FUNC((char *)data + REFCOUNT_FIELD_SIZE);
}
static int dbsync_strpool_compare_func(const void *d1, const void *d2)
{
return strcmp((char *)d1 + REFCOUNT_FIELD_SIZE, (char *)d2 + REFCOUNT_FIELD_SIZE);
}
static char *dbsync_strdup(const char *str)
{
void *ptr;
ptr = zbx_hashset_insert_ext(&dbsync_env.strpool, str - REFCOUNT_FIELD_SIZE,
REFCOUNT_FIELD_SIZE + strlen(str) + 1, REFCOUNT_FIELD_SIZE, ZBX_HASHSET_UNIQ_FALSE);
(*(zbx_uint32_t *)ptr)++;
return (char *)ptr + REFCOUNT_FIELD_SIZE;
}
static void dbsync_strfree(char *str)
{
if (NULL != str)
{
void *ptr = str - REFCOUNT_FIELD_SIZE;
if (0 == --(*(zbx_uint32_t *)ptr))
zbx_hashset_remove_direct(&dbsync_env.strpool, ptr);
}
}
/* macro value validators */
/******************************************************************************
* *
* Purpose: compares 64 bit unsigned integer with a raw database value *
* *
******************************************************************************/
static int dbsync_compare_uint64(const char *value_raw, zbx_uint64_t value)
{
zbx_uint64_t value_ui64;
ZBX_DBROW2UINT64(value_ui64, value_raw);
return (value_ui64 == value ? SUCCEED : FAIL);
}
/******************************************************************************
* *