From d439bc3807b3f7cea0544899ee5fc8d849bf32df Mon Sep 17 00:00:00 2001 From: Fritz Elfert Date: Wed, 2 Aug 2000 18:26:29 +0000 Subject: Added a wrapper for enums and changed all return-code related stuff as well as some other enums to use that instead of plain enums. This results in stronger type checking, range checking and the ability to write an enum's textual representation. --- lib/rpcs32.cc | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'lib/rpcs32.cc') diff --git a/lib/rpcs32.cc b/lib/rpcs32.cc index 22433ee..95dfd6f 100644 --- a/lib/rpcs32.cc +++ b/lib/rpcs32.cc @@ -42,21 +42,21 @@ rpcs32::~rpcs32() { bufferStore a; a.addStringT("Close"); - if (status == E_PSI_GEN_NONE) + if (status == rfsv::E_PSI_GEN_NONE) skt->sendBufferStore(a); skt->closeSocket(); } -int rpcs32:: +Enum rpcs32:: queryDrive(char drive, bufferArray &ret) { bufferStore a; - int res; + Enum res; a.addByte(drive); if (!sendCommand(rpcs::QUERY_DRIVE, a)) - return rpcs::E_PSI_FILE_DISC; - if ((res = getResponse(a))) + return rfsv::E_PSI_FILE_DISC; + if ((res = getResponse(a)) != rfsv::E_PSI_GEN_NONE) return res; int l = a.getLen(); ret.clear(); @@ -89,40 +89,40 @@ queryDrive(char drive, bufferArray &ret) return res; } -int rpcs32:: +Enum rpcs32:: getCmdLine(const char *process, bufferStore &ret) { bufferStore a; - int res; + Enum res; a.addStringT(process); if (!sendCommand(rpcs::GET_CMDLINE, a)) - return rpcs::E_PSI_FILE_DISC; + return rfsv::E_PSI_FILE_DISC; res = getResponse(a); ret = a; return res; } -int rpcs32:: +Enum rpcs32:: getMachineInfo(machineInfo &mi) { bufferStore a; - int res; + Enum res; if (!sendCommand(rpcs::GET_MACHINE_INFO, a)) - return rpcs::E_PSI_FILE_DISC; - if ((res = getResponse(a))) + return rfsv::E_PSI_FILE_DISC; + if ((res = getResponse(a)) != rfsv::E_PSI_GEN_NONE) return res; if (a.getLen() != 256) - return E_PSI_GEN_FAIL; - mi.machineType = a.getDWord(0); + return rfsv::E_PSI_GEN_FAIL; + mi.machineType = (enum rpcs::machs)a.getDWord(0); strncpy(mi.machineName, a.getString(16), 16); mi.machineName[16] = '\0'; mi.machineUID = a.getDWord(44); mi.machineUID <<= 32; mi.machineUID |= a.getDWord(40); mi.countryCode = a.getDWord(56); - strcpy(mi.uiLanguage, languageString(a.getDWord(164))); + mi.uiLanguage = (enum rpcs::languages)a.getDWord(164); mi.romMajor = a.getByte(4); mi.romMinor = a.getByte(5); @@ -149,7 +149,7 @@ getMachineInfo(machineInfo &mi) mi.mainBatteryInsertionTime.tv_low = a.getDWord(72); mi.mainBatteryInsertionTime.tv_high = a.getDWord(76); - mi.mainBatteryStatus = a.getDWord(80); + mi.mainBatteryStatus = (enum rpcs::batterystates)a.getDWord(80); mi.mainBatteryUsedTime.tv_low = a.getDWord(84); mi.mainBatteryUsedTime.tv_high = a.getDWord(88); mi.mainBatteryCurrent = a.getDWord(92); @@ -157,7 +157,7 @@ getMachineInfo(machineInfo &mi) mi.mainBatteryVoltage = a.getDWord(100); mi.mainBatteryMaxVoltage = a.getDWord(104); - mi.backupBatteryStatus = a.getDWord(108); + mi.backupBatteryStatus = (enum rpcs::batterystates)a.getDWord(108); mi.backupBatteryVoltage = a.getDWord(112); mi.backupBatteryMaxVoltage = a.getDWord(116); mi.backupBatteryUsedTime.tv_low = a.getDWord(124); @@ -170,25 +170,25 @@ getMachineInfo(machineInfo &mi) static unsigned long hhh; -int rpcs32:: +Enum rpcs32:: configOpen(void) { bufferStore a; - int res; + Enum res; if (!sendCommand(rpcs::CONFIG_OPEN, a)) - return rpcs::E_PSI_FILE_DISC; + return rfsv::E_PSI_FILE_DISC; res = getResponse(a); cout << "co: r=" << res << " a=" << a << endl; hhh = a.getDWord(0); - return 0; + return rfsv::E_PSI_GEN_NONE; } -int rpcs32:: +Enum rpcs32:: configRead(void) { bufferStore a; - int res; + Enum res; int l; FILE *f; @@ -197,8 +197,8 @@ configRead(void) a.init(); a.addDWord(hhh); if (!sendCommand(rpcs::CONFIG_READ, a)) - return rpcs::E_PSI_FILE_DISC; - if ((res = getResponse(a))) + return rfsv::E_PSI_FILE_DISC; + if ((res = getResponse(a)) != rfsv::E_PSI_GEN_NONE) return res; l = a.getLen(); cout << "cr: " << l << endl; @@ -206,5 +206,5 @@ configRead(void) } while (l > 0); fclose(f); //cout << "cr: r=" << res << " a=" << a << endl; - return 0; + return rfsv::E_PSI_GEN_NONE; } -- cgit v1.2.3