Last change
on this file since 3651 was 3232, checked in by Bruno Cornec, 11 years ago |
- Update mindi-busybox to 1.21.1
|
File size:
1.2 KB
|
Rev | Line | |
---|
[821] | 1 | /* vi: set sw=4 ts=4: */
|
---|
| 2 | /*
|
---|
| 3 | * setconsole.c - redirect system console output
|
---|
| 4 | *
|
---|
| 5 | * Copyright (C) 2004,2005 Enrik Berkhan <Enrik.Berkhan@inka.de>
|
---|
[2725] | 6 | * Copyright (C) 2008 Bernhard Reutner-Fischer
|
---|
[821] | 7 | *
|
---|
[2725] | 8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
---|
[821] | 9 | */
|
---|
| 10 |
|
---|
[3232] | 11 | //usage:#define setconsole_trivial_usage
|
---|
| 12 | //usage: "[-r" IF_FEATURE_SETCONSOLE_LONG_OPTIONS("|--reset") "] [DEVICE]"
|
---|
| 13 | //usage:#define setconsole_full_usage "\n\n"
|
---|
| 14 | //usage: "Redirect system console output to DEVICE (default: /dev/tty)\n"
|
---|
| 15 | //usage: "\n -r Reset output to /dev/console"
|
---|
| 16 |
|
---|
[1765] | 17 | #include "libbb.h"
|
---|
[821] | 18 |
|
---|
[2725] | 19 | int setconsole_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
---|
| 20 | int setconsole_main(int argc UNUSED_PARAM, char **argv)
|
---|
[821] | 21 | {
|
---|
| 22 | const char *device = CURRENT_TTY;
|
---|
[2725] | 23 | bool reset;
|
---|
[821] | 24 |
|
---|
| 25 | #if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
|
---|
[2725] | 26 | static const char setconsole_longopts[] ALIGN1 =
|
---|
| 27 | "reset\0" No_argument "r"
|
---|
| 28 | ;
|
---|
[1765] | 29 | applet_long_options = setconsole_longopts;
|
---|
[821] | 30 | #endif
|
---|
[2725] | 31 | /* at most one non-option argument */
|
---|
| 32 | opt_complementary = "?1";
|
---|
| 33 | reset = getopt32(argv, "r");
|
---|
[821] | 34 |
|
---|
[2725] | 35 | argv += 1 + reset;
|
---|
| 36 | if (*argv) {
|
---|
| 37 | device = *argv;
|
---|
[821] | 38 | } else {
|
---|
[2725] | 39 | if (reset)
|
---|
[1765] | 40 | device = DEV_CONSOLE;
|
---|
[821] | 41 | }
|
---|
| 42 |
|
---|
[3232] | 43 | xioctl(xopen(device, O_WRONLY), TIOCCONS, NULL);
|
---|
[821] | 44 | return EXIT_SUCCESS;
|
---|
| 45 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.