diff options
-rw-r--r-- | lib/iowatch.cc | 8 | ||||
-rw-r--r-- | lib/rclip.cc | 45 |
2 files changed, 28 insertions, 25 deletions
diff --git a/lib/iowatch.cc b/lib/iowatch.cc index 50c03a6..7335d4a 100644 --- a/lib/iowatch.cc +++ b/lib/iowatch.cc @@ -61,14 +61,18 @@ void IOWatch::remIO(const int fd) { bool IOWatch::watch(const long secs, const long usecs) { if (num > 0) { + int maxfd = 0; fd_set iop; FD_ZERO(&iop); - for (int i = 0; i < num; i++) + for (int i = 0; i < num; i++) { FD_SET(io[i], &iop); + if (io[i] > maxfd) + maxfd = io[i]; + } struct timeval t; t.tv_usec = usecs; t.tv_sec = secs; - return (select(io[0]+1, &iop, NULL, NULL, &t) > 0); + return (select(maxfd+1, &iop, NULL, NULL, &t) > 0); } sleep(secs); usleep(usecs); diff --git a/lib/rclip.cc b/lib/rclip.cc index 6c55c39..365c117 100644 --- a/lib/rclip.cc +++ b/lib/rclip.cc @@ -127,15 +127,18 @@ sendListen() { Enum<rfsv::errs> rclip:: checkNotify() { Enum<rfsv::errs> ret; - bufferStore a; - if ((ret = getResponse(a)) != rfsv::E_PSI_GEN_NONE) - cerr << "RCLIP ERR:" << a << endl; - else { - if (a.getLen() != 1) - ret = rfsv::E_PSI_GEN_FAIL; - if (a.getByte(0) != 0) - ret = rfsv::E_PSI_GEN_FAIL; + + int r = skt->getBufferStore(a, false); + if (r < 0) { + ret = status = rfsv::E_PSI_FILE_DISC; + } else { + if (r == 0) + ret = rfsv::E_PSI_FILE_EOF; + else { + if ((a.getLen() != 1) || (a.getByte(0) != 0)) + ret = rfsv::E_PSI_GEN_FAIL; + } } return ret; } @@ -146,12 +149,8 @@ waitNotify() { bufferStore a; sendCommand(RCLIP_LISTEN); - if ((ret = getResponse(a)) != rfsv::E_PSI_GEN_NONE) - cerr << "RCLIP ERR:" << a << endl; - else { - if (a.getLen() != 1) - ret = rfsv::E_PSI_GEN_FAIL; - if (a.getByte(0) != 0) + if ((ret = getResponse(a)) == rfsv::E_PSI_GEN_NONE) { + if ((a.getLen() != 1) || (a.getByte(0) != 0)) ret = rfsv::E_PSI_GEN_FAIL; } return ret; @@ -163,24 +162,24 @@ notify() { bufferStore a; sendCommand(RCLIP_NOTIFY); - if ((ret = getResponse(a)) != rfsv::E_PSI_GEN_NONE) - cerr << "RCLIP ERR:" << a << endl; - if (a.getLen() != 1) - ret = rfsv::E_PSI_GEN_FAIL; - if (a.getByte(0) != RCLIP_NOTIFY) + if ((ret = getResponse(a)) == rfsv::E_PSI_GEN_NONE) { + if ((a.getLen() != 1) || (a.getByte(0) != RCLIP_NOTIFY)) ret = rfsv::E_PSI_GEN_FAIL; + } return ret; } Enum<rfsv::errs> rclip:: initClipbd() { - Enum<rfsv::errs> ret = rfsv::E_PSI_GEN_NONE; + Enum<rfsv::errs> ret; bufferStore a; sendCommand(RCLIP_INIT); - if ((ret = getResponse(a)) != rfsv::E_PSI_GEN_NONE) - cerr << "RCLIP ERR:" << a << endl; - cout << "RCLIP RESP: " << a << endl; + if ((ret = getResponse(a)) == rfsv::E_PSI_GEN_NONE) { + if ((a.getLen() != 3) || (a.getByte(0) != RCLIP_INIT) || + (a.getWord(1) != 0x100)) + ret = rfsv::E_PSI_GEN_FAIL; + } return ret; } |