| 1 | /* |
| 2 | * This file is a part of QTerminal - http://gitorious.org/qterminal |
| 3 | * |
| 4 | * This file was un-linked from KDE and modified |
| 5 | * by Maxim Bourmistrov <[email protected]> |
| 6 | * |
| 7 | */ |
| 8 | |
| 9 | /* |
| 10 | |
| 11 | This file is part of the KDE libraries |
| 12 | Copyright (C) 2007 Oswald Buddenhagen <[email protected]> |
| 13 | Copyright (C) 2010 KDE e.V. <[email protected]> |
| 14 | Author Adriaan de Groot <[email protected]> |
| 15 | |
| 16 | This library is free software; you can redistribute it and/or |
| 17 | modify it under the terms of the GNU Library General Public |
| 18 | License as published by the Free Software Foundation; either |
| 19 | version 2 of the License, or (at your option) any later version. |
| 20 | |
| 21 | This library is distributed in the hope that it will be useful, |
| 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 24 | Library General Public License for more details. |
| 25 | |
| 26 | You should have received a copy of the GNU Library General Public License |
| 27 | along with this library; see the file COPYING.LIB. If not, write to |
| 28 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 29 | Boston, MA 02110-1301, USA. |
| 30 | */ |
| 31 | |
| 32 | #include "kptydevice.h"cxx . . $ `<file>/lib/kptydevice.h`/ |
| 33 | #include "kpty_p.h"cxx . . $ `<file>/lib/kpty_p.h`/ |
| 34 | |
| 35 | #include <QSocketNotifier> |
| 36 | |
| 37 | #include <unistd.h> |
| 38 | #include <cerrno> |
| 39 | #include <csignal> |
| 40 | #include <termios.h> |
| 41 | #include <fcntl.h> |
| 42 | #include <sys/ioctl.h> |
| 43 | #ifdef HAVE_SYS_FILIO_H |
| 44 | # include <sys/filio.h> |
| 45 | #endif |
| 46 | #ifdef HAVE_SYS_TIME_Hcxx . . $ `<built-in>:481:9`! |
| 47 | # include <sys/time.h> |
| 48 | #endif |
| 49 | |
| 50 | #if defined(Q_OS_FREEBSD) || defined(Q_OS_MAC) |
| 51 | // "the other end's output queue size" - kinda braindead, huh? |
| 52 | # define PTY_BYTES_AVAILABLE TIOCOUTQ |
| 53 | #elif defined(TIOCINQcxx . . $ `<external>/123502480044527469/ioctls.h:47:9`!) |
| 54 | // "our end's input queue size" |
| 55 | # define PTY_BYTES_AVAILABLEcxx . . $ `lib/kptydevice.cpp:55:10`! TIOCINQcxx . . $ `<external>/123502480044527469/ioctls.h:47:9`! |
| 56 | #else |
| 57 | // likewise. more generic ioctl (theoretically) |
| 58 | # define PTY_BYTES_AVAILABLE FIONREAD |
| 59 | #endif |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | ////////////////// |
| 65 | // private data // |
| 66 | ////////////////// |
| 67 | |
| 68 | // Lifted from Qt. I don't think they would mind. ;) |
| 69 | // Re-lift again from Qt whenever a proper replacement for pthread_once appears |
| 70 | static void qt_ignore_sigpipecxx . . $ qt_ignore_sigpipe(49f6e7a06ebc5aa8).() |
| 71 | { |
| 72 | static QBasicAtomicIntcxx . . $ QBasicAtomicInt# atom = Q_BASIC_ATOMIC_INITIALIZERcxx . . $ `<external>/14530492643939732081/qatomic_cxx11.h:484:11`!(0); |
| 73 | if (atom.testAndSetRelaxedcxx . . $ QBasicAtomicInteger#testAndSetRelaxed(3a762b1b358ff2bf).(0, 1)) { |
| 74 | struct sigaction noaction; |
| 75 | memset(&noaction, 0, sizeof(noaction)); |
| 76 | noaction.sa_handlercxx . . $ `<external>/16635209305659446502/sigaction.h:39:10`! = SIG_IGNcxx . . $ `<external>/11773118241360591791/signum-generic.h:30:9`!; |
| 77 | sigaction(SIGPIPEcxx . . $ `<external>/11773118241360591791/signum-generic.h:60:9`!, &noaction, nullptr); |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | #define NO_INTRcxx . . $ `lib/kptydevice.cpp:81:9`!(ret,func) do { ret = func; } while (ret < 0 && errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! == EINTRcxx . . $ `<external>/8987895939074593727/errno-base.h:8:9`!) |
| 82 | |
| 83 | bool KPtyDevicePrivatecxx . . $ KPtyDevicePrivate#::_k_canReadcxx . . $ KPtyDevicePrivate#_k_canRead(c9857a73d68e59ba).() |
| 84 | { |
| 85 | Q_Qcxx . . $ `<external>/15045578679651060896/qglobal.h:1178:9`!(KPtyDevice); |
| 86 | qint64cxx . . $ qint64# readBytes = 0; |
| 87 | |
| 88 | #ifdef Q_OS_IRIX // this should use a config define, but how to check it? |
| 89 | size_t available; |
| 90 | #else |
| 91 | int available; |
| 92 | #endif |
| 93 | if (::ioctl(q->masterFdcxx . . $ KPty#masterFd(455f465bc33b4cdf).(), PTY_BYTES_AVAILABLEcxx . . $ `lib/kptydevice.cpp:55:10`!, (char *) &available) != -1) { |
| 94 | #ifdef Q_OS_SOLARIS |
| 95 | // A Pty is a STREAMS module, and those can be activated |
| 96 | // with 0 bytes available. This happens either when ^C is |
| 97 | // pressed, or when an application does an explicit write(a,b,0) |
| 98 | // which happens in experiments fairly often. When 0 bytes are |
| 99 | // available, you must read those 0 bytes to clear the STREAMS |
| 100 | // module, but we don't want to hit the !readBytes case further down. |
| 101 | if (!available) { |
| 102 | char c; |
| 103 | // Read the 0-byte STREAMS message |
| 104 | NO_INTR(readBytes, read(q->masterFd(), &c, 0)); |
| 105 | // Should return 0 bytes read; -1 is error |
| 106 | if (readBytes < 0) { |
| 107 | readNotifier->setEnabled(false); |
| 108 | emit q->readEof(); |
| 109 | return false; |
| 110 | } |
| 111 | return true; |
| 112 | } |
| 113 | #endif |
| 114 | |
| 115 | char *ptr = readBuffercxx . . $ KPtyDevicePrivate#readBuffer..reservecxx . . $ KRingBuffer#reserve(ff224f080444ee45).(available); |
| 116 | #ifdef Q_OS_SOLARIS |
| 117 | // Even if available > 0, it is possible for read() |
| 118 | // to return 0 on Solaris, due to 0-byte writes in the stream. |
| 119 | // Ignore them and keep reading until we hit *some* data. |
| 120 | // In Solaris it is possible to have 15 bytes available |
| 121 | // and to (say) get 0, 0, 6, 0 and 9 bytes in subsequent reads. |
| 122 | // Because the stream is set to O_NONBLOCK in finishOpen(), |
| 123 | // an EOF read will return -1. |
| 124 | readBytes = 0; |
| 125 | while (!readBytes) |
| 126 | #endif |
| 127 | // Useless block braces except in Solaris |
| 128 | { |
| 129 | NO_INTRcxx . . $ `lib/kptydevice.cpp:81:9`!(readBytes, read(q->masterFd(), ptr, available)); |
| 130 | } |
| 131 | if (readBytes < 0) { |
| 132 | readBuffercxx . . $ KPtyDevicePrivate#readBuffer..unreservecxx . . $ KRingBuffer#unreserve(d4f767463ce0a6b3).(available); |
| 133 | q->setErrorStringcxx . . $ QIODevice#setErrorString(3520e46b33348bf6).(QLatin1Stringcxx . . $ QString#QString(4641beeb24e75d60).("Error reading from PTY")); |
| 134 | return false; |
| 135 | } |
| 136 | readBuffercxx . . $ KPtyDevicePrivate#readBuffer..unreservecxx . . $ KRingBuffer#unreserve(d4f767463ce0a6b3).(available - readBytes); // *should* be a no-op |
| 137 | } |
| 138 | |
| 139 | if (!readBytes) { |
| 140 | readNotifiercxx . . $ KPtyDevicePrivate#readNotifier.->setEnabledcxx . . $ QSocketNotifier#setEnabled(b45ddcbc8423892c).(false); |
| 141 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! q->readEofcxx . . $ KPtyDevice#readEof(49f6e7a06ebc5aa8).(); |
| 142 | return false; |
| 143 | } else { |
| 144 | if (!emittedReadyReadcxx . . $ KPtyDevicePrivate#emittedReadyRead.) { |
| 145 | emittedReadyReadcxx . . $ KPtyDevicePrivate#emittedReadyRead. = true; |
| 146 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! q->readyReadcxx . . $ QIODevice#readyRead(49f6e7a06ebc5aa8).(); |
| 147 | emittedReadyReadcxx . . $ KPtyDevicePrivate#emittedReadyRead. = false; |
| 148 | } |
| 149 | return true; |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | bool KPtyDevicePrivatecxx . . $ KPtyDevicePrivate#::_k_canWritecxx . . $ KPtyDevicePrivate#_k_canWrite(c9857a73d68e59ba).() |
| 154 | { |
| 155 | Q_Qcxx . . $ `<external>/15045578679651060896/qglobal.h:1178:9`!(KPtyDevice); |
| 156 | |
| 157 | writeNotifiercxx . . $ KPtyDevicePrivate#writeNotifier.->setEnabledcxx . . $ QSocketNotifier#setEnabled(b45ddcbc8423892c).(false); |
| 158 | if (writeBuffercxx . . $ KPtyDevicePrivate#writeBuffer..isEmptycxx . . $ KRingBuffer#isEmpty(50ce9a9e25b4a850).()) |
| 159 | return false; |
| 160 | |
| 161 | qt_ignore_sigpipecxx . . $ qt_ignore_sigpipe(49f6e7a06ebc5aa8).(); |
| 162 | int wroteBytes; |
| 163 | NO_INTRcxx . . $ `lib/kptydevice.cpp:81:9`!(wroteBytes, |
| 164 | write(q->masterFd(), |
| 165 | writeBuffer.readPointer(), writeBuffer.readSize())); |
| 166 | if (wroteBytes < 0) { |
| 167 | q->setErrorStringcxx . . $ QIODevice#setErrorString(3520e46b33348bf6).(QLatin1Stringcxx . . $ QString#QString(4641beeb24e75d60).("Error writing to PTY")); |
| 168 | return false; |
| 169 | } |
| 170 | writeBuffercxx . . $ KPtyDevicePrivate#writeBuffer..freecxx . . $ KRingBuffer#free(d4f767463ce0a6b3).(wroteBytes); |
| 171 | |
| 172 | if (!emittedBytesWrittencxx . . $ KPtyDevicePrivate#emittedBytesWritten.) { |
| 173 | emittedBytesWrittencxx . . $ KPtyDevicePrivate#emittedBytesWritten. = true; |
| 174 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! q->bytesWrittencxx . . $ QIODevice#bytesWritten(35cb52607f6af42f).(wroteBytes); |
| 175 | emittedBytesWrittencxx . . $ KPtyDevicePrivate#emittedBytesWritten. = false; |
| 176 | } |
| 177 | |
| 178 | if (!writeBuffercxx . . $ KPtyDevicePrivate#writeBuffer..isEmptycxx . . $ KRingBuffer#isEmpty(50ce9a9e25b4a850).()) |
| 179 | writeNotifiercxx . . $ KPtyDevicePrivate#writeNotifier.->setEnabledcxx . . $ QSocketNotifier#setEnabled(b45ddcbc8423892c).(true); |
| 180 | return true; |
| 181 | } |
| 182 | |
| 183 | #ifndef timeraddcxx . . $ `<external>/8057359269225398204/time.h:237:10`! |
| 184 | // Lifted from GLIBC |
| 185 | # define timeradd(a, b, result) \ |
| 186 | do { \ |
| 187 | (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \ |
| 188 | (result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \ |
| 189 | if ((result)->tv_usec >= 1000000) { \ |
| 190 | ++(result)->tv_sec; \ |
| 191 | (result)->tv_usec -= 1000000; \ |
| 192 | } \ |
| 193 | } while (0) |
| 194 | # define timersub(a, b, result) \ |
| 195 | do { \ |
| 196 | (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ |
| 197 | (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ |
| 198 | if ((result)->tv_usec < 0) { \ |
| 199 | --(result)->tv_sec; \ |
| 200 | (result)->tv_usec += 1000000; \ |
| 201 | } \ |
| 202 | } while (0) |
| 203 | #endif |
| 204 | |
| 205 | bool KPtyDevicePrivatecxx . . $ KPtyDevicePrivate#::doWaitcxx . . $ KPtyDevicePrivate#doWait(9609253e83e89946).(int msecs, bool reading) |
| 206 | { |
| 207 | Q_Qcxx . . $ `<external>/15045578679651060896/qglobal.h:1178:9`!(KPtyDevice); |
| 208 | #ifndef __linux__cxx . . $ `<built-in>:464:9`! |
| 209 | struct timeval etv; |
| 210 | #endif |
| 211 | struct timeval tv, *tvp; |
| 212 | |
| 213 | if (msecs < 0) |
| 214 | tvp = nullptr; |
| 215 | else { |
| 216 | tv.tv_sec = msecs / 1000; |
| 217 | tv.tv_usec = (msecs % 1000) * 1000; |
| 218 | #ifndef __linux__cxx . . $ `<built-in>:464:9`! |
| 219 | gettimeofday(&etv, 0); |
| 220 | timeradd(&tv, &etv, &etv); |
| 221 | #endif |
| 222 | tvp = &tv; |
| 223 | } |
| 224 | |
| 225 | while (reading ? readNotifiercxx . . $ KPtyDevicePrivate#readNotifier.->isEnabledcxx . . $ QSocketNotifier#isEnabled(50ce9a9e25b4a850).() : !writeBuffercxx . . $ KPtyDevicePrivate#writeBuffer..isEmptycxx . . $ KRingBuffer#isEmpty(50ce9a9e25b4a850).()) { |
| 226 | fd_set rfds; |
| 227 | fd_set wfds; |
| 228 | |
| 229 | FD_ZEROcxx . . $ `<external>/946878812840035423/select.h:88:9`!(&rfds); |
| 230 | FD_ZEROcxx . . $ `<external>/946878812840035423/select.h:88:9`!(&wfds); |
| 231 | |
| 232 | if (readNotifiercxx . . $ KPtyDevicePrivate#readNotifier.->isEnabledcxx . . $ QSocketNotifier#isEnabled(50ce9a9e25b4a850).()) |
| 233 | FD_SETcxx . . $ `<external>/946878812840035423/select.h:85:9`!(q->masterFd(), &rfds); |
| 234 | if (!writeBuffercxx . . $ KPtyDevicePrivate#writeBuffer..isEmptycxx . . $ KRingBuffer#isEmpty(50ce9a9e25b4a850).()) |
| 235 | FD_SETcxx . . $ `<external>/946878812840035423/select.h:85:9`!(q->masterFd(), &wfds); |
| 236 | |
| 237 | #ifndef __linux__cxx . . $ `<built-in>:464:9`! |
| 238 | if (tvp) { |
| 239 | gettimeofday(&tv, 0); |
| 240 | timersub(&etv, &tv, &tv); |
| 241 | if (tv.tv_sec < 0) |
| 242 | tv.tv_sec = tv.tv_usec = 0; |
| 243 | } |
| 244 | #endif |
| 245 | |
| 246 | switch (select(q->masterFdcxx . . $ KPty#masterFd(455f465bc33b4cdf).() + 1, &rfds, &wfds, nullptr, tvp)) { |
| 247 | case -1: |
| 248 | if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! == EINTRcxx . . $ `<external>/8987895939074593727/errno-base.h:8:9`!) |
| 249 | break; |
| 250 | return false; |
| 251 | case 0: |
| 252 | q->setErrorStringcxx . . $ QIODevice#setErrorString(3520e46b33348bf6).(QLatin1Stringcxx . . $ QString#QString(4641beeb24e75d60).("PTY operation timed out")); |
| 253 | return false; |
| 254 | default: |
| 255 | if (FD_ISSETcxx . . $ `<external>/946878812840035423/select.h:87:9`!(q->masterFd(), &rfds)) { |
| 256 | bool canRead = _k_canReadcxx . . $ KPtyDevicePrivate#_k_canRead(c9857a73d68e59ba).(); |
| 257 | if (reading && canRead) |
| 258 | return true; |
| 259 | } |
| 260 | if (FD_ISSETcxx . . $ `<external>/946878812840035423/select.h:87:9`!(q->masterFd(), &wfds)) { |
| 261 | bool canWrite = _k_canWritecxx . . $ KPtyDevicePrivate#_k_canWrite(c9857a73d68e59ba).(); |
| 262 | if (!reading) |
| 263 | return canWrite; |
| 264 | } |
| 265 | break; |
| 266 | } |
| 267 | } |
| 268 | return false; |
| 269 | } |
| 270 | |
| 271 | void KPtyDevicePrivatecxx . . $ KPtyDevicePrivate#::finishOpencxx . . $ KPtyDevicePrivate#finishOpen(6a9e152534c2b05f).(QIODevicecxx . . $ QIODevice#::OpenModecxx . . $ QIODevice#OpenMode# mode) |
| 272 | { |
| 273 | Q_Qcxx . . $ `<external>/15045578679651060896/qglobal.h:1178:9`!(KPtyDevice); |
| 274 | |
| 275 | q->QIODevicecxx . . $ QIODevice#::opencxx . . $ QIODevice#open(dca164408be960c8).(mode); |
| 276 | fcntl(q->masterFdcxx . . $ KPty#masterFd(455f465bc33b4cdf).(), F_SETFLcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:169:9`!, O_NONBLOCKcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:62:10`!); |
| 277 | readBuffercxx . . $ KPtyDevicePrivate#readBuffer..clearcxx . . $ KRingBuffer#clear(49f6e7a06ebc5aa8).(); |
| 278 | readNotifiercxx . . $ KPtyDevicePrivate#readNotifier. = new QSocketNotifiercxx . . $ QSocketNotifier#QSocketNotifier(61e5ada07161773).(q->masterFdcxx . . $ KPty#masterFd(455f465bc33b4cdf).(), QSocketNotifiercxx . . $ QSocketNotifier#::Readcxx . . $ QSocketNotifier#Read., q); |
| 279 | writeNotifiercxx . . $ KPtyDevicePrivate#writeNotifier. = new QSocketNotifiercxx . . $ QSocketNotifier#QSocketNotifier(61e5ada07161773).(q->masterFdcxx . . $ KPty#masterFd(455f465bc33b4cdf).(), QSocketNotifiercxx . . $ QSocketNotifier#::Writecxx . . $ QSocketNotifier#Write., q); |
| 280 | QObjectcxx . . $ QObject#::connectcxx . . $ QObject#connect(158df1d9a01a3410).(readNotifiercxx . . $ KPtyDevicePrivate#readNotifier., SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(activated(int)), q, SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(_k_canRead())); |
| 281 | QObjectcxx . . $ QObject#::connectcxx . . $ QObject#connect(158df1d9a01a3410).(writeNotifiercxx . . $ KPtyDevicePrivate#writeNotifier., SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(activated(int)), q, SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(_k_canWrite())); |
| 282 | readNotifiercxx . . $ KPtyDevicePrivate#readNotifier.->setEnabledcxx . . $ QSocketNotifier#setEnabled(b45ddcbc8423892c).(true); |
| 283 | } |
| 284 | |
| 285 | ///////////////////////////// |
| 286 | // public member functions // |
| 287 | ///////////////////////////// |
| 288 | |
| 289 | KPtyDevicecxx . . $ KPtyDevice#::KPtyDevicecxx . . $ KPtyDevice#KPtyDevice(749de1b6ae65bddd).(QObjectcxx . . $ QObject# *parent) : |
| 290 | QIODevicecxx . . $ QIODevice#(parent), |
| 291 | KPtycxx . . $ KPty#(new KPtyDevicePrivatecxx . . $ KPtyDevicePrivate#KPtyDevicePrivate(24a2b0b8e23ae922).(this)) |
| 292 | { |
| 293 | } |
| 294 | |
| 295 | KPtyDevicecxx . . $ KPtyDevice#::~cxx . . $ KPtyDevice#`~KPtyDevice`(ced63f7c635d850d).KPtyDevicecxx . . $ KPtyDevice#() |
| 296 | { |
| 297 | closecxx . . $ KPtyDevice#close(49f6e7a06ebc5aa8).(); |
| 298 | } |
| 299 | |
| 300 | bool KPtyDevicecxx . . $ KPtyDevice#::opencxx . . $ KPtyDevice#open(dca164408be960c8).(OpenModecxx . . $ QIODevice#OpenMode# mode) |
| 301 | { |
| 302 | Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(KPtyDevice); |
| 303 | |
| 304 | if (masterFdcxx . . $ KPty#masterFd(455f465bc33b4cdf).() >= 0) |
| 305 | return true; |
| 306 | |
| 307 | if (!KPtycxx . . $ KPty#::opencxx . . $ KPty#open(c9857a73d68e59ba).()) { |
| 308 | setErrorStringcxx . . $ QIODevice#setErrorString(3520e46b33348bf6).(QLatin1Stringcxx . . $ QString#QString(4641beeb24e75d60).("Error opening PTY")); |
| 309 | return false; |
| 310 | } |
| 311 | |
| 312 | d->finishOpencxx . . $ KPtyDevicePrivate#finishOpen(6a9e152534c2b05f).(mode); |
| 313 | |
| 314 | return true; |
| 315 | } |
| 316 | |
| 317 | bool KPtyDevicecxx . . $ KPtyDevice#::opencxx . . $ KPtyDevice#open(461c37ce8fbaff32).(int fd, OpenModecxx . . $ QIODevice#OpenMode# mode) |
| 318 | { |
| 319 | Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(KPtyDevice); |
| 320 | |
| 321 | if (!KPtycxx . . $ KPty#::opencxx . . $ KPty#open(83c267b20bac841a).(fd)) { |
| 322 | setErrorStringcxx . . $ QIODevice#setErrorString(3520e46b33348bf6).(QLatin1Stringcxx . . $ QString#QString(4641beeb24e75d60).("Error opening PTY")); |
| 323 | return false; |
| 324 | } |
| 325 | |
| 326 | d->finishOpencxx . . $ KPtyDevicePrivate#finishOpen(6a9e152534c2b05f).(mode); |
| 327 | |
| 328 | return true; |
| 329 | } |
| 330 | |
| 331 | void KPtyDevicecxx . . $ KPtyDevice#::closecxx . . $ KPtyDevice#close(49f6e7a06ebc5aa8).() |
| 332 | { |
| 333 | Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(KPtyDevice); |
| 334 | |
| 335 | if (masterFdcxx . . $ KPty#masterFd(455f465bc33b4cdf).() < 0) |
| 336 | return; |
| 337 | |
| 338 | delete d->readNotifiercxx . . $ KPtyDevicePrivate#readNotifier.; |
| 339 | delete d->writeNotifiercxx . . $ KPtyDevicePrivate#writeNotifier.; |
| 340 | |
| 341 | QIODevicecxx . . $ QIODevice#::closecxx . . $ QIODevice#close(49f6e7a06ebc5aa8).(); |
| 342 | |
| 343 | KPtycxx . . $ KPty#::closecxx . . $ KPty#close(49f6e7a06ebc5aa8).(); |
| 344 | } |
| 345 | |
| 346 | bool KPtyDevicecxx . . $ KPtyDevice#::isSequentialcxx . . $ KPtyDevice#isSequential(50ce9a9e25b4a850).() const |
| 347 | { |
| 348 | return true; |
| 349 | } |
| 350 | |
| 351 | bool KPtyDevicecxx . . $ KPtyDevice#::canReadLinecxx . . $ KPtyDevice#canReadLine(50ce9a9e25b4a850).() const |
| 352 | { |
| 353 | Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(const KPtyDevice); |
| 354 | return QIODevicecxx . . $ QIODevice#::canReadLinecxx . . $ QIODevice#canReadLine(50ce9a9e25b4a850).() || d->readBuffercxx . . $ KPtyDevicePrivate#readBuffer..canReadLinecxx . . $ KRingBuffer#canReadLine(50ce9a9e25b4a850).(); |
| 355 | } |
| 356 | |
| 357 | bool KPtyDevicecxx . . $ KPtyDevice#::atEndcxx . . $ KPtyDevice#atEnd(50ce9a9e25b4a850).() const |
| 358 | { |
| 359 | Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(const KPtyDevice); |
| 360 | return QIODevicecxx . . $ QIODevice#::atEndcxx . . $ QIODevice#atEnd(50ce9a9e25b4a850).() && d->readBuffercxx . . $ KPtyDevicePrivate#readBuffer..isEmptycxx . . $ KRingBuffer#isEmpty(50ce9a9e25b4a850).(); |
| 361 | } |
| 362 | |
| 363 | qint64cxx . . $ qint64# KPtyDevicecxx . . $ KPtyDevice#::bytesAvailablecxx . . $ KPtyDevice#bytesAvailable(98833e9ab7de59a4).() const |
| 364 | { |
| 365 | Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(const KPtyDevice); |
| 366 | return QIODevicecxx . . $ QIODevice#::bytesAvailablecxx . . $ QIODevice#bytesAvailable(98833e9ab7de59a4).() + d->readBuffercxx . . $ KPtyDevicePrivate#readBuffer..sizecxx . . $ KRingBuffer#size(455f465bc33b4cdf).(); |
| 367 | } |
| 368 | |
| 369 | qint64cxx . . $ qint64# KPtyDevicecxx . . $ KPtyDevice#::bytesToWritecxx . . $ KPtyDevice#bytesToWrite(98833e9ab7de59a4).() const |
| 370 | { |
| 371 | Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(const KPtyDevice); |
| 372 | return d->writeBuffercxx . . $ KPtyDevicePrivate#writeBuffer..sizecxx . . $ KRingBuffer#size(455f465bc33b4cdf).(); |
| 373 | } |
| 374 | |
| 375 | bool KPtyDevicecxx . . $ KPtyDevice#::waitForReadyReadcxx . . $ KPtyDevice#waitForReadyRead(83c267b20bac841a).(int msecs) |
| 376 | { |
| 377 | Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(KPtyDevice); |
| 378 | return d->doWaitcxx . . $ KPtyDevicePrivate#doWait(9609253e83e89946).(msecs, true); |
| 379 | } |
| 380 | |
| 381 | bool KPtyDevicecxx . . $ KPtyDevice#::waitForBytesWrittencxx . . $ KPtyDevice#waitForBytesWritten(83c267b20bac841a).(int msecs) |
| 382 | { |
| 383 | Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(KPtyDevice); |
| 384 | return d->doWaitcxx . . $ KPtyDevicePrivate#doWait(9609253e83e89946).(msecs, false); |
| 385 | } |
| 386 | |
| 387 | void KPtyDevicecxx . . $ KPtyDevice#::setSuspendedcxx . . $ KPtyDevice#setSuspended(b45ddcbc8423892c).(bool suspended) |
| 388 | { |
| 389 | Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(KPtyDevice); |
| 390 | d->readNotifiercxx . . $ KPtyDevicePrivate#readNotifier.->setEnabledcxx . . $ QSocketNotifier#setEnabled(b45ddcbc8423892c).(!suspended); |
| 391 | } |
| 392 | |
| 393 | bool KPtyDevicecxx . . $ KPtyDevice#::isSuspendedcxx . . $ KPtyDevice#isSuspended(50ce9a9e25b4a850).() const |
| 394 | { |
| 395 | Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(const KPtyDevice); |
| 396 | return !d->readNotifiercxx . . $ KPtyDevicePrivate#readNotifier.->isEnabledcxx . . $ QSocketNotifier#isEnabled(50ce9a9e25b4a850).(); |
| 397 | } |
| 398 | |
| 399 | // protected |
| 400 | qint64cxx . . $ qint64# KPtyDevicecxx . . $ KPtyDevice#::readDatacxx . . $ KPtyDevice#readData(2e638bc8ed65be6c).(char *data, qint64cxx . . $ qint64# maxlen) |
| 401 | { |
| 402 | Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(KPtyDevice); |
| 403 | return d->readBuffercxx . . $ KPtyDevicePrivate#readBuffer..readcxx . . $ KRingBuffer#read(6abd07ddb1a912f0).(data, (int)qMincxx . . $ qMin(2a338fce5842aa6a).<qint64cxx . . $ qint64#>(maxlen, KMAXINTcxx . . $ `lib/kptydevice.h:36:9`!)); |
| 404 | } |
| 405 | |
| 406 | // protected |
| 407 | qint64cxx . . $ qint64# KPtyDevicecxx . . $ KPtyDevice#::readLineDatacxx . . $ KPtyDevice#readLineData(2e638bc8ed65be6c).(char *data, qint64cxx . . $ qint64# maxlen) |
| 408 | { |
| 409 | Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(KPtyDevice); |
| 410 | return d->readBuffercxx . . $ KPtyDevicePrivate#readBuffer..readLinecxx . . $ KRingBuffer#readLine(6abd07ddb1a912f0).(data, (int)qMincxx . . $ qMin(2a338fce5842aa6a).<qint64cxx . . $ qint64#>(maxlen, KMAXINTcxx . . $ `lib/kptydevice.h:36:9`!)); |
| 411 | } |
| 412 | |
| 413 | // protected |
| 414 | qint64cxx . . $ qint64# KPtyDevicecxx . . $ KPtyDevice#::writeDatacxx . . $ KPtyDevice#writeData(93d4069f65218ea4).(const char *data, qint64cxx . . $ qint64# len) |
| 415 | { |
| 416 | Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(KPtyDevice); |
| 417 | Q_ASSERTcxx . . $ `<external>/15045578679651060896/qglobal.h:859:13`!(len <= KMAXINTcxx . . $ `lib/kptydevice.h:36:9`!); |
| 418 | |
| 419 | d->writeBuffercxx . . $ KPtyDevicePrivate#writeBuffer..writecxx . . $ KRingBuffer#write(34d26762b42c433a).(data, len); |
| 420 | d->writeNotifiercxx . . $ KPtyDevicePrivate#writeNotifier.->setEnabledcxx . . $ QSocketNotifier#setEnabled(b45ddcbc8423892c).(true); |
| 421 | return len; |
| 422 | } |