Source
/*
** 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/>.
**/
static int zbx_zlib_errno = 0;
/******************************************************************************
* *
* Purpose: returns last conversion error message *
* *
******************************************************************************/
const char *zbx_compress_strerror(void)
{
static char message[ZBX_COMPRESS_STRERROR_LEN];
switch (zbx_zlib_errno)
{
case Z_ERRNO:
zbx_strlcpy(message, zbx_strerror(errno), sizeof(message));
break;
case Z_MEM_ERROR:
zbx_strlcpy(message, "not enough memory", sizeof(message));
break;
case Z_BUF_ERROR:
zbx_strlcpy(message, "not enough space in output buffer", sizeof(message));
break;
case Z_DATA_ERROR:
zbx_strlcpy(message, "corrupted input data", sizeof(message));
break;
default:
zbx_snprintf(message, sizeof(message), "unknown error (%d)", zbx_zlib_errno);
break;
}
return message;
}
/******************************************************************************
* *
* Purpose: compress data *
* *
* Parameters: in - [IN] the data to compress *
* size_in - [IN] the input data size *
* out - [OUT] the compressed data *