home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / vsoup128.zip / areas.hh < prev    next >
Text File  |  1997-01-20  |  3KB  |  89 lines

  1. //  $Id: areas.hh 1.12 1997/01/20 16:13:28 hardy Exp $
  2. //
  3. //  This progam/module was written by Hardy Griech based on ideas and
  4. //  pieces of code from Chin Huang (cthuang@io.org).  Bug reports should
  5. //  be submitted to rgriech@ibm.net.
  6. //
  7. //  This file is part of soup++ for OS/2.  Soup++ including this file
  8. //  is freeware.  There is no warranty of any kind implied.  The terms
  9. //  of the GNU Gernal Public Licence are valid for this piece of software.
  10. //
  11.  
  12.  
  13. #ifndef __AREAS_HH__
  14. #define __AREAS_HH__
  15.  
  16.  
  17. #include "mts.hh"
  18. #include "sema.hh"
  19.  
  20.  
  21. #define AREAS_FIFOSIZE  15
  22.  
  23.  
  24. class TAreas {
  25.  
  26. private:
  27.     TAreas( const TAreas &right );      // copy constructor not allowed !
  28.     operator = (const TAreas &right);   // assignment operator not allowed !
  29.     TAreas( void );                     // not allowed !
  30. public:
  31.     TAreas( const char *areasName, const char *msgNamePattern );
  32.     ~TAreas();
  33.  
  34.     int  msgWrite( const char *buf, int buflen );
  35.     int  msgPrintf( const char *fmt, ... ) __attribute__ ((format (printf, 2, 3)));
  36.     void closeAll( void );
  37.     void msgStart( const char *id, const char *format );
  38.     void msgStop( void );
  39.  
  40. protected:
  41.     const char *msgNamePattern;
  42.     TFile areasF;
  43.  
  44. private:
  45.     TFile msgF;
  46.     int  msgCounter;
  47.     int  msgStarted;
  48.     long msgLenPos;
  49.  
  50.     struct {
  51.     const char *id;
  52.     const char *format;
  53.     const char *filename;
  54.     } fifo[AREAS_FIFOSIZE];
  55.     int fifoNext;
  56.     int fifoMsgF;
  57. };
  58.     
  59.  
  60. class TAreasMail: public TAreas  {
  61. private:
  62.     TAreasMail( void );                         // not allowed !
  63.     TAreasMail( const TAreasMail &right );      // copy constructor not allowed !
  64.     operator = (const TAreasMail &right);       // assignment operator not allowed !
  65. public:
  66.     TAreasMail( const char *areasName, const char *msgNamePattern ); ///: TAreas(areasName,msgNamePattern) {}
  67.     ~TAreasMail();
  68.     void mailOpen( const char *title );
  69.     void mailStart( int doEcho=0 );
  70.     void mailStop( void );
  71.     int  mailPrintf( const char *fmt, ... ) __attribute__ ((format (printf, 2, 3)));
  72.     int  mailPrintf1( int doEcho, const char *fmt, ... ) __attribute__ ((format (printf, 3, 4)));
  73.     void mailException( void ) { mailExcept = 1; }
  74.     void closeAll( void );
  75.     void forceMail( void ) { mailForced = 1; }
  76. private:
  77.     int mailStarted;
  78.     int mailFirstLine;
  79.     int mailForced;
  80.     int mailExcept;
  81.     TFile mailF;
  82.     const char *mailName;
  83.     int conEcho;
  84.     TSemaphor mpSema;
  85. };
  86.  
  87.  
  88. #endif   // __AREAS_HH__
  89.