Source
static void convert_unix_to_telnet_eol(const char *buf, size_t offset, char *out_buf, size_t *out_offset)
/*
** 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 char prompt_char = '\0';
static int telnet_waitsocket(ZBX_SOCKET socket_fd, short mode)
{
int rc;
zbx_pollfd_t pd;
zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __func__);
pd.fd = socket_fd;
pd.events = mode;
if (0 > (rc = zbx_socket_poll(&pd, 1, 100)))
{
zabbix_log(LOG_LEVEL_DEBUG, "%s() poll() error rc:%d errno:%d error:[%s]", __func__, rc,
zbx_socket_last_error(), zbx_strerror_from_system(zbx_socket_last_error()));
}
else if (0 < rc && POLLIN != (pd.revents & (POLLIN | POLLERR | POLLHUP | POLLNVAL)))
{
char *errmsg;
errmsg = socket_poll_error(pd.revents);
zabbix_log(LOG_LEVEL_DEBUG, "%s() %s", __func__, errmsg);
zbx_free(errmsg);
rc = ZBX_PROTO_ERROR;
}
zabbix_log(LOG_LEVEL_DEBUG, "End of %s():%d", __func__, rc);
return rc;
}
static ssize_t telnet_socket_read(zbx_socket_t *s, void *buf, size_t count)
{
ssize_t rc;