aboutsummaryrefslogtreecommitdiff
path: root/console-tools
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-10-08 12:49:22 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-10-08 12:49:22 +0000
commit1385899416a4396385ad421ae1f532be7103738a (patch)
treefc4d14a910593d1235318bb36abe5e9f72d2039e /console-tools
parent5625415085e68ac5e150f54e685417c866620d76 (diff)
downloadbusybox-w32-1385899416a4396385ad421ae1f532be7103738a.tar.gz
busybox-w32-1385899416a4396385ad421ae1f532be7103738a.tar.bz2
busybox-w32-1385899416a4396385ad421ae1f532be7103738a.zip
attempt to regularize atoi mess.
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 aff66e007..bbc5a9c31 100644
--- a/console-tools/chvt.c
+++ b/console-tools/chvt.c
@@ -7,11 +7,6 @@
7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
8 */ 8 */
9 9
10#include <stdio.h>
11#include <stdlib.h>
12#include <fcntl.h>
13#include <sys/types.h>
14#include <sys/ioctl.h>
15#include "busybox.h" 10#include "busybox.h"
16 11
17/* From <linux/vt.h> */ 12/* From <linux/vt.h> */
@@ -29,7 +24,7 @@ int chvt_main(int argc, char **argv)
29 } 24 }
30 25
31 fd = get_console_fd(); 26 fd = get_console_fd();
32 num = bb_xgetlarg(argv[1], 10, 0, INT_MAX); 27 num = xatoul_range(argv[1], 1, 63);
33 if ((-1 == ioctl(fd, VT_ACTIVATE, num)) 28 if ((-1 == ioctl(fd, VT_ACTIVATE, num))
34 || (-1 == ioctl(fd, VT_WAITACTIVE, num))) { 29 || (-1 == ioctl(fd, VT_WAITACTIVE, num))) {
35 bb_perror_msg_and_die("ioctl"); 30 bb_perror_msg_and_die("ioctl");
diff --git a/console-tools/deallocvt.c b/console-tools/deallocvt.c
index b2e8e2bef..cd581b1c8 100644
--- a/console-tools/deallocvt.c
+++ b/console-tools/deallocvt.c
@@ -10,11 +10,6 @@
10 10
11/* no options, no getopt */ 11/* no options, no getopt */
12 12
13#include <stdlib.h>
14#include <stdio.h>
15#include <fcntl.h>
16#include <sys/types.h>
17#include <sys/ioctl.h>
18#include "busybox.h" 13#include "busybox.h"
19 14
20/* From <linux/vt.h> */ 15/* From <linux/vt.h> */
@@ -26,15 +21,13 @@ int deallocvt_main(int argc, char *argv[])
26 int num = 0; 21 int num = 0;
27 22
28 switch (argc) { 23 switch (argc) {
29 case 2: 24 case 2:
30 if ((num = bb_xgetlarg(argv[1], 10, 0, INT_MAX)) == 0) { 25 num = xatoul_range(argv[1], 1, 63);
31 bb_error_msg_and_die("0: illegal VT number");
32 }
33 /* Fallthrough */ 26 /* Fallthrough */
34 case 1: 27 case 1:
35 break; 28 break;
36 default: 29 default:
37 bb_show_usage(); 30 bb_show_usage();
38 } 31 }
39 32
40 if (-1 == ioctl(get_console_fd(), VT_DISALLOCATE, num)) { 33 if (-1 == ioctl(get_console_fd(), VT_DISALLOCATE, num)) {
diff --git a/console-tools/openvt.c b/console-tools/openvt.c
index 0c0cef23c..f1cf5645b 100644
--- a/console-tools/openvt.c
+++ b/console-tools/openvt.c
@@ -10,14 +10,6 @@
10 10
11/* getopt not needed */ 11/* getopt not needed */
12 12
13#include <stdio.h>
14#include <stdlib.h>
15#include <unistd.h>
16#include <fcntl.h>
17#include <string.h>
18#include <sys/types.h>
19#include <ctype.h>
20
21#include "busybox.h" 13#include "busybox.h"
22 14
23int openvt_main(int argc, char **argv) 15int openvt_main(int argc, char **argv)
@@ -29,8 +21,8 @@ int openvt_main(int argc, char **argv)
29 if (argc < 3) { 21 if (argc < 3) {
30 bb_show_usage(); 22 bb_show_usage();
31 } 23 }
32 /* check for Illegal vt number: < 1 or > 12 */ 24 /* check for illegal vt number: < 1 or > 63 */
33 sprintf(vtname, VC_FORMAT, (int)bb_xgetlarg(argv[1], 10, 1, 12)); 25 sprintf(vtname, VC_FORMAT, (int)xatoul_range(argv[1], 1, 63));
34 26
35 if (fork() == 0) { 27 if (fork() == 0) {
36 /* leave current vt */ 28 /* leave current vt */
diff --git a/console-tools/setkeycodes.c b/console-tools/setkeycodes.c
index 607b8c785..d82525786 100644
--- a/console-tools/setkeycodes.c
+++ b/console-tools/setkeycodes.c
@@ -27,7 +27,6 @@ enum {
27extern int 27extern int
28setkeycodes_main(int argc, char** argv) 28setkeycodes_main(int argc, char** argv)
29{ 29{
30 char *ep;
31 int fd, sc; 30 int fd, sc;
32 struct kbkeycode a; 31 struct kbkeycode a;
33 32
@@ -38,19 +37,13 @@ setkeycodes_main(int argc, char** argv)
38 fd = get_console_fd(); 37 fd = get_console_fd();
39 38
40 while (argc > 2) { 39 while (argc > 2) {
41 a.keycode = atoi(argv[2]); 40 a.keycode = xatoul_range(argv[2], 0, 127);
42 a.scancode = sc = strtol(argv[1], &ep, 16); 41 a.scancode = sc = xstrtoul_range(argv[1], 16, 0, 255);
43 if (*ep) {
44 bb_error_msg_and_die("error reading SCANCODE: '%s'", argv[1]);
45 }
46 if (a.scancode > 127) { 42 if (a.scancode > 127) {
47 a.scancode -= 0xe000; 43 a.scancode -= 0xe000;
48 a.scancode += 128; 44 a.scancode += 128;
49 } 45 }
50 if (a.scancode > 255 || a.keycode > 127) { 46 if (ioctl(fd, KDSETKEYCODE, &a)) {
51 bb_error_msg_and_die("SCANCODE or KEYCODE outside bounds");
52 }
53 if (ioctl(fd,KDSETKEYCODE,&a)) {
54 bb_perror_msg_and_die("failed to set SCANCODE %x to KEYCODE %d", sc, a.keycode); 47 bb_perror_msg_and_die("failed to set SCANCODE %x to KEYCODE %d", sc, a.keycode);
55 } 48 }
56 argc -= 2; 49 argc -= 2;
diff --git a/console-tools/setlogcons.c b/console-tools/setlogcons.c
index 90f24ce9c..ae15b9b28 100644
--- a/console-tools/setlogcons.c
+++ b/console-tools/setlogcons.c
@@ -22,7 +22,7 @@ extern int setlogcons_main(int argc, char **argv)
22 arg.subarg = 0; /* to specified console (current as default) */ 22 arg.subarg = 0; /* to specified console (current as default) */
23 23
24 if (argc == 2) 24 if (argc == 2)
25 arg.subarg = atoi(argv[1]); 25 arg.subarg = xatoul_range(argv[1], 0, 63);
26 26
27 if (ioctl(xopen(VC_1, O_RDONLY), TIOCLINUX, &arg)) 27 if (ioctl(xopen(VC_1, O_RDONLY), TIOCLINUX, &arg))
28 bb_perror_msg_and_die("TIOCLINUX"); 28 bb_perror_msg_and_die("TIOCLINUX");