1 From 0aa2e2cae2e1777863993a10c809bb50f4cde7f8 Mon Sep 17 00:00:00 2001
2 From: Christian Hesse <mail@eworm.de>
3 Date: Sat, 25 Apr 2020 20:55:28 +0200
4 Subject: [PATCH 1/1] fix boolean value with json-c 0.14
6 Upstream removed the TRUE and FALSE defines in commit
7 0992aac61f8b087efd7094e9ac2b84fa9c040fcd.
9 ykpers-json.c | 18 +++++++++---------
10 1 file changed, 9 insertions(+), 9 deletions(-)
12 diff --git a/ykpers-json.c b/ykpers-json.c
13 index a62e907..15ad380 100644
17 #define yk_json_object_object_get(obj, key, value) json_object_object_get_ex(obj, key, &value)
19 typedef int json_bool;
20 -#define yk_json_object_object_get(obj, key, value) (value = json_object_object_get(obj, key)) == NULL ? (json_bool)FALSE : (json_bool)TRUE
21 +#define yk_json_object_object_get(obj, key, value) (value = json_object_object_get(obj, key)) == NULL ? 0 : 1
24 static void set_json_value(struct map_st *p, int mode, json_object *options, YKP_CONFIG *cfg) {
25 @@ -50,7 +50,7 @@ static void set_json_value(struct map_st *p, int mode, json_object *options, YKP
26 if(p->mode && (mode & p->mode) == mode) {
28 json_bool ret = yk_json_object_object_get(options, p->json_text, joption);
29 - if(ret == TRUE && json_object_get_type(joption) == json_type_boolean) {
30 + if(ret == 1 && json_object_get_type(joption) == json_type_boolean) {
31 int value = json_object_get_boolean(joption);
34 @@ -230,20 +230,20 @@ int _ykp_json_import_cfg(YKP_CONFIG *cfg, const char *json, size_t len) {
35 ykp_errno = YKP_EINVAL;
38 - if(yk_json_object_object_get(jobj, "yubiProdConfig", yprod_json) == FALSE) {
39 + if(yk_json_object_object_get(jobj, "yubiProdConfig", yprod_json) == 0) {
40 ykp_errno = YKP_EINVAL;
43 - if(yk_json_object_object_get(yprod_json, "mode", jmode) == FALSE) {
44 + if(yk_json_object_object_get(yprod_json, "mode", jmode) == 0) {
45 ykp_errno = YKP_EINVAL;
48 - if(yk_json_object_object_get(yprod_json, "options", options) == FALSE) {
49 + if(yk_json_object_object_get(yprod_json, "options", options) == 0) {
50 ykp_errno = YKP_EINVAL;
54 - if(yk_json_object_object_get(yprod_json, "targetConfig", jtarget) == TRUE) {
55 + if(yk_json_object_object_get(yprod_json, "targetConfig", jtarget) == 1) {
56 int target_config = json_object_get_int(jtarget);
58 if(target_config == 1) {
59 @@ -275,13 +275,13 @@ int _ykp_json_import_cfg(YKP_CONFIG *cfg, const char *json, size_t len) {
60 if(mode == MODE_OATH_HOTP) {
61 json_object *jdigits, *jrandom;
62 ykp_set_tktflag_OATH_HOTP(cfg, true);
63 - if(yk_json_object_object_get(options, "oathDigits", jdigits) == TRUE) {
64 + if(yk_json_object_object_get(options, "oathDigits", jdigits) == 1) {
65 int digits = json_object_get_int(jdigits);
67 ykp_set_cfgflag_OATH_HOTP8(cfg, true);
70 - if(yk_json_object_object_get(options, "randomSeed", jrandom) == TRUE) {
71 + if(yk_json_object_object_get(options, "randomSeed", jrandom) == 1) {
72 int random = json_object_get_boolean(jrandom);
75 @@ -290,7 +290,7 @@ int _ykp_json_import_cfg(YKP_CONFIG *cfg, const char *json, size_t len) {
79 - if(yk_json_object_object_get(options, "fixedSeedvalue", jseed) == TRUE) {
80 + if(yk_json_object_object_get(options, "fixedSeedvalue", jseed) == 1) {
81 seed = json_object_get_int(jseed);