Stop using TRUE and FALSE for exit status.
[oweals/busybox.git] / console-tools / deallocvt.c
1 /* vi: set sw=4 ts=4: */
2 /*
3  * disalloc.c - aeb - 940501 - Disallocate virtual terminal(s)
4  * Renamed deallocvt.
5  */
6 #include "busybox.h"
7 #include <stdlib.h>
8 #include <stdio.h>
9 #include <fcntl.h>
10 #include <sys/types.h>
11 #include <sys/ioctl.h>
12
13 /* From <linux/vt.h> */
14 #define VT_DISALLOCATE  0x5608  /* free memory associated to vt */
15
16 int deallocvt_main(int argc, char *argv[])
17 {
18         int fd, num, i;
19
20         //if ((argc > 2) || ((argv == 2) && (**(argv + 1) == '-')))
21         if (argc > 2)
22                 usage(deallocvt_usage);
23
24         fd = get_console_fd("/dev/console");
25
26         if (argc == 1) {
27 printf("erik: A\n");
28                 /* deallocate all unused consoles */
29                 if (ioctl(fd, VT_DISALLOCATE, 0)) {
30                         perror("VT_DISALLOCATE");
31                         return EXIT_FAILURE;
32                 }
33         } else
34 printf("erik: B\n");
35                 for (i = 1; i < argc; i++) {
36                         num = atoi(argv[i]);
37                         if (num == 0)
38                                 errorMsg("0: illegal VT number\n");
39                         else if (num == 1)
40                                 errorMsg("VT 1 cannot be deallocated\n");
41                         else if (ioctl(fd, VT_DISALLOCATE, num)) {
42                                 perror("VT_DISALLOCATE");
43                                 fatalError("could not deallocate console %d\n", num);
44                         }
45                 }
46 printf("erik: C\n");
47         return EXIT_SUCCESS;
48 }