[BusyBox-cvs] busybox/console-tools deallocvt.c,1.25,1.26

Erik Andersen andersen at busybox.net
Sun Apr 27 10:42:34 UTC 2003


Update of /var/cvs/busybox/console-tools
In directory winder:/tmp/cvs-serv13835/console-tools

Modified Files:
	deallocvt.c 
Log Message:
A couple of patches from Tito <farmatito at tiscali.it>


Index: deallocvt.c
===================================================================
RCS file: /var/cvs/busybox/console-tools/deallocvt.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- deallocvt.c	19 Mar 2003 09:11:28 -0000	1.25
+++ deallocvt.c	27 Apr 2003 10:42:30 -0000	1.26
@@ -15,29 +15,32 @@
 
 int deallocvt_main(int argc, char *argv[])
 {
-	int fd, num, i;
+	int fd, num=0;
 
-	//if ((argc > 2) || ((argv == 2) && (**(argv + 1) == '-')))
 	if (argc > 2)
 		bb_show_usage();
 
 	fd = get_console_fd();
+	
+	/*  num=0  deallocate all unused consoles */
+	if (argc == 1)
+		goto disallocate_all;
 
-	if (argc == 1) {
-		/* deallocate all unused consoles */
-		if (ioctl(fd, VT_DISALLOCATE, 0))
-			bb_perror_msg_and_die("VT_DISALLOCATE");
-	} else {
-		for (i = 1; i < argc; i++) {
-			num = atoi(argv[i]);
-			if (num == 0)
-				bb_error_msg("0: illegal VT number");
-			else if (num == 1)
-				bb_error_msg("VT 1 cannot be deallocated");
-			else if (ioctl(fd, VT_DISALLOCATE, num))
+	num=bb_xgetlarg(argv[1], 10, 0, INT_MAX);
+
+	switch(num)
+	{
+		case 0:
+			bb_error_msg("0: illegal VT number");
+			break;
+		case 1:
+			bb_error_msg("VT 1 cannot be deallocated");
+			break;
+		default:
+disallocate_all:
+			if (ioctl(fd, VT_DISALLOCATE, num))
 				bb_perror_msg_and_die("VT_DISALLOCATE");
-		}
+			return EXIT_SUCCESS;
 	}
-
-	return EXIT_SUCCESS;
+	return EXIT_FAILURE;
 }



More information about the busybox-cvs mailing list