lorun.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /**
  2. * Loco program runner core
  3. * Copyright (C) 2011 Lodevil(Du Jiong)
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef __LO_GCC_HEADER
  19. #define __LO_GCC_HEADER
  20. #include <Python.h>
  21. #include <sys/types.h>
  22. #define CALLS_MAX 400
  23. #define MAX_OUTPUT 100000000
  24. enum JUDGE_RESULT {
  25. AC=0, //0 Accepted
  26. PE, //1 Presentation Error
  27. TLE, //2 Time Limit Exceeded
  28. MLE, //3 Memory Limit Exceeded
  29. WA, //4 Wrong Answer
  30. RE, //5 Runtime Error
  31. OLE, //6 Output Limit Exceeded
  32. CE, //7 Compile Error
  33. SE, //8 System Error
  34. };
  35. struct Result {
  36. int judge_result; //JUDGE_RESULT
  37. int time_used, memory_used;
  38. int re_signum;
  39. int re_call;
  40. const char* re_file;
  41. int re_file_flag;
  42. };
  43. struct Runobj {
  44. PyObject *files;
  45. u_char inttable[CALLS_MAX];
  46. char * const* args;
  47. int fd_in, fd_out, fd_err;
  48. int time_limit, memory_limit;
  49. int runner;
  50. int trace;
  51. };
  52. #define RAISE(msg) PyErr_SetString(PyExc_Exception,msg);
  53. #define RAISE0(msg) \
  54. {PyErr_SetString(PyExc_Exception,msg); return NULL;}
  55. #define RAISE1(msg) \
  56. {PyErr_SetString(PyExc_Exception,msg); return -1;}
  57. #if PY_MAJOR_VERSION >= 3
  58. #define IS_PY3
  59. #endif
  60. #endif