aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am2
-rw-r--r--configure.in2
-rw-r--r--lib/Makefile.am4
-rw-r--r--lib/rfsv.cc230
-rw-r--r--lib/rfsv.h81
-rw-r--r--lib/rfsv16.cc236
-rw-r--r--lib/rfsv16.h51
-rw-r--r--lib/rfsv32.cc141
-rw-r--r--lib/rfsv32.h51
-rw-r--r--lib/rpcs.cc183
-rw-r--r--lib/rpcs.h282
-rw-r--r--lib/rpcs16.cc14
-rw-r--r--lib/rpcs16.h4
-rw-r--r--lib/rpcs32.cc52
-rw-r--r--lib/rpcs32.h36
-rw-r--r--plpftp/ftp.cc101
-rw-r--r--plpftp/ftp.h4
17 files changed, 683 insertions, 791 deletions
diff --git a/Makefile.am b/Makefile.am
index a62e5bf..def9a41 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -14,4 +14,4 @@ maintainer-clean-local:
install-sh ltconfig ltmain.sh missing mkinstalldirs
kdoc:
- kdoc -d doc/api -n libplp -P lib/*.h
+ kdoc -d doc/api -n libplp lib/*.h
diff --git a/configure.in b/configure.in
index 6d4b5fe..d042094 100644
--- a/configure.in
+++ b/configure.in
@@ -142,6 +142,8 @@ AC_OUTPUT(
ncpd/Makefile
plpftp/Makefile
plpnfsd/Makefile
+ doc/Makefile
+ doc/api/Makefile
include/config.h
etc/psion
)
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 33d50b8..404814e 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -5,10 +5,10 @@ lib_LTLIBRARIES = libplp.la
libplp_la_LDFLAGS = --debug -version-info 1:1:0
libplp_la_SOURCES = bufferarray.cc bufferstore.cc iowatch.cc ppsocket.cc \
rfsv16.cc rfsv32.cc rfsvfactory.cc log.cc rfsv.cc rpcs32.cc rpcs16.cc \
- rpcs.cc rpcsfactory.cc psitime.cc
+ rpcs.cc rpcsfactory.cc psitime.cc Enum.cc
EXTRA_DIST = bool.h bufferarray.h bufferstore.h iowatch.h ppsocket.h \
rfsv.h rfsv16.h rfsv32.h rfsvfactory.h log.h rpcs32.h rpcs16.h rpcs.h \
- rpcsfactory.h psitime.h
+ rpcsfactory.h psitime.h Enum.h
maintainer-clean-local:
rm -f Makefile.in
diff --git a/lib/rfsv.cc b/lib/rfsv.cc
index 3b9dc6a..0b7fd42 100644
--- a/lib/rfsv.cc
+++ b/lib/rfsv.cc
@@ -1,158 +1,80 @@
#include "rfsv.h"
+#include "Enum.h"
-char *rfsv::
-opErr(long status)
-{
- enum errs e = (enum errs) status;
- switch (e) {
- case E_PSI_GEN_NONE:
- return "no error";
- case E_PSI_GEN_FAIL:
- return "general";
- case E_PSI_GEN_ARG:
- return "bad argument";
- case E_PSI_GEN_OS:
- return "OS error";
- case E_PSI_GEN_NSUP:
- return "not supported";
- case E_PSI_GEN_UNDER:
- return "numeric underflow";
- case E_PSI_GEN_OVER:
- return "numeric overflow";
- case E_PSI_GEN_RANGE:
- return "numeric exception";
- case E_PSI_GEN_INUSE:
- return "in use";
- case E_PSI_GEN_NOMEMORY:
- return "out of memory";
- case E_PSI_GEN_NOSEGMENTS:
- return "out of segments";
- case E_PSI_GEN_NOSEM:
- return "out of semaphores";
- case E_PSI_GEN_NOPROC:
- return "out of processes";
- case E_PSI_GEN_OPEN:
- return "already open";
- case E_PSI_GEN_NOTOPEN:
- return "not open";
- case E_PSI_GEN_IMAGE:
- return "bad image";
- case E_PSI_GEN_RECEIVER:
- return "receiver error";
- case E_PSI_GEN_DEVICE:
- return "device error";
- case E_PSI_GEN_FSYS:
- return "no filesystem";
- case E_PSI_GEN_START:
- return "not ready";
- case E_PSI_GEN_NOFONT:
- return "no font";
- case E_PSI_GEN_TOOWIDE:
- return "too wide";
- case E_PSI_GEN_TOOMANY:
- return "too many";
- case E_PSI_FILE_EXIST:
- return "file already exists";
- case E_PSI_FILE_NXIST:
- return "no such file";
- case E_PSI_FILE_WRITE:
- return "write error";
- case E_PSI_FILE_READ:
- return "read error";
- case E_PSI_FILE_EOF:
- return "end of file";
- case E_PSI_FILE_FULL:
- return "disk/serial read buffer full";
- case E_PSI_FILE_NAME:
- return "invalid name";
- case E_PSI_FILE_ACCESS:
- return "access denied";
- case E_PSI_FILE_LOCKED:
- return "ressource locked";
- case E_PSI_FILE_DEVICE:
- return "no such device";
- case E_PSI_FILE_DIR:
- return "no such directory";
- case E_PSI_FILE_RECORD:
- return "no such record";
- case E_PSI_FILE_RDONLY:
- return "file is read-only";
- case E_PSI_FILE_INV:
- return "invalid I/O operation";
- case E_PSI_FILE_PENDING:
- return "I/O pending (not yet completed)";
- case E_PSI_FILE_VOLUME:
- return "invalid volume name";
- case E_PSI_FILE_CANCEL:
- return "cancelled";
- case E_PSI_FILE_ALLOC:
- return "no memory for control block";
- case E_PSI_FILE_DISC:
- return "unit disconnected";
- case E_PSI_FILE_CONNECT:
- return "already connected";
- case E_PSI_FILE_RETRAN:
- return "retransmission threshold exceeded";
- case E_PSI_FILE_LINE:
- return "physical link failure";
- case E_PSI_FILE_INACT:
- return "inactivity timer expired";
- case E_PSI_FILE_PARITY:
- return "serial parity error";
- case E_PSI_FILE_FRAME:
- return "serial framing error";
- case E_PSI_FILE_OVERRUN:
- return "serial overrun error";
- case E_PSI_MDM_CONFAIL:
- return "modem cannot connect to remote modem";
- case E_PSI_MDM_BUSY:
- return "remote modem busy";
- case E_PSI_MDM_NOANS:
- return "remote modem did not answer";
- case E_PSI_MDM_BLACKLIST:
- return "number blacklisted by the modem";
- case E_PSI_FILE_NOTREADY:
- return "drive not ready";
- case E_PSI_FILE_UNKNOWN:
- return "unknown media";
- case E_PSI_FILE_DIRFULL:
- return "directory full";
- case E_PSI_FILE_PROTECT:
- return "write-protected";
- case E_PSI_FILE_CORRUPT:
- return "media corrupt";
- case E_PSI_FILE_ABORT:
- return "aborted operation";
- case E_PSI_FILE_ERASE:
- return "failed to erase flash media";
- case E_PSI_FILE_INVALID:
- return "invalid file for DBF system";
- case E_PSI_GEN_POWER:
- return "power failure";
- case E_PSI_FILE_TOOBIG:
- return "too big";
- case E_PSI_GEN_DESCR:
- return "bad descriptor";
- case E_PSI_GEN_LIB:
- return "bad entry point";
- case E_PSI_FILE_NDISC:
- return "could not diconnect";
- case E_PSI_FILE_DRIVER:
- return "bad driver";
- case E_PSI_FILE_COMPLETION:
- return "operation not completed";
- case E_PSI_GEN_BUSY:
- return "server busy";
- case E_PSI_GEN_TERMINATED:
- return "terminated";
- case E_PSI_GEN_DIED:
- return "died";
- case E_PSI_FILE_HANDLE:
- return "bad handle";
- case E_PSI_NOT_SIBO:
- return "invalid operation for RFSV16";
- default:
- return "Unknown error";
- }
+ENUM_DEFINITION(rfsv::errs, rfsv::E_PSI_GEN_NONE) {
+ stringRep.add(rfsv::E_PSI_GEN_NONE, "no error");
+ stringRep.add(rfsv::E_PSI_GEN_FAIL, "general");
+ stringRep.add(rfsv::E_PSI_GEN_ARG, "bad argument");
+ stringRep.add(rfsv::E_PSI_GEN_OS, "OS error");
+ stringRep.add(rfsv::E_PSI_GEN_NSUP, "not supported");
+ stringRep.add(rfsv::E_PSI_GEN_UNDER, "numeric underflow");
+ stringRep.add(rfsv::E_PSI_GEN_OVER, "numeric overflow");
+ stringRep.add(rfsv::E_PSI_GEN_RANGE, "numeric exception");
+ stringRep.add(rfsv::E_PSI_GEN_INUSE, "in use");
+ stringRep.add(rfsv::E_PSI_GEN_NOMEMORY, "out of memory");
+ stringRep.add(rfsv::E_PSI_GEN_NOSEGMENTS, "out of segments");
+ stringRep.add(rfsv::E_PSI_GEN_NOSEM, "out of semaphores");
+ stringRep.add(rfsv::E_PSI_GEN_NOPROC, "out of processes");
+ stringRep.add(rfsv::E_PSI_GEN_OPEN, "already open");
+ stringRep.add(rfsv::E_PSI_GEN_NOTOPEN, "not open");
+ stringRep.add(rfsv::E_PSI_GEN_IMAGE, "bad image");
+ stringRep.add(rfsv::E_PSI_GEN_RECEIVER, "receiver error");
+ stringRep.add(rfsv::E_PSI_GEN_DEVICE, "device error");
+ stringRep.add(rfsv::E_PSI_GEN_FSYS, "no filesystem");
+ stringRep.add(rfsv::E_PSI_GEN_START, "not ready");
+ stringRep.add(rfsv::E_PSI_GEN_NOFONT, "no font");
+ stringRep.add(rfsv::E_PSI_GEN_TOOWIDE, "too wide");
+ stringRep.add(rfsv::E_PSI_GEN_TOOMANY, "too many");
+ stringRep.add(rfsv::E_PSI_FILE_EXIST, "file already exists");
+ stringRep.add(rfsv::E_PSI_FILE_NXIST, "no such file");
+ stringRep.add(rfsv::E_PSI_FILE_WRITE, "write error");
+ stringRep.add(rfsv::E_PSI_FILE_READ, "read error");
+ stringRep.add(rfsv::E_PSI_FILE_EOF, "end of file");
+ stringRep.add(rfsv::E_PSI_FILE_FULL, "disk/serial read buffer full");
+ stringRep.add(rfsv::E_PSI_FILE_NAME, "invalid name");
+ stringRep.add(rfsv::E_PSI_FILE_ACCESS, "access denied");
+ stringRep.add(rfsv::E_PSI_FILE_LOCKED, "ressource locked");
+ stringRep.add(rfsv::E_PSI_FILE_DEVICE, "no such device");
+ stringRep.add(rfsv::E_PSI_FILE_DIR, "no such directory");
+ stringRep.add(rfsv::E_PSI_FILE_RECORD, "no such record");
+ stringRep.add(rfsv::E_PSI_FILE_RDONLY, "file is read-only");
+ stringRep.add(rfsv::E_PSI_FILE_INV, "invalid I/O operation");
+ stringRep.add(rfsv::E_PSI_FILE_PENDING, "I/O pending (not yet completed)");
+ stringRep.add(rfsv::E_PSI_FILE_VOLUME, "invalid volume name");
+ stringRep.add(rfsv::E_PSI_FILE_CANCEL, "cancelled");
+ stringRep.add(rfsv::E_PSI_FILE_ALLOC, "no memory for control block");
+ stringRep.add(rfsv::E_PSI_FILE_DISC, "unit disconnected");
+ stringRep.add(rfsv::E_PSI_FILE_CONNECT, "already connected");
+ stringRep.add(rfsv::E_PSI_FILE_RETRAN, "retransmission threshold exceeded");
+ stringRep.add(rfsv::E_PSI_FILE_LINE, "physical link failure");
+ stringRep.add(rfsv::E_PSI_FILE_INACT, "inactivity timer expired");
+ stringRep.add(rfsv::E_PSI_FILE_PARITY, "serial parity error");
+ stringRep.add(rfsv::E_PSI_FILE_FRAME, "serial framing error");
+ stringRep.add(rfsv::E_PSI_FILE_OVERRUN, "serial overrun error");
+ stringRep.add(rfsv::E_PSI_MDM_CONFAIL, "modem cannot connect to remote modem");
+ stringRep.add(rfsv::E_PSI_MDM_BUSY, "remote modem busy");
+ stringRep.add(rfsv::E_PSI_MDM_NOANS, "remote modem did not answer");
+ stringRep.add(rfsv::E_PSI_MDM_BLACKLIST, "number blacklisted by the modem");
+ stringRep.add(rfsv::E_PSI_FILE_NOTREADY, "drive not ready");
+ stringRep.add(rfsv::E_PSI_FILE_UNKNOWN, "unknown media");
+ stringRep.add(rfsv::E_PSI_FILE_DIRFULL, "directory full");
+ stringRep.add(rfsv::E_PSI_FILE_PROTECT, "write-protected");
+ stringRep.add(rfsv::E_PSI_FILE_CORRUPT, "media corrupt");
+ stringRep.add(rfsv::E_PSI_FILE_ABORT, "aborted operation");
+ stringRep.add(rfsv::E_PSI_FILE_ERASE, "failed to erase flash media");
+ stringRep.add(rfsv::E_PSI_FILE_INVALID, "invalid file for DBF system");
+ stringRep.add(rfsv::E_PSI_GEN_POWER, "power failure");
+ stringRep.add(rfsv::E_PSI_FILE_TOOBIG, "too big");
+ stringRep.add(rfsv::E_PSI_GEN_DESCR, "bad descriptor");
+ stringRep.add(rfsv::E_PSI_GEN_LIB, "bad entry point");
+ stringRep.add(rfsv::E_PSI_FILE_NDISC, "could not diconnect");
+ stringRep.add(rfsv::E_PSI_FILE_DRIVER, "bad driver");
+ stringRep.add(rfsv::E_PSI_FILE_COMPLETION, "operation not completed");
+ stringRep.add(rfsv::E_PSI_GEN_BUSY, "server busy");
+ stringRep.add(rfsv::E_PSI_GEN_TERMINATED, "terminated");
+ stringRep.add(rfsv::E_PSI_GEN_DIED, "died");
+ stringRep.add(rfsv::E_PSI_FILE_HANDLE, "bad handle");
+ stringRep.add(rfsv::E_PSI_NOT_SIBO, "invalid operation for RFSV16");
+ stringRep.add(rfsv::E_PSI_INTERNAL, "libplp internal error");
}
diff --git a/lib/rfsv.h b/lib/rfsv.h
index a74fd0c..3aa9f70 100644
--- a/lib/rfsv.h
+++ b/lib/rfsv.h
@@ -1,6 +1,8 @@
#ifndef _rfsv_h_
#define _rfsv_h_
+#include "Enum.h"
+
class ppsocket;
class bufferStore;
class bufferArray;
@@ -30,44 +32,6 @@ typedef int (*cpCallback_t)(long);
*/
class rfsv {
public:
- virtual ~rfsv() {}
- virtual void reset() = 0;
- virtual void reconnect() = 0;
- virtual long getStatus() = 0;
- virtual const char *getConnectName() = 0;
- virtual long fopen(long, const char *, long &) = 0;
- virtual long mktemp(long *, char *) = 0;
- virtual long fcreatefile(long, const char *, long &) = 0;
- virtual long freplacefile(long, const char *, long &) = 0;
- virtual long fopendir(long, const char *, long &) = 0;
- virtual long fclose(long) = 0;
- virtual long dir(const char *, bufferArray *) = 0;
- virtual long fgetmtime(const char *, long *) = 0;
- virtual long fsetmtime(const char *, long) = 0;
- virtual long fgetattr(const char *, long *) = 0;
- virtual long fgeteattr(const char *, long *, long *, long *) =0;
- virtual long fsetattr(const char *, long, long) = 0;
- virtual long dircount(const char *, long *) = 0;
- virtual long devlist(long *) = 0;
- virtual char *devinfo(int, long *, long *, long *, long *) = 0;
- virtual char *opAttr(long) = 0;
- virtual long opMode(long) = 0;
- virtual long fread(long, unsigned char *, long) = 0;
- virtual long fwrite(long, unsigned char *, long) = 0;
- virtual long copyFromPsion(const char *, const char *, cpCallback_t) = 0;
- virtual long copyToPsion(const char *, const char *, cpCallback_t) = 0;
- virtual long fsetsize(long, long) = 0;
- virtual long fseek(long, long, long) = 0;
- virtual long mkdir(const char *) = 0;
- virtual long rmdir(const char *) = 0;
- virtual long rename(const char *, const char *) = 0;
- virtual long remove(const char *) = 0;
-
- virtual long attr2std(long) = 0;
- virtual long std2attr(long) = 0;
-
- char *opErr(long);
-
/**
* The kown modes for seek.
*/
@@ -175,7 +139,9 @@ class rfsv {
E_PSI_FILE_HANDLE = -110,
// Special error code for "Operation not permitted in RFSV16"
- E_PSI_NOT_SIBO = -200
+ E_PSI_NOT_SIBO = -200,
+ // Special error code for "internal library error"
+ E_PSI_INTERNAL = -201
};
/**
@@ -207,6 +173,43 @@ class rfsv {
PSI_A_STREAM = 0x0800,
PSI_A_TEXT = 0x1000
};
+ virtual ~rfsv() {}
+ virtual void reset() = 0;
+ virtual void reconnect() = 0;
+ virtual Enum<errs> getStatus() = 0;
+ virtual const char *getConnectName() = 0;
+ virtual Enum<errs> fopen(long, const char *, long &) = 0;
+ virtual Enum<errs> mktemp(long *, char *) = 0;
+ virtual Enum<errs> fcreatefile(long, const char *, long &) = 0;
+ virtual Enum<errs> freplacefile(long, const char *, long &) = 0;
+ virtual Enum<errs> fopendir(long, const char *, long &) = 0;
+ virtual Enum<errs> fclose(long) = 0;
+ virtual Enum<errs> dir(const char *, bufferArray *) = 0;
+ virtual Enum<errs> fgetmtime(const char *, long *) = 0;
+ virtual Enum<errs> fsetmtime(const char *, long) = 0;
+ virtual Enum<errs> fgetattr(const char *, long *) = 0;
+ virtual Enum<errs> fgeteattr(const char *, long *, long *, long *) =0;
+ virtual Enum<errs> fsetattr(const char *, long, long) = 0;
+ virtual Enum<errs> dircount(const char *, long *) = 0;
+ virtual Enum<errs> devlist(long *) = 0;
+ virtual char *devinfo(int, long *, long *, long *, long *) = 0;
+ virtual char *opAttr(long) = 0;
+ virtual long opMode(long) = 0;
+ virtual long fread(long, unsigned char *, long) = 0;
+ virtual long fwrite(long, unsigned char *, long) = 0;
+ virtual Enum<errs> copyFromPsion(const char *, const char *, cpCallback_t) = 0;
+ virtual Enum<errs> copyToPsion(const char *, const char *, cpCallback_t) = 0;
+ virtual Enum<errs> fsetsize(long, long) = 0;
+ virtual long fseek(long, long, long) = 0;
+ virtual Enum<errs> mkdir(const char *) = 0;
+ virtual Enum<errs> rmdir(const char *) = 0;
+ virtual Enum<errs> rename(const char *, const char *) = 0;
+ virtual Enum<errs> remove(const char *) = 0;
+
+ virtual long attr2std(long) = 0;
+ virtual long std2attr(long) = 0;
+
+ char *opErr(long);
};
#endif
diff --git a/lib/rfsv16.cc b/lib/rfsv16.cc
index de57bdf..bd30039 100644
--- a/lib/rfsv16.cc
+++ b/lib/rfsv16.cc
@@ -32,7 +32,7 @@
#include <fstream.h>
#include <iomanip.h>
#include <time.h>
-#include <string.h>
+#include <string>
#include "bool.h"
#include "rfsv16.h"
@@ -84,7 +84,7 @@ reset()
}
// move to base class?
-long rfsv16::
+Enum<rfsv::errs> rfsv16::
getStatus()
{
return status;
@@ -97,7 +97,7 @@ getConnectName()
return "SYS$RFSV";
}
-int rfsv16::
+Enum<rfsv::errs> rfsv16::
convertName(const char* orig, char *retVal)
{
int len = strlen(orig);
@@ -130,16 +130,16 @@ convertName(const char* orig, char *retVal)
delete [] temp;
cout << retVal << endl;
- return 0;
+ return E_PSI_GEN_NONE;
}
-long rfsv16::
+Enum<rfsv::errs> rfsv16::
fopen(long attr, const char *name, long &handle)
{
bufferStore a;
char realName[200];
- int rv = convertName(name, realName);
- if (rv) return (long)rv;
+ Enum<rfsv::errs> rv = convertName(name, realName);
+ if (rv) return rv;
// FIXME: anything that calls fopen should NOT do the name
// conversion - it's just done here.
@@ -150,16 +150,16 @@ fopen(long attr, const char *name, long &handle)
if (!sendCommand(FOPEN, a))
return E_PSI_FILE_DISC;
- long res = getResponse(a);
+ Enum<rfsv::errs> res = getResponse(a);
if (res == 0) {
handle = (long)a.getWord(0);
- return 0;
+ return E_PSI_GEN_NONE;
}
return res;
}
// internal
-long rfsv16::
+Enum<rfsv::errs> rfsv16::
mktemp(long *handle, char *tmpname)
{
bufferStore a;
@@ -173,38 +173,38 @@ mktemp(long *handle, char *tmpname)
if (!sendCommand(OPENUNIQUE, a))
return E_PSI_FILE_DISC;
- long res = getResponse(a);
- if (res == 0) {
+ Enum<rfsv::errs> res = getResponse(a);
+ if (res == E_PSI_GEN_NONE) {
*handle = a.getWord(0);
strcpy(tmpname, a.getString(2));
- return 0;
+ return res;
}
return res;
}
// internal and external
-long rfsv16::
+Enum<rfsv::errs> rfsv16::
fcreatefile(long attr, const char *name, long &handle)
{
return fopen(attr | P_FCREATE, name, handle);
}
// this is internal - not used by plpnfsd, unlike fcreatefile
-long rfsv16::
+Enum<rfsv::errs> rfsv16::
freplacefile(long attr, const char *name, long &handle)
{
return fopen(attr | P_FREPLACE, name, handle);
}
// internal
-long rfsv16::
+Enum<rfsv::errs> rfsv16::
fopendir(long attr, const char *name, long &handle)
{
cerr << "rfsv16::fopendir ***" << endl;
- return 0;
+ return E_PSI_GEN_NONE;
}
-long rfsv16::
+Enum<rfsv::errs> rfsv16::
fclose(long fileHandle)
{
bufferStore a;
@@ -214,16 +214,14 @@ fclose(long fileHandle)
return getResponse(a);
}
-long rfsv16::
+Enum<rfsv::errs> rfsv16::
dir(const char *dirName, bufferArray * files)
{
long fileHandle;
- long res;
+ Enum<rfsv::errs> res = fopen(P_FDIR, dirName, fileHandle);
- long status = fopen(P_FDIR, dirName, fileHandle);
- if (status != 0) {
- return status;
- }
+ if (res != E_PSI_GEN_NONE)
+ return res;
while (1) {
bufferStore a;
@@ -231,14 +229,15 @@ dir(const char *dirName, bufferArray * files)
if (!sendCommand(FDIRREAD, a))
return E_PSI_FILE_DISC;
res = getResponse(a);
- if (res)
+ if (res != E_PSI_GEN_NONE)
break;
a.discardFirstBytes(2); // Don't know what these mean!
while (a.getLen() > 16) {
int version = a.getWord(0);
if (version != 2) {
cerr << "dir: not version 2" << endl;
- return 1;
+ fclose(fileHandle);
+ return E_PSI_GEN_FAIL;
}
int status = a.getWord(2);
long size = a.getDWord(4);
@@ -254,8 +253,8 @@ dir(const char *dirName, bufferArray * files)
files->append(temp);
}
}
- if ((short int)res == E_PSI_FILE_EOF)
- res = 0;
+ if (res == E_PSI_FILE_EOF)
+ res = E_PSI_GEN_NONE;
fclose(fileHandle);
return res;
}
@@ -293,14 +292,14 @@ opMode(long mode)
return ret;
}
-long rfsv16::
+Enum<rfsv::errs> rfsv16::
fgetmtime(const char *name, long *mtime)
{
cerr << "rfsv16::fgetmtime" << endl;
// NB: fgetattr, fgeteattr is almost identical...
bufferStore a;
char realName[200];
- int rv = convertName(name, realName);
+ Enum<rfsv::errs> rv = convertName(name, realName);
if (rv) return rv;
a.addString(realName);
a.addByte(0x00); // needs to be null-terminated,
@@ -308,8 +307,8 @@ cerr << "rfsv16::fgetmtime" << endl;
if (!sendCommand(FINFO, a))
return E_PSI_FILE_DISC;
- long res = getResponse(a);
- if (res != 0) {
+ Enum<rfsv::errs> res = getResponse(a);
+ if (res != E_PSI_GEN_NONE) {
cerr << "fgetmtime: Error " << res << " on file " << name << endl;
return res;
}
@@ -318,10 +317,10 @@ cerr << "rfsv16::fgetmtime" << endl;
return res;
}
cerr << "fgetmtime: Unknown response (" << name << ") " << a <<endl;
- return 1;
+ return E_PSI_GEN_FAIL;
}
-long rfsv16::
+Enum<rfsv::errs> rfsv16::
fsetmtime(const char *name, long mtime)
{
cerr << "rfsv16::fsetmtime ***" << endl;
@@ -330,13 +329,13 @@ cerr << "rfsv16::fsetmtime ***" << endl;
return E_PSI_NOT_SIBO;
}
-long rfsv16::
+Enum<rfsv::errs> rfsv16::
fgetattr(const char *name, long *attr)
{
// NB: fgetmtime, fgeteattr are almost identical...
bufferStore a;
char realName[200];
- int rv = convertName(name, realName);
+ Enum<rfsv::errs> rv = convertName(name, realName);
if (rv) return rv;
a.addString(realName);
a.addByte(0x00); // needs to be null-terminated,
@@ -344,7 +343,7 @@ fgetattr(const char *name, long *attr)
if (!sendCommand(FINFO, a))
return E_PSI_FILE_DISC;
- long res = getResponse(a);
+ Enum<rfsv::errs> res = getResponse(a);
if (res != 0) {
cerr << "fgetattr: Error " << res << " on file " << name << endl;
return res;
@@ -354,15 +353,15 @@ fgetattr(const char *name, long *attr)
return res;
}
cerr << "fgetattr: Unknown response (" << name << ") " << a <<endl;
- return 1;
+ return E_PSI_GEN_FAIL;
}
-long rfsv16::
+Enum<rfsv::errs> rfsv16::
fgeteattr(const char *name, long *attr, long *size, long *time)
{
bufferStore a;
char realName[200];
- int rv = convertName(name, realName);
+ Enum<rfsv::errs> rv = convertName(name, realName);
if (rv) return rv;
a.addString(realName);
a.addByte(0x00); // needs to be null-terminated,
@@ -370,9 +369,9 @@ fgeteattr(const char *name, long *attr, long *size, long *time)
if (!sendCommand(FINFO, a))
return E_PSI_FILE_DISC;
- long res = getResponse(a);
+ Enum<rfsv::errs> res = getResponse(a);
if (res != 0) {
- cerr << "fgeteattr: Error " << a.getWord(0) << " on file " << name << endl;
+ cerr << "fgeteattr: Error " << res << " on file " << name << endl;
return res;
}
else if (a.getLen() == 16) {
@@ -382,10 +381,10 @@ fgeteattr(const char *name, long *attr, long *size, long *time)
return res;
}
cerr << "fgeteattr: Unknown response (" << name << ") " << a <<endl;
- return 1;
+ return E_PSI_GEN_FAIL;
}
-long rfsv16::
+Enum<rfsv::errs> rfsv16::
fsetattr(const char *name, long seta, long unseta)
{
cerr << "rfsv16::fsetattr" << endl;
@@ -412,17 +411,16 @@ cerr << "rfsv16::fsetattr" << endl;
return getResponse(a);
}
-long rfsv16::
+Enum<rfsv::errs> rfsv16::
dircount(const char *name, long *count)
{
long fileHandle;
- long res;
+ Enum<rfsv::errs> res;
*count = 0;
- long status = fopen(P_FDIR, name, fileHandle);
- if (status != 0) {
- return status;
- }
+ res = fopen(P_FDIR, name, fileHandle);
+ if (res != E_PSI_GEN_NONE)
+ return res;
while (1) {
bufferStore a;
@@ -430,14 +428,15 @@ dircount(const char *name, long *count)
if (!sendCommand(FDIRREAD, a))
return E_PSI_FILE_DISC;
res = getResponse(a);
- if (res)
+ if (res != E_PSI_GEN_NONE)
break;
a.discardFirstBytes(2); // Don't know what these mean!
while (a.getLen() > 16) {
int version = a.getWord(0);
if (version != 2) {
cerr << "dir: not version 2" << endl;
- return 1;
+ fclose(fileHandle);
+ return E_PSI_GEN_FAIL;
}
// int status = a.getWord(2);
// long size = a.getDWord(4);
@@ -447,16 +446,16 @@ dircount(const char *name, long *count)
(*count)++;
}
}
- if ((short int)res == E_PSI_FILE_EOF)
- res = 0;
+ if (res == E_PSI_FILE_EOF)
+ res = E_PSI_GEN_NONE;
fclose(fileHandle);
return res;
}
-long rfsv16::
+Enum<rfsv::errs> rfsv16::
devlist(long *devbits)
{
- long res;
+ Enum<rfsv::errs> res;
long fileHandle;
*devbits = 0;
@@ -473,7 +472,7 @@ devlist(long *devbits)
if (!sendCommand(PARSE, a))
return E_PSI_FILE_DISC;
res = getResponse(a);
- if (res)
+ if (res != E_PSI_GEN_NONE)
return res;
// Find the drive to FOPEN
@@ -481,10 +480,10 @@ devlist(long *devbits)
a.discardFirstBytes(6); // Result, fsys, dev, path, file, file, ending, flag
/* This leaves R E M : : M : \ */
name[0] = (char) a.getByte(5); // the M
- long status = fopen(P_FDEVICE, name, fileHandle);
- if (status != 0) {
+ res = fopen(P_FDEVICE, name, fileHandle);
+ if (res != E_PSI_GEN_NONE)
return status;
- }
+
while (1) {
bufferStore a;
a.init();
@@ -497,7 +496,8 @@ devlist(long *devbits)
int version = a.getWord(0);
if (version != 2) {
cerr << "devlist: not version 2" << endl;
- return 1; // FIXME
+ fclose(fileHandle);
+ return E_PSI_GEN_FAIL; // FIXME
}
char drive = a.getByte(64);
if (drive >= 'A' && drive <= 'Z') {
@@ -509,8 +509,8 @@ devlist(long *devbits)
<< drive << ")" << endl;
}
}
- if ((short int)res == E_PSI_FILE_EOF)
- res = 0;
+ if (res == E_PSI_FILE_EOF)
+ res = E_PSI_GEN_NONE;
fclose(fileHandle);
return res;
}
@@ -521,9 +521,9 @@ devinfo(int devnum, long *vfree, long *vtotal, long *vattr,
{
bufferStore a;
long res;
- long fileHandle;
+ // long fileHandle;
- // Again, this is taken from an excahnge between PsiWin and a 3c.
+ // Again, this is taken from an exchange between PsiWin and a 3c.
// For each drive, we PARSE with its drive letter to get a response
// (which we ignore), then do a STATUSDEVICE to get the info.
@@ -554,12 +554,12 @@ devinfo(int devnum, long *vfree, long *vtotal, long *vattr,
return NULL;
}
int type = a.getWord(2);
- int changeable = a.getWord(4);
+ // int changeable = a.getWord(4);
long size = a.getDWord(6);
long free = a.getDWord(10);
- const char *volume = a.getString(14);
- int battery = a.getWord(30);
- const char *devicename = a.getString(62);
+ // const char *volume = a.getString(14);
+ // int battery = a.getWord(30);
+ // const char *devicename = a.getString(62);
*vfree = free;
*vtotal = size;
*vattr = type;
@@ -594,7 +594,7 @@ sendCommand(enum commands cc, bufferStore & data)
}
-long rfsv16::
+Enum<rfsv::errs> rfsv16::
getResponse(bufferStore & data)
{
// getWord(2) is the size field
@@ -605,7 +605,7 @@ getResponse(bufferStore & data)
"getBufferStore failed." << endl;
} else if (data.getWord(0) == 0x2a &&
data.getWord(2) == data.getLen()-4) {
- long ret = (short)data.getWord(4);
+ Enum<errs> ret = (enum errs)data.getWord(4);
data.discardFirstBytes(6);
return ret;
} else {
@@ -614,19 +614,10 @@ getResponse(bufferStore & data)
data.getLen()-4 << " Result field:" <<
data.getWord(4) << endl;
}
-
status = E_PSI_FILE_DISC;
return status;
}
-char * rfsv16::
-opErr(long status)
-{
-cerr << "rfsv16::opErr 0x" << hex << setfill('0') << setw(4)
- << status << " (" << dec << (signed short int)status << ")" << endl;
- return rfsv::opErr(status);
-}
-
long rfsv16::
fread(long handle, unsigned char *buf, long len)
{
@@ -696,69 +687,76 @@ fwrite(long handle, unsigned char *buf, long len)
return count;
}
-long rfsv16::
+Enum<rfsv::errs> rfsv16::
copyFromPsion(const char *from, const char *to, cpCallback_t cb)
{
long handle;
- long res;
+ Enum<rfsv::errs> res;
long len;
- if ((res = fopen(P_FSHARE | P_FSTREAM, from, handle)) != 0)
+ if ((res = fopen(P_FSHARE | P_FSTREAM, from, handle)) != E_PSI_GEN_NONE)
return res;
ofstream op(to);
if (!op) {
fclose(handle);
- return -1;
+ return E_PSI_GEN_FAIL;
}
do {
unsigned char buf[RFSV_SENDLEN];
if ((len = fread(handle, buf, sizeof(buf))) > 0)
op.write(buf, len);
+ else
+ res = (enum rfsv::errs)len;
if (cb) {
if (!cb(len)) {
- len = E_PSI_FILE_CANCEL;
+ res = E_PSI_FILE_CANCEL;
break;
}
}
- } while (len > 0);
+ } while (res > 0);
fclose(handle);
op.close();
- return len == E_PSI_FILE_EOF ? 0 : len;
+ if (res == E_PSI_FILE_EOF)
+ res = E_PSI_GEN_NONE;
+ return res;
}
-long rfsv16::
+Enum<rfsv::errs> rfsv16::
copyToPsion(const char *from, const char *to, cpCallback_t cb)
{
long handle;
- long res;
+ long len = 0;
+ Enum<rfsv::errs> res;
ifstream ip(from);
if (!ip)
return E_PSI_FILE_NXIST;
res = fcreatefile(P_FSTREAM | P_FUPDATE, to, handle);
- if (res != 0) {
+ if (res != E_PSI_GEN_NONE) {
res = freplacefile(P_FSTREAM | P_FUPDATE, to, handle);
- if (res != 0)
+ if (res != E_PSI_GEN_NONE)
return res;
}
unsigned char *buff = new unsigned char[RFSV_SENDLEN];
while (res >= 0 && ip && !ip.eof()) {
ip.read(buff, RFSV_SENDLEN);
- res = fwrite(handle, buff, ip.gcount());
+ len = fwrite(handle, buff, ip.gcount());
+ if (len <= 0)
+ res = (enum rfsv::errs)len;
if (cb)
- if (!cb(res)) {
+ if (!cb(len)) {
res = E_PSI_FILE_CANCEL;
- }
- }
+ }
+ }
- delete[]buff;
+ delete[]buff;
fclose(handle);
ip.close();
- return 0;
+ return E_PSI_GEN_NONE;
}
-long rfsv16::
+Enum<rfsv::errs> rfsv16::
fsetsize(long handle, long size)
{
bufferStore a;
@@ -865,27 +863,27 @@ fseek(long handle, long pos, long mode)
return realpos;
}
-long rfsv16::
+Enum<rfsv::errs> rfsv16::
mkdir(const char* dirName)
{
char realName[200];
- int rv = convertName(dirName, realName);
- if (rv) return rv;
+ Enum<rfsv::errs> res = convertName(dirName, realName);
+ if (res != E_PSI_GEN_NONE) return res;
bufferStore a;
a.addString(realName);
a.addByte(0x00); // needs to be null-terminated,
// and this needs sending in the length word.
sendCommand(MKDIR, a);
- long res = getResponse(a);
- if (!res) {
+ res = getResponse(a);
+ if (res == E_PSI_GEN_NONE) {
// Correct response
return res;
}
cerr << "Unknown response from mkdir "<< res <<endl;
- return 1;
+ return E_PSI_GEN_FAIL;
}
-long rfsv16::
+Enum<rfsv::errs> rfsv16::
rmdir(const char *dirName)
{
// There doesn't seem to be an RMDIR command, but DELETE works. We
@@ -893,16 +891,16 @@ rmdir(const char *dirName)
return remove(dirName);
}
-long rfsv16::
+Enum<rfsv::errs> rfsv16::
rename(const char *oldName, const char *newName)
{
cerr << "rfsv16::rename ***" << endl;
char realOldName[200];
- int rv = convertName(oldName, realOldName);
- if (rv) return rv;
+ Enum<rfsv::errs> res = convertName(oldName, realOldName);
+ if (res != E_PSI_GEN_NONE) return res;
char realNewName[200];
- rv = convertName(newName, realNewName);
- if (rv) return rv;
+ res = convertName(newName, realNewName);
+ if (res != E_PSI_GEN_NONE) return res;
bufferStore a;
a.addString(realOldName);
a.addByte(0x00); // needs to be null-terminated,
@@ -911,33 +909,33 @@ cerr << "rfsv16::rename ***" << endl;
a.addByte(0x00); // needs to be null-terminated,
// and this needs sending in the length word.
sendCommand(RENAME, a);
- long res = getResponse(a);
- if (!res) {
+ res = getResponse(a);
+ if (res == E_PSI_GEN_NONE) {
// Correct response
return res;
}
cerr << "Unknown response from rename "<< res <<endl;
- return 1;
+ return E_PSI_GEN_FAIL;
}
-long rfsv16::
+Enum<rfsv::errs> rfsv16::
remove(const char* psionName)
{
char realName[200];
- int rv = convertName(psionName, realName);
- if (rv) return rv;
+ Enum<rfsv::errs> res = convertName(psionName, realName);
+ if (res != E_PSI_GEN_NONE) return res;
bufferStore a;
a.addString(realName);
a.addByte(0x00); // needs to be null-terminated,
// and this needs sending in the length word.
sendCommand(DELETE, a);
- long res = getResponse(a);
- if (!res) {
+ res = getResponse(a);
+ if (res == E_PSI_GEN_NONE) {
// Correct response
return res;
}
cerr << "Unknown response from delete "<< res <<endl;
- return 1;
+ return E_PSI_GEN_FAIL;
}
/*
diff --git a/lib/rfsv16.h b/lib/rfsv16.h
index bb6a947..08c87f5 100644
--- a/lib/rfsv16.h
+++ b/lib/rfsv16.h
@@ -11,38 +11,37 @@ class rfsv16 : public rfsv {
void reconnect();
// these are the original publics
- long dir(const char *, bufferArray *);
+ Enum<rfsv::errs> dir(const char *, bufferArray *);
/*long read(const char* psionName, const char* localName);
long write(const char* localName, const char* psionName);*/
- long mkdir(const char *);
+ Enum<rfsv::errs> mkdir(const char *);
// these are FS' promotions
- long dircount(const char *, long *);
- long copyFromPsion(const char *, const char *, cpCallback_t);
- long copyToPsion(const char *, const char *, cpCallback_t);
- long rmdir(const char *);
- long remove(const char *); // MJG: was this del? FE: yes
- long rename(const char *, const char *);
- long mktemp(long *, char *);
- long fgeteattr(const char *, long *, long *, long *);
- long fgetattr(const char *, long *);
- long fsetattr(const char *, long seta, long unseta);
- long fgetmtime(const char *, long *);
- long fsetmtime(const char *, long);
- long fopendir(long, const char *, long &);
- long fopen(long, const char *, long &);
- long fcreatefile(long, const char *, long &);
- long freplacefile(long, const char *, long &);
+ Enum<rfsv::errs> dircount(const char *, long *);
+ Enum<rfsv::errs> copyFromPsion(const char *, const char *, cpCallback_t);
+ Enum<rfsv::errs> copyToPsion(const char *, const char *, cpCallback_t);
+ Enum<rfsv::errs> rmdir(const char *);
+ Enum<rfsv::errs> remove(const char *); // MJG: was this del? FE: yes
+ Enum<rfsv::errs> rename(const char *, const char *);
+ Enum<rfsv::errs> mktemp(long *, char *);
+ Enum<rfsv::errs> fgeteattr(const char *, long *, long *, long *);
+ Enum<rfsv::errs> fgetattr(const char *, long *);
+ Enum<rfsv::errs> fsetattr(const char *, long seta, long unseta);
+ Enum<rfsv::errs> fgetmtime(const char *, long *);
+ Enum<rfsv::errs> fsetmtime(const char *, long);
+ Enum<rfsv::errs> fopendir(long, const char *, long &);
+ Enum<rfsv::errs> fopen(long, const char *, long &);
+ Enum<rfsv::errs> fcreatefile(long, const char *, long &);
+ Enum<rfsv::errs> freplacefile(long, const char *, long &);
long fseek(long, long, long);
long fread(long, unsigned char *, long);
long fwrite(long, unsigned char *, long);
- long fsetsize(long, long);
- long fclose(long);
+ Enum<rfsv::errs> fsetsize(long, long);
+ Enum<rfsv::errs> fclose(long);
- long devlist(long *);
+ Enum<rfsv::errs> devlist(long *);
char *devinfo(int, long *, long *, long *, long *);
- long getStatus();
- char *opErr(long);
+ Enum<rfsv::errs> getStatus();
char *opAttr(long);
long opMode(long);
@@ -113,17 +112,17 @@ private:
//long fclose(int fileHandle);
// Miscellaneous
- int convertName(const char*, char *);
+ Enum<rfsv::errs> convertName(const char*, char *);
// Communication
bool sendCommand(enum commands, bufferStore &);
- long getResponse(bufferStore &);
+ Enum<rfsv::errs> getResponse(bufferStore &);
// Vars
ppsocket *skt;
// MJG: not sure what these are yet
int serNum;
- long status; // current connection status
+ Enum<errs> status; // current connection status
int tDiff; // don't think this is used anywhere
};
diff --git a/lib/rfsv32.cc b/lib/rfsv32.cc
index fa4852f..99c7f06 100644
--- a/lib/rfsv32.cc
+++ b/lib/rfsv32.cc
@@ -36,7 +36,7 @@
#include "ppsocket.h"
#include "bufferarray.h"
-rfsv32::rfsv32(ppsocket * _skt) : serNum(0)
+rfsv32::rfsv32(ppsocket * _skt) : serNum(0), status(rfsv::E_PSI_FILE_DISC)
{
skt = _skt;
reset();
@@ -74,7 +74,7 @@ reset()
}
}
-long rfsv32::
+Enum<rfsv::errs> rfsv32::
getStatus()
{
return status;
@@ -96,7 +96,7 @@ convertSlash(const char *name)
return n;
}
-long rfsv32::
+Enum<rfsv::errs> rfsv32::
fopen(long attr, const char *name, long &handle)
{
bufferStore a;
@@ -107,29 +107,29 @@ fopen(long attr, const char *name, long &handle)
free(n);
if (!sendCommand(OPEN_FILE, a))
return E_PSI_FILE_DISC;
- long res = getResponse(a);
- if (!res && a.getLen() == 4) {
+ Enum<rfsv::errs> res = getResponse(a);
+ if (res == E_PSI_GEN_NONE && a.getLen() == 4) {
handle = a.getDWord(0);
- return 0;
+ return E_PSI_GEN_NONE;
}
return res;
}
-long rfsv32::
+Enum<rfsv::errs> rfsv32::
mktemp(long *handle, char *tmpname)
{
bufferStore a;
if (!sendCommand(TEMP_FILE, a))
return E_PSI_FILE_DISC;
- long res = getResponse(a);
- if (res == 0) {
+ Enum<rfsv::errs> res = getResponse(a);
+ if (res == E_PSI_GEN_NONE) {
*handle = a.getDWord(0);
strcpy(tmpname, a.getString(6));
}
return res;
}
-long rfsv32::
+Enum<rfsv::errs> rfsv32::
fcreatefile(long attr, const char *name, long &handle)
{
bufferStore a;
@@ -140,13 +140,13 @@ fcreatefile(long attr, const char *name, long &handle)
free(n);
if (!sendCommand(CREATE_FILE, a))
return E_PSI_FILE_DISC;
- long res = getResponse(a);
- if (!res && a.getLen() == 4)
+ Enum<rfsv::errs> res = getResponse(a);
+ if (res == E_PSI_GEN_NONE && a.getLen() == 4)
handle = a.getDWord(0);
return res;
}
-long rfsv32::
+Enum<rfsv::errs> rfsv32::
freplacefile(long attr, const char *name, long &handle)
{
bufferStore a;
@@ -157,13 +157,13 @@ freplacefile(long attr, const char *name, long &handle)
free(n);
if (!sendCommand(REPLACE_FILE, a))
return E_PSI_FILE_DISC;
- long res = getResponse(a);
- if (!res && a.getLen() == 4)
+ Enum<rfsv::errs> res = getResponse(a);
+ if (res == E_PSI_GEN_NONE && a.getLen() == 4)
handle = a.getDWord(0);
return res;
}
-long rfsv32::
+Enum<rfsv::errs> rfsv32::
fopendir(long attr, const char *name, long &handle)
{
bufferStore a;
@@ -174,13 +174,13 @@ fopendir(long attr, const char *name, long &handle)
free(n);
if (!sendCommand(OPEN_DIR, a))
return E_PSI_FILE_DISC;
- long res = getResponse(a);
+ Enum<rfsv::errs> res = getResponse(a);
if (!res && a.getLen() == 4)
handle = a.getDWord(0);
return res;
}
-long rfsv32::
+Enum<rfsv::errs> rfsv32::
fclose(long handle)
{
bufferStore a;
@@ -245,12 +245,12 @@ time2micro(unsigned long time, unsigned long &microHi, unsigned long &microLo)
microHi = (micro & (unsigned long long)0x0FFFFFFFF);
}
-long rfsv32::
+Enum<rfsv::errs> rfsv32::
dir(const char *name, bufferArray * files)
{
long handle;
- long res = fopendir(EPOC_ATTR_HIDDEN | EPOC_ATTR_SYSTEM | EPOC_ATTR_DIRECTORY, name, handle);
- if (res != 0)
+ Enum<rfsv::errs> res = fopendir(EPOC_ATTR_HIDDEN | EPOC_ATTR_SYSTEM | EPOC_ATTR_DIRECTORY, name, handle);
+ if (res != E_PSI_GEN_NONE)
return res;
while (1) {
@@ -259,7 +259,7 @@ dir(const char *name, bufferArray * files)
if (!sendCommand(READ_DIR, a))
return E_PSI_FILE_DISC;
res = getResponse(a);
- if (res)
+ if (res != E_PSI_GEN_NONE)
break;
while (a.getLen() > 16) {
long shortLen = a.getDWord(0);
@@ -292,7 +292,7 @@ dir(const char *name, bufferArray * files)
}
}
if (res == E_PSI_FILE_EOF)
- res = 0;
+ res = E_PSI_GEN_NONE;
fclose(handle);
return res;
}
@@ -326,7 +326,7 @@ opMode(long mode)
return ret;
}
-long rfsv32::
+Enum<rfsv::errs> rfsv32::
fgetmtime(const char *name, long *mtime)
{
bufferStore a;
@@ -336,14 +336,14 @@ fgetmtime(const char *name, long *mtime)
free(n);
if (!sendCommand(MODIFIED, a))
return E_PSI_FILE_DISC;
- long res = getResponse(a);
- if (res != 0)
+ Enum<rfsv::errs> res = getResponse(a);
+ if (res != E_PSI_GEN_NONE)
return res;
*mtime = micro2time(a.getDWord(4), a.getDWord(0));
- return 0;
+ return res;
}
-long rfsv32::
+Enum<rfsv::errs> rfsv32::
fsetmtime(const char *name, long mtime)
{
bufferStore a;
@@ -357,13 +357,10 @@ fsetmtime(const char *name, long mtime)
free(n);
if (!sendCommand(SET_MODIFIED, a))
return E_PSI_FILE_DISC;
- long res = getResponse(a);
- if (res != 0)
- return res;
- return 0;
+ return getResponse(a);
}
-long rfsv32::
+Enum<rfsv::errs> rfsv32::
fgetattr(const char *name, long *attr)
{
bufferStore a;
@@ -373,14 +370,14 @@ fgetattr(const char *name, long *attr)
free(n);
if (!sendCommand(ATT, a))
return E_PSI_FILE_DISC;
- long res = getResponse(a);
- if (res != 0)
+ Enum<rfsv::errs> res = getResponse(a);
+ if (res != E_PSI_GEN_NONE)
return res;
*attr = a.getDWord(0);
- return 0;
+ return res;
}
-long rfsv32::
+Enum<rfsv::errs> rfsv32::
fgeteattr(const char *name, long *attr, long *size, long *time)
{
bufferStore a;
@@ -390,8 +387,8 @@ fgeteattr(const char *name, long *attr, long *size, long *time)
free(n);
if (!sendCommand(REMOTE_ENTRY, a))
return E_PSI_FILE_DISC;
- long res = getResponse(a);
- if (res != 0)
+ Enum<rfsv::errs> res = getResponse(a);
+ if (res != E_PSI_GEN_NONE)
return res;
// long shortLen = a.getDWord(0);
*attr = a.getDWord(4);
@@ -403,10 +400,10 @@ fgeteattr(const char *name, long *attr, long *size, long *time)
// long uid3 = a.getDWord(28);
// long longLen = a.getDWord(32);
*time = micro2time(modHi, modLow);
- return 0;
+ return res;
}
-long rfsv32::
+Enum<rfsv::errs> rfsv32::
fsetattr(const char *name, long seta, long unseta)
{
bufferStore a;
@@ -421,13 +418,13 @@ fsetattr(const char *name, long seta, long unseta)
return getResponse(a);
}
-long rfsv32::
+Enum<rfsv::errs> rfsv32::
dircount(const char *name, long *count)
{
long handle;
- long res = fopendir(EPOC_ATTR_HIDDEN | EPOC_ATTR_SYSTEM | EPOC_ATTR_DIRECTORY, name, handle);
+ Enum<rfsv::errs> res = fopendir(EPOC_ATTR_HIDDEN | EPOC_ATTR_SYSTEM | EPOC_ATTR_DIRECTORY, name, handle);
*count = 0;
- if (res != 0)
+ if (res != E_PSI_GEN_NONE)
return res;
while (1) {
@@ -436,7 +433,7 @@ dircount(const char *name, long *count)
if (!sendCommand(READ_DIR, a))
return E_PSI_FILE_DISC;
res = getResponse(a);
- if (res)
+ if (res != E_PSI_GEN_NONE)
break;
while (a.getLen() > 16) {
int d = 36 + a.getDWord(32);
@@ -451,21 +448,21 @@ dircount(const char *name, long *count)
}
fclose(handle);
if (res == E_PSI_FILE_EOF)
- res = 0;
+ res = E_PSI_GEN_NONE;
return res;
}
-long rfsv32::
+Enum<rfsv::errs> rfsv32::
devlist(long *devbits)
{
bufferStore a;
- long res;
+ Enum<rfsv::errs> res;
if (!sendCommand(GET_DRIVE_LIST, a))
return E_PSI_FILE_DISC;
res = getResponse(a);
*devbits = 0;
- if ((res == 0) && (a.getLen() == 26)) {
+ if ((res == E_PSI_GEN_NONE) && (a.getLen() == 26)) {
for (int i = 25; i >= 0; i--) {
*devbits <<= 1;
if (a.getByte(i) != 0)
@@ -525,7 +522,7 @@ sendCommand(enum commands cc, bufferStore & data)
return result;
}
-long rfsv32::
+Enum<rfsv::errs> rfsv32::
getResponse(bufferStore & data)
{
if (skt->getBufferStore(data) == 1 &&
@@ -585,50 +582,52 @@ fwrite(long handle, unsigned char *buf, long len)
return total;
}
-long rfsv32::
+Enum<rfsv::errs> rfsv32::
copyFromPsion(const char *from, const char *to, cpCallback_t cb)
{
long handle;
- long res;
+ Enum<rfsv::errs> res;
long len;
- if ((res = fopen(EPOC_OMODE_SHARE_READERS | EPOC_OMODE_BINARY, from, handle)) != 0)
+ if ((res = fopen(EPOC_OMODE_SHARE_READERS | EPOC_OMODE_BINARY, from, handle)) != E_PSI_GEN_NONE)
return res;
ofstream op(to);
if (!op) {
fclose(handle);
- return -1;
+ return E_PSI_GEN_FAIL;
}
unsigned char *buff = new unsigned char[RFSV_SENDLEN];
do {
if ((len = fread(handle, buff, RFSV_SENDLEN)) > 0)
op.write(buff, len);
+ else
+ res = (enum rfsv::errs)len;
if (cb) {
if (!cb(len)) {
- len = E_PSI_FILE_CANCEL;
+ res = E_PSI_FILE_CANCEL;
break;
}
}
- } while (len > 0);
+ } while ((len > 0) && (res == E_PSI_GEN_NONE));
delete[]buff;
fclose(handle);
op.close();
- return len;
+ return res;
}
-long rfsv32::
+Enum<rfsv::errs> rfsv32::
copyToPsion(const char *from, const char *to, cpCallback_t cb)
{
long handle;
- long res;
+ Enum<rfsv::errs> res;
ifstream ip(from);
if (!ip)
return E_PSI_FILE_NXIST;
res = fcreatefile(EPOC_OMODE_BINARY | EPOC_OMODE_SHARE_EXCLUSIVE | EPOC_OMODE_READ_WRITE, to, handle);
- if (res != 0) {
+ if (res != E_PSI_GEN_NONE) {
res = freplacefile(EPOC_OMODE_BINARY | EPOC_OMODE_SHARE_EXCLUSIVE | EPOC_OMODE_READ_WRITE, to, handle);
- if (res != 0)
+ if (res != E_PSI_GEN_NONE)
return res;
}
unsigned char *buff = new unsigned char[RFSV_SENDLEN];
@@ -649,7 +648,7 @@ copyToPsion(const char *from, const char *to, cpCallback_t cb)
return E_PSI_FILE_DISC;
}
res = getResponse(a);
- if (res) {
+ if (res != E_PSI_GEN_NONE) {
fclose(handle);
ip.close();
delete[]buff;
@@ -667,10 +666,10 @@ copyToPsion(const char *from, const char *to, cpCallback_t cb)
fclose(handle);
ip.close();
delete[]buff;
- return 0;
+ return E_PSI_GEN_NONE;
}
-long rfsv32::
+Enum<rfsv::errs> rfsv32::
fsetsize(long handle, long size)
{
bufferStore a;
@@ -789,7 +788,7 @@ fseek(long handle, long pos, long mode)
return realpos;
}
-long rfsv32::
+Enum<rfsv::errs> rfsv32::
mkdir(const char *name)
{
bufferStore a;
@@ -808,7 +807,7 @@ mkdir(const char *name)
return getResponse(a);
}
-long rfsv32::
+Enum<rfsv::errs> rfsv32::
rmdir(const char *name)
{
bufferStore a;
@@ -827,7 +826,7 @@ rmdir(const char *name)
return getResponse(a);
}
-long rfsv32::
+Enum<rfsv::errs> rfsv32::
rename(const char *oldname, const char *newname)
{
bufferStore a;
@@ -844,7 +843,7 @@ rename(const char *oldname, const char *newname)
return getResponse(a);
}
-long rfsv32::
+Enum<rfsv::errs> rfsv32::
remove(const char *name)
{
bufferStore a;
@@ -857,7 +856,7 @@ remove(const char *name)
return getResponse(a);
}
-static long e2psi[] = {
+static enum rfsv::errs e2psi[] = {
rfsv::E_PSI_FILE_DIRFULL, // -43
rfsv::E_PSI_GEN_POWER, // -42
rfsv::E_PSI_GEN_DIVIDE, // -41
@@ -904,12 +903,12 @@ static long e2psi[] = {
rfsv::E_PSI_GEN_NONE // 0
};
-long rfsv32::
+Enum<rfsv::errs> rfsv32::
err2psierr(long status)
{
if ((status > E_EPOC_NONE) || (status < E_EPOC_DIR_FULL)) {
cerr << "FATAL: inavlid error-code" << endl;
- return -999;
+ return E_PSI_INTERNAL;
}
return e2psi[status - E_EPOC_DIR_FULL];
}
diff --git a/lib/rfsv32.h b/lib/rfsv32.h
index 2aac5b9..af59af6 100644
--- a/lib/rfsv32.h
+++ b/lib/rfsv32.h
@@ -14,33 +14,33 @@ class rfsv32 : public rfsv {
void reset();
void reconnect();
- long dir(const char *, bufferArray *);
- long dircount(const char *, long *);
- long copyFromPsion(const char *, const char *, cpCallback_t);
- long copyToPsion(const char *, const char *, cpCallback_t);
- long mkdir(const char *);
- long rmdir(const char *);
- long remove(const char *);
- long rename(const char *, const char *);
- long mktemp(long *, char *);
- long fgeteattr(const char *, long *, long *, long *);
- long fgetattr(const char *, long *);
- long fsetattr(const char *, long, long);
- long fgetmtime(const char *, long *);
- long fsetmtime(const char *, long);
- long fopendir(long, const char *, long &);
- long fopen(long, const char *, long &);
- long fcreatefile(long, const char *, long &);
- long freplacefile(long, const char *, long &);
+ Enum<rfsv::errs> dir(const char *, bufferArray *);
+ Enum<rfsv::errs> dircount(const char *, long *);
+ Enum<rfsv::errs> copyFromPsion(const char *, const char *, cpCallback_t);
+ Enum<rfsv::errs> copyToPsion(const char *, const char *, cpCallback_t);
+ Enum<rfsv::errs> mkdir(const char *);
+ Enum<rfsv::errs> rmdir(const char *);
+ Enum<rfsv::errs> remove(const char *);
+ Enum<rfsv::errs> rename(const char *, const char *);
+ Enum<rfsv::errs> mktemp(long *, char *);
+ Enum<rfsv::errs> fgeteattr(const char *, long *, long *, long *);
+ Enum<rfsv::errs> fgetattr(const char *, long *);
+ Enum<rfsv::errs> fsetattr(const char *, long, long);
+ Enum<rfsv::errs> fgetmtime(const char *, long *);
+ Enum<rfsv::errs> fsetmtime(const char *, long);
+ Enum<rfsv::errs> fopendir(long, const char *, long &);
+ Enum<rfsv::errs> fopen(long, const char *, long &);
+ Enum<rfsv::errs> fcreatefile(long, const char *, long &);
+ Enum<rfsv::errs> freplacefile(long, const char *, long &);
long fseek(long, long, long);
long fread(long, unsigned char *, long);
long fwrite(long, unsigned char *, long);
- long fsetsize(long, long);
- long fclose(long);
+ Enum<rfsv::errs> fsetsize(long, long);
+ Enum<rfsv::errs> fclose(long);
- long devlist(long *);
+ Enum<rfsv::errs> devlist(long *);
char *devinfo(int, long *, long *, long *, long *);
- long getStatus();
+ Enum<rfsv::errs> getStatus();
char *opAttr(long);
long opMode(long);
@@ -155,11 +155,11 @@ class rfsv32 : public rfsv {
};
const char *getConnectName();
- long err2psierr(long);
+ Enum<rfsv::errs> err2psierr(long);
// Communication
bool sendCommand(enum commands, bufferStore &);
- long getResponse(bufferStore &);
+ Enum<rfsv::errs> getResponse(bufferStore &);
char *convertSlash(const char *);
// time-conversion
@@ -169,8 +169,7 @@ class rfsv32 : public rfsv {
// Vars
ppsocket *skt;
int serNum;
- long status;
- int tDiff;
+ Enum<rfsv::errs> status;
};
#endif
diff --git a/lib/rpcs.cc b/lib/rpcs.cc
index cdbbabd..a4a19ab 100644
--- a/lib/rpcs.cc
+++ b/lib/rpcs.cc
@@ -30,16 +30,60 @@
#include "bufferstore.h"
#include "ppsocket.h"
#include "bufferarray.h"
+#include "Enum.h"
+
+ENUM_DEFINITION(rpcs::machs, rpcs::PSI_MACH_UNKNOWN) {
+ stringRep.add(rpcs::PSI_MACH_UNKNOWN, "Unknown device");
+ stringRep.add(rpcs::PSI_MACH_PC, "PC");
+ stringRep.add(rpcs::PSI_MACH_MC, "MC");
+ stringRep.add(rpcs::PSI_MACH_HC, "HC");
+ stringRep.add(rpcs::PSI_MACH_S3, "Series 3");
+ stringRep.add(rpcs::PSI_MACH_S3A, "Series 3a, 3c or 3mx");
+ stringRep.add(rpcs::PSI_MACH_WORKABOUT, "Workabout");
+ stringRep.add(rpcs::PSI_MACH_SIENNA, "Sienna");
+ stringRep.add(rpcs::PSI_MACH_S3C, "Series 3c");
+ stringRep.add(rpcs::PSI_MACH_S5, "Series 5");
+ stringRep.add(rpcs::PSI_MACH_WINC, "WinC");
+}
+
+ENUM_DEFINITION(rpcs::batterystates, rpcs::PSI_BATT_DEAD) {
+ stringRep.add(rpcs::PSI_BATT_DEAD, "Empty");
+ stringRep.add(rpcs::PSI_BATT_VERYLOW, "Very Low");
+ stringRep.add(rpcs::PSI_BATT_LOW, "Low");
+ stringRep.add(rpcs::PSI_BATT_GOOD, "Good");
+}
-static const char * const langstrings[] = {
- "Test", "English", "French", "German", "Spanish", "Italian", "Swedish",
- "Danish", "Norwegian", "Finnish", "American", "Swiss French",
- "Swiss German", "Portugese", "Turkish", "Icelandic", "Russian",
- "Hungarian", "Dutch", "Belgian Flemish", "Australian",
- "Belgish French", "Austrian", "New Zealand",
- "International French", "Czech", "Slovak", "Polish", "Slovenian",
- 0L
-};
+ENUM_DEFINITION(rpcs::languages, rpcs::PSI_LANG_TEST) {
+ stringRep.add(rpcs::PSI_LANG_TEST, "Test");
+ stringRep.add(rpcs::PSI_LANG_en_GB, "English");
+ stringRep.add(rpcs::PSI_LANG_de_DE, "German");
+ stringRep.add(rpcs::PSI_LANG_fr_FR, "French");
+ stringRep.add(rpcs::PSI_LANG_es_ES, "Spanish");
+ stringRep.add(rpcs::PSI_LANG_it_IT, "Italian");
+ stringRep.add(rpcs::PSI_LANG_sv_SE, "Swedish");
+ stringRep.add(rpcs::PSI_LANG_da_DK, "Danish");
+ stringRep.add(rpcs::PSI_LANG_no_NO, "Norwegian");
+ stringRep.add(rpcs::PSI_LANG_fi_FI, "Finnish");
+ stringRep.add(rpcs::PSI_LANG_en_US, "American");
+ stringRep.add(rpcs::PSI_LANG_fr_CH, "Swiss French");
+ stringRep.add(rpcs::PSI_LANG_de_CH, "Swiss German");
+ stringRep.add(rpcs::PSI_LANG_pt_PT, "Portugese");
+ stringRep.add(rpcs::PSI_LANG_tr_TR, "Turkish");
+ stringRep.add(rpcs::PSI_LANG_is_IS, "Icelandic");
+ stringRep.add(rpcs::PSI_LANG_ru_RU, "Russian");
+ stringRep.add(rpcs::PSI_LANG_hu_HU, "Hungarian");
+ stringRep.add(rpcs::PSI_LANG_nl_NL, "Dutch");
+ stringRep.add(rpcs::PSI_LANG_nl_BE, "Belgian Flemish");
+ stringRep.add(rpcs::PSI_LANG_en_AU, "Australian");
+ stringRep.add(rpcs::PSI_LANG_fr_BE, "Belgish French");
+ stringRep.add(rpcs::PSI_LANG_de_AT, "Austrian");
+ stringRep.add(rpcs::PSI_LANG_en_NZ, "New Zealand"); // FIXME: not shure about ISO code
+ stringRep.add(rpcs::PSI_LANG_fr_CA, "International French"); // FIXME: not shure about ISO code
+ stringRep.add(rpcs::PSI_LANG_cs_CZ, "Czech");
+ stringRep.add(rpcs::PSI_LANG_sk_SK, "Slovak");
+ stringRep.add(rpcs::PSI_LANG_pl_PL, "Polish");
+ stringRep.add(rpcs::PSI_LANG_sl_SI, "Slovenian");
+}
//
// public common API
@@ -56,17 +100,17 @@ void rpcs::
reset(void)
{
bufferStore a;
- status = E_PSI_FILE_DISC;
+ status = rfsv::E_PSI_FILE_DISC;
a.addStringT(getConnectName());
if (skt->sendBufferStore(a)) {
if (skt->getBufferStore(a) == 1) {
if (!strcmp(a.getString(0), "Ok"))
- status = E_PSI_GEN_NONE;
+ status = rfsv::E_PSI_GEN_NONE;
}
}
}
-long rpcs::
+Enum<rfsv::errs> rpcs::
getStatus(void)
{
return status;
@@ -84,9 +128,9 @@ getConnectName(void)
bool rpcs::
sendCommand(enum commands cc, bufferStore & data)
{
- if (status == E_PSI_FILE_DISC) {
+ if (status == rfsv::E_PSI_FILE_DISC) {
reconnect();
- if (status == E_PSI_FILE_DISC)
+ if (status == rfsv::E_PSI_FILE_DISC)
return false;
}
bool result;
@@ -98,44 +142,44 @@ sendCommand(enum commands cc, bufferStore & data)
reconnect();
result = skt->sendBufferStore(a);
if (!result)
- status = E_PSI_FILE_DISC;
+ status = rfsv::E_PSI_FILE_DISC;
}
return result;
}
-int rpcs::
+Enum<rfsv::errs> rpcs::
getResponse(bufferStore & data)
{
if (skt->getBufferStore(data) == 1) {
- char ret = data.getByte(0);
+ Enum<rfsv::errs> ret = (enum rfsv::errs)data.getByte(0);
data.discardFirstBytes(1);
return ret;
} else
- status = E_PSI_FILE_DISC;
+ status = rfsv::E_PSI_FILE_DISC;
return status;
}
//
// APIs, identical on SIBO and EPOC
//
-int rpcs::
+Enum<rfsv::errs> rpcs::
getNCPversion(int &major, int &minor)
{
- int res;
+ Enum<rfsv::errs> res;
bufferStore a;
if (!sendCommand(QUERY_NCP, a))
- return 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() != 2)
- return E_PSI_GEN_FAIL;
+ return rfsv::E_PSI_GEN_FAIL;
major = a.getByte(0);
minor = a.getByte(1);
return res;
}
-int rpcs::
+Enum<rfsv::errs> rpcs::
execProgram(const char *program, const char *args)
{
bufferStore a;
@@ -147,87 +191,87 @@ execProgram(const char *program, const char *args)
a.addByte(strlen(args));
a.addStringT(args);
if (!sendCommand(EXEC_PROG, a))
- return E_PSI_FILE_DISC;
+ return rfsv::E_PSI_FILE_DISC;
return getResponse(a);
}
-int rpcs::
+Enum<rfsv::errs> rpcs::
stopProgram(const char *program)
{
bufferStore a;
a.addStringT(program);
if (!sendCommand(STOP_PROG, a))
- return E_PSI_FILE_DISC;
+ return rfsv::E_PSI_FILE_DISC;
return getResponse(a);
}
-int rpcs::
+Enum<rfsv::errs> rpcs::
queryProgram(const char *program)
{
bufferStore a;
a.addStringT(program);
if (!sendCommand(QUERY_PROG, a))
- return E_PSI_FILE_DISC;
+ return rfsv::E_PSI_FILE_DISC;
return getResponse(a);
}
-int rpcs::
+Enum<rfsv::errs> rpcs::
formatOpen(const char *drive, int &handle, int &count)
{
- int res;
+ Enum<rfsv::errs> res;
bufferStore a;
a.addStringT(drive);
if (!sendCommand(FORMAT_OPEN, a))
- return 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() != 4)
- return E_PSI_GEN_FAIL;
+ return rfsv::E_PSI_GEN_FAIL;
handle = a.getWord(0);
count = a.getWord(2);
return res;
}
-int rpcs::
+Enum<rfsv::errs> rpcs::
formatRead(int handle)
{
bufferStore a;
a.addWord(handle);
if (!sendCommand(FORMAT_READ, a))
- return E_PSI_FILE_DISC;
+ return rfsv::E_PSI_FILE_DISC;
return getResponse(a);
}
-int rpcs::
+Enum<rfsv::errs> rpcs::
getUniqueID(const char *device, long &id)
{
- int res;
+ Enum<rfsv::errs> res;
bufferStore a;
a.addStringT(device);
if (!sendCommand(GET_UNIQUEID, a))
- return 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() != 4)
- return E_PSI_GEN_FAIL;
+ return rfsv::E_PSI_GEN_FAIL;
id = a.getDWord(0);
return res;
}
-int rpcs::
+Enum<rfsv::errs> rpcs::
getOwnerInfo(bufferArray &owner)
{
- int res;
+ Enum<rfsv::errs> res;
bufferStore a;
if (!sendCommand(GET_OWNERINFO, a))
- return E_PSI_FILE_DISC;
- if ((res = getResponse(a)))
+ return rfsv::E_PSI_FILE_DISC;
+ if ((res = (enum rfsv::errs)getResponse(a)) != rfsv::E_PSI_GEN_NONE)
return res;
a.addByte(0);
int l = a.getLen();
@@ -251,33 +295,33 @@ getOwnerInfo(bufferArray &owner)
return res;
}
-int rpcs::
-getMachineType(int &type)
+Enum<rfsv::errs> rpcs::
+getMachineType(Enum<machs> &type)
{
- int res;
+ Enum<rfsv::errs> res;
bufferStore a;
if (!sendCommand(GET_MACHINETYPE, a))
- return 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() != 2)
- return E_PSI_GEN_FAIL;
- type = a.getWord(0);
+ return rfsv::E_PSI_GEN_FAIL;
+ type = (enum machs)a.getWord(0);
return res;
}
-int rpcs::
+Enum<rfsv::errs> rpcs::
fuser(const char *name, char *buf, int maxlen)
{
- int res;
+ Enum<rfsv::errs> res;
bufferStore a;
char *p;
a.addStringT(name);
if (!sendCommand(FUSER, a))
- return 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;
strncpy(buf, a.getString(0), maxlen - 1);
while ((p = strchr(buf, 6)))
@@ -285,34 +329,11 @@ fuser(const char *name, char *buf, int maxlen)
return res;
}
-int rpcs::
+Enum<rfsv::errs> rpcs::
quitServer(void)
{
bufferStore a;
if (!sendCommand(QUIT_SERVER, a))
- return E_PSI_FILE_DISC;
+ return rfsv::E_PSI_FILE_DISC;
return getResponse(a);
}
-
-const char *rpcs::
-languageString(int code) {
- for (int i = 0; i <= code; i++)
- if (langstrings[i] == 0L)
- return "Unknown";
- return langstrings[code];
-}
-
-const char *rpcs::
-batteryStatusString(int code) {
- switch (code) {
- case PSI_BATT_DEAD:
- return "Empty";
- case PSI_BATT_VERYLOW:
- return "Very low";
- case PSI_BATT_LOW:
- return "Low";
- case PSI_BATT_GOOD:
- return "Good";
- }
- return "Unknown";
-}
diff --git a/lib/rpcs.h b/lib/rpcs.h
index 3c569bb..18d4d66 100644
--- a/lib/rpcs.h
+++ b/lib/rpcs.h
@@ -2,57 +2,14 @@
#define _rpcs_h_
#include "psitime.h"
+#include "rfsv.h"
+#include "Enum.h"
class ppsocket;
class bufferStore;
class bufferArray;
/**
- * This struct holds the data returned
- * by @ref rpcs::getMachineInfo.
- */
-typedef struct machineInfo_t {
- unsigned long machineType;
- char machineName[17];
- unsigned long long machineUID;
- unsigned long countryCode;
- char uiLanguage[32];
-
- unsigned short romMajor;
- unsigned short romMinor;
- unsigned short romBuild;
- unsigned long romSize;
- bool romProgrammable;
-
- unsigned long ramSize;
- unsigned long ramFree;
- unsigned long ramMaxFree;
- unsigned long ramDiskSize;
-
- unsigned long registrySize;
- unsigned long displayWidth;
- unsigned long displayHeight;
-
- psi_timeval time;
- psi_timezone tz;
-
- psi_timeval mainBatteryInsertionTime;
- unsigned long mainBatteryStatus;
- psi_timeval mainBatteryUsedTime;
- unsigned long mainBatteryCurrent;
- unsigned long mainBatteryUsedPower;
- unsigned long mainBatteryVoltage;
- unsigned long mainBatteryMaxVoltage;
-
- unsigned long backupBatteryStatus;
- unsigned long backupBatteryVoltage;
- unsigned long backupBatteryMaxVoltage;
- psi_timeval backupBatteryUsedTime;
-
- bool externalPower;
-} machineInfo;
-
-/**
* Remote procedure call services via PLP
*
* rpcs provides an interface for communicating
@@ -68,6 +25,114 @@ typedef struct machineInfo_t {
class rpcs {
public:
/**
+ * The known machine types.
+ */
+ enum machs {
+ PSI_MACH_UNKNOWN = 0,
+ PSI_MACH_PC = 1,
+ PSI_MACH_MC = 2,
+ PSI_MACH_HC = 3,
+ PSI_MACH_S3 = 4,
+ PSI_MACH_S3A = 5,
+ PSI_MACH_WORKABOUT = 6,
+ PSI_MACH_SIENNA = 7,
+ PSI_MACH_S3C = 8,
+ PSI_MACH_S5 = 32,
+ PSI_MACH_WINC = 33,
+ // TODO: Code for 5mx
+ };
+
+ /**
+ * The known interface languages.
+ */
+ enum languages {
+ PSI_LANG_TEST = 0,
+ PSI_LANG_en_GB = 1,
+ PSI_LANG_fr_FR = 2,
+ PSI_LANG_de_DE = 3,
+ PSI_LANG_es_ES = 4,
+ PSI_LANG_it_IT = 5,
+ PSI_LANG_sv_SE = 6,
+ PSI_LANG_da_DK = 7,
+ PSI_LANG_no_NO = 8,
+ PSI_LANG_fi_FI = 9,
+ PSI_LANG_en_US = 10,
+ PSI_LANG_fr_CH = 11,
+ PSI_LANG_de_CH = 12,
+ PSI_LANG_pt_PT = 13,
+ PSI_LANG_tr_TR = 14,
+ PSI_LANG_is_IS = 15,
+ PSI_LANG_ru_RU = 16,
+ PSI_LANG_hu_HU = 17,
+ PSI_LANG_nl_NL = 18,
+ PSI_LANG_nl_BE = 19,
+ PSI_LANG_en_AU = 20,
+ PSI_LANG_fr_BE = 21,
+ PSI_LANG_de_AT = 22,
+ PSI_LANG_en_NZ = 23,
+ PSI_LANG_fr_CA = 24,
+ PSI_LANG_cs_CZ = 25,
+ PSI_LANG_sk_SK = 26,
+ PSI_LANG_pl_PL = 27,
+ PSI_LANG_sl_SI = 28,
+ };
+
+ /**
+ * The known battery states.
+ */
+ enum batterystates {
+ PSI_BATT_DEAD = 0,
+ PSI_BATT_VERYLOW = 1,
+ PSI_BATT_LOW = 2,
+ PSI_BATT_GOOD = 3,
+ };
+
+ /**
+ * This struct holds the data returned
+ * by @ref rpcs::getMachineInfo.
+ */
+ typedef struct machineInfo_t {
+ Enum<machs> machineType;
+ char machineName[17];
+ unsigned long long machineUID;
+ unsigned long countryCode;
+ Enum<languages> uiLanguage;
+
+ unsigned short romMajor;
+ unsigned short romMinor;
+ unsigned short romBuild;
+ unsigned long romSize;
+ bool romProgrammable;
+
+ unsigned long ramSize;
+ unsigned long ramFree;
+ unsigned long ramMaxFree;
+ unsigned long ramDiskSize;
+
+ unsigned long registrySize;
+ unsigned long displayWidth;
+ unsigned long displayHeight;
+
+ psi_timeval time;
+ psi_timezone tz;
+
+ psi_timeval mainBatteryInsertionTime;
+ Enum<batterystates> mainBatteryStatus;
+ psi_timeval mainBatteryUsedTime;
+ unsigned long mainBatteryCurrent;
+ unsigned long mainBatteryUsedPower;
+ unsigned long mainBatteryVoltage;
+ unsigned long mainBatteryMaxVoltage;
+
+ Enum<batterystates> backupBatteryStatus;
+ unsigned long backupBatteryVoltage;
+ unsigned long backupBatteryMaxVoltage;
+ psi_timeval backupBatteryUsedTime;
+
+ bool externalPower;
+ } machineInfo;
+
+ /**
* Provides a virtual destructor.
*/
virtual ~rpcs() {};
@@ -92,7 +157,7 @@ class rpcs {
*
* @returns The connection status.
*/
- long getStatus();
+ Enum<rfsv::errs> getStatus();
/**
* Retrieves the version of the NCP protocol
@@ -108,7 +173,7 @@ class rpcs {
*
* @returns A psion error code. 0 = Ok.
*/
- int getNCPversion(int &major, int &minor);
+ Enum<rfsv::errs> getNCPversion(int &major, int &minor);
/**
* Starts execution of a program on the remote machine.
@@ -123,7 +188,7 @@ class rpcs {
*
* @returns A psion error code. 0 = Ok.
*/
- int execProgram(const char *program, const char *args);
+ Enum<rfsv::errs> execProgram(const char *program, const char *args);
/**
* Requests termination of a program running on the
@@ -136,11 +201,11 @@ class rpcs {
*
* @returns A psion error code. 0 = Ok.
*/
- int stopProgram(const char *);
- int queryProgram(const char *);
- int formatOpen(const char *, int &, int &);
- int formatRead(int);
- int getUniqueID(const char *, long &);
+ Enum<rfsv::errs> stopProgram(const char *);
+ Enum<rfsv::errs> queryProgram(const char *);
+ Enum<rfsv::errs> formatOpen(const char *, int &, int &);
+ Enum<rfsv::errs> formatRead(int);
+ Enum<rfsv::errs> getUniqueID(const char *, long &);
/**
* Retrieve owner information of the remote machine.
@@ -153,7 +218,7 @@ class rpcs {
*
* @returns A psion error code. 0 = Ok.
*/
- int getOwnerInfo(bufferArray &);
+ Enum<rfsv::errs> getOwnerInfo(bufferArray &);
/**
* Retrieves the type of machine on the remote side
@@ -167,7 +232,7 @@ class rpcs {
*
* @returns A psion error code. 0 = Ok.
*/
- int getMachineType(int &type);
+ Enum<rfsv::errs> getMachineType(Enum<machs> &type);
/**
* Retrieves the name of a process, having a
@@ -182,7 +247,7 @@ class rpcs {
* program's name.
* @param maxlen The maximum capacity of the buffer.
*/
- int fuser(const char *name, char *buf, int maxlen);
+ Enum<rfsv::errs> fuser(const char *name, char *buf, int maxlen);
/**
* Requests the remote server to terminate.
@@ -194,33 +259,10 @@ class rpcs {
*
* @returns A psion error code. 0 = Ok.
*/
- int quitServer(void);
-
- /**
- * Maps a language code to a human readable language name.
- *
- * @param code The language code to map.
- *
- * @returns The name of the language, represented by code, or
- * "Unknown", if the code does not match one of the known
- * languages.
- */
- const char *languageString(const int code);
-
- /**
- * Maps a battery status code to a human readable description.
- *
- * @param code The battary status code to map.
- *
- * @returns A descriptive text for the battery status, or
- * "Unknown", if the code does not match a known
- * battery status.
- */
- const char *batteryStatusString(const int code);
-
+ Enum<rfsv::errs> quitServer(void);
// API different on SIBO and EPOC
- virtual int queryDrive(const char, bufferArray &) = 0;
+ virtual Enum<rfsv::errs> queryDrive(const char, bufferArray &) = 0;
/**
* Retrieves the command line of a running process.
*
@@ -232,7 +274,7 @@ class rpcs {
*
* @return Psion error code. 0 = Ok.
*/
- virtual int getCmdLine(const char *process, bufferStore &ret) = 0;
+ virtual Enum<rfsv::errs> getCmdLine(const char *process, bufferStore &ret) = 0;
// API only existent on EPOC
// default-methods for SIBO here.
@@ -246,65 +288,19 @@ class rpcs {
* @param machineInfo The struct holding all information on return.
* @return Psion error code. 0 = Ok.
*/
- virtual int getMachineInfo(machineInfo &) { return E_PSI_NOT_SIBO;}
- virtual int closeHandle(int) { return E_PSI_NOT_SIBO;}
- virtual int regOpenIter(void) { return E_PSI_NOT_SIBO;}
- virtual int regReadIter(void) { return E_PSI_NOT_SIBO;}
- virtual int regWrite(void) { return E_PSI_NOT_SIBO;}
- virtual int regRead(void) { return E_PSI_NOT_SIBO;}
- virtual int regDelete(void) { return E_PSI_NOT_SIBO;}
- virtual int setTime(void) { return E_PSI_NOT_SIBO;}
- virtual int configOpen(void) { return E_PSI_NOT_SIBO;}
- virtual int configRead(void) { return E_PSI_NOT_SIBO;}
- virtual int configWrite(void) { return E_PSI_NOT_SIBO;}
- virtual int queryOpen(void) { return E_PSI_NOT_SIBO;}
- virtual int queryRead(void) { return E_PSI_NOT_SIBO;}
-
- enum errs {
- E_PSI_GEN_NONE = 0,
- E_PSI_GEN_FAIL = -1,
- E_PSI_FILE_DISC = -50,
- // Special error code for "Operation not permitted in RPCS16"
- E_PSI_NOT_SIBO = -200
- };
-
- /**
- * The known machine types.
- */
- enum machs {
- PSI_MACH_UNKNOWN = 0,
- PSI_MACH_PC = 1,
- PSI_MACH_MC = 2,
- PSI_MACH_HC = 3,
- PSI_MACH_S3 = 4,
- PSI_MACH_S3A = 5,
- PSI_MACH_WORKABOUT = 6,
- PSI_MACH_SIENNA = 7,
- PSI_MACH_S3C = 8,
- PSI_MACH_S5 = 32,
- PSI_MACH_WINC = 33,
- // TODO: Code for 5mx
- };
-
- /**
- * The known interface languages.
- */
- enum languagecodes {
- PSI_LANG_TEST = 0,
- PSI_LANG_ENGLISH = 1,
- PSI_LANG_FRENCH = 2,
- PSI_LANG_GERMAN = 3,
- };
-
- /**
- * The known battery states.
- */
- enum batterystates {
- PSI_BATT_DEAD = 0,
- PSI_BATT_VERYLOW = 1,
- PSI_BATT_LOW = 2,
- PSI_BATT_GOOD = 3,
- };
+ virtual Enum<rfsv::errs> getMachineInfo(machineInfo &) { return rfsv::E_PSI_NOT_SIBO;}
+ virtual Enum<rfsv::errs> closeHandle(int) { return rfsv::E_PSI_NOT_SIBO;}
+ virtual Enum<rfsv::errs> regOpenIter(void) { return rfsv::E_PSI_NOT_SIBO;}
+ virtual Enum<rfsv::errs> regReadIter(void) { return rfsv::E_PSI_NOT_SIBO;}
+ virtual Enum<rfsv::errs> regWrite(void) { return rfsv::E_PSI_NOT_SIBO;}
+ virtual Enum<rfsv::errs> regRead(void) { return rfsv::E_PSI_NOT_SIBO;}
+ virtual Enum<rfsv::errs> regDelete(void) { return rfsv::E_PSI_NOT_SIBO;}
+ virtual Enum<rfsv::errs> setTime(void) { return rfsv::E_PSI_NOT_SIBO;}
+ virtual Enum<rfsv::errs> configOpen(void) { return rfsv::E_PSI_NOT_SIBO;}
+ virtual Enum<rfsv::errs> configRead(void) { return rfsv::E_PSI_NOT_SIBO;}
+ virtual Enum<rfsv::errs> configWrite(void) { return rfsv::E_PSI_NOT_SIBO;}
+ virtual Enum<rfsv::errs> queryOpen(void) { return rfsv::E_PSI_NOT_SIBO;}
+ virtual Enum<rfsv::errs> queryRead(void) { return rfsv::E_PSI_NOT_SIBO;}
protected:
/**
@@ -316,7 +312,7 @@ class rpcs {
/**
* The current status of the connection.
*/
- long status;
+ Enum<rfsv::errs> status;
/**
* The possible commands.
@@ -364,7 +360,7 @@ class rpcs {
* @returns true on success, false on failure.
*/
bool sendCommand(enum commands cc, bufferStore &data);
- int getResponse(bufferStore &);
+ Enum<rfsv::errs> getResponse(bufferStore &);
const char *getConnectName();
};
diff --git a/lib/rpcs16.cc b/lib/rpcs16.cc
index d8d75cf..57963e2 100644
--- a/lib/rpcs16.cc
+++ b/lib/rpcs16.cc
@@ -40,27 +40,25 @@ rpcs16::~rpcs16()
{
bufferStore a;
a.addStringT("Close");
- if (status == E_PSI_GEN_NONE)
+ if (status == rfsv::E_PSI_GEN_NONE)
skt->sendBufferStore(a);
skt->closeSocket();
}
-int rpcs16::
+Enum<rfsv::errs> rpcs16::
queryDrive(char drive, bufferArray &ret)
{
bufferStore a;
a.addByte(drive);
if (!sendCommand(rpcs::QUERY_DRIVE, a))
- return rpcs::E_PSI_FILE_DISC;
- long res = getResponse(a);
+ return rfsv::E_PSI_FILE_DISC;
+ Enum<rfsv::errs> res = getResponse(a);
cout << dec << "qd: " << res << " " << a.getLen() << " a="<< a << endl;
- if (res)
- return res;
return res;
}
-int rpcs16::
+Enum<rfsv::errs> rpcs16::
getCmdLine(const char *process, bufferStore &ret)
{
- return 0;
+ return rfsv::E_PSI_GEN_NONE;
}
diff --git a/lib/rpcs16.h b/lib/rpcs16.h
index c803fff..efc6b99 100644
--- a/lib/rpcs16.h
+++ b/lib/rpcs16.h
@@ -11,8 +11,8 @@ class rpcs16 : public rpcs {
rpcs16(ppsocket *);
~rpcs16();
- int queryDrive(const char, bufferArray &);
- int getCmdLine(const char *, bufferStore &);
+ Enum<rfsv::errs> queryDrive(const char, bufferArray &);
+ Enum<rfsv::errs> getCmdLine(const char *, bufferStore &);
};
#endif
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<rfsv::errs> rpcs32::
queryDrive(char drive, bufferArray &ret)
{
bufferStore a;
- int res;
+ Enum<rfsv::errs> 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<rfsv::errs> rpcs32::
getCmdLine(const char *process, bufferStore &ret)
{
bufferStore a;
- int res;
+ Enum<rfsv::errs> 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<rfsv::errs> rpcs32::
getMachineInfo(machineInfo &mi)
{
bufferStore a;
- int res;
+ Enum<rfsv::errs> 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<rfsv::errs> rpcs32::
configOpen(void)
{
bufferStore a;
- int res;
+ Enum<rfsv::errs> 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<rfsv::errs> rpcs32::
configRead(void)
{
bufferStore a;
- int res;
+ Enum<rfsv::errs> 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;
}
diff --git a/lib/rpcs32.h b/lib/rpcs32.h
index 6c333b4..973b142 100644
--- a/lib/rpcs32.h
+++ b/lib/rpcs32.h
@@ -10,25 +10,25 @@ class rpcs32 : public rpcs {
rpcs32(ppsocket *);
~rpcs32();
- int queryDrive(const char, bufferArray &);
- int getCmdLine(const char *, bufferStore &);
- int getMachineInfo(machineInfo &);
- int configOpen(void);
- int configRead(void);
+ Enum<rfsv::errs> queryDrive(const char, bufferArray &);
+ Enum<rfsv::errs> getCmdLine(const char *, bufferStore &);
+ Enum<rfsv::errs> getMachineInfo(machineInfo &);
+ Enum<rfsv::errs> configOpen(void);
+ Enum<rfsv::errs> configRead(void);
#if 0
- int closeHandle(int);
- int regOpenIter(void);
- int regReadIter(void);
- int regWrite(void);
- int regRead(void);
- int regDelete(void);
- int setTime(void);
- int configOpen(void);
- int configRead(void);
- int configWrite(void);
- int queryOpen(void);
- int queryRead(void);
- int quitServer(void);
+ Enum<rfsv::errs> closeHandle(int);
+ Enum<rfsv::errs> regOpenIter(void);
+ Enum<rfsv::errs> regReadIter(void);
+ Enum<rfsv::errs> regWrite(void);
+ Enum<rfsv::errs> regRead(void);
+ Enum<rfsv::errs> regDelete(void);
+ Enum<rfsv::errs> setTime(void);
+ Enum<rfsv::errs> configOpen(void);
+ Enum<rfsv::errs> configRead(void);
+ Enum<rfsv::errs> configWrite(void);
+ Enum<rfsv::errs> queryOpen(void);
+ Enum<rfsv::errs> queryRead(void);
+ Enum<rfsv::errs> quitServer(void);
#endif
};
diff --git a/plpftp/ftp.cc b/plpftp/ftp.cc
index 2022eb5..60ebfb4 100644
--- a/plpftp/ftp.cc
+++ b/plpftp/ftp.cc
@@ -45,6 +45,7 @@
#include "rpcs.h"
#include "bufferarray.h"
#include "bufferstore.h"
+#include "Enum.h"
#if HAVE_LIBREADLINE
extern "C" {
@@ -196,7 +197,7 @@ session(rfsv & a, rpcs & r, int xargc, char **xargv)
char *argv[10];
char f1[256];
char f2[256];
- long res;
+ Enum<rfsv::errs> res;
bool prompt = true;
bool hash = false;
cpCallback_t cab = checkAbortNoHash;
@@ -211,48 +212,9 @@ session(rfsv & a, rpcs & r, int xargc, char **xargv)
if (!once) {
bufferArray b;
if (!(res = r.getOwnerInfo(b))) {
- int machType;
+ Enum<rpcs::machs> machType;
r.getMachineType(machType);
- cout << "Connected to ";
- switch (machType) {
- case rpcs::PSI_MACH_UNKNOWN:
- cout << "an unknown Device";
- break;
- case rpcs::PSI_MACH_PC:
- cout << "a PC";
- break;
- case rpcs::PSI_MACH_MC:
- cout << "a MC";
- break;
- case rpcs::PSI_MACH_HC:
- cout << "a HC";
- break;
- case rpcs::PSI_MACH_S3:
- cout << "a Serie 3";
- break;
- case rpcs::PSI_MACH_S3A:
- cout << "a Series 3a, 3c or 3mx";
- break;
- case rpcs::PSI_MACH_WORKABOUT:
- cout << "a Workabout";
- break;
- case rpcs::PSI_MACH_SIENNA:
- cout << "a Sienna";
- break;
- case rpcs::PSI_MACH_S3C:
- cout << "a Series 3c";
- break;
- case rpcs::PSI_MACH_S5:
- cout << "a Series 5";
- break;
- case rpcs::PSI_MACH_WINC:
- cout << "a WinC";
- break;
- default:
- cout << "an undefined Device";
- break;
- }
- cout << ", OwnerInfo:" << endl;
+ cout << "Connected to a " << machType << ", OwnerInfo:" << endl;
while (!b.empty())
cout << " " << b.pop().getString() << endl;
cout << endl;
@@ -321,14 +283,14 @@ session(rfsv & a, rpcs & r, int xargc, char **xargv)
strcpy(f2, psionDir);
strcat(f2, argv[2]);
if ((res = a.rename(f1, f2)) != 0)
- errprint(res, a);
+ cerr << "Error: " << res << endl;
continue;
}
if (!strcmp(argv[0], "touch") && (argc == 2)) {
strcpy(f1, psionDir);
strcat(f1, argv[1]);
if ((res = a.fsetmtime(f1, time(0))) != 0)
- errprint(res, a);
+ cerr << "Error: " << res << endl;
continue;
}
if (!strcmp(argv[0], "test") && (argc == 2)) {
@@ -336,7 +298,7 @@ session(rfsv & a, rpcs & r, int xargc, char **xargv)
strcpy(f1, psionDir);
strcat(f1, argv[1]);
if ((res = a.fgeteattr(f1, &attr, &size, &time)) != 0)
- errprint(res, a);
+ cerr << "Error: " << res << endl;
else {
// never used to do this
char dateBuff[100];
@@ -353,7 +315,7 @@ session(rfsv & a, rpcs & r, int xargc, char **xargv)
strcpy(f1, psionDir);
strcat(f1, argv[1]);
if ((res = a.fgetattr(f1, &attr)) != 0)
- errprint(res, a);
+ cerr << "Error: " << res << endl;
else {
cout << hex << setw(4) << setfill('0') << attr;
cout << " (" << a.opAttr(attr) << ")" << endl;
@@ -365,7 +327,7 @@ session(rfsv & a, rpcs & r, int xargc, char **xargv)
strcpy(f1, psionDir);
strcat(f1, argv[1]);
if ((res = a.fgetmtime(f1, &mtime)) != 0)
- errprint(res, a);
+ cerr << "Error: " << res << endl;
else {
char dateBuff[100];
strftime(dateBuff, sizeof(dateBuff), datefmt, localtime(&mtime));
@@ -410,13 +372,13 @@ session(rfsv & a, rpcs & r, int xargc, char **xargv)
p++;
}
if ((res = a.fsetattr(f1, attr[0], attr[1])) != 0)
- errprint(res, a);
+ cerr << "Error: " << res << endl;
continue;
}
if (!strcmp(argv[0], "dircnt")) {
long cnt;
if ((res = a.dircount(psionDir, &cnt)) != 0)
- errprint(res, a);
+ cerr << "Error: " << res << endl;
else
cout << cnt << " Entries" << endl;
continue;
@@ -443,13 +405,13 @@ session(rfsv & a, rpcs & r, int xargc, char **xargv)
devbits >>= 1;
}
} else
- errprint(res, a);
+ cerr << "Error: " << res << endl;
continue;
}
if (!strcmp(argv[0], "ls") || !strcmp(argv[0], "dir")) {
bufferArray files;
if ((res = a.dir(psionDir, &files)) != 0)
- errprint(res, a);
+ cerr << "Error: " << res << endl;
else
while (!files.empty()) {
bufferStore s;
@@ -515,7 +477,7 @@ session(rfsv & a, rpcs & r, int xargc, char **xargv)
strcpy(psionDir, f1);
}
else {
- errprint(res, a);
+ cerr << "Error: " << res << endl;
cerr << "Keeping original directory \"" << psionDir << "\"" << endl;
}
}
@@ -538,7 +500,7 @@ session(rfsv & a, rpcs & r, int xargc, char **xargv)
if (hash)
cout << endl;
continueRunning = 1;
- errprint(res, a);
+ cerr << "Error: " << res << endl;
} else {
if (hash)
cout << endl;
@@ -564,7 +526,7 @@ session(rfsv & a, rpcs & r, int xargc, char **xargv)
char *pattern = argv[1];
bufferArray files;
if ((res = a.dir(psionDir, &files)) != 0) {
- errprint(res, a);
+ cerr << "Error: " << res << endl;
continue;
}
while (!files.empty()) {
@@ -602,7 +564,7 @@ session(rfsv & a, rpcs & r, int xargc, char **xargv)
if (hash)
cout << endl;
continueRunning = 1;
- errprint(res, a);
+ cerr << "Error: " << res << endl;
break;
} else {
if (hash)
@@ -630,7 +592,7 @@ session(rfsv & a, rpcs & r, int xargc, char **xargv)
if (hash)
cout << endl;
continueRunning = 1;
- errprint(res, a);
+ cerr << "Error: " << res << endl;
} else {
if (hash)
cout << endl;
@@ -691,7 +653,7 @@ session(rfsv & a, rpcs & r, int xargc, char **xargv)
if (hash)
cout << endl;
continueRunning = 1;
- errprint(res, a);
+ cerr << "Error: " << res << endl;
break;
} else {
if (hash)
@@ -711,21 +673,21 @@ session(rfsv & a, rpcs & r, int xargc, char **xargv)
strcpy(f1, psionDir);
strcat(f1, argv[1]);
if ((res = a.remove(f1)) != 0)
- errprint(res, a);
+ cerr << "Error: " << res << endl;
continue;
}
if (!strcmp(argv[0], "mkdir") && (argc == 2)) {
strcpy(f1, psionDir);
strcat(f1, argv[1]);
if ((res = a.mkdir(f1)) != 0)
- errprint(res, a);
+ cerr << "Error: " << res << endl;
continue;
}
if (!strcmp(argv[0], "rmdir") && (argc == 2)) {
strcpy(f1, psionDir);
strcat(f1, argv[1]);
if ((res = a.rmdir(f1)) != 0)
- errprint(res, a);
+ cerr << "Error: " << res << endl;
continue;
}
if (argv[0][0] == '!') {
@@ -777,9 +739,9 @@ session(rfsv & a, rpcs & r, int xargc, char **xargv)
continue;
}
if (!strcmp(argv[0], "machinfo")) {
- machineInfo mi;
+ rpcs::machineInfo mi;
if ((res = r.getMachineInfo(mi))) {
- errprint(res, a);
+ cerr << "Error: " << res << endl;
continue;
}
@@ -814,15 +776,13 @@ session(rfsv & a, rpcs & r, int xargc, char **xargv)
pt.setPsiTime(&mi.mainBatteryInsertionTime);
cout << " Changed at: " << pt << endl;
cout << " Used for: " << mi.mainBatteryUsedTime << endl;
- cout << " Status: " <<
- r.batteryStatusString(mi.mainBatteryStatus) << endl;
+ cout << " Status: " << mi.mainBatteryStatus << endl;
cout << " Current: " << mi.mainBatteryCurrent << " mA" << endl;
cout << " UsedPower: " << mi.mainBatteryUsedPower << " mAs" << endl;
cout << " Voltage: " << mi.mainBatteryVoltage << " mV" << endl;
cout << " Max. voltage: " << mi.mainBatteryMaxVoltage << " mV" << endl;
cout << "Backup battery:" << endl;
- cout << " Status: " <<
- r.batteryStatusString(mi.backupBatteryStatus) << endl;
+ cout << " Status: " << mi.backupBatteryStatus << endl;
cout << " Voltage: " << mi.backupBatteryVoltage << " mV" << endl;
cout << " Max. voltage: " << mi.backupBatteryMaxVoltage << " mV" << endl;
cout << " Used for: " << mi.backupBatteryUsedTime << endl;
@@ -840,7 +800,7 @@ session(rfsv & a, rpcs & r, int xargc, char **xargv)
ip >> cmd >> arg;
if ((res = r.execProgram(cmd, arg))) {
cerr << "Could not start " << cmd << " " << arg << endl;
- errprint(res, a);
+ cerr << "Error: " << res << endl;
}
}
ip.close();
@@ -922,11 +882,6 @@ session(rfsv & a, rpcs & r, int xargc, char **xargv)
return a.getStatus();
}
-void ftp::
-errprint(long errcode, rfsv & a) {
- cerr << "Error: " << a.opErr(errcode) << endl;
-}
-
#if HAVE_LIBREADLINE
static char *all_commands[] = {
"pwd", "ren", "touch", "gtime", "test", "gattr", "sattr", "devs",
@@ -959,7 +914,7 @@ filename_generator(char *text, int state)
delete comp_files;
comp_files = new bufferArray();
if ((res = comp_a->dir(psionDir, comp_files)) != 0) {
- cerr << "Error: " << comp_a->opErr(res) << endl;
+ cerr << "Error: " << res << endl;
return NULL;
}
}
diff --git a/plpftp/ftp.h b/plpftp/ftp.h
index a89fd62..86c3d42 100644
--- a/plpftp/ftp.h
+++ b/plpftp/ftp.h
@@ -26,8 +26,9 @@
#define _ftp_h_
#include "bool.h"
+#include "rfsv.h"
+#include "Enum.h"
-class rfsv;
class rpcs;
class bufferStore;
class bufferArray;
@@ -47,7 +48,6 @@ class ftp {
void getUnixDir(bufferArray & files);
void resetUnixPwd();
void usage();
- void errprint(long errcode, rfsv & a);
void cd(const char *source, const char *cdto, char *dest);
// MJG: note, this isn't actually used anywhere