Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 815 by niro, Sat Sep 1 22:45:15 2007 UTC revision 816 by niro, Fri Apr 24 18:33:46 2009 UTC
# Line 8  Line 8 
8   * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.   * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
9   */   */
10    
11  /* no options, no getopt */  #include "libbb.h"
12    
13  #include <stdio.h>  /* BTW, which "standard" package has this utility? It doesn't seem
14  #include <stdlib.h>   * to be ncurses, coreutils, console-tools... then what? */
 #include <unistd.h>  
 #include "busybox.h"  
15    
16  int reset_main(int argc, char **argv)  #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  {  {
23   if (isatty(1)) {   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   /* See 'man 4 console_codes' for details:   /* See 'man 4 console_codes' for details:
31   * "ESC c" -- Reset   * "ESC c" -- Reset
32   * "ESC ( K" -- Select user mapping   * "ESC ( K" -- Select user mapping
# Line 26  int reset_main(int argc, char **argv) Line 35  int reset_main(int argc, char **argv)
35   * "ESC [ ? 25 h" -- Make cursor visible.   * "ESC [ ? 25 h" -- Make cursor visible.
36   */   */
37   printf("\033c\033(K\033[J\033[0m\033[?25h");   printf("\033c\033(K\033[J\033[0m\033[?25h");
38     /* 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   }   }
46   return EXIT_SUCCESS;   return EXIT_SUCCESS;
47  }  }
   

Legend:
Removed from v.815  
changed lines
  Added in v.816