home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C++ / Applications / Nuntius 1.2 / src / Nuntius / UNetAsciiProtocol.h < prev    next >
Encoding:
Text File  |  1994-03-06  |  1.3 KB  |  61 lines  |  [TEXT/MPS ]

  1. // Copyright © 1992 Peter Speck, speck@dat.ruc.dk. All rights reserved.
  2. // UNetAsciiProtocol.h
  3.  
  4. #define __UNETASCIIPROTOCOL__
  5.  
  6. class PTcpStream;
  7. class TProgress;
  8.  
  9. const long kCommandBufferSize = 256;
  10. const long kReturnLineBufferSize = 256;
  11.  
  12. class PNetAsciiProtocol
  13. {
  14.     public:
  15.     protected:
  16.         Ptr fRespondLineP; // c string
  17.         short fRespondCode;
  18.         
  19.         void SendCommand(char *cmd);
  20.         // cmd should not be CR/LF terminated, only text as C-string
  21.  
  22.         void GetRespondLine();
  23.         // returns status code
  24.         
  25.         void SendDotTerminatedText(Handle h);
  26.  
  27.         // The last char in the handle returned by GetDotTerminatedText
  28.         // is null (for optimized parsing)
  29.         Handle GetDotTerminatedText();
  30.         
  31.         void LogCommands(char *p);
  32.         
  33.         PNetAsciiProtocol();
  34.         void INetAsciiProtocol(long newsServerAddr, short port);
  35.         virtual ~PNetAsciiProtocol();
  36.  
  37.     private:
  38.         PTcpStream *fMacTcp;
  39.         Ptr fReceiveBufferP;
  40.         Ptr fCurrentReceiveP;
  41.         long fCurrentReceiveLeft;
  42.         long fProgressDelta;
  43.         
  44.         Ptr fTransmitBufferP;
  45.         Ptr fCurrentTransmitP;
  46.         long fCurrentTransmitChars;
  47.         
  48.         void FillReceiveBuffer();
  49.         void CopyChars(Handle h, long noChars, long &curSize);
  50.         char GetChar();
  51.         void GetLine();
  52.  
  53.         void FlushTransmitBuffer();
  54.         void SendChars(const void *p, long noChars);
  55.  
  56.         void UpdateProgress();
  57.  
  58.         long DoGetDotTerminatedText(Handle h);
  59.         void UpdateDotBuffer(Handle h, Ptr &destP);
  60. };
  61.