wuget.cpp 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. filesSeen++;
  47. if (doWorkunit || !doManifestInfo)
  48. {
  49. StringBuffer xml;
  50. if (getWorkunitXMLFromFile(argv[i], xml))
  51. {
  52. Owned<ILocalWorkUnit> wu = createLocalWorkUnit(xml);
  53. exportWorkUnitToXML(wu, xml.clear(), true, false);
  54. printf("%s\n", xml.str());
  55. }
  56. else
  57. {
  58. fprintf(stderr, "Could not load workunit from %s\n", argv[i]);
  59. errors++;
  60. }
  61. }
  62. if (doManifestInfo)
  63. {
  64. StringBuffer xml;
  65. if (getManifestXMLFromFile(argv[i], xml))
  66. {
  67. printf("%s\n", xml.str());
  68. }
  69. else
  70. {
  71. fprintf(stderr, "Could not load manifest from %s\n", argv[i]);
  72. errors++;
  73. }
  74. }
  75. }
  76. }
  77. if (!filesSeen)
  78. {
  79. fprintf(stderr, "No files specified\n");
  80. errors++;
  81. }
  82. return errors ? 1 : 0;
  83. }