-extern int more_main(int argc, char **argv)
-{
- int c, lines=0, input=0;
- int next_page=0;
- struct stat st;
- FILE *file;
-
- argc--;
- argv++;
-
- if ( argc > 0 && (strcmp(*argv,"--help")==0 || strcmp(*argv,"-h")==0) ) {
- usage (more_usage);
- }
- do {
- if (argc==0) {
- file = stdin;
- }
- else
- file = fopen(*argv, "r");
-
- if (file == NULL) {
- perror(*argv);
- exit(FALSE);
- }
- fstat(fileno(file), &st);
-
-#ifdef BB_MORE_TERM
- cin = fopen("/dev/tty", "r");
- if (!cin)
- cin = fopen("/dev/console", "r");
-#ifdef USE_OLD_TERMIO
- ioctl(fileno(cin),TCGETA,&initial_settings);
+ argc--;
+ argv++;
+
+ do {
+ if (argc == 0) {
+ file = stdin;
+ } else
+ file = xfopen(*argv, "r");
+
+ fstat(fileno(file), &st);
+
+#ifdef BB_FEATURE_USE_TERMIOS
+ 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)",