diff options
author | sinanmohd <sinan@sinanmohd.com> | 2024-06-11 13:42:20 +0530 |
---|---|---|
committer | sinanmohd <sinan@sinanmohd.com> | 2024-06-11 13:42:45 +0530 |
commit | 36b229a8065d717ae165a610042bb961a6fa4759 (patch) | |
tree | 983e3a370c2dc6d5d7df1a0d94578c5f6ad5c052 /src | |
parent | d69cf8e89b3d7e182d2ef55a8f9b5e90b38fac5b (diff) |
src/jobs/job_read: read outputs
Diffstat (limited to 'src')
-rw-r--r-- | src/jobs.c | 37 |
1 files changed, 35 insertions, 2 deletions
@@ -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); |