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.

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