1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
|
/*** dfparse.h - Definitions for Directives File parser
*
* Microsoft Confidential
* Copyright (C) Microsoft Corporation 1993-1994
* All Rights Reserved.
*
* Author:
* Benjamin W. Slivka
*
* History:
* 10-Aug-1993 bens Initial version
* 12-Aug-1993 bens Removed summary of directives file syntax
* 14-Aug-1993 bens Start working on parser proper
* 21-Aug-1993 bens Return HVARLIST from DFPInit()
* 22-Aug-1993 bens Fleshed out directive parsing
* 10-Feb-1994 bens Added SESSION asserts
* 14-Feb-1994 bens Added FCI context information
* 15-Feb-1994 bens Export DFPParseVarAssignment()
* 16-Feb-1994 bens Add file byte count totals to SESSION
* 21-Feb-1994 bens Add wrapper for stdout writes (lineOut)
* 08-Mar-1994 bens Control INF generation
* 30-Mar-1994 bens Keep track of file counts per folder/cabinet/disk
* 25-Apr-1994 bens Add customizable INF stuff
* 27-May-1994 bens Add CompressionXxxx support
* 28-Mar-1995 jeffwe Add ChecksumWidth variable
*/
#ifndef INCLUDED_DFPARSE
#define INCLUDED_DFPARSE 1
#include <time.h>
#include "error.h"
#include "textfile.h"
#include "variable.h"
#include "filelist.h"
#include "fileutil.h" // Get cbFILE_NAME_MAX
#include "command.h"
/*** HINF - handle to INF context
*
* NOTE: Duplication copied from INF.H to avoid chicken-and-egg definition
* problem. INF.H needs PSESSION, and PSESSION needs HINF!
*/
typedef void *HINF; /* hinf */
#ifdef BIT16
#include "chuck\fci.h"
#else // !BIT16
#include "chuck\nt\fci.h"
#endif // !BIT16
//** Random constants
//BUGBUG 21-Feb-1994 bens Hard-coded screen width
#define cchSCREEN_WIDTH 79 // Width of std screen - 1
//** Directive file limits
#define cbMAX_DF_LINE 256 // Maximum length of a directives file line
#define cbMAX_COMMAND_NAME 50 // Maxmimum length of a command name
/*** DDFMODE - Mode of INF generation indicated by DDF
*
*/
typedef enum {
ddfmodeBAD,
ddfmodeUNKNOWN,
ddfmodeUNIFIED,
ddfmodeRELATIONAL,
} DDFMODE; /* ddfmode */
/*** ACTION - What action Diamond command line requested
*
*/
typedef enum {
actBAD, // Invalid action
actHELP, // Show help
actFILE, // Compress a single file specification
actDIRECTIVE, // Process a directives file
} ACTION; /* act */
/*** VERBOSITY - Verbosity of debug output
*
*/
typedef enum {
vbNONE, // Minimal output during disk layout
vbSOME, // Only high-level status feedback
vbMORE, // Medium level status feedback
vbFULL, // Lots of feedback!
} VERBOSITY;
#ifdef ASSERT
#define sigSESSION MAKESIG('S','E','S','S') // SESSION signature
#define AssertSess(psess) AssertStructure(psess,sigSESSION);
#else // !ASSERT
#define AssertSess(psess)
#endif // !ASSERT
typedef struct {
#ifdef ASSERT
SIGNATURE sig; // structure signature sigSESSION
#endif
ACTION act; // Action to perform
HFILELIST hflistDirectives; // Directive file list, or single file
HVARLIST hvlist; // List of variables
HVARLIST hvlistPass2; // List of variables for pass 2
BOOL fPass2; // Doing pass 2 processing
int iDisk; // Current disk number
int iCabinet; // Current cabinet number
int iFolder; // Current folder number
long cbDiskLeft; // Count of bytes left on current disk
long cFilesInFolder; // Count of files in current folder
long cFilesInCabinet; // Count of files in current cabinet
long cFilesInDisk; // Count of files in current disk
long cbCabinetEstimate; // Estimated size of last cabinet
long cbClusterCabEst; // Custer size for estimated cabinet
int cErrors; // Count of errors encountered
int cWarnings; // Count of warnings encountered
VERBOSITY levelVerbose; // Verbosity level
HFCI hfci; // FCI context
ERF erf; // FCI error structure
BOOL fNoLineFeed; // TRUE if last printf did not have \n
int cchLastLine; // Length of last line written to stdout
ULONG cbTotalFileBytes; // Total bytes in files (from pass 1)
ULONG cbFileBytes; // Running total of bytes processed
ULONG cbFileBytesComp; // Running total of compressed bytes
long cFiles; // Total files in directives file(s)
long iCurrFile; // Index of file in DDF; 0 means no
// file copy commands have been
// processed, yet.
HINF hinf; // Inf file info
clock_t clkStart; // Time at start of run
clock_t clkEnd; // Time at end of run
BOOL fGenerateInf; // TRUE => generate INF file
USHORT setID; // Cabinet set ID for FCI
HGENLIST hglistFiles; // List of files in session
HGENERIC hgenFile; // Next file in hglistFiles to be placed
HGENERIC hgenFileLast; // Last file added to hglistFiles
DDFMODE ddfmode; // DDF INF generation mode
BOOL fExpectFileCommand; // TRUE => non-command DDF lines are
// file copy commands;
// FALSE => non-command DDF lines are
// INF reference commands
BOOL fCopyToInf; // TRUE => Copy lines to INF file
INFAREA inf; // if fCopyToInf is true, area of INF
// lines are being copied to.
BOOL fExplicitVarDefine; // TRUE => Vars must be .Define before .Set
BOOL fGetVerInfo; // TRUE => Get file version/lang info
BOOL fGetFileChecksum; // TRUE => Compute file checksum
BOOL fForceNewDisk; // TRUE => Force new disk next time we
// check; get's reset at that time
BOOL fRunSeen; // TRUE => /RUN flag already seen
char achCurrFile[cbFILE_NAME_MAX]; // Last file sent to FCIAddFile
char achMsg[cbMAX_DF_LINE*2]; // Message formatting buffer
char achBlanks[cchSCREEN_WIDTH+1]; // Buffer of spaces
char achCurrDiskLabel[cbFILE_NAME_MAX]; // Current readable disk label
char achCurrOutputDir[cbFILE_NAME_MAX]; // Current output disk directory
#ifndef REMOVE_CHICAGO_M6_HACK
int fFailOnIncompressible; // TRUE => Fail if a block is incompressible
#endif
} SESSION; /* sess */
typedef SESSION *PSESSION; /* psess */
/*** PFNDIRFILEPARSE - Function type for DFPParse call back
*** FNDIRFILEPARSE - macro to help define DFPParse call back function
*
* Entry:
* psess - Session
* pcmd - Command to process
* htfDF - Handle to directives file
* pszLine - Line from directives file
* iLine - Line number in directives file
* perr - ERROR structure
*
* Exit-Success:
* Returns TRUE; continue with parse.
*
* Exit-Failure:
* Returns FALSE; abort parse
* ERROR structure filled in with details of error.
*/
typedef (*PFNDIRFILEPARSE)(PSESSION psess,
PCOMMAND pcmd,
HTEXTFILE htfDF,
char *pszLine,
int iLine,
PERROR perr);
#define FNDIRFILEPARSE(fn) BOOL fn(PSESSION psess, \
PCOMMAND pcmd, \
HTEXTFILE htfDF, \
char *pszLine, \
int iLine, \
PERROR perr)
/*** DFPInit - initialize directive file parser
*
* Entry:
* psess - Session
* perr - ERROR structure
*
* Exit-Success:
* Returns HVARLIST of standard variables.
*
* Exit-Failure:
* Returns NULL; perr filled in with error.
*/
HVARLIST DFPInit(PSESSION psess, PERROR perr);
/*** DFPParse - Parse a directive file
*
* Entry:
* psess - Session
* htfDF - Open directive file to parse
* pfndfp - Function to call back after each line is parsed
* perr - ERROR structure
*
* Exit-Success:
* Returns TRUE; directives file parsed successfully
*
* Exit-Failure:
* Returns FALSE; perr filled in with error.
*/
BOOL DFPParse(PSESSION psess,
HTEXTFILE htfDF,
PFNDIRFILEPARSE pfndfp,
PERROR perr);
/*** DFPParseVarAssignment - Parse var=value string
*
* Entry:
* pcmd - Command to fill in after line is parsed
* psess - Session state
* pszArg - Start of argument string (var=value or var="value")
* perr - ERROR structure
*
* Exit-Success:
* Returns TRUE; pcmd filled in
*
* Exit-Failure:
* Returns FALSE; perr filled in with error.
*
* Syntax:
* var=value
* var="value"
*
* NOTES:
* (1) Any leading spaces (between = operator and first non-whitespace
* character) are removed from value, as are any trailing spaces.
* (2) No variable substition is performed by this function.
*
*/
BOOL DFPParseVarAssignment(PCOMMAND pcmd,
PSESSION psess,
char * pszArg,
PERROR perr);
/*** IsSpecialDiskSize - Check if supplied size is a standard one
*
* Entry:
* psess - Session state
* pszDiskSize - String with disk size
*
* Exit-Success:
* Returns non-zero disk size; Special size specified
*
* Exit-Failure:
* Returns 0; not a special size
*/
long IsSpecialDiskSize(PSESSION psess,char *pszDiskSize);
/*** BOOLfromPSZ - Get boolean from string value
*
* Entry:
* psz - String to convert (YES/NO/TRUE/FALSE/1/0)
*
* Exit-Success:
* Returns BOOL version of string (TRUE or FALSE)
*
* Exit-Failure:
* Returns -1; perr filled in
*/
BOOL BOOLfromPSZ(char *psz, PERROR perr);
/*** ChecksumWidthFromPSZ - Get Checksum Width from a string
*
* Entry:
* psz - String to parse
* perr - ERROR structure
*
* Exit-Success:
* Returns checksum width.
*
* Exit-Failure:
* Returns -1; perr filled in.
*/
int ChecksumWidthFromPSZ(char *psz, PERROR perr);
/*** CompTypeFromPSZ - Get Compression Type from a string
*
* Entry:
* psz - String to parse
* perr - ERROR structure
*
* Exit-Success:
* Returns compression type.
*
* Exit-Failure:
* Returns -1; perr filled in.
*/
int CompTypeFromPSZ(char *psz, PERROR perr);
/*** CompLevelFromPSZ - Get Compression Level from a string
*
* Entry:
* psz - String to parse
* perr - ERROR structure
*
* Exit-Success:
* Returns compression level.
*
* Exit-Failure:
* Returns -1; perr filled in.
*/
int CompLevelFromPSZ(char *psz, PERROR perr);
/*** CompMemoryFromPSZ - Get Compression Memory from a string
*
* Entry:
* psz - String to parse
* perr - ERROR structure
*
* Exit-Success:
* Returns compression memory.
*
* Exit-Failure:
* Returns -1; perr filled in.
*/
int CompMemoryFromPSZ(char *psz, PERROR perr);
/*** lineOut - write line to stdout with padding
*
* Entry:
* psess - Current session
* pszLine - Line to write
* fLineFeed - TRUE => write line feed (else, just carriage return)
*
* Exit:
* Line written to stdout
*/
void lineOut(PSESSION psess, char *pszLine, BOOL fLineFeed);
#endif // !INCLUDED_DFPARSE
|