wuget.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. #include "jlib.hpp"
  14. #include "thorplugin.hpp"
  15. #include "workunit.hpp"
  16. void usage(const char *progname)
  17. {
  18. fprintf(stderr, "%s - extract workunit information from query dll.\nUsage: %s filename\n", progname, progname);
  19. }
  20. int main(int argc, char **argv)
  21. {
  22. InitModuleObjects();
  23. bool doManifestInfo = false;
  24. bool doWorkunit = false;
  25. for (int i = 1; i < argc; i++)
  26. {
  27. if (argv[i][0]=='-')
  28. {
  29. if (strcmp(argv[i], "-m")==0)
  30. doManifestInfo = true;
  31. else if (strcmp(argv[i], "-w")==0)
  32. doWorkunit = true;
  33. else
  34. {
  35. usage(argv[0]);
  36. return 1;
  37. }
  38. }
  39. }
  40. int filesSeen = 0;
  41. int errors = 0;
  42. for (int i = 1; i < argc; i++)
  43. {
  44. if (argv[i][0]!='-')
  45. {
  46. try
  47. {
  48. filesSeen++;
  49. if (doWorkunit || !doManifestInfo)
  50. {
  51. StringBuffer xml;
  52. if (getWorkunitXMLFromFile(argv[i], xml))
  53. {
  54. Owned<ILocalWorkUnit> wu = createLocalWorkUnit(xml);
  55. exportWorkUnitToXML(wu, xml.clear(), true, false, true);
  56. printf("%s\n", xml.str());
  57. }
  58. else
  59. {
  60. fprintf(stderr, "Could not load workunit from %s\n", argv[i]);
  61. errors++;
  62. }
  63. }
  64. if (doManifestInfo)
  65. {
  66. StringBuffer xml;
  67. if (getManifestXMLFromFile(argv[i], xml))
  68. {
  69. printf("%s\n", xml.str());
  70. }
  71. else
  72. {
  73. fprintf(stderr, "Could not load manifest from %s\n", argv[i]);
  74. errors++;
  75. }
  76. }
  77. }
  78. catch (IException *E)
  79. {
  80. StringBuffer msg;
  81. fprintf(stderr, "Exception %d: %s processing argument %s\n", E->errorCode(), E->errorMessage(msg).str(), argv[i]);
  82. errors++;
  83. E->Release();
  84. }
  85. }
  86. }
  87. if (!filesSeen)
  88. {
  89. fprintf(stderr, "No files specified\n");
  90. errors++;
  91. }
  92. return errors ? 1 : 0;
  93. }