mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Fixed error printing for no autoconnect mode
Always print errors but only print silent errors when in no autoconnect mode.
This commit is contained in:
parent
ffe87bc566
commit
dd49d07547
3 changed files with 16 additions and 9 deletions
10
src/error.c
10
src/error.c
|
|
@ -27,10 +27,14 @@
|
|||
#include "tio/print.h"
|
||||
#include "tio/error.h"
|
||||
|
||||
char error[1000];
|
||||
char error[2][1000];
|
||||
|
||||
void error_exit(void)
|
||||
{
|
||||
if ((error[0] != 0) && (option.no_autoconnect))
|
||||
printf("\rError: %s\r\n", error);
|
||||
/* Always print errors but only print silent errors when in no autoconnect
|
||||
* mode */
|
||||
if (error[0][0] != 0)
|
||||
printf("\rError: %s\r\n", error[0]);
|
||||
else if ((error[1][0] != 0) && (option.no_autoconnect))
|
||||
printf("\rError: %s\r\n", error[1]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,10 +25,13 @@
|
|||
#define TIO_SUCCESS 0
|
||||
#define TIO_ERROR 1
|
||||
|
||||
extern char error[1000];
|
||||
extern char error[2][1000];
|
||||
|
||||
#define error_printf(format, args...) \
|
||||
snprintf (error, 1000, format, ## args);
|
||||
snprintf (error[0], 1000, format, ## args);
|
||||
|
||||
#define error_printf_silent(format, args...) \
|
||||
snprintf (error[1], 1000, format, ## args);
|
||||
|
||||
void error_exit(void);
|
||||
|
||||
|
|
|
|||
|
|
@ -230,14 +230,14 @@ int connect_tty(void)
|
|||
fd = open(option.tty_device, O_RDWR | O_NOCTTY );
|
||||
if (fd < 0)
|
||||
{
|
||||
error_printf("Could not open tty device (%s)", strerror(errno));
|
||||
error_printf_silent("Could not open tty device (%s)", strerror(errno));
|
||||
goto error_open;
|
||||
}
|
||||
|
||||
/* Make sure device is of tty type */
|
||||
if (!isatty(fd))
|
||||
{
|
||||
error_printf("Not a tty device");
|
||||
error_printf_silent("Not a tty device");
|
||||
goto error_isatty;
|
||||
}
|
||||
|
||||
|
|
@ -315,7 +315,7 @@ int connect_tty(void)
|
|||
} else
|
||||
{
|
||||
/* Error reading - device is likely unplugged */
|
||||
error_printf("Could not read from tty device");
|
||||
error_printf_silent("Could not read from tty device");
|
||||
goto error_read;
|
||||
}
|
||||
}
|
||||
|
|
@ -327,7 +327,7 @@ int connect_tty(void)
|
|||
status = read(STDIN_FILENO, &input_char, 1);
|
||||
if (status <= 0)
|
||||
{
|
||||
error_printf("Could not read from stdin");
|
||||
error_printf_silent("Could not read from stdin");
|
||||
goto error_read;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue