RootTest.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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
  22. file.RootTest_mainFunc = RootTest_toStr(main);
  23. file.RootTest_mainName = file.RootTest_mainFunc.replace(/_main$/, '');
  24. ?>
  25. #define RootTest_mainName <?js return '"' + file.RootTest_mainName + '"' ?>
  26. #define RootTest_main <?js return 'RootTest_'+file.RootTest_mainFunc; ?>
  27. int RootTest_main(int argc, char** argv);
  28. int main(int argc, char** argv)
  29. {
  30. int runIt = 0;
  31. int j = 0;
  32. for (int i = 0; i < argc; i++) {
  33. argv[j] = argv[i];
  34. if (!CString_strcmp("+roottest", argv[i])) {
  35. j--;
  36. runIt = 1;
  37. }
  38. j++;
  39. }
  40. if (runIt) {
  41. return RootTest_main(j,argv);
  42. } else {
  43. fprintf(stderr, "\nRoot test %s disabled, use [%s %s +roottest] to include it\n",
  44. RootTest_mainName,
  45. (argc > 0) ? argv[0] : "",
  46. RootTest_mainName);
  47. }
  48. return 0;
  49. }
  50. #ifdef main
  51. #undef main
  52. #endif
  53. #define main RootTest_main // CHECKFILES_IGNORE
  54. int main(int argc, char** argv);
  55. #endif