summaryrefslogtreecommitdiff
path: root/console-tools
diff options
context:
space:
mode:
Diffstat (limited to 'console-tools')
-rw-r--r--console-tools/chvt.c7
-rw-r--r--console-tools/deallocvt.c19
-rw-r--r--console-tools/openvt.c12
-rw-r--r--console-tools/setkeycodes.c13
-rw-r--r--console-tools/setlogcons.c2
5 files changed, 13 insertions, 40 deletions
diff --git a/console-tools/chvt.c b/console-tools/chvt.c
index aff66e0..bbc5a9c 100644
--- a/console-tools/chvt.c
+++ b/console-tools/chvt.c
@@ -7,11 +7,6 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/ioctl.h>
#include "busybox.h"
/* From <linux/vt.h> */
@@ -29,7 +24,7 @@ int chvt_main(int argc, char **argv)
}
fd = get_console_fd();
- num = bb_xgetlarg(argv[1], 10, 0, INT_MAX);
+ num = xatoul_range(argv[1], 1, 63);
if ((-1 == ioctl(fd, VT_ACTIVATE, num))
|| (-1 == ioctl(fd, VT_WAITACTIVE, num))) {
bb_perror_msg_and_die("ioctl");
diff --git a/console-tools/deallocvt.c b/console-tools/deallocvt.c
index b2e8e2b..cd581b1 100644
--- a/console-tools/deallocvt.c
+++ b/console-tools/deallocvt.c
@@ -10,11 +10,6 @@
/* no options, no getopt */
-#include <stdlib.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/ioctl.h>
#include "busybox.h"
/* From <linux/vt.h> */
@@ -26,15 +21,13 @@ int deallocvt_main(int argc, char *argv[])
int num = 0;
switch (argc) {
- case 2:
- if ((num = bb_xgetlarg(argv[1], 10, 0, INT_MAX)) == 0) {
- bb_error_msg_and_die("0: illegal VT number");
- }
+ case 2:
+ num = xatoul_range(argv[1], 1, 63);
/* Fallthrough */
- case 1:
- break;
- default:
- bb_show_usage();
+ case 1:
+ break;
+ default:
+ bb_show_usage();
}
if (-1 == ioctl(get_console_fd(), VT_DISALLOCATE, num)) {
diff --git a/console-tools/openvt.c b/console-tools/openvt.c
index 0c0cef2..f1cf564 100644
--- a/console-tools/openvt.c
+++ b/console-tools/openvt.c
@@ -10,14 +10,6 @@
/* getopt not needed */
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <string.h>
-#include <sys/types.h>
-#include <ctype.h>
-
#include "busybox.h"
int openvt_main(int argc, char **argv)
@@ -29,8 +21,8 @@ int openvt_main(int argc, char **argv)
if (argc < 3) {
bb_show_usage();
}
- /* check for Illegal vt number: < 1 or > 12 */
- sprintf(vtname, VC_FORMAT, (int)bb_xgetlarg(argv[1], 10, 1, 12));
+ /* check for illegal vt number: < 1 or > 63 */
+ sprintf(vtname, VC_FORMAT, (int)xatoul_range(argv[1], 1, 63));
if (fork() == 0) {
/* leave current vt */
diff --git a/console-tools/setkeycodes.c b/console-tools/setkeycodes.c
index 607b8c7..d825257 100644
--- a/console-tools/setkeycodes.c
+++ b/console-tools/setkeycodes.c
@@ -27,7 +27,6 @@ enum {
extern int
setkeycodes_main(int argc, char** argv)
{
- char *ep;
int fd, sc;
struct kbkeycode a;
@@ -38,19 +37,13 @@ setkeycodes_main(int argc, char** argv)
fd = get_console_fd();
while (argc > 2) {
- a.keycode = atoi(argv[2]);
- a.scancode = sc = strtol(argv[1], &ep, 16);
- if (*ep) {
- bb_error_msg_and_die("error reading SCANCODE: '%s'", argv[1]);
- }
+ a.keycode = xatoul_range(argv[2], 0, 127);
+ a.scancode = sc = xstrtoul_range(argv[1], 16, 0, 255);
if (a.scancode > 127) {
a.scancode -= 0xe000;
a.scancode += 128;
}
- if (a.scancode > 255 || a.keycode > 127) {
- bb_error_msg_and_die("SCANCODE or KEYCODE outside bounds");
- }
- if (ioctl(fd,KDSETKEYCODE,&a)) {
+ if (ioctl(fd, KDSETKEYCODE, &a)) {
bb_perror_msg_and_die("failed to set SCANCODE %x to KEYCODE %d", sc, a.keycode);
}
argc -= 2;
diff --git a/console-tools/setlogcons.c b/console-tools/setlogcons.c
index 90f24ce..ae15b9b 100644
--- a/console-tools/setlogcons.c
+++ b/console-tools/setlogcons.c
@@ -22,7 +22,7 @@ extern int setlogcons_main(int argc, char **argv)
arg.subarg = 0; /* to specified console (current as default) */
if (argc == 2)
- arg.subarg = atoi(argv[1]);
+ arg.subarg = xatoul_range(argv[1], 0, 63);
if (ioctl(xopen(VC_1, O_RDONLY), TIOCLINUX, &arg))
bb_perror_msg_and_die("TIOCLINUX");