setting terminal modes (structure question)
iv looked thru a few c tutorials but i don't seem to find what I'm looking for, more specifically the operators &= |= (i think they AND and OR the values with the previous one, but what really gets me is what does ~ mean.. ), heres 2 examples
int
set_istrip (int desc, int value)
{
struct termios settings;
int result;
result = tcgetattr (desc, &settings);
if (result < 0)
{
perror ("error in tcgetattr");
return 0;
}
settings.c_iflag &= ~ISTRIP;
if (value)
settings.c_iflag |= ISTRIP;
result = tcsetattr (desc, TCSANOW, &settings);
if (result < 0)
{
perror ("error in tcsetattr");
return 0;
}
return 1;
}
taken from a glib tutorial thing, and another one i found somewhere on the same site
termios-p->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP
|INLCR|IGNCR|ICRNL|IXON);
termios-p->c_oflag &= ~OPOST;
termios-p->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
termios-p->c_cflag &= ~(CSIZE|PARENB);
termios-p->c_cflag |= CS8;
can anyone tell me what this means termios-p->c_oflag &= ~OPOST;
more like what it does to the termios-p->c_oflag flag, in the first example it looks like it might delete it, but the second one looks like it might set the flag,,, anyone know please?
|