From 8fd75f88d2c9fc3be927c620cf57bd47bb8984ef Mon Sep 17 00:00:00 2001 From: bigfoot547 Date: Thu, 11 Jan 2024 04:40:31 -0600 Subject: add launch command --- src/version.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/version.c') diff --git a/src/version.c b/src/version.c index 6aa32db..dd8506a 100644 --- a/src/version.c +++ b/src/version.c @@ -39,7 +39,7 @@ const char *const l2_version__messages[] = { unsigned l2_version__load_manifest(json_t **out_json); unsigned l2_version__load_all_from_json(json_t *json); -unsigned l2_version__add_remote(json_t *obj); +unsigned l2_version__add_remote(json_t *obj, const char *latestrel, const char *latestsnap); unsigned l2_version_load_remote(void) { @@ -485,15 +485,18 @@ unsigned l2_version__load_all_from_json(json_t *json) return VERSION_EFORMAT; } + l2_state.ver_latest = NULL; + l2_state.ver_snapshot = NULL; + json_array_foreach(versions, index, value) { - if ((res = l2_version__add_remote(value)) != VERSION_SUCCESS) + if ((res = l2_version__add_remote(value, latestrel, latestsnap)) != VERSION_SUCCESS) return res; } return VERSION_SUCCESS; } -unsigned l2_version__add_remote(json_t *js) +unsigned l2_version__add_remote(json_t *js, const char *latestrel, const char *latestsnap) { struct l2_version_remote *ver = NULL; json_t *val; @@ -511,6 +514,7 @@ unsigned l2_version__add_remote(json_t *js) val = json_object_get(js, "id"); if (!json_is_string(val)) goto cleanup; + const char *verid = json_string_value(val); /* I hate this code */ ver->id = strdup(json_string_value(val)); val = json_object_get(js, "type"); @@ -547,6 +551,14 @@ unsigned l2_version__add_remote(json_t *js) l2_state.ver_remote_head = l2_state.ver_remote_tail = ver; } + if (!strcmp(verid, latestrel)) { + l2_state.ver_latest = ver; + } + + if (!strcmp(verid, latestsnap)) { + l2_state.ver_snapshot = ver; + } + return VERSION_SUCCESS; cleanup: -- cgit v1.2.3-70-g09d2