CMake/Tests/SystemInformation/DumpInformation.cxx

50 lines
900 B
C++
Raw Normal View History

2002-11-12 02:07:20 +03:00
#include <stdio.h>
#include "DumpInformation.h"
2003-03-17 16:25:45 +03:00
int DumpFile(char* filename, char* comment)
2002-11-12 02:07:20 +03:00
{
2003-03-17 16:25:45 +03:00
FILE* file = fopen(filename, "r");
2002-11-12 02:07:20 +03:00
if(!file)
{
2003-03-17 16:25:45 +03:00
printf("Error, could not open file %s\n", filename);
return 1;
2002-11-12 02:07:20 +03:00
}
2003-03-17 16:25:45 +03:00
printf("%s", comment);
2002-11-12 02:07:20 +03:00
while(!feof(file))
{
2002-11-12 17:33:00 +03:00
int ch = fgetc(file);
if(ch != EOF)
{
2002-11-12 22:18:36 +03:00
if(ch == '<')
{
printf("&lt;");
}
else if(ch == '>')
{
printf("&gt;");
}
else if(ch == '&')
{
printf("&amp;");
}
else
{
putc(ch, stdout);
}
2002-11-12 17:33:00 +03:00
}
2002-11-12 02:07:20 +03:00
}
2002-11-12 22:18:36 +03:00
printf("\n");
2002-11-12 02:07:20 +03:00
fclose(file);
return 0;
}
2003-03-17 16:25:45 +03:00
int main(int, char*[])
{
int res = 0;
res += DumpFile(CMAKE_DUMP_FILE, "#CMake System Variables are:");
res += DumpFile(CMAKE_CACHE_FILE, "#CMake Cache is:");
res += DumpFile(CMAKE_ALL_VARIABLES, "#CMake Variables are:");
return res;
}