3 Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
4 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
41 #define UTILITY_NAME "GuidChk"
42 #define UTILITY_VERSION "v1.0"
47 } FILE_TYPE_TABLE_ENTRY
;
49 #define FILE_EXTENSION_UNKNOWN 0
50 #define FILE_EXTENSION_C 1
51 #define FILE_EXTENSION_H 2
52 #define FILE_EXTENSION_IA32_ASM 3
53 #define FILE_EXTENSION_IA32_INC 4
54 #define FILE_EXTENSION_IA64_ASM 5
55 #define FILE_EXTENSION_IA64_INC 6
56 #define FILE_EXTENSION_PKG 7
57 #define FILE_EXTENSION_INF 8
59 FILE_TYPE_TABLE_ENTRY FileTypeTable
[] = {
65 FILE_EXTENSION_IA32_INC
,
67 FILE_EXTENSION_IA32_ASM
,
69 FILE_EXTENSION_IA64_ASM
,
75 FILE_EXTENSION_IA64_INC
,
80 typedef struct EFI_GUID
{
92 typedef struct _GUID_RECORD
{
93 struct _GUID_RECORD
*Next
;
100 typedef struct _SIGNATURE_RECORD
{
101 struct _SIGNATURE_RECORD
*Next
;
104 EFI_SIGNATURE Signature
;
111 INT8 DatabaseOutputFileName
[MAX_PATH
]; // with -b option
112 STRING_LIST
*ExcludeDirs
; // list of directory names not to process
113 STRING_LIST
*ExcludeSubDirs
; // list of directory names to not process subdirectories (build)
114 STRING_LIST
*ExcludeFiles
; // list of files to exclude (make.inf)
115 STRING_LIST
*ExcludeExtensions
; // list of filename extensions to exclude (.inf, .pkg)
119 BOOLEAN CheckSignatures
;
120 BOOLEAN GuidXReference
;
190 ProcessINFFileGuids (
196 ProcessPkgFileGuids (
202 ProcessIA32FileGuids (
208 ProcessIA64FileGuids (
249 UINT32 DataHH
, // Upper 32-bits of upper 64 bits of guid
250 UINT32 DataHL
, // Lower 32-bits of upper 64 bits
279 // GUID_RECORD *FileRecord
303 /**************************** GLOBALS ****************************************/
304 static GUID_RECORD
*gGuidList
= NULL
;
305 static SIGNATURE_RECORD
*gSignatureList
= NULL
;
306 static OPTIONS gOptions
;
308 /*****************************************************************************/
318 SetUtilityName ("GuidChk");
320 // Get the current working directory and then process the command line
323 Cwd
= _getcwd (NULL
, 0);
324 Status
= ProcessArgs (Argc
, Argv
);
325 if (Status
!= STATUS_SUCCESS
) {
329 if (gOptions
.CheckGuids
|| gOptions
.CheckSignatures
) {
330 Status
= ProcessDirectory (Cwd
, NULL
);
331 if (Status
== STATUS_SUCCESS
) {
333 // Check for duplicates
335 Status
= CheckDuplicates ();
339 if (gOptions
.DatabaseOutputFileName
[0] != 0) {
340 CreateGuidList (gOptions
.DatabaseOutputFileName
);
343 // Free up the memory
349 return GetUtilityStatus ();
359 STRING_LIST
*StrList
;
361 memset ((char *) &gOptions
, 0, sizeof (gOptions
));
363 // skip over program name
377 if ((Argv
[0][0] == '-') || (Argv
[0][0] == '/')) {
378 switch (Argv
[0][1]) {
390 // Check guids option
394 gOptions
.CheckGuids
= TRUE
;
398 // Check signatures option
402 gOptions
.CheckSignatures
= TRUE
;
406 // Print guids found option
410 gOptions
.PrintFound
= TRUE
;
414 // Exclude files option
419 // Check for another arg
422 Error (NULL
, 0, 0, Argv
[0], "missing argument with option");
427 StrList
= malloc (sizeof (STRING_LIST
));
428 if (StrList
== NULL
) {
429 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
433 memset ((char *) StrList
, 0, sizeof (STRING_LIST
));
434 StrList
->Str
= Argv
[1];
435 StrList
->Next
= gOptions
.ExcludeFiles
;
436 gOptions
.ExcludeFiles
= StrList
;
442 // Exclude directories option
447 // Check for another arg
450 Error (NULL
, 0, 0, Argv
[0], "missing argument with option");
455 StrList
= malloc (sizeof (STRING_LIST
));
456 if (StrList
== NULL
) {
457 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
461 memset ((char *) StrList
, 0, sizeof (STRING_LIST
));
462 StrList
->Str
= Argv
[1];
463 StrList
->Next
= gOptions
.ExcludeDirs
;
464 gOptions
.ExcludeDirs
= StrList
;
470 // -u exclude all subdirectories of a given directory option
475 // Check for another arg
478 Error (NULL
, 0, 0, Argv
[0], "missing argument with option");
483 StrList
= malloc (sizeof (STRING_LIST
));
484 if (StrList
== NULL
) {
485 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
489 memset ((char *) StrList
, 0, sizeof (STRING_LIST
));
490 StrList
->Str
= Argv
[1];
491 StrList
->Next
= gOptions
.ExcludeSubDirs
;
492 gOptions
.ExcludeSubDirs
= StrList
;
498 // -e exclude by filename extension option
503 // Check for another arg
506 Error (NULL
, 0, 0, Argv
[0], "missing argument with option");
511 StrList
= malloc (sizeof (STRING_LIST
));
512 if (StrList
== NULL
) {
513 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
517 memset ((char *) StrList
, 0, sizeof (STRING_LIST
));
519 // Let them put a * in front of the filename extension
521 StrList
->Str
= Argv
[1];
522 if (StrList
->Str
[0] == '*') {
526 StrList
->Next
= gOptions
.ExcludeExtensions
;
527 gOptions
.ExcludeExtensions
= StrList
;
533 // Print guid with matching symbol name for guid definitions found
537 gOptions
.GuidXReference
= TRUE
;
541 // -b Print the internal database list to a file
546 // Check for one more arg
549 Error (NULL
, 0, 0, Argv
[0], "must specify file name with option");
554 strcpy (gOptions
.DatabaseOutputFileName
, Argv
[1]);
560 Error (NULL
, 0, 0, Argv
[0], "invalid option");
575 Error (NULL
, 0, 0, Argv
[0], "invalid argument");
580 // Have to check signatures, GUIDs, or dump the GUID database.
582 if ((!gOptions
.CheckGuids
) && (!gOptions
.CheckSignatures
) && (gOptions
.DatabaseOutputFileName
[0] == 0)) {
583 Error (NULL
, 0, 0, "nothing to do", "must specify -g, -s, and/or -b");
588 return STATUS_SUCCESS
;
591 // Print usage instructions
600 const char *Str
[] = {
601 UTILITY_NAME
" "UTILITY_VERSION
" - Intel GUID Check Utility",
602 " Copyright (C), 2004 - 2008 Intel Corporation",
604 #if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
605 " Built from "UTILITY_BUILD
", project of "UTILITY_VENDOR
,
609 " "UTILITY_NAME
" [OPTION]...",
611 " Scan files for duplicate GUID or signature definitions.",
613 " -d dirname exclude searching of a directory",
614 " -f filename exclude searching of a file",
615 " -e extension exclude searching of files by extension",
616 " -p print all GUIDS found",
617 " -g check for duplicate guids",
618 " -s check for duplicate signatures",
619 " -x print guid+defined symbol name",
620 " -b outfile write internal GUID+basename list to outfile",
621 " -u dirname exclude searching all subdirectories of a directory",
622 " -h -? print this help text",
624 " GuidChk -g -u build -d fv -f make.inf -e .pkg",
627 for (Index
= 0; Str
[Index
] != NULL
; Index
++) {
628 fprintf (stdout
, "%s\n", Str
[Index
]);
632 // Process an entire directory by name
641 FILE_SEARCH_DATA FSData
;
649 // Root directory may be null
651 if (DirectoryName
!= NULL
) {
653 // printf ("Processing directory: %s\n", DirectoryName);
657 // Initialize our file searching
659 FileSearchInit (&FSData
);
662 // Exclude some directories, files, and extensions
664 FileSearchExcludeDirs (&FSData
, gOptions
.ExcludeDirs
);
665 FileSearchExcludeExtensions (&FSData
, gOptions
.ExcludeExtensions
);
666 FileSearchExcludeFiles (&FSData
, gOptions
.ExcludeFiles
);
668 // See if this directory is in the list of directories that they
669 // don't want to process subdirectories of
672 if (DirectoryName
!= NULL
) {
673 for (SLPtr
= gOptions
.ExcludeSubDirs
; SLPtr
!= NULL
; SLPtr
= SLPtr
->Next
) {
674 if (_stricmp (SLPtr
->Str
, DirectoryName
) == 0) {
676 // printf ("not processing subdirectories of %s\n", DirectoryName);
684 // Create a filemask of files to search for. We'll append "\*.*" on the
685 // end, so allocate some extra bytes.
687 Len
= strlen (Path
) + 10;
688 if (DirectoryName
!= NULL
) {
689 Len
+= strlen (DirectoryName
);
692 FileMask
= malloc (Len
);
693 if (FileMask
== NULL
) {
694 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
698 // Now put it all together
700 strcpy (FileMask
, Path
);
701 if ((DirectoryName
!= NULL
) && (strlen (DirectoryName
) > 0)) {
702 strcat (FileMask
, "\\");
703 strcat (FileMask
, DirectoryName
);
706 strcat (FileMask
, "\\*.*");
709 // Start file searching for files and directories
711 if (FileSearchStart (&FSData
, FileMask
, FILE_SEARCH_FILE
| FILE_SEARCH_DIR
) == STATUS_SUCCESS
) {
718 // Now hack the "\*.*" off the end of the filemask so we can use it to pass
719 // the full directory path on recursive calls to process directories.
721 FileMask
[strlen (FileMask
) - 4] = 0;
724 // Loop until no more files
728 // printf ("Found %s...", FSData.FileName);
730 if (FSData
.FileFlags
& FILE_SEARCH_DIR
) {
732 // printf ("directory\n");
735 ProcessDirectory (FileMask
, FSData
.FileName
);
737 } else if (FSData
.FileFlags
& FILE_SEARCH_FILE
) {
739 // printf ("file\n");
741 ProcessFile (FileMask
, FSData
.FileName
);
744 // printf ("unknown\n");
748 if (FileSearchFindNext (&FSData
) != STATUS_SUCCESS
) {
753 // Free up allocated memory
758 // Free up our file searching
760 FileSearchDestroy (&FSData
);
762 return STATUS_SUCCESS
;
765 // Process a single file.
775 UINT32 FileExtension
;
776 INT8 FullFileName
[MAX_PATH
];
778 Status
= STATUS_SUCCESS
;
780 sprintf (FullFileName
, "%s\\%s", DirectoryName
, FileName
);
782 // printf ("Found file: %s\n", FullFileName);
784 FileExtension
= GetFileExtension (FileName
);
787 // Process these for GUID checks
789 if (gOptions
.CheckGuids
) {
790 switch (FileExtension
) {
791 case FILE_EXTENSION_C
:
792 case FILE_EXTENSION_H
:
793 Status
= ProcessCFileGuids (FullFileName
);
796 case FILE_EXTENSION_PKG
:
797 Status
= ProcessPkgFileGuids (FullFileName
);
800 case FILE_EXTENSION_IA32_INC
:
801 case FILE_EXTENSION_IA32_ASM
:
802 Status
= ProcessIA32FileGuids (FullFileName
);
805 case FILE_EXTENSION_INF
:
806 Status
= ProcessINFFileGuids (FullFileName
);
809 case FILE_EXTENSION_IA64_INC
:
810 case FILE_EXTENSION_IA64_ASM
:
811 Status
= ProcessIA64FileGuids (FullFileName
);
818 Status
= STATUS_SUCCESS
;
823 if (gOptions
.CheckSignatures
) {
824 switch (FileExtension
) {
825 case FILE_EXTENSION_C
:
826 case FILE_EXTENSION_H
:
827 Status
= ProcessCFileSigs (FullFileName
);
834 Status
= STATUS_SUCCESS
;
842 // Return a code indicating the file name extension.
854 // Look back for a filename extension
856 for (Extension
= FileName
+ strlen (FileName
) - 1; Extension
>= FileName
; Extension
--) {
857 if (*Extension
== '.') {
858 for (Index
= 0; FileTypeTable
[Index
].Extension
!= NULL
; Index
++) {
859 if (_stricmp (FileTypeTable
[Index
].Extension
, Extension
) == 0) {
860 return FileTypeTable
[Index
].ExtensionCode
;
866 return FILE_TYPE_UNKNOWN
;
869 // Process a .pkg file.
871 // Look for FFS_FILEGUID=35b898ca-b6a9-49ce-8c72-904735cc49b7
875 ProcessPkgFileGuids (
880 INT8 Line
[MAX_LINE_LEN
* 2];
886 if ((Fptr
= fopen (FileName
, "r")) == NULL
) {
887 Error (NULL
, 0, 0, FileName
, "could not open input file for reading");
891 // Read lines from the file until done
893 while (fgets (Line
, sizeof (Line
), Fptr
) != NULL
) {
895 Cptr
+= SkipWhiteSpace (Line
);
896 if (strncmp (Cptr
, "FFS_FILEGUID", 12) == 0) {
898 Cptr
+= SkipWhiteSpace (Cptr
);
901 Cptr
+= SkipWhiteSpace (Cptr
+ 1);
903 // Blank out dashes on the line.
905 for (Cptr2
= Cptr
; *Cptr2
; Cptr2
++) {
920 AddPkgGuid (FileName
, GuidScan
, &Guid64
);
922 DebugMsg (NULL
, 0, 0, FileName
, "GUID scan failed");
929 return STATUS_SUCCESS
;
932 // Process an IA32 assembly file.
935 // FIND_FD_GUID_VAL equ 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h
936 // PEI_GUID_FileNameGuid_Gmch815 equ 081818181h, 08181h, 08181h, 081h, 081h, 081h, 081h, 081h, 081h, 081h, 081h
940 ProcessIA32FileGuids (
945 INT8 Line
[MAX_LINE_LEN
];
953 if ((Fptr
= fopen (FileName
, "r")) == NULL
) {
954 Error (NULL
, 0, 0, FileName
, "could not open input file for reading");
958 // Read lines from the file until done
960 while (fgets (Line
, sizeof (Line
), Fptr
) != NULL
) {
962 Cptr
+= SkipWhiteSpace (Line
);
964 // Look for xxxGUIDyyy equ 01h, 02h, 03h, ...
966 Len
= ValidSymbolName (Cptr
);
969 // Terminate the line after the symbol name, then look for "guid" in
972 CSavePtr
= Cptr
+ Len
;
976 if (_strnicmp (Cptr
, "guid", 4) == 0) {
983 // If we found the string "guid", continue
987 // Restore the character on the line where we null-terminated the symbol
991 Len
= SkipWhiteSpace (Cptr
);
993 // Had to be some white space
998 // now look for "equ"
1000 if (_strnicmp (Cptr
, "equ", 3) == 0) {
1002 Cptr
+= SkipWhiteSpace (Cptr
);
1004 // Now scan all the data
1006 for (Index
= 0; Index
< 16; Index
++) {
1007 if (sscanf (Cptr
, "%X", &GuidData
[Index
]) != 1) {
1013 while (isxdigit (*Cptr
)) {
1017 if ((*Cptr
!= 'h') && (*Cptr
!= 'H')) {
1021 while (*Cptr
&& (isspace (*Cptr
) || (*Cptr
== ','))) {
1027 // Now see which form we had
1030 AddGuid16 (FileName
, GuidData
);
1031 } else if (Index
== 11) {
1032 AddGuid11 (FileName
, GuidData
, NULL
);
1041 return STATUS_SUCCESS
;
1044 // Found and parsed an IA32 assembly code guid. Save the 16 bytes off in the list
1054 GUID_RECORD
*NewRec
;
1058 // Sanity check the data
1060 if (!CheckGuidData (Data
, 16)) {
1061 return STATUS_ERROR
;
1064 // Allocate memory for a new guid structure
1066 NewRec
= malloc (sizeof (GUID_RECORD
));
1067 if (NewRec
== NULL
) {
1068 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
1069 return STATUS_ERROR
;
1072 memset ((char *) NewRec
, 0, sizeof (GUID_RECORD
));
1073 NewRec
->FileName
= malloc (strlen (FileName
) + 1);
1074 if (NewRec
->FileName
== NULL
) {
1076 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
1077 return STATUS_ERROR
;
1080 strcpy (NewRec
->FileName
, FileName
);
1081 NewRec
->Guid
.Data1
= (UINT32
) (Data
[0] | (Data
[1] << 8) | (Data
[2] << 16) | (Data
[3] << 24));
1082 NewRec
->Guid
.Data2
= (UINT16
) (Data
[4] | (Data
[5] << 8));
1083 NewRec
->Guid
.Data3
= (UINT16
) (Data
[6] | (Data
[7] << 8));
1084 for (Index
= 0; Index
< 8; Index
++) {
1085 NewRec
->Guid
.Data4
[Index
] = (UINT8
) Data
[Index
+ 8];
1088 // Add it to the list
1090 NewRec
->Next
= gGuidList
;
1095 // ReportGuid (FileName, NewRec);
1097 return STATUS_SUCCESS
;
1100 // Add a GUID defined as GuidLow: 0x1122334455667788
1101 // GuidHi: 0x99AABBCCDDEEFF00
1103 // These are equivalent:
1104 // { 0x11223344, 0x5566, 0x7788, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x00 }
1106 // Low: 00FFEEDDCCBBAA99
1107 // Hi: 7788556611223344
1113 UINT32 DataHH
, // Upper 32-bits of upper 64 bits of guid
1114 UINT32 DataHL
, // Lower 32-bits of upper 64 bits
1120 GUID_RECORD
*NewRec
;
1124 // Allocate memory for a new guid structure
1126 NewRec
= malloc (sizeof (GUID_RECORD
));
1127 if (NewRec
== NULL
) {
1128 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
1129 return STATUS_ERROR
;
1132 memset ((char *) NewRec
, 0, sizeof (GUID_RECORD
));
1133 NewRec
->FileName
= malloc (strlen (FileName
) + 1);
1134 if (NewRec
->FileName
== NULL
) {
1136 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
1137 return STATUS_ERROR
;
1140 strcpy (NewRec
->FileName
, FileName
);
1141 NewRec
->Guid
.Data1
= DataHL
;
1142 NewRec
->Guid
.Data2
= (UINT16
) DataHH
;
1143 NewRec
->Guid
.Data3
= (UINT16
) (DataHH
>> 16);
1144 for (Index
= 0; Index
< 4; Index
++) {
1145 NewRec
->Guid
.Data4
[Index
] = (UINT8
) DataLL
;
1149 for (Index
= 0; Index
< 4; Index
++) {
1150 NewRec
->Guid
.Data4
[Index
+ 4] = (UINT8
) DataLH
;
1154 if (SymName
!= NULL
) {
1155 NewRec
->SymName
= malloc (strlen (SymName
) + 1);
1156 if (NewRec
->SymName
== NULL
) {
1158 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
1159 return STATUS_ERROR
;
1161 strcpy (NewRec
->SymName
, SymName
);
1165 // Add it to the list
1167 NewRec
->Next
= gGuidList
;
1172 // ReportGuid (FileName, NewRec);
1174 return STATUS_SUCCESS
;
1177 // Process INF files. Look for:
1178 // FILE_GUID = 240612B6-A063-11d4-9A3A-0090273FC14D
1182 ProcessINFFileGuids (
1187 INT8 Line
[MAX_LINE_LEN
* 2];
1190 UINT32 GuidScan
[11];
1193 if ((Fptr
= fopen (FileName
, "r")) == NULL
) {
1194 Error (NULL
, 0, 0, FileName
, "could not open input file for reading");
1195 return STATUS_ERROR
;
1198 // Read lines from the file until done
1200 while (fgets (Line
, sizeof (Line
), Fptr
) != NULL
) {
1202 Cptr
+= SkipWhiteSpace (Line
);
1203 if (strncmp (Cptr
, "FILE_GUID", 9) == 0) {
1205 Cptr
+= SkipWhiteSpace (Cptr
);
1208 Cptr
+= SkipWhiteSpace (Cptr
+ 1);
1210 // Blank out dashes on the line.
1212 for (Cptr2
= Cptr
; *Cptr2
; Cptr2
++) {
1213 if (*Cptr2
== '-') {
1220 "%X %X %X %X %I64X",
1227 AddPkgGuid (FileName
, GuidScan
, &Guid64
);
1229 DebugMsg (NULL
, 0, 0, FileName
, "GUID scan failed");
1236 return STATUS_SUCCESS
;
1239 // Parse ('g','m','a','p','a','b','c','d')
1249 SIGNATURE_RECORD
*NewRec
;
1255 // Allocate memory for the new record
1258 NewRec
= malloc (sizeof (SIGNATURE_RECORD
));
1260 if (NewRec
== NULL
) {
1261 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
1262 return STATUS_ERROR
;
1264 memset ((char *) NewRec
, 0, sizeof (SIGNATURE_RECORD
));
1267 // Allocate memory to save the file name
1269 NewRec
->FileName
= malloc (strlen (FileName
) + 1);
1270 if (NewRec
->FileName
== NULL
) {
1271 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
1273 return STATUS_ERROR
;
1276 // Fill in the fields
1278 strcpy (NewRec
->FileName
, FileName
);
1279 NewRec
->Signature
.DataLen
= (UINT8
) SigSize
;
1281 // Skip to open parenthesis
1284 Cptr
+= SkipWhiteSpace (Cptr
);
1292 // Skip to first ' and start processing
1294 while (*Cptr
&& (*Cptr
!= '\'')) {
1298 for (Index
= 0; Index
< SigSize
; Index
++) {
1299 if (*Cptr
== '\'') {
1301 NewRec
->Signature
.Data
[Index
] = (INT8
) *Cptr
;
1303 // Skip to closing quote
1306 if (*Cptr
!= '\'') {
1311 // Skip over closing quote, go to next one
1314 while (*Cptr
&& (*Cptr
!= '\'')) {
1319 DebugMsg (NULL
, 0, 0, FileName
, "failed to parse signature");
1326 free (NewRec
->FileName
);
1328 return STATUS_ERROR
;
1331 NewRec
->Next
= gSignatureList
;
1332 gSignatureList
= NewRec
;
1333 return STATUS_SUCCESS
;
1337 // #define POOL_HEAD_SIGNATURE EFI_SIGNATURE_16('p','h')
1338 // #define GCD_MEMORY_MAP_SIGNATURE EFI_SIGNATURE_32('g','m','a','p')
1339 // #define GCD_MEMORY_MAP_SIGNATURE EFI_SIGNATURE_64('g','m','a','p','a','b','c','d')
1348 INT8 Line
[MAX_LINE_LEN
* 2];
1352 if ((Fptr
= fopen (FileName
, "r")) == NULL
) {
1353 Error (NULL
, 0, 0, FileName
, "could not open input file for reading");
1354 return STATUS_ERROR
;
1357 // Read lines from the file until done
1359 while (fgets (Line
, sizeof (Line
), Fptr
) != NULL
) {
1361 Cptr
+= SkipWhiteSpace (Line
);
1363 // look for #define EFI_SIGNATURE_xx value
1367 Cptr
+= SkipWhiteSpace (Cptr
);
1369 // Look for "define"
1371 if (!strncmp (Cptr
, "define", 6)) {
1374 // Better be whitespace
1376 Len
= SkipWhiteSpace (Cptr
);
1380 // See if it's a valid symbol name
1382 Len
= ValidSymbolName (Cptr
);
1385 // It is a valid symbol name. See if there's line continuation,
1386 // and if so, read more lines.
1387 // Skip over the symbol name and look for the string "EFI_SIGNATURE_xx"
1389 ConcatenateLines (Fptr
, Line
, sizeof(Line
));
1392 Cptr
+= SkipWhiteSpace (Cptr
);
1393 if (strncmp (Cptr
, "EFI_SIGNATURE_16", 16) == 0) {
1394 AddSignature (FileName
, Cptr
+ 16, 2);
1395 } else if (strncmp (Cptr
, "EFI_SIGNATURE_32", 16) == 0) {
1396 AddSignature (FileName
, Cptr
+ 16, 4);
1397 } else if (strncmp (Cptr
, "EFI_SIGNATURE_64", 16) == 0) {
1398 AddSignature (FileName
, Cptr
+ 16, 8);
1407 return STATUS_SUCCESS
;
1410 // look for #define xxxGUIDyyy { 0x...}
1411 // xxx EFI_GUID GuidName = { 0x... };
1420 INT8 Line
[MAX_LINE_LEN
* 2];
1427 UINT32 GuidScan
[11];
1429 if ((Fptr
= fopen (FileName
, "r")) == NULL
) {
1430 Error (NULL
, 0, 0, FileName
, "could not open input file for reading");
1431 return STATUS_ERROR
;
1434 // Read lines from the file until done
1436 while (fgets (Line
, sizeof (Line
), Fptr
) != NULL
) {
1438 Cptr
+= SkipWhiteSpace (Line
);
1440 // look for #define xxxGUIDxxx value
1444 Cptr
+= SkipWhiteSpace (Cptr
);
1446 // Look for "define"
1448 if (!strncmp (Cptr
, "define", 6)) {
1452 // Better be whitespace
1454 Len
= SkipWhiteSpace (Cptr
);
1458 // See if it's a valid symbol name
1460 Len
= ValidSymbolName (Cptr
);
1463 // It is a valid symbol name. See if there's line continuation,
1464 // and if so, read more lines.
1465 // Then truncate after the symbol name, look for the string "GUID",
1469 ConcatenateLines (Fptr
, Line
, sizeof(Line
));
1472 // Now look for { 0x....... }
1474 CSavePtr
= Cptr
+ Len
;
1476 Cptr
+= SkipWhiteSpace (Cptr
);
1480 // Blank out 'L', 'l', '{', '}', ',' on the line.
1482 for (TempCptr
= Cptr
; *TempCptr
; TempCptr
++) {
1483 if ((*TempCptr
== 'L') || (*TempCptr
== 'l') || (*TempCptr
== '{') ||
1484 (*TempCptr
== '}') || (*TempCptr
== ',')) {
1491 "%X %X %X %X %X %X %X %X %X %X %X",
1505 AddGuid11 (FileName
, GuidScan
, SymName
);
1512 // Else look for "static EFI_GUID xxxGUIDxxx = { 0x.... };
1514 } else if ((CSavePtr
= strstr (Line
, "EFI_GUID")) != NULL
) {
1516 // Read more lines until met ';'
1518 ConcatenateLines (Fptr
, Line
, sizeof(Line
));
1519 while (strstr (Line
, ";") == NULL
) {
1520 LineLen
= strlen (Line
);
1521 Len
= sizeof(Line
) - LineLen
;
1525 if (Line
[LineLen
- 1] == '\n') {
1526 Cptr
= Line
+ LineLen
- 1;
1528 if (fgets (Cptr
, Len
, Fptr
) == NULL
){
1531 ConcatenateLines (Fptr
, Line
, sizeof(Line
));
1533 Cptr
= Line
+ LineLen
;
1535 if (fgets (Cptr
, Len
, Fptr
) == NULL
) {
1538 ConcatenateLines (Fptr
, Line
, sizeof(Line
));
1542 // EFI_GUID may appear in comments wihout end of ';' which may cause
1543 // ignoring of new #define, so handle it here.
1545 Cptr
+= SkipWhiteSpace (Cptr
);
1548 Cptr
+= SkipWhiteSpace (Cptr
);
1549 if (!strncmp (Cptr
, "define", 6)) {
1555 Cptr
= CSavePtr
+ 8;
1556 Cptr
+= SkipWhiteSpace (Cptr
);
1558 // Should be variable name next
1560 Len
= ValidSymbolName (Cptr
);
1564 Cptr
+= SkipWhiteSpace (Cptr
);
1568 Cptr
+= SkipWhiteSpace (Cptr
);
1570 // Should be open-brace next to define guid
1575 // Blank out 'L', 'l', '{', '}', ',' on the line.
1577 for (TempCptr
= Cptr
; *TempCptr
; TempCptr
++) {
1578 if ((*TempCptr
== 'L') || (*TempCptr
== 'l') || (*TempCptr
== '{') ||
1579 (*TempCptr
== '}') || (*TempCptr
== ',')) {
1586 "%X %X %X %X %X %X %X %X %X %X %X",
1599 AddGuid11 (FileName
, GuidScan
, SymName
);
1607 return STATUS_SUCCESS
;
1610 // Process Intel Itanium(TM) GUID definitions. Look for:
1611 // #define Cs870MemoryTestPEIMGuidL 0x9C2403386E1C8FAA
1612 // #define Cs870MemoryTestPEIMGuidH 0xE89E95C6180342f0
1614 // This function assumes no blank lines between definitions.
1618 ProcessIA64FileGuids (
1623 INT8 Line
[MAX_LINE_LEN
];
1628 INT8 SymName1
[MAX_LINE_LEN
];
1629 INT8 SymName2
[MAX_LINE_LEN
];
1634 if ((Fptr
= fopen (FileName
, "r")) == NULL
) {
1635 Error (NULL
, 0, 0, FileName
, "could not open input file for reading");
1636 return STATUS_ERROR
;
1640 if (fgets (Line
, sizeof (Line
), Fptr
) == NULL
) {
1644 // Read lines from the file until done. Since the guid definition takes
1645 // two lines, we read lines in different places to recover gracefully
1646 // from mismatches. For example, if you thought you found the first half,
1647 // but the next line had a symbol mismatch, then you have to process the
1648 // line again in case it's the start of a new definition.
1652 // Check current line for GUID definition. Assume low define first.
1654 if (IsIA64GuidLine (Line
, &Guid1H
, &Guid1L
, &FoundLow
, SymName1
)) {
1656 // Might have to swap guids later. Save off if we found the LOW first
1664 // Read the next line and try for the rest of the guid definition
1666 if (fgets (Line
, sizeof (Line
), Fptr
) == NULL
) {
1669 if (IsIA64GuidLine (Line
, &Guid2H
, &Guid2L
, &FoundLow
, SymName2
)) {
1671 // Found another. If the symbol names match, then save it off.
1673 if (strcmp (SymName1
, SymName2
) == 0) {
1675 // Yea, found one. Save it off.
1678 AddGuid64x2 (FileName
, Guid2H
, Guid2L
, Guid1H
, Guid1L
, SymName1
);
1680 AddGuid64x2 (FileName
, Guid1H
, Guid1L
, Guid2H
, Guid2L
, SymName1
);
1683 // Read the next line for processing
1685 if (fgets (Line
, sizeof (Line
), Fptr
) == NULL
) {
1690 // Don't get another line so that we reprocess this line in case it
1691 // contains the start of a new definition.
1692 // fprintf (stdout, "Symbol name mismatch: %s: %s != %s\n",
1693 // FileName, SymName1, SymName2);
1698 // Second line was not a guid definition. Get the next line from the
1701 if (fgets (Line
, sizeof (Line
), Fptr
) == NULL
) {
1708 // Not a guid define line. Next.
1710 if (fgets (Line
, sizeof (Line
), Fptr
) == NULL
) {
1717 return STATUS_SUCCESS
;
1720 // Given a line from an Itanium-based assembly file, check the line for a guid
1721 // defininition. One of either:
1722 // #define Cs870MemoryTestPEIMGuidL 0x9C2403386E1C8FAA
1723 // #define Cs870MemoryTestPEIMGuidH 0xE89E95C6180342f0
1724 // Return the defined value as two 32-bit values, and whether it's a high
1744 Cptr
+= SkipWhiteSpace (Cptr
);
1746 // look for #define xxxGUID[L|H] 0xHexValue
1750 Cptr
+= SkipWhiteSpace (Cptr
);
1752 // Look for "define"
1754 if (!strncmp (Cptr
, "define", 6)) {
1757 // Better be whitespace
1759 Len
= SkipWhiteSpace (Cptr
);
1763 // See if it's a valid symbol name
1765 Len
= ValidSymbolName (Cptr
);
1768 // Save the start so we can copy it to their string if later checks are ok
1772 // It is a valid symbol name, look for the string GuidL or GuidH
1774 CSavePtr
= Cptr
+ Len
;
1778 if (strncmp (Cptr
, "GuidL", 5) == 0) {
1781 } else if (strncmp (Cptr
, "GuidH", 5) == 0) {
1789 // If we didn't run out of string, then we found the GUID string.
1790 // Restore the null character we inserted above and continue.
1791 // Now look for 0x.......
1795 // Return symbol name less the "L" or "H"
1797 strcpy (SymName
, SymStart
);
1798 SymName
[strlen (SymName
) - 1] = 0;
1801 Cptr
+= SkipWhiteSpace (Cptr
);
1802 if ((*Cptr
== '0') && (*(Cptr
+ 1) == 'x')) {
1808 // 0x0123456789ABCDEF -- null terminate after 8 characters,
1809 // scan, replace the character and scan at that point.
1811 CSave
= *(Cptr
+ 8);
1813 if (sscanf (Cptr
, "%X", GuidHigh
) == 1) {
1814 *(Cptr
+ 8) = CSave
;
1815 if (sscanf (Cptr
+ 8, "%X", GuidLow
) == 1) {
1829 // Look at the characters in the string and determine if it's a valid
1830 // symbol name. Basically [a-zA-Z_][a-zA-Z_0-9]*
1843 // Test first character
1845 if (((*Name
>= 'a') && (*Name
<= 'z')) || ((*Name
>= 'A') && (*Name
<= 'Z')) || (*Name
== '_')) {
1849 if (((*Name
>= 'a') && (*Name
<= 'z')) ||
1850 ((*Name
>= 'A') && (*Name
<= 'Z')) ||
1851 ((*Name
>= '0') && (*Name
<= '9')) ||
1873 while (isspace (*Str
) && *Str
) {
1881 // found FFS_FILEGUID=35b898ca-b6a9-49ce-8c72-904735cc49b7
1891 GUID_RECORD
*NewRec
;
1895 // Sanity check the data
1897 if ((Data
[1] | Data
[2] | Data
[3]) & 0xFFFF0000) {
1898 Error (NULL
, 0, 0, "out of range value for GUID data word(s) [1] - [3]", NULL
);
1899 return STATUS_ERROR
;
1902 // More checks for Data64?
1903 // Allocate memory for a new one guid structure
1905 NewRec
= malloc (sizeof (GUID_RECORD
));
1906 if (NewRec
== NULL
) {
1907 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
1908 return STATUS_ERROR
;
1911 memset ((char *) NewRec
, 0, sizeof (GUID_RECORD
));
1912 NewRec
->FileName
= malloc (strlen (FileName
) + 1);
1913 if (NewRec
->FileName
== NULL
) {
1915 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
1916 return STATUS_ERROR
;
1919 strcpy (NewRec
->FileName
, FileName
);
1920 NewRec
->Guid
.Data1
= Data
[0];
1921 NewRec
->Guid
.Data2
= (UINT16
) Data
[1];
1922 NewRec
->Guid
.Data3
= (UINT16
) Data
[2];
1923 NewRec
->Guid
.Data4
[0] = (UINT8
) (Data
[3] >> 8);
1924 NewRec
->Guid
.Data4
[1] = (UINT8
) Data
[3];
1925 for (Index
= 2; Index
< 8; Index
++) {
1926 NewRec
->Guid
.Data4
[Index
] = ((UINT8
*)Data64
)[7-Index
];
1929 // Add it to the list
1931 NewRec
->Next
= gGuidList
;
1936 // ReportGuid (FileName, NewRec);
1938 return STATUS_SUCCESS
;
1941 // Add a guid consisting of 11 fields to our list of guids
1951 GUID_RECORD
*NewRec
;
1955 // Sanity check the data
1957 if (!CheckGuidData (Data
, 11)) {
1958 return STATUS_ERROR
;
1961 // Allocate memory for a new one guid structure
1963 NewRec
= malloc (sizeof (GUID_RECORD
));
1964 if (NewRec
== NULL
) {
1965 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
1966 return STATUS_ERROR
;
1969 memset ((char *) NewRec
, 0, sizeof (GUID_RECORD
));
1970 NewRec
->FileName
= malloc (strlen (FileName
) + 1);
1971 if (NewRec
->FileName
== NULL
) {
1973 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
1974 return STATUS_ERROR
;
1977 strcpy (NewRec
->FileName
, FileName
);
1978 if (SymName
!= NULL
) {
1979 NewRec
->SymName
= malloc (strlen (SymName
) + 1);
1980 if (NewRec
->SymName
== NULL
) {
1982 Error (NULL
, 0, 0, "memory allocation failure", NULL
);
1983 return STATUS_ERROR
;
1985 strcpy (NewRec
->SymName
, SymName
);
1988 NewRec
->Guid
.Data1
= Data
[0];
1989 NewRec
->Guid
.Data2
= (UINT16
) Data
[1];
1990 NewRec
->Guid
.Data3
= (UINT16
) Data
[2];
1991 for (Index
= 0; Index
< 8; Index
++) {
1992 NewRec
->Guid
.Data4
[Index
] = (UINT8
) Data
[3 + Index
];
1995 // Add it to the list
1997 NewRec
->Next
= gGuidList
;
2002 // ReportGuid (FileName, NewRec);
2004 return STATUS_SUCCESS
;
2007 // For debug purposes, print each guid found
2013 // GUID_RECORD *NewGuid
2016 // //fprintf (stdout, "%s: 0x%08X\n", FileName, NewGuid->Guid.Data1);
2019 // Free up memory we allocated to keep track of guids defined.
2027 GUID_RECORD
*NextRec
;
2028 while (gGuidList
!= NULL
) {
2029 NextRec
= gGuidList
->Next
;
2030 if (gGuidList
->FileName
!= NULL
) {
2031 free (gGuidList
->FileName
);
2034 if (gGuidList
->SymName
!= NULL
) {
2035 free (gGuidList
->SymName
);
2039 gGuidList
= NextRec
;
2049 SIGNATURE_RECORD
*NextRec
;
2050 while (gSignatureList
!= NULL
) {
2051 NextRec
= gSignatureList
->Next
;
2052 if (gSignatureList
->FileName
!= NULL
) {
2053 free (gSignatureList
->FileName
);
2056 free (gSignatureList
);
2057 gSignatureList
= NextRec
;
2061 // Scan through all guids defined and compare each for duplicates.
2069 GUID_RECORD
*CurrentFile
;
2071 GUID_RECORD
*TempFile
;
2072 SIGNATURE_RECORD
*CurrentSig
;
2073 SIGNATURE_RECORD
*TempSig
;
2082 Status
= STATUS_SUCCESS
;
2085 // If we're checking guids.....
2087 if (gOptions
.CheckGuids
) {
2089 // If -p option, print all guids found
2091 if (gOptions
.PrintFound
) {
2092 CurrentFile
= gGuidList
;
2093 while (CurrentFile
!= NULL
) {
2096 "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",
2097 (UINT32
) CurrentFile
->Guid
.Data1
,
2098 (UINT32
) CurrentFile
->Guid
.Data2
,
2099 (UINT32
) CurrentFile
->Guid
.Data3
,
2100 (UINT32
) CurrentFile
->Guid
.Data4
[0],
2101 (UINT32
) CurrentFile
->Guid
.Data4
[1],
2102 (UINT32
) CurrentFile
->Guid
.Data4
[2],
2103 (UINT32
) CurrentFile
->Guid
.Data4
[3],
2104 (UINT32
) CurrentFile
->Guid
.Data4
[4],
2105 (UINT32
) CurrentFile
->Guid
.Data4
[5],
2106 (UINT32
) CurrentFile
->Guid
.Data4
[6],
2107 (UINT32
) CurrentFile
->Guid
.Data4
[7],
2108 CurrentFile
->FileName
2110 CurrentFile
= CurrentFile
->Next
;
2114 if (gOptions
.GuidXReference
) {
2115 CurrentFile
= gGuidList
;
2116 while (CurrentFile
!= NULL
) {
2118 // If no symbol name, print FileName
2120 SymName
= CurrentFile
->SymName
;
2121 if (SymName
== NULL
) {
2123 // Assume file name will not be NULL and strlen > 0
2125 SymName
= CurrentFile
->FileName
+ strlen (CurrentFile
->FileName
) - 1;
2126 while ((*SymName
!= '\\') && (SymName
> CurrentFile
->FileName
)) SymName
--;
2127 if (*SymName
== '\\') SymName
++;
2132 "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X %s\n",
2133 (UINT32
) CurrentFile
->Guid
.Data1
,
2134 (UINT32
) CurrentFile
->Guid
.Data2
,
2135 (UINT32
) CurrentFile
->Guid
.Data3
,
2136 (UINT32
) CurrentFile
->Guid
.Data4
[0],
2137 (UINT32
) CurrentFile
->Guid
.Data4
[1],
2138 (UINT32
) CurrentFile
->Guid
.Data4
[2],
2139 (UINT32
) CurrentFile
->Guid
.Data4
[3],
2140 (UINT32
) CurrentFile
->Guid
.Data4
[4],
2141 (UINT32
) CurrentFile
->Guid
.Data4
[5],
2142 (UINT32
) CurrentFile
->Guid
.Data4
[6],
2143 (UINT32
) CurrentFile
->Guid
.Data4
[7],
2146 CurrentFile
= CurrentFile
->Next
;
2150 // Now go through all guids and report duplicates.
2152 CurrentFile
= gGuidList
;
2153 while (CurrentFile
!= NULL
) {
2155 TempFile
= CurrentFile
->Next
;
2158 // Compare the guids
2160 if ((CurrentFile
->Guid
.Data1
== TempFile
->Guid
.Data1
) &&
2161 (CurrentFile
->Guid
.Data2
== TempFile
->Guid
.Data2
) &&
2162 (CurrentFile
->Guid
.Data3
== TempFile
->Guid
.Data3
)
2165 // OR in all the guid bytes so we can ignore NULL-guid definitions.
2167 GuidSum
= CurrentFile
->Guid
.Data1
| CurrentFile
->Guid
.Data2
| CurrentFile
->Guid
.Data3
;
2169 for (Index
= 0; Index
< 8; Index
++) {
2170 GuidSum
|= CurrentFile
->Guid
.Data4
[Index
];
2171 if (CurrentFile
->Guid
.Data4
[Index
] != TempFile
->Guid
.Data4
[Index
]) {
2177 // If they're the same, and the guid was non-zero, print a message.
2179 if (Same
&& GuidSum
) {
2180 if (DupCount
== 0) {
2181 Error (NULL
, 0, 0, "duplicate GUIDS found", NULL
);
2182 fprintf (stdout
, " FILE1: %s\n", CurrentFile
->FileName
);
2186 fprintf (stdout
, " FILE%d: %s\n", DupCount
+ 1, TempFile
->FileName
);
2188 // Flag it as reported so we don't report it again if there's three or more
2190 TempFile
->Reported
= TRUE
;
2196 TempFile
= TempFile
->Next
;
2199 // Print the guid if we found duplicates
2204 " GUID: 0x%08X 0x%04X 0x%04X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X\n",
2205 (UINT32
) CurrentFile
->Guid
.Data1
,
2206 (UINT32
) CurrentFile
->Guid
.Data2
,
2207 (UINT32
) CurrentFile
->Guid
.Data3
,
2208 (UINT32
) CurrentFile
->Guid
.Data4
[0],
2209 (UINT32
) CurrentFile
->Guid
.Data4
[1],
2210 (UINT32
) CurrentFile
->Guid
.Data4
[2],
2211 (UINT32
) CurrentFile
->Guid
.Data4
[3],
2212 (UINT32
) CurrentFile
->Guid
.Data4
[4],
2213 (UINT32
) CurrentFile
->Guid
.Data4
[5],
2214 (UINT32
) CurrentFile
->Guid
.Data4
[6],
2215 (UINT32
) CurrentFile
->Guid
.Data4
[7]
2218 // return STATUS_ERROR;
2222 // Find the next one that hasn't been reported
2225 CurrentFile
= CurrentFile
->Next
;
2226 } while ((CurrentFile
!= NULL
) && (CurrentFile
->Reported
));
2230 if (gOptions
.CheckSignatures
) {
2232 // Print ones found if specified
2234 if (gOptions
.PrintFound
) {
2235 CurrentSig
= gSignatureList
;
2236 while (CurrentSig
!= NULL
) {
2237 Len
= CurrentSig
->Signature
.DataLen
;
2238 for (Index
= 0; Index
< Len
; Index
++) {
2239 fprintf (stdout
, "%c", CurrentSig
->Signature
.Data
[Index
]);
2242 fprintf (stdout
, " %s\n", CurrentSig
->FileName
);
2243 CurrentSig
= CurrentSig
->Next
;
2247 CurrentSig
= gSignatureList
;
2248 while (CurrentSig
!= NULL
) {
2250 TempSig
= CurrentSig
->Next
;
2251 Len
= CurrentSig
->Signature
.DataLen
;
2254 // Check for same length, then do string compare
2256 if (Len
== TempSig
->Signature
.DataLen
) {
2257 if (strncmp (CurrentSig
->Signature
.Data
, TempSig
->Signature
.Data
, Len
) == 0) {
2259 // Print header message if first failure for this sig
2261 if (DupCount
== 0) {
2262 Error (NULL
, 0, 0, "duplicate signatures found", NULL
);
2263 fprintf (stdout
, " FILE1: %s\n", CurrentSig
->FileName
);
2267 fprintf (stdout
, " FILE%d: %s\n", DupCount
+ 1, TempSig
->FileName
);
2268 TempSig
->Reported
= TRUE
;
2272 TempSig
= TempSig
->Next
;
2276 fprintf (stdout
, " SIG: ");
2277 for (Index
= 0; Index
< Len
; Index
++) {
2278 fprintf (stdout
, "%c", CurrentSig
->Signature
.Data
[Index
]);
2281 fprintf (stdout
, "\n");
2284 // On to the next one that hasn't been reported
2287 CurrentSig
= CurrentSig
->Next
;
2288 } while ((CurrentSig
!= NULL
) && (CurrentSig
->Reported
));
2302 Routine Description:
2303 Free up any memory we allocated when processing command-line options.
2312 We don't free up the ->Str fields because we did not allocate them.
2313 Instead, we just set the pointer to point to the actual parameter
2314 from the command line.
2319 while (gOptions
.ExcludeDirs
!= NULL
) {
2320 Ptr
= gOptions
.ExcludeDirs
->Next
;
2322 // free (gOptions.ExcludeDirs->Str);
2324 free (gOptions
.ExcludeDirs
);
2325 gOptions
.ExcludeDirs
= Ptr
;
2328 while (gOptions
.ExcludeSubDirs
!= NULL
) {
2329 Ptr
= gOptions
.ExcludeSubDirs
->Next
;
2331 // free (gOptions.ExcludeSubDirs->Str);
2333 free (gOptions
.ExcludeSubDirs
);
2334 gOptions
.ExcludeSubDirs
= Ptr
;
2337 while (gOptions
.ExcludeExtensions
!= NULL
) {
2338 Ptr
= gOptions
.ExcludeExtensions
->Next
;
2340 // free (gOptions.ExcludeExtensions->Str);
2342 free (gOptions
.ExcludeExtensions
);
2343 gOptions
.ExcludeExtensions
= Ptr
;
2346 while (gOptions
.ExcludeFiles
!= NULL
) {
2347 Ptr
= gOptions
.ExcludeFiles
->Next
;
2349 // free (gOptions.ExcludeFiles->Str);
2351 free (gOptions
.ExcludeFiles
);
2352 gOptions
.ExcludeFiles
= Ptr
;
2356 // Given an array of 32-bit data, validate the data for the given number of
2357 // guid data. For example, it might have been scanned as 16 bytes of data, or
2358 // 11 fields of data.
2369 if (DataCount
== 16) {
2370 for (Index
= 0; Index
< 16; Index
++) {
2371 if (Data
[Index
] &~0xFF) {
2377 } else if (DataCount
== 11) {
2379 // Data[0] never out of range (32-bit)
2381 if ((Data
[1] | Data
[2]) &~0xFFFF) {
2383 // Error ("Out of range value for GUID data word(s) [1] and/or [2]");
2388 for (Index
= 0; Index
< 8; Index
++) {
2389 if (Data
[Index
+ 3] &~0xFF) {
2391 // Error ("Out of range value for GUID data byte(s) [4] - [11]");
2416 LineLen
= strlen (Line
);
2417 if ((Line
[LineLen
- 1] == '\n') && (Line
[LineLen
- 2] == '\\')) {
2418 Line
[LineLen
- 2] = '\0';
2419 fgets (Line
+ LineLen
- 2, Len
- LineLen
, Fptr
);
2420 } else if (Line
[LineLen
- 1] == '\\') {
2421 Line
[LineLen
- 1] = '\0';
2422 fgets (Line
+ LineLen
- 1, Len
- LineLen
, Fptr
);