aboutsummaryrefslogtreecommitdiffstats
path: root/src/version.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/version.c')
-rw-r--r--src/version.c18
1 files changed, 15 insertions, 3 deletions
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: