Add one-line GPL boilerplate to numerous (but not all yet) source files.
[oweals/busybox.git] / console-tools / deallocvt.c
1 /* vi: set sw=4 ts=4: */
2 /*
3  * Disallocate virtual terminal(s)
4  *
5  * Copyright (C) 2003 by Tito Ragusa <farmatito@tiscali.it>
6  * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
7  *
8  * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
9  */
10
11 /* no options, no getopt */
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"
19
20 /* From <linux/vt.h> */
21 enum { VT_DISALLOCATE = 0x5608 }; /* free memory associated to vt */
22
23 int deallocvt_main(int argc, char *argv[])
24 {
25         /* num = 0 deallocate all unused consoles */
26         int num = 0;
27
28         switch (argc) {
29                 case 2:
30                         if ((num = bb_xgetlarg(argv[1], 10, 0, INT_MAX)) == 0) {
31                                 bb_error_msg_and_die("0: illegal VT number");
32                         }
33                 /* Fallthrough */
34                 case 1:
35                         break;
36                 default:
37                         bb_show_usage();
38         }
39
40         if (-1 == ioctl(get_console_fd(), VT_DISALLOCATE, num)) {
41                 bb_perror_msg_and_die("VT_DISALLOCATE");
42         }
43         return EXIT_SUCCESS;
44 }