/* Copyright (c) 2001-2004 by SoftIntegration, Inc. All Rights Reserved */
/* a sample program that sets terminal's input mode then prints it. */
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <termios.h>

/* struct termios {
	tcflag_t	c_iflag;	 Input modes 
	tcflag_t	c_oflag;	 Output modes 
	tcflag_t	c_cflag;	 Control modes 
	tcflag_t	c_lflag; 	 Local modes 
	tcflag_t	c_reserved;	 Reserved for future use 
	cc_t		c_cc[NCCS];	 Control characters 
     };
*/  
int main() {
    int fildes;
    struct termios termios_p;
    
    /* open file for reading only */
    if((fildes = open("tcsetattr.c",O_RDONLY)) == -1){ 
      printf("cannot open file");
      exit(1);
    }
    termios_p.c_iflag = IGNBRK; /* input mode is Ignore break condition 
                                   IGNBRK = 1 */
    tcsetattr(fildes,TCSANOW,&termios_p); /* TCSANOW means the change is immediate */
    tcgetattr(fildes,&termios_p);
    printf(" the input mode  is %u\n",termios_p.c_iflag);
    if(close(fildes)) printf("error in closing file\n");
    return (0);
}


   
