Magellan Linux

Annotation of /trunk/mkinitrd-magellan/busybox/console-tools/reset.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1123 - (hide annotations) (download)
Wed Aug 18 21:56:57 2010 UTC (13 years, 8 months ago) by niro
File MIME type: text/plain
File size: 1338 byte(s)
-updated to busybox-1.17.1
1 niro 532 /* vi: set sw=4 ts=4: */
2     /*
3     * Mini reset implementation for busybox
4     *
5     * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
6     * Written by Erik Andersen and Kent Robotti <robotti@metconnect.com>
7     *
8     * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
9     */
10    
11 niro 816 #include "libbb.h"
12 niro 532
13 niro 816 /* BTW, which "standard" package has this utility? It doesn't seem
14     * to be ncurses, coreutils, console-tools... then what? */
15 niro 532
16 niro 816 #if ENABLE_STTY
17     int stty_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
18     #endif
19    
20     int reset_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
21     int reset_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
22 niro 532 {
23 niro 816 static const char *const args[] = {
24     "stty", "sane", NULL
25     };
26    
27     /* no options, no getopt */
28    
29     if (isatty(STDIN_FILENO) && isatty(STDOUT_FILENO)) {
30 niro 532 /* See 'man 4 console_codes' for details:
31 niro 1123 * "ESC c" -- Reset
32     * "ESC ( K" -- Select user mapping
33     * "ESC [ J" -- Erase to the end of screen
34     * "ESC [ 0 m" -- Reset all display attributes
35     * "ESC [ ? 25 h" -- Make cursor visible
36 niro 532 */
37     printf("\033c\033(K\033[J\033[0m\033[?25h");
38 niro 816 /* http://bugs.busybox.net/view.php?id=1414:
39     * people want it to reset echo etc: */
40     #if ENABLE_STTY
41     return stty_main(2, (char**)args);
42     #else
43     execvp("stty", (char**)args);
44     #endif
45 niro 532 }
46     return EXIT_SUCCESS;
47     }