From 36b229a8065d717ae165a610042bb961a6fa4759 Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Tue, 11 Jun 2024 13:42:20 +0530 Subject: src/jobs/job_read: read outputs --- src/jobs.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/src/jobs.c b/src/jobs.c index 78b52cc..1a386ff 100644 --- a/src/jobs.c +++ b/src/jobs.c @@ -15,10 +15,11 @@ int job_read(FILE *stream, struct job **job) { int ret; struct job *dep_job; - cJSON *root, *temp, *input_drvs, *array; + cJSON *root, *temp, *input_drvs, *array, *outputs; char *name = NULL; - char *out_name = NULL; char *drv_path = NULL; + char *out_name = NULL; + char *out_path = NULL; ret = json_streaming_read(stream, &root); if (ret < 0) @@ -75,6 +76,12 @@ int job_read(FILE *stream, struct job **job) for (; array != NULL; array = array->next) { out_name = strdup(array->string); + if (out_name == NULL) { + ret = -EPERM; + job_free(*job); + goto out_free; + } + ret = job_output_insert(dep_job, out_name, NULL); if (ret < 0) { job_free(*job); @@ -88,6 +95,32 @@ int job_read(FILE *stream, struct job **job) LIST_INSERT_HEAD(&(*job)->deps, dep_job, dlist); } + outputs = cJSON_GetObjectItemCaseSensitive(root, "outputs"); + for (temp = outputs; temp != NULL; temp = temp->next) { + out_name = strdup(temp->string); + if (out_name == NULL) { + ret = -EPERM; + job_free(*job); + goto out_free; + } + + out_path = strdup(temp->valuestring); + if (out_path == NULL) { + ret = -EPERM; + job_free(*job); + goto out_free; + } + + ret = job_output_insert(*job, out_name, out_path); + free(out_path); + if (ret < 0) { + ret = -EPERM; + job_free(*job); + goto out_free; + } + + } + out_free: cJSON_Delete(root); -- cgit v1.2.3