Source
xxxxxxxxxx
static void convert_unix_to_telnet_eol(const char *buf, size_t offset, char *out_buf, size_t *out_offset)
/*
** 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.
**/
static char prompt_char = '\0';
static int telnet_waitsocket(ZBX_SOCKET socket_fd, int mode)
{
struct timeval tv;
int rc;
fd_set fd, *readfd = NULL, *writefd = NULL;
zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __func__);
tv.tv_sec = 0;
tv.tv_usec = 100000; /* 1/10 sec */
FD_ZERO(&fd);
FD_SET(socket_fd, &fd);
if (WAIT_READ == mode)
readfd = &fd;
else
writefd = &fd;
rc = select(ZBX_SOCKET_TO_INT(socket_fd) + 1, readfd, writefd, NULL, &tv);
if (ZBX_PROTO_ERROR == rc)
{
zabbix_log(LOG_LEVEL_DEBUG, "%s() rc:%d errno:%d error:[%s]", __func__, rc, zbx_socket_last_error(),
strerror_from_system(zbx_socket_last_error()));
}
zabbix_log(LOG_LEVEL_DEBUG, "End of %s():%d", __func__, rc);
return rc;
}
static ssize_t telnet_socket_read(ZBX_SOCKET socket_fd, void *buf, size_t count)
{
ssize_t rc;
int error;