Source
static int vmware_rest_post(const char *fn_parent, CURL *easyhandle, const char *url_suffix, const char *request,
/*
** 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 *data;
size_t alloc;
size_t offset;
char *url;
}
ZBX_HTTPPAGE_REST;
/******************************************************************************
* *
* Purpose: cURL service function *
* *
******************************************************************************/
static size_t curl_write_cb(void *ptr, size_t size, size_t nmemb, void *userdata)
{
size_t r_size = size * nmemb;
ZBX_HTTPPAGE_REST *page_http = (ZBX_HTTPPAGE_REST *)userdata;
zbx_strncpy_alloc(&page_http->data, &page_http->alloc, &page_http->offset, (const char *)ptr, r_size);
return r_size;
}
/******************************************************************************
* *
* Purpose: cURL service function *
* *
******************************************************************************/
static size_t curl_header_cb(void *ptr, size_t size, size_t nmemb, void *userdata)
{
ZBX_UNUSED(ptr);
ZBX_UNUSED(userdata);
return size * nmemb;
}
ZBX_PTR_VECTOR_IMPL(vmware_key_value, zbx_vmware_key_value_t)
/******************************************************************************
* *
* Purpose: frees resources allocated to store zbx_vmware_key_value_t *
* *
******************************************************************************/
void zbx_vmware_key_value_free(zbx_vmware_key_value_t value)
{
zbx_str_free(value.key);
zbx_str_free(value.value);
}
ZBX_PTR_VECTOR_IMPL(vmware_entity_tags_ptr, zbx_vmware_entity_tags_t *)
ZBX_PTR_VECTOR_IMPL(vmware_tag_ptr, zbx_vmware_tag_t *)
/******************************************************************************
* *
* Purpose: sorting function to sort zbx_vmware_tag_t vector by id *
* *
******************************************************************************/
static int zbx_vmware_tag_id_compare(const void *p1, const void *p2)
{
const zbx_vmware_tag_t *v1 = *(const zbx_vmware_tag_t * const *)p1;
const zbx_vmware_tag_t *v2 = *(const zbx_vmware_tag_t * const *)p2;
return strcmp(v1->id, v2->id);
}