1 /*****************************************************************************/ 2 /* */ 3 /* (C) Copyright 1995-1997 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 // FBlib.Hpp 100 22 23 #ifndef _FBlib_HPP_ 24 #define _FBlib_HPP_ 25 26 #ifdef __OS2__ 27 #define INCL_DOS 28 #include <os2.h> 29 #endif 30 31 #include <stdlib.h> 32 #include <huskylib/cvtdate.h> 33 #include <apgenlib.hpp> 34 35 #pragma pack (1) 36 37 #define FBBSLSIZE 1024 // size of files.bbs line buffer 38 39 class namelist; 40 class FBD; 41 class ANumLst; 42 struct AreaData; 43 struct FIDX; 44 struct _area; 45 46 typedef void (*DupeF) (FIDX *p, BOOL included); 47 typedef void (*ShowF) (char *AreaName, char *AreaPath, int Code); 48 49 // FileBase function, flags parameter 50 51 #define _UniqueDmpLine_ 0x0001 // Change '\n' to ' ' in .DMP 52 53 54 // for ShowF, BuildArea, OpenArea 55 #define _Error_ -3 56 #define _BbsPathNotFound_ -2 // for files.* 57 #define _FilePathNotFound_ -1 // for area files 58 #define _OK_ 0 59 #define _BegProc_ 1 // Processing begun (normally) 60 #define _ReadOnly_ 2 61 #define _WriteProtected_ 3 62 #define _NoFilesBbs_ 4 63 64 // for Build action 65 66 #define _FBUpdate_ 0x0001 // update main index, otherwise rebuild 67 #define _FBNoLocBase_ 0x0002 // don't write local dat/dmp/idx 68 #define _FBMarkedOnly_ 0x0004 // Build marked areas only, even with Rebuild 69 #define _FBAutoDate_ 0x0008 // Date and Size must be read from dir (by default) 70 #define _FBNewAsMarked_ 0x0010 // Consider areas with FILESBBS newer 71 // than FILESIDX as marked. RO/CDROM skipped. 72 #define _FBSkipSlow_ 0x0020 // Skip areas of type Slow (CD etc.) and 73 // build all others ! 74 75 // for flag in AreaAddEntry 76 77 78 #define FF_FILE 0x01 /* Entry is a filename */ 79 #define FF_NOTIME 0x10 /* Don't deduct file from user's time limit */ 80 #define FF_NOBYTES 0x20 /* Don't deduce file from user's DL bytes limit */ 81 82 83 struct FAH; 84 85 86 class FileBase { 87 private: 88 namelist *AreaNameList; 89 namelist *AreaPathList; 90 FBD *fbd; 91 AreaData *ad; 92 93 char cont; // continuation character 94 int cpos; // spaces before cont char 95 word flags; // special flags 96 97 BOOL AreaNameMatch (const char *areaname); 98 BOOL AreaPathMatch (const char *areapath); 99 int DmpWrite (const char *text, dword *ofs); 100 // Writes text to files.dmp, stores offset into ofs. 101 // returns 0 on success 102 int BuildArea (word areanum, const char *filepath, const char *filesbbs, 103 const char *acs, word fattr, sword date_style, 104 BOOL NoLocBase = FALSE); 105 // Builds files.dat .dmp .idx, stores data for maxfiles.idx 106 // NoLocBase can be passed along to AreaOpen 107 // returns _OK_, _BbsPathNotFound_, _FilePathNotFound_, 108 // _ReadOnly_, _WriteProtected_, _Error_ 109 BOOL IsBuild (const FAH *fahp, word action); 110 // return TRUE if area must be built. 111 112 public: 113 FileBase (char cont = ' ', // cont. character 114 int cpos = 31, // cont. column, -1 to disable 115 word flags = 0 // Special flags. 116 ); 117 ~FileBase (void); 118 int AreaOpen (word areanum, const char *filesbbs, 119 BOOL NoLocBase = FALSE); 120 // areanum: number of area in area.dat 121 // filesbbs: "<path>\<name>" (can have an extension) 122 // NoLocBase: Do Not Build local DAT/DMP/IDX 123 // Opens files.dat and files.dmp and prepares for addentry 124 // returns _OK_, _BbsPathNotFound_, _ReadOnly_, 125 // _WriteProtected_, _Error_ 126 int AreaAddEntry (const char *filename, word flag, 127 const _stamp *cre_date, const _stamp *mod_date, 128 dword size, const char *desc, const char *acs, 129 const char *path = NULL); 130 // Appends files.dat and files.dmp 131 // Stores file data for later index build 132 // cre_date is the date of creation (upload) 133 // mod_date is the date of last write (dir) 134 // path optionally indicates an override path 135 // Returns 0 on success 136 int AreaClose (void); 137 // Closes files.dat and files.dmp 138 // Builds the current area index from stored data 139 // Returns 0 on success 140 void AddName (const char *areaname, const char *AreaDat = NULL); 141 // area tag to be rebuilt 142 // AreaDat != NULL -> add the upload path of areaname 143 void AddPath (const char *areapath); // area path to be rebuilt 144 int Build (const char *AreaDat, word action, const char *FullIdx, 145 const char *NoDupeIdx = NULL, ShowF sf = NULL, 146 DupeF df = NULL); 147 // NoDupeIdx is the full pathname for the file-request, no dupes, 148 // Index file. In case of dupes, it contains the file in the 149 // lowest area number. 150 // df is a function called for each Dupe found while building NoDupeIdx 151 // sf is a function called for each area processed 152 // AreaDat && update -> Build marked areas, update main index 153 // AreaDat && !update -> Build all areas, rebuild main index 154 // AreaDat,!update,MarkedOnly -> Build marked areas, rebuild index 155 // Stored data is always used in addition to the built areas. 156 // !AreaDat -> use stored data only, rebuild/update main index 157 // returns 0 on success 158 }; 159 160 161 162 163 #endif 164