diff options
| author | 2023-01-16 04:25:52 +0100 | |
|---|---|---|
| committer | 2023-01-16 04:25:52 +0100 | |
| commit | d886885b0ec2506fa2caf0986a3d0e496fea91c2 (patch) | |
| tree | 58bc4bcd1963ea885abd60a65bf87a2685526714 /src/xplist.c | |
| parent | 47a7fbe438ee7350a2b151e007f07043ef596775 (diff) | |
| download | libplist-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/xplist.c')
| -rw-r--r-- | src/xplist.c | 6 |
1 files changed, 3 insertions, 3 deletions
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 }; |
