From 7623e44dbd8818113bc243e64c107c8c159f06c1 Mon Sep 17 00:00:00 2001 From: Nishi Date: Sat, 12 Oct 2024 01:25:30 +0000 Subject: [PATCH] program stuff git-svn-id: file:///raid/svn-personal/rbuild/trunk@22 c68d3453-7f82-0740-9748-1d72386a946b --- Server/server.c | 5 ++++- Server/task.c | 19 +++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Server/server.c b/Server/server.c index d79ad69..df45091 100644 --- a/Server/server.c +++ b/Server/server.c @@ -171,6 +171,7 @@ void rbs_server_handler(void* sockptr) { int i; char* arg = NULL; char* cmd = line; + CMBOOL tool = CMFALSE; if(line == NULL) { break; } @@ -181,6 +182,8 @@ void rbs_server_handler(void* sockptr) { break; } } + tool = tool || strcmp(cmd, "CC") == 0; + tool = tool || strcmp(cmd, "LD") == 0; if(strcmp(cmd, "QUIT") == 0) { free(line); break; @@ -215,7 +218,7 @@ void rbs_server_handler(void* sockptr) { free(line); break; } - } else if(strcmp(cmd, "CC") == 0 && arg != NULL && authed) { + } else if(tool && arg != NULL && authed) { if(rbs_task(sock, section, cmd, arg)) { rbs_write(sock, "SUCCESS\n", 8); free(line); diff --git a/Server/task.c b/Server/task.c index abd27f8..98fd113 100644 --- a/Server/task.c +++ b/Server/task.c @@ -132,11 +132,26 @@ CMBOOL rbs_wait_process(int sock) { } #endif +char* rbs_get_program(const char* section, const char* cmd) { + char* type = rbs_config_get(section, "type"); + if(strcmp(type, "gnu") == 0) { + char* prefix = rbs_config_get(section, "prefix"); + if(strcmp(cmd, "CC") == 0) { + return cm_strcat(prefix, "gcc"); + } else if(strcmp(cmd, "LD") == 0) { + return cm_strcat(prefix, "ld"); + } + } + return cm_strdup(""); +} + CMBOOL rbs_task(int sock, const char* section, const char* cmd, const char* arg) { - char** args = rbs_parse_args("gcc", arg); - CMBOOL status = rbs_start_process("gcc", args); + char* program = rbs_get_program(section, cmd); + char** args = rbs_parse_args(program, arg); + CMBOOL status = rbs_start_process(program, args); rbs_stack_free(args); if(!status) return CMFALSE; rbs_write(sock, "SUCCESS\n", 8); + free(program); return rbs_wait_process(sock); } -- 2.43.0