32 #ifndef _QORE_QC_TERMIOS_H
33 #define _QORE_QC_TERMIOS_H
44 #include <sys/ioctl.h>
54 xsink->
raiseException(
"TERMIOS-CC-ERROR",
"cc offset (%lld) is < 0", offset);
59 xsink->
raiseException(
"TERMIOS-CC-ERROR",
"cc offset (%lld) is > NCCS (%d)", offset, NCCS);
66 DLLLOCAL QoreTermIOS() {
69 DLLLOCAL QoreTermIOS(
const QoreTermIOS &cp) {
70 memcpy(&ios, &cp.ios,
sizeof(
struct termios));
73 DLLLOCAL
bool is_equal(
const QoreTermIOS *qtios) {
74 return !memcmp(&ios, &qtios->ios,
sizeof(
struct termios));
78 int rc = tcgetattr(fd, &ios);
89 int rc = tcsetattr(fd, action, &ios);
97 DLLLOCAL
void set_lflag(tcflag_t val) {
101 DLLLOCAL
void set_cflag(tcflag_t val) {
105 DLLLOCAL
void set_oflag(tcflag_t val) {
109 DLLLOCAL
void set_iflag(tcflag_t val) {
113 DLLLOCAL tcflag_t get_lflag()
const {
117 DLLLOCAL tcflag_t get_cflag()
const {
121 DLLLOCAL tcflag_t get_oflag()
const {
125 DLLLOCAL tcflag_t get_iflag()
const {
130 if (check_offset(offset, xsink))
133 return ios.c_cc[offset];
137 if (check_offset(offset, xsink))
140 ios.c_cc[offset] = val;
144 DLLLOCAL
static int getWindowSize(
int &rows,
int &columns,
ExceptionSink *xsink) {
147 int fd = open(
"/dev/tty", O_RDONLY);
149 xsink->
raiseErrnoException(
"TERMIOS-GET-WINDOW-SIZE-ERROR", errno,
"cannot open controlling terminal");
153 if (ioctl(fd, TIOCGWINSZ, &ws)) {
154 xsink->
raiseErrnoException(
"TERMIOS-GET-WINDOW-SIZE-ERROR", errno,
"error reading window size");
157 xsink->
raiseErrnoException(
"TERMIOS-GET-WINDOW-SIZE-ERROR", errno,
"error closing controlling terminal");
163 xsink->
raiseErrnoException(
"TERMIOS-GET-WINDOW-SIZE-ERROR", errno,
"error closing controlling terminal");
173 #endif // HAVE_TERMIOS_H
175 #endif // _QORE_QC_TERMIOS_H