From 7c95357610f722db4ee1f684086fb4478e3875c3 Mon Sep 17 00:00:00 2001 From: bigfoot547 Date: Sun, 31 Dec 2023 02:39:11 -0600 Subject: downloads versions now --- src/launcherutil.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/launcherutil.c') diff --git a/src/launcherutil.c b/src/launcherutil.c index 38dddaa..e11c280 100644 --- a/src/launcherutil.c +++ b/src/launcherutil.c @@ -1,7 +1,10 @@ +#include "digest/digest.h" #include "macros.h" #include "l2su.h" #include +#include +#include #include #include #include @@ -234,3 +237,24 @@ CURLcode l2_launcher_download(CURL *cd, const char *url, void **odata, size_t *o return CURLE_OK; } + +int l2_json_merge_objects(json_t *j1, json_t *j2) +{ + const char *key; + size_t keylen; + json_t *val; + json_t *myval; + + json_object_keylen_foreach(j2, key, keylen, val) { + myval = json_object_getn(j1, key, keylen); + if (json_is_object(myval) && json_is_object(val)) { + if (l2_json_merge_objects(myval, val) < 0) return -1; + } else if (json_is_array(myval) && json_is_array(val)) { + if (json_array_extend(myval, val) < 0) return -1; + } else if (!myval) { + if (json_object_setn_nocheck(j1, key, keylen, val) < 0) return -1; + } + } + + return 0; +} -- cgit v1.2.3-70-g09d2