Cleanup error printing routines

Clean up so that only the following error related printing functions are
used: tio_error_printf(), tio_error_printf_silent(),
tio_warning_printf().

A session mode switch is introduced for error printing so that it will
print error messages with better formatting depending on in or out of
session.
This commit is contained in:
Martin Lund 2022-07-11 23:15:00 +02:00
parent 73a30a89ef
commit ac859f41b9
9 changed files with 122 additions and 77 deletions

View file

@ -340,7 +340,7 @@ void options_parse(int argc, char *argv[])
option.color = string_to_long(optarg);
if ((option.color < 0) || (option.color > 255))
{
printf("Error: Invalid color code\n");
tio_error_printf("Invalid color code");
exit(EXIT_FAILURE);
}
break;
@ -382,17 +382,17 @@ void options_parse(int argc, char *argv[])
if (strlen(option.tty_device) == 0)
{
printf("Error: Missing tty device or sub-configuration name\n");
tio_error_printf("Missing tty device or sub-configuration name");
exit(EXIT_FAILURE);
}
/* Print any remaining command line arguments (unknown options) */
if (optind < argc)
{
printf("Error: Unknown argument ");
fprintf(stderr, "Error: Unknown argument ");
while (optind < argc)
printf("%s ", argv[optind++]);
printf("\n");
fprintf(stderr, "\n");
exit(EXIT_FAILURE);
}
}