summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2023-01-16 04:25:52 +0100
committerGravatar Nikias Bassen2023-01-16 04:25:52 +0100
commitd886885b0ec2506fa2caf0986a3d0e496fea91c2 (patch)
tree58bc4bcd1963ea885abd60a65bf87a2685526714 /src
parent47a7fbe438ee7350a2b151e007f07043ef596775 (diff)
downloadlibplist-d886885b0ec2506fa2caf0986a3d0e496fea91c2.tar.gz
libplist-d886885b0ec2506fa2caf0986a3d0e496fea91c2.tar.bz2
Rename PLIST_UINT to PLIST_INT and add plist_new_int() and plist_get_int_val()
This properly supports getting and setting signed or unsigned integer values. Also, a new helper function plist_int_val_is_negative() was added to determine if a given #PLIST_INT node has a negative value or not. The old type PLIST_UINT is defined as a macro with the value of PLIST_INT for backwards compatibility. This commit also adds int vs. uint support to the C++ interface, and the python bindings in a hopefully useful way.
Diffstat (limited to 'src')
-rw-r--r--src/Integer.cpp35
-rw-r--r--src/Key.cpp2
-rw-r--r--src/Node.cpp4
-rw-r--r--src/Real.cpp2
-rw-r--r--src/String.cpp2
-rw-r--r--src/bplist.c24
-rw-r--r--src/jplist.c12
-rw-r--r--src/oplist.c4
-rw-r--r--src/plist.c68
-rw-r--r--src/xplist.c6
10 files changed, 121 insertions, 38 deletions
diff --git a/src/Integer.cpp b/src/Integer.cpp
index a40d026..7fa0f93 100644
--- a/src/Integer.cpp
+++ b/src/Integer.cpp
@@ -24,7 +24,7 @@
24namespace PList 24namespace PList
25{ 25{
26 26
27Integer::Integer(Node* parent) : Node(PLIST_UINT, parent) 27Integer::Integer(Node* parent) : Node(PLIST_INT, parent)
28{ 28{
29} 29}
30 30
@@ -32,7 +32,7 @@ Integer::Integer(plist_t node, Node* parent) : Node(node, parent)
32{ 32{
33} 33}
34 34
35Integer::Integer(const PList::Integer& i) : Node(PLIST_UINT) 35Integer::Integer(const PList::Integer& i) : Node(PLIST_INT)
36{ 36{
37 plist_set_uint_val(_node, i.GetValue()); 37 plist_set_uint_val(_node, i.GetValue());
38} 38}
@@ -44,11 +44,16 @@ Integer& Integer::operator=(const PList::Integer& i)
44 return *this; 44 return *this;
45} 45}
46 46
47Integer::Integer(uint64_t i) : Node(PLIST_UINT) 47Integer::Integer(uint64_t i) : Node(PLIST_INT)
48{ 48{
49 plist_set_uint_val(_node, i); 49 plist_set_uint_val(_node, i);
50} 50}
51 51
52Integer::Integer(int64_t i) : Node(PLIST_INT)
53{
54 plist_set_int_val(_node, i);
55}
56
52Integer::~Integer() 57Integer::~Integer()
53{ 58{
54} 59}
@@ -58,16 +63,38 @@ Node* Integer::Clone() const
58 return new Integer(*this); 63 return new Integer(*this);
59} 64}
60 65
66void Integer::SetValue(int64_t i)
67{
68 plist_set_int_val(_node, i);
69}
70
61void Integer::SetValue(uint64_t i) 71void Integer::SetValue(uint64_t i)
62{ 72{
63 plist_set_uint_val(_node, i); 73 plist_set_uint_val(_node, i);
64} 74}
65 75
66uint64_t Integer::GetValue() const 76void Integer::SetUnsignedValue(uint64_t i)
77{
78 plist_set_uint_val(_node, i);
79}
80
81int64_t Integer::GetValue() const
82{
83 int64_t i = 0;
84 plist_get_int_val(_node, &i);
85 return i;
86}
87
88uint64_t Integer::GetUnsignedValue() const
67{ 89{
68 uint64_t i = 0; 90 uint64_t i = 0;
69 plist_get_uint_val(_node, &i); 91 plist_get_uint_val(_node, &i);
70 return i; 92 return i;
71} 93}
72 94
95bool Integer::isNegative() const
96{
97 return plist_int_val_is_negative(_node);
98}
99
73} // namespace PList 100} // namespace PList
diff --git a/src/Key.cpp b/src/Key.cpp
index 5d7d372..5f8d205 100644
--- a/src/Key.cpp
+++ b/src/Key.cpp
@@ -32,7 +32,7 @@ Key::Key(plist_t node, Node* parent) : Node(node, parent)
32{ 32{
33} 33}
34 34
35Key::Key(const PList::Key& k) : Node(PLIST_UINT) 35Key::Key(const PList::Key& k) : Node(PLIST_INT)
36{ 36{
37 plist_set_key_val(_node, k.GetValue().c_str()); 37 plist_set_key_val(_node, k.GetValue().c_str());
38} 38}
diff --git a/src/Node.cpp b/src/Node.cpp
index fb79911..08a91b0 100644
--- a/src/Node.cpp
+++ b/src/Node.cpp
@@ -52,7 +52,7 @@ Node::Node(plist_type type, Node* parent) : _parent(parent)
52 case PLIST_BOOLEAN: 52 case PLIST_BOOLEAN:
53 _node = plist_new_bool(0); 53 _node = plist_new_bool(0);
54 break; 54 break;
55 case PLIST_UINT: 55 case PLIST_INT:
56 _node = plist_new_uint(0); 56 _node = plist_new_uint(0);
57 break; 57 break;
58 case PLIST_REAL: 58 case PLIST_REAL:
@@ -134,7 +134,7 @@ Node* Node::FromPlist(plist_t node, Node* parent)
134 case PLIST_BOOLEAN: 134 case PLIST_BOOLEAN:
135 ret = new Boolean(node, parent); 135 ret = new Boolean(node, parent);
136 break; 136 break;
137 case PLIST_UINT: 137 case PLIST_INT:
138 ret = new Integer(node, parent); 138 ret = new Integer(node, parent);
139 break; 139 break;
140 case PLIST_REAL: 140 case PLIST_REAL:
diff --git a/src/Real.cpp b/src/Real.cpp
index 6bdb920..02d1d9b 100644
--- a/src/Real.cpp
+++ b/src/Real.cpp
@@ -32,7 +32,7 @@ Real::Real(plist_t node, Node* parent) : Node(node, parent)
32{ 32{
33} 33}
34 34
35Real::Real(const PList::Real& d) : Node(PLIST_UINT) 35Real::Real(const PList::Real& d) : Node(PLIST_INT)
36{ 36{
37 plist_set_real_val(_node, d.GetValue()); 37 plist_set_real_val(_node, d.GetValue());
38} 38}
diff --git a/src/String.cpp b/src/String.cpp
index 06b61ba..aee2358 100644
--- a/src/String.cpp
+++ b/src/String.cpp
@@ -32,7 +32,7 @@ String::String(plist_t node, Node* parent) : Node(node, parent)
32{ 32{
33} 33}
34 34
35String::String(const PList::String& s) : Node(PLIST_UINT) 35String::String(const PList::String& s) : Node(PLIST_INT)
36{ 36{
37 plist_set_string_val(_node, s.GetValue().c_str()); 37 plist_set_string_val(_node, s.GetValue().c_str());
38} 38}
diff --git a/src/bplist.c b/src/bplist.c
index 851ecd6..8927de6 100644
--- a/src/bplist.c
+++ b/src/bplist.c
@@ -62,7 +62,7 @@ enum
62 BPLIST_FALSE = 0x08, 62 BPLIST_FALSE = 0x08,
63 BPLIST_TRUE = 0x09, 63 BPLIST_TRUE = 0x09,
64 BPLIST_FILL = 0x0F, /* will be used for length grabbing */ 64 BPLIST_FILL = 0x0F, /* will be used for length grabbing */
65 BPLIST_UINT = 0x10, 65 BPLIST_INT = 0x10,
66 BPLIST_REAL = 0x20, 66 BPLIST_REAL = 0x20,
67 BPLIST_DATE = 0x30, 67 BPLIST_DATE = 0x30,
68 BPLIST_DATA = 0x40, 68 BPLIST_DATA = 0x40,
@@ -229,7 +229,7 @@ void plist_bin_deinit(void)
229 229
230static plist_t parse_bin_node_at_index(struct bplist_data *bplist, uint32_t node_index); 230static plist_t parse_bin_node_at_index(struct bplist_data *bplist, uint32_t node_index);
231 231
232static plist_t parse_uint_node(const char **bnode, uint8_t size) 232static plist_t parse_int_node(const char **bnode, uint8_t size)
233{ 233{
234 plist_data_t data = plist_new_plist_data(); 234 plist_data_t data = plist_new_plist_data();
235 235
@@ -254,7 +254,7 @@ static plist_t parse_uint_node(const char **bnode, uint8_t size)
254 data->intval = UINT_TO_HOST(*bnode, size); 254 data->intval = UINT_TO_HOST(*bnode, size);
255 255
256 (*bnode) += size; 256 (*bnode) += size;
257 data->type = PLIST_UINT; 257 data->type = PLIST_INT;
258 258
259 return node_create(NULL, data); 259 return node_create(NULL, data);
260} 260}
@@ -583,8 +583,8 @@ static plist_t parse_bin_node(struct bplist_data *bplist, const char** object)
583 case BPLIST_DICT: 583 case BPLIST_DICT:
584 { 584 {
585 uint16_t next_size = **object & BPLIST_FILL; 585 uint16_t next_size = **object & BPLIST_FILL;
586 if ((**object & BPLIST_MASK) != BPLIST_UINT) { 586 if ((**object & BPLIST_MASK) != BPLIST_INT) {
587 PLIST_BIN_ERR("%s: invalid size node type for node type 0x%02x: found 0x%02x, expected 0x%02x\n", __func__, type, **object & BPLIST_MASK, BPLIST_UINT); 587 PLIST_BIN_ERR("%s: invalid size node type for node type 0x%02x: found 0x%02x, expected 0x%02x\n", __func__, type, **object & BPLIST_MASK, BPLIST_INT);
588 return NULL; 588 return NULL;
589 } 589 }
590 (*object)++; 590 (*object)++;
@@ -641,12 +641,12 @@ static plist_t parse_bin_node(struct bplist_data *bplist, const char** object)
641 return NULL; 641 return NULL;
642 } 642 }
643 643
644 case BPLIST_UINT: 644 case BPLIST_INT:
645 if (pobject + (uint64_t)(1 << size) > poffset_table) { 645 if (pobject + (uint64_t)(1 << size) > poffset_table) {
646 PLIST_BIN_ERR("%s: BPLIST_UINT data bytes point outside of valid range\n", __func__); 646 PLIST_BIN_ERR("%s: BPLIST_INT data bytes point outside of valid range\n", __func__);
647 return NULL; 647 return NULL;
648 } 648 }
649 return parse_uint_node(object, size); 649 return parse_int_node(object, size);
650 650
651 case BPLIST_REAL: 651 case BPLIST_REAL:
652 if (pobject + (uint64_t)(1 << size) > poffset_table) { 652 if (pobject + (uint64_t)(1 << size) > poffset_table) {
@@ -896,7 +896,7 @@ static unsigned int plist_data_hash(const void* key)
896 switch (data->type) 896 switch (data->type)
897 { 897 {
898 case PLIST_BOOLEAN: 898 case PLIST_BOOLEAN:
899 case PLIST_UINT: 899 case PLIST_INT:
900 case PLIST_REAL: 900 case PLIST_REAL:
901 case PLIST_DATE: 901 case PLIST_DATE:
902 case PLIST_UID: 902 case PLIST_UID:
@@ -973,7 +973,7 @@ static void write_int(bytearray_t * bplist, uint64_t val)
973 //do not write 3bytes int node 973 //do not write 3bytes int node
974 if (size == 3) 974 if (size == 3)
975 size++; 975 size++;
976 sz = BPLIST_UINT | Log2(size); 976 sz = BPLIST_INT | Log2(size);
977 977
978 val = be64toh(val); 978 val = be64toh(val);
979 byte_array_append(bplist, &sz, 1); 979 byte_array_append(bplist, &sz, 1);
@@ -982,7 +982,7 @@ static void write_int(bytearray_t * bplist, uint64_t val)
982 982
983static void write_uint(bytearray_t * bplist, uint64_t val) 983static void write_uint(bytearray_t * bplist, uint64_t val)
984{ 984{
985 uint8_t sz = BPLIST_UINT | 4; 985 uint8_t sz = BPLIST_INT | 4;
986 uint64_t zero = 0; 986 uint64_t zero = 0;
987 987
988 val = be64toh(val); 988 val = be64toh(val);
@@ -1346,7 +1346,7 @@ PLIST_API plist_err_t plist_to_bin(plist_t plist, char **plist_bin, uint32_t * l
1346 byte_array_append(bplist_buff, &b, 1); 1346 byte_array_append(bplist_buff, &b, 1);
1347 break; 1347 break;
1348 } 1348 }
1349 case PLIST_UINT: 1349 case PLIST_INT:
1350 if (data->length == 16) { 1350 if (data->length == 16) {
1351 write_uint(bplist_buff, data->intval); 1351 write_uint(bplist_buff, data->intval);
1352 } else { 1352 } else {
diff --git a/src/jplist.c b/src/jplist.c
index f4adf2f..7817b1c 100644
--- a/src/jplist.c
+++ b/src/jplist.c
@@ -131,7 +131,7 @@ static int node_to_json(node_t* node, bytearray_t **outbuf, uint32_t depth, int
131 str_buf_append(*outbuf, "null", 4); 131 str_buf_append(*outbuf, "null", 4);
132 break; 132 break;
133 133
134 case PLIST_UINT: 134 case PLIST_INT:
135 val = (char*)malloc(64); 135 val = (char*)malloc(64);
136 if (node_data->length == 16) { 136 if (node_data->length == 16) {
137 val_len = snprintf(val, 64, "%"PRIu64, node_data->intval); 137 val_len = snprintf(val, 64, "%"PRIu64, node_data->intval);
@@ -349,7 +349,7 @@ static int node_estimate_size(node_t *node, uint64_t *size, uint32_t depth, int
349 *size += data->length; 349 *size += data->length;
350 *size += 2; 350 *size += 2;
351 break; 351 break;
352 case PLIST_UINT: 352 case PLIST_INT:
353 if (data->length == 16) { 353 if (data->length == 16) {
354 *size += num_digits_u(data->intval); 354 *size += num_digits_u(data->intval);
355 } else { 355 } else {
@@ -501,10 +501,15 @@ static plist_t parse_primitive(const char* js, jsmntok_info_t* ti, int* index)
501 val = plist_new_node(data); 501 val = plist_new_node(data);
502 } else if (isdigit(str_val[0]) || (str_val[0] == '-' && str_val+1 < str_end && isdigit(str_val[1]))) { 502 } else if (isdigit(str_val[0]) || (str_val[0] == '-' && str_val+1 < str_end && isdigit(str_val[1]))) {
503 char* endp = (char*)str_val; 503 char* endp = (char*)str_val;
504 int is_neg = (str_val[0] == '-');
504 int64_t intpart = parse_decimal(str_val, str_end, &endp); 505 int64_t intpart = parse_decimal(str_val, str_end, &endp);
505 if (endp >= str_end) { 506 if (endp >= str_end) {
506 /* integer */ 507 /* integer */
507 val = plist_new_uint((uint64_t)intpart); 508 if (is_neg || intpart <= INT64_MAX) {
509 val = plist_new_int(intpart);
510 } else {
511 val = plist_new_uint((uint64_t)intpart);
512 }
508 } else if ((*endp == '.' && endp+1 < str_end && isdigit(*(endp+1))) || ((*endp == 'e' || *endp == 'E') && endp+1 < str_end && (isdigit(*(endp+1)) || ((*(endp+1) == '-') && endp+2 < str_end && isdigit(*(endp+2)))))) { 513 } else if ((*endp == '.' && endp+1 < str_end && isdigit(*(endp+1))) || ((*endp == 'e' || *endp == 'E') && endp+1 < str_end && (isdigit(*(endp+1)) || ((*(endp+1) == '-') && endp+2 < str_end && isdigit(*(endp+2)))))) {
509 /* floating point */ 514 /* floating point */
510 double dval = (double)intpart; 515 double dval = (double)intpart;
@@ -513,7 +518,6 @@ static plist_t parse_primitive(const char* js, jsmntok_info_t* ti, int* index)
513 do { 518 do {
514 if (*endp == '.') { 519 if (*endp == '.') {
515 fendp++; 520 fendp++;
516 int is_neg = (str_val[0] == '-');
517 double frac = 0; 521 double frac = 0;
518 double p = 0.1; 522 double p = 0.1;
519 while (fendp < str_end && isdigit(*fendp)) { 523 while (fendp < str_end && isdigit(*fendp)) {
diff --git a/src/oplist.c b/src/oplist.c
index 122440f..8936cce 100644
--- a/src/oplist.c
+++ b/src/oplist.c
@@ -146,7 +146,7 @@ static int node_to_openstep(node_t* node, bytearray_t **outbuf, uint32_t depth,
146 146
147 switch (node_data->type) 147 switch (node_data->type)
148 { 148 {
149 case PLIST_UINT: 149 case PLIST_INT:
150 val = (char*)malloc(64); 150 val = (char*)malloc(64);
151 if (node_data->length == 16) { 151 if (node_data->length == 16) {
152 val_len = snprintf(val, 64, "%"PRIu64, node_data->intval); 152 val_len = snprintf(val, 64, "%"PRIu64, node_data->intval);
@@ -393,7 +393,7 @@ static int node_estimate_size(node_t *node, uint64_t *size, uint32_t depth, int
393 *size += data->length; 393 *size += data->length;
394 *size += 2; 394 *size += 2;
395 break; 395 break;
396 case PLIST_UINT: 396 case PLIST_INT:
397 if (data->length == 16) { 397 if (data->length == 16) {
398 *size += num_digits_u(data->intval); 398 *size += num_digits_u(data->intval);
399 } else { 399 } else {
diff --git a/src/plist.c b/src/plist.c
index e696f70..5d06311 100644
--- a/src/plist.c
+++ b/src/plist.c
@@ -2,7 +2,7 @@
2 * plist.c 2 * plist.c
3 * Builds plist XML structures 3 * Builds plist XML structures
4 * 4 *
5 * Copyright (c) 2009-2019 Nikias Bassen, All Rights Reserved. 5 * Copyright (c) 2009-2023 Nikias Bassen, All Rights Reserved.
6 * Copyright (c) 2010-2015 Martin Szulecki, All Rights Reserved. 6 * Copyright (c) 2010-2015 Martin Szulecki, All Rights Reserved.
7 * Copyright (c) 2008 Zach C., All Rights Reserved. 7 * Copyright (c) 2008 Zach C., All Rights Reserved.
8 * 8 *
@@ -390,7 +390,16 @@ PLIST_API plist_t plist_new_bool(uint8_t val)
390PLIST_API plist_t plist_new_uint(uint64_t val) 390PLIST_API plist_t plist_new_uint(uint64_t val)
391{ 391{
392 plist_data_t data = plist_new_plist_data(); 392 plist_data_t data = plist_new_plist_data();
393 data->type = PLIST_UINT; 393 data->type = PLIST_INT;
394 data->intval = val;
395 data->length = (val > INT_MAX) ? sizeof(uint64_t)*2 : sizeof(uint64_t);
396 return plist_new_node(data);
397}
398
399PLIST_API plist_t plist_new_int(int64_t val)
400{
401 plist_data_t data = plist_new_plist_data();
402 data->type = PLIST_INT;
394 data->intval = val; 403 data->intval = val;
395 data->length = sizeof(uint64_t); 404 data->length = sizeof(uint64_t);
396 return plist_new_node(data); 405 return plist_new_node(data);
@@ -926,7 +935,7 @@ static void plist_get_type_and_value(plist_t node, plist_type * type, void *valu
926 case PLIST_BOOLEAN: 935 case PLIST_BOOLEAN:
927 *((char *) value) = data->boolval; 936 *((char *) value) = data->boolval;
928 break; 937 break;
929 case PLIST_UINT: 938 case PLIST_INT:
930 case PLIST_UID: 939 case PLIST_UID:
931 *((uint64_t *) value) = data->intval; 940 *((uint64_t *) value) = data->intval;
932 break; 941 break;
@@ -1024,12 +1033,17 @@ PLIST_API void plist_get_uint_val(plist_t node, uint64_t * val)
1024 return; 1033 return;
1025 plist_type type = plist_get_node_type(node); 1034 plist_type type = plist_get_node_type(node);
1026 uint64_t length = 0; 1035 uint64_t length = 0;
1027 if (PLIST_UINT != type) 1036 if (PLIST_INT != type)
1028 return; 1037 return;
1029 plist_get_type_and_value(node, &type, (void *) val, &length); 1038 plist_get_type_and_value(node, &type, (void *) val, &length);
1030 assert(length == sizeof(uint64_t) || length == 16); 1039 assert(length == sizeof(uint64_t) || length == 16);
1031} 1040}
1032 1041
1042PLIST_API void plist_get_int_val(plist_t node, int64_t * val)
1043{
1044 plist_get_uint_val(node, (uint64_t*)val);
1045}
1046
1033PLIST_API void plist_get_uid_val(plist_t node, uint64_t * val) 1047PLIST_API void plist_get_uid_val(plist_t node, uint64_t * val)
1034{ 1048{
1035 if (!node || !val) 1049 if (!node || !val)
@@ -1116,7 +1130,7 @@ int plist_data_compare(const void *a, const void *b)
1116 switch (val_a->type) 1130 switch (val_a->type)
1117 { 1131 {
1118 case PLIST_BOOLEAN: 1132 case PLIST_BOOLEAN:
1119 case PLIST_UINT: 1133 case PLIST_INT:
1120 case PLIST_REAL: 1134 case PLIST_REAL:
1121 case PLIST_DATE: 1135 case PLIST_DATE:
1122 case PLIST_UID: 1136 case PLIST_UID:
@@ -1180,7 +1194,7 @@ static void plist_set_element_val(plist_t node, plist_type type, const void *val
1180 case PLIST_BOOLEAN: 1194 case PLIST_BOOLEAN:
1181 data->boolval = *((char *) value); 1195 data->boolval = *((char *) value);
1182 break; 1196 break;
1183 case PLIST_UINT: 1197 case PLIST_INT:
1184 case PLIST_UID: 1198 case PLIST_UID:
1185 data->intval = *((uint64_t *) value); 1199 data->intval = *((uint64_t *) value);
1186 break; 1200 break;
@@ -1225,7 +1239,12 @@ PLIST_API void plist_set_bool_val(plist_t node, uint8_t val)
1225 1239
1226PLIST_API void plist_set_uint_val(plist_t node, uint64_t val) 1240PLIST_API void plist_set_uint_val(plist_t node, uint64_t val)
1227{ 1241{
1228 plist_set_element_val(node, PLIST_UINT, &val, sizeof(uint64_t)); 1242 plist_set_element_val(node, PLIST_INT, &val, (val > INT64_MAX) ? sizeof(uint64_t)*2 : sizeof(uint64_t));
1243}
1244
1245PLIST_API void plist_set_int_val(plist_t node, int64_t val)
1246{
1247 plist_set_element_val(node, PLIST_INT, &val, sizeof(uint64_t));
1229} 1248}
1230 1249
1231PLIST_API void plist_set_uid_val(plist_t node, uint64_t val) 1250PLIST_API void plist_set_uid_val(plist_t node, uint64_t val)
@@ -1259,9 +1278,42 @@ PLIST_API int plist_bool_val_is_true(plist_t boolnode)
1259 return (bv == 1); 1278 return (bv == 1);
1260} 1279}
1261 1280
1281PLIST_API int plist_int_val_is_negative(plist_t intnode)
1282{
1283 if (!PLIST_IS_INT(intnode)) {
1284 return 0;
1285 }
1286 plist_data_t data = plist_get_data(intnode);
1287 if (data->length == 16) {
1288 return 0;
1289 }
1290 if ((int64_t)data->intval < 0) {
1291 return 1;
1292 }
1293 return 0;
1294}
1295
1296PLIST_API int plist_int_val_compare(plist_t uintnode, int64_t cmpval)
1297{
1298 if (!PLIST_IS_INT(uintnode)) {
1299 return -1;
1300 }
1301 int64_t uintval = 0;
1302 plist_get_int_val(uintnode, &uintval);
1303 if (uintval == cmpval) {
1304 return 0;
1305 }
1306
1307 if (uintval < cmpval) {
1308 return -1;
1309 }
1310
1311 return 1;
1312}
1313
1262PLIST_API int plist_uint_val_compare(plist_t uintnode, uint64_t cmpval) 1314PLIST_API int plist_uint_val_compare(plist_t uintnode, uint64_t cmpval)
1263{ 1315{
1264 if (!PLIST_IS_UINT(uintnode)) { 1316 if (!PLIST_IS_INT(uintnode)) {
1265 return -1; 1317 return -1;
1266 } 1318 }
1267 uint64_t uintval = 0; 1319 uint64_t uintval = 0;
diff --git a/src/xplist.c b/src/xplist.c
index d8f6458..cf5d818 100644
--- a/src/xplist.c
+++ b/src/xplist.c
@@ -162,7 +162,7 @@ static int node_to_xml(node_t* node, bytearray_t **outbuf, uint32_t depth)
162 } 162 }
163 break; 163 break;
164 164
165 case PLIST_UINT: 165 case PLIST_INT:
166 tag = XPLIST_INT; 166 tag = XPLIST_INT;
167 tag_len = XPLIST_INT_LEN; 167 tag_len = XPLIST_INT_LEN;
168 val = (char*)malloc(64); 168 val = (char*)malloc(64);
@@ -479,7 +479,7 @@ static int node_estimate_size(node_t *node, uint64_t *size, uint32_t depth)
479 *size += data->length; 479 *size += data->length;
480 *size += (XPLIST_KEY_LEN << 1) + 6; 480 *size += (XPLIST_KEY_LEN << 1) + 6;
481 break; 481 break;
482 case PLIST_UINT: 482 case PLIST_INT:
483 if (data->length == 16) { 483 if (data->length == 16) {
484 *size += num_digits_u(data->intval); 484 *size += num_digits_u(data->intval);
485 } else { 485 } else {
@@ -1194,7 +1194,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist)
1194 data->intval = 0; 1194 data->intval = 0;
1195 data->length = 8; 1195 data->length = 8;
1196 } 1196 }
1197 data->type = PLIST_UINT; 1197 data->type = PLIST_INT;
1198 } else if (!strcmp(tag, XPLIST_REAL)) { 1198 } else if (!strcmp(tag, XPLIST_REAL)) {
1199 if (!is_empty) { 1199 if (!is_empty) {
1200 text_part_t first_part = { NULL, 0, 0, NULL }; 1200 text_part_t first_part = { NULL, 0, 0, NULL };