Pristine Ack-5.5
[Ack-5.5.git] / util / int / test / ioc0.c
1 /* $Id: ioc0.c,v 1.2 1994/06/24 10:50:48 ceriel Exp $ */
2
3 /* Testing ioctl monitor call */
4 #include        <sgtty.h>
5
6 char sbuf[10];
7 struct sgttyb old, ttyb;
8
9 main()
10 {
11    register i = 0;
12    char c;
13
14    if( ioctl( 1, TIOCGETP, &old ) != 0 ) {
15        write( 2, "ioctl ophalen mislukt\n", 22 );
16        exit( 100 );
17    }
18    write( 2, "Huidige status opgehaald\n", 25 );
19    ttyb = old;
20    ttyb.sg_flags &= ~ECHO;
21    if( ioctl( 1, TIOCSETP, &ttyb ) != 0 ) {
22        write( 2, "ioctl -echo mislukt\n", 20 );
23        exit( 100 );
24    }
25    write( 2, "Echo uitgezet\n", 14 );
26    write( 2, "geef input: ", 12 ); 
27    while( i<9 && (c = getchar()) != '\n' )
28        sbuf[i++] = c;
29    write( 1, sbuf, strlen(sbuf) );
30    if( ioctl( 1, TIOCSETP, &old ) != 0 ) {
31        write( 2, "ioctl reset mislukt\n", 20 );
32        exit( 100 );
33    }
34    write( 2, "Klaar\n", 6 );
35    exit( 0 );
36 }