1 /*****************************************************************************/
2 /*                                                                           */
3 /*                 (C) Copyright 1992-1996  Alberto Pasquale                 */
4 /*                                                                           */
5 /*                   A L L   R I G H T S   R E S E R V E D                   */
6 /*                                                                           */
7 /*****************************************************************************/
8 /*                                                                           */
9 /* This source code is NOT in the public domain and it CANNOT be used or     */
10 /* distributed without written permission from the author.                   */
11 /*                                                                           */
12 /*****************************************************************************/
13 /*                                                                           */
14 /* How to contact the author:  Alberto Pasquale of 2:332/504@fidonet         */
15 /*                             Viale Verdi 106                               */
16 /*                             41100 Modena                                  */
17 /*                             Italy                                         */
18 /*                                                                           */
19 /*****************************************************************************/
20 
21 // DayDir.hpp
22 
23 #ifndef DAYDIR_HPP
24 #define DAYDIR_HPP
25 
26 #include "defines.hpp"
27 #include <time.h>
28 
29 class InpncBlk;
30 
31 
32 #define NODELIST 0   // for Select
33 #define ARCLIST  1
34 #define NODEDIFF 2
35 #define ARCDIFF  3
36 
37 #define DD_SIZE 400   // size of dd_data array
38 
39 
40 struct dd_data {
41     short day;    // number of day, resolved for circular order
42     char  first;  // initial character, don't care for 3 digit ext
43 };
44 
45 
46 class DAYDIR {      // for variable numeric extensions
47   private:
48     int  Select;
49     char *mask;
50     BOOL arc;
51     char *fname;
52 
53     int  keep;
54     BOOL VarList;
55     time_t OldTime;
56 
57     int firstnew;       // index to first new entry
58     int nfound;         // number of entries found
59     dd_data *dir;       // pointer to array of directory data
60     time_t latestime;   // Unix time of latest file in above dir
61     time_t fixtime;     // Unix time of latest fixed extension
62     char *fixext;       // Pointer to extension of latest fixed extension
63     BOOL SrcNodeMissing;  // TRUE when Latest == -1 in constructor
64     int FutDiff;        // first nodediff that caused a day mismatch, if != 0
65     int FirstKeep (int keep);   // returns index to first entry to be kept; keep is the number of items to be kept (for each archiver)
66     char *Name (int dd_idx=-1); // returns pointer to static area with full resolved name; if dd_idx omitted, fixext is taken
67     int FindNew (BOOL first); // return first/next new index
68     void CommInit (int Latest = -1);
69 
70   public:
71     DAYDIR (int Select, InpncBlk *cib, int Latest=-1, int FutDiff = 0);
72                 // FutDiff is used for NodeDiff/ArcDiff
73                 // FutDiff is day of first nodediff that caused a day mismatch
74     DAYDIR (int Select, char *List, int nKeep = 1);
75     ~DAYDIR (void);
76 
77     BOOL NewAvail (void);   // returns TRUE if something new available
78     char *FindNewName (BOOL first=FALSE);  // returns first/next new name
79     int  FindNewDay (BOOL first=FALSE);   // returns first/next new day
80     char *LatestName ();    // Returns name of latest file
81     int  LatestDay (void);  // Returns day of latest file, -1 if none
82     void KillOld (void);    // kills all files older than configured
83     void KillAll (void);    // kills all files
84 };
85 
86 
87 #endif
88