aboutsummaryrefslogtreecommitdiffstats
path: root/src/launcherutil.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/launcherutil.c')
-rw-r--r--src/launcherutil.c24
1 files changed, 24 insertions, 0 deletions
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 <curl/easy.h>
+#include <jansson.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
@@ -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;
+}