From 1d9b2e0e156f9a58bd642b9f9e8b2a08e768f5ed Mon Sep 17 00:00:00 2001 From: Fritz Elfert Date: Wed, 20 Mar 2002 02:18:51 +0000 Subject: - rpcs: Implemented scratch RAM access. - Updated spec file (not complete) - Updated KDE translations - kioslave and property-dialog now translate correctly - ppsocket: Added a patch for FreeBSD - plpftp: Some experimental code for testing --- lib/rpcs32.cc | 72 +++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 55 insertions(+), 17 deletions(-) (limited to 'lib/rpcs32.cc') diff --git a/lib/rpcs32.cc b/lib/rpcs32.cc index 64ac5b4..b1cbe49 100644 --- a/lib/rpcs32.cc +++ b/lib/rpcs32.cc @@ -169,45 +169,83 @@ regReadIter(u_int16_t handle) } Enum rpcs32:: -configOpen(void) +configOpen(u_int16_t &handle, u_int32_t size) { bufferStore a; Enum res; + a.addDWord(size); if (!sendCommand(rpcs::CONFIG_OPEN, a)) return rfsv::E_PSI_FILE_DISC; res = getResponse(a, true); - cout << "co: r=" << res << " a=" << a << endl; - if (a.getLen() > 0) - hhh = a.getDWord(0); - return rfsv::E_PSI_GEN_NONE; + if (res == rfsv::E_PSI_GEN_NONE && (a.getLen() >= 2)) + handle = a.getWord(0); + return res; } Enum rpcs32:: -configRead(void) +configRead(u_int32_t size, bufferStore &ret) { bufferStore a; + u_int16_t handle; Enum res; - int l; - FILE *f; - f = fopen("blah", "w"); + ret.init(); + if ((res = configOpen(handle, size)) != rfsv::E_PSI_GEN_NONE) + return res; do { a.init(); - a.addDWord(hhh); + a.addWord(handle); + a.addDWord(2047); if (!sendCommand(rpcs::CONFIG_READ, a)) return rfsv::E_PSI_FILE_DISC; - if ((res = getResponse(a, true)) != rfsv::E_PSI_GEN_NONE) + if ((res = getResponse(a, true)) != rfsv::E_PSI_GEN_NONE) { + closeHandle(handle); + return res; + } + if (a.getLen() > 0) + ret.addBuff(a); + } while (a.getLen() > 0); + return rfsv::E_PSI_GEN_NONE; +} + +Enum rpcs32:: +configWrite(bufferStore data) +{ + bufferStore a; + u_int16_t handle; + Enum res; + + return rfsv::E_PSI_GEN_NONE; + if ((res = configOpen(handle, data.getLen())) != rfsv::E_PSI_GEN_NONE) + return res; + do { + a.init(); + long l = (data.getLen() > 2047) ? 2047 : data.getLen(); + a.addWord(handle); + a.addBuff(data, l); + data.discardFirstBytes(l); + if (!sendCommand(rpcs::CONFIG_WRITE, a)) + return rfsv::E_PSI_FILE_DISC; + if ((res = getResponse(a, true)) != rfsv::E_PSI_GEN_NONE) { + closeHandle(handle); return res; - l = a.getLen(); - cout << "cr: " << l << endl; - fwrite(a.getString(0), 1, l, f); - } while (l > 0); - fclose(f); -//cout << "cr: r=" << res << " a=" << a << endl; + } + } while (data.getLen() > 0); return rfsv::E_PSI_GEN_NONE; } +Enum rpcs32:: +closeHandle(u_int16_t handle) +{ + bufferStore a; + + a.addWord(handle); + if (!sendCommand(rpcs::CLOSE_HANDLE, a)) + return rfsv::E_PSI_FILE_DISC; + return getResponse(a, true); +} + /* * Local variables: * c-basic-offset: 4 -- cgit v1.2.3