/* vi: set sw=4 ts=4: */
-/* stty -- change and print terminal line settings
- Copyright (C) 1990-1999 Free Software Foundation, Inc.
-
- Licensed under GPLv2 or later, see file LICENSE in this source tree.
-*/
+/*
+ * stty -- change and print terminal line settings
+ * Copyright (C) 1990-1999 Free Software Foundation, Inc.
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
+ */
/* Usage: stty [-ag] [-F device] [setting...]
+ *
+ * Options:
+ * -a Write all current settings to stdout in human-readable form.
+ * -g Write all current settings to stdout in stty-readable form.
+ * -F Open and use the specified device instead of stdin
+ *
+ * If no args are given, write to stdout the baud rate and settings that
+ * have been changed from their defaults. Mode reading and changes
+ * are done on the specified device, or stdin if none was specified.
+ *
+ * David MacKenzie <djm@gnu.ai.mit.edu>
+ *
+ * Special for busybox ported by Vladimir Oleynik <dzo@simtreas.ru> 2001
+ */
+//config:config STTY
+//config: bool "stty (8.6 kb)"
+//config: default y
+//config: help
+//config: stty is used to change and print terminal line settings.
- Options:
- -a Write all current settings to stdout in human-readable form.
- -g Write all current settings to stdout in stty-readable form.
- -F Open and use the specified device instead of stdin
-
- If no args are given, write to stdout the baud rate and settings that
- have been changed from their defaults. Mode reading and changes
- are done on the specified device, or stdin if none was specified.
-
- David MacKenzie <djm@gnu.ai.mit.edu>
-
- Special for busybox ported by Vladimir Oleynik <dzo@simtreas.ru> 2001
+//applet:IF_STTY(APPLET_NOEXEC(stty, stty, BB_DIR_BIN, BB_SUID_DROP, stty))
- */
+//kbuild:lib-$(CONFIG_STTY) += stty.o
//usage:#define stty_trivial_usage
//usage: "[-a|g] [-F DEVICE] [SETTING]..."
#ifndef CRDLY
# define CRDLY 0
#endif
+#ifndef CMSPAR
+# define CMSPAR 0
+#endif
#ifndef CRTSCTS
# define CRTSCTS 0
#endif
#endif
MI_ENTRY("parenb", control, REV, PARENB, 0 )
MI_ENTRY("parodd", control, REV, PARODD, 0 )
+#if CMSPAR
+ MI_ENTRY("cmspar", control, REV, CMSPAR, 0 )
+#endif
MI_ENTRY("cs5", control, 0, CS5, CSIZE)
MI_ENTRY("cs6", control, 0, CS6, CSIZE)
MI_ENTRY("cs7", control, 0, CS7, CSIZE)
#if ECHOKE
MI_ENTRY("echoke", local, SANE_SET | REV, ECHOKE, 0 )
MI_ENTRY("crtkill", local, OMIT | REV, ECHOKE, 0 )
+#endif
+ MI_ENTRY("flusho", local, SANE_UNSET | REV, FLUSHO, 0 )
+#ifdef EXTPROC
+ MI_ENTRY("extproc", local, SANE_UNSET | REV, EXTPROC, 0 )
#endif
;
#endif
MI_ENTRY("parenb", control, REV, PARENB, 0 )
MI_ENTRY("parodd", control, REV, PARODD, 0 )
+#if CMSPAR
+ MI_ENTRY("cmspar", control, REV, CMSPAR, 0 )
+#endif
MI_ENTRY("cs5", control, 0, CS5, CSIZE)
MI_ENTRY("cs6", control, 0, CS6, CSIZE)
MI_ENTRY("cs7", control, 0, CS7, CSIZE)
#if ECHOKE
MI_ENTRY("echoke", local, SANE_SET | REV, ECHOKE, 0 )
MI_ENTRY("crtkill", local, OMIT | REV, ECHOKE, 0 )
+#endif
+ MI_ENTRY("flusho", local, SANE_UNSET | REV, FLUSHO, 0 )
+#ifdef EXTPROC
+ MI_ENTRY("extproc", local, SANE_UNSET | REV, EXTPROC, 0 )
#endif
};
unsigned max_col;
/* Current position, to know when to wrap */
unsigned current_col;
- char buf[10];
} FIX_ALIASING;
#define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { \
+ setup_common_bufsiz(); \
G.device_name = bb_msg_standard_input; \
G.max_col = 80; \
+ G.current_col = 0; /* we are noexec, must clear */ \
} while (0)
static void set_speed_or_die(enum speed_setting type, const char *arg,
G.current_col++;
if (buf[0] != '\n') {
if (G.current_col + buflen >= G.max_col) {
- bb_putchar('\n');
G.current_col = 0;
- } else
+ bb_putchar('\n');
+ } else {
bb_putchar(' ');
+ }
}
}
fputs(buf, stdout);
for (i = 0; i != CIDX_min; ++i) {
char ch;
+ char buf10[10];
+
/* If swtch is the same as susp, don't print both */
#if VSWTCH == VSUSP
if (i == CIDX_swtch)
#endif
ch = mode->c_cc[control_info[i].offset];
if (ch == _POSIX_VDISABLE)
- strcpy(G.buf, "<undef>");
+ strcpy(buf10, "<undef>");
else
- visible(ch, G.buf, 0);
- wrapf("%s = %s;", nth_string(control_name, i), G.buf);
+ visible(ch, buf10, 0);
+ wrapf("%s = %s;", nth_string(control_name, i), buf10);
}
#if VEOF == VMIN
if ((mode->c_lflag & ICANON) == 0)