Judger/runner.h

62 lines
1.0 KiB
C
Raw Normal View History

2016-01-12 08:09:18 +00:00
#ifndef JUDGER_RUNNER_H
#define JUDGER_RUNNER_H
#endif
2016-01-12 08:40:28 +00:00
#define __DEBUG__
#ifdef __DEBUG__
2016-01-19 05:48:46 +00:00
#define log(format, ...) printf("File: "__FILE__", Line: %05d: "format"\n", __LINE__, ##__VA_ARGS__)
2016-01-12 08:40:28 +00:00
#else
2016-01-19 05:48:46 +00:00
#define log(format,...)
2016-01-12 08:40:28 +00:00
#endif
2016-01-15 17:24:51 +00:00
#define SUCCESS 0
2016-01-12 08:40:28 +00:00
2016-01-15 17:39:46 +00:00
#define FORK_FAILED 1
#define WAIT4_FAILED 2
#define RUN_FAILED 3
#define SETITIMER_FAILED 4
#define SETRLIMIT_FAILED 5
#define DUP2_FAILED 6
#define EXCEVE_FAILED 7
2016-01-20 03:00:05 +00:00
#define LOAD_SECCOMP_FAILED 8
2016-01-23 07:05:24 +00:00
#define SET_UID_FAILED 9
#define SET_GID_FAILED 10
2016-01-12 08:40:28 +00:00
#define CPU_TIME_LIMIT_EXCEEDED 1
#define REAL_TIME_LIMIT_EXCEEDED 2
#define MEMORY_LIMIT_EXCEEDED 3
#define RUNTIME_ERROR 4
#define SYSTEM_ERROR 5
2016-01-23 07:34:48 +00:00
#define ERROR(code) raise(SIGUSR1)
2016-01-12 08:40:28 +00:00
2016-01-23 07:05:24 +00:00
#define NOBODY_UID 65534
#define NOBODY_GID 65534
2016-01-12 08:09:18 +00:00
struct result {
int cpu_time;
long memory;
int real_time;
int signal;
int flag;
};
struct config {
int max_cpu_time;
int max_memory;
2016-01-12 10:23:56 +00:00
char *path;
char *in_file;
char *out_file;
2016-01-12 15:51:11 +00:00
char *args[100];
char *env[100];
2016-01-22 02:01:08 +00:00
int use_sandbox;
2016-01-12 08:09:18 +00:00
};
2016-01-23 07:34:48 +00:00
void run(struct config *, struct result *);
2016-01-12 08:09:18 +00:00