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

  1. //  $Id: nntpcl.hh 1.17 1997/04/20 19:19:10 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@swol.de.
  6. //
  7. //  This file is part of VSoup for OS/2.  VSoup 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 __NNTPCL_HH__
  14. #define __NNTPCL_HH__
  15.  
  16.  
  17. #include <assert.h>
  18.  
  19. #include "mts.hh"
  20. #include "socket.hh"
  21.  
  22.  
  23. //--------------------------------------------------------------------------------
  24. //
  25. //  Diverse NNTP-Fkts zur Klasse zusammengefaßt
  26. //
  27. //  Problem dieser Klasse ist:
  28. //  - die Zustände können/müssen von extern gesetzt werden
  29. //
  30. class TNntp:  private TSocket {
  31. public:
  32.     enum Res   { nok,ok,killed,notavail };    // nok must be 0, ok 1
  33.     int artNotAvail;
  34.  
  35. public:
  36.     TNntp( void );
  37.     ~TNntp();
  38.     TNntp( const TNntp &right );          // copy constructor not allowed !
  39.     operator = (const TNntp &right);      // assignment operator not allowed !
  40.  
  41.     void  setHelper( void (*xref)(const char *xrefLine),
  42.              long (*killQ)(const char *groupName, const char *headerLine) );
  43.     Res  open( const char *nntpServer, const char *nntpUser,
  44.            const char *nntpPasswd, int nntpPort );
  45.     void close( int sendQuit=1 );
  46.     int  isReadOnly( void ) { return readOnly; }
  47.  
  48.     Res  getNewGroups( const char *nntpTimeFile, int changeFile );
  49.     Res  getOverview( long first, long last );
  50.     Res  setActGroup( const char *grpname, long &Cnt, long &lo, long &hi);
  51.     Res  nextArticle( long *next );
  52.     Res  postArticle( TFile &file, size_t bytes );
  53.     Res  getArticle( void );
  54.     Res  getXhdr( const char *headerField, long first, long last,
  55.           int (*callback)(int operation, const char *line) );
  56.  
  57.     TFileTmp &getTmpF( void ) { return tmpF; }
  58.  
  59.     void selectArticle( const char *grpname, long artNum=-1,
  60.             int doKill=0, long artFirst=-1, long artHi=-1 );
  61.     long article( void ) { return selArticle; }
  62.     long artFirst( void ) { return nntpArtFirst; };
  63.     long artHi( void ) { return nntpArtHi; };
  64.     long nntpArticle( void ) { return selNntpArticle; }
  65.     const char *groupName( void ) { return selGroup; }
  66.     const char *getLastErrMsg( void );
  67.  
  68. private:
  69.     int   readOnly;
  70.     TFileTmp tmpF;
  71.     const char *actGroup;                                 // group activated at nntp server
  72.     const char *selGroup;
  73.     long selArticle;
  74.     long selNntpArticle;
  75.     long nntpArtFirst;
  76.     long nntpArtHi;
  77.     int  killEnabled;
  78.     char lastErrMsg[1000];                                // buffer for last error msg
  79.     const char *user;
  80.     const char *passwd;
  81.  
  82.     void (*xrefHook)( const char *xrefLine );             // hook for xref processing
  83.     long (*killQHook)( const char *groupName,             // hook for killfile processing
  84.                const char *headerLine );  
  85.  
  86.     Res request( const char *request, char *reply, size_t replySize, int expReply );
  87.  
  88.     Res _getHead( void );
  89.     Res _getBody( void );
  90. };
  91.  
  92.     
  93. #endif   // __NNTPCL_HH__
  94.