Ignore:
Timestamp:
Nov 4, 2007, 3:16:40 AM (16 years ago)
Author:
Bruno Cornec
Message:

Update to busybox 1.7.2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.5/mindi-busybox/console-tools/setkeycodes.c

    r821 r1765  
    77 * Adjusted for BusyBox by Erik Andersen <andersen@codepoet.org>
    88 *
    9  * This program is free software; you can redistribute it and/or modify
    10  * it under the terms of the GNU General Public License as published by
    11  * the Free Software Foundation; either version 2 of the License, or
    12  * (at your option) any later version.
    13  *
    14  * This program is distributed in the hope that it will be useful,
    15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    17  * General Public License for more details.
    18  *
    19  * You should have received a copy of the GNU General Public License
    20  * along with this program; if not, write to the Free Software
    21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    22  *
     9 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
    2310 */
    2411
    25 #include <stdio.h>
    26 #include <stdlib.h>
    27 #include <fcntl.h>
    28 #include <sys/ioctl.h>
    29 #include "busybox.h"
    30 
     12//#include <sys/ioctl.h>
     13#include "libbb.h"
    3114
    3215/* From <linux/kd.h> */
     
    3821};
    3922
    40 extern int
    41 setkeycodes_main(int argc, char** argv)
     23int setkeycodes_main(int argc, char** argv);
     24int setkeycodes_main(int argc, char** argv)
    4225{
    43     char *ep;
    44     int fd, sc;
    45     struct kbkeycode a;
     26    int fd, sc;
     27    struct kbkeycode a;
    4628
    47     if (argc % 2 != 1 || argc < 2) {
    48       bb_show_usage();
     29    if (argc % 2 != 1 || argc < 2) {
     30        bb_show_usage();
    4931    }
    5032
    5133    fd = get_console_fd();
    5234
    53     while (argc > 2) {
    54     a.keycode = atoi(argv[2]);
    55     a.scancode = sc = strtol(argv[1], &ep, 16);
    56     if (*ep) {
    57       bb_error_msg_and_die("error reading SCANCODE: '%s'", argv[1]);
     35    while (argc > 2) {
     36        a.keycode = xatoul_range(argv[2], 0, 127);
     37        a.scancode = sc = xstrtoul_range(argv[1], 16, 0, 255);
     38        if (a.scancode > 127) {
     39            a.scancode -= 0xe000;
     40            a.scancode += 128;
     41        }
     42        ioctl_or_perror_and_die(fd, KDSETKEYCODE, &a,
     43            "failed to set SCANCODE %x to KEYCODE %d",
     44            sc, a.keycode);
     45        argc -= 2;
     46        argv += 2;
    5847    }
    59     if (a.scancode > 127) {
    60         a.scancode -= 0xe000;
    61         a.scancode += 128;
    62     }
    63     if (a.scancode > 255 || a.keycode > 127) {
    64       bb_error_msg_and_die("SCANCODE or KEYCODE outside bounds");
    65     }
    66     if (ioctl(fd,KDSETKEYCODE,&a)) {
    67         perror("KDSETKEYCODE");
    68         bb_error_msg_and_die("failed to set SCANCODE %x to KEYCODE %d", sc, a.keycode);
    69     }
    70     argc -= 2;
    71     argv += 2;
    72     }
    7348    return EXIT_SUCCESS;
    7449}
Note: See TracChangeset for help on using the changeset viewer.