From a25527272916f342875809d7c3606ba0ebd350b4 Mon Sep 17 00:00:00 2001 From: Jeffrey Armstrong Date: Tue, 11 May 2021 20:09:08 -0400 Subject: Moved some command handling into requtils to share with web and gemini modes. Started work on handling post requests to add players. --- captain/requtils.f90 | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'captain/requtils.f90') diff --git a/captain/requtils.f90 b/captain/requtils.f90 index 7010bcb..cb52113 100644 --- a/captain/requtils.f90 +++ b/captain/requtils.f90 @@ -319,4 +319,41 @@ contains end subroutine get_job_page_title + subroutine handle_instruction_command(req) + use captain_db + use server_response + use remote_launch + implicit none + + type(request), intent(in)::req + character(32)::command + character(PLAYER_NAME_LENGTH)::argument, instruction_name + + integer::i, j + + i = index(req%page, ".", back=.true.) + + instruction_name = req%page(1:i-1) + + i = index(req%query_string, "=") + command = req%query_string(1:i-1) + argument = req%query_string(i+1:len_trim(req%query_string)) + + if(trim(command) == "launch") then + call launch_instructions_on_player(instruction_name, argument) + + else if(trim(command) == "assign") then + i = get_instruction_id(trim(instruction_name)) + j = get_player_id(trim(argument)) + call add_player_for_instruction(i, j) + + else if(trim(command) == "remove") then + i = get_instruction_id(trim(instruction_name)) + j = get_player_id(trim(argument)) + call remove_player_for_instruction(i, j) + + end if + + end subroutine handle_instruction_command + end module request_utils \ No newline at end of file -- cgit v1.2.3