summaryrefslogtreecommitdiff
path: root/loginutils/getty.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-11-05 13:20:58 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-11-05 13:20:58 +0000
commit202ac504e1addf0aa2debd53e7cd2411cc73ac8c (patch)
tree20a02054110c8b0dbec1f94252a9d2b759dac3ae /loginutils/getty.c
parent905ed8730f1b78461cf83e719a1e077214c2432c (diff)
downloadbusybox-w32-202ac504e1addf0aa2debd53e7cd2411cc73ac8c.tar.gz
busybox-w32-202ac504e1addf0aa2debd53e7cd2411cc73ac8c.tar.bz2
busybox-w32-202ac504e1addf0aa2debd53e7cd2411cc73ac8c.zip
*: code shrink by adding a wrapper around very common tcsetattr(0, TCSANOW, xx) op
function old new delta tcsetattr_stdin_TCSANOW - 14 +14 set_sane_term 116 113 -3 top_main 1277 1273 -4 make_new_session 421 415 -6 rawmode 133 126 -7 reset_term 18 10 -8 die 43 35 -8 cookmode 62 54 -8 vlock_main 425 415 -10 read_line_input 3165 3155 -10 bb_askpass 357 347 -10 fsck_minix_main 3079 3065 -14 getty_main 2375 2332 -43 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/12 up/down: 14/-131) Total: -117 bytes
Diffstat (limited to 'loginutils/getty.c')
-rw-r--r--loginutils/getty.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/loginutils/getty.c b/loginutils/getty.c
index 8b0e729fb..0f536888b 100644
--- a/loginutils/getty.c
+++ b/loginutils/getty.c
@@ -279,7 +279,7 @@ static void termios_init(struct termios *tp, int speed, struct options *op)
279 */ 279 */
280#ifdef __linux__ 280#ifdef __linux__
281 /* flush input and output queues, important for modems! */ 281 /* flush input and output queues, important for modems! */
282 ioctl(0, TCFLSH, TCIOFLUSH); 282 ioctl(0, TCFLSH, TCIOFLUSH); /* tcflush(0, TCIOFLUSH)? - same */
283#endif 283#endif
284 284
285 tp->c_cflag = CS8 | HUPCL | CREAD | speed; 285 tp->c_cflag = CS8 | HUPCL | CREAD | speed;
@@ -297,7 +297,7 @@ static void termios_init(struct termios *tp, int speed, struct options *op)
297 tp->c_cflag |= CRTSCTS; 297 tp->c_cflag |= CRTSCTS;
298#endif 298#endif
299 299
300 ioctl(0, TCSETS, tp); 300 tcsetattr_stdin_TCSANOW(tp);
301 301
302 debug("term_io 2\n"); 302 debug("term_io 2\n");
303} 303}
@@ -334,7 +334,7 @@ static void auto_baud(char *buf, unsigned size_buf, struct termios *tp)
334 tp->c_iflag |= ISTRIP; /* enable 8th-bit stripping */ 334 tp->c_iflag |= ISTRIP; /* enable 8th-bit stripping */
335 vmin = tp->c_cc[VMIN]; 335 vmin = tp->c_cc[VMIN];
336 tp->c_cc[VMIN] = 0; /* don't block if queue empty */ 336 tp->c_cc[VMIN] = 0; /* don't block if queue empty */
337 ioctl(0, TCSETS, tp); 337 tcsetattr_stdin_TCSANOW(tp);
338 338
339 /* 339 /*
340 * Wait for a while, then read everything the modem has said so far and 340 * Wait for a while, then read everything the modem has said so far and
@@ -359,7 +359,7 @@ static void auto_baud(char *buf, unsigned size_buf, struct termios *tp)
359 /* Restore terminal settings. Errors will be dealt with later on. */ 359 /* Restore terminal settings. Errors will be dealt with later on. */
360 tp->c_iflag = iflag; 360 tp->c_iflag = iflag;
361 tp->c_cc[VMIN] = vmin; 361 tp->c_cc[VMIN] = vmin;
362 ioctl(0, TCSETS, tp); 362 tcsetattr_stdin_TCSANOW(tp);
363} 363}
364 364
365/* do_prompt - show login prompt, optionally preceded by /etc/issue contents */ 365/* do_prompt - show login prompt, optionally preceded by /etc/issue contents */
@@ -404,7 +404,7 @@ static char *get_logname(char *logname, unsigned size_logname,
404 404
405 /* Flush pending input (esp. after parsing or switching the baud rate). */ 405 /* Flush pending input (esp. after parsing or switching the baud rate). */
406 sleep(1); 406 sleep(1);
407 ioctl(0, TCFLSH, TCIFLUSH); 407 ioctl(0, TCFLSH, TCIFLUSH); /* tcflush(0, TCIOFLUSH)? - same */
408 408
409 /* Prompt for and read a login name. */ 409 /* Prompt for and read a login name. */
410 logname[0] = '\0'; 410 logname[0] = '\0';
@@ -552,12 +552,13 @@ static void termios_final(struct options *op, struct termios *tp, struct chardat
552 } 552 }
553#endif 553#endif
554 /* Optionally enable hardware flow control */ 554 /* Optionally enable hardware flow control */
555#ifdef CRTSCTS 555#ifdef CRTSCTS
556 if (op->flags & F_RTSCTS) 556 if (op->flags & F_RTSCTS)
557 tp->c_cflag |= CRTSCTS; 557 tp->c_cflag |= CRTSCTS;
558#endif 558#endif
559 559
560 /* Finally, make the new settings effective */ 560 /* Finally, make the new settings effective */
561 /* It's tcsetattr_stdin_TCSANOW() + error check */
561 ioctl_or_perror_and_die(0, TCSETS, tp, "%s: TCSETS", op->tty); 562 ioctl_or_perror_and_die(0, TCSETS, tp, "%s: TCSETS", op->tty);
562} 563}
563 564
@@ -689,6 +690,7 @@ int getty_main(int argc UNUSED_PARAM, char **argv)
689 * by patching the SunOS kernel variable "zsadtrlow" to a larger value; 690 * by patching the SunOS kernel variable "zsadtrlow" to a larger value;
690 * 5 seconds seems to be a good value. 691 * 5 seconds seems to be a good value.
691 */ 692 */
693 /* tcgetattr() + error check */
692 ioctl_or_perror_and_die(0, TCGETS, &termios, "%s: TCGETS", options.tty); 694 ioctl_or_perror_and_die(0, TCGETS, &termios, "%s: TCGETS", options.tty);
693 695
694#ifdef __linux__ 696#ifdef __linux__
@@ -753,7 +755,7 @@ int getty_main(int argc UNUSED_PARAM, char **argv)
753 baud_index = (baud_index + 1) % options.numspeed; 755 baud_index = (baud_index + 1) % options.numspeed;
754 termios.c_cflag &= ~CBAUD; 756 termios.c_cflag &= ~CBAUD;
755 termios.c_cflag |= options.speeds[baud_index]; 757 termios.c_cflag |= options.speeds[baud_index];
756 ioctl(0, TCSETS, &termios); 758 tcsetattr_stdin_TCSANOW(&termios);
757 } 759 }
758 } 760 }
759 761