Standards / Extensions | C or C++ | Dependencies |
---|---|---|
z/OS® UNIX | both |
#define _OPEN_SYS_PTY_EXTENSIONS
#include <termios.h>
int __tcsetcp(int fildes, size_t termcplen, const struct __termcp *termcpptr);
The __tcsetcp() function sets (or changes) the terminal session code page information contained in the termcp structure.
Use the __tcsetcp() function to send new code page information to the data conversion point in order to change the data conversion environment for the terminal session. This function is used with terminal devices that support the “forward code page names only” Code Page Change Notification (CPCN) capability. The z/OS UNIX pseudotty (pty) device driver supports this capability.
For terminal sessions that use the z/OS UNIX pty device driver, the data conversion point is the application that uses the master pty device. An example data conversion point is the z/OS UNIX rlogin server. Here, rlogin uses CPCN functions to determine the ASCII source and/or EBCDIC target code pages to use for the conversion of the terminal data. During its processing of the __tcsetcp() function, the pty device driver applies the __termcp structure once the pty outbound data queue is drained. When this occurs, the pty input data queue is also flushed and a TIOCXPKT_CHCP packet exception event is generated if extended packet mode is enabled (PKTXTND is set in the termios structure) to notify the application using the master pty that the code page information has been changed. The master pty application can then use the __tcgetcp() function to retrieve the new code page information and establish a new data conversion environment.
The __tcsetcp() function is supported by both the master and slave pty device drivers, however, CPCN functions first must be enabled by the application that uses the master pty; enabling CPCN functions is performed by the system during the initial __tcsetcp() invocation against the master pty device. Once the __tcsetcp() function is performed against the master pty then it may be subsequently issued against the slave pty.
__tccp_fromname is case-sensitive.
__tccp_toname is case-sensitive.
When __tcsetcp() is issued against the slave pty from a process in a background process group, SIGTTOU processing is as follows:
Processing for SIGTTOU | Expected Behavior |
---|---|
Default or signal handler | The SIGTTOU signal is generated. The function is not performed. __tcsetcp() returns -1 and sets errno to EINTR. |
Ignored or blocked | The SIGTTOU signal is not sent. The function continues normally. |
If successful, __tcsetcp() returns 0.
The __tcsetcp() function must be issued against the master pty before any CPCN function can be issued against the slave pty.
#define _OPEN_SYS_PTY_EXTENSIONS
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <termios.h>
void main(void)
{
struct __termcp mytermcp;
int rv;
int cterm_fd;
if ((cterm_fd = open("/dev/tty",O_RDWR)) == -1)
printf("No controlling terminal established.\n");
else {
if ((rv = __tcgetcp(STDIN_FILENO,sizeof(mytermcp),&mytermcp))== -1)
perror("__tcgetcp() error");
else {
if (rv== _CPCN_NAMES) {
if (_TCCP_BINARY == (mytermcp.__tccp_flags & _TCCP_BINARY))
printf("Binary mode is in effect. No change made.\n");
else {
strcpy(mytermcp.__tccp_fromname,"IBM-850");
if (__tcsetcp(STDOUT_FILENO,sizeof(mytermcp),&mytermcp)!=0)
perror("__tcsetcp() error");
else
printf("ASCII code page changed to IBM-850.\n");
} /*not binary mode */
} /* _CPCN_NAMES */
} /* __tcgetcp success */
close(cterm_fd);
} /* controlling terminal established */
} /* main */
ASCII code page changed to IBM-850.