Standards / Extensions | C or C++ | Dependencies |
---|---|---|
z/OS® UNIX | both |
#define _OPEN_SYS_PTY_EXTENSIONS
#include <termios.h>
int __tcgetcp(int fildes, size_t termcplen, struct __termcp *termcpptr);
The __tcgetcp() function gets the terminal session code page information contained in the termcp structure and the Code Page Change Notification (CPCN) capability for the terminal file.
Use the __tcsetcp() function to change the terminal session data conversion. The z/OS UNIX pseudotty device driver supports this CPCN capability.
Use __tcsettables() to change the terminal session data conversion. The OCS remote-tty device driver supports this CPCN capability.
In the returned termcp structure, if the _TCCP_FASTP bit is set then the data conversion that is specified by the source and target code page names can be performed locally by the data conversion application. This is valid any time that a table-driven conversion can be performed. For example, the data conversion point (application) could use the z/OS UNIX iconv() service to build local data conversion tables and perform all data conversion using the local tables instead of using iconv() all in subsequent conversions. This provides for better-performing data conversion.
In the returned termcp structure, if the _TCCP_BINARY bit is set then no data conversion is being performed and the code page names contained in the termcp structure should be ignored.
__tcgetcp() can run in either a foreground or background process; however, if the process is in the background, a foreground process may subsequently change the terminal code pages.
If successful, __tcgetcp() returns the termcp structure in a memory location pointed to by termcpptr. The return value contains the CPCN capability.
For a z/OS UNIX pseudotty terminal device file, issue the __tcsetcp() function against the master pty first to enable CPCN support.
#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(cterm_fd,sizeof(mytermcp),&mytermcp))== -1)
perror("__tcgetcp() error");
else {
if (_CPCN_NAMES == rv)
printf("Forward Code Page Names Only.\n");
else
printf("Forward Code Page Names and Tables.\n");
if (_TCCP_BINARY == (mytermcp.__tccp_flags & _TCCP_BINARY))
printf("Binary mode is in effect.\n");
else {
printf("ASCII code page name is %s.\n",
mytermcp.__tccp_fromname);
printf("EBCIDC code page name is %s.\n",
mytermcp.__tccp_toname);
}
}
close(cterm_fd);
}
} /* main */
Forward code page names only.
ASCII code page name is ISO8859-1.
EBCDIC code page name is IBM-1047.