From 8e889a0ed94aa6422be8c078c123cec64774e2c2 Mon Sep 17 00:00:00 2001 From: Fritz Elfert Date: Wed, 23 May 2001 08:30:31 +0000 Subject: Fixed iowatch More clipboard work (Works now in direction Psion -> PC ;-) --- lib/iowatch.cc | 8 ++++++-- lib/rclip.cc | 45 ++++++++++++++++++++++----------------------- 2 files changed, 28 insertions(+), 25 deletions(-) (limited to 'lib') 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 rclip:: checkNotify() { Enum 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 rclip:: initClipbd() { - Enum ret = rfsv::E_PSI_GEN_NONE; + Enum 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; } -- cgit v1.2.3