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 180 // we concatenate two lines sometimes
33 // Define a structure that correlates filename extensions to an enumerated
37 #define UTILITY_NAME "GuidChk"
38 #define UTILITY_MAJOR_VERSION 1
39 #define UTILITY_MINOR_VERSION 0
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
;
193 ProcessINFFileGuids (
199 ProcessPkgFileGuids (
205 ProcessIA32FileGuids (
211 ProcessIA64FileGuids (
252 UINT32 DataHH
, // Upper 32-bits of upper 64 bits of guid
253 UINT32 DataHL
, // Lower 32-bits of upper 64 bits
281 // GUID_RECORD *FileRecord
297 /**************************** GLOBALS ****************************************/
298 static GUID_RECORD
*gGuidList
= NULL
;
299 static SIGNATURE_RECORD
*gSignatureList
= NULL
;
300 static OPTIONS gOptions
;
302 /*****************************************************************************/
312 SetUtilityName ("GuidChk");
314 // Get the current working directory and then process the command line
317 Cwd
= _getcwd (NULL
, 0);
318 Status
= ProcessArgs (Argc
, Argv
);
319 if (Status
!= STATUS_SUCCESS
) {
323 if (gOptions
.CheckGuids
|| gOptions
.CheckSignatures
) {
324 Status
= ProcessDirectory (Cwd
, NULL
);
325 if (Status
== STATUS_SUCCESS
) {
327 // Check for duplicates
329 Status
= CheckDuplicates ();
333 if (gOptions
.DatabaseOutputFileName
[0] != 0) {
334 CreateGuidList (gOptions
.DatabaseOutputFileName
);
337 // Free up the memory
343 return GetUtilityStatus ();
353 STRING_LIST
*StrList
;
355 memset ((char *) &gOptions
, 0, sizeof (gOptions
));
357 // skip over program name
367 if ((strcmp(Argv
[0], "-h") == 0) || (strcmp(Argv
[0], "--help") == 0) ||
368 (strcmp(Argv
[0], "-?") == 0) || (strcmp(Argv
[0], "/?") == 0)) {
373 if ((strcmp(Argv
[0], "-V") == 0) || (strcmp(Argv
[0], "--version") == 0)) {
382 if ((Argv
[0][0] == '-') || (Argv
[0][0] == '/')) {
383 switch (Argv
[0][1]) {
395 // Check guids option
399 gOptions
.CheckGuids
= TRUE
;
403 // Check signatures option
407 gOptions
.CheckSignatures
= TRUE
;
411 // Print guids found option
415 gOptions
.PrintFound
= TRUE
;
419 // Exclude files option
424 // Check for another arg
427 Error (NULL
, 0, 0, Argv
[0], "missing argument with option");
432 StrList
= malloc (sizeof (STRING_LIST
));
433 if (StrList
== NULL
) {
434 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
438 memset ((char *) StrList
, 0, sizeof (STRING_LIST
));
439 StrList
->Str
= Argv
[1];
440 StrList
->Next
= gOptions
.ExcludeFiles
;
441 gOptions
.ExcludeFiles
= StrList
;
447 // Exclude directories option
452 // Check for another arg
455 Error (NULL
, 0, 0, Argv
[0], "missing argument with option");
460 StrList
= malloc (sizeof (STRING_LIST
));
461 if (StrList
== NULL
) {
462 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
466 memset ((char *) StrList
, 0, sizeof (STRING_LIST
));
467 StrList
->Str
= Argv
[1];
468 StrList
->Next
= gOptions
.ExcludeDirs
;
469 gOptions
.ExcludeDirs
= StrList
;
475 // -u exclude all subdirectories of a given directory option
480 // Check for another arg
483 Error (NULL
, 0, 0, Argv
[0], "missing argument with option");
488 StrList
= malloc (sizeof (STRING_LIST
));
489 if (StrList
== NULL
) {
490 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
494 memset ((char *) StrList
, 0, sizeof (STRING_LIST
));
495 StrList
->Str
= Argv
[1];
496 StrList
->Next
= gOptions
.ExcludeSubDirs
;
497 gOptions
.ExcludeSubDirs
= StrList
;
503 // -e exclude by filename extension option
508 // Check for another arg
511 Error (NULL
, 0, 0, Argv
[0], "missing argument with option");
516 StrList
= malloc (sizeof (STRING_LIST
));
517 if (StrList
== NULL
) {
518 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
522 memset ((char *) StrList
, 0, sizeof (STRING_LIST
));
524 // Let them put a * in front of the filename extension
526 StrList
->Str
= Argv
[1];
527 if (StrList
->Str
[0] == '*') {
531 StrList
->Next
= gOptions
.ExcludeExtensions
;
532 gOptions
.ExcludeExtensions
= StrList
;
538 // Print guid with matching symbol name for guid definitions found
542 gOptions
.GuidXReference
= 1;
546 // -b Print the internal database list to a file
551 // Check for one more arg
554 Error (NULL
, 0, 0, Argv
[0], "must specify file name with option");
559 strcpy (gOptions
.DatabaseOutputFileName
, Argv
[1]);
565 Error (NULL
, 0, 0, Argv
[0], "invalid option");
580 Error (NULL
, 0, 0, Argv
[0], "invalid argument");
585 // Have to check signatures, GUIDs, or dump the GUID database.
587 if ((!gOptions
.CheckGuids
) && (!gOptions
.CheckSignatures
) && (gOptions
.DatabaseOutputFileName
[0] == 0)) {
588 Error (NULL
, 0, 0, "nothing to do", "must specify -g, -s, and/or -b");
593 return STATUS_SUCCESS
;
605 Displays the standard utility information to SDTOUT
617 printf ("%s v%d.%d -Utility for checking guid duplication for files in a given directory.\n", UTILITY_NAME
, UTILITY_MAJOR_VERSION
, UTILITY_MINOR_VERSION
);
618 printf ("Copyright (c) 1999-2007 Intel Corporation. All rights reserved.\n");
622 // Print usage instructions
632 "GuidChk - scan files for duplicate GUID or signature definitions",
634 "Usage: GuidChk {options}\n",
636 " -d dirname exclude searching of a directory",
637 " -f filename exclude searching of a file",
638 " -e extension exclude searching of files by extension",
639 " -p print all GUIDS found",
640 " -g check for duplicate guids",
641 " -s check for duplicate signatures",
642 " -x print guid+defined symbol name",
643 " -b outfile write internal GUID+basename list to outfile",
644 " -u dirname exclude searching all subdirectories of a directory",
645 " -h,--help,-?,/? display help messages",
646 " -V,--version display version information",
648 " Example: GuidChk -g -u build -d fv -f make.inf -e .pkg",
655 for (Index
= 0; Str
[Index
] != NULL
; Index
++) {
656 fprintf (stdout
, "%s\n", Str
[Index
]);
660 // Process an entire directory by name
669 FILE_SEARCH_DATA FSData
;
677 // Root directory may be null
679 if (DirectoryName
!= NULL
) {
681 // printf ("Processing directory: %s\n", DirectoryName);
685 // Initialize our file searching
687 FileSearchInit (&FSData
);
690 // Exclude some directories, files, and extensions
692 FileSearchExcludeDirs (&FSData
, gOptions
.ExcludeDirs
);
693 FileSearchExcludeExtensions (&FSData
, gOptions
.ExcludeExtensions
);
694 FileSearchExcludeFiles (&FSData
, gOptions
.ExcludeFiles
);
696 // See if this directory is in the list of directories that they
697 // don't want to process subdirectories of
700 if (DirectoryName
!= NULL
) {
701 for (SLPtr
= gOptions
.ExcludeSubDirs
; SLPtr
!= NULL
; SLPtr
= SLPtr
->Next
) {
702 if (stricmp (SLPtr
->Str
, DirectoryName
) == 0) {
704 // printf ("not processing subdirectories of %s\n", DirectoryName);
712 // Create a filemask of files to search for. We'll append "\*.*" on the
713 // end, so allocate some extra bytes.
715 Len
= strlen (Path
) + 10;
716 if (DirectoryName
!= NULL
) {
717 Len
+= strlen (DirectoryName
);
720 FileMask
= malloc (Len
);
721 if (FileMask
== NULL
) {
722 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
726 // Now put it all together
728 strcpy (FileMask
, Path
);
729 if ((DirectoryName
!= NULL
) && (strlen (DirectoryName
) > 0)) {
730 strcat (FileMask
, "\\");
731 strcat (FileMask
, DirectoryName
);
734 strcat (FileMask
, "\\*.*");
737 // Start file searching for files and directories
739 FileSearchStart (&FSData
, FileMask
, FILE_SEARCH_FILE
| FILE_SEARCH_DIR
);
742 // Now hack the "\*.*" off the end of the filemask so we can use it to pass
743 // the full directory path on recursive calls to process directories.
745 FileMask
[strlen (FileMask
) - 4] = 0;
748 // Loop until no more files
753 // printf ("Found %s...", FSData.FileName);
755 if (FSData
.FileFlags
& FILE_SEARCH_DIR
) {
757 // printf ("directory\n");
760 ProcessDirectory (FileMask
, FSData
.FileName
);
762 } else if (FSData
.FileFlags
& FILE_SEARCH_FILE
) {
764 // printf ("file\n");
766 ProcessFile (FileMask
, FSData
.FileName
);
769 // printf ("unknown\n");
773 if (FileSearchFindNext (&FSData
) != STATUS_SUCCESS
) {
778 // Free up allocated memory
783 // Free up our file searching
785 FileSearchDestroy (&FSData
);
787 return STATUS_SUCCESS
;
790 // Process a single file.
800 UINT32 FileExtension
;
801 INT8 FullFileName
[MAX_PATH
];
803 Status
= STATUS_SUCCESS
;
805 sprintf (FullFileName
, "%s\\%s", DirectoryName
, FileName
);
807 // printf ("Found file: %s\n", FullFileName);
809 FileExtension
= GetFileExtension (FileName
);
812 // Process these for GUID checks
814 if (gOptions
.CheckGuids
) {
815 switch (FileExtension
) {
816 case FILE_EXTENSION_C
:
817 case FILE_EXTENSION_H
:
818 Status
= ProcessCFileGuids (FullFileName
);
821 case FILE_EXTENSION_PKG
:
822 Status
= ProcessPkgFileGuids (FullFileName
);
825 case FILE_EXTENSION_IA32_INC
:
826 case FILE_EXTENSION_IA32_ASM
:
827 Status
= ProcessIA32FileGuids (FullFileName
);
830 case FILE_EXTENSION_INF
:
831 Status
= ProcessINFFileGuids (FullFileName
);
834 case FILE_EXTENSION_IA64_INC
:
835 case FILE_EXTENSION_IA64_ASM
:
836 Status
= ProcessIA64FileGuids (FullFileName
);
843 Status
= STATUS_SUCCESS
;
848 if (gOptions
.CheckSignatures
) {
849 switch (FileExtension
) {
850 case FILE_EXTENSION_C
:
851 case FILE_EXTENSION_H
:
852 Status
= ProcessCFileSigs (FullFileName
);
859 Status
= STATUS_SUCCESS
;
867 // Return a code indicating the file name extension.
879 // Look back for a filename extension
881 for (Extension
= FileName
+ strlen (FileName
) - 1; Extension
>= FileName
; Extension
--) {
882 if (*Extension
== '.') {
883 for (Index
= 0; FileTypeTable
[Index
].Extension
!= NULL
; Index
++) {
884 if (stricmp (FileTypeTable
[Index
].Extension
, Extension
) == 0) {
885 return FileTypeTable
[Index
].ExtensionCode
;
891 return FILE_TYPE_UNKNOWN
;
894 // Process a .pkg file.
896 // Look for FFS_FILEGUID=35b898ca-b6a9-49ce-8c72-904735cc49b7
900 ProcessPkgFileGuids (
905 INT8 Line
[MAX_LINE_LEN
* 2];
911 if ((Fptr
= fopen (FileName
, "r")) == NULL
) {
912 Error (NULL
, 0, 0, FileName
, "could not open input file for reading");
916 // Read lines from the file until done
918 while (fgets (Line
, sizeof (Line
), Fptr
) != NULL
) {
920 Cptr
+= SkipWhiteSpace (Line
);
921 if (strncmp (Cptr
, "FFS_FILEGUID", 12) == 0) {
923 Cptr
+= SkipWhiteSpace (Cptr
);
926 Cptr
+= SkipWhiteSpace (Cptr
+ 1);
928 // Blank out dashes on the line.
930 for (Cptr2
= Cptr
; *Cptr2
; Cptr2
++) {
945 AddPkgGuid (FileName
, GuidScan
, &Guid64
);
947 DebugMsg (NULL
, 0, 0, FileName
, "GUID scan failed");
954 return STATUS_SUCCESS
;
957 // Process an IA32 assembly file.
960 // FIND_FD_GUID_VAL equ 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h
961 // PEI_GUID_FileNameGuid_Gmch815 equ 081818181h, 08181h, 08181h, 081h, 081h, 081h, 081h, 081h, 081h, 081h, 081h
965 ProcessIA32FileGuids (
970 INT8 Line
[MAX_LINE_LEN
];
978 if ((Fptr
= fopen (FileName
, "r")) == NULL
) {
979 Error (NULL
, 0, 0, FileName
, "could not open input file for reading");
983 // Read lines from the file until done
985 while (fgets (Line
, sizeof (Line
), Fptr
) != NULL
) {
987 Cptr
+= SkipWhiteSpace (Line
);
989 // Look for xxxGUIDyyy equ 01h, 02h, 03h, ...
991 Len
= ValidSymbolName (Cptr
);
994 // Terminate the line after the symbol name, then look for "guid" in
997 CSavePtr
= Cptr
+ Len
;
1001 if (strnicmp (Cptr
, "guid", 4) == 0) {
1008 // If we found the string "guid", continue
1012 // Restore the character on the line where we null-terminated the symbol
1016 Len
= SkipWhiteSpace (Cptr
);
1018 // Had to be some white space
1023 // now look for "equ"
1025 if (strnicmp (Cptr
, "equ", 3) == 0) {
1027 Cptr
+= SkipWhiteSpace (Cptr
);
1029 // Now scan all the data
1031 for (Index
= 0; Index
< 16; Index
++) {
1032 if (sscanf (Cptr
, "%X", &GuidData
[Index
]) != 1) {
1038 while (isxdigit (*Cptr
)) {
1042 if ((*Cptr
!= 'h') && (*Cptr
!= 'H')) {
1046 while (*Cptr
&& (isspace (*Cptr
) || (*Cptr
== ','))) {
1052 // Now see which form we had
1055 AddGuid16 (FileName
, GuidData
);
1056 } else if (Index
== 11) {
1057 AddGuid11 (FileName
, GuidData
, NULL
);
1066 return STATUS_SUCCESS
;
1069 // Found and parsed an IA32 assembly code guid. Save the 16 bytes off in the list
1079 GUID_RECORD
*NewRec
;
1083 // Sanity check the data
1085 if (!CheckGuidData (Data
, 16)) {
1086 return STATUS_ERROR
;
1089 // Allocate memory for a new guid structure
1091 NewRec
= malloc (sizeof (GUID_RECORD
));
1092 if (NewRec
== NULL
) {
1093 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
1094 return STATUS_ERROR
;
1097 memset ((char *) NewRec
, 0, sizeof (GUID_RECORD
));
1098 NewRec
->FileName
= malloc (strlen (FileName
) + 1);
1099 if (NewRec
->FileName
== NULL
) {
1101 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
1102 return STATUS_ERROR
;
1105 strcpy (NewRec
->FileName
, FileName
);
1106 NewRec
->Guid
.Data1
= (UINT32
) (Data
[0] | (Data
[1] << 8) | (Data
[2] << 16) | (Data
[3] << 24));
1107 NewRec
->Guid
.Data2
= (UINT16
) (Data
[4] | (Data
[5] << 8));
1108 NewRec
->Guid
.Data3
= (UINT16
) (Data
[6] | (Data
[7] << 8));
1109 for (Index
= 0; Index
< 8; Index
++) {
1110 NewRec
->Guid
.Data4
[Index
] = (UINT8
) Data
[Index
+ 8];
1113 // Add it to the list
1115 NewRec
->Next
= gGuidList
;
1120 // ReportGuid (FileName, NewRec);
1122 return STATUS_SUCCESS
;
1125 // Add a GUID defined as GuidLow: 0x1122334455667788
1126 // GuidHi: 0x99AABBCCDDEEFF00
1128 // These are equivalent:
1129 // { 0x11223344, 0x5566, 0x7788, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x00 }
1131 // Low: 00FFEEDDCCBBAA99
1132 // Hi: 7788556611223344
1138 UINT32 DataHH
, // Upper 32-bits of upper 64 bits of guid
1139 UINT32 DataHL
, // Lower 32-bits of upper 64 bits
1144 GUID_RECORD
*NewRec
;
1148 // Allocate memory for a new guid structure
1150 NewRec
= malloc (sizeof (GUID_RECORD
));
1151 if (NewRec
== NULL
) {
1152 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
1153 return STATUS_ERROR
;
1156 memset ((char *) NewRec
, 0, sizeof (GUID_RECORD
));
1157 NewRec
->FileName
= malloc (strlen (FileName
) + 1);
1158 if (NewRec
->FileName
== NULL
) {
1160 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
1161 return STATUS_ERROR
;
1164 strcpy (NewRec
->FileName
, FileName
);
1165 NewRec
->Guid
.Data1
= DataHL
;
1166 NewRec
->Guid
.Data2
= (UINT16
) DataHH
;
1167 NewRec
->Guid
.Data3
= (UINT16
) (DataHH
>> 16);
1168 for (Index
= 0; Index
< 4; Index
++) {
1169 NewRec
->Guid
.Data4
[Index
] = (UINT8
) DataLL
;
1173 for (Index
= 0; Index
< 4; Index
++) {
1174 NewRec
->Guid
.Data4
[Index
+ 4] = (UINT8
) DataLH
;
1178 // Add it to the list
1180 NewRec
->Next
= gGuidList
;
1185 // ReportGuid (FileName, NewRec);
1187 return STATUS_SUCCESS
;
1190 // Process INF files. Look for:
1191 // FILE_GUID = 240612B6-A063-11d4-9A3A-0090273FC14D
1195 ProcessINFFileGuids (
1200 INT8 Line
[MAX_LINE_LEN
* 2];
1203 UINT32 GuidScan
[11];
1206 if ((Fptr
= fopen (FileName
, "r")) == NULL
) {
1207 Error (NULL
, 0, 0, FileName
, "could not open input file for reading");
1208 return STATUS_ERROR
;
1211 // Read lines from the file until done
1213 while (fgets (Line
, sizeof (Line
), Fptr
) != NULL
) {
1215 Cptr
+= SkipWhiteSpace (Line
);
1216 if (strncmp (Cptr
, "FILE_GUID", 9) == 0) {
1218 Cptr
+= SkipWhiteSpace (Cptr
);
1221 Cptr
+= SkipWhiteSpace (Cptr
+ 1);
1223 // Blank out dashes on the line.
1225 for (Cptr2
= Cptr
; *Cptr2
; Cptr2
++) {
1226 if (*Cptr2
== '-') {
1233 "%X %X %X %X %I64X",
1240 AddPkgGuid (FileName
, GuidScan
, &Guid64
);
1242 DebugMsg (NULL
, 0, 0, FileName
, "GUID scan failed");
1249 return STATUS_SUCCESS
;
1252 // Parse ('g','m','a','p','a','b','c','d')
1262 SIGNATURE_RECORD
*NewRec
;
1268 // Allocate memory for the new record
1271 NewRec
= malloc (sizeof (SIGNATURE_RECORD
));
1272 if (NewRec
== NULL
) {
1273 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
1274 return STATUS_ERROR
;
1277 // Allocate memory to save the file name
1279 NewRec
->FileName
= malloc (strlen (FileName
) + 1);
1280 if (NewRec
->FileName
== NULL
) {
1281 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
1283 return STATUS_ERROR
;
1286 // Fill in the fields
1288 strcpy (NewRec
->FileName
, FileName
);
1289 NewRec
->Signature
.DataLen
= (UINT8
) SigSize
;
1291 // Skip to open parenthesis
1294 Cptr
+= SkipWhiteSpace (Cptr
);
1302 // Skip to first ' and start processing
1304 while (*Cptr
&& (*Cptr
!= '\'')) {
1308 for (Index
= 0; Index
< SigSize
; Index
++) {
1309 if (*Cptr
== '\'') {
1311 NewRec
->Signature
.Data
[Index
] = (INT8
) *Cptr
;
1313 // Skip to closing quote
1316 if (*Cptr
!= '\'') {
1321 // Skip over closing quote, go to next one
1324 while (*Cptr
&& (*Cptr
!= '\'')) {
1329 DebugMsg (NULL
, 0, 0, StrDef
, "failed to parse signature");
1336 free (NewRec
->FileName
);
1338 return STATUS_ERROR
;
1341 NewRec
->Next
= gSignatureList
;
1342 gSignatureList
= NewRec
;
1343 return STATUS_SUCCESS
;
1347 // #define POOL_HEAD_SIGNATURE EFI_SIGNATURE_16('p','h')
1348 // #define GCD_MEMORY_MAP_SIGNATURE EFI_SIGNATURE_32('g','m','a','p')
1349 // #define GCD_MEMORY_MAP_SIGNATURE EFI_SIGNATURE_64('g','m','a','p','a','b','c','d')
1358 INT8 Line
[MAX_LINE_LEN
* 2];
1363 if ((Fptr
= fopen (FileName
, "r")) == NULL
) {
1364 Error (NULL
, 0, 0, FileName
, "could not open input file for reading");
1365 return STATUS_ERROR
;
1368 // Read lines from the file until done
1370 while (fgets (Line
, sizeof (Line
), Fptr
) != NULL
) {
1372 Cptr
+= SkipWhiteSpace (Line
);
1374 // look for #define xxxGUIDxxx value
1378 Cptr
+= SkipWhiteSpace (Cptr
);
1380 // Look for "define"
1382 if (!strncmp (Cptr
, "define", 6)) {
1385 // Better be whitespace
1387 Len
= SkipWhiteSpace (Cptr
);
1391 // See if it's a valid symbol name
1393 Len
= ValidSymbolName (Cptr
);
1396 // It is a valid symbol name. See if there's a line continuation,
1397 // and if so, read one more line.
1398 // Skip over the symbol name and look for the string "EFI_SIGNATURE_xx"
1400 LineLen
= strlen (Line
);
1401 if ((Line
[LineLen
- 1] == '\n') && (Line
[LineLen
- 2] == '\\')) {
1402 fgets (Line
+ LineLen
- 2, sizeof (Line
) - LineLen
, Fptr
);
1403 } else if (Line
[LineLen
- 1] == '\\') {
1404 fgets (Line
+ LineLen
- 1, sizeof (Line
) - LineLen
, Fptr
);
1408 Cptr
+= SkipWhiteSpace (Cptr
);
1409 if (strncmp (Cptr
, "EFI_SIGNATURE_16", 16) == 0) {
1410 AddSignature (FileName
, Cptr
+ 16, 2);
1411 } else if (strncmp (Cptr
, "EFI_SIGNATURE_32", 16) == 0) {
1412 AddSignature (FileName
, Cptr
+ 16, 4);
1413 } else if (strncmp (Cptr
, "EFI_SIGNATURE_64", 16) == 0) {
1414 AddSignature (FileName
, Cptr
+ 16, 8);
1423 return STATUS_SUCCESS
;
1426 // look for #define xxxGUIDyyy { 0x...}
1427 // xxx EFI_GUID GuidName = { 0x... };
1436 INT8 Line
[MAX_LINE_LEN
* 2];
1444 UINT32 GuidScan
[11];
1446 if ((Fptr
= fopen (FileName
, "r")) == NULL
) {
1447 Error (NULL
, 0, 0, FileName
, "could not open input file for reading");
1448 return STATUS_ERROR
;
1451 // Read lines from the file until done
1453 while (fgets (Line
, sizeof (Line
), Fptr
) != NULL
) {
1455 Cptr
+= SkipWhiteSpace (Line
);
1457 // look for #define xxxGUIDxxx value
1461 Cptr
+= SkipWhiteSpace (Cptr
);
1463 // Look for "define"
1465 if (!strncmp (Cptr
, "define", 6)) {
1468 // Better be whitespace
1470 Len
= SkipWhiteSpace (Cptr
);
1474 // See if it's a valid symbol name
1476 Len
= ValidSymbolName (Cptr
);
1479 // It is a valid symbol name. See if there's a line continuation,
1480 // and if so, read one more line.
1481 // Then truncate after the symbol name, look for the string "GUID",
1485 LineLen
= strlen (Line
);
1486 if ((Line
[LineLen
- 1] == '\n') && (Line
[LineLen
- 2] == '\\')) {
1487 fgets (Line
+ LineLen
- 2, sizeof (Line
) - LineLen
, Fptr
);
1488 } else if (Line
[LineLen
- 1] == '\\') {
1489 fgets (Line
+ LineLen
- 1, sizeof (Line
) - LineLen
, Fptr
);
1492 CSavePtr
= Cptr
+ Len
;
1496 if (strncmp (Cptr
, "GUID", 4) == 0) {
1503 // If we didn't run out of string, then we found the GUID string.
1504 // Now look for { 0x....... }
1509 Cptr
+= SkipWhiteSpace (Cptr
);
1514 // 0x665E3FF6, 0x46CC, 0x11d4, 0x9A, 0x38, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }
1515 // If you have one suffixed with "L", then it doesn't work. So hack off 'L' characters
1518 for (TempCptr
= Cptr
; *TempCptr
; TempCptr
++) {
1519 if (*TempCptr
== 'L') {
1520 if (*(TempCptr
+ 1) == ',') {
1522 *(TempCptr
+ 1) = ' ';
1529 "%X, %X, %X, %X, %X, %X, %X, %X, %X, %X, %X",
1542 AddGuid11 (FileName
, GuidScan
, SymName
);
1550 // Else look for "static EFI_GUID xxxGUIDxxx = { 0x.... };
1552 } else if ((CSavePtr
= strstr (Line
, "EFI_GUID")) != NULL
) {
1554 // Read the next line if line continuation
1556 LineLen
= strlen (Line
);
1557 if ((Line
[LineLen
- 1] == '\n') && (Line
[LineLen
- 2] == '\\')) {
1558 fgets (Line
+ LineLen
- 2, sizeof (Line
) - LineLen
, Fptr
);
1559 } else if (Line
[LineLen
- 1] == '\\') {
1560 fgets (Line
+ LineLen
- 1, sizeof (Line
) - LineLen
, Fptr
);
1563 Cptr
= CSavePtr
+ 8;
1564 Cptr
+= SkipWhiteSpace (Cptr
);
1566 // Should be variable name next
1568 Len
= ValidSymbolName (Cptr
);
1571 Cptr
+= SkipWhiteSpace (Cptr
);
1574 Cptr
+= SkipWhiteSpace (Cptr
);
1576 // Should be open-brace next to define guid
1581 // 0x665E3FF6, 0x46CC, 0x11d4, 0x9A, 0x38, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }
1585 "%X, %X, %X, %X, %X, %X, %X, %X, %X, %X, %X",
1598 AddGuid11 (FileName
, GuidScan
, Cptr
);
1600 // printf ("Found guid: %s", Cptr);
1609 return STATUS_SUCCESS
;
1612 // Process Intel Itanium(TM) GUID definitions. Look for:
1613 // #define Cs870MemoryTestPEIMGuidL 0x9C2403386E1C8FAA
1614 // #define Cs870MemoryTestPEIMGuidH 0xE89E95C6180342f0
1616 // This function assumes no blank lines between definitions.
1620 ProcessIA64FileGuids (
1625 INT8 Line
[MAX_LINE_LEN
];
1630 INT8 SymName1
[MAX_LINE_LEN
];
1631 INT8 SymName2
[MAX_LINE_LEN
];
1636 if ((Fptr
= fopen (FileName
, "r")) == NULL
) {
1637 Error (NULL
, 0, 0, FileName
, "could not open input file for reading");
1638 return STATUS_ERROR
;
1642 if (fgets (Line
, sizeof (Line
), Fptr
) == NULL
) {
1646 // Read lines from the file until done. Since the guid definition takes
1647 // two lines, we read lines in different places to recover gracefully
1648 // from mismatches. For example, if you thought you found the first half,
1649 // but the next line had a symbol mismatch, then you have to process the
1650 // line again in case it's the start of a new definition.
1654 // Check current line for GUID definition. Assume low define first.
1656 if (IsIA64GuidLine (Line
, &Guid1H
, &Guid1L
, &FoundLow
, SymName1
)) {
1658 // Might have to swap guids later. Save off if we found the LOW first
1666 // Read the next line and try for the rest of the guid definition
1668 if (fgets (Line
, sizeof (Line
), Fptr
) == NULL
) {
1671 if (IsIA64GuidLine (Line
, &Guid2H
, &Guid2L
, &FoundLow
, SymName2
)) {
1673 // Found another. If the symbol names match, then save it off.
1675 if (strcmp (SymName1
, SymName2
) == 0) {
1677 // Yea, found one. Save it off.
1680 AddGuid64x2 (FileName
, Guid2H
, Guid2L
, Guid1H
, Guid1L
);
1682 AddGuid64x2 (FileName
, Guid1H
, Guid1L
, Guid2H
, Guid2L
);
1685 // Read the next line for processing
1687 if (fgets (Line
, sizeof (Line
), Fptr
) == NULL
) {
1692 // Don't get another line so that we reprocess this line in case it
1693 // contains the start of a new definition.
1694 // fprintf (stdout, "Symbol name mismatch: %s: %s != %s\n",
1695 // FileName, SymName1, SymName2);
1700 // Second line was not a guid definition. Get the next line from the
1703 if (fgets (Line
, sizeof (Line
), Fptr
) == NULL
) {
1710 // Not a guid define line. Next.
1712 if (fgets (Line
, sizeof (Line
), Fptr
) == NULL
) {
1719 return STATUS_SUCCESS
;
1722 // Given a line from an Itanium-based assembly file, check the line for a guid
1723 // defininition. One of either:
1724 // #define Cs870MemoryTestPEIMGuidL 0x9C2403386E1C8FAA
1725 // #define Cs870MemoryTestPEIMGuidH 0xE89E95C6180342f0
1726 // Return the defined value as two 32-bit values, and whether it's a high
1746 Cptr
+= SkipWhiteSpace (Cptr
);
1748 // look for #define xxxGUID[L|H] 0xHexValue
1752 Cptr
+= SkipWhiteSpace (Cptr
);
1754 // Look for "define"
1756 if (!strncmp (Cptr
, "define", 6)) {
1759 // Better be whitespace
1761 Len
= SkipWhiteSpace (Cptr
);
1765 // See if it's a valid symbol name
1767 Len
= ValidSymbolName (Cptr
);
1770 // Save the start so we can copy it to their string if later checks are ok
1774 // It is a valid symbol name, look for the string GuidL or GuidH
1776 CSavePtr
= Cptr
+ Len
;
1780 if (strncmp (Cptr
, "GuidL", 5) == 0) {
1783 } else if (strncmp (Cptr
, "GuidH", 5) == 0) {
1791 // If we didn't run out of string, then we found the GUID string.
1792 // Restore the null character we inserted above and continue.
1793 // Now look for 0x.......
1797 // Return symbol name less the "L" or "H"
1799 strcpy (SymName
, SymStart
);
1800 SymName
[strlen (SymName
) - 1] = 0;
1803 Cptr
+= SkipWhiteSpace (Cptr
);
1804 if ((*Cptr
== '0') && (*(Cptr
+ 1) == 'x')) {
1810 // 0x0123456789ABCDEF -- null terminate after 8 characters,
1811 // scan, replace the character and scan at that point.
1813 CSave
= *(Cptr
+ 8);
1815 if (sscanf (Cptr
, "%X", GuidHigh
) == 1) {
1816 *(Cptr
+ 8) = CSave
;
1817 if (sscanf (Cptr
+ 8, "%X", GuidLow
) == 1) {
1831 // Look at the characters in the string and determine if it's a valid
1832 // symbol name. Basically [a-zA-Z_][a-zA-Z_0-9]*
1845 // Test first character
1847 if (((*Name
>= 'a') && (*Name
<= 'z')) || ((*Name
>= 'A') && (*Name
<= 'Z')) || (*Name
== '_')) {
1851 if (((*Name
>= 'a') && (*Name
<= 'z')) ||
1852 ((*Name
>= 'A') && (*Name
<= 'Z')) ||
1853 ((*Name
>= '0') && (*Name
<= '9')) ||
1875 while (isspace (*Str
) && *Str
) {
1883 // found FFS_FILEGUID=35b898ca-b6a9-49ce-8c72-904735cc49b7
1893 GUID_RECORD
*NewRec
;
1897 // Sanity check the data
1899 if ((Data
[1] | Data
[2] | Data
[3]) & 0xFFFF0000) {
1900 Error (NULL
, 0, 0, "out of range value for GUID data word(s) [1] - [3]", NULL
);
1901 return STATUS_ERROR
;
1904 // More checks for Data64?
1905 // Allocate memory for a new one guid structure
1907 NewRec
= malloc (sizeof (GUID_RECORD
));
1908 if (NewRec
== NULL
) {
1909 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
1910 return STATUS_ERROR
;
1913 memset ((char *) NewRec
, 0, sizeof (GUID_RECORD
));
1914 NewRec
->FileName
= malloc (strlen (FileName
) + 1);
1915 if (NewRec
->FileName
== NULL
) {
1917 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
1918 return STATUS_ERROR
;
1921 strcpy (NewRec
->FileName
, FileName
);
1922 NewRec
->Guid
.Data1
= Data
[0];
1923 NewRec
->Guid
.Data2
= (UINT16
) Data
[1];
1924 NewRec
->Guid
.Data3
= (UINT16
) Data
[2];
1925 NewRec
->Guid
.Data4
[0] = (UINT8
) Data
[3];
1926 NewRec
->Guid
.Data4
[1] = (UINT8
) (Data
[3] >> 8);
1927 for (Index
= 2; Index
< 8; Index
++) {
1928 NewRec
->Guid
.Data4
[Index
] = (UINT8
) *Data64
;
1932 // Add it to the list
1934 NewRec
->Next
= gGuidList
;
1939 // ReportGuid (FileName, NewRec);
1941 return STATUS_SUCCESS
;
1944 // Add a guid consisting of 11 fields to our list of guids
1954 GUID_RECORD
*NewRec
;
1958 // Sanity check the data
1960 if (!CheckGuidData (Data
, 11)) {
1961 return STATUS_ERROR
;
1964 // Allocate memory for a new one guid structure
1966 NewRec
= malloc (sizeof (GUID_RECORD
));
1967 if (NewRec
== NULL
) {
1968 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
1969 return STATUS_ERROR
;
1972 memset ((char *) NewRec
, 0, sizeof (GUID_RECORD
));
1973 NewRec
->FileName
= malloc (strlen (FileName
) + 1);
1974 if (NewRec
->FileName
== NULL
) {
1976 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
1977 return STATUS_ERROR
;
1980 strcpy (NewRec
->FileName
, FileName
);
1981 if (SymName
!= NULL
) {
1982 NewRec
->SymName
= malloc (strlen (SymName
) + 1);
1983 if (NewRec
->SymName
== NULL
) {
1985 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
1986 return STATUS_ERROR
;
1990 strcpy (NewRec
->SymName
, SymName
);
1992 NewRec
->Guid
.Data1
= Data
[0];
1993 NewRec
->Guid
.Data2
= (UINT16
) Data
[1];
1994 NewRec
->Guid
.Data3
= (UINT16
) Data
[2];
1995 for (Index
= 0; Index
< 8; Index
++) {
1996 NewRec
->Guid
.Data4
[Index
] = (UINT8
) Data
[3 + Index
];
1999 // Add it to the list
2001 NewRec
->Next
= gGuidList
;
2006 // ReportGuid (FileName, NewRec);
2008 return STATUS_SUCCESS
;
2011 // For debug purposes, print each guid found
2017 // GUID_RECORD *NewGuid
2020 // //fprintf (stdout, "%s: 0x%08X\n", FileName, NewGuid->Guid.Data1);
2023 // Free up memory we allocated to keep track of guids defined.
2031 GUID_RECORD
*NextRec
;
2032 while (gGuidList
!= NULL
) {
2033 NextRec
= gGuidList
->Next
;
2034 if (gGuidList
->FileName
!= NULL
) {
2035 free (gGuidList
->FileName
);
2038 if (gGuidList
->SymName
!= NULL
) {
2039 free (gGuidList
->SymName
);
2043 gGuidList
= NextRec
;
2053 SIGNATURE_RECORD
*NextRec
;
2054 while (gSignatureList
!= NULL
) {
2055 NextRec
= gSignatureList
->Next
;
2056 if (gSignatureList
->FileName
!= NULL
) {
2057 free (gSignatureList
->FileName
);
2060 free (gSignatureList
);
2061 gSignatureList
= NextRec
;
2065 // Scan through all guids defined and compare each for duplicates.
2073 GUID_RECORD
*CurrentFile
;
2075 GUID_RECORD
*TempFile
;
2076 SIGNATURE_RECORD
*CurrentSig
;
2077 SIGNATURE_RECORD
*TempSig
;
2086 Status
= STATUS_SUCCESS
;
2089 // If we're checking guids.....
2091 if (gOptions
.CheckGuids
) {
2093 // If -p option, print all guids found
2095 if (gOptions
.PrintFound
) {
2096 CurrentFile
= gGuidList
;
2097 while (CurrentFile
!= NULL
) {
2100 "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",
2101 (UINT32
) CurrentFile
->Guid
.Data1
,
2102 (UINT32
) CurrentFile
->Guid
.Data2
,
2103 (UINT32
) CurrentFile
->Guid
.Data3
,
2104 (UINT32
) CurrentFile
->Guid
.Data4
[0],
2105 (UINT32
) CurrentFile
->Guid
.Data4
[1],
2106 (UINT32
) CurrentFile
->Guid
.Data4
[2],
2107 (UINT32
) CurrentFile
->Guid
.Data4
[3],
2108 (UINT32
) CurrentFile
->Guid
.Data4
[4],
2109 (UINT32
) CurrentFile
->Guid
.Data4
[5],
2110 (UINT32
) CurrentFile
->Guid
.Data4
[6],
2111 (UINT32
) CurrentFile
->Guid
.Data4
[7],
2112 CurrentFile
->FileName
2114 CurrentFile
= CurrentFile
->Next
;
2118 if (gOptions
.GuidXReference
) {
2119 CurrentFile
= gGuidList
;
2120 while (CurrentFile
!= NULL
) {
2122 // If no symbol name, print "unknown"
2124 SymName
= CurrentFile
->SymName
;
2125 if (SymName
== NULL
) {
2126 SymName
= "unknown";
2131 "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X %s\n",
2132 (UINT32
) CurrentFile
->Guid
.Data1
,
2133 (UINT32
) CurrentFile
->Guid
.Data2
,
2134 (UINT32
) CurrentFile
->Guid
.Data3
,
2135 (UINT32
) CurrentFile
->Guid
.Data4
[0],
2136 (UINT32
) CurrentFile
->Guid
.Data4
[1],
2137 (UINT32
) CurrentFile
->Guid
.Data4
[2],
2138 (UINT32
) CurrentFile
->Guid
.Data4
[3],
2139 (UINT32
) CurrentFile
->Guid
.Data4
[4],
2140 (UINT32
) CurrentFile
->Guid
.Data4
[5],
2141 (UINT32
) CurrentFile
->Guid
.Data4
[6],
2142 (UINT32
) CurrentFile
->Guid
.Data4
[7],
2145 CurrentFile
= CurrentFile
->Next
;
2149 // Now go through all guids and report duplicates.
2151 CurrentFile
= gGuidList
;
2152 while (CurrentFile
!= NULL
) {
2154 TempFile
= CurrentFile
->Next
;
2157 // Compare the guids
2159 if ((CurrentFile
->Guid
.Data1
== TempFile
->Guid
.Data1
) &&
2160 (CurrentFile
->Guid
.Data2
== TempFile
->Guid
.Data2
) &&
2161 (CurrentFile
->Guid
.Data3
== TempFile
->Guid
.Data3
)
2164 // OR in all the guid bytes so we can ignore NULL-guid definitions.
2166 GuidSum
= CurrentFile
->Guid
.Data1
| CurrentFile
->Guid
.Data2
| CurrentFile
->Guid
.Data3
;
2168 for (Index
= 0; Index
< 8; Index
++) {
2169 GuidSum
|= CurrentFile
->Guid
.Data4
[Index
];
2170 if (CurrentFile
->Guid
.Data4
[Index
] != TempFile
->Guid
.Data4
[Index
]) {
2176 // If they're the same, and the guid was non-zero, print a message.
2178 if (Same
&& GuidSum
) {
2179 if (DupCount
== 0) {
2180 Error (NULL
, 0, 0, "duplicate GUIDS found", NULL
);
2181 fprintf (stdout
, " FILE1: %s\n", CurrentFile
->FileName
);
2185 fprintf (stdout
, " FILE%d: %s\n", DupCount
+ 1, TempFile
->FileName
);
2187 // Flag it as reported so we don't report it again if there's three or more
2189 TempFile
->Reported
= TRUE
;
2195 TempFile
= TempFile
->Next
;
2198 // Print the guid if we found duplicates
2203 " GUID: 0x%08X 0x%04X 0x%04X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X\n",
2204 (UINT32
) CurrentFile
->Guid
.Data1
,
2205 (UINT32
) CurrentFile
->Guid
.Data2
,
2206 (UINT32
) CurrentFile
->Guid
.Data3
,
2207 (UINT32
) CurrentFile
->Guid
.Data4
[0],
2208 (UINT32
) CurrentFile
->Guid
.Data4
[1],
2209 (UINT32
) CurrentFile
->Guid
.Data4
[2],
2210 (UINT32
) CurrentFile
->Guid
.Data4
[3],
2211 (UINT32
) CurrentFile
->Guid
.Data4
[4],
2212 (UINT32
) CurrentFile
->Guid
.Data4
[5],
2213 (UINT32
) CurrentFile
->Guid
.Data4
[6],
2214 (UINT32
) CurrentFile
->Guid
.Data4
[7]
2217 // return STATUS_ERROR;
2221 // Find the next one that hasn't been reported
2224 CurrentFile
= CurrentFile
->Next
;
2225 } while ((CurrentFile
!= NULL
) && (CurrentFile
->Reported
));
2229 if (gOptions
.CheckSignatures
) {
2231 // Print ones found if specified
2233 if (gOptions
.PrintFound
) {
2234 CurrentSig
= gSignatureList
;
2235 while (CurrentSig
!= NULL
) {
2236 Len
= CurrentSig
->Signature
.DataLen
;
2237 for (Index
= 0; Index
< Len
; Index
++) {
2238 fprintf (stdout
, "%c", CurrentSig
->Signature
.Data
[Index
]);
2241 fprintf (stdout
, " %s\n", CurrentSig
->FileName
);
2242 CurrentSig
= CurrentSig
->Next
;
2246 CurrentSig
= gSignatureList
;
2247 while (CurrentSig
!= NULL
) {
2249 TempSig
= CurrentSig
->Next
;
2250 Len
= CurrentSig
->Signature
.DataLen
;
2253 // Check for same length, then do string compare
2255 if (Len
== TempSig
->Signature
.DataLen
) {
2256 if (strncmp (CurrentSig
->Signature
.Data
, TempSig
->Signature
.Data
, Len
) == 0) {
2258 // Print header message if first failure for this sig
2260 if (DupCount
== 0) {
2261 Error (NULL
, 0, 0, "duplicate signatures found", NULL
);
2262 fprintf (stdout
, " FILE1: %s\n", CurrentSig
->FileName
);
2266 fprintf (stdout
, " FILE%d: %s\n", DupCount
+ 1, TempSig
->FileName
);
2267 TempSig
->Reported
= TRUE
;
2271 TempSig
= TempSig
->Next
;
2275 fprintf (stdout
, " SIG: ");
2276 for (Index
= 0; Index
< Len
; Index
++) {
2277 fprintf (stdout
, "%c", CurrentSig
->Signature
.Data
[Index
]);
2280 fprintf (stdout
, "\n");
2283 // On to the next one that hasn't been reported
2286 CurrentSig
= CurrentSig
->Next
;
2287 } while ((CurrentSig
!= NULL
) && (CurrentSig
->Reported
));
2301 Routine Description:
2302 Free up any memory we allocated when processing command-line options.
2311 We don't free up the ->Str fields because we did not allocate them.
2312 Instead, we just set the pointer to point to the actual parameter
2313 from the command line.
2318 while (gOptions
.ExcludeDirs
!= NULL
) {
2319 Ptr
= gOptions
.ExcludeDirs
->Next
;
2321 // free (gOptions.ExcludeDirs->Str);
2323 free (gOptions
.ExcludeDirs
);
2324 gOptions
.ExcludeDirs
= Ptr
;
2327 while (gOptions
.ExcludeSubDirs
!= NULL
) {
2328 Ptr
= gOptions
.ExcludeSubDirs
->Next
;
2330 // free (gOptions.ExcludeSubDirs->Str);
2332 free (gOptions
.ExcludeSubDirs
);
2333 gOptions
.ExcludeSubDirs
= Ptr
;
2336 while (gOptions
.ExcludeExtensions
!= NULL
) {
2337 Ptr
= gOptions
.ExcludeExtensions
->Next
;
2339 // free (gOptions.ExcludeExtensions->Str);
2341 free (gOptions
.ExcludeExtensions
);
2342 gOptions
.ExcludeExtensions
= Ptr
;
2345 while (gOptions
.ExcludeFiles
!= NULL
) {
2346 Ptr
= gOptions
.ExcludeFiles
->Next
;
2348 // free (gOptions.ExcludeFiles->Str);
2350 free (gOptions
.ExcludeFiles
);
2351 gOptions
.ExcludeFiles
= Ptr
;
2355 // Given an array of 32-bit data, validate the data for the given number of
2356 // guid data. For example, it might have been scanned as 16 bytes of data, or
2357 // 11 fields of data.
2368 if (DataCount
== 16) {
2369 for (Index
= 0; Index
< 16; Index
++) {
2370 if (Data
[Index
] &~0xFF) {
2376 } else if (DataCount
== 11) {
2378 // Data[0] never out of range (32-bit)
2380 if ((Data
[1] | Data
[2]) &~0xFFFF) {
2382 // Error ("Out of range value for GUID data word(s) [1] and/or [2]");
2387 for (Index
= 0; Index
< 8; Index
++) {
2388 if (Data
[Index
+ 3] &~0xFF) {
2390 // Error ("Out of range value for GUID data byte(s) [4] - [11]");