|
Packit Service |
50ad14 |
/*
|
|
Packit Service |
50ad14 |
* chvt.c - aeb - 940227 - Change virtual terminal
|
|
Packit Service |
50ad14 |
*/
|
|
Packit Service |
50ad14 |
#include "config.h"
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
#include <sys/types.h>
|
|
Packit Service |
50ad14 |
#include <sys/ioctl.h>
|
|
Packit Service |
50ad14 |
#include <linux/vt.h>
|
|
Packit Service |
50ad14 |
#include <stdio.h>
|
|
Packit Service |
50ad14 |
#include <stdlib.h>
|
|
Packit Service |
50ad14 |
#include <errno.h>
|
|
Packit Service |
50ad14 |
#include <fcntl.h>
|
|
Packit Service |
50ad14 |
#include "getfd.h"
|
|
Packit Service |
50ad14 |
#include "nls.h"
|
|
Packit Service |
50ad14 |
#include "version.h"
|
|
Packit Service |
50ad14 |
#include "kbd_error.h"
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
int main(int argc, char *argv[])
|
|
Packit Service |
50ad14 |
{
|
|
Packit Service |
50ad14 |
int fd, num;
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
set_progname(argv[0]);
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
setlocale(LC_ALL, "");
|
|
Packit Service |
50ad14 |
bindtextdomain(PACKAGE_NAME, LOCALEDIR);
|
|
Packit Service |
50ad14 |
textdomain(PACKAGE_NAME);
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
if (argc == 2 && !strcmp(argv[1], "-V"))
|
|
Packit Service |
50ad14 |
print_version_and_exit();
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
if (argc != 2) {
|
|
Packit Service |
50ad14 |
fprintf(stderr, _("usage: chvt N\n"));
|
|
Packit Service |
50ad14 |
return EXIT_FAILURE;
|
|
Packit Service |
50ad14 |
}
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
if ((fd = getfd(NULL)) < 0)
|
|
Packit Service |
50ad14 |
kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console"));
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
num = atoi(argv[1]);
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
if (ioctl(fd, VT_ACTIVATE, num)) {
|
|
Packit Service |
50ad14 |
kbd_error(EXIT_FAILURE, errno, "ioctl VT_ACTIVATE");
|
|
Packit Service |
50ad14 |
}
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
if (ioctl(fd, VT_WAITACTIVE, num)) {
|
|
Packit Service |
50ad14 |
kbd_error(EXIT_FAILURE, errno, "ioctl VT_WAITACTIVE");
|
|
Packit Service |
50ad14 |
}
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
return EXIT_SUCCESS;
|
|
Packit Service |
50ad14 |
}
|