summaryrefslogtreecommitdiffstats
path: root/src/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common.c')
-rw-r--r--src/common.c139
1 files changed, 0 insertions, 139 deletions
diff --git a/src/common.c b/src/common.c
index 499509d..e5ee07b 100644
--- a/src/common.c
+++ b/src/common.c
@@ -558,145 +558,6 @@ void get_user_input(char *buf, int maxlen, int secure)
buf[len] = 0;
}
-uint64_t _plist_dict_get_uint(plist_t dict, const char *key)
-{
- uint64_t uintval = 0;
- char *strval = NULL;
- uint64_t strsz = 0;
- plist_t node = plist_dict_get_item(dict, key);
- if (!node) {
- return uintval;
- }
- switch (plist_get_node_type(node)) {
- case PLIST_UINT:
- plist_get_uint_val(node, &uintval);
- break;
- case PLIST_STRING:
- plist_get_string_val(node, &strval);
- if (strval) {
- uintval = strtoull(strval, NULL, 0);
- free(strval);
- }
- break;
- case PLIST_DATA:
- plist_get_data_val(node, &strval, &strsz);
- if (strval) {
- if (strsz == 8) {
- uintval = le64toh(*(uint64_t*)strval);
- } else if (strsz == 4) {
- uintval = le32toh(*(uint32_t*)strval);
- } else if (strsz == 2) {
- uintval = le16toh(*(uint16_t*)strval);
- } else if (strsz == 1) {
- uintval = strval[0];
- } else {
- error("%s: ERROR: invalid size %" PRIu64 " for data to integer conversion\n", __func__, strsz);
- }
- free(strval);
- }
- break;
- default:
- break;
- }
- return uintval;
-}
-
-uint8_t _plist_dict_get_bool(plist_t dict, const char *key)
-{
- uint8_t bval = 0;
- uint64_t uintval = 0;
- char *strval = NULL;
- uint64_t strsz = 0;
- plist_t node = plist_dict_get_item(dict, key);
- if (!node) {
- return 0;
- }
- switch (plist_get_node_type(node)) {
- case PLIST_BOOLEAN:
- plist_get_bool_val(node, &bval);
- break;
- case PLIST_UINT:
- plist_get_uint_val(node, &uintval);
- bval = (uint8_t)uintval;
- break;
- case PLIST_STRING:
- plist_get_string_val(node, &strval);
- if (strval) {
- if (strcmp(strval, "true")) {
- bval = 1;
- } else if (strcmp(strval, "false")) {
- bval = 0;
- }
- free(strval);
- }
- break;
- case PLIST_DATA:
- plist_get_data_val(node, &strval, &strsz);
- if (strval) {
- if (strsz == 1) {
- bval = strval[0];
- } else {
- error("%s: ERROR: invalid size %" PRIu64 " for data to boolean conversion\n", __func__, strsz);
- }
- free(strval);
- }
- break;
- default:
- break;
- }
- return bval;
-}
-
-int _plist_dict_copy_uint(plist_t target_dict, plist_t source_dict, const char *key, const char *alt_source_key)
-{
- if (plist_dict_get_item(source_dict, (alt_source_key) ? alt_source_key : key) == NULL) {
- return -1;
- }
- uint64_t u64val = _plist_dict_get_uint(source_dict, (alt_source_key) ? alt_source_key : key);
- plist_dict_set_item(target_dict, key, plist_new_uint(u64val));
- return 0;
-}
-
-int _plist_dict_copy_bool(plist_t target_dict, plist_t source_dict, const char *key, const char *alt_source_key)
-{
- if (plist_dict_get_item(source_dict, (alt_source_key) ? alt_source_key : key) == NULL) {
- return -1;
- }
- uint64_t bval = _plist_dict_get_bool(source_dict, (alt_source_key) ? alt_source_key : key);
- plist_dict_set_item(target_dict, key, plist_new_bool(bval));
- return 0;
-}
-
-int _plist_dict_copy_data(plist_t target_dict, plist_t source_dict, const char *key, const char *alt_source_key)
-{
- plist_t node = plist_dict_get_item(source_dict, (alt_source_key) ? alt_source_key : key);
- if (!PLIST_IS_DATA(node)) {
- return -1;
- }
- plist_dict_set_item(target_dict, key, plist_copy(node));
- return 0;
-}
-
-int _plist_dict_copy_string(plist_t target_dict, plist_t source_dict, const char *key, const char *alt_source_key)
-{
- plist_t node = plist_dict_get_item(source_dict, (alt_source_key) ? alt_source_key : key);
- if (!PLIST_IS_STRING(node)) {
- return -1;
- }
- plist_dict_set_item(target_dict, key, plist_copy(node));
- return 0;
-}
-
-int _plist_dict_copy_item(plist_t target_dict, plist_t source_dict, const char *key, const char *alt_source_key)
-{
- plist_t node = plist_dict_get_item(source_dict, (alt_source_key) ? alt_source_key : key);
- if (!node) {
- return -1;
- }
- plist_dict_set_item(target_dict, key, plist_copy(node));
- return 0;
-}
-
const char* path_get_basename(const char* path)
{
#ifdef WIN32