wuget.cpp 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*##############################################################################
  2. Copyright (C) 2011 HPCC Systems.
  3. All rights reserved. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Affero General Public License as
  5. published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Affero General Public License for more details.
  11. You should have received a copy of the GNU Affero General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ############################################################################## */
  14. #include "jlib.hpp"
  15. #include "thorplugin.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. bool doManifestInfo = false;
  23. bool doWorkunit = false;
  24. for (int i = 1; i < argc; i++)
  25. {
  26. if (argv[i][0]=='-')
  27. {
  28. if (strcmp(argv[i], "-m")==0)
  29. doManifestInfo = true;
  30. else if (strcmp(argv[i], "-w")==0)
  31. doWorkunit = true;
  32. else
  33. {
  34. usage(argv[0]);
  35. return 1;
  36. }
  37. }
  38. }
  39. int filesSeen = 0;
  40. int errors = 0;
  41. for (int i = 1; i < argc; i++)
  42. {
  43. if (argv[i][0]!='-')
  44. {
  45. filesSeen++;
  46. if (doWorkunit || !doManifestInfo)
  47. {
  48. StringBuffer xml;
  49. if (getWorkunitXMLFromFile(argv[i], xml))
  50. {
  51. printf("%s\n", xml.str());
  52. }
  53. else
  54. {
  55. fprintf(stderr, "Could not load workunit from %s\n", argv[i]);
  56. errors++;
  57. }
  58. }
  59. if (doManifestInfo)
  60. {
  61. StringBuffer xml;
  62. if (getManifestXMLFromFile(argv[i], xml))
  63. {
  64. printf("%s\n", xml.str());
  65. }
  66. else
  67. {
  68. fprintf(stderr, "Could not load manifest from %s\n", argv[i]);
  69. errors++;
  70. }
  71. }
  72. }
  73. }
  74. if (!filesSeen)
  75. {
  76. fprintf(stderr, "No files specified\n");
  77. errors++;
  78. }
  79. return errors ? 1 : 0;
  80. }