From ba066c34dde204aa192d03a23a81356374d93731 Mon Sep 17 00:00:00 2001 From: chatty Date: Wed, 7 Apr 1993 11:50:31 +0000 Subject: Initial revision --- comm/MsgStream.h | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 comm/MsgStream.h (limited to 'comm/MsgStream.h') diff --git a/comm/MsgStream.h b/comm/MsgStream.h new file mode 100644 index 0000000..c2b8e1f --- /dev/null +++ b/comm/MsgStream.h @@ -0,0 +1,70 @@ +/* + * The Unix Channel + * + * by Michel Beaudouin-Lafon + * + * Copyright 1990-1993 + * Laboratoire de Recherche en Informatique (LRI) + * + * UchMessage streams + * + * $Id$ + * $CurLog$ + */ + +#ifndef MsgStream_H_ +#define MsgStream_H_ + +#include "Stream.h" +#include "ccu/SmartPointer.h" +#include "MsgBuffer.h" +class UchMessage; + +class UchMsgStream : public UchStream { +private: + +protected: + UchMsgBuffer InBuffer; + int InSize; + UchMsgBuffer OutBuffer; + int OutSize; +enum STATE { WAITING, GOT_TYPE, GOT_LENGTH, DONE}; +enum TYPE { MSG = 1, ASK, ANS, SYNC, ASYNC, OK }; + STATE State; + bool BufferedMessages; + UchMsgBuffer Buffered; + bool WaitingForAnswer; + bool WaitingReply; + int InLength; + byte InType; + bool Sync; + + void ProcessInput (UchMsgBuffer&, bool); + int ReadInput (); +public: + UchMsgStream (); + UchMsgStream (const UchMsgStream&); + UchMsgStream (UchAddress*, UchAddress*); + ~UchMsgStream (); + + void InputBuffer (int min, int grow, int max); + void OutputBuffer (int min, int grow, int max); +inline void FlushSize (int n) { OutSize = n; } + UchChannel* Copy () const; + void HandleRead (); + void HandleWrite (); + bool HandleSelect (); +inline bool GetSyncMode () { return Sync; } +inline void SetSyncMode (bool s) { Sync = s; Flush (); } +virtual bool NewMessage (UchMsgBuffer&, bool); +virtual void* ConvertAnswer (UchMsgBuffer&); +virtual void Delete (); + void Send (UchMessage&, bool = FALSE); + void* Ask (UchMessage&); + void Reply (UchMessage&); + void Flush (); + void Send (UchMsgBuffer&, bool = FALSE); +}; + +#endif /* MsgStream_H_ */ + -- cgit v1.1