ioc0.c 807 B

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