RootTest.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 <https://www.gnu.org/licenses/>.
  14. */
  15. #ifndef RootTest_H
  16. #define RootTest_H
  17. #include "util/CString.h"
  18. #include "util/Js.h"
  19. #include <stdio.h>
  20. #define RootTest_toStr(x) RootTest_toStr2(x)
  21. #define RootTest_toStr2(x) #x
  22. Js({
  23. this.RootTest_mainFunc = RootTest_toStr(main);
  24. this.RootTest_mainName = this.RootTest_mainFunc.replace(/_main$/, '');
  25. })
  26. #define RootTest_mainName Js_or({ return '"' + this.RootTest_mainName + '"' }, "main")
  27. #define RootTest_main Js_or({ return 'RootTest_' + this.RootTest_mainFunc; }, RootTest_main)
  28. int RootTest_main(int argc, char** argv);
  29. int main(int argc, char** argv)
  30. {
  31. int runIt = 0;
  32. int j = 0;
  33. for (int i = 0; i < argc; i++) {
  34. argv[j] = argv[i];
  35. if (!CString_strcmp("+roottest", argv[i])) {
  36. j--;
  37. runIt = 1;
  38. }
  39. j++;
  40. }
  41. if (runIt) {
  42. return RootTest_main(j,argv);
  43. } else {
  44. fprintf(stderr, "\nRoot test %s disabled, use [%s %s +roottest] to include it\n",
  45. RootTest_mainName,
  46. (argc > 0) ? argv[0] : "",
  47. RootTest_mainName);
  48. }
  49. return 0;
  50. }
  51. #ifdef main
  52. #undef main
  53. #endif
  54. #define main RootTest_main // CHECKFILES_IGNORE
  55. int main(int argc, char** argv);
  56. #endif