DumpInformation.cxx 900 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include <stdio.h>
  2. #include "DumpInformation.h"
  3. int DumpFile(char* filename, char* comment)
  4. {
  5. FILE* file = fopen(filename, "r");
  6. if(!file)
  7. {
  8. printf("Error, could not open file %s\n", filename);
  9. return 1;
  10. }
  11. printf("%s", comment);
  12. while(!feof(file))
  13. {
  14. int ch = fgetc(file);
  15. if(ch != EOF)
  16. {
  17. if(ch == '<')
  18. {
  19. printf("&lt;");
  20. }
  21. else if(ch == '>')
  22. {
  23. printf("&gt;");
  24. }
  25. else if(ch == '&')
  26. {
  27. printf("&amp;");
  28. }
  29. else
  30. {
  31. putc(ch, stdout);
  32. }
  33. }
  34. }
  35. printf("\n");
  36. fclose(file);
  37. return 0;
  38. }
  39. int main(int, char*[])
  40. {
  41. int res = 0;
  42. res += DumpFile(CMAKE_DUMP_FILE, "#CMake System Variables are:");
  43. res += DumpFile(CMAKE_CACHE_FILE, "#CMake Cache is:");
  44. res += DumpFile(CMAKE_ALL_VARIABLES, "#CMake Variables are:");
  45. return res;
  46. }