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");
DLLEXPORT QoreStringNode * q_strerror(int errnum)
returns the error string as a QoreStringNode
the base class for all data to be used as private data of Qore objects
Definition: AbstractPrivateData.h:44
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:48
DLLEXPORT AbstractQoreNode * raiseErrnoException(const char *err, int en, const char *fmt,...)
appends a Qore-language exception to the list and appends the result of strerror(errno) to the descri...
DLLEXPORT AbstractQoreNode * raiseException(const char *err, const char *fmt,...)
appends a Qore-language exception to the list
defines a Qore-language class
Definition: QoreClass.h:249
contains constants, classes, and subnamespaces in QoreProgram objects
Definition: QoreNamespace.h:65
unsigned qore_classid_t
used for the unique class ID for QoreClass objects
Definition: common.h:79
long long int64
64bit integer type, cannot use int64_t here since it breaks the API on some 64-bit systems due to equ...
Definition: common.h:260