STYLE: Nightly Version update
[cmake.git] / Tests / SystemInformation / DumpInformation.cxx
blobc84af3729411b5ddf5e56802d85058887e023dbc
1 #include "DumpInformation.h"
2 #include <stdio.h>
3 #include <sys/stat.h>
5 void cmDumpInformationPrintFile(const char* name, FILE* fout)
7 fprintf(fout,
8 "Avoid ctest truncation of output: CTEST_FULL_OUTPUT\n");
9 fprintf(fout,
10 "================================================================\n");
11 struct stat fs;
12 if(stat(name, &fs) != 0)
14 fprintf(fout, "The file \"%s\" does not exist.\n", name);
15 fflush(fout);
16 return;
19 FILE* fin = fopen(name, "r");
20 if(fin)
22 fprintf(fout,
23 "Contents of \"%s\":\n"
24 "----------------------------------------------------------------\n",
25 name);
26 const int bufferSize = 4096;
27 char buffer[bufferSize];
28 int n;
29 while((n = fread(buffer, 1, bufferSize, fin)) > 0)
31 for(char* c = buffer; c < buffer+n; ++c)
33 switch(*c)
35 case '<': fprintf(fout, "&lt;"); break;
36 case '>': fprintf(fout, "&gt;"); break;
37 case '&': fprintf(fout, "&amp;"); break;
38 default: putc(*c, fout); break;
41 fflush(fout);
43 fclose(fin);
45 else
47 fprintf(fout, "Error opening \"%s\" for reading.\n", name);
48 fflush(fout);
52 int main(int,char *[])
54 const char* files[] =
56 DumpInformation_BINARY_DIR "/SystemInformation.out",
57 DumpInformation_BINARY_DIR "/AllVariables.txt",
58 DumpInformation_BINARY_DIR "/AllCommands.txt",
59 DumpInformation_BINARY_DIR "/AllMacros.txt",
60 DumpInformation_BINARY_DIR "/OtherProperties.txt",
61 DumpInformation_BINARY_DIR "/../../Source/cmConfigure.h",
62 DumpInformation_BINARY_DIR "/../../CMakeCache.txt",
63 DumpInformation_BINARY_DIR "/../../CMakeOutput.log",
64 DumpInformation_BINARY_DIR "/../../CMakeError.log",
65 DumpInformation_BINARY_DIR "/../../Bootstrap.cmk/cmake_bootstrap.log",
66 DumpInformation_BINARY_DIR "/../../Source/cmsys/Configure.hxx",
67 DumpInformation_BINARY_DIR "/../../Source/cmsys/Configure.h",
71 const char** f;
72 for(f = files; *f; ++f)
74 cmDumpInformationPrintFile(*f, stdout);
77 return 0;