Home | History | Annotate | Line # | Download | only in intro
      1  1.2  jmcneill /*	$NetBSD: doioctl.c,v 1.2 2021/07/06 09:30:07 jmcneill Exp $	*/
      2  1.1     pooka 
      3  1.1     pooka #include <sys/types.h>
      4  1.1     pooka #include <sys/ioctl.h>
      5  1.1     pooka 
      6  1.2  jmcneill #include <err.h>
      7  1.1     pooka #include <fcntl.h>
      8  1.1     pooka #include <stdio.h>
      9  1.2  jmcneill #include <stdlib.h>
     10  1.1     pooka 
     11  1.1     pooka #include "common.h"
     12  1.1     pooka 
     13  1.1     pooka int
     14  1.1     pooka main(int argc, char *argv[])
     15  1.1     pooka {
     16  1.1     pooka 	int fd, i;
     17  1.1     pooka 
     18  1.1     pooka 	if (argc != 3 && argc != 4)
     19  1.1     pooka 		errx(1, "args");
     20  1.1     pooka 
     21  1.1     pooka 	fd = open(argv[1], O_RDWR);
     22  1.1     pooka 	if (fd == -1)
     23  1.1     pooka 		err(1, "open");
     24  1.1     pooka 
     25  1.1     pooka 	i = atoi(argv[2]);
     26  1.1     pooka 
     27  1.1     pooka 	if (argc == 3)
     28  1.1     pooka 		if (ioctl(fd, INTROTOGGLE, &i) == -1)
     29  1.1     pooka 			err(1, "ioctl");
     30  1.1     pooka 	else
     31  1.1     pooka 		if (ioctl(fd, INTROTOGGLE_R, &i) == -1)
     32  1.1     pooka 			err(1, "ioctl");
     33  1.1     pooka 
     34  1.1     pooka 	printf("i is now %d\n", i);
     35  1.1     pooka }
     36