mirror of
https://github.com/sheumann/hush.git
synced 2024-12-22 14:30:31 +00:00
Applied patch from Vladimir N. Oleynik that fixes incorrect behaviour in
recovery_mode and changed option processing.
This commit is contained in:
parent
42ab250709
commit
446dd27843
144
coreutils/stty.c
144
coreutils/stty.c
@ -24,10 +24,11 @@
|
||||
|
||||
David MacKenzie <djm@gnu.ai.mit.edu>
|
||||
|
||||
Special for busybox ported by vodz@usa.net 2001
|
||||
Special for busybox ported by Vladimir Oleynik <vodz@usa.net> 2001
|
||||
|
||||
*/
|
||||
|
||||
//#define TEST
|
||||
|
||||
#include <termios.h>
|
||||
#include <sys/ioctl.h>
|
||||
@ -219,7 +220,6 @@ static const struct mode_info mode_info[] = {
|
||||
#ifdef CRTSCTS
|
||||
{"crtscts", control, REV, CRTSCTS, 0 },
|
||||
#endif
|
||||
|
||||
{"ignbrk", input, SANE_UNSET | REV, IGNBRK, 0 },
|
||||
{"brkint", input, SANE_SET | REV, BRKINT, 0 },
|
||||
{"ignpar", input, REV, IGNPAR, 0 },
|
||||
@ -241,7 +241,6 @@ static const struct mode_info mode_info[] = {
|
||||
#ifdef IMAXBEL
|
||||
{"imaxbel", input, SANE_SET | REV, IMAXBEL, 0 },
|
||||
#endif
|
||||
|
||||
{"opost", output, SANE_SET | REV, OPOST, 0 },
|
||||
#ifdef OLCUC
|
||||
{"olcuc", output, SANE_UNSET | REV, OLCUC, 0 },
|
||||
@ -274,6 +273,7 @@ static const struct mode_info mode_info[] = {
|
||||
{"cr1", output, SANE_UNSET, CR1, CRDLY},
|
||||
{"cr0", output, SANE_SET, CR0, CRDLY},
|
||||
#endif
|
||||
|
||||
#ifdef TABDLY
|
||||
{"tab3", output, SANE_UNSET, TAB3, TABDLY},
|
||||
{"tab2", output, SANE_UNSET, TAB2, TABDLY},
|
||||
@ -284,6 +284,7 @@ static const struct mode_info mode_info[] = {
|
||||
{"tab3", output, SANE_UNSET, OXTABS, 0 },
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef BSDLY
|
||||
{"bs1", output, SANE_UNSET, BS1, BSDLY},
|
||||
{"bs0", output, SANE_SET, BS0, BSDLY},
|
||||
@ -296,7 +297,6 @@ static const struct mode_info mode_info[] = {
|
||||
{"ff1", output, SANE_UNSET, FF1, FFDLY},
|
||||
{"ff0", output, SANE_SET, FF0, FFDLY},
|
||||
#endif
|
||||
|
||||
{"isig", local, SANE_SET | REV, ISIG, 0 },
|
||||
{"icanon", local, SANE_SET | REV, ICANON, 0 },
|
||||
#ifdef IEXTEN
|
||||
@ -326,7 +326,6 @@ static const struct mode_info mode_info[] = {
|
||||
{"echoke", local, SANE_SET | REV, ECHOKE, 0 },
|
||||
{"crtkill", local, REV | OMIT, ECHOKE, 0 },
|
||||
#endif
|
||||
|
||||
{evenp, combination, REV | OMIT, 0, 0 },
|
||||
{parity, combination, REV | OMIT, 0, 0 },
|
||||
{stty_oddp, combination, REV | OMIT, 0, 0 },
|
||||
@ -399,7 +398,6 @@ static const struct control_info control_info[] = {
|
||||
#ifdef VSTATUS
|
||||
{"status", CSTATUS, VSTATUS},
|
||||
#endif
|
||||
|
||||
/* These must be last because of the display routines. */
|
||||
{stty_min, 1, VMIN},
|
||||
{stty_time, 0, VTIME},
|
||||
@ -433,7 +431,6 @@ static void set_control_char(const struct control_info *info,
|
||||
static void set_speed(enum speed_setting type,
|
||||
const char *arg, struct termios *mode);
|
||||
static void set_window_size(int rows, int cols, int fd,
|
||||
|
||||
const char *device_name);
|
||||
|
||||
/* The width of the screen, for output wrapping. */
|
||||
@ -475,7 +472,11 @@ static const struct suffix_mult stty_suffixes[] = {
|
||||
{NULL, 0 }
|
||||
};
|
||||
|
||||
#ifndef TEST
|
||||
extern int stty_main(int argc, char **argv)
|
||||
#else
|
||||
extern int main(int argc, char **argv)
|
||||
#endif
|
||||
{
|
||||
struct termios mode;
|
||||
enum output_type output_type;
|
||||
@ -581,43 +582,39 @@ extern int stty_main(int argc, char **argv)
|
||||
++argv[k];
|
||||
reversed = 1;
|
||||
}
|
||||
for (i = 0; i < NUM_mode_info; ++i) {
|
||||
for (i = 0; i < NUM_mode_info; ++i)
|
||||
if (STREQ(argv[k], mode_info[i].name)) {
|
||||
match_found = set_mode(&mode_info[i], reversed, &mode);
|
||||
require_set_attr = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (match_found == 0 && reversed) {
|
||||
|
||||
if (match_found == 0 && reversed)
|
||||
error_msg_and_die("invalid argument `%s'", --argv[k]);
|
||||
}
|
||||
if (match_found == 0) {
|
||||
for (i = 0; i < NUM_control_info; ++i) {
|
||||
|
||||
if (match_found == 0)
|
||||
for (i = 0; i < NUM_control_info; ++i)
|
||||
if (STREQ(argv[k], control_info[i].name)) {
|
||||
if (k == argc - 1) {
|
||||
if (k == argc - 1)
|
||||
error_msg_and_die("missing argument to `%s'", argv[k]);
|
||||
}
|
||||
match_found = 1;
|
||||
++k;
|
||||
set_control_char(&control_info[i], argv[k], &mode);
|
||||
require_set_attr = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (match_found == 0) {
|
||||
if (STREQ(argv[k], "ispeed")) {
|
||||
if (k == argc - 1) {
|
||||
if (k == argc - 1)
|
||||
error_msg_and_die("missing argument to `%s'", argv[k]);
|
||||
}
|
||||
++k;
|
||||
set_speed(input_speed, argv[k], &mode);
|
||||
speed_was_set = 1;
|
||||
require_set_attr = 1;
|
||||
} else if (STREQ(argv[k], "ospeed")) {
|
||||
if (k == argc - 1) {
|
||||
if (k == argc - 1)
|
||||
error_msg_and_die("missing argument to `%s'", argv[k]);
|
||||
}
|
||||
++k;
|
||||
set_speed(output_speed, argv[k], &mode);
|
||||
speed_was_set = 1;
|
||||
@ -625,16 +622,14 @@ extern int stty_main(int argc, char **argv)
|
||||
}
|
||||
#ifdef TIOCGWINSZ
|
||||
else if (STREQ(argv[k], "rows")) {
|
||||
if (k == argc - 1) {
|
||||
if (k == argc - 1)
|
||||
error_msg_and_die("missing argument to `%s'", argv[k]);
|
||||
}
|
||||
++k;
|
||||
set_window_size((int) parse_number(argv[k], stty_suffixes),
|
||||
-1, fd, device_name);
|
||||
} else if (STREQ(argv[k], "cols") || STREQ(argv[k], "columns")) {
|
||||
if (k == argc - 1) {
|
||||
if (k == argc - 1)
|
||||
error_msg_and_die("missing argument to `%s'", argv[k]);
|
||||
}
|
||||
++k;
|
||||
set_window_size(-1,
|
||||
(int) parse_number(argv[k], stty_suffixes),
|
||||
@ -647,9 +642,8 @@ extern int stty_main(int argc, char **argv)
|
||||
#endif
|
||||
#ifdef HAVE_C_LINE
|
||||
else if (STREQ(argv[k], "line")) {
|
||||
if (k == argc - 1) {
|
||||
if (k == argc - 1)
|
||||
error_msg_and_die("missing argument to `%s'", argv[k]);
|
||||
}
|
||||
++k;
|
||||
mode.c_line = parse_number(argv[k], stty_suffixes);
|
||||
require_set_attr = 1;
|
||||
@ -658,17 +652,15 @@ extern int stty_main(int argc, char **argv)
|
||||
else if (STREQ(argv[k], "speed")) {
|
||||
max_col = screen_columns();
|
||||
display_speed(&mode, 0);
|
||||
} else if (string_to_baud(argv[k]) != (speed_t) - 1) {
|
||||
} else if (recover_mode(argv[k], &mode) == 1)
|
||||
require_set_attr = 1;
|
||||
else if (string_to_baud(argv[k]) != (speed_t) - 1) {
|
||||
set_speed(both_speeds, argv[k], &mode);
|
||||
speed_was_set = 1;
|
||||
require_set_attr = 1;
|
||||
} else {
|
||||
if (recover_mode(argv[k], &mode) == 0) {
|
||||
} else
|
||||
error_msg_and_die("invalid argument `%s'", argv[k]);
|
||||
}
|
||||
require_set_attr = 1;
|
||||
}
|
||||
}
|
||||
k++;
|
||||
}
|
||||
|
||||
@ -712,21 +704,8 @@ extern int stty_main(int argc, char **argv)
|
||||
new_mode.c_cflag &= (~CIBAUD);
|
||||
if (speed_was_set || memcmp(&mode, &new_mode, sizeof(mode)) != 0)
|
||||
#endif
|
||||
{
|
||||
error_msg_and_die ("%s: unable to perform all requested operations",
|
||||
device_name);
|
||||
#ifdef TESTING
|
||||
{
|
||||
size_t i;
|
||||
|
||||
printf("new_mode: mode\n");
|
||||
for (i = 0; i < sizeof(new_mode); i++)
|
||||
printf("0x%02x: 0x%02x\n",
|
||||
*(((unsigned char *) &new_mode) + i),
|
||||
*(((unsigned char *) &mode) + i));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1382,6 +1361,79 @@ static const char *visible(unsigned int ch)
|
||||
return (const char *) buf;
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
unsigned long parse_number(const char *numstr,
|
||||
const struct suffix_mult *suffixes)
|
||||
{
|
||||
const struct suffix_mult *sm;
|
||||
unsigned long int ret;
|
||||
int len;
|
||||
char *end;
|
||||
|
||||
ret = strtoul(numstr, &end, 10);
|
||||
if (numstr == end)
|
||||
error_msg_and_die("invalid number `%s'", numstr);
|
||||
while (end[0] != '\0') {
|
||||
sm = suffixes;
|
||||
while ( sm != 0 ) {
|
||||
if(sm->suffix) {
|
||||
len = strlen(sm->suffix);
|
||||
if (strncmp(sm->suffix, end, len) == 0) {
|
||||
ret *= sm->mult;
|
||||
end += len;
|
||||
break;
|
||||
}
|
||||
sm++;
|
||||
|
||||
} else
|
||||
sm = 0;
|
||||
}
|
||||
if (sm == 0)
|
||||
error_msg_and_die("invalid number `%s'", numstr);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
const char *applet_name = "stty";
|
||||
|
||||
static void verror_msg(const char *s, va_list p)
|
||||
{
|
||||
fflush(stdout);
|
||||
fprintf(stderr, "%s: ", applet_name);
|
||||
vfprintf(stderr, s, p);
|
||||
}
|
||||
|
||||
extern void error_msg_and_die(const char *s, ...)
|
||||
{
|
||||
va_list p;
|
||||
|
||||
va_start(p, s);
|
||||
verror_msg(s, p);
|
||||
va_end(p);
|
||||
putc('\n', stderr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static void vperror_msg(const char *s, va_list p)
|
||||
{
|
||||
int err=errno;
|
||||
verror_msg(s, p);
|
||||
if (*s) s = ": ";
|
||||
fprintf(stderr, "%s%s\n", s, strerror(err));
|
||||
}
|
||||
|
||||
extern void perror_msg_and_die(const char *s, ...)
|
||||
{
|
||||
va_list p;
|
||||
|
||||
va_start(p, s);
|
||||
vperror_msg(s, p);
|
||||
va_end(p);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
|
144
stty.c
144
stty.c
@ -24,10 +24,11 @@
|
||||
|
||||
David MacKenzie <djm@gnu.ai.mit.edu>
|
||||
|
||||
Special for busybox ported by vodz@usa.net 2001
|
||||
Special for busybox ported by Vladimir Oleynik <vodz@usa.net> 2001
|
||||
|
||||
*/
|
||||
|
||||
//#define TEST
|
||||
|
||||
#include <termios.h>
|
||||
#include <sys/ioctl.h>
|
||||
@ -219,7 +220,6 @@ static const struct mode_info mode_info[] = {
|
||||
#ifdef CRTSCTS
|
||||
{"crtscts", control, REV, CRTSCTS, 0 },
|
||||
#endif
|
||||
|
||||
{"ignbrk", input, SANE_UNSET | REV, IGNBRK, 0 },
|
||||
{"brkint", input, SANE_SET | REV, BRKINT, 0 },
|
||||
{"ignpar", input, REV, IGNPAR, 0 },
|
||||
@ -241,7 +241,6 @@ static const struct mode_info mode_info[] = {
|
||||
#ifdef IMAXBEL
|
||||
{"imaxbel", input, SANE_SET | REV, IMAXBEL, 0 },
|
||||
#endif
|
||||
|
||||
{"opost", output, SANE_SET | REV, OPOST, 0 },
|
||||
#ifdef OLCUC
|
||||
{"olcuc", output, SANE_UNSET | REV, OLCUC, 0 },
|
||||
@ -274,6 +273,7 @@ static const struct mode_info mode_info[] = {
|
||||
{"cr1", output, SANE_UNSET, CR1, CRDLY},
|
||||
{"cr0", output, SANE_SET, CR0, CRDLY},
|
||||
#endif
|
||||
|
||||
#ifdef TABDLY
|
||||
{"tab3", output, SANE_UNSET, TAB3, TABDLY},
|
||||
{"tab2", output, SANE_UNSET, TAB2, TABDLY},
|
||||
@ -284,6 +284,7 @@ static const struct mode_info mode_info[] = {
|
||||
{"tab3", output, SANE_UNSET, OXTABS, 0 },
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef BSDLY
|
||||
{"bs1", output, SANE_UNSET, BS1, BSDLY},
|
||||
{"bs0", output, SANE_SET, BS0, BSDLY},
|
||||
@ -296,7 +297,6 @@ static const struct mode_info mode_info[] = {
|
||||
{"ff1", output, SANE_UNSET, FF1, FFDLY},
|
||||
{"ff0", output, SANE_SET, FF0, FFDLY},
|
||||
#endif
|
||||
|
||||
{"isig", local, SANE_SET | REV, ISIG, 0 },
|
||||
{"icanon", local, SANE_SET | REV, ICANON, 0 },
|
||||
#ifdef IEXTEN
|
||||
@ -326,7 +326,6 @@ static const struct mode_info mode_info[] = {
|
||||
{"echoke", local, SANE_SET | REV, ECHOKE, 0 },
|
||||
{"crtkill", local, REV | OMIT, ECHOKE, 0 },
|
||||
#endif
|
||||
|
||||
{evenp, combination, REV | OMIT, 0, 0 },
|
||||
{parity, combination, REV | OMIT, 0, 0 },
|
||||
{stty_oddp, combination, REV | OMIT, 0, 0 },
|
||||
@ -399,7 +398,6 @@ static const struct control_info control_info[] = {
|
||||
#ifdef VSTATUS
|
||||
{"status", CSTATUS, VSTATUS},
|
||||
#endif
|
||||
|
||||
/* These must be last because of the display routines. */
|
||||
{stty_min, 1, VMIN},
|
||||
{stty_time, 0, VTIME},
|
||||
@ -433,7 +431,6 @@ static void set_control_char(const struct control_info *info,
|
||||
static void set_speed(enum speed_setting type,
|
||||
const char *arg, struct termios *mode);
|
||||
static void set_window_size(int rows, int cols, int fd,
|
||||
|
||||
const char *device_name);
|
||||
|
||||
/* The width of the screen, for output wrapping. */
|
||||
@ -475,7 +472,11 @@ static const struct suffix_mult stty_suffixes[] = {
|
||||
{NULL, 0 }
|
||||
};
|
||||
|
||||
#ifndef TEST
|
||||
extern int stty_main(int argc, char **argv)
|
||||
#else
|
||||
extern int main(int argc, char **argv)
|
||||
#endif
|
||||
{
|
||||
struct termios mode;
|
||||
enum output_type output_type;
|
||||
@ -581,43 +582,39 @@ extern int stty_main(int argc, char **argv)
|
||||
++argv[k];
|
||||
reversed = 1;
|
||||
}
|
||||
for (i = 0; i < NUM_mode_info; ++i) {
|
||||
for (i = 0; i < NUM_mode_info; ++i)
|
||||
if (STREQ(argv[k], mode_info[i].name)) {
|
||||
match_found = set_mode(&mode_info[i], reversed, &mode);
|
||||
require_set_attr = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (match_found == 0 && reversed) {
|
||||
|
||||
if (match_found == 0 && reversed)
|
||||
error_msg_and_die("invalid argument `%s'", --argv[k]);
|
||||
}
|
||||
if (match_found == 0) {
|
||||
for (i = 0; i < NUM_control_info; ++i) {
|
||||
|
||||
if (match_found == 0)
|
||||
for (i = 0; i < NUM_control_info; ++i)
|
||||
if (STREQ(argv[k], control_info[i].name)) {
|
||||
if (k == argc - 1) {
|
||||
if (k == argc - 1)
|
||||
error_msg_and_die("missing argument to `%s'", argv[k]);
|
||||
}
|
||||
match_found = 1;
|
||||
++k;
|
||||
set_control_char(&control_info[i], argv[k], &mode);
|
||||
require_set_attr = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (match_found == 0) {
|
||||
if (STREQ(argv[k], "ispeed")) {
|
||||
if (k == argc - 1) {
|
||||
if (k == argc - 1)
|
||||
error_msg_and_die("missing argument to `%s'", argv[k]);
|
||||
}
|
||||
++k;
|
||||
set_speed(input_speed, argv[k], &mode);
|
||||
speed_was_set = 1;
|
||||
require_set_attr = 1;
|
||||
} else if (STREQ(argv[k], "ospeed")) {
|
||||
if (k == argc - 1) {
|
||||
if (k == argc - 1)
|
||||
error_msg_and_die("missing argument to `%s'", argv[k]);
|
||||
}
|
||||
++k;
|
||||
set_speed(output_speed, argv[k], &mode);
|
||||
speed_was_set = 1;
|
||||
@ -625,16 +622,14 @@ extern int stty_main(int argc, char **argv)
|
||||
}
|
||||
#ifdef TIOCGWINSZ
|
||||
else if (STREQ(argv[k], "rows")) {
|
||||
if (k == argc - 1) {
|
||||
if (k == argc - 1)
|
||||
error_msg_and_die("missing argument to `%s'", argv[k]);
|
||||
}
|
||||
++k;
|
||||
set_window_size((int) parse_number(argv[k], stty_suffixes),
|
||||
-1, fd, device_name);
|
||||
} else if (STREQ(argv[k], "cols") || STREQ(argv[k], "columns")) {
|
||||
if (k == argc - 1) {
|
||||
if (k == argc - 1)
|
||||
error_msg_and_die("missing argument to `%s'", argv[k]);
|
||||
}
|
||||
++k;
|
||||
set_window_size(-1,
|
||||
(int) parse_number(argv[k], stty_suffixes),
|
||||
@ -647,9 +642,8 @@ extern int stty_main(int argc, char **argv)
|
||||
#endif
|
||||
#ifdef HAVE_C_LINE
|
||||
else if (STREQ(argv[k], "line")) {
|
||||
if (k == argc - 1) {
|
||||
if (k == argc - 1)
|
||||
error_msg_and_die("missing argument to `%s'", argv[k]);
|
||||
}
|
||||
++k;
|
||||
mode.c_line = parse_number(argv[k], stty_suffixes);
|
||||
require_set_attr = 1;
|
||||
@ -658,17 +652,15 @@ extern int stty_main(int argc, char **argv)
|
||||
else if (STREQ(argv[k], "speed")) {
|
||||
max_col = screen_columns();
|
||||
display_speed(&mode, 0);
|
||||
} else if (string_to_baud(argv[k]) != (speed_t) - 1) {
|
||||
} else if (recover_mode(argv[k], &mode) == 1)
|
||||
require_set_attr = 1;
|
||||
else if (string_to_baud(argv[k]) != (speed_t) - 1) {
|
||||
set_speed(both_speeds, argv[k], &mode);
|
||||
speed_was_set = 1;
|
||||
require_set_attr = 1;
|
||||
} else {
|
||||
if (recover_mode(argv[k], &mode) == 0) {
|
||||
} else
|
||||
error_msg_and_die("invalid argument `%s'", argv[k]);
|
||||
}
|
||||
require_set_attr = 1;
|
||||
}
|
||||
}
|
||||
k++;
|
||||
}
|
||||
|
||||
@ -712,21 +704,8 @@ extern int stty_main(int argc, char **argv)
|
||||
new_mode.c_cflag &= (~CIBAUD);
|
||||
if (speed_was_set || memcmp(&mode, &new_mode, sizeof(mode)) != 0)
|
||||
#endif
|
||||
{
|
||||
error_msg_and_die ("%s: unable to perform all requested operations",
|
||||
device_name);
|
||||
#ifdef TESTING
|
||||
{
|
||||
size_t i;
|
||||
|
||||
printf("new_mode: mode\n");
|
||||
for (i = 0; i < sizeof(new_mode); i++)
|
||||
printf("0x%02x: 0x%02x\n",
|
||||
*(((unsigned char *) &new_mode) + i),
|
||||
*(((unsigned char *) &mode) + i));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1382,6 +1361,79 @@ static const char *visible(unsigned int ch)
|
||||
return (const char *) buf;
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
unsigned long parse_number(const char *numstr,
|
||||
const struct suffix_mult *suffixes)
|
||||
{
|
||||
const struct suffix_mult *sm;
|
||||
unsigned long int ret;
|
||||
int len;
|
||||
char *end;
|
||||
|
||||
ret = strtoul(numstr, &end, 10);
|
||||
if (numstr == end)
|
||||
error_msg_and_die("invalid number `%s'", numstr);
|
||||
while (end[0] != '\0') {
|
||||
sm = suffixes;
|
||||
while ( sm != 0 ) {
|
||||
if(sm->suffix) {
|
||||
len = strlen(sm->suffix);
|
||||
if (strncmp(sm->suffix, end, len) == 0) {
|
||||
ret *= sm->mult;
|
||||
end += len;
|
||||
break;
|
||||
}
|
||||
sm++;
|
||||
|
||||
} else
|
||||
sm = 0;
|
||||
}
|
||||
if (sm == 0)
|
||||
error_msg_and_die("invalid number `%s'", numstr);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
const char *applet_name = "stty";
|
||||
|
||||
static void verror_msg(const char *s, va_list p)
|
||||
{
|
||||
fflush(stdout);
|
||||
fprintf(stderr, "%s: ", applet_name);
|
||||
vfprintf(stderr, s, p);
|
||||
}
|
||||
|
||||
extern void error_msg_and_die(const char *s, ...)
|
||||
{
|
||||
va_list p;
|
||||
|
||||
va_start(p, s);
|
||||
verror_msg(s, p);
|
||||
va_end(p);
|
||||
putc('\n', stderr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static void vperror_msg(const char *s, va_list p)
|
||||
{
|
||||
int err=errno;
|
||||
verror_msg(s, p);
|
||||
if (*s) s = ": ";
|
||||
fprintf(stderr, "%s%s\n", s, strerror(err));
|
||||
}
|
||||
|
||||
extern void perror_msg_and_die(const char *s, ...)
|
||||
{
|
||||
va_list p;
|
||||
|
||||
va_start(p, s);
|
||||
vperror_msg(s, p);
|
||||
va_end(p);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
|
Loading…
Reference in New Issue
Block a user