Tomato 1.24
[tomato.git] / release / src / router / busybox / console-tools / setconsole.c
blob8ad9948dd5a90b53c4bb10f6f486ddb3bc97f6c7
1 /* vi: set sw=4 ts=4: */
2 /*
3 * setconsole.c - redirect system console output
5 * Copyright (C) 2004,2005 Enrik Berkhan <Enrik.Berkhan@inka.de>
6 * Copyright (C) 2008 Bernhard Reutner-Fischer
8 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
9 */
11 #include "libbb.h"
13 int setconsole_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
14 int setconsole_main(int argc UNUSED_PARAM, char **argv)
16 const char *device = CURRENT_TTY;
17 bool reset;
19 #if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
20 static const char setconsole_longopts[] ALIGN1 =
21 "reset\0" No_argument "r"
23 applet_long_options = setconsole_longopts;
24 #endif
25 /* at most one non-option argument */
26 opt_complementary = "?1";
27 reset = getopt32(argv, "r");
29 argv += 1 + reset;
30 if (*argv) {
31 device = *argv;
32 } else {
33 if (reset)
34 device = DEV_CONSOLE;
37 xioctl(xopen(device, O_RDONLY), TIOCCONS, NULL);
38 return EXIT_SUCCESS;