You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
3.5 KiB

  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] fix boolean value with json-c 0.14
  5. Upstream removed the TRUE and FALSE defines in commit
  6. 0992aac61f8b087efd7094e9ac2b84fa9c040fcd.
  7. ---
  8. ykpers-json.c | 18 +++++++++---------
  9. 1 file changed, 9 insertions(+), 9 deletions(-)
  10. diff --git a/ykpers-json.c b/ykpers-json.c
  11. index a62e907..15ad380 100644
  12. --- a/ykpers-json.c
  13. +++ b/ykpers-json.c
  14. @@ -40,7 +40,7 @@
  15. #define yk_json_object_object_get(obj, key, value) json_object_object_get_ex(obj, key, &value)
  16. #else
  17. typedef int json_bool;
  18. -#define yk_json_object_object_get(obj, key, value) (value = json_object_object_get(obj, key)) == NULL ? (json_bool)FALSE : (json_bool)TRUE
  19. +#define yk_json_object_object_get(obj, key, value) (value = json_object_object_get(obj, key)) == NULL ? 0 : 1
  20. #endif
  21. static void set_json_value(struct map_st *p, int mode, json_object *options, YKP_CONFIG *cfg) {
  22. @@ -50,7 +50,7 @@ static void set_json_value(struct map_st *p, int mode, json_object *options, YKP
  23. if(p->mode && (mode & p->mode) == mode) {
  24. json_object *joption;
  25. json_bool ret = yk_json_object_object_get(options, p->json_text, joption);
  26. - if(ret == TRUE && json_object_get_type(joption) == json_type_boolean) {
  27. + if(ret == 1 && json_object_get_type(joption) == json_type_boolean) {
  28. int value = json_object_get_boolean(joption);
  29. if(value == 1) {
  30. p->setter(cfg, true);
  31. @@ -230,20 +230,20 @@ int _ykp_json_import_cfg(YKP_CONFIG *cfg, const char *json, size_t len) {
  32. ykp_errno = YKP_EINVAL;
  33. goto out;
  34. }
  35. - if(yk_json_object_object_get(jobj, "yubiProdConfig", yprod_json) == FALSE) {
  36. + if(yk_json_object_object_get(jobj, "yubiProdConfig", yprod_json) == 0) {
  37. ykp_errno = YKP_EINVAL;
  38. goto out;
  39. }
  40. - if(yk_json_object_object_get(yprod_json, "mode", jmode) == FALSE) {
  41. + if(yk_json_object_object_get(yprod_json, "mode", jmode) == 0) {
  42. ykp_errno = YKP_EINVAL;
  43. goto out;
  44. }
  45. - if(yk_json_object_object_get(yprod_json, "options", options) == FALSE) {
  46. + if(yk_json_object_object_get(yprod_json, "options", options) == 0) {
  47. ykp_errno = YKP_EINVAL;
  48. goto out;
  49. }
  50. - if(yk_json_object_object_get(yprod_json, "targetConfig", jtarget) == TRUE) {
  51. + if(yk_json_object_object_get(yprod_json, "targetConfig", jtarget) == 1) {
  52. int target_config = json_object_get_int(jtarget);
  53. int command;
  54. if(target_config == 1) {
  55. @@ -275,13 +275,13 @@ int _ykp_json_import_cfg(YKP_CONFIG *cfg, const char *json, size_t len) {
  56. if(mode == MODE_OATH_HOTP) {
  57. json_object *jdigits, *jrandom;
  58. ykp_set_tktflag_OATH_HOTP(cfg, true);
  59. - if(yk_json_object_object_get(options, "oathDigits", jdigits) == TRUE) {
  60. + if(yk_json_object_object_get(options, "oathDigits", jdigits) == 1) {
  61. int digits = json_object_get_int(jdigits);
  62. if(digits == 8) {
  63. ykp_set_cfgflag_OATH_HOTP8(cfg, true);
  64. }
  65. }
  66. - if(yk_json_object_object_get(options, "randomSeed", jrandom) == TRUE) {
  67. + if(yk_json_object_object_get(options, "randomSeed", jrandom) == 1) {
  68. int random = json_object_get_boolean(jrandom);
  69. int seed = 0;
  70. if(random == 1) {
  71. @@ -290,7 +290,7 @@ int _ykp_json_import_cfg(YKP_CONFIG *cfg, const char *json, size_t len) {
  72. goto out;
  73. } else {
  74. json_object *jseed;
  75. - if(yk_json_object_object_get(options, "fixedSeedvalue", jseed) == TRUE) {
  76. + if(yk_json_object_object_get(options, "fixedSeedvalue", jseed) == 1) {
  77. seed = json_object_get_int(jseed);
  78. }
  79. }