aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan200101 <sentrycraft123@gmail.com>2022-07-21 15:13:00 +0200
committerJan200101 <sentrycraft123@gmail.com>2022-07-21 15:13:00 +0200
commit63b339b383294a032da86bc52bfb452fb494e62f (patch)
treed112d4a3ace2c44d1dbbedd5aaa8f4eeb2857d3d /src
parent7909d89fa3a041ae157d19b4a22f73f3f1bac3d7 (diff)
downloadcgci-63b339b383294a032da86bc52bfb452fb494e62f.tar.gz
cgci-63b339b383294a032da86bc52bfb452fb494e62f.zip
only load current build fully
Diffstat (limited to 'src')
-rw-r--r--src/config.c1
-rw-r--r--src/config.h1
-rw-r--r--src/parser.c41
-rw-r--r--src/parser.h5
4 files changed, 32 insertions, 16 deletions
diff --git a/src/config.c b/src/config.c
index 02ad9e3..4eb5621 100644
--- a/src/config.c
+++ b/src/config.c
@@ -57,6 +57,7 @@ void init_config()
if (!strcmp(context.index, config.projects[i].builds[j].name))
{
current_build = &config.projects[i].builds[j];
+ load_full_build(current_project, current_build);
break;
}
}
diff --git a/src/config.h b/src/config.h
index 49daf77..8cc27a0 100644
--- a/src/config.h
+++ b/src/config.h
@@ -43,7 +43,6 @@ extern struct build_t* current_build;
void init_config();
void deinit_config();
-void parse_config();
char* cache_dir();
char* project_dir(char* project);
diff --git a/src/parser.c b/src/parser.c
index d8ad576..f13cbe5 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -208,21 +208,6 @@ void parse_config()
}
build[build_size] = '\0';
- strcat(build, "/log");
- fd = fopen(build, "rb");
- if (fd)
- {
- fseek(fd, 0, SEEK_END);
- size_t size = (size_t)ftell(fd);
- rewind(fd);
-
- config.projects[i].builds[config.projects[i].build_count-1].log = malloc(size + 1);
- fread(config.projects[i].builds[config.projects[i].build_count-1].log, sizeof(char), size, fd);
- fclose(fd);
- config.projects[i].builds[config.projects[i].build_count-1].log[size] = '\0';
- }
- build[build_size] = '\0';
-
free(build);
}
closedir(dir);
@@ -252,6 +237,32 @@ void parse_config()
free(buf);
}
+void load_full_build(struct project_t* project, struct build_t* build)
+{
+ if (!build)
+ return;
+
+ char* path = build_dir(project->name, build->name);
+ size_t build_size = strlen(path);
+ path = realloc(path, (build_size + 11 + 1) * sizeof(char));
+ FILE* fd;
+
+ strcat(path, "/log");
+ fd = fopen(path, "rb");
+ if (fd)
+ {
+ fseek(fd, 0, SEEK_END);
+ size_t size = (size_t)ftell(fd);
+ rewind(fd);
+
+ build->log = malloc(size + 1);
+ fread(build->log, sizeof(char), size, fd);
+ fclose(fd);
+ build->log[size] = '\0';
+ }
+ path[build_size] = '\0';
+}
+
void parse_path(const char* path)
{
size_t path_len = strlen(path) + 1;
diff --git a/src/parser.h b/src/parser.h
index e5d5465..09e1710 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -1,6 +1,11 @@
#ifndef PARSER_H
#define PARSER_H
+#include "config.h"
+
+void parse_config();
+void load_full_build(struct project_t*, struct build_t*);
+
void argv_to_path(int, char**);
void parse_path(const char*);
void parse_query(const char*);