ack/util/int/test/ioc0.c

37 lines
811 B
C
Raw Normal View History

1988-06-24 15:40:41 +00:00
/* $Header$ */
/* Testing ioctl monitor call */
#include <sgtty.h>
char sbuf[10];
struct sgttyb old, ttyb;
main()
{
register i = 0;
char c;
if( ioctl( 1, TIOCGETP, &old ) != 0 ) {
write( 2, "ioctl ophalen mislukt\n", 22 );
exit( 100 );
}
write( 2, "Huidige status opgehaald\n", 25 );
ttyb = old;
ttyb.sg_flags &= ~ECHO;
if( ioctl( 1, TIOCSETP, &ttyb ) != 0 ) {
write( 2, "ioctl -echo mislukt\n", 20 );
exit( 100 );
}
write( 2, "Echo uitgezet\n", 14 );
write( 2, "geef input: ", 12 );
while( i<9 && (c = getchar()) != '\n' )
sbuf[i++] = c;
write( 1, sbuf, strlen(sbuf) );
if( ioctl( 1, TIOCSETP, &old ) != 0 ) {
write( 2, "ioctl reset mislukt\n", 20 );
exit( 100 );
}
write( 2, "Klaar\n", 6 );
exit( 0 );
}