Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.0 KiB

  1. /*
  2. * Filename: Main.cpp
  3. * Description:
  4. * Author: shouse, 04.10.01
  5. */
  6. #include "stdafx.h"
  7. #include <stdio.h>
  8. #include <string.h>
  9. #include "NLB_XMLParser.h"
  10. #include <vector>
  11. using namespace std;
  12. int __cdecl wmain (int argc, WCHAR ** argv) {
  13. vector<NLB_Cluster> Clusters;
  14. bool bValidateOnly = false;
  15. bool bShowPopups = true;
  16. NLB_XMLParser * pParser;
  17. NLB_XMLError error;
  18. HRESULT hr = S_OK;
  19. int arg;
  20. if (argc < 2) {
  21. goto usage;
  22. }
  23. for (arg = 2; arg < argc; arg++) {
  24. if (argv[arg][0] == L'-') {
  25. if (!lstrcmpi(argv[arg] + 1, L"validate")) {
  26. bValidateOnly = true;
  27. } else if (!lstrcmpi(argv[arg] + 1, L"nopopups")) {
  28. bShowPopups = false;
  29. } else {
  30. printf("Invalid argument: %ls\n", argv[arg]);
  31. goto usage;
  32. }
  33. } else {
  34. printf("Invalid argument: %ls\n", argv[arg]);
  35. goto usage;
  36. }
  37. }
  38. pParser = new NLB_XMLParser(!bShowPopups);
  39. if (bValidateOnly) {
  40. printf("\nValidating XML document...\n");
  41. hr = pParser->Parse(argv[1]);
  42. } else {
  43. printf("\nParsing XML document...\n");
  44. hr = pParser->Parse(argv[1], &Clusters);
  45. }
  46. if (!bShowPopups) {
  47. printf("\n");
  48. if (hr != S_OK) {
  49. pParser->GetParseError(&error);
  50. fprintf(stderr, "Error 0x%08x:\n\n%ls\n", error.code, error.wszReason);
  51. if (error.line > 0) {
  52. fprintf(stderr, "Error on line %d, position %d in \"%ls\".\n",
  53. error.line, error.character, error.wszURL);
  54. }
  55. return -1;
  56. } else {
  57. fprintf(stderr, "XML document loaded successfully...\n");
  58. }
  59. }
  60. if (!bValidateOnly)
  61. pParser->Print();
  62. return 0;
  63. usage:
  64. printf("Usage: %ls <XML filename> [-validate] [-nopopups]\n", argv[0]);
  65. return -1;
  66. }