+static\r
+STATUS\r
+ProcessClOutput (\r
+ INT8 *TargetFileName,\r
+ INT8 *FileName,\r
+ STRING_LIST *ProcessedFiles\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Given a source file name, open the file and parse all "Note: including file: xxx.h" lines.\r
+ \r
+Arguments:\r
+\r
+ TargetFileName - name of the usually .obj target\r
+ FileName - name of the file to process\r
+ ProcessedFiles - list of processed files.\r
+\r
+Returns:\r
+\r
+ standard status.\r
+ \r
+--*/\r
+{\r
+ FILE *Fptr;\r
+ INT8 Line[MAX_LINE_LEN];\r
+ INT8 IncludeFileName[MAX_LINE_LEN];\r
+ STRING_LIST *ListPtr;\r
+ BOOLEAN ClError;\r
+ INT32 Ret;\r
+ INT8 Char;\r
+\r
+ if ((Fptr = fopen (FileName, "r")) == NULL) {\r
+ Error (NULL, 0, 0, FileName, "could not open file for reading");\r
+ return STATUS_ERROR;\r
+ }\r
+ if (fgets (Line, sizeof (Line), Fptr) != NULL) {\r
+ //\r
+ // First line is the source file name, print it\r
+ //\r
+ printf ("%s", Line);\r
+ } else {\r
+ //\r
+ // No output from cl\r
+ //\r
+ fclose (Fptr);\r
+ Error (NULL, 0, 0, NULL, "incorrect cl tool path may be used ");\r
+ return STATUS_ERROR;\r
+ }\r
+ \r
+ ClError = FALSE;\r
+ while (fgets (Line, sizeof (Line), Fptr) != NULL) {\r
+ Ret = sscanf (Line, "Note: including file: %s %c", IncludeFileName, &Char);\r
+ if (Ret == 2) {\r
+ //\r
+ // There is space in include file name. It's VS header file. Ignore it.\r
+ //\r
+ continue;\r
+ } else if ( Ret != 1) {\r
+ //\r
+ // Cl error info, print it\r
+ // the tool will return error code to stop the nmake\r
+ //\r
+ ClError = TRUE;\r
+ printf ("%s", Line);\r
+ continue;\r
+ }\r
+ \r
+ //\r
+ // If we're not doing duplicates, and we've already seen this filename,\r
+ // then continue\r
+ //\r
+ if (mGlobals.NoDupes) {\r
+ for (ListPtr = ProcessedFiles->Next; ListPtr != NULL; ListPtr = ListPtr->Next) {\r
+ if (_stricmp (IncludeFileName, ListPtr->Str) == 0) {\r
+ break;\r
+ }\r
+ }\r
+ //\r
+ // If we found a match, we're done. If we didn't, create a new element\r
+ // and add it to the list.\r
+ //\r
+ if (ListPtr != NULL) {\r
+ //\r
+ // Print a message if verbose mode\r
+ //\r
+ if (mGlobals.Verbose) {\r
+ DebugMsg (NULL, 0, 0, IncludeFileName, "duplicate include -- not processed again");\r
+ }\r
+ \r
+ continue;\r
+ }\r
+ \r
+ ListPtr = malloc (sizeof (STRING_LIST));\r
+ ListPtr->Str = malloc (strlen (IncludeFileName) + 1);\r
+ strcpy (ListPtr->Str, IncludeFileName);\r
+ ListPtr->Next = ProcessedFiles->Next;\r
+ ProcessedFiles->Next = ListPtr;\r
+ }\r
+ \r
+ PrintDependency (TargetFileName, IncludeFileName);\r
+ }\r
+ \r
+ fclose (Fptr);\r
+ \r
+ if (ClError) {\r
+ Error (NULL, 0, 0, NULL, "cl error");\r
+ return STATUS_ERROR;\r
+ } else {\r
+ return STATUS_SUCCESS;\r
+ }\r
+}\r
+\r