Source
/* make attempts to read until there is a printable character, which would indicate a result of the command */
/*
** Zabbix
** Copyright (C) 2001-2023 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 int write_gsm(int fd, const char *str, char *error, int max_error_len)
{
int i, wlen, len, ret = SUCCEED;
zabbix_log(LOG_LEVEL_DEBUG, "In %s() str:'%s'", __func__, str);
len = strlen(str);
for (wlen = 0; wlen < len; wlen += i)
{
if (-1 == (i = write(fd, str + wlen, len - wlen)))
{
i = 0;
if (EAGAIN == errno)
continue;
zabbix_log(LOG_LEVEL_DEBUG, "error writing to GSM modem: %s", zbx_strerror(errno));
if (NULL != error)
zbx_snprintf(error, max_error_len, "error writing to GSM modem: %s", zbx_strerror(errno));
ret = FAIL;
break;
}
}
zabbix_log(LOG_LEVEL_DEBUG, "End of %s():%s", __func__, zbx_result_string(ret));
return ret;
}
static int check_modem_result(char *buffer, char **ebuf, char **sbuf, const char *expect, char *error,
int max_error_len)
{
char rcv[0xff];
int i, len, ret = SUCCEED;