Terminal Option flag of terminal I/O

Source: Internet
Author: User

Table 18-1 in the http://www.cnblogs.com/nufangrensheng/p/3575752.html to Table 18-4All option flag (except the blocking flag) are represented by one or more bits (set or clear), while the blocking flag defines multiple bits and they are combined, therefore, multiple values can be defined. A blocking bit has a definition name, and each value also has a name.For example, to set the length of a character, first use the character length shield sign CSIZE to clear the characters that indicate the length of 0, and then set one of the following values: CS5, CS6, CS7, or CS8.

Instance: Use the shield flag to retrieve or set a value.

Program list 18-2 tcgetattr and tcsetattr instances

# Include "apue. h"

# Include <termios. h>

 

Int

Main (void)

{

Struct termios term;

If (tcgetattr (STDIN_FILENO, & term) <0)

Err_sys ("tcgetattr error ");

Switch (term. c_cflag & CSIZE)

{

Case CS5:

Printf ("5 bits/byte \ n ");

Break;

Case CS6:

Printf ("6 bits/byte \ n ");

Break;

Case CS7:

Printf ("7 bits/byte \ n ");

Break;

Case CS8:

Printf ("8 bits/byte \ n ");

Break;

Default:

Printf ("unknown bits/byte \ n ");

}

 

Term. c_cflag & = ~ CSIZE;/* zero out of the bits */

Term. c_cflag | = CS8;

If (tcsetattr (STDIN_FILENO, TCSANOW, & term) <0)

Err_sys ("tcsetattr error ");

 

Exit (0 );

}

For a detailed description of each option flag, refer to advanced programming in UNIX environment.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.