mirror of git://git.suckless.org/ubase
Use estrtol() instead of atoi()
Some more stylistic fixes.
This commit is contained in:
parent
643a714256
commit
55dbbb7b3f
21
chvt.c
21
chvt.c
|
@ -1,10 +1,11 @@
|
||||||
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
#include <fcntl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#define KDGKBTYPE 0x4B33 /* get keyboard type */
|
#define KDGKBTYPE 0x4B33 /* get keyboard type */
|
||||||
|
@ -32,25 +33,25 @@ main(int argc, char *argv[])
|
||||||
int fd;
|
int fd;
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
if(argc!=2 || strspn(argv[1], "1234567890") != strlen(argv[1]))
|
if (argc != 2 || strspn(argv[1], "1234567890") != strlen(argv[1]))
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
n = atoi(argv[1]);
|
n = estrtol(argv[1], 10);
|
||||||
for(i = 0; i < LEN(vts); i++) {
|
for (i = 0; i < LEN(vts); i++) {
|
||||||
fd = open(vts[i], O_RDONLY);
|
fd = open(vts[i], O_RDONLY);
|
||||||
if(fd < 1)
|
if (fd < 1)
|
||||||
continue;
|
continue;
|
||||||
c = 0;
|
c = 0;
|
||||||
if(ioctl(fd, KDGKBTYPE, &c) == 0)
|
if (ioctl(fd, KDGKBTYPE, &c) == 0)
|
||||||
goto VTfound;
|
goto VTfound;
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
eprintf("couldn't find a console.\n");
|
eprintf("couldn't find a console.\n");
|
||||||
VTfound:
|
VTfound:
|
||||||
if(ioctl(fd, VT_ACTIVATE, n) == -1)
|
if (ioctl(fd, VT_ACTIVATE, n) == -1)
|
||||||
eprintf("VT_ACTIVATE %d:", n);
|
eprintf("VT_ACTIVATE %d:", n);
|
||||||
if(ioctl(fd, VT_WAITACTIVE, n) == -1)
|
if (ioctl(fd, VT_WAITACTIVE, n) == -1)
|
||||||
eprintf("VT_WAITACTIVE %d:", n);
|
eprintf("VT_WAITACTIVE %d:", n);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue