aboutsummaryrefslogtreecommitdiff
path: root/console-tools/setconsole.c
diff options
context:
space:
mode:
Diffstat (limited to 'console-tools/setconsole.c')
-rw-r--r--console-tools/setconsole.c32
1 files changed, 13 insertions, 19 deletions
diff --git a/console-tools/setconsole.c b/console-tools/setconsole.c
index 8765a7c2e..82fe83f22 100644
--- a/console-tools/setconsole.c
+++ b/console-tools/setconsole.c
@@ -3,40 +3,34 @@
3 * setconsole.c - redirect system console output 3 * setconsole.c - redirect system console output
4 * 4 *
5 * Copyright (C) 2004,2005 Enrik Berkhan <Enrik.Berkhan@inka.de> 5 * Copyright (C) 2004,2005 Enrik Berkhan <Enrik.Berkhan@inka.de>
6 * Copyright (C) 2008 Bernhard Fischer
6 * 7 *
7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 8 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
8 */ 9 */
9 10
10#include "libbb.h" 11#include "libbb.h"
11 12
12#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
13static const char setconsole_longopts[] ALIGN1 =
14 "reset\0" No_argument "r"
15 ;
16#endif
17
18#define OPT_SETCONS_RESET 1
19
20int setconsole_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 13int setconsole_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
21int setconsole_main(int argc, char **argv) 14int setconsole_main(int ATTRIBUTE_UNUSED argc, char **argv)
22{ 15{
23 unsigned long flags;
24 const char *device = CURRENT_TTY; 16 const char *device = CURRENT_TTY;
17 bool reset;
25 18
26#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS 19#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
20 static const char setconsole_longopts[] ALIGN1 =
21 "reset\0" No_argument "r"
22 ;
27 applet_long_options = setconsole_longopts; 23 applet_long_options = setconsole_longopts;
28#endif 24#endif
29 flags = getopt32(argv, "r"); 25 /* at most one non-option argument */
30 26 opt_complementary = "?1";
31 if (argc - optind > 1) 27 reset = getopt32(argv, "r");
32 bb_show_usage();
33 28
34 if (argc - optind == 1) { 29 argv += 1 + reset;
35 if (flags & OPT_SETCONS_RESET) 30 if (*argv) {
36 bb_show_usage(); 31 device = *argv;
37 device = argv[optind];
38 } else { 32 } else {
39 if (flags & OPT_SETCONS_RESET) 33 if (reset)
40 device = DEV_CONSOLE; 34 device = DEV_CONSOLE;
41 } 35 }
42 36