- cin = fopen("/dev/tty", "r");
- if (!cin)
- cin = fopen("/dev/console", "r");
-#ifdef USE_OLD_TERMIO
- ioctl(fileno(cin),TCGETA,&initial_settings);
+ cin = fopen("/dev/tty", "r");
+ if (!cin)
+ cin = fopen("/dev/console", "r");
+ getTermSettings(fileno(cin), &initial_settings);
+ new_settings = initial_settings;
+ new_settings.c_cc[VMIN] = 1;
+ new_settings.c_cc[VTIME] = 0;
+ new_settings.c_lflag &= ~ICANON;
+ new_settings.c_lflag &= ~ECHO;
+ setTermSettings(fileno(cin), &new_settings);
+
+# ifdef BB_FEATURE_AUTOWIDTH
+ ioctl(fileno(stdout), TIOCGWINSZ, &win);
+ if (win.ws_row > 4)
+ terminal_height = win.ws_row - 2;
+ if (win.ws_col > 0)
+ terminal_width = win.ws_col - 1;
+# endif
+
+ (void) signal(SIGINT, gotsig);
+ (void) signal(SIGQUIT, gotsig);
+ (void) signal(SIGTERM, gotsig);
+
+#endif
+ while ((c = getc(file)) != EOF) {
+ if (please_display_more_prompt) {
+ int len = 0;
+
+ please_display_more_prompt = 0;
+ lines = 0;
+ len = printf("--More-- ");
+ if (file != stdin) {
+#if _FILE_OFFSET_BITS == 64
+ len += printf("(%d%% of %lld bytes)",