]> Nishi Git Mirror - rbuild.git/commitdiff
program stuff
authorNishi <nishi@nishi.boats>
Sat, 12 Oct 2024 01:25:30 +0000 (01:25 +0000)
committerNishi <nishi@nishi.boats>
Sat, 12 Oct 2024 01:25:30 +0000 (01:25 +0000)
git-svn-id: file:///raid/svn-personal/rbuild/trunk@22 c68d3453-7f82-0740-9748-1d72386a946b

Server/server.c
Server/task.c

index d79ad69c66bd1bf0c7c1fb8528678d61b3e3f32f..df45091974b6be8d6056af7f2f8683ec228483d4 100644 (file)
@@ -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);
index abd27f81ad761f4b86461de88abd691ebabce3b1..98fd113eb23b36cbd6ad863afd9eda56f5367ce7 100644 (file)
@@ -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);
 }