diff options
-rw-r--r-- | netfs/msgtypes.cpp | 84 | ||||
-rw-r--r-- | netfs/msgtypes.h | 4 | ||||
-rw-r--r-- | netfs/xfers.h | 9 |
3 files changed, 53 insertions, 44 deletions
diff --git a/netfs/msgtypes.cpp b/netfs/msgtypes.cpp index e7a814e..b2d449e 100644 --- a/netfs/msgtypes.cpp +++ b/netfs/msgtypes.cpp @@ -7,26 +7,6 @@ MessageFactories & MsgFacs() return m; } -MSGTYPE(0, SimpleInt) -MSGTYPE(1, AccessRequest) -MSGTYPE(2, GetAttrRequest) -MSGTYPE(3, GetAttrReply) -MSGTYPE(4, OpenDirRequest) -MSGTYPE(5, OpenDirReply) -MSGTYPE(6, CloseDirRequest) -MSGTYPE(7, CloseDirReply) -MSGTYPE(8, ReadDirRequest) -MSGTYPE(9, ReadDirReply) -MSGTYPE(10, ReadDirContent) -MSGTYPE(11, OpenRequest) -MSGTYPE(12, OpenReply) -MSGTYPE(13, CloseRequest) -MSGTYPE(14, CloseReply) -MSGTYPE(15, ReadRequest) -MSGTYPE(16, ReadReply) -MSGTYPE(17, WriteRequest) -MSGTYPE(18, WriteReply) - template<class Type> void operator<<(FILE &, const Type & t); template<class Type> void operator>>(FILE &, Type & t); @@ -66,25 +46,52 @@ void ContentBase::Read(FILE*) { } -Xfer2(RequestBase, ContentBase, uid, gid) -Xfer1(OpenDirRequest, RequestBase, path) -Xfer2(OpenDirReply, ContentBase, error, handle) -Xfer2(ReadDirReply, ContentBase, error, count) -Xfer1(ReadDirRequest, RequestBase, handle) -Xfer2(AccessRequest, RequestBase, path, access) -Xfer1(SimpleInt, ContentBase, value) -Xfer1(GetAttrRequest, RequestBase, path) -Xfer2(GetAttrReply, ContentBase, res, val) -Xfer1(CloseDirRequest, RequestBase, handle) -Xfer1(CloseDirReply, ContentBase, error) -Xfer2(ReadDirContent, ContentBase, path, val) -Xfer1(OpenRequest, RequestBase, path) -Xfer2(OpenReply, ContentBase, error, handle) -Xfer1(CloseRequest, RequestBase, handle) -Xfer1(CloseReply, ContentBase, error) -Xfer3(ReadRequest, RequestBase, handle, offset, size) -Xfer1(WriteReply, ContentBase, error) +void +RequestBase::Send(FILE*f) const +{ + ContentBase::Send(f); + *f << uid; + *f << gid; +} +void +RequestBase::Read(FILE*f) +{ + ContentBase::Read(f); + *f >> uid; + *f >> gid; +} +Xfer1(3, OpenDirRequest, RequestBase, path) +Xfer2(4, OpenDirReply, ContentBase, error, handle) +Xfer2(5, ReadDirReply, ContentBase, error, count) +Xfer1(6, ReadDirRequest, RequestBase, handle) +Xfer2(7, AccessRequest, RequestBase, path, access) +Xfer1(8, SimpleInt, ContentBase, value) +Xfer1(9, GetAttrRequest, RequestBase, path) +Xfer2(10, GetAttrReply, ContentBase, res, val) +Xfer1(11, CloseDirRequest, RequestBase, handle) +Xfer1(12, CloseDirReply, ContentBase, error) +Xfer2(13, ReadDirContent, ContentBase, path, val) +Xfer1(14, OpenRequest, RequestBase, path) +Xfer2(15, OpenReply, ContentBase, error, handle) +Xfer1(16, CloseRequest, RequestBase, handle) +Xfer1(17, CloseReply, ContentBase, error) +Xfer3(18, ReadRequest, RequestBase, handle, offset, size) +Xfer1(19, WriteReply, ContentBase, error) +Xfer1(20, MkDirRequest, RequestBase, path) +Xfer1(21, UnlinkRequest, RequestBase, path) +Xfer2(22, SymlinkRequest, RequestBase, path1, path2) +Xfer2(23, LinkRequest, RequestBase, path1, path2) +Xfer2(24, RenameRequest, RequestBase, path1, path2) +Xfer1(25, ReadlinkRequest, RequestBase, path) +Xfer1(26, ReadlinkReply, ContentBase, path) +Xfer2(27, ChmodRequest, RequestBase, path, mode) +Xfer3(28, ChownRequest, RequestBase, path, user, group) +Xfer2(29, TruncateRequest, RequestBase, path, size) +Xfer2(30, FtruncateRequest, RequestBase, handle, size) +Xfer1(31, StatfsRequest, RequestBase, path) +Xfer2(32, StatfsReply, ContentBase, statfs, error) +MSGTYPE(2, ReadReply) ReadReply::~ReadReply() { if (data) { @@ -118,6 +125,7 @@ ReadReply::Read(FILE*f) } } +MSGTYPE(1, WriteRequest) WriteRequest::~WriteRequest() { if (data) { diff --git a/netfs/msgtypes.h b/netfs/msgtypes.h index 79d6d74..78986d3 100644 --- a/netfs/msgtypes.h +++ b/netfs/msgtypes.h @@ -333,10 +333,8 @@ class StatfsRequest : public RequestBase { virtual void Read(FILE*); }; - - #define MSGTYPE(id, cls) \ const uint16_t cls::TypeID = id; \ - namespace FactoryFor##cls { Factory<cls> fac; } + namespace MsgFactories { Factory<cls> facFor##id; } #endif diff --git a/netfs/xfers.h b/netfs/xfers.h index c1369eb..baf2eaa 100644 --- a/netfs/xfers.h +++ b/netfs/xfers.h @@ -1,7 +1,8 @@ #ifndef XFERS_H #define XFERS_H -#define Xfer1(Ptype, Pbase, v1) \ +#define Xfer1(id, Ptype, Pbase, v1) \ +MSGTYPE(id, Ptype) \ void \ Ptype::Send(FILE*f) const \ { \ @@ -15,7 +16,8 @@ Ptype::Read(FILE*f) \ *f >> v1; \ } -#define Xfer2(Ptype, Pbase, v1, v2) \ +#define Xfer2(id, Ptype, Pbase, v1, v2) \ +MSGTYPE(id, Ptype) \ void \ Ptype::Send(FILE*f) const \ { \ @@ -31,7 +33,8 @@ Ptype::Read(FILE*f) \ *f >> v2; \ } -#define Xfer3(Ptype, Pbase, v1, v2, v3) \ +#define Xfer3(id, Ptype, Pbase, v1, v2, v3) \ +MSGTYPE(id, Ptype) \ void \ Ptype::Send(FILE*f) const \ { \ |