From 660caf830d3aadb6eb5dbad5fe37dbea7dcb380a Mon Sep 17 00:00:00 2001 From: Fritz Elfert Date: Sun, 27 Aug 2000 23:24:17 +0000 Subject: Bugfix: QUERY_DRIVE returns status as last byte, not first. --- lib/rpcs.cc | 38 ++++++++++++++++++++++++-------------- lib/rpcs.h | 2 +- lib/rpcs16.cc | 2 +- lib/rpcs32.cc | 10 +++++----- 4 files changed, 31 insertions(+), 21 deletions(-) (limited to 'lib') diff --git a/lib/rpcs.cc b/lib/rpcs.cc index a4a19ab..f1cac8a 100644 --- a/lib/rpcs.cc +++ b/lib/rpcs.cc @@ -148,11 +148,21 @@ sendCommand(enum commands cc, bufferStore & data) } Enum rpcs:: -getResponse(bufferStore & data) +getResponse(bufferStore & data, bool statusIsFirstByte) { + Enum ret; if (skt->getBufferStore(data) == 1) { - Enum ret = (enum rfsv::errs)data.getByte(0); - data.discardFirstBytes(1); + if (statusIsFirstByte) { + ret = (enum rfsv::errs)data.getByte(0); + data.discardFirstBytes(1); + } else { + int l = data.getLen(); + if (l > 0) { + ret = (enum rfsv::errs)data.getByte(data.getLen() - 1); + data.init((const unsigned char *)data.getString(), l - 1); + } else + ret = rfsv::E_PSI_GEN_FAIL; + } return ret; } else status = rfsv::E_PSI_FILE_DISC; @@ -170,7 +180,7 @@ getNCPversion(int &major, int &minor) if (!sendCommand(QUERY_NCP, a)) return rfsv::E_PSI_FILE_DISC; - if ((res = getResponse(a)) != rfsv::E_PSI_GEN_NONE) + if ((res = getResponse(a, true)) != rfsv::E_PSI_GEN_NONE) return res; if (a.getLen() != 2) return rfsv::E_PSI_GEN_FAIL; @@ -192,7 +202,7 @@ execProgram(const char *program, const char *args) a.addStringT(args); if (!sendCommand(EXEC_PROG, a)) return rfsv::E_PSI_FILE_DISC; - return getResponse(a); + return getResponse(a, true); } Enum rpcs:: @@ -203,7 +213,7 @@ stopProgram(const char *program) a.addStringT(program); if (!sendCommand(STOP_PROG, a)) return rfsv::E_PSI_FILE_DISC; - return getResponse(a); + return getResponse(a, true); } Enum rpcs:: @@ -214,7 +224,7 @@ queryProgram(const char *program) a.addStringT(program); if (!sendCommand(QUERY_PROG, a)) return rfsv::E_PSI_FILE_DISC; - return getResponse(a); + return getResponse(a, true); } Enum rpcs:: @@ -226,7 +236,7 @@ formatOpen(const char *drive, int &handle, int &count) a.addStringT(drive); if (!sendCommand(FORMAT_OPEN, a)) return rfsv::E_PSI_FILE_DISC; - if ((res = getResponse(a)) != rfsv::E_PSI_GEN_NONE) + if ((res = getResponse(a, true)) != rfsv::E_PSI_GEN_NONE) return res; if (a.getLen() != 4) return rfsv::E_PSI_GEN_FAIL; @@ -243,7 +253,7 @@ formatRead(int handle) a.addWord(handle); if (!sendCommand(FORMAT_READ, a)) return rfsv::E_PSI_FILE_DISC; - return getResponse(a); + return getResponse(a, true); } Enum rpcs:: @@ -255,7 +265,7 @@ getUniqueID(const char *device, long &id) a.addStringT(device); if (!sendCommand(GET_UNIQUEID, a)) return rfsv::E_PSI_FILE_DISC; - if ((res = getResponse(a)) != rfsv::E_PSI_GEN_NONE) + if ((res = getResponse(a, true)) != rfsv::E_PSI_GEN_NONE) return res; if (a.getLen() != 4) return rfsv::E_PSI_GEN_FAIL; @@ -271,7 +281,7 @@ getOwnerInfo(bufferArray &owner) if (!sendCommand(GET_OWNERINFO, a)) return rfsv::E_PSI_FILE_DISC; - if ((res = (enum rfsv::errs)getResponse(a)) != rfsv::E_PSI_GEN_NONE) + if ((res = (enum rfsv::errs)getResponse(a, true)) != rfsv::E_PSI_GEN_NONE) return res; a.addByte(0); int l = a.getLen(); @@ -303,7 +313,7 @@ getMachineType(Enum &type) if (!sendCommand(GET_MACHINETYPE, a)) return rfsv::E_PSI_FILE_DISC; - if ((res = getResponse(a)) != rfsv::E_PSI_GEN_NONE) + if ((res = getResponse(a, true)) != rfsv::E_PSI_GEN_NONE) return res; if (a.getLen() != 2) return rfsv::E_PSI_GEN_FAIL; @@ -321,7 +331,7 @@ fuser(const char *name, char *buf, int maxlen) a.addStringT(name); if (!sendCommand(FUSER, a)) return rfsv::E_PSI_FILE_DISC; - if ((res = getResponse(a)) != rfsv::E_PSI_GEN_NONE) + if ((res = getResponse(a, true)) != rfsv::E_PSI_GEN_NONE) return res; strncpy(buf, a.getString(0), maxlen - 1); while ((p = strchr(buf, 6))) @@ -335,5 +345,5 @@ quitServer(void) bufferStore a; if (!sendCommand(QUIT_SERVER, a)) return rfsv::E_PSI_FILE_DISC; - return getResponse(a); + return getResponse(a, true); } diff --git a/lib/rpcs.h b/lib/rpcs.h index 18d4d66..83a8732 100644 --- a/lib/rpcs.h +++ b/lib/rpcs.h @@ -360,7 +360,7 @@ class rpcs { * @returns true on success, false on failure. */ bool sendCommand(enum commands cc, bufferStore &data); - Enum getResponse(bufferStore &); + Enum getResponse(bufferStore &data, bool statusIsFirstByte); const char *getConnectName(); }; diff --git a/lib/rpcs16.cc b/lib/rpcs16.cc index 57963e2..6e196fc 100644 --- a/lib/rpcs16.cc +++ b/lib/rpcs16.cc @@ -52,7 +52,7 @@ queryDrive(char drive, bufferArray &ret) a.addByte(drive); if (!sendCommand(rpcs::QUERY_DRIVE, a)) return rfsv::E_PSI_FILE_DISC; - Enum res = getResponse(a); + Enum res = getResponse(a, true); cout << dec << "qd: " << res << " " << a.getLen() << " a="<< a << endl; return res; } diff --git a/lib/rpcs32.cc b/lib/rpcs32.cc index 95dfd6f..85dd415 100644 --- a/lib/rpcs32.cc +++ b/lib/rpcs32.cc @@ -56,7 +56,7 @@ queryDrive(char drive, bufferArray &ret) a.addByte(drive); if (!sendCommand(rpcs::QUERY_DRIVE, a)) return rfsv::E_PSI_FILE_DISC; - if ((res = getResponse(a)) != rfsv::E_PSI_GEN_NONE) + if ((res = getResponse(a, false)) != rfsv::E_PSI_GEN_NONE) return res; int l = a.getLen(); ret.clear(); @@ -98,7 +98,7 @@ getCmdLine(const char *process, bufferStore &ret) a.addStringT(process); if (!sendCommand(rpcs::GET_CMDLINE, a)) return rfsv::E_PSI_FILE_DISC; - res = getResponse(a); + res = getResponse(a, true); ret = a; return res; } @@ -111,7 +111,7 @@ getMachineInfo(machineInfo &mi) if (!sendCommand(rpcs::GET_MACHINE_INFO, a)) return rfsv::E_PSI_FILE_DISC; - if ((res = getResponse(a)) != rfsv::E_PSI_GEN_NONE) + if ((res = getResponse(a, true)) != rfsv::E_PSI_GEN_NONE) return res; if (a.getLen() != 256) return rfsv::E_PSI_GEN_FAIL; @@ -178,7 +178,7 @@ configOpen(void) if (!sendCommand(rpcs::CONFIG_OPEN, a)) return rfsv::E_PSI_FILE_DISC; - res = getResponse(a); + res = getResponse(a, true); cout << "co: r=" << res << " a=" << a << endl; hhh = a.getDWord(0); return rfsv::E_PSI_GEN_NONE; @@ -198,7 +198,7 @@ configRead(void) a.addDWord(hhh); if (!sendCommand(rpcs::CONFIG_READ, a)) return rfsv::E_PSI_FILE_DISC; - if ((res = getResponse(a)) != rfsv::E_PSI_GEN_NONE) + if ((res = getResponse(a, true)) != rfsv::E_PSI_GEN_NONE) return res; l = a.getLen(); cout << "cr: " << l << endl; -- cgit v1.2.3