]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrCompiler.cpp
Sync all bug fixes between EDK1.04 and EDK1.06 into EdkCompatibilityPkg.
[mirror_edk2.git] / EdkCompatibilityPkg / Sample / Tools / Source / UefiVfrCompile / VfrCompiler.cpp
CommitLineData
5b19df7f
LG
1/*++\r
2\r
4b1e1121
HT
3Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
4This program and the accompanying materials\r
5b19df7f
LG
5are licensed and made available under the terms and conditions of the BSD License\r
6which accompanies this distribution. The full text of the license may be found at\r
7http://opensource.org/licenses/bsd-license.php\r
8\r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11\r
12Module Name:\r
13\r
3e99020d 14 VfrCompiler.cpp\r
5b19df7f
LG
15\r
16Abstract:\r
17\r
18--*/\r
19\r
95d675b5 20#include "stdio.h"\r
21#include "string.h"\r
22#include "process.h"\r
23#include "VfrCompiler.h"\r
24\r
25\r
26VOID\r
27CVfrCompiler::SET_RUN_STATUS (\r
28 IN COMPILER_RUN_STATUS Status\r
29 )\r
30{\r
31 mRunStatus = Status;\r
32}\r
33\r
34BOOLEAN\r
35CVfrCompiler::IS_RUN_STATUS (\r
36 IN COMPILER_RUN_STATUS Status\r
37 )\r
38{\r
39 return mRunStatus == Status;\r
40}\r
41\r
42VOID\r
43CVfrCompiler::OptionInitialization (\r
3e99020d 44 IN INT32 Argc,\r
95d675b5 45 IN INT8 **Argv\r
46 )\r
47{\r
48 INT32 Index;\r
49\r
50 mOptions.VfrFileName[0] = '\0';\r
51 mOptions.RecordListFile[0] = '\0';\r
52 mOptions.CreateRecordListFile = FALSE;\r
53 mOptions.CreateIfrPkgFile = FALSE;\r
54 mOptions.PkgOutputFileName[0] = '\0';\r
55 mOptions.COutputFileName[0] = '\0';\r
56 mOptions.OutputDirectory[0] = '\0';\r
57 mOptions.PreprocessorOutputFileName[0] = '\0';\r
58 mOptions.VfrBaseFileName[0] = '\0';\r
59 mOptions.IncludePaths = NULL;\r
3e99020d 60 mOptions.SkipCPreprocessor = FALSE;\r
95d675b5 61 mOptions.CPreprocessorOptions = NULL;\r
62\r
63 for (Index = 1; (Index < Argc) && (Argv[Index][0] == '-'); Index++) {\r
64 if ((_stricmp(Argv[Index], "-?") == 0) || (_stricmp(Argv[Index], "-h") == 0)) {\r
65 Usage ();\r
66 SET_RUN_STATUS (STATUS_DEAD);\r
67 return;\r
68 } else if (_stricmp(Argv[Index], "-l") == 0) {\r
69 mOptions.CreateRecordListFile = TRUE;\r
70 gCIfrRecordInfoDB.TurnOn ();\r
71 } else if (_stricmp(Argv[Index], "-i") == 0) {\r
72 Index++;\r
73 if ((Index >= Argc) || (Argv[Index][0] == '-')) {\r
3e99020d 74 printf ("%s -i - missing path argument\n", UTILITY_NAME);\r
95d675b5 75 goto Fail;\r
76 }\r
77\r
78 AppendIncludePath(Argv[Index]);\r
79 } else if (_stricmp(Argv[Index], "-od") == 0) {\r
80 Index++;\r
81 if ((Index >= Argc) || (Argv[Index][0] == '-')) {\r
3e99020d 82 printf ("%s -od - missing output directory name\n", UTILITY_NAME);\r
95d675b5 83 goto Fail;\r
84 }\r
85 strcpy (mOptions.OutputDirectory, Argv[Index]);\r
3e99020d 86 strcat (mOptions.OutputDirectory, "\\");\r
95d675b5 87 } else if (_stricmp(Argv[Index], "-ibin") == 0) {\r
88 mOptions.CreateIfrPkgFile = TRUE;\r
89 } else if (_stricmp(Argv[Index], "-nostrings") == 0) {\r
3e99020d
LG
90 } else if (_stricmp(Argv[Index], "-nopp") == 0) {\r
91 mOptions.SkipCPreprocessor = TRUE;\r
95d675b5 92 } else if (_stricmp(Argv[Index], "-ppflag") == 0) {\r
93 Index++;\r
94 if ((Index >= Argc) || (Argv[Index][0] == '-')) {\r
3e99020d 95 printf ("%s -od - missing C-preprocessor argument\n", UTILITY_NAME);\r
95d675b5 96 goto Fail;\r
97 }\r
98\r
99 AppendCPreprocessorOptions (Argv[Index]);\r
100 } else {\r
3e99020d 101 printf ("%s unrecognized option %s\n", UTILITY_NAME, Argv[Index]);\r
95d675b5 102 Usage ();\r
103 goto Fail;\r
104 }\r
105 }\r
106\r
107 if (Index != Argc - 1) {\r
3e99020d 108 printf ("%s must specify VFR file name\n", UTILITY_NAME);\r
95d675b5 109 Usage ();\r
110 goto Fail;\r
111 } else {\r
112 strcpy (mOptions.VfrFileName, Argv[Index]);\r
113 }\r
114\r
115 if (SetBaseFileName() != 0) {\r
116 goto Fail;\r
117 }\r
118 if (SetPkgOutputFileName () != 0) {\r
119 goto Fail;\r
120 }\r
121 if (SetCOutputFileName() != 0) {\r
122 goto Fail;\r
123 }\r
124 if (SetPreprocessorOutputFileName () != 0) {\r
125 goto Fail;\r
126 }\r
127 if (SetRecordListFileName () != 0) {\r
128 goto Fail;\r
129 }\r
130 return;\r
131\r
132Fail:\r
133 SET_RUN_STATUS (STATUS_FAILED);\r
134\r
135 mOptions.VfrFileName[0] = '\0';\r
136 mOptions.RecordListFile[0] = '\0';\r
137 mOptions.CreateRecordListFile = FALSE;\r
138 mOptions.CreateIfrPkgFile = FALSE;\r
139 mOptions.PkgOutputFileName[0] = '\0';\r
140 mOptions.COutputFileName[0] = '\0';\r
141 mOptions.OutputDirectory[0] = '\0';\r
142 mOptions.PreprocessorOutputFileName[0] = '\0';\r
143 mOptions.VfrBaseFileName[0] = '\0';\r
144 if (mOptions.IncludePaths != NULL) {\r
145 delete mOptions.IncludePaths;\r
146 mOptions.IncludePaths = NULL;\r
3e99020d 147 }\r
95d675b5 148 if (mOptions.CPreprocessorOptions != NULL) {\r
149 delete mOptions.CPreprocessorOptions;\r
150 mOptions.CPreprocessorOptions = NULL;\r
151 }\r
152}\r
153\r
154VOID\r
155CVfrCompiler::AppendIncludePath (\r
156 IN INT8 *PathStr\r
157 )\r
158{\r
159 UINT32 Len = 0;\r
160 INT8 *IncludePaths = NULL;\r
161\r
162 Len = strlen (" -I ") + strlen (PathStr) + 1;\r
163 if (mOptions.IncludePaths != NULL) {\r
164 Len += strlen (mOptions.IncludePaths);\r
165 }\r
166 IncludePaths = new INT8[Len];\r
167 if (IncludePaths == NULL) {\r
3e99020d 168 printf ("%s memory allocation failure\n", UTILITY_NAME);\r
95d675b5 169 return;\r
170 }\r
171 IncludePaths[0] = '\0';\r
172 if (mOptions.IncludePaths != NULL) {\r
173 strcat (IncludePaths, mOptions.IncludePaths);\r
174 }\r
175 strcat (IncludePaths, " -I ");\r
176 strcat (IncludePaths, PathStr);\r
177 if (mOptions.IncludePaths != NULL) {\r
178 delete mOptions.IncludePaths;\r
179 }\r
180 mOptions.IncludePaths = IncludePaths;\r
181}\r
182\r
183VOID\r
184CVfrCompiler::AppendCPreprocessorOptions (\r
185 IN INT8 *Options\r
186 )\r
187{\r
188 UINT32 Len = 0;\r
189 INT8 *Opt = NULL;\r
190\r
191 Len = strlen (Options) + strlen (" ") + 1;\r
192 if (mOptions.CPreprocessorOptions != NULL) {\r
193 Len += strlen (mOptions.CPreprocessorOptions);\r
194 }\r
195 Opt = new INT8[Len];\r
196 if (Opt == NULL) {\r
3e99020d 197 printf ("%s memory allocation failure\n", UTILITY_NAME);\r
95d675b5 198 return;\r
199 }\r
200 Opt[0] = 0;\r
201 if (mOptions.CPreprocessorOptions != NULL) {\r
202 strcat (Opt, mOptions.CPreprocessorOptions);\r
203 }\r
204 strcat (Opt, " ");\r
205 strcat (Opt, Options);\r
206 if (mOptions.CPreprocessorOptions != NULL) {\r
207 delete mOptions.CPreprocessorOptions;\r
208 }\r
209 mOptions.CPreprocessorOptions = Opt;\r
210}\r
211\r
212INT8\r
213CVfrCompiler::SetBaseFileName (\r
214 VOID\r
215 )\r
216{\r
217 INT8 *pFileName, *pPath, *pExt;\r
218\r
219 if (mOptions.VfrFileName[0] == '\0') {\r
220 return -1;\r
221 }\r
222\r
223 pFileName = mOptions.VfrFileName;\r
3e99020d
LG
224 while (\r
225 ((pPath = strchr (pFileName, '\\')) != NULL) ||\r
226 ((pPath = strchr (pFileName, '/')) != NULL)\r
227 )\r
228 {\r
95d675b5 229 pFileName = pPath + 1;\r
230 }\r
231\r
232 if (pFileName == NULL) {\r
233 return -1;\r
234 }\r
235\r
236 if ((pExt = strchr (pFileName, '.')) == NULL) {\r
237 return -1;\r
238 }\r
239\r
240 strncpy (mOptions.VfrBaseFileName, pFileName, pExt - pFileName);\r
241 mOptions.VfrBaseFileName[pExt - pFileName] = '\0';\r
242\r
243 return 0;\r
244}\r
245\r
246INT8\r
247CVfrCompiler::SetPkgOutputFileName (\r
248 VOID\r
249 )\r
250{\r
251 if (mOptions.VfrBaseFileName[0] == '\0') {\r
252 return -1;\r
253 }\r
254\r
255 strcpy (mOptions.PkgOutputFileName, mOptions.OutputDirectory);\r
256 strcat (mOptions.PkgOutputFileName, mOptions.VfrBaseFileName);\r
257 strcat (mOptions.PkgOutputFileName, VFR_PACKAGE_FILENAME_EXTENSION);\r
258\r
259 return 0;\r
260}\r
261\r
262INT8\r
263CVfrCompiler::SetCOutputFileName (\r
264 VOID\r
265 )\r
266{\r
267 if (mOptions.VfrBaseFileName[0] == '\0') {\r
268 return -1;\r
269 }\r
270\r
271 strcpy (mOptions.COutputFileName, mOptions.OutputDirectory);\r
272 strcat (mOptions.COutputFileName, mOptions.VfrBaseFileName);\r
273 strcat (mOptions.COutputFileName, ".c");\r
274\r
275 return 0;\r
276}\r
277\r
278INT8\r
279CVfrCompiler::SetPreprocessorOutputFileName (\r
280 VOID\r
281 )\r
282{\r
283 if (mOptions.VfrBaseFileName[0] == '\0') {\r
284 return -1;\r
285 }\r
286\r
287 strcpy (mOptions.PreprocessorOutputFileName, mOptions.OutputDirectory);\r
288 strcat (mOptions.PreprocessorOutputFileName, mOptions.VfrBaseFileName);\r
289 strcat (mOptions.PreprocessorOutputFileName, VFR_PREPROCESS_FILENAME_EXTENSION);\r
290\r
291 return 0;\r
292}\r
293\r
294INT8\r
295CVfrCompiler::SetRecordListFileName (\r
296 VOID\r
297 )\r
298{\r
299 if (mOptions.VfrBaseFileName[0] == '\0') {\r
300 return -1;\r
301 }\r
302\r
303 strcpy (mOptions.RecordListFile, mOptions.OutputDirectory);\r
304 strcat (mOptions.RecordListFile, mOptions.VfrBaseFileName);\r
305 strcat (mOptions.RecordListFile, VFR_RECORDLIST_FILENAME_EXTENSION);\r
306\r
307 return 0;\r
308}\r
309\r
310CVfrCompiler::CVfrCompiler (\r
3e99020d 311 IN INT32 Argc,\r
95d675b5 312 IN INT8 **Argv\r
313 )\r
314{\r
315 mPreProcessCmd = PREPROCESSOR_COMMAND;\r
316 mPreProcessOpt = PREPROCESSOR_OPTIONS;\r
317\r
318 OptionInitialization(Argc, Argv);\r
319\r
320 if ((IS_RUN_STATUS(STATUS_FAILED)) || (IS_RUN_STATUS(STATUS_DEAD))) {\r
321 return;\r
322 }\r
323\r
324 SET_RUN_STATUS(STATUS_INITIALIZED);\r
325}\r
326\r
327CVfrCompiler::~CVfrCompiler (\r
328 VOID\r
329 )\r
330{\r
331 if (mOptions.IncludePaths != NULL) {\r
332 delete mOptions.IncludePaths;\r
333 mOptions.IncludePaths = NULL;\r
334 }\r
335\r
336 if (mOptions.CPreprocessorOptions != NULL) {\r
337 delete mOptions.CPreprocessorOptions;\r
338 mOptions.CPreprocessorOptions = NULL;\r
339 }\r
340\r
341 SET_RUN_STATUS(STATUS_DEAD);\r
342}\r
343\r
3e99020d 344VOID\r
95d675b5 345CVfrCompiler::Usage (\r
346 VOID\r
347 )\r
348{\r
3e99020d
LG
349 int Index;\r
350 const char *Str[] = {\r
351 UTILITY_NAME" "UTILITY_VERSION" - Intel UEFI VFR Compiler Utility",\r
352 " Copyright (C), 2004 - 2008 Intel Corporation",\r
353#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )\r
354 " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,\r
355#endif\r
356 "",\r
357 "Usage:",\r
358 " "UTILITY_NAME" [OPTION] VFRFILE",\r
359 "Description:",\r
360 " Compile VFRFILE.",\r
361 "Options:",\r
362 " -? or -h print this help",\r
363 " -l create an output IFR listing file",\r
364 " -i IncPath add IncPath to the search path for VFR included files",\r
365 " -od OutputDir deposit all output files to directory OutputDir (default=cwd)",\r
366 " -ibin create an IFR HII pack file",\r
367 " -ppflag CFlags pass Flags as C-preprocessor-flag",\r
368 " -v or -version print version information",\r
95d675b5 369 NULL\r
3e99020d
LG
370 };\r
371\r
372 for (Index = 0; Str[Index] != NULL; Index++) {\r
373 fprintf (stdout, "%s\n", Str[Index]);\r
95d675b5 374 }\r
375}\r
376\r
3e99020d 377\r
95d675b5 378VOID\r
379CVfrCompiler::PreProcess (\r
380 VOID\r
381 )\r
382{\r
383 FILE *pVfrFile = NULL;\r
384 UINT32 CmdLen = 0;\r
385 INT8 *PreProcessCmd = NULL;\r
386\r
387 if (!IS_RUN_STATUS(STATUS_INITIALIZED)) {\r
388 goto Fail;\r
389 }\r
390\r
3e99020d
LG
391 if (mOptions.SkipCPreprocessor == TRUE) {\r
392 goto Out;\r
393 }\r
394\r
95d675b5 395 if ((pVfrFile = fopen (mOptions.VfrFileName, "r")) == NULL) {\r
3e99020d 396 printf ("%s could not open input VFR file - %s\n", UTILITY_NAME, mOptions.VfrFileName);\r
95d675b5 397 goto Fail;\r
398 }\r
399 fclose (pVfrFile);\r
400\r
401 CmdLen = strlen (mPreProcessCmd) + strlen (mPreProcessOpt) + \r
402 strlen (mOptions.VfrFileName) + strlen (mOptions.PreprocessorOutputFileName);\r
403 if (mOptions.CPreprocessorOptions != NULL) {\r
404 CmdLen += strlen (mOptions.CPreprocessorOptions);\r
405 }\r
406 if (mOptions.IncludePaths != NULL) {\r
407 CmdLen += strlen (mOptions.IncludePaths);\r
408 }\r
409\r
410 PreProcessCmd = new INT8[CmdLen + 10];\r
411 if (PreProcessCmd == NULL) {\r
3e99020d 412 printf ("%s could not allocate memory\n", UTILITY_NAME);\r
95d675b5 413 goto Fail;\r
414 }\r
415 strcpy (PreProcessCmd, mPreProcessCmd), strcat (PreProcessCmd, " ");\r
416 strcat (PreProcessCmd, mPreProcessOpt), strcat (PreProcessCmd, " ");\r
417 if (mOptions.IncludePaths != NULL) {\r
418 strcat (PreProcessCmd, mOptions.IncludePaths), strcat (PreProcessCmd, " ");\r
419 }\r
420 if (mOptions.CPreprocessorOptions != NULL) {\r
421 strcat (PreProcessCmd, mOptions.CPreprocessorOptions), strcat (PreProcessCmd, " ");\r
422 }\r
423 strcat (PreProcessCmd, mOptions.VfrFileName), strcat (PreProcessCmd, " > ");\r
424 strcat (PreProcessCmd, mOptions.PreprocessorOutputFileName);\r
425\r
426 if (system (PreProcessCmd) != 0) {\r
3e99020d 427 printf ("%s failed to spawn C preprocessor on VFR file \n\t - %s\n", UTILITY_NAME, PreProcessCmd);\r
95d675b5 428 goto Fail;\r
429 }\r
430\r
431 delete PreProcessCmd;\r
3e99020d
LG
432\r
433Out:\r
95d675b5 434 SET_RUN_STATUS (STATUS_PREPROCESSED);\r
435 return;\r
436\r
437Fail:\r
438 if (!IS_RUN_STATUS(STATUS_DEAD)) {\r
439 SET_RUN_STATUS (STATUS_FAILED);\r
440 }\r
441 delete PreProcessCmd;\r
442}\r
443\r
444extern UINT8 VfrParserStart (IN FILE *);\r
445\r
446VOID\r
447CVfrCompiler::Compile (\r
448 VOID\r
449 )\r
450{\r
3e99020d
LG
451 FILE *pInFile = NULL;\r
452 INT8 *InFileName = NULL;\r
95d675b5 453\r
454 if (!IS_RUN_STATUS(STATUS_PREPROCESSED)) {\r
455 goto Fail;\r
456 }\r
457\r
3e99020d
LG
458 InFileName = (mOptions.SkipCPreprocessor == TRUE) ? mOptions.VfrFileName : mOptions.PreprocessorOutputFileName;\r
459\r
460 gCVfrErrorHandle.SetInputFile (InFileName);\r
461\r
462 if ((pInFile = fopen (InFileName, "r")) == NULL) {\r
463 printf ("%s failed to open input file - %s\n", UTILITY_NAME, InFileName);\r
95d675b5 464 goto Fail;\r
465 }\r
466\r
3e99020d 467 if (VfrParserStart (pInFile) != 0) {\r
95d675b5 468 goto Fail;\r
469 }\r
470\r
3e99020d 471 fclose (pInFile);\r
95d675b5 472\r
473 if (gCFormPkg.HavePendingUnassigned () == TRUE) {\r
474 gCFormPkg.PendingAssignPrintAll ();\r
475 goto Fail;\r
476 }\r
477\r
478 SET_RUN_STATUS (STATUS_COMPILEED);\r
479 return;\r
480\r
481Fail:\r
482 if (!IS_RUN_STATUS(STATUS_DEAD)) {\r
3e99020d 483 printf ("%s compile error!\n", UTILITY_NAME);\r
95d675b5 484 SET_RUN_STATUS (STATUS_FAILED);\r
485 }\r
3e99020d
LG
486 if (pInFile != NULL) {\r
487 fclose (pInFile);\r
95d675b5 488 }\r
489}\r
490\r
491VOID\r
492CVfrCompiler::GenBinary (\r
493 VOID\r
494 )\r
495{\r
496 FILE *pFile = NULL;\r
497\r
498 if (!IS_RUN_STATUS(STATUS_COMPILEED)) {\r
499 goto Fail;\r
500 }\r
501\r
502 if (mOptions.CreateIfrPkgFile == TRUE) {\r
503 if ((pFile = fopen (mOptions.PkgOutputFileName, "wb")) == NULL) {\r
3e99020d 504 printf ("can not open %s\n", mOptions.PkgOutputFileName);\r
95d675b5 505 goto Fail;\r
506 }\r
507 if (gCFormPkg.BuildPkg (pFile) != VFR_RETURN_SUCCESS) {\r
508 fclose (pFile);\r
509 goto Fail;\r
510 }\r
511 fclose (pFile);\r
512 }\r
513\r
514 SET_RUN_STATUS (STATUS_GENBINARY);\r
515 return;\r
516\r
517Fail:\r
518 if (!IS_RUN_STATUS(STATUS_DEAD)) {\r
519 SET_RUN_STATUS (STATUS_FAILED);\r
520 }\r
521}\r
522\r
523static const char *gSourceFileHeader[] = {\r
524 "//",\r
525 "// DO NOT EDIT -- auto-generated file",\r
526 "//",\r
527 "// This file is generated by the vfrcompiler utility",\r
528 "//",\r
529 NULL\r
530};\r
531\r
532VOID\r
533CVfrCompiler::GenCFile (\r
534 VOID\r
535 )\r
536{\r
537 FILE *pFile;\r
538 UINT32 Index;\r
539\r
540 if (!IS_RUN_STATUS(STATUS_GENBINARY)) {\r
541 goto Fail;\r
542 }\r
543\r
544 if ((pFile = fopen (mOptions.COutputFileName, "w")) == NULL) {\r
545 printf ("failed to open output C file - %s\n", mOptions.COutputFileName);\r
546 goto Fail;\r
547 }\r
548\r
549 for (Index = 0; gSourceFileHeader[Index] != NULL; Index++) {\r
550 fprintf (pFile, "%s\n", gSourceFileHeader[Index]);\r
551 }\r
552\r
553 gCVfrBufferConfig.OutputCFile (pFile, mOptions.VfrBaseFileName);\r
554\r
555 if (gCFormPkg.GenCFile (mOptions.VfrBaseFileName, pFile) != VFR_RETURN_SUCCESS) {\r
556 fclose (pFile);\r
557 goto Fail;\r
558 }\r
559 fclose (pFile);\r
560\r
561 SET_RUN_STATUS (STATUS_FINISHED);\r
562 return;\r
563\r
564Fail:\r
565 if (!IS_RUN_STATUS(STATUS_DEAD)) {\r
566 SET_RUN_STATUS (STATUS_FAILED);\r
567 }\r
568}\r
569\r
570VOID\r
571CVfrCompiler::GenRecordListFile (\r
572 VOID\r
573 )\r
574{\r
3e99020d
LG
575 INT8 *InFileName = NULL;\r
576 FILE *pInFile = NULL;\r
577 FILE *pOutFile = NULL;\r
95d675b5 578 INT8 LineBuf[MAX_LINE_LEN];\r
579 UINT32 LineNo;\r
580\r
3e99020d
LG
581 InFileName = (mOptions.SkipCPreprocessor == TRUE) ? mOptions.VfrFileName : mOptions.PreprocessorOutputFileName;\r
582\r
95d675b5 583 if (mOptions.CreateRecordListFile == TRUE) {\r
3e99020d 584 if ((InFileName[0] == '\0') || (mOptions.RecordListFile[0] == '\0')) {\r
95d675b5 585 return;\r
586 }\r
587\r
3e99020d
LG
588 if ((pInFile = fopen (InFileName, "r")) == NULL) {\r
589 printf ("%s failed to open input VFR preprocessor output file - %s\n", UTILITY_NAME, InFileName);\r
95d675b5 590 return;\r
591 }\r
592\r
593 if ((pOutFile = fopen (mOptions.RecordListFile, "w")) == NULL) {\r
3e99020d 594 printf ("%s failed to open record list file for writing - %s\n", UTILITY_NAME, mOptions.RecordListFile);\r
95d675b5 595 goto Err1;\r
596 }\r
597\r
3e99020d 598 fprintf (pOutFile, "//\n// VFR compiler version " UTILITY_VERSION "\n//\n");\r
95d675b5 599 LineNo = 0;\r
600 while (!feof (pInFile)) {\r
601 if (fgets (LineBuf, MAX_LINE_LEN, pInFile) != NULL) {\r
602 fprintf (pOutFile, "%s", LineBuf);\r
603 LineNo++;\r
604 gCIfrRecordInfoDB.IfrRecordOutput (pOutFile, LineNo);\r
605 }\r
606 }\r
607\r
608 fclose (pOutFile);\r
609 fclose (pInFile);\r
610 }\r
611\r
612 return;\r
613\r
614Err1:\r
615 fclose (pInFile);\r
616}\r
617\r
618INT32\r
619main (\r
3e99020d 620 IN INT32 Argc,\r
95d675b5 621 IN INT8 **Argv\r
622 )\r
623{\r
624 COMPILER_RUN_STATUS Status;\r
625 CVfrCompiler Compiler(Argc, Argv);\r
626\r
627 Compiler.PreProcess();\r
628 Compiler.Compile();\r
629 Compiler.GenBinary();\r
630 Compiler.GenCFile();\r
631 Compiler.GenRecordListFile ();\r
632\r
633 Status = Compiler.RunStatus ();\r
634 if ((Status == STATUS_DEAD) || (Status == STATUS_FAILED)) {\r
635 return 2;\r
636 }\r
637\r
638 return 0;\r
639}\r
640\r