home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / vsoup128.zip / newsrc.hh < prev    next >
C/C++ Source or Header  |  1997-01-20  |  3KB  |  83 lines

  1. //  $Id: newsrc.hh 1.9 1997/01/20 16:24:52 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 __NEWSRC_HH__
  14. #define __NEWSRC_HH__
  15.  
  16.  
  17. #include "mts.hh"
  18.  
  19.  
  20. #define NEWSRC_HASHSIZE   4095
  21.  
  22.  
  23. class TNewsrc {
  24. private:
  25.     //
  26.     //  article number range in the .newsrc file
  27.     //
  28.     typedef struct aRange {
  29.     struct aRange *next;    // pointer to next
  30.     long lo, hi;        // article number range */
  31.     } Range;
  32.  
  33.     //
  34.     //  newsgroup entry in the .newsrc file
  35.     //
  36.     typedef struct aGroup {
  37.     struct aGroup *next;        // pointer to next
  38.     struct aGroup *hashNext;        // pointer to next in hash list
  39.     const char *name;        // newsgroup name
  40.     Range *readList;        // list of read article ranges
  41.     char subscribed;        // subscribed flag
  42.     } Group, *pGroup;
  43.  
  44.     int fileChanged;                    // (internal) file has been changed (-> rewrite file)
  45.     pGroup groups;                      // list of .newsrc entries.
  46.     const char *filename;               // name of newsrc-file
  47.     TSemaphor sema;
  48.     const char *cacheGroupName;         // Cache for active group
  49.     pGroup cacheGroup;                  //          "
  50.     int fileRead;
  51.     pGroup addGroupP;
  52.  
  53.     pGroup hashTab[NEWSRC_HASHSIZE];
  54.     
  55. public:
  56.     TNewsrc( void );
  57.     ~TNewsrc();
  58.     TNewsrc( const TNewsrc &right );    // copy constructor not allowed !
  59.     operator = (const TNewsrc &right);  // assignment operator not allowed !
  60.  
  61.     int   readFile( const char *newsrcFile );
  62.     int   writeFile( void );
  63.     const char *grpFirst( void );
  64.     const char *grpNext( const char *prevGroupName );
  65.     int   grpSubscribed( const char *groupName );
  66.     int   grpExists( const char *groupName );
  67.     void  grpUnsubscribe( const char *groupName );
  68.     void  grpFixReadList( const char *groupName, long groupLo, long groupHi );
  69.     long  grpFirstUnread( const char *groupName, long groupLo );
  70.     int   artIsRead( const char *groupName, long artNum );
  71.     void  artMarkRead( const char *groupName, long artNum );
  72.     void  grpCatchup( const char *groupName, long groupLo, long groupHi, long numKeep );
  73.     void  *grpAdd( const char *groupName, int subscribe=0 );
  74.  
  75. private:
  76.     Range *getReadList( TFile &nrcFile );
  77.     void putReadList( TFile &fd, Range *head );
  78.     pGroup getGroupP( const char *groupName );
  79. };
  80.  
  81.  
  82. #endif   // __NEWSRC_HH__
  83.