ort.c 862 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include "duktape/duktape.h"
  2. #include "config.h"
  3. #include "runtime.h"
  4. int main(int argc, char *argv[]) {
  5. int status = 0;
  6. char binPath[MAX_CHAR_LEN];
  7. char filename[MAX_CHAR_LEN];
  8. if (argc < 2) {
  9. printHelp();
  10. return 0;
  11. } else {
  12. strcpy(filename, argv[1]);
  13. }
  14. /* Init Runtime */
  15. initRuntime();
  16. getExeDir(binPath);
  17. /* file operations */
  18. // loadJS("./js/lib.js", binPath);
  19. loadJS("./js/card-lib.js", binPath);
  20. loadJS("./js/yahooWeather.js", binPath); // TODO: this is a hack, fix this by loading modules from js
  21. status = loadJS(filename, binPath);
  22. if (status == EXIT_SUCCESS) {
  23. runSetup();
  24. while (status == EXIT_SUCCESS) {
  25. status = runLoop();
  26. usleep(100000);
  27. }
  28. }
  29. /* destroy runtime */
  30. destroyRuntime();
  31. return status;
  32. }