⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 library_16.html

📁 Linux程序员的工作手册
💻 HTML
📖 第 1 页 / 共 5 页
字号:
indicates an error.  If <VAR>speed</VAR> is not a speed, <CODE>cfsetospeed</CODE>returns <CODE>-1</CODE>.<P><A NAME="IDX1163"></A><U>Function:</U> int <B>cfsetspeed</B> <I>(struct termios *<VAR>termios_p</VAR>, speed_t <VAR>speed</VAR>)</I><P>This function stores <VAR>speed</VAR> in <CODE>*<VAR>termios_p</VAR></CODE> as both theinput and output speeds.  The normal return value is <CODE>0</CODE>; a valueof <CODE>-1</CODE> indicates an error.  If <VAR>speed</VAR> is not a speed,<CODE>cfsetspeed</CODE> returns <CODE>-1</CODE>.  This function is an extension in4.4 BSD.<P><A NAME="IDX1164"></A><U>Data Type:</U> <B>speed_t</B><P>The <CODE>speed_t</CODE> type is an unsigned integer data type used torepresent line speeds.<P>The functions <CODE>cfsetospeed</CODE> and <CODE>cfsetispeed</CODE> report errorsonly for speed values that the system simply cannot handle.  If youspecify a speed value that is basically acceptable, then those functionswill succeed.  But they do not check that a particular hardware devicecan actually support the specified speeds--in fact, they don't knowwhich device you plan to set the speed for.  If you use <CODE>tcsetattr</CODE>to set the speed of a particular device to a value that it cannothandle, <CODE>tcsetattr</CODE> returns <CODE>-1</CODE>.<P><STRONG>Portability note:</STRONG> In the GNU library, the functions aboveaccept speeds measured in bits per second as input, and return speedvalues measured in bits per second.  Other libraries require speeds tobe indicated by special codes.  For POSIX.1 portability, you must useone of the following symbols to represent the speed; their precisenumeric values are system-dependent, but each name has a fixed meaning:<CODE>B110</CODE> stands for 110 bps, <CODE>B300</CODE> for 300 bps, and so on.There is no portable way to represent any speed but these, but these arethe only speeds that typical serial lines can support.<A NAME="IDX1165"></A><A NAME="IDX1166"></A><A NAME="IDX1167"></A><A NAME="IDX1168"></A><A NAME="IDX1169"></A><A NAME="IDX1170"></A><A NAME="IDX1171"></A><A NAME="IDX1172"></A><A NAME="IDX1173"></A><A NAME="IDX1174"></A><A NAME="IDX1175"></A><A NAME="IDX1176"></A><A NAME="IDX1177"></A><A NAME="IDX1178"></A><A NAME="IDX1179"></A><A NAME="IDX1180"></A><P><PRE>B0  B50  B75  B110  B134  B150  B200B300  B600  B1200  B1800  B2400  B4800B9600  B19200  B38400</PRE><A NAME="IDX1181"></A><A NAME="IDX1182"></A><P>BSD defines two additional speed symbols as aliases: <CODE>EXTA</CODE> is analias for <CODE>B19200</CODE> and <CODE>EXTB</CODE> is an alias for <CODE>B38400</CODE>.These aliases are obsolete.<P><A NAME="IDX1183"></A><U>Function:</U> int <B>cfmakeraw</B> <I>(struct termios *<VAR>termios_p</VAR>)</I><P><PRE>  t-&#62;c_iflag &#38;= ~(IGNBRK|BRKINT|PARMRK|ISTRIP                  |INLCR|IGNCR|ICRNL|IXON);  t-&#62;c_oflag &#38;= ~OPOST;  t-&#62;c_lflag &#38;= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);  t-&#62;c_cflag &#38;= ~(CSIZE|PARENB);  t-&#62;c_cflag |= CS8;</PRE><P><H3><A NAME="SEC281" HREF="library_toc.html#SEC281" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC281">Special Characters</A></H3><P>In canonical input, the terminal driver recognizes a number of specialcharacters which perform various control functions.  These include theERASE character (usually <KBD>DEL</KBD>) for editing input, and other editingcharacters.  The INTR character (normally <KBD>C-c</KBD>) for sending a<CODE>SIGINT</CODE> signal, and other signal-raising characters, may beavailable in either canonical or noncanonical input mode.  All thesecharacters are described in this section.<P>The particular characters used are specified in the <CODE>c_cc</CODE> memberof the <CODE>struct termios</CODE> structure.  This member is an array; eachelement specifies the character for a particular role.  Each element hasa symbolic constant that stands for the index of that element--forexample, <CODE>INTR</CODE> is the index of the element that specifies the INTRcharacter, so storing <CODE>'='</CODE> in <CODE><VAR>termios</VAR>.c_cc[INTR]</CODE>specifies <SAMP>`='</SAMP> as the INTR character.<A NAME="IDX1184"></A><P>On some systems, you can disable a particular special character functionby specifying the value <CODE>_POSIX_VDISABLE</CODE> for that role.  Thisvalue is unequal to any possible character code.  See section <A HREF="library_27.html#SEC464" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_27.html#SEC464">Optional Features in File Support</A>, for more information about how to tell whether the operatingsystem you are using supports <CODE>_POSIX_VDISABLE</CODE>.<P><H4><A NAME="SEC282" HREF="library_toc.html#SEC282" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC282">Characters for Input Editing</A></H4><P>These special characters are active only in canonical input mode.See section <A HREF="library_16.html#SEC271" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_16.html#SEC271">Two Styles of Input: Canonical or Not</A>.<P><A NAME="IDX1185"></A><A NAME="IDX1186"></A><U>Macro:</U> int <B>VEOF</B><P>This is the subscript for the EOF character in the special controlcharacter array.  <CODE><VAR>termios</VAR>.c_cc[VEOF]</CODE> holds the characteritself.<P>The EOF character is recognized only in canonical input mode.  It actsas a line terminator in the same way as a newline character, but if theEOF character is typed at the beginning of a line it causes <CODE>read</CODE>to return a byte count of zero, indicating end-of-file.  The EOFcharacter itself is discarded.<P>Usually, the EOF character is <KBD>C-d</KBD>.<P><A NAME="IDX1187"></A><A NAME="IDX1188"></A><U>Macro:</U> int <B>VEOL</B><P>This is the subscript for the EOL character in the special controlcharacter array.  <CODE><VAR>termios</VAR>.c_cc[VEOL]</CODE> holds the characteritself.<P>The EOL character is recognized only in canonical input mode.  It actsas a line terminator, just like a newline character.  The EOL characteris not discarded; it is read as the last character in the input line.<P>You don't need to use the EOL character to make <KBD>RET</KBD> end a line.Just set the ICRNL flag.  In fact, this is the default state ofaffairs.<P><A NAME="IDX1189"></A><A NAME="IDX1190"></A><U>Macro:</U> int <B>VERASE</B><P>This is the subscript for the ERASE character in the special controlcharacter array.  <CODE><VAR>termios</VAR>.c_cc[VERASE]</CODE> holds thecharacter itself.<P>The ERASE character is recognized only in canonical input mode.  Whenthe user types the erase character, the previous character typed isdiscarded.  (If the terminal generates multibyte character sequences,this may cause more than one byte of input to be discarded.)  Thiscannot be used to erase past the beginning of the current line of text.The ERASE character itself is discarded.<P>Usually, the ERASE character is <KBD>DEL</KBD>.<P><A NAME="IDX1191"></A><A NAME="IDX1192"></A><U>Macro:</U> int <B>VKILL</B><P>This is the subscript for the KILL character in the special controlcharacter array.  <CODE><VAR>termios</VAR>.c_cc[VKILL]</CODE> holds the characteritself.<P>The KILL character is recognized only in canonical input mode.  When theuser types the kill character, the entire contents of the current lineof input are discarded.  The kill character itself is discarded too.<P>The KILL character is usually <KBD>C-u</KBD>.<P><H4><A NAME="SEC283" HREF="library_toc.html#SEC283" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC283">BSD Extensions to Editing Characters</A></H4><P>These special characters are active only in canonical input mode.See section <A HREF="library_16.html#SEC271" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_16.html#SEC271">Two Styles of Input: Canonical or Not</A>.  They are BSD extensions; the GNU librarydefines the symbols on any system if you ask for them, but thecharacters you specify don't actually <EM>do</EM> anything except on a BSDsystem.<P><A NAME="IDX1193"></A><A NAME="IDX1194"></A><U>Macro:</U> int <B>VEOL2</B><P>This is the subscript for the EOL2 character in the special controlcharacter array.  <CODE><VAR>termios</VAR>.c_cc[VEOL2]</CODE> holds the characteritself.<P>The EOL2 character works just like the EOL character (see above), but itcan be a different character.  Thus, you can specify two characters toterminate an input line, but setting EOL to one of them and EOL2 to theother.<P><A NAME="IDX1195"></A><A NAME="IDX1196"></A><U>Macro:</U> int <B>VWERASE</B><P>This is the subscript for the WERASE character in the special controlcharacter array.  <CODE><VAR>termios</VAR>.c_cc[VWERASE]</CODE> holds the characteritself.<P>The WERASE character is recognized only in canonical input mode.  Iterases an entire word of prior input.<P><A NAME="IDX1197"></A><A NAME="IDX1198"></A><U>Macro:</U> int <B>VREPRINT</B><P>This is the subscript for the REPRINT character in the special controlcharacter array.  <CODE><VAR>termios</VAR>.c_cc[VREPRINT]</CODE> holds the characteritself.<P>The REPRINT character is recognized only in canonical input mode.  Itreprints the current input line.<P><A NAME="IDX1199"></A><A NAME="IDX1200"></A><U>Macro:</U> int <B>VLNEXT</B><P>This is the subscript for the LNEXT character in the special controlcharacter array.  <CODE><VAR>termios</VAR>.c_cc[VLNEXT]</CODE> holds the characteritself.<P>The LNEXT character is recognized only when <CODE>IEXTEN</CODE> is set.  Itdisables the editing significance of the next character the user types.It is the analogue of the <KBD>C-q</KBD> command in Emacs.  "LNEXT" standsfor "literal next."<P>The LNEXT character is usually <KBD>C-v</KBD>.<P><H4><A NAME="SEC284" HREF="library_toc.html#SEC284" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC284">Characters that Cause Signals</A></H4><P>These special characters may be active in either canonical or noncanonicalinput mode, but only when the <CODE>ISIG</CODE> flag is set (see section <A HREF="library_16.html#SEC279" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_16.html#SEC279">Local Modes</A>).<P><A NAME="IDX1201"></A><A NAME="IDX1202"></A><A NAME="IDX1203"></A><U>Macro:</U> int <B>VINTR</B><P>This is the subscript for the INTR character in the special controlcharacter array.  <CODE><VAR>termios</VAR>.c_cc[VINTR]</CODE> holds the characteritself.<P>The INTR (interrupt) character raises a <CODE>SIGINT</CODE> signal for allprocesses in the foreground job associated with the terminal.  The INTRcharacter itself is then discarded.  See section <A HREF="library_21.html#SEC330" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_21.html#SEC330">Signal Handling</A>, for moreinformation about signals.<P>Typically, the INTR character is <KBD>C-c</KBD>.<P><A NAME="IDX1204"></A><A NAME="IDX1205"></A><U>Macro:</U> int <B>VQUIT</B><P>This is the subscript for the QUIT character in the special controlcharacter array.  <CODE><VAR>termios</VAR>.c_cc[VQUIT]</CODE> holds the characteritself.<P>The QUIT character raises a <CODE>SIGQUIT</CODE> signal for all processes inthe foreground job associated with the terminal.  The QUIT characteritself is then discarded.  See section <A HREF="library_21.html#SEC330" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_21.html#SEC330">Signal Handling</A>, for more informationabout signals.<P>Typically, the QUIT character is <KBD>C-\</KBD>.<P><A NAME="IDX1206"></A><A NAME="IDX1207"></A><A NAME="IDX1208"></A><U>Macro:</U> int <B>VSUSP</B><P>This is the subscript for the SUSP character in the special controlcharacter array.  <CODE><VAR>termios</VAR>.c_cc[VSUSP]</CODE> holds the characteritself.<P>The SUSP (suspend) character is recognized only if the implementationsupports job control (see section <A HREF="library_24.html#SEC411" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_24.html#SEC411">Job Control</A>).  It causes a <CODE>SIGTSTP</CODE>signal to be sent to all processes in the foreground job associated withthe terminal.  The SUSP character itself is then discarded.See section <A HREF="library_21.html#SEC330" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_21.html#SEC330">Signal Handling</A>, for more information about signals.<P>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -