CMake/Tests/SystemInformation/DumpInformation.cxx

72 lines
1.8 KiB
C++
Raw Normal View History

2002-11-12 02:07:20 +03:00
#include "DumpInformation.h"
#include <stdio.h>
#include <sys/stat.h>
2002-11-12 02:07:20 +03:00
void cmDumpInformationPrintFile(const char* name, FILE* fout)
2002-11-12 02:07:20 +03:00
{
fprintf(fout,
"================================================================\n");
struct stat fs;
if(stat(name, &fs) != 0)
2002-11-12 02:07:20 +03:00
{
fprintf(fout, "The file \"%s\" does not exist.\n", name);
fflush(fout);
return;
2002-11-12 02:07:20 +03:00
}
FILE* fin = fopen(name, "rb");
if(fin)
2002-11-12 02:07:20 +03:00
{
fprintf(fout,
"Contents of \"%s\":\n"
"----------------------------------------------------------------\n",
name);
const int bufferSize = 4096;
char buffer[bufferSize];
int n;
while((n = fread(buffer, 1, bufferSize, fin)) > 0)
2002-11-12 17:33:00 +03:00
{
for(char* c = buffer; c < buffer+n; ++c)
2002-11-12 22:18:36 +03:00
{
switch(*c)
{
case '<': fprintf(fout, "&lt;"); break;
case '>': fprintf(fout, "&gt;"); break;
case '&': fprintf(fout, "&amp;"); break;
default: putc(*c, fout); break;
}
2002-11-12 22:18:36 +03:00
}
fflush(fout);
2002-11-12 17:33:00 +03:00
}
fclose(fin);
}
else
{
fprintf(fout, "Error opening \"%s\" for reading.\n", name);
fflush(fout);
2002-11-12 02:07:20 +03:00
}
}
2003-03-17 16:25:45 +03:00
int main(int,char *[])
2003-03-17 16:25:45 +03:00
{
const char* files[] =
{
DumpInformation_BINARY_DIR "/SystemInformation.out",
DumpInformation_BINARY_DIR "/AllVariables.txt",
DumpInformation_BINARY_DIR "/../../Source/cmConfigure.h",
DumpInformation_BINARY_DIR "/../../CMakeCache.txt",
DumpInformation_BINARY_DIR "/../../CMakeOutput.log",
DumpInformation_BINARY_DIR "/../../CMakeError.log",
DumpInformation_BINARY_DIR "/../../Bootstrap.cmk/cmake_bootstrap.log",
0
};
const char** f;
for(f = files; *f; ++f)
{
cmDumpInformationPrintFile(*f, stdout);
}
return 0;
}