3 Copyright (c) 2004 - 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 Parse files in a directory and subdirectories to find all guid definitions.
19 Then check them against each other to make sure there are no duplicates.
28 #include "CommonUtils.h"
29 #include "FileSearch.h"
30 #include "UtilsMsgs.h"
32 #define MAX_LINE_LEN 1024 // we concatenate lines sometimes
33 // Define a structure that correlates filename extensions to an enumerated
44 } FILE_TYPE_TABLE_ENTRY
;
46 #define FILE_EXTENSION_UNKNOWN 0
47 #define FILE_EXTENSION_C 1
48 #define FILE_EXTENSION_H 2
49 #define FILE_EXTENSION_IA32_ASM 3
50 #define FILE_EXTENSION_IA32_INC 4
51 #define FILE_EXTENSION_IA64_ASM 5
52 #define FILE_EXTENSION_IA64_INC 6
53 #define FILE_EXTENSION_PKG 7
54 #define FILE_EXTENSION_INF 8
56 FILE_TYPE_TABLE_ENTRY FileTypeTable
[] = {
62 FILE_EXTENSION_IA32_INC
,
64 FILE_EXTENSION_IA32_ASM
,
66 FILE_EXTENSION_IA64_ASM
,
72 FILE_EXTENSION_IA64_INC
,
77 typedef struct EFI_GUID
{
89 typedef struct _GUID_RECORD
{
90 struct _GUID_RECORD
*Next
;
97 typedef struct _SIGNATURE_RECORD
{
98 struct _SIGNATURE_RECORD
*Next
;
101 EFI_SIGNATURE Signature
;
108 INT8 DatabaseOutputFileName
[MAX_PATH
]; // with -b option
109 STRING_LIST
*ExcludeDirs
; // list of directory names not to process
110 STRING_LIST
*ExcludeSubDirs
; // list of directory names to not process subdirectories (build)
111 STRING_LIST
*ExcludeFiles
; // list of files to exclude (make.inf)
112 STRING_LIST
*ExcludeExtensions
; // list of filename extensions to exclude (.inf, .pkg)
116 BOOLEAN CheckSignatures
;
117 BOOLEAN GuidXReference
;
187 ProcessINFFileGuids (
193 ProcessPkgFileGuids (
199 ProcessIA32FileGuids (
205 ProcessIA64FileGuids (
246 UINT32 DataHH
, // Upper 32-bits of upper 64 bits of guid
247 UINT32 DataHL
, // Lower 32-bits of upper 64 bits
276 // GUID_RECORD *FileRecord
300 /**************************** GLOBALS ****************************************/
301 static GUID_RECORD
*gGuidList
= NULL
;
302 static SIGNATURE_RECORD
*gSignatureList
= NULL
;
303 static OPTIONS gOptions
;
305 /*****************************************************************************/
315 SetUtilityName ("GuidChk");
317 // Get the current working directory and then process the command line
320 Cwd
= _getcwd (NULL
, 0);
321 Status
= ProcessArgs (Argc
, Argv
);
322 if (Status
!= STATUS_SUCCESS
) {
326 if (gOptions
.CheckGuids
|| gOptions
.CheckSignatures
) {
327 Status
= ProcessDirectory (Cwd
, NULL
);
328 if (Status
== STATUS_SUCCESS
) {
330 // Check for duplicates
332 Status
= CheckDuplicates ();
336 if (gOptions
.DatabaseOutputFileName
[0] != 0) {
337 CreateGuidList (gOptions
.DatabaseOutputFileName
);
340 // Free up the memory
346 return GetUtilityStatus ();
356 STRING_LIST
*StrList
;
358 memset ((char *) &gOptions
, 0, sizeof (gOptions
));
360 // skip over program name
374 if ((Argv
[0][0] == '-') || (Argv
[0][0] == '/')) {
375 switch (Argv
[0][1]) {
387 // Check guids option
391 gOptions
.CheckGuids
= TRUE
;
395 // Check signatures option
399 gOptions
.CheckSignatures
= TRUE
;
403 // Print guids found option
407 gOptions
.PrintFound
= TRUE
;
411 // Exclude files option
416 // Check for another arg
419 Error (NULL
, 0, 0, Argv
[0], "missing argument with option");
424 StrList
= malloc (sizeof (STRING_LIST
));
425 if (StrList
== NULL
) {
426 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
430 memset ((char *) StrList
, 0, sizeof (STRING_LIST
));
431 StrList
->Str
= Argv
[1];
432 StrList
->Next
= gOptions
.ExcludeFiles
;
433 gOptions
.ExcludeFiles
= StrList
;
439 // Exclude directories option
444 // Check for another arg
447 Error (NULL
, 0, 0, Argv
[0], "missing argument with option");
452 StrList
= malloc (sizeof (STRING_LIST
));
453 if (StrList
== NULL
) {
454 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
458 memset ((char *) StrList
, 0, sizeof (STRING_LIST
));
459 StrList
->Str
= Argv
[1];
460 StrList
->Next
= gOptions
.ExcludeDirs
;
461 gOptions
.ExcludeDirs
= StrList
;
467 // -u exclude all subdirectories of a given directory option
472 // Check for another arg
475 Error (NULL
, 0, 0, Argv
[0], "missing argument with option");
480 StrList
= malloc (sizeof (STRING_LIST
));
481 if (StrList
== NULL
) {
482 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
486 memset ((char *) StrList
, 0, sizeof (STRING_LIST
));
487 StrList
->Str
= Argv
[1];
488 StrList
->Next
= gOptions
.ExcludeSubDirs
;
489 gOptions
.ExcludeSubDirs
= StrList
;
495 // -e exclude by filename extension option
500 // Check for another arg
503 Error (NULL
, 0, 0, Argv
[0], "missing argument with option");
508 StrList
= malloc (sizeof (STRING_LIST
));
509 if (StrList
== NULL
) {
510 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
514 memset ((char *) StrList
, 0, sizeof (STRING_LIST
));
516 // Let them put a * in front of the filename extension
518 StrList
->Str
= Argv
[1];
519 if (StrList
->Str
[0] == '*') {
523 StrList
->Next
= gOptions
.ExcludeExtensions
;
524 gOptions
.ExcludeExtensions
= StrList
;
530 // Print guid with matching symbol name for guid definitions found
534 gOptions
.GuidXReference
= TRUE
;
538 // -b Print the internal database list to a file
543 // Check for one more arg
546 Error (NULL
, 0, 0, Argv
[0], "must specify file name with option");
551 strcpy (gOptions
.DatabaseOutputFileName
, Argv
[1]);
557 Error (NULL
, 0, 0, Argv
[0], "invalid option");
572 Error (NULL
, 0, 0, Argv
[0], "invalid argument");
577 // Have to check signatures, GUIDs, or dump the GUID database.
579 if ((!gOptions
.CheckGuids
) && (!gOptions
.CheckSignatures
) && (gOptions
.DatabaseOutputFileName
[0] == 0)) {
580 Error (NULL
, 0, 0, "nothing to do", "must specify -g, -s, and/or -b");
585 return STATUS_SUCCESS
;
588 // Print usage instructions
598 "GuidChk - scan files for duplicate GUID or signature definitions",
600 "Usage: GuidChk {options}\n",
602 " -d dirname exclude searching of a directory",
603 " -f filename exclude searching of a file",
604 " -e extension exclude searching of files by extension",
605 " -p print all GUIDS found",
606 " -g check for duplicate guids",
607 " -s check for duplicate signatures",
608 " -x print guid+defined symbol name",
609 " -b outfile write internal GUID+basename list to outfile",
610 " -u dirname exclude searching all subdirectories of a directory",
611 " -h -? print this help text",
613 " Example: GuidChk -g -u build -d fv -f make.inf -e .pkg",
617 for (Index
= 0; Str
[Index
] != NULL
; Index
++) {
618 fprintf (stdout
, "%s\n", Str
[Index
]);
622 // Process an entire directory by name
631 FILE_SEARCH_DATA FSData
;
639 // Root directory may be null
641 if (DirectoryName
!= NULL
) {
643 // printf ("Processing directory: %s\n", DirectoryName);
647 // Initialize our file searching
649 FileSearchInit (&FSData
);
652 // Exclude some directories, files, and extensions
654 FileSearchExcludeDirs (&FSData
, gOptions
.ExcludeDirs
);
655 FileSearchExcludeExtensions (&FSData
, gOptions
.ExcludeExtensions
);
656 FileSearchExcludeFiles (&FSData
, gOptions
.ExcludeFiles
);
658 // See if this directory is in the list of directories that they
659 // don't want to process subdirectories of
662 if (DirectoryName
!= NULL
) {
663 for (SLPtr
= gOptions
.ExcludeSubDirs
; SLPtr
!= NULL
; SLPtr
= SLPtr
->Next
) {
664 if (_stricmp (SLPtr
->Str
, DirectoryName
) == 0) {
666 // printf ("not processing subdirectories of %s\n", DirectoryName);
674 // Create a filemask of files to search for. We'll append "\*.*" on the
675 // end, so allocate some extra bytes.
677 Len
= strlen (Path
) + 10;
678 if (DirectoryName
!= NULL
) {
679 Len
+= strlen (DirectoryName
);
682 FileMask
= malloc (Len
);
683 if (FileMask
== NULL
) {
684 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
688 // Now put it all together
690 strcpy (FileMask
, Path
);
691 if ((DirectoryName
!= NULL
) && (strlen (DirectoryName
) > 0)) {
692 strcat (FileMask
, "\\");
693 strcat (FileMask
, DirectoryName
);
696 strcat (FileMask
, "\\*.*");
699 // Start file searching for files and directories
701 if (FileSearchStart (&FSData
, FileMask
, FILE_SEARCH_FILE
| FILE_SEARCH_DIR
) == STATUS_SUCCESS
) {
708 // Now hack the "\*.*" off the end of the filemask so we can use it to pass
709 // the full directory path on recursive calls to process directories.
711 FileMask
[strlen (FileMask
) - 4] = 0;
714 // Loop until no more files
718 // printf ("Found %s...", FSData.FileName);
720 if (FSData
.FileFlags
& FILE_SEARCH_DIR
) {
722 // printf ("directory\n");
725 ProcessDirectory (FileMask
, FSData
.FileName
);
727 } else if (FSData
.FileFlags
& FILE_SEARCH_FILE
) {
729 // printf ("file\n");
731 ProcessFile (FileMask
, FSData
.FileName
);
734 // printf ("unknown\n");
738 if (FileSearchFindNext (&FSData
) != STATUS_SUCCESS
) {
743 // Free up allocated memory
748 // Free up our file searching
750 FileSearchDestroy (&FSData
);
752 return STATUS_SUCCESS
;
755 // Process a single file.
765 UINT32 FileExtension
;
766 INT8 FullFileName
[MAX_PATH
];
768 Status
= STATUS_SUCCESS
;
770 sprintf (FullFileName
, "%s\\%s", DirectoryName
, FileName
);
772 // printf ("Found file: %s\n", FullFileName);
774 FileExtension
= GetFileExtension (FileName
);
777 // Process these for GUID checks
779 if (gOptions
.CheckGuids
) {
780 switch (FileExtension
) {
781 case FILE_EXTENSION_C
:
782 case FILE_EXTENSION_H
:
783 Status
= ProcessCFileGuids (FullFileName
);
786 case FILE_EXTENSION_PKG
:
787 Status
= ProcessPkgFileGuids (FullFileName
);
790 case FILE_EXTENSION_IA32_INC
:
791 case FILE_EXTENSION_IA32_ASM
:
792 Status
= ProcessIA32FileGuids (FullFileName
);
795 case FILE_EXTENSION_INF
:
796 Status
= ProcessINFFileGuids (FullFileName
);
799 case FILE_EXTENSION_IA64_INC
:
800 case FILE_EXTENSION_IA64_ASM
:
801 Status
= ProcessIA64FileGuids (FullFileName
);
808 Status
= STATUS_SUCCESS
;
813 if (gOptions
.CheckSignatures
) {
814 switch (FileExtension
) {
815 case FILE_EXTENSION_C
:
816 case FILE_EXTENSION_H
:
817 Status
= ProcessCFileSigs (FullFileName
);
824 Status
= STATUS_SUCCESS
;
832 // Return a code indicating the file name extension.
844 // Look back for a filename extension
846 for (Extension
= FileName
+ strlen (FileName
) - 1; Extension
>= FileName
; Extension
--) {
847 if (*Extension
== '.') {
848 for (Index
= 0; FileTypeTable
[Index
].Extension
!= NULL
; Index
++) {
849 if (_stricmp (FileTypeTable
[Index
].Extension
, Extension
) == 0) {
850 return FileTypeTable
[Index
].ExtensionCode
;
856 return FILE_TYPE_UNKNOWN
;
859 // Process a .pkg file.
861 // Look for FFS_FILEGUID=35b898ca-b6a9-49ce-8c72-904735cc49b7
865 ProcessPkgFileGuids (
870 INT8 Line
[MAX_LINE_LEN
* 2];
876 if ((Fptr
= fopen (FileName
, "r")) == NULL
) {
877 Error (NULL
, 0, 0, FileName
, "could not open input file for reading");
881 // Read lines from the file until done
883 while (fgets (Line
, sizeof (Line
), Fptr
) != NULL
) {
885 Cptr
+= SkipWhiteSpace (Line
);
886 if (strncmp (Cptr
, "FFS_FILEGUID", 12) == 0) {
888 Cptr
+= SkipWhiteSpace (Cptr
);
891 Cptr
+= SkipWhiteSpace (Cptr
+ 1);
893 // Blank out dashes on the line.
895 for (Cptr2
= Cptr
; *Cptr2
; Cptr2
++) {
910 AddPkgGuid (FileName
, GuidScan
, &Guid64
);
912 DebugMsg (NULL
, 0, 0, FileName
, "GUID scan failed");
919 return STATUS_SUCCESS
;
922 // Process an IA32 assembly file.
925 // FIND_FD_GUID_VAL equ 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h
926 // PEI_GUID_FileNameGuid_Gmch815 equ 081818181h, 08181h, 08181h, 081h, 081h, 081h, 081h, 081h, 081h, 081h, 081h
930 ProcessIA32FileGuids (
935 INT8 Line
[MAX_LINE_LEN
];
943 if ((Fptr
= fopen (FileName
, "r")) == NULL
) {
944 Error (NULL
, 0, 0, FileName
, "could not open input file for reading");
948 // Read lines from the file until done
950 while (fgets (Line
, sizeof (Line
), Fptr
) != NULL
) {
952 Cptr
+= SkipWhiteSpace (Line
);
954 // Look for xxxGUIDyyy equ 01h, 02h, 03h, ...
956 Len
= ValidSymbolName (Cptr
);
959 // Terminate the line after the symbol name, then look for "guid" in
962 CSavePtr
= Cptr
+ Len
;
966 if (_strnicmp (Cptr
, "guid", 4) == 0) {
973 // If we found the string "guid", continue
977 // Restore the character on the line where we null-terminated the symbol
981 Len
= SkipWhiteSpace (Cptr
);
983 // Had to be some white space
988 // now look for "equ"
990 if (_strnicmp (Cptr
, "equ", 3) == 0) {
992 Cptr
+= SkipWhiteSpace (Cptr
);
994 // Now scan all the data
996 for (Index
= 0; Index
< 16; Index
++) {
997 if (sscanf (Cptr
, "%X", &GuidData
[Index
]) != 1) {
1003 while (isxdigit (*Cptr
)) {
1007 if ((*Cptr
!= 'h') && (*Cptr
!= 'H')) {
1011 while (*Cptr
&& (isspace (*Cptr
) || (*Cptr
== ','))) {
1017 // Now see which form we had
1020 AddGuid16 (FileName
, GuidData
);
1021 } else if (Index
== 11) {
1022 AddGuid11 (FileName
, GuidData
, NULL
);
1031 return STATUS_SUCCESS
;
1034 // Found and parsed an IA32 assembly code guid. Save the 16 bytes off in the list
1044 GUID_RECORD
*NewRec
;
1048 // Sanity check the data
1050 if (!CheckGuidData (Data
, 16)) {
1051 return STATUS_ERROR
;
1054 // Allocate memory for a new guid structure
1056 NewRec
= malloc (sizeof (GUID_RECORD
));
1057 if (NewRec
== NULL
) {
1058 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
1059 return STATUS_ERROR
;
1062 memset ((char *) NewRec
, 0, sizeof (GUID_RECORD
));
1063 NewRec
->FileName
= malloc (strlen (FileName
) + 1);
1064 if (NewRec
->FileName
== NULL
) {
1066 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
1067 return STATUS_ERROR
;
1070 strcpy (NewRec
->FileName
, FileName
);
1071 NewRec
->Guid
.Data1
= (UINT32
) (Data
[0] | (Data
[1] << 8) | (Data
[2] << 16) | (Data
[3] << 24));
1072 NewRec
->Guid
.Data2
= (UINT16
) (Data
[4] | (Data
[5] << 8));
1073 NewRec
->Guid
.Data3
= (UINT16
) (Data
[6] | (Data
[7] << 8));
1074 for (Index
= 0; Index
< 8; Index
++) {
1075 NewRec
->Guid
.Data4
[Index
] = (UINT8
) Data
[Index
+ 8];
1078 // Add it to the list
1080 NewRec
->Next
= gGuidList
;
1085 // ReportGuid (FileName, NewRec);
1087 return STATUS_SUCCESS
;
1090 // Add a GUID defined as GuidLow: 0x1122334455667788
1091 // GuidHi: 0x99AABBCCDDEEFF00
1093 // These are equivalent:
1094 // { 0x11223344, 0x5566, 0x7788, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x00 }
1096 // Low: 00FFEEDDCCBBAA99
1097 // Hi: 7788556611223344
1103 UINT32 DataHH
, // Upper 32-bits of upper 64 bits of guid
1104 UINT32 DataHL
, // Lower 32-bits of upper 64 bits
1110 GUID_RECORD
*NewRec
;
1114 // Allocate memory for a new guid structure
1116 NewRec
= malloc (sizeof (GUID_RECORD
));
1117 if (NewRec
== NULL
) {
1118 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
1119 return STATUS_ERROR
;
1122 memset ((char *) NewRec
, 0, sizeof (GUID_RECORD
));
1123 NewRec
->FileName
= malloc (strlen (FileName
) + 1);
1124 if (NewRec
->FileName
== NULL
) {
1126 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
1127 return STATUS_ERROR
;
1130 strcpy (NewRec
->FileName
, FileName
);
1131 NewRec
->Guid
.Data1
= DataHL
;
1132 NewRec
->Guid
.Data2
= (UINT16
) DataHH
;
1133 NewRec
->Guid
.Data3
= (UINT16
) (DataHH
>> 16);
1134 for (Index
= 0; Index
< 4; Index
++) {
1135 NewRec
->Guid
.Data4
[Index
] = (UINT8
) DataLL
;
1139 for (Index
= 0; Index
< 4; Index
++) {
1140 NewRec
->Guid
.Data4
[Index
+ 4] = (UINT8
) DataLH
;
1144 if (SymName
!= NULL
) {
1145 NewRec
->SymName
= malloc (strlen (SymName
) + 1);
1146 if (NewRec
->SymName
== NULL
) {
1148 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
1149 return STATUS_ERROR
;
1151 strcpy (NewRec
->SymName
, SymName
);
1155 // Add it to the list
1157 NewRec
->Next
= gGuidList
;
1162 // ReportGuid (FileName, NewRec);
1164 return STATUS_SUCCESS
;
1167 // Process INF files. Look for:
1168 // FILE_GUID = 240612B6-A063-11d4-9A3A-0090273FC14D
1172 ProcessINFFileGuids (
1177 INT8 Line
[MAX_LINE_LEN
* 2];
1180 UINT32 GuidScan
[11];
1183 if ((Fptr
= fopen (FileName
, "r")) == NULL
) {
1184 Error (NULL
, 0, 0, FileName
, "could not open input file for reading");
1185 return STATUS_ERROR
;
1188 // Read lines from the file until done
1190 while (fgets (Line
, sizeof (Line
), Fptr
) != NULL
) {
1192 Cptr
+= SkipWhiteSpace (Line
);
1193 if (strncmp (Cptr
, "FILE_GUID", 9) == 0) {
1195 Cptr
+= SkipWhiteSpace (Cptr
);
1198 Cptr
+= SkipWhiteSpace (Cptr
+ 1);
1200 // Blank out dashes on the line.
1202 for (Cptr2
= Cptr
; *Cptr2
; Cptr2
++) {
1203 if (*Cptr2
== '-') {
1210 "%X %X %X %X %I64X",
1217 AddPkgGuid (FileName
, GuidScan
, &Guid64
);
1219 DebugMsg (NULL
, 0, 0, FileName
, "GUID scan failed");
1226 return STATUS_SUCCESS
;
1229 // Parse ('g','m','a','p','a','b','c','d')
1239 SIGNATURE_RECORD
*NewRec
;
1245 // Allocate memory for the new record
1248 NewRec
= malloc (sizeof (SIGNATURE_RECORD
));
1250 if (NewRec
== NULL
) {
1251 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
1252 return STATUS_ERROR
;
1254 memset ((char *) NewRec
, 0, sizeof (SIGNATURE_RECORD
));
1257 // Allocate memory to save the file name
1259 NewRec
->FileName
= malloc (strlen (FileName
) + 1);
1260 if (NewRec
->FileName
== NULL
) {
1261 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
1263 return STATUS_ERROR
;
1266 // Fill in the fields
1268 strcpy (NewRec
->FileName
, FileName
);
1269 NewRec
->Signature
.DataLen
= (UINT8
) SigSize
;
1271 // Skip to open parenthesis
1274 Cptr
+= SkipWhiteSpace (Cptr
);
1282 // Skip to first ' and start processing
1284 while (*Cptr
&& (*Cptr
!= '\'')) {
1288 for (Index
= 0; Index
< SigSize
; Index
++) {
1289 if (*Cptr
== '\'') {
1291 NewRec
->Signature
.Data
[Index
] = (INT8
) *Cptr
;
1293 // Skip to closing quote
1296 if (*Cptr
!= '\'') {
1301 // Skip over closing quote, go to next one
1304 while (*Cptr
&& (*Cptr
!= '\'')) {
1309 DebugMsg (NULL
, 0, 0, FileName
, "failed to parse signature");
1316 free (NewRec
->FileName
);
1318 return STATUS_ERROR
;
1321 NewRec
->Next
= gSignatureList
;
1322 gSignatureList
= NewRec
;
1323 return STATUS_SUCCESS
;
1327 // #define POOL_HEAD_SIGNATURE EFI_SIGNATURE_16('p','h')
1328 // #define GCD_MEMORY_MAP_SIGNATURE EFI_SIGNATURE_32('g','m','a','p')
1329 // #define GCD_MEMORY_MAP_SIGNATURE EFI_SIGNATURE_64('g','m','a','p','a','b','c','d')
1338 INT8 Line
[MAX_LINE_LEN
* 2];
1342 if ((Fptr
= fopen (FileName
, "r")) == NULL
) {
1343 Error (NULL
, 0, 0, FileName
, "could not open input file for reading");
1344 return STATUS_ERROR
;
1347 // Read lines from the file until done
1349 while (fgets (Line
, sizeof (Line
), Fptr
) != NULL
) {
1351 Cptr
+= SkipWhiteSpace (Line
);
1353 // look for #define EFI_SIGNATURE_xx value
1357 Cptr
+= SkipWhiteSpace (Cptr
);
1359 // Look for "define"
1361 if (!strncmp (Cptr
, "define", 6)) {
1364 // Better be whitespace
1366 Len
= SkipWhiteSpace (Cptr
);
1370 // See if it's a valid symbol name
1372 Len
= ValidSymbolName (Cptr
);
1375 // It is a valid symbol name. See if there's line continuation,
1376 // and if so, read more lines.
1377 // Skip over the symbol name and look for the string "EFI_SIGNATURE_xx"
1379 ConcatenateLines (Fptr
, Line
, sizeof(Line
));
1382 Cptr
+= SkipWhiteSpace (Cptr
);
1383 if (strncmp (Cptr
, "EFI_SIGNATURE_16", 16) == 0) {
1384 AddSignature (FileName
, Cptr
+ 16, 2);
1385 } else if (strncmp (Cptr
, "EFI_SIGNATURE_32", 16) == 0) {
1386 AddSignature (FileName
, Cptr
+ 16, 4);
1387 } else if (strncmp (Cptr
, "EFI_SIGNATURE_64", 16) == 0) {
1388 AddSignature (FileName
, Cptr
+ 16, 8);
1397 return STATUS_SUCCESS
;
1400 // look for #define xxxGUIDyyy { 0x...}
1401 // xxx EFI_GUID GuidName = { 0x... };
1410 INT8 Line
[MAX_LINE_LEN
* 2];
1417 UINT32 GuidScan
[11];
1419 if ((Fptr
= fopen (FileName
, "r")) == NULL
) {
1420 Error (NULL
, 0, 0, FileName
, "could not open input file for reading");
1421 return STATUS_ERROR
;
1424 // Read lines from the file until done
1426 while (fgets (Line
, sizeof (Line
), Fptr
) != NULL
) {
1428 Cptr
+= SkipWhiteSpace (Line
);
1430 // look for #define xxxGUIDxxx value
1434 Cptr
+= SkipWhiteSpace (Cptr
);
1436 // Look for "define"
1438 if (!strncmp (Cptr
, "define", 6)) {
1442 // Better be whitespace
1444 Len
= SkipWhiteSpace (Cptr
);
1448 // See if it's a valid symbol name
1450 Len
= ValidSymbolName (Cptr
);
1453 // It is a valid symbol name. See if there's line continuation,
1454 // and if so, read more lines.
1455 // Then truncate after the symbol name, look for the string "GUID",
1459 ConcatenateLines (Fptr
, Line
, sizeof(Line
));
1462 // Now look for { 0x....... }
1464 CSavePtr
= Cptr
+ Len
;
1466 Cptr
+= SkipWhiteSpace (Cptr
);
1470 // Blank out 'L', 'l', '{', '}', ',' on the line.
1472 for (TempCptr
= Cptr
; *TempCptr
; TempCptr
++) {
1473 if ((*TempCptr
== 'L') || (*TempCptr
== 'l') || (*TempCptr
== '{') ||
1474 (*TempCptr
== '}') || (*TempCptr
== ',')) {
1481 "%X %X %X %X %X %X %X %X %X %X %X",
1495 AddGuid11 (FileName
, GuidScan
, SymName
);
1502 // Else look for "static EFI_GUID xxxGUIDxxx = { 0x.... };
1504 } else if ((CSavePtr
= strstr (Line
, "EFI_GUID")) != NULL
) {
1506 // Read more lines until met ';'
1508 ConcatenateLines (Fptr
, Line
, sizeof(Line
));
1509 while (strstr (Line
, ";") == NULL
) {
1510 LineLen
= strlen (Line
);
1511 Len
= sizeof(Line
) - LineLen
;
1515 if (Line
[LineLen
- 1] == '\n') {
1516 Cptr
= Line
+ LineLen
- 1;
1518 if (fgets (Cptr
, Len
, Fptr
) == NULL
){
1521 ConcatenateLines (Fptr
, Line
, sizeof(Line
));
1523 Cptr
= Line
+ LineLen
;
1525 if (fgets (Cptr
, Len
, Fptr
) == NULL
) {
1528 ConcatenateLines (Fptr
, Line
, sizeof(Line
));
1532 // EFI_GUID may appear in comments wihout end of ';' which may cause
1533 // ignoring of new #define, so handle it here.
1535 Cptr
+= SkipWhiteSpace (Cptr
);
1538 Cptr
+= SkipWhiteSpace (Cptr
);
1539 if (!strncmp (Cptr
, "define", 6)) {
1545 Cptr
= CSavePtr
+ 8;
1546 Cptr
+= SkipWhiteSpace (Cptr
);
1548 // Should be variable name next
1550 Len
= ValidSymbolName (Cptr
);
1554 Cptr
+= SkipWhiteSpace (Cptr
);
1558 Cptr
+= SkipWhiteSpace (Cptr
);
1560 // Should be open-brace next to define guid
1565 // Blank out 'L', 'l', '{', '}', ',' on the line.
1567 for (TempCptr
= Cptr
; *TempCptr
; TempCptr
++) {
1568 if ((*TempCptr
== 'L') || (*TempCptr
== 'l') || (*TempCptr
== '{') ||
1569 (*TempCptr
== '}') || (*TempCptr
== ',')) {
1576 "%X %X %X %X %X %X %X %X %X %X %X",
1589 AddGuid11 (FileName
, GuidScan
, SymName
);
1597 return STATUS_SUCCESS
;
1600 // Process Intel Itanium(TM) GUID definitions. Look for:
1601 // #define Cs870MemoryTestPEIMGuidL 0x9C2403386E1C8FAA
1602 // #define Cs870MemoryTestPEIMGuidH 0xE89E95C6180342f0
1604 // This function assumes no blank lines between definitions.
1608 ProcessIA64FileGuids (
1613 INT8 Line
[MAX_LINE_LEN
];
1618 INT8 SymName1
[MAX_LINE_LEN
];
1619 INT8 SymName2
[MAX_LINE_LEN
];
1624 if ((Fptr
= fopen (FileName
, "r")) == NULL
) {
1625 Error (NULL
, 0, 0, FileName
, "could not open input file for reading");
1626 return STATUS_ERROR
;
1630 if (fgets (Line
, sizeof (Line
), Fptr
) == NULL
) {
1634 // Read lines from the file until done. Since the guid definition takes
1635 // two lines, we read lines in different places to recover gracefully
1636 // from mismatches. For example, if you thought you found the first half,
1637 // but the next line had a symbol mismatch, then you have to process the
1638 // line again in case it's the start of a new definition.
1642 // Check current line for GUID definition. Assume low define first.
1644 if (IsIA64GuidLine (Line
, &Guid1H
, &Guid1L
, &FoundLow
, SymName1
)) {
1646 // Might have to swap guids later. Save off if we found the LOW first
1654 // Read the next line and try for the rest of the guid definition
1656 if (fgets (Line
, sizeof (Line
), Fptr
) == NULL
) {
1659 if (IsIA64GuidLine (Line
, &Guid2H
, &Guid2L
, &FoundLow
, SymName2
)) {
1661 // Found another. If the symbol names match, then save it off.
1663 if (strcmp (SymName1
, SymName2
) == 0) {
1665 // Yea, found one. Save it off.
1668 AddGuid64x2 (FileName
, Guid2H
, Guid2L
, Guid1H
, Guid1L
, SymName1
);
1670 AddGuid64x2 (FileName
, Guid1H
, Guid1L
, Guid2H
, Guid2L
, SymName1
);
1673 // Read the next line for processing
1675 if (fgets (Line
, sizeof (Line
), Fptr
) == NULL
) {
1680 // Don't get another line so that we reprocess this line in case it
1681 // contains the start of a new definition.
1682 // fprintf (stdout, "Symbol name mismatch: %s: %s != %s\n",
1683 // FileName, SymName1, SymName2);
1688 // Second line was not a guid definition. Get the next line from the
1691 if (fgets (Line
, sizeof (Line
), Fptr
) == NULL
) {
1698 // Not a guid define line. Next.
1700 if (fgets (Line
, sizeof (Line
), Fptr
) == NULL
) {
1707 return STATUS_SUCCESS
;
1710 // Given a line from an Itanium-based assembly file, check the line for a guid
1711 // defininition. One of either:
1712 // #define Cs870MemoryTestPEIMGuidL 0x9C2403386E1C8FAA
1713 // #define Cs870MemoryTestPEIMGuidH 0xE89E95C6180342f0
1714 // Return the defined value as two 32-bit values, and whether it's a high
1734 Cptr
+= SkipWhiteSpace (Cptr
);
1736 // look for #define xxxGUID[L|H] 0xHexValue
1740 Cptr
+= SkipWhiteSpace (Cptr
);
1742 // Look for "define"
1744 if (!strncmp (Cptr
, "define", 6)) {
1747 // Better be whitespace
1749 Len
= SkipWhiteSpace (Cptr
);
1753 // See if it's a valid symbol name
1755 Len
= ValidSymbolName (Cptr
);
1758 // Save the start so we can copy it to their string if later checks are ok
1762 // It is a valid symbol name, look for the string GuidL or GuidH
1764 CSavePtr
= Cptr
+ Len
;
1768 if (strncmp (Cptr
, "GuidL", 5) == 0) {
1771 } else if (strncmp (Cptr
, "GuidH", 5) == 0) {
1779 // If we didn't run out of string, then we found the GUID string.
1780 // Restore the null character we inserted above and continue.
1781 // Now look for 0x.......
1785 // Return symbol name less the "L" or "H"
1787 strcpy (SymName
, SymStart
);
1788 SymName
[strlen (SymName
) - 1] = 0;
1791 Cptr
+= SkipWhiteSpace (Cptr
);
1792 if ((*Cptr
== '0') && (*(Cptr
+ 1) == 'x')) {
1798 // 0x0123456789ABCDEF -- null terminate after 8 characters,
1799 // scan, replace the character and scan at that point.
1801 CSave
= *(Cptr
+ 8);
1803 if (sscanf (Cptr
, "%X", GuidHigh
) == 1) {
1804 *(Cptr
+ 8) = CSave
;
1805 if (sscanf (Cptr
+ 8, "%X", GuidLow
) == 1) {
1819 // Look at the characters in the string and determine if it's a valid
1820 // symbol name. Basically [a-zA-Z_][a-zA-Z_0-9]*
1833 // Test first character
1835 if (((*Name
>= 'a') && (*Name
<= 'z')) || ((*Name
>= 'A') && (*Name
<= 'Z')) || (*Name
== '_')) {
1839 if (((*Name
>= 'a') && (*Name
<= 'z')) ||
1840 ((*Name
>= 'A') && (*Name
<= 'Z')) ||
1841 ((*Name
>= '0') && (*Name
<= '9')) ||
1863 while (isspace (*Str
) && *Str
) {
1871 // found FFS_FILEGUID=35b898ca-b6a9-49ce-8c72-904735cc49b7
1881 GUID_RECORD
*NewRec
;
1885 // Sanity check the data
1887 if ((Data
[1] | Data
[2] | Data
[3]) & 0xFFFF0000) {
1888 Error (NULL
, 0, 0, "out of range value for GUID data word(s) [1] - [3]", NULL
);
1889 return STATUS_ERROR
;
1892 // More checks for Data64?
1893 // Allocate memory for a new one guid structure
1895 NewRec
= malloc (sizeof (GUID_RECORD
));
1896 if (NewRec
== NULL
) {
1897 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
1898 return STATUS_ERROR
;
1901 memset ((char *) NewRec
, 0, sizeof (GUID_RECORD
));
1902 NewRec
->FileName
= malloc (strlen (FileName
) + 1);
1903 if (NewRec
->FileName
== NULL
) {
1905 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
1906 return STATUS_ERROR
;
1909 strcpy (NewRec
->FileName
, FileName
);
1910 NewRec
->Guid
.Data1
= Data
[0];
1911 NewRec
->Guid
.Data2
= (UINT16
) Data
[1];
1912 NewRec
->Guid
.Data3
= (UINT16
) Data
[2];
1913 NewRec
->Guid
.Data4
[0] = (UINT8
) (Data
[3] >> 8);
1914 NewRec
->Guid
.Data4
[1] = (UINT8
) Data
[3];
1915 for (Index
= 2; Index
< 8; Index
++) {
1916 NewRec
->Guid
.Data4
[Index
] = ((UINT8
*)Data64
)[7-Index
];
1919 // Add it to the list
1921 NewRec
->Next
= gGuidList
;
1926 // ReportGuid (FileName, NewRec);
1928 return STATUS_SUCCESS
;
1931 // Add a guid consisting of 11 fields to our list of guids
1941 GUID_RECORD
*NewRec
;
1945 // Sanity check the data
1947 if (!CheckGuidData (Data
, 11)) {
1948 return STATUS_ERROR
;
1951 // Allocate memory for a new one guid structure
1953 NewRec
= malloc (sizeof (GUID_RECORD
));
1954 if (NewRec
== NULL
) {
1955 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
1956 return STATUS_ERROR
;
1959 memset ((char *) NewRec
, 0, sizeof (GUID_RECORD
));
1960 NewRec
->FileName
= malloc (strlen (FileName
) + 1);
1961 if (NewRec
->FileName
== NULL
) {
1963 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
1964 return STATUS_ERROR
;
1967 strcpy (NewRec
->FileName
, FileName
);
1968 if (SymName
!= NULL
) {
1969 NewRec
->SymName
= malloc (strlen (SymName
) + 1);
1970 if (NewRec
->SymName
== NULL
) {
1972 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
1973 return STATUS_ERROR
;
1975 strcpy (NewRec
->SymName
, SymName
);
1978 NewRec
->Guid
.Data1
= Data
[0];
1979 NewRec
->Guid
.Data2
= (UINT16
) Data
[1];
1980 NewRec
->Guid
.Data3
= (UINT16
) Data
[2];
1981 for (Index
= 0; Index
< 8; Index
++) {
1982 NewRec
->Guid
.Data4
[Index
] = (UINT8
) Data
[3 + Index
];
1985 // Add it to the list
1987 NewRec
->Next
= gGuidList
;
1992 // ReportGuid (FileName, NewRec);
1994 return STATUS_SUCCESS
;
1997 // For debug purposes, print each guid found
2003 // GUID_RECORD *NewGuid
2006 // //fprintf (stdout, "%s: 0x%08X\n", FileName, NewGuid->Guid.Data1);
2009 // Free up memory we allocated to keep track of guids defined.
2017 GUID_RECORD
*NextRec
;
2018 while (gGuidList
!= NULL
) {
2019 NextRec
= gGuidList
->Next
;
2020 if (gGuidList
->FileName
!= NULL
) {
2021 free (gGuidList
->FileName
);
2024 if (gGuidList
->SymName
!= NULL
) {
2025 free (gGuidList
->SymName
);
2029 gGuidList
= NextRec
;
2039 SIGNATURE_RECORD
*NextRec
;
2040 while (gSignatureList
!= NULL
) {
2041 NextRec
= gSignatureList
->Next
;
2042 if (gSignatureList
->FileName
!= NULL
) {
2043 free (gSignatureList
->FileName
);
2046 free (gSignatureList
);
2047 gSignatureList
= NextRec
;
2051 // Scan through all guids defined and compare each for duplicates.
2059 GUID_RECORD
*CurrentFile
;
2061 GUID_RECORD
*TempFile
;
2062 SIGNATURE_RECORD
*CurrentSig
;
2063 SIGNATURE_RECORD
*TempSig
;
2072 Status
= STATUS_SUCCESS
;
2075 // If we're checking guids.....
2077 if (gOptions
.CheckGuids
) {
2079 // If -p option, print all guids found
2081 if (gOptions
.PrintFound
) {
2082 CurrentFile
= gGuidList
;
2083 while (CurrentFile
!= NULL
) {
2086 "GUID: 0x%08X 0x%04X 0x%04X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X %s\n",
2087 (UINT32
) CurrentFile
->Guid
.Data1
,
2088 (UINT32
) CurrentFile
->Guid
.Data2
,
2089 (UINT32
) CurrentFile
->Guid
.Data3
,
2090 (UINT32
) CurrentFile
->Guid
.Data4
[0],
2091 (UINT32
) CurrentFile
->Guid
.Data4
[1],
2092 (UINT32
) CurrentFile
->Guid
.Data4
[2],
2093 (UINT32
) CurrentFile
->Guid
.Data4
[3],
2094 (UINT32
) CurrentFile
->Guid
.Data4
[4],
2095 (UINT32
) CurrentFile
->Guid
.Data4
[5],
2096 (UINT32
) CurrentFile
->Guid
.Data4
[6],
2097 (UINT32
) CurrentFile
->Guid
.Data4
[7],
2098 CurrentFile
->FileName
2100 CurrentFile
= CurrentFile
->Next
;
2104 if (gOptions
.GuidXReference
) {
2105 CurrentFile
= gGuidList
;
2106 while (CurrentFile
!= NULL
) {
2108 // If no symbol name, print FileName
2110 SymName
= CurrentFile
->SymName
;
2111 if (SymName
== NULL
) {
2113 // Assume file name will not be NULL and strlen > 0
2115 SymName
= CurrentFile
->FileName
+ strlen (CurrentFile
->FileName
) - 1;
2116 while ((*SymName
!= '\\') && (SymName
> CurrentFile
->FileName
)) SymName
--;
2117 if (*SymName
== '\\') SymName
++;
2122 "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X %s\n",
2123 (UINT32
) CurrentFile
->Guid
.Data1
,
2124 (UINT32
) CurrentFile
->Guid
.Data2
,
2125 (UINT32
) CurrentFile
->Guid
.Data3
,
2126 (UINT32
) CurrentFile
->Guid
.Data4
[0],
2127 (UINT32
) CurrentFile
->Guid
.Data4
[1],
2128 (UINT32
) CurrentFile
->Guid
.Data4
[2],
2129 (UINT32
) CurrentFile
->Guid
.Data4
[3],
2130 (UINT32
) CurrentFile
->Guid
.Data4
[4],
2131 (UINT32
) CurrentFile
->Guid
.Data4
[5],
2132 (UINT32
) CurrentFile
->Guid
.Data4
[6],
2133 (UINT32
) CurrentFile
->Guid
.Data4
[7],
2136 CurrentFile
= CurrentFile
->Next
;
2140 // Now go through all guids and report duplicates.
2142 CurrentFile
= gGuidList
;
2143 while (CurrentFile
!= NULL
) {
2145 TempFile
= CurrentFile
->Next
;
2148 // Compare the guids
2150 if ((CurrentFile
->Guid
.Data1
== TempFile
->Guid
.Data1
) &&
2151 (CurrentFile
->Guid
.Data2
== TempFile
->Guid
.Data2
) &&
2152 (CurrentFile
->Guid
.Data3
== TempFile
->Guid
.Data3
)
2155 // OR in all the guid bytes so we can ignore NULL-guid definitions.
2157 GuidSum
= CurrentFile
->Guid
.Data1
| CurrentFile
->Guid
.Data2
| CurrentFile
->Guid
.Data3
;
2159 for (Index
= 0; Index
< 8; Index
++) {
2160 GuidSum
|= CurrentFile
->Guid
.Data4
[Index
];
2161 if (CurrentFile
->Guid
.Data4
[Index
] != TempFile
->Guid
.Data4
[Index
]) {
2167 // If they're the same, and the guid was non-zero, print a message.
2169 if (Same
&& GuidSum
) {
2170 if (DupCount
== 0) {
2171 Error (NULL
, 0, 0, "duplicate GUIDS found", NULL
);
2172 fprintf (stdout
, " FILE1: %s\n", CurrentFile
->FileName
);
2176 fprintf (stdout
, " FILE%d: %s\n", DupCount
+ 1, TempFile
->FileName
);
2178 // Flag it as reported so we don't report it again if there's three or more
2180 TempFile
->Reported
= TRUE
;
2186 TempFile
= TempFile
->Next
;
2189 // Print the guid if we found duplicates
2194 " GUID: 0x%08X 0x%04X 0x%04X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X\n",
2195 (UINT32
) CurrentFile
->Guid
.Data1
,
2196 (UINT32
) CurrentFile
->Guid
.Data2
,
2197 (UINT32
) CurrentFile
->Guid
.Data3
,
2198 (UINT32
) CurrentFile
->Guid
.Data4
[0],
2199 (UINT32
) CurrentFile
->Guid
.Data4
[1],
2200 (UINT32
) CurrentFile
->Guid
.Data4
[2],
2201 (UINT32
) CurrentFile
->Guid
.Data4
[3],
2202 (UINT32
) CurrentFile
->Guid
.Data4
[4],
2203 (UINT32
) CurrentFile
->Guid
.Data4
[5],
2204 (UINT32
) CurrentFile
->Guid
.Data4
[6],
2205 (UINT32
) CurrentFile
->Guid
.Data4
[7]
2208 // return STATUS_ERROR;
2212 // Find the next one that hasn't been reported
2215 CurrentFile
= CurrentFile
->Next
;
2216 } while ((CurrentFile
!= NULL
) && (CurrentFile
->Reported
));
2220 if (gOptions
.CheckSignatures
) {
2222 // Print ones found if specified
2224 if (gOptions
.PrintFound
) {
2225 CurrentSig
= gSignatureList
;
2226 while (CurrentSig
!= NULL
) {
2227 Len
= CurrentSig
->Signature
.DataLen
;
2228 for (Index
= 0; Index
< Len
; Index
++) {
2229 fprintf (stdout
, "%c", CurrentSig
->Signature
.Data
[Index
]);
2232 fprintf (stdout
, " %s\n", CurrentSig
->FileName
);
2233 CurrentSig
= CurrentSig
->Next
;
2237 CurrentSig
= gSignatureList
;
2238 while (CurrentSig
!= NULL
) {
2240 TempSig
= CurrentSig
->Next
;
2241 Len
= CurrentSig
->Signature
.DataLen
;
2244 // Check for same length, then do string compare
2246 if (Len
== TempSig
->Signature
.DataLen
) {
2247 if (strncmp (CurrentSig
->Signature
.Data
, TempSig
->Signature
.Data
, Len
) == 0) {
2249 // Print header message if first failure for this sig
2251 if (DupCount
== 0) {
2252 Error (NULL
, 0, 0, "duplicate signatures found", NULL
);
2253 fprintf (stdout
, " FILE1: %s\n", CurrentSig
->FileName
);
2257 fprintf (stdout
, " FILE%d: %s\n", DupCount
+ 1, TempSig
->FileName
);
2258 TempSig
->Reported
= TRUE
;
2262 TempSig
= TempSig
->Next
;
2266 fprintf (stdout
, " SIG: ");
2267 for (Index
= 0; Index
< Len
; Index
++) {
2268 fprintf (stdout
, "%c", CurrentSig
->Signature
.Data
[Index
]);
2271 fprintf (stdout
, "\n");
2274 // On to the next one that hasn't been reported
2277 CurrentSig
= CurrentSig
->Next
;
2278 } while ((CurrentSig
!= NULL
) && (CurrentSig
->Reported
));
2292 Routine Description:
2293 Free up any memory we allocated when processing command-line options.
2302 We don't free up the ->Str fields because we did not allocate them.
2303 Instead, we just set the pointer to point to the actual parameter
2304 from the command line.
2309 while (gOptions
.ExcludeDirs
!= NULL
) {
2310 Ptr
= gOptions
.ExcludeDirs
->Next
;
2312 // free (gOptions.ExcludeDirs->Str);
2314 free (gOptions
.ExcludeDirs
);
2315 gOptions
.ExcludeDirs
= Ptr
;
2318 while (gOptions
.ExcludeSubDirs
!= NULL
) {
2319 Ptr
= gOptions
.ExcludeSubDirs
->Next
;
2321 // free (gOptions.ExcludeSubDirs->Str);
2323 free (gOptions
.ExcludeSubDirs
);
2324 gOptions
.ExcludeSubDirs
= Ptr
;
2327 while (gOptions
.ExcludeExtensions
!= NULL
) {
2328 Ptr
= gOptions
.ExcludeExtensions
->Next
;
2330 // free (gOptions.ExcludeExtensions->Str);
2332 free (gOptions
.ExcludeExtensions
);
2333 gOptions
.ExcludeExtensions
= Ptr
;
2336 while (gOptions
.ExcludeFiles
!= NULL
) {
2337 Ptr
= gOptions
.ExcludeFiles
->Next
;
2339 // free (gOptions.ExcludeFiles->Str);
2341 free (gOptions
.ExcludeFiles
);
2342 gOptions
.ExcludeFiles
= Ptr
;
2346 // Given an array of 32-bit data, validate the data for the given number of
2347 // guid data. For example, it might have been scanned as 16 bytes of data, or
2348 // 11 fields of data.
2359 if (DataCount
== 16) {
2360 for (Index
= 0; Index
< 16; Index
++) {
2361 if (Data
[Index
] &~0xFF) {
2367 } else if (DataCount
== 11) {
2369 // Data[0] never out of range (32-bit)
2371 if ((Data
[1] | Data
[2]) &~0xFFFF) {
2373 // Error ("Out of range value for GUID data word(s) [1] and/or [2]");
2378 for (Index
= 0; Index
< 8; Index
++) {
2379 if (Data
[Index
+ 3] &~0xFF) {
2381 // Error ("Out of range value for GUID data byte(s) [4] - [11]");
2406 LineLen
= strlen (Line
);
2407 if ((Line
[LineLen
- 1] == '\n') && (Line
[LineLen
- 2] == '\\')) {
2408 Line
[LineLen
- 2] = '\0';
2409 fgets (Line
+ LineLen
- 2, Len
- LineLen
, Fptr
);
2410 } else if (Line
[LineLen
- 1] == '\\') {
2411 Line
[LineLen
- 1] = '\0';
2412 fgets (Line
+ LineLen
- 1, Len
- LineLen
, Fptr
);