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