From 72f6cb41b5d37b4093e3181b2e37209a6a3087f5 Mon Sep 17 00:00:00 2001 From: Martin Polanka Date: Thu, 19 Apr 2018 11:39:32 +0200 Subject: [PATCH] Introduce new passthrough judge --- judges/CMakeLists.txt | 1 + judges/judge_passthrough/CMakeLists.txt | 25 ++++++++++++++++ judges/judge_passthrough/main.cpp | 39 +++++++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 judges/judge_passthrough/CMakeLists.txt create mode 100644 judges/judge_passthrough/main.cpp diff --git a/judges/CMakeLists.txt b/judges/CMakeLists.txt index 9955c916..bc235454 100644 --- a/judges/CMakeLists.txt +++ b/judges/CMakeLists.txt @@ -2,5 +2,6 @@ cmake_minimum_required(VERSION 2.8) # Just add all judges and nothing else add_subdirectory(codex_judge) +add_subdirectory(judge_passthrough) add_subdirectory(filter) add_subdirectory(shuffled) diff --git a/judges/judge_passthrough/CMakeLists.txt b/judges/judge_passthrough/CMakeLists.txt new file mode 100644 index 00000000..e020efde --- /dev/null +++ b/judges/judge_passthrough/CMakeLists.txt @@ -0,0 +1,25 @@ +cmake_minimum_required(VERSION 2.8) +project(recodex-judge-passthrough) + +# Use all settings from original Makefile +if(UNIX) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Wall -fexceptions") + set(CMAKE_CXX_LINKER_FLAGS "${CMAKE_CXX_LINKER_FLAGS} -s") +endif() + +# The worker executable +set(SOURCE_FILES + main.cpp +) + +add_executable(${PROJECT_NAME} ${SOURCE_FILES}) + + +# installation +if(UNIX) + install(TARGETS recodex-judge-passthrough DESTINATION /usr/bin COMPONENT binaries) +elseif(MSVC) + install(TARGETS recodex-judge-passthrough DESTINATION worker/bin COMPONENT binaries) +else() + install(TARGETS recodex-judge-passthrough DESTINATION recodex/worker/bin COMPONENT binaries) +endif() diff --git a/judges/judge_passthrough/main.cpp b/judges/judge_passthrough/main.cpp new file mode 100644 index 00000000..07b961f3 --- /dev/null +++ b/judges/judge_passthrough/main.cpp @@ -0,0 +1,39 @@ +/* + * Passthrough judge which just outputs inputted file. + * (C) 2018 ReCodEx Team + * + * Usage: recodex-judge-passthrough + * + * Exitcode: + * - 0: if output was provided + * - 2: errors were present during execution of comparision, error message should be visible on stderr + * + * Enjoy :o) + */ + +#include +#include + +#define RES_OK 0 +#define RES_ERROR 2 + +using namespace std; + + +/* + * Application entry point. + */ +int main(int argc, char **argv) { + + // Check amount of program arguments. + if (argc != 3) { + cerr << "Wrong amount of arguments." << endl; + return RES_ERROR; + } + + ifstream inputfile(argv[1]); + cout << inputfile.rdbuf(); + inputfile.close(); + + return RES_OK; +}