📄 rptinfo.c
字号:
/*********************************************************************
* Microsoft Diagnostics Version 2.0
*
* A diagnostic utility to detect as much useful information about a
* customer's computer system as is possible.
*
* Microsoft Diagnostics: We detect the World.
*
* RPTINFO.C - Source file for reporting specific code.
********************************************************************/
/* Include Files */
#include "msd.h"
PSZ pszHeaderLine = NULL; /* Header string */
/********************************************************************
* ReportOnly - Generates an MSD report from the "/F" command line
* parameter.
*
* pszRptFilename - Name of file for "/F" report
*
* This routine will get and print each record, one record at a time.
*
* Returns: TRUE if an error condition occured.
********************************************************************/
BOOL ReportOnly (PSZ pszRptFilename)
{
FILE *fileReportFile; /* File handle for report file */
VOID *pStructForInfo = NULL; /* Pointer to structure with data */
WORD wStructSize; /* Stores memory requirements for */
/* GetInfo record */
WORD wRecordType; /* Record Type */
QSZ *pqszStrings; /* Array of strings to print */
BOOL fReturnValue = FALSE; /* Stores return value from GetInfo */
BOOL fFirstPass = TRUE; /* Used for printing the first header */
INT i, u; /* Looping variables */
INT iLoopStart; /* Starting value for loop */
INT iLoopEnd; /* Ending value for loop */
CHAR chBuffer[_MAX_PATH]; /* Local string */
/* Open the report file */
fileReportFile = OpenFile (pszRptFilename, pszOutput, TRUE);
if (fileReportFile == NULL)
return (TRUE);
/* Set the buffer size to 0 so all characters will be written to */
/* the disk immediately. This will help us determine where */
/* MSD crashed, and will give us as much information as MSD */
/* could provide before crashing. */
/* setvbuf (fileReportFile, NULL, _IONBF, 0); */
/* Set page, line, and column counts to 0 */
wLineCount = 0;
wColumnCount = 0;
wPageCount = 0;
if (fFirstPass && rgfReportItemFlag[IDI_CUSTOMER_INFORMATION] == FALSE)
{
fFirstPass = FALSE;
/* Put on the initial page break */
fReturnValue = WritePageBreak (fileReportFile);
if (fReturnValue)
return (fReturnValue);
}
/* If this is a /S summary only report, just print the summary */
if (fSummaryOnly)
{
iLoopStart = IDI_SUMMARY_SCREEN;
iLoopEnd = IDI_SUMMARY_SCREEN + 1;
}
else
{
iLoopStart = 1;
iLoopEnd = NMBR_OF_RECORDS;
}
/* Report the information from the buttons */
for (i = iLoopStart; i < iLoopEnd && !fReturnValue; ++i)
{
#if HEAP_DEBUG
sprintf (chBuffer, "i = %d", i);
HeapCheck (chBuffer);
#endif
/* Is the information available for this item */
if (rgfReportItemFlag[i] == FALSE)
continue;
/* Determine the memory required to store the record */
wStructSize = GetInfoSize (rwRecordTypes[i], 0);
if (wStructSize == 0)
continue; /* NULL usually means I had an invalid record type */
/* Allocate memory for the structure */
pStructForInfo = malloc (wStructSize);
if (pStructForInfo == NULL)
{
OutOfMemory();
return (TRUE);
}
/* Zero out the structure */
memset (pStructForInfo, '\0', wStructSize);
/* Fill it with the GetInfo data */
fReturnValue = GetInfo (rwRecordTypes[i],
pStructForInfo,
FALSE, /* Do not obtain minimum info */
FALSE, /* No include header record */
TRUE); /* We are doing a report */
#if HEAP_DEBUG
sprintf (chBuffer, "After GetInfo %d", i);
HeapCheck (chBuffer);
#endif
if (fReturnValue)
{
free (pStructForInfo);
return (TRUE);
}
pqszStrings = SprintInfo (rwRecordTypes[i],
pStructForInfo,
NULL,
TRUE); /* We are doing a report */
#if HEAP_DEBUG
sprintf (chBuffer, "After SprintInfo %d", i);
HeapCheck (chBuffer);
#endif
if (fFirstPass && !fSummaryOnly)
{
fFirstPass = FALSE;
/* Put on the initial page break */
fReturnValue = WritePageBreak (fileReportFile);
if (fReturnValue)
return (fReturnValue);
}
/* Write the strings to the report file */
if (pqszStrings != NULL)
if (fSummaryOnly)
{
/* Print out the summary information */
for (u = 0; !fReturnValue && pqszStrings[u] != NULL; ++u)
fReturnValue = WriteLine (pqszStrings[u], fileReportFile, TRUE);
}
else
{
wRecordType = rwRecordTypes[i];
fReturnValue = WriteInfo (fileReportFile,
paszButtonNames[wRecordType],
pqszStrings);
}
#if HEAP_DEBUG
sprintf (chBuffer, "After WriteInfo %d", i);
HeapCheck (chBuffer);
#endif
/* Flush the report buffer */
fflush (fileReportFile);
/* Free up the allocated memory */
free (pStructForInfo);
FreeStringSpace (pqszStrings);
#if HEAP_DEBUG
sprintf (chBuffer, "After three free's %d", i);
HeapCheck (chBuffer);
#endif
}
/* If we're doing just the summary, then we're done */
if (fSummaryOnly)
return (fReturnValue);
/* Report the Memory Browser information */
if (rgfReportItemFlag[i] == TRUE && !fReturnValue)
{
fReturnValue = ReportBrowseInfo (fileReportFile);
/* Flush the report buffer */
fflush (fileReportFile);
}
/* Check to see if we are only printing one item */
if (iLoopStart != iLoopEnd + 1)
{
/* Report the files (AUTOEXEC.BAT, etc) */
for (i = RIF_START;
i < MAX_REPORT_ITEM_FLAGS && !fReturnValue; ++i)
{
FILE_INFO FAR * ffi; /* File Information structure */
FILE_INFO FAR * ffi2; /* File Information structure (copy) */
/* Is the information available for this item */
if (rgfReportItemFlag[i] == FALSE)
continue;
ffi = FindFile (rgszSystemFiles[i - RIF_START], NULL,
rgwSystemFiles[i - RIF_START], '\0');
ffi2 = ffi;
while (ffi != NULL && ffi->fpNextFileInfo != NULL && !fReturnValue)
{
/* Put the filename into chBuffer */
_fstrcpy (chBuffer, ffi->fpszPathToFile);
/* Print the file on the report */
fReturnValue = ReportFile (chBuffer, chBuffer, fileReportFile);
/* Flush the report buffer */
fflush (fileReportFile);
/* Point to the next File info structure */
ffi = (FILE_INFO FAR *) (ffi->fpNextFileInfo);
}
FreeFileInfo (ffi2);
}
}
/* Send a form feed at the end of the document */
if (fReturnValue == FALSE)
fReturnValue = WriteChar ('\f', fileReportFile);
CloseFile (fileReportFile);
free (pszHeaderLine);
if (fReportOnly && !fSummaryOnly)
putch ('\n');
return (fReturnValue);
}
#if CW_INCLUDED
/*********************************************************************
* ReportFromCW - Generates a report from the CW version of MSD.
*
* Globals:
* wReportToIndex - Index to paszReporTo. == 7 if pszReportFilename
* already contains a filename for the report.
*********************************************************************/
BOOL ReportFromCW (VOID)
{
BOOL fReturnValue; /* Return value from ReportOnly() */
/* Set the flag indicating that a report is underway */
fReportFlag = TRUE;
/* Report to the appropriate port/file */
if (wReportToIndex == 7)
{
fReturnValue = ReportOnly (pszReportFilename);
free (pszReportFilename);
}
else
{
fReturnValue = ReportOnly (paszReportTo[wReportToIndex]);
}
/* Set the flag indicating that the report is over */
fReportFlag = FALSE;
/* Inform the user that the report is finished */
DisplayStatus (ST_REPORT_COMPLETED);
return (fReturnValue);
}
#endif
/********************************************************************
* WriteInfo - Writes a set of strings to the output file
*
* fileReportFile - File handle to write strings to
* pszTitle - Title of information being printed
* (NULL for no separator line)
* ppszStrings - Array of strings to print
*
* Globals:
* wLineCount - Used for determining the need for a page break
*
* Returns: TRUE if an error condition occured.
********************************************************************/
BOOL WriteInfo (FILE *fileOutput,
PSZ pszTitle,
QSZ *pqszStrings)
{
BOOL fReturnValue = FALSE; /* Return value from various functions */
INT i; /* Index to pqszStrings, looping variable */
WORD wNmbrLines = 0; /* Number of lines in this string array */
WORD wLongestLine = 0; /* The length of the longest line */
WORD wLength; /* The length of the current line */
INT iIndent; /* Number of characters to indent on each */
/* line, for centering purposes */
INT iIndentCount; /* Variable for outputting the indent */
/* Determine the number of lines and the length of the longest line */
while (pqszStrings[wNmbrLines] != NULL)
{
if ((wLength = Qstrlen (pqszStrings[wNmbrLines++])) > wLongestLine)
wLongestLine = wLength;
}
/* Determine the left indent required to center the text */
if (wNmbrLines)
{
iIndent = (REPORT_WIDTH / 2) - (wLongestLine / 2) - 1;
if (iIndent < 0)
iIndent = 0;
/* Account for the separator line */
if (pszTitle != NULL && pszTitle[0] != '\0')
wNmbrLines += 3;
/* Determine if a page break is required */
if (wNmbrLines + wLineCount > LINES_PER_PAGE)
fReturnValue = WritePageBreak (fileOutput);
/* Write the separator line, if requested */
if (pszTitle != NULL && pszTitle[0] != '\0')
fReturnValue = WriteSepLine (fileOutput, pszTitle);
/* Write the strings */
i = 0;
while (!fReturnValue && pqszStrings[i] != NULL)
{
iIndentCount = iIndent;
while (!fReturnValue && iIndentCount--)
fReturnValue = WriteChar (' ', fileOutput);
if (!fReturnValue)
fReturnValue = WriteLine (pqszStrings[i++], fileOutput, TRUE);
}
/* Flush the buffer contents */
if (!fReturnValue)
{
fReturnValue = fflush (fileOutput);
/* Adjust the return value appropriately */
if (fReturnValue == EOF)
fReturnValue = TRUE;
else
fReturnValue = FALSE;
}
}
return (fReturnValue);
}
/********************************************************************
* WriteSepLine - Writes a separator line to the output file
*
* fileOutput - File handle to write strings to
* pszTitle - Title of record type being printed
* (NULL for no separator line)
*
* Returns: TRUE if an error condition occured.
********************************************************************/
BOOL WriteSepLine (FILE *fileOutput, PSZ pszTitle)
{
BOOL fReturnValue; /* Return value from Write___ functions */
CHAR chBuffer[REPORT_WIDTH]; /* Buffer for building output string */
INT iLen; /* String length */
INT iDashCount; /* Number of dashes to the left of title */
INT i; /* Index to chBuffer */
/* Fill in all the dashes */
memset (chBuffer, '-', REPORT_WIDTH - 1);
/* Determine the length of the title */
iLen = strlen (pszTitle);
iDashCount = ((REPORT_WIDTH - iLen) / 2) - 2;
i = iDashCount;
/* Put in a leading space, the name, and the trailing space */
chBuffer[i++] = ' ';
strcpy (&chBuffer[i], pszTitle);
i += iLen;
chBuffer[i] = ' ';
chBuffer[REPORT_WIDTH - 1] = '\0';
/* Now, output the separator line */
fReturnValue = WriteChar ('\n', fileOutput);
if (fReturnValue)
return (fReturnValue);
fReturnValue = WriteLine (chBuffer, fileOutput, TRUE);
if (fReturnValue)
return (fReturnValue);
fReturnValue = WriteChar ('\n', fileOutput);
if (fReturnValue)
return (fReturnValue);
}
/********************************************************************
* WritePageBreak - Writes a separator line to the output file
*
* fileOutput - File handle to write strings to
*
* Returns: TRUE if an error condition occured.
********************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -