diff options
-rw-r--r-- | src/common.c | 22 | ||||
-rw-r--r-- | src/common.h | 3 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/common.c b/src/common.c index 79dc123..a00cc05 100644 --- a/src/common.c +++ b/src/common.c @@ -547,3 +547,25 @@ void get_user_input(char *buf, int maxlen, int secure) fputs("\n", stdout); buf[len] = 0; } + +uint64_t _plist_dict_get_uint(plist_t dict, const char *key) +{ + uint64_t uintval = 0; + plist_t node = plist_dict_get_item(dict, key); + if (!node) { + return (uint64_t)-1LL; + } + plist_get_uint_val(node, &uintval); + return uintval; +} + +uint8_t _plist_dict_get_bool(plist_t dict, const char *key) +{ + uint8_t bval = 0; + plist_t node = plist_dict_get_item(dict, key); + if (!node) { + return 0; + } + plist_get_bool_val(node, &bval); + return bval; +} diff --git a/src/common.h b/src/common.h index 6c568f8..2c8d07f 100644 --- a/src/common.h +++ b/src/common.h @@ -150,6 +150,9 @@ char* realpath(const char *filename, char *resolved_name); void get_user_input(char *buf, int maxlen, int secure); +uint8_t _plist_dict_get_bool(plist_t dict, const char *key); +uint64_t _plist_dict_get_uint(plist_t dict, const char *key); + #ifdef __cplusplus } #endif |