1
0

RootTest.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* vim: set expandtab ts=4 sw=4: */
  2. /*
  3. * You may redistribute this program and/or modify it under the terms of
  4. * the GNU General Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. *
  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 General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. #ifndef RootTest_H
  16. #define RootTest_H
  17. #include "util/CString.h"
  18. #include <stdio.h>
  19. #define RootTest_toStr(x) RootTest_toStr2(x)
  20. #define RootTest_toStr2(x) #x
  21. <?js file.RootTest_mainFunc = RootTest_toStr(main) ?>
  22. #define RootTest_main <?js return 'RootTest_'+file.RootTest_mainFunc; ?>
  23. int RootTest_main(int argc, char** argv);
  24. int main(int argc, char** argv)
  25. {
  26. int runIt = 0;
  27. int j = 0;
  28. for (int i = 0; i < argc; i++) {
  29. argv[j] = argv[i];
  30. if (!CString_strcmp("+roottest", argv[i])) {
  31. j--;
  32. runIt = 1;
  33. }
  34. j++;
  35. }
  36. if (runIt) {
  37. return RootTest_main(j,argv);
  38. } else {
  39. fprintf(stderr, "\nRoot test %s disabled, use [%s +roottest] to include it\n",
  40. RootTest_toStr(main),
  41. (argc > 0) ? argv[0] : "");
  42. }
  43. return 0;
  44. }
  45. #ifdef main
  46. #undef main
  47. #endif
  48. #define main RootTest_main // CHECKFILES_IGNORE
  49. int main(int argc, char** argv);
  50. #endif