update for HEAD-2003091401
[reactos.git] / tools / cabman / dfp.h
1 /*
2  * COPYRIGHT:   See COPYING in the top level directory
3  * PROJECT:     ReactOS cabinet manager
4  * FILE:        tools/cabman/dfp.h
5  * PURPOSE:     Directive file parser header
6  */
7 #ifndef __DFP_H
8 #define __DFP_H
9
10 #include "cabinet.h"
11
12 typedef struct _CABINET_NAME {
13     struct _CABINET_NAME *Next;
14     unsigned long DiskNumber;
15     char Name[128];
16 } CABINET_NAME, *PCABINET_NAME;
17
18 typedef struct _DISK_NUMBER {
19     struct _DISK_NUMBER *Next;
20     unsigned long DiskNumber;
21     unsigned long Number;
22 } DISK_NUMBER, *PDISK_NUMBER;
23
24 typedef enum {
25     TokenUnknown,
26     TokenInteger,
27     TokenIdentifier,
28     TokenString,
29     TokenSpace,
30     TokenSemi,
31     TokenEqual,
32     TokenPeriod,
33     TokenBackslash,
34     TokenEnd,
35 } TOKEN;
36
37
38 typedef enum {
39     stCabinetName,
40     stCabinetNameTemplate,
41     stDiskLabel,
42     stDiskLabelTemplate,
43     stMaxDiskSize,
44     stInfFileName
45 } SETTYPE;
46
47
48 typedef enum {
49     ntDisk,
50     ntCabinet,
51     ntFolder,
52 } NEWTYPE;
53
54
55 /* Classes */
56
57 class CDFParser : public CCabinet {
58 public:
59     CDFParser();
60     virtual ~CDFParser();
61     unsigned long Load(char* FileName);
62     unsigned long Parse();
63     bool InfFileOnly;
64     bool DontGenerateInf;
65 private:
66     /* Event handlers */
67     virtual bool OnDiskLabel(unsigned long Number, char* Label);
68     virtual bool OnCabinetName(unsigned long Number, char* Name);
69
70     void WriteInfLine(char* InfLine);
71     bool SetDiskName(PCABINET_NAME *List, unsigned long Number, char* String);
72     bool GetDiskName(PCABINET_NAME *List, unsigned long Number, char* String);
73     bool SetDiskNumber(PDISK_NUMBER *List, unsigned long Number, unsigned long Value);
74     bool GetDiskNumber(PDISK_NUMBER *List, unsigned long Number, unsigned long* Value);
75     bool DoDiskLabel(unsigned long Number, char* Label);
76     void DoDiskLabelTemplate(char* Template);
77     bool DoCabinetName(unsigned long Number, char* Name);
78     void DoCabinetNameTemplate(char* Template);
79     void DoInfFileName(char* InfFileName);
80     unsigned long DoMaxDiskSize(bool NumberValid, unsigned long Number);
81     unsigned long SetupNewDisk();
82     unsigned long PerformSetCommand();
83     unsigned long PerformNewCommand();
84     unsigned long PerformInfBeginCommand();
85     unsigned long PerformInfEndCommand();
86     unsigned long PerformCommand();
87     unsigned long PerformFileCopy();
88     void SkipSpaces();
89     bool IsNextToken(TOKEN Token, bool NoSpaces);
90     bool ReadLine();
91     void NextToken();
92     /* Parsing */
93     bool FileLoaded;
94     FILEHANDLE FileHandle;
95     char* FileBuffer;
96     unsigned long FileBufferSize;
97     unsigned long CurrentOffset;
98     char Line[128];
99     unsigned long LineLength;
100     unsigned long CurrentLine;
101     unsigned long CurrentChar;
102     /* Token */
103     TOKEN CurrentToken;
104     unsigned long CurrentInteger;
105     char CurrentString[256];
106
107     /* State */
108     bool CabinetCreated;
109     bool DiskCreated;
110     bool FolderCreated;
111     /* Standard directive variable */
112     bool Cabinet;
113     unsigned long CabinetFileCountThreshold;
114     PCABINET_NAME CabinetName;
115     bool CabinetNameTemplateSet;
116     char CabinetNameTemplate[128];
117     bool InfFileNameSet;
118     char InfFileName[256];
119     bool Compress;
120     unsigned long CompressionType;
121     PCABINET_NAME DiskLabel;
122     bool DiskLabelTemplateSet;
123     char DiskLabelTemplate[128];
124     unsigned long FolderFileCountThreshold;
125     unsigned long FolderSizeThreshold;
126     unsigned long MaxCabinetSize;
127     unsigned long MaxDiskFileCount;
128     PDISK_NUMBER MaxDiskSize;
129     bool MaxDiskSizeAllSet;
130     unsigned long MaxDiskSizeAll;
131     unsigned long ReservePerCabinetSize;
132     unsigned long ReservePerDataBlockSize;
133     unsigned long ReservePerFolderSize;
134     char SourceDir[256];
135     FILEHANDLE InfFileHandle;
136     bool InfModeEnabled;
137 };
138
139 #endif /* __DFP_H */
140
141 /* EOF */