diff options
| author | 2023-05-21 00:12:57 +0200 | |
|---|---|---|
| committer | 2023-05-21 00:12:57 +0200 | |
| commit | f28cf0f1e51c7554d590cbec56abac46b4a44b4e (patch) | |
| tree | 4e2e2038fe0b780dd9595deecbe887d89a3e3de8 | |
| parent | d772fd74d2a52646c34d558220533547725a2298 (diff) | |
| download | libplist-f28cf0f1e51c7554d590cbec56abac46b4a44b4e.tar.gz libplist-f28cf0f1e51c7554d590cbec56abac46b4a44b4e.tar.bz2 | |
Add explicit casts and fix return type mismatches
| -rw-r--r-- | src/bplist.c | 22 | ||||
| -rw-r--r-- | src/hashtable.c | 10 | ||||
| -rw-r--r-- | src/jplist.c | 20 | ||||
| -rw-r--r-- | src/oplist.c | 28 | ||||
| -rw-r--r-- | src/out-default.c | 20 | ||||
| -rw-r--r-- | src/out-limd.c | 20 | ||||
| -rw-r--r-- | src/out-plutil.c | 20 | ||||
| -rw-r--r-- | src/plist.c | 90 | ||||
| -rw-r--r-- | src/ptrarray.c | 2 | ||||
| -rw-r--r-- | src/xplist.c | 66 |
10 files changed, 152 insertions, 146 deletions
diff --git a/src/bplist.c b/src/bplist.c index 897b90f..953c2c7 100644 --- a/src/bplist.c +++ b/src/bplist.c | |||
| @@ -47,7 +47,8 @@ | |||
| 47 | #define BPLIST_VERSION ((uint8_t*)"00") | 47 | #define BPLIST_VERSION ((uint8_t*)"00") |
| 48 | #define BPLIST_VERSION_SIZE 2 | 48 | #define BPLIST_VERSION_SIZE 2 |
| 49 | 49 | ||
| 50 | typedef struct __attribute__((packed)) { | 50 | #pragma pack(push,1) |
| 51 | typedef struct { | ||
| 51 | uint8_t unused[6]; | 52 | uint8_t unused[6]; |
| 52 | uint8_t offset_size; | 53 | uint8_t offset_size; |
| 53 | uint8_t ref_size; | 54 | uint8_t ref_size; |
| @@ -55,6 +56,7 @@ typedef struct __attribute__((packed)) { | |||
| 55 | uint64_t root_object_index; | 56 | uint64_t root_object_index; |
| 56 | uint64_t offset_table_offset; | 57 | uint64_t offset_table_offset; |
| 57 | } bplist_trailer_t; | 58 | } bplist_trailer_t; |
| 59 | #pragma pack(pop) | ||
| 58 | 60 | ||
| 59 | enum | 61 | enum |
| 60 | { | 62 | { |
| @@ -384,7 +386,7 @@ static char *plist_utf16be_to_utf8(uint16_t *unistr, long len, long *items_read, | |||
| 384 | outbuf[p] = 0; | 386 | outbuf[p] = 0; |
| 385 | 387 | ||
| 386 | /* reduce the size to the actual size */ | 388 | /* reduce the size to the actual size */ |
| 387 | outbuf_new = realloc(outbuf, p+1); | 389 | outbuf_new = (char*)realloc(outbuf, p+1); |
| 388 | if (outbuf_new) { | 390 | if (outbuf_new) { |
| 389 | outbuf = outbuf_new; | 391 | outbuf = outbuf_new; |
| 390 | } | 392 | } |
| @@ -498,8 +500,8 @@ static plist_t parse_dict_node(struct bplist_data *bplist, const char** bnode, u | |||
| 498 | return NULL; | 500 | return NULL; |
| 499 | } | 501 | } |
| 500 | 502 | ||
| 501 | node_attach(node, key); | 503 | node_attach((node_t)node, (node_t)key); |
| 502 | node_attach(node, val); | 504 | node_attach((node_t)node, (node_t)val); |
| 503 | } | 505 | } |
| 504 | 506 | ||
| 505 | return node; | 507 | return node; |
| @@ -543,7 +545,7 @@ static plist_t parse_array_node(struct bplist_data *bplist, const char** bnode, | |||
| 543 | return NULL; | 545 | return NULL; |
| 544 | } | 546 | } |
| 545 | 547 | ||
| 546 | node_attach(node, val); | 548 | node_attach((node_t)node, (node_t)val); |
| 547 | } | 549 | } |
| 548 | 550 | ||
| 549 | return node; | 551 | return node; |
| @@ -1229,7 +1231,7 @@ plist_err_t plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length) | |||
| 1229 | //serialize plist | 1231 | //serialize plist |
| 1230 | ser_s.objects = objects; | 1232 | ser_s.objects = objects; |
| 1231 | ser_s.ref_table = ref_table; | 1233 | ser_s.ref_table = ref_table; |
| 1232 | serialize_plist(plist, &ser_s); | 1234 | serialize_plist((node_t)plist, &ser_s); |
| 1233 | 1235 | ||
| 1234 | //now stream to output buffer | 1236 | //now stream to output buffer |
| 1235 | offset_size = 0; //unknown yet | 1237 | offset_size = 0; //unknown yet |
| @@ -1243,7 +1245,7 @@ plist_err_t plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length) | |||
| 1243 | uint64_t req = 0; | 1245 | uint64_t req = 0; |
| 1244 | for (i = 0; i < num_objects; i++) | 1246 | for (i = 0; i < num_objects; i++) |
| 1245 | { | 1247 | { |
| 1246 | node_t node = ptr_array_index(objects, i); | 1248 | node_t node = (node_t)ptr_array_index(objects, i); |
| 1247 | plist_data_t data = plist_get_data(node); | 1249 | plist_data_t data = plist_get_data(node); |
| 1248 | uint64_t size; | 1250 | uint64_t size; |
| 1249 | uint8_t bsize; | 1251 | uint8_t bsize; |
| @@ -1382,10 +1384,10 @@ plist_err_t plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length) | |||
| 1382 | write_data(bplist_buff, data->buff, data->length); | 1384 | write_data(bplist_buff, data->buff, data->length); |
| 1383 | break; | 1385 | break; |
| 1384 | case PLIST_ARRAY: | 1386 | case PLIST_ARRAY: |
| 1385 | write_array(bplist_buff, ptr_array_index(objects, i), ref_table, ref_size); | 1387 | write_array(bplist_buff, (node_t)ptr_array_index(objects, i), ref_table, ref_size); |
| 1386 | break; | 1388 | break; |
| 1387 | case PLIST_DICT: | 1389 | case PLIST_DICT: |
| 1388 | write_dict(bplist_buff, ptr_array_index(objects, i), ref_table, ref_size); | 1390 | write_dict(bplist_buff, (node_t)ptr_array_index(objects, i), ref_table, ref_size); |
| 1389 | break; | 1391 | break; |
| 1390 | case PLIST_DATE: | 1392 | case PLIST_DATE: |
| 1391 | write_date(bplist_buff, data->realval); | 1393 | write_date(bplist_buff, data->realval); |
| @@ -1423,7 +1425,7 @@ plist_err_t plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length) | |||
| 1423 | byte_array_append(bplist_buff, &trailer, sizeof(bplist_trailer_t)); | 1425 | byte_array_append(bplist_buff, &trailer, sizeof(bplist_trailer_t)); |
| 1424 | 1426 | ||
| 1425 | //set output buffer and size | 1427 | //set output buffer and size |
| 1426 | *plist_bin = bplist_buff->data; | 1428 | *plist_bin = (char*)bplist_buff->data; |
| 1427 | *length = bplist_buff->len; | 1429 | *length = bplist_buff->len; |
| 1428 | 1430 | ||
| 1429 | bplist_buff->data = NULL; // make sure we don't free the output buffer | 1431 | bplist_buff->data = NULL; // make sure we don't free the output buffer |
diff --git a/src/hashtable.c b/src/hashtable.c index dd6dbfc..86dae82 100644 --- a/src/hashtable.c +++ b/src/hashtable.c | |||
| @@ -47,7 +47,7 @@ void hash_table_destroy(hashtable_t *ht) | |||
| 47 | ht->free_func(e->value); | 47 | ht->free_func(e->value); |
| 48 | } | 48 | } |
| 49 | hashentry_t* old = e; | 49 | hashentry_t* old = e; |
| 50 | e = e->next; | 50 | e = (hashentry_t*)e->next; |
| 51 | free(old); | 51 | free(old); |
| 52 | } | 52 | } |
| 53 | } | 53 | } |
| @@ -71,7 +71,7 @@ void hash_table_insert(hashtable_t* ht, void *key, void *value) | |||
| 71 | e->value = value; | 71 | e->value = value; |
| 72 | return; | 72 | return; |
| 73 | } | 73 | } |
| 74 | e = e->next; | 74 | e = (hashentry_t*)e->next; |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | // if we get here, the element is not yet in the list. | 77 | // if we get here, the element is not yet in the list. |
| @@ -103,7 +103,7 @@ void* hash_table_lookup(hashtable_t* ht, void *key) | |||
| 103 | if (ht->compare_func(e->key, key)) { | 103 | if (ht->compare_func(e->key, key)) { |
| 104 | return e->value; | 104 | return e->value; |
| 105 | } | 105 | } |
| 106 | e = e->next; | 106 | e = (hashentry_t*)e->next; |
| 107 | } | 107 | } |
| 108 | return NULL; | 108 | return NULL; |
| 109 | } | 109 | } |
| @@ -124,7 +124,7 @@ void hash_table_remove(hashtable_t* ht, void *key) | |||
| 124 | // found element, remove it from the list | 124 | // found element, remove it from the list |
| 125 | hashentry_t* old = e; | 125 | hashentry_t* old = e; |
| 126 | if (e == ht->entries[idx0]) { | 126 | if (e == ht->entries[idx0]) { |
| 127 | ht->entries[idx0] = e->next; | 127 | ht->entries[idx0] = (hashentry_t*)e->next; |
| 128 | } else { | 128 | } else { |
| 129 | last->next = e->next; | 129 | last->next = e->next; |
| 130 | } | 130 | } |
| @@ -135,6 +135,6 @@ void hash_table_remove(hashtable_t* ht, void *key) | |||
| 135 | return; | 135 | return; |
| 136 | } | 136 | } |
| 137 | last = e; | 137 | last = e; |
| 138 | e = e->next; | 138 | e = (hashentry_t*)e->next; |
| 139 | } | 139 | } |
| 140 | } | 140 | } |
diff --git a/src/jplist.c b/src/jplist.c index f6c96ca..782d2b3 100644 --- a/src/jplist.c +++ b/src/jplist.c | |||
| @@ -110,7 +110,7 @@ static size_t dtostr(char *buf, size_t bufsize, double realval) | |||
| 110 | return len; | 110 | return len; |
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | static int node_to_json(node_t node, bytearray_t **outbuf, uint32_t depth, int prettify) | 113 | static plist_err_t node_to_json(node_t node, bytearray_t **outbuf, uint32_t depth, int prettify) |
| 114 | { | 114 | { |
| 115 | plist_data_t node_data = NULL; | 115 | plist_data_t node_data = NULL; |
| 116 | 116 | ||
| @@ -206,7 +206,7 @@ static int node_to_json(node_t node, bytearray_t **outbuf, uint32_t depth, int p | |||
| 206 | str_buf_append(*outbuf, " ", 2); | 206 | str_buf_append(*outbuf, " ", 2); |
| 207 | } | 207 | } |
| 208 | } | 208 | } |
| 209 | int res = node_to_json(ch, outbuf, depth+1, prettify); | 209 | plist_err_t res = node_to_json(ch, outbuf, depth+1, prettify); |
| 210 | if (res < 0) { | 210 | if (res < 0) { |
| 211 | return res; | 211 | return res; |
| 212 | } | 212 | } |
| @@ -234,7 +234,7 @@ static int node_to_json(node_t node, bytearray_t **outbuf, uint32_t depth, int p | |||
| 234 | str_buf_append(*outbuf, " ", 2); | 234 | str_buf_append(*outbuf, " ", 2); |
| 235 | } | 235 | } |
| 236 | } | 236 | } |
| 237 | int res = node_to_json(ch, outbuf, depth+1, prettify); | 237 | plist_err_t res = node_to_json(ch, outbuf, depth+1, prettify); |
| 238 | if (res < 0) { | 238 | if (res < 0) { |
| 239 | return res; | 239 | return res; |
| 240 | } | 240 | } |
| @@ -311,7 +311,7 @@ static int num_digits_u(uint64_t i) | |||
| 311 | return n; | 311 | return n; |
| 312 | } | 312 | } |
| 313 | 313 | ||
| 314 | static int node_estimate_size(node_t node, uint64_t *size, uint32_t depth, int prettify) | 314 | static plist_err_t node_estimate_size(node_t node, uint64_t *size, uint32_t depth, int prettify) |
| 315 | { | 315 | { |
| 316 | plist_data_t data; | 316 | plist_data_t data; |
| 317 | if (!node) { | 317 | if (!node) { |
| @@ -322,7 +322,7 @@ static int node_estimate_size(node_t node, uint64_t *size, uint32_t depth, int p | |||
| 322 | node_t ch; | 322 | node_t ch; |
| 323 | unsigned int n_children = node_n_children(node); | 323 | unsigned int n_children = node_n_children(node); |
| 324 | for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) { | 324 | for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) { |
| 325 | int res = node_estimate_size(ch, size, depth + 1, prettify); | 325 | plist_err_t res = node_estimate_size(ch, size, depth + 1, prettify); |
| 326 | if (res < 0) { | 326 | if (res < 0) { |
| 327 | return res; | 327 | return res; |
| 328 | } | 328 | } |
| @@ -401,7 +401,7 @@ static int node_estimate_size(node_t node, uint64_t *size, uint32_t depth, int p | |||
| 401 | plist_err_t plist_to_json(plist_t plist, char **plist_json, uint32_t* length, int prettify) | 401 | plist_err_t plist_to_json(plist_t plist, char **plist_json, uint32_t* length, int prettify) |
| 402 | { | 402 | { |
| 403 | uint64_t size = 0; | 403 | uint64_t size = 0; |
| 404 | int res; | 404 | plist_err_t res; |
| 405 | 405 | ||
| 406 | if (!plist || !plist_json || !length) { | 406 | if (!plist || !plist_json || !length) { |
| 407 | return PLIST_ERR_INVALID_ARG; | 407 | return PLIST_ERR_INVALID_ARG; |
| @@ -412,7 +412,7 @@ plist_err_t plist_to_json(plist_t plist, char **plist_json, uint32_t* length, in | |||
| 412 | return PLIST_ERR_FORMAT; | 412 | return PLIST_ERR_FORMAT; |
| 413 | } | 413 | } |
| 414 | 414 | ||
| 415 | res = node_estimate_size(plist, &size, 0, prettify); | 415 | res = node_estimate_size((node_t)plist, &size, 0, prettify); |
| 416 | if (res < 0) { | 416 | if (res < 0) { |
| 417 | return res; | 417 | return res; |
| 418 | } | 418 | } |
| @@ -423,7 +423,7 @@ plist_err_t plist_to_json(plist_t plist, char **plist_json, uint32_t* length, in | |||
| 423 | return PLIST_ERR_NO_MEM; | 423 | return PLIST_ERR_NO_MEM; |
| 424 | } | 424 | } |
| 425 | 425 | ||
| 426 | res = node_to_json(plist, &outbuf, 0, prettify); | 426 | res = node_to_json((node_t)plist, &outbuf, 0, prettify); |
| 427 | if (res < 0) { | 427 | if (res < 0) { |
| 428 | str_buf_free(outbuf); | 428 | str_buf_free(outbuf); |
| 429 | *plist_json = NULL; | 429 | *plist_json = NULL; |
| @@ -436,7 +436,7 @@ plist_err_t plist_to_json(plist_t plist, char **plist_json, uint32_t* length, in | |||
| 436 | 436 | ||
| 437 | str_buf_append(outbuf, "\0", 1); | 437 | str_buf_append(outbuf, "\0", 1); |
| 438 | 438 | ||
| 439 | *plist_json = outbuf->data; | 439 | *plist_json = (char*)outbuf->data; |
| 440 | *length = outbuf->len - 1; | 440 | *length = outbuf->len - 1; |
| 441 | 441 | ||
| 442 | outbuf->data = NULL; | 442 | outbuf->data = NULL; |
| @@ -800,7 +800,7 @@ plist_err_t plist_from_json(const char *json, uint32_t length, plist_t * plist) | |||
| 800 | jsmntok_t *tokens = NULL; | 800 | jsmntok_t *tokens = NULL; |
| 801 | 801 | ||
| 802 | do { | 802 | do { |
| 803 | jsmntok_t* newtokens = realloc(tokens, sizeof(jsmntok_t)*maxtoks); | 803 | jsmntok_t* newtokens = (jsmntok_t*)realloc(tokens, sizeof(jsmntok_t)*maxtoks); |
| 804 | if (!newtokens) { | 804 | if (!newtokens) { |
| 805 | PLIST_JSON_ERR("%s: Out of memory\n", __func__); | 805 | PLIST_JSON_ERR("%s: Out of memory\n", __func__); |
| 806 | return PLIST_ERR_NO_MEM; | 806 | return PLIST_ERR_NO_MEM; |
diff --git a/src/oplist.c b/src/oplist.c index 7597b3c..6ab6603 100644 --- a/src/oplist.c +++ b/src/oplist.c | |||
| @@ -139,7 +139,7 @@ static int str_needs_quotes(const char* str, size_t len) | |||
| 139 | return 0; | 139 | return 0; |
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | static int node_to_openstep(node_t node, bytearray_t **outbuf, uint32_t depth, int prettify) | 142 | static plist_err_t node_to_openstep(node_t node, bytearray_t **outbuf, uint32_t depth, int prettify) |
| 143 | { | 143 | { |
| 144 | plist_data_t node_data = NULL; | 144 | plist_data_t node_data = NULL; |
| 145 | 145 | ||
| @@ -230,7 +230,7 @@ static int node_to_openstep(node_t node, bytearray_t **outbuf, uint32_t depth, i | |||
| 230 | str_buf_append(*outbuf, " ", 2); | 230 | str_buf_append(*outbuf, " ", 2); |
| 231 | } | 231 | } |
| 232 | } | 232 | } |
| 233 | int res = node_to_openstep(ch, outbuf, depth+1, prettify); | 233 | plist_err_t res = node_to_openstep(ch, outbuf, depth+1, prettify); |
| 234 | if (res < 0) { | 234 | if (res < 0) { |
| 235 | return res; | 235 | return res; |
| 236 | } | 236 | } |
| @@ -258,7 +258,7 @@ static int node_to_openstep(node_t node, bytearray_t **outbuf, uint32_t depth, i | |||
| 258 | str_buf_append(*outbuf, " ", 2); | 258 | str_buf_append(*outbuf, " ", 2); |
| 259 | } | 259 | } |
| 260 | } | 260 | } |
| 261 | int res = node_to_openstep(ch, outbuf, depth+1, prettify); | 261 | plist_err_t res = node_to_openstep(ch, outbuf, depth+1, prettify); |
| 262 | if (res < 0) { | 262 | if (res < 0) { |
| 263 | return res; | 263 | return res; |
| 264 | } | 264 | } |
| @@ -355,7 +355,7 @@ static int num_digits_u(uint64_t i) | |||
| 355 | return n; | 355 | return n; |
| 356 | } | 356 | } |
| 357 | 357 | ||
| 358 | static int node_estimate_size(node_t node, uint64_t *size, uint32_t depth, int prettify) | 358 | static plist_err_t node_estimate_size(node_t node, uint64_t *size, uint32_t depth, int prettify) |
| 359 | { | 359 | { |
| 360 | plist_data_t data; | 360 | plist_data_t data; |
| 361 | if (!node) { | 361 | if (!node) { |
| @@ -366,7 +366,7 @@ static int node_estimate_size(node_t node, uint64_t *size, uint32_t depth, int p | |||
| 366 | node_t ch; | 366 | node_t ch; |
| 367 | unsigned int n_children = node_n_children(node); | 367 | unsigned int n_children = node_n_children(node); |
| 368 | for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) { | 368 | for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) { |
| 369 | int res = node_estimate_size(ch, size, depth + 1, prettify); | 369 | plist_err_t res = node_estimate_size(ch, size, depth + 1, prettify); |
| 370 | if (res < 0) { | 370 | if (res < 0) { |
| 371 | return res; | 371 | return res; |
| 372 | } | 372 | } |
| @@ -445,13 +445,13 @@ static int node_estimate_size(node_t node, uint64_t *size, uint32_t depth, int p | |||
| 445 | plist_err_t plist_to_openstep(plist_t plist, char **openstep, uint32_t* length, int prettify) | 445 | plist_err_t plist_to_openstep(plist_t plist, char **openstep, uint32_t* length, int prettify) |
| 446 | { | 446 | { |
| 447 | uint64_t size = 0; | 447 | uint64_t size = 0; |
| 448 | int res; | 448 | plist_err_t res; |
| 449 | 449 | ||
| 450 | if (!plist || !openstep || !length) { | 450 | if (!plist || !openstep || !length) { |
| 451 | return PLIST_ERR_INVALID_ARG; | 451 | return PLIST_ERR_INVALID_ARG; |
| 452 | } | 452 | } |
| 453 | 453 | ||
| 454 | res = node_estimate_size(plist, &size, 0, prettify); | 454 | res = node_estimate_size((node_t)plist, &size, 0, prettify); |
| 455 | if (res < 0) { | 455 | if (res < 0) { |
| 456 | return res; | 456 | return res; |
| 457 | } | 457 | } |
| @@ -462,7 +462,7 @@ plist_err_t plist_to_openstep(plist_t plist, char **openstep, uint32_t* length, | |||
| 462 | return PLIST_ERR_NO_MEM; | 462 | return PLIST_ERR_NO_MEM; |
| 463 | } | 463 | } |
| 464 | 464 | ||
| 465 | res = node_to_openstep(plist, &outbuf, 0, prettify); | 465 | res = node_to_openstep((node_t)plist, &outbuf, 0, prettify); |
| 466 | if (res < 0) { | 466 | if (res < 0) { |
| 467 | str_buf_free(outbuf); | 467 | str_buf_free(outbuf); |
| 468 | *openstep = NULL; | 468 | *openstep = NULL; |
| @@ -475,7 +475,7 @@ plist_err_t plist_to_openstep(plist_t plist, char **openstep, uint32_t* length, | |||
| 475 | 475 | ||
| 476 | str_buf_append(outbuf, "\0", 1); | 476 | str_buf_append(outbuf, "\0", 1); |
| 477 | 477 | ||
| 478 | *openstep = outbuf->data; | 478 | *openstep = (char*)outbuf->data; |
| 479 | *length = outbuf->len - 1; | 479 | *length = outbuf->len - 1; |
| 480 | 480 | ||
| 481 | outbuf->data = NULL; | 481 | outbuf->data = NULL; |
| @@ -532,7 +532,7 @@ static void parse_skip_ws(parse_ctx ctx) | |||
| 532 | 532 | ||
| 533 | #define HEX_DIGIT(x) ((x <= '9') ? (x - '0') : ((x <= 'F') ? (x - 'A' + 10) : (x - 'a' + 10))) | 533 | #define HEX_DIGIT(x) ((x <= '9') ? (x - '0') : ((x <= 'F') ? (x - 'A' + 10) : (x - 'a' + 10))) |
| 534 | 534 | ||
| 535 | static int node_from_openstep(parse_ctx ctx, plist_t *plist); | 535 | static plist_err_t node_from_openstep(parse_ctx ctx, plist_t *plist); |
| 536 | 536 | ||
| 537 | static void parse_dict_data(parse_ctx ctx, plist_t dict) | 537 | static void parse_dict_data(parse_ctx ctx, plist_t dict) |
| 538 | { | 538 | { |
| @@ -603,7 +603,7 @@ static void parse_dict_data(parse_ctx ctx, plist_t dict) | |||
| 603 | plist_free(val); | 603 | plist_free(val); |
| 604 | } | 604 | } |
| 605 | 605 | ||
| 606 | static int node_from_openstep(parse_ctx ctx, plist_t *plist) | 606 | static plist_err_t node_from_openstep(parse_ctx ctx, plist_t *plist) |
| 607 | { | 607 | { |
| 608 | plist_t subnode = NULL; | 608 | plist_t subnode = NULL; |
| 609 | const char *p = NULL; | 609 | const char *p = NULL; |
| @@ -746,7 +746,7 @@ static int node_from_openstep(parse_ctx ctx, plist_t *plist) | |||
| 746 | goto err_out; | 746 | goto err_out; |
| 747 | } | 747 | } |
| 748 | ctx->pos++; | 748 | ctx->pos++; |
| 749 | data->buff = bytes->data; | 749 | data->buff = (uint8_t*)bytes->data; |
| 750 | data->length = bytes->len; | 750 | data->length = bytes->len; |
| 751 | bytes->data = NULL; | 751 | bytes->data = NULL; |
| 752 | byte_array_free(bytes); | 752 | byte_array_free(bytes); |
| @@ -781,7 +781,7 @@ static int node_from_openstep(parse_ctx ctx, plist_t *plist) | |||
| 781 | } | 781 | } |
| 782 | size_t slen = ctx->pos - p; | 782 | size_t slen = ctx->pos - p; |
| 783 | ctx->pos++; // skip the closing quote | 783 | ctx->pos++; // skip the closing quote |
| 784 | char* strbuf = malloc(slen+1); | 784 | char* strbuf = (char*)malloc(slen+1); |
| 785 | if (num_escapes > 0) { | 785 | if (num_escapes > 0) { |
| 786 | size_t i = 0; | 786 | size_t i = 0; |
| 787 | size_t o = 0; | 787 | size_t o = 0; |
| @@ -907,7 +907,7 @@ plist_err_t plist_from_openstep(const char *plist_ostep, uint32_t length, plist_ | |||
| 907 | 907 | ||
| 908 | struct _parse_ctx ctx = { plist_ostep, plist_ostep, plist_ostep + length, 0 , 0 }; | 908 | struct _parse_ctx ctx = { plist_ostep, plist_ostep, plist_ostep + length, 0 , 0 }; |
| 909 | 909 | ||
| 910 | int err = node_from_openstep(&ctx, plist); | 910 | plist_err_t err = node_from_openstep(&ctx, plist); |
| 911 | if (err == 0) { | 911 | if (err == 0) { |
| 912 | if (!*plist) { | 912 | if (!*plist) { |
| 913 | /* whitespace only file is considered an empty dictionary */ | 913 | /* whitespace only file is considered an empty dictionary */ |
diff --git a/src/out-default.c b/src/out-default.c index 3ee9b3a..266070b 100644 --- a/src/out-default.c +++ b/src/out-default.c | |||
| @@ -65,7 +65,7 @@ static size_t dtostr(char *buf, size_t bufsize, double realval) | |||
| 65 | return len; | 65 | return len; |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | static int node_to_string(node_t node, bytearray_t **outbuf, uint32_t depth, uint32_t indent, int partial_data) | 68 | static plist_err_t node_to_string(node_t node, bytearray_t **outbuf, uint32_t depth, uint32_t indent, int partial_data) |
| 69 | { | 69 | { |
| 70 | plist_data_t node_data = NULL; | 70 | plist_data_t node_data = NULL; |
| 71 | 71 | ||
| @@ -159,7 +159,7 @@ static int node_to_string(node_t node, bytearray_t **outbuf, uint32_t depth, uin | |||
| 159 | for (i = 0; i <= depth+indent; i++) { | 159 | for (i = 0; i <= depth+indent; i++) { |
| 160 | str_buf_append(*outbuf, " ", 2); | 160 | str_buf_append(*outbuf, " ", 2); |
| 161 | } | 161 | } |
| 162 | int res = node_to_string(ch, outbuf, depth+1, indent, partial_data); | 162 | plist_err_t res = node_to_string(ch, outbuf, depth+1, indent, partial_data); |
| 163 | if (res < 0) { | 163 | if (res < 0) { |
| 164 | return res; | 164 | return res; |
| 165 | } | 165 | } |
| @@ -187,7 +187,7 @@ static int node_to_string(node_t node, bytearray_t **outbuf, uint32_t depth, uin | |||
| 187 | str_buf_append(*outbuf, " ", 2); | 187 | str_buf_append(*outbuf, " ", 2); |
| 188 | } | 188 | } |
| 189 | } | 189 | } |
| 190 | int res = node_to_string(ch, outbuf, depth+1, indent, partial_data); | 190 | plist_err_t res = node_to_string(ch, outbuf, depth+1, indent, partial_data); |
| 191 | if (res < 0) { | 191 | if (res < 0) { |
| 192 | return res; | 192 | return res; |
| 193 | } | 193 | } |
| @@ -310,7 +310,7 @@ static int num_digits_u(uint64_t i) | |||
| 310 | return n; | 310 | return n; |
| 311 | } | 311 | } |
| 312 | 312 | ||
| 313 | static int node_estimate_size(node_t node, uint64_t *size, uint32_t depth, uint32_t indent, int partial_data) | 313 | static plist_err_t node_estimate_size(node_t node, uint64_t *size, uint32_t depth, uint32_t indent, int partial_data) |
| 314 | { | 314 | { |
| 315 | plist_data_t data; | 315 | plist_data_t data; |
| 316 | if (!node) { | 316 | if (!node) { |
| @@ -321,7 +321,7 @@ static int node_estimate_size(node_t node, uint64_t *size, uint32_t depth, uint3 | |||
| 321 | node_t ch; | 321 | node_t ch; |
| 322 | unsigned int n_children = node_n_children(node); | 322 | unsigned int n_children = node_n_children(node); |
| 323 | for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) { | 323 | for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) { |
| 324 | int res = node_estimate_size(ch, size, depth + 1, indent, partial_data); | 324 | plist_err_t res = node_estimate_size(ch, size, depth + 1, indent, partial_data); |
| 325 | if (res < 0) { | 325 | if (res < 0) { |
| 326 | return res; | 326 | return res; |
| 327 | } | 327 | } |
| @@ -411,7 +411,7 @@ static plist_err_t _plist_write_to_strbuf(plist_t plist, strbuf_t *outbuf, plist | |||
| 411 | for (i = 0; i < indent; i++) { | 411 | for (i = 0; i < indent; i++) { |
| 412 | str_buf_append(outbuf, " ", 2); | 412 | str_buf_append(outbuf, " ", 2); |
| 413 | } | 413 | } |
| 414 | int res = node_to_string(plist, &outbuf, 0, indent, options & PLIST_OPT_PARTIAL_DATA); | 414 | plist_err_t res = node_to_string((node_t)plist, &outbuf, 0, indent, options & PLIST_OPT_PARTIAL_DATA); |
| 415 | if (res < 0) { | 415 | if (res < 0) { |
| 416 | return res; | 416 | return res; |
| 417 | } | 417 | } |
| @@ -424,7 +424,7 @@ static plist_err_t _plist_write_to_strbuf(plist_t plist, strbuf_t *outbuf, plist | |||
| 424 | plist_err_t plist_write_to_string_default(plist_t plist, char **output, uint32_t* length, plist_write_options_t options) | 424 | plist_err_t plist_write_to_string_default(plist_t plist, char **output, uint32_t* length, plist_write_options_t options) |
| 425 | { | 425 | { |
| 426 | uint64_t size = 0; | 426 | uint64_t size = 0; |
| 427 | int res; | 427 | plist_err_t res; |
| 428 | 428 | ||
| 429 | if (!plist || !output || !length) { | 429 | if (!plist || !output || !length) { |
| 430 | return PLIST_ERR_INVALID_ARG; | 430 | return PLIST_ERR_INVALID_ARG; |
| @@ -435,7 +435,7 @@ plist_err_t plist_write_to_string_default(plist_t plist, char **output, uint32_t | |||
| 435 | indent = (options >> 24) & 0xFF; | 435 | indent = (options >> 24) & 0xFF; |
| 436 | } | 436 | } |
| 437 | 437 | ||
| 438 | res = node_estimate_size(plist, &size, 0, indent, options & PLIST_OPT_PARTIAL_DATA); | 438 | res = node_estimate_size((node_t)plist, &size, 0, indent, options & PLIST_OPT_PARTIAL_DATA); |
| 439 | if (res < 0) { | 439 | if (res < 0) { |
| 440 | return res; | 440 | return res; |
| 441 | } | 441 | } |
| @@ -457,7 +457,7 @@ plist_err_t plist_write_to_string_default(plist_t plist, char **output, uint32_t | |||
| 457 | } | 457 | } |
| 458 | str_buf_append(outbuf, "\0", 1); | 458 | str_buf_append(outbuf, "\0", 1); |
| 459 | 459 | ||
| 460 | *output = outbuf->data; | 460 | *output = (char*)outbuf->data; |
| 461 | *length = outbuf->len - 1; | 461 | *length = outbuf->len - 1; |
| 462 | 462 | ||
| 463 | outbuf->data = NULL; | 463 | outbuf->data = NULL; |
| @@ -479,7 +479,7 @@ plist_err_t plist_write_to_stream_default(plist_t plist, FILE *stream, plist_wri | |||
| 479 | return PLIST_ERR_NO_MEM; | 479 | return PLIST_ERR_NO_MEM; |
| 480 | } | 480 | } |
| 481 | 481 | ||
| 482 | int res = _plist_write_to_strbuf(plist, outbuf, options); | 482 | plist_err_t res = _plist_write_to_strbuf(plist, outbuf, options); |
| 483 | if (res < 0) { | 483 | if (res < 0) { |
| 484 | str_buf_free(outbuf); | 484 | str_buf_free(outbuf); |
| 485 | return res; | 485 | return res; |
diff --git a/src/out-limd.c b/src/out-limd.c index 433ae06..7d861f8 100644 --- a/src/out-limd.c +++ b/src/out-limd.c | |||
| @@ -67,7 +67,7 @@ static size_t dtostr(char *buf, size_t bufsize, double realval) | |||
| 67 | return len; | 67 | return len; |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | static int node_to_string(node_t node, bytearray_t **outbuf, uint32_t depth, uint32_t indent) | 70 | static plist_err_t node_to_string(node_t node, bytearray_t **outbuf, uint32_t depth, uint32_t indent) |
| 71 | { | 71 | { |
| 72 | plist_data_t node_data = NULL; | 72 | plist_data_t node_data = NULL; |
| 73 | 73 | ||
| @@ -154,7 +154,7 @@ static int node_to_string(node_t node, bytearray_t **outbuf, uint32_t depth, uin | |||
| 154 | } | 154 | } |
| 155 | size_t sl = sprintf(buf, "%u: ", cnt); | 155 | size_t sl = sprintf(buf, "%u: ", cnt); |
| 156 | str_buf_append(*outbuf, buf, sl); | 156 | str_buf_append(*outbuf, buf, sl); |
| 157 | int res = node_to_string(ch, outbuf, depth+1, indent); | 157 | plist_err_t res = node_to_string(ch, outbuf, depth+1, indent); |
| 158 | if (res < 0) { | 158 | if (res < 0) { |
| 159 | return res; | 159 | return res; |
| 160 | } | 160 | } |
| @@ -171,7 +171,7 @@ static int node_to_string(node_t node, bytearray_t **outbuf, uint32_t depth, uin | |||
| 171 | str_buf_append(*outbuf, " ", 1); | 171 | str_buf_append(*outbuf, " ", 1); |
| 172 | } | 172 | } |
| 173 | } | 173 | } |
| 174 | int res = node_to_string(ch, outbuf, depth+1, indent); | 174 | plist_err_t res = node_to_string(ch, outbuf, depth+1, indent); |
| 175 | if (res < 0) { | 175 | if (res < 0) { |
| 176 | return res; | 176 | return res; |
| 177 | } | 177 | } |
| @@ -278,7 +278,7 @@ static int num_digits_u(uint64_t i) | |||
| 278 | return n; | 278 | return n; |
| 279 | } | 279 | } |
| 280 | 280 | ||
| 281 | static int node_estimate_size(node_t node, uint64_t *size, uint32_t depth, uint32_t indent) | 281 | static plist_err_t node_estimate_size(node_t node, uint64_t *size, uint32_t depth, uint32_t indent) |
| 282 | { | 282 | { |
| 283 | plist_data_t data; | 283 | plist_data_t data; |
| 284 | if (!node) { | 284 | if (!node) { |
| @@ -289,7 +289,7 @@ static int node_estimate_size(node_t node, uint64_t *size, uint32_t depth, uint3 | |||
| 289 | node_t ch; | 289 | node_t ch; |
| 290 | unsigned int n_children = node_n_children(node); | 290 | unsigned int n_children = node_n_children(node); |
| 291 | for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) { | 291 | for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) { |
| 292 | int res = node_estimate_size(ch, size, depth + 1, indent); | 292 | plist_err_t res = node_estimate_size(ch, size, depth + 1, indent); |
| 293 | if (res < 0) { | 293 | if (res < 0) { |
| 294 | return res; | 294 | return res; |
| 295 | } | 295 | } |
| @@ -369,7 +369,7 @@ static plist_err_t _plist_write_to_strbuf(plist_t plist, strbuf_t *outbuf, plist | |||
| 369 | for (i = 0; i < indent; i++) { | 369 | for (i = 0; i < indent; i++) { |
| 370 | str_buf_append(outbuf, " ", 1); | 370 | str_buf_append(outbuf, " ", 1); |
| 371 | } | 371 | } |
| 372 | int res = node_to_string(plist, &outbuf, 0, indent); | 372 | plist_err_t res = node_to_string((node_t)plist, &outbuf, 0, indent); |
| 373 | if (res < 0) { | 373 | if (res < 0) { |
| 374 | return res; | 374 | return res; |
| 375 | } | 375 | } |
| @@ -382,7 +382,7 @@ static plist_err_t _plist_write_to_strbuf(plist_t plist, strbuf_t *outbuf, plist | |||
| 382 | plist_err_t plist_write_to_string_limd(plist_t plist, char **output, uint32_t* length, plist_write_options_t options) | 382 | plist_err_t plist_write_to_string_limd(plist_t plist, char **output, uint32_t* length, plist_write_options_t options) |
| 383 | { | 383 | { |
| 384 | uint64_t size = 0; | 384 | uint64_t size = 0; |
| 385 | int res; | 385 | plist_err_t res; |
| 386 | 386 | ||
| 387 | if (!plist || !output || !length) { | 387 | if (!plist || !output || !length) { |
| 388 | return PLIST_ERR_INVALID_ARG; | 388 | return PLIST_ERR_INVALID_ARG; |
| @@ -393,7 +393,7 @@ plist_err_t plist_write_to_string_limd(plist_t plist, char **output, uint32_t* l | |||
| 393 | indent = (options >> 24) & 0xFF; | 393 | indent = (options >> 24) & 0xFF; |
| 394 | } | 394 | } |
| 395 | 395 | ||
| 396 | res = node_estimate_size(plist, &size, 0, indent); | 396 | res = node_estimate_size((node_t)plist, &size, 0, indent); |
| 397 | if (res < 0) { | 397 | if (res < 0) { |
| 398 | return res; | 398 | return res; |
| 399 | } | 399 | } |
| @@ -415,7 +415,7 @@ plist_err_t plist_write_to_string_limd(plist_t plist, char **output, uint32_t* l | |||
| 415 | } | 415 | } |
| 416 | str_buf_append(outbuf, "\0", 1); | 416 | str_buf_append(outbuf, "\0", 1); |
| 417 | 417 | ||
| 418 | *output = outbuf->data; | 418 | *output = (char*)outbuf->data; |
| 419 | *length = outbuf->len - 1; | 419 | *length = outbuf->len - 1; |
| 420 | 420 | ||
| 421 | outbuf->data = NULL; | 421 | outbuf->data = NULL; |
| @@ -437,7 +437,7 @@ plist_err_t plist_write_to_stream_limd(plist_t plist, FILE *stream, plist_write_ | |||
| 437 | return PLIST_ERR_NO_MEM; | 437 | return PLIST_ERR_NO_MEM; |
| 438 | } | 438 | } |
| 439 | 439 | ||
| 440 | int res = _plist_write_to_strbuf(plist, outbuf, options); | 440 | plist_err_t res = _plist_write_to_strbuf(plist, outbuf, options); |
| 441 | if (res < 0) { | 441 | if (res < 0) { |
| 442 | str_buf_free(outbuf); | 442 | str_buf_free(outbuf); |
| 443 | return res; | 443 | return res; |
diff --git a/src/out-plutil.c b/src/out-plutil.c index ed71d8f..d85f22c 100644 --- a/src/out-plutil.c +++ b/src/out-plutil.c | |||
| @@ -65,7 +65,7 @@ static size_t dtostr(char *buf, size_t bufsize, double realval) | |||
| 65 | return len; | 65 | return len; |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | static int node_to_string(node_t node, bytearray_t **outbuf, uint32_t depth) | 68 | static plist_err_t node_to_string(node_t node, bytearray_t **outbuf, uint32_t depth) |
| 69 | { | 69 | { |
| 70 | plist_data_t node_data = NULL; | 70 | plist_data_t node_data = NULL; |
| 71 | 71 | ||
| @@ -159,7 +159,7 @@ static int node_to_string(node_t node, bytearray_t **outbuf, uint32_t depth) | |||
| 159 | char indexbuf[16]; | 159 | char indexbuf[16]; |
| 160 | int l = sprintf(indexbuf, "%u => ", cnt); | 160 | int l = sprintf(indexbuf, "%u => ", cnt); |
| 161 | str_buf_append(*outbuf, indexbuf, l); | 161 | str_buf_append(*outbuf, indexbuf, l); |
| 162 | int res = node_to_string(ch, outbuf, depth+1); | 162 | plist_err_t res = node_to_string(ch, outbuf, depth+1); |
| 163 | if (res < 0) { | 163 | if (res < 0) { |
| 164 | return res; | 164 | return res; |
| 165 | } | 165 | } |
| @@ -184,7 +184,7 @@ static int node_to_string(node_t node, bytearray_t **outbuf, uint32_t depth) | |||
| 184 | str_buf_append(*outbuf, " ", 2); | 184 | str_buf_append(*outbuf, " ", 2); |
| 185 | } | 185 | } |
| 186 | } | 186 | } |
| 187 | int res = node_to_string(ch, outbuf, depth+1); | 187 | plist_err_t res = node_to_string(ch, outbuf, depth+1); |
| 188 | if (res < 0) { | 188 | if (res < 0) { |
| 189 | return res; | 189 | return res; |
| 190 | } | 190 | } |
| @@ -304,7 +304,7 @@ static int num_digits_u(uint64_t i) | |||
| 304 | return n; | 304 | return n; |
| 305 | } | 305 | } |
| 306 | 306 | ||
| 307 | static int node_estimate_size(node_t node, uint64_t *size, uint32_t depth) | 307 | static plist_err_t node_estimate_size(node_t node, uint64_t *size, uint32_t depth) |
| 308 | { | 308 | { |
| 309 | plist_data_t data; | 309 | plist_data_t data; |
| 310 | if (!node) { | 310 | if (!node) { |
| @@ -315,7 +315,7 @@ static int node_estimate_size(node_t node, uint64_t *size, uint32_t depth) | |||
| 315 | node_t ch; | 315 | node_t ch; |
| 316 | unsigned int n_children = node_n_children(node); | 316 | unsigned int n_children = node_n_children(node); |
| 317 | for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) { | 317 | for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) { |
| 318 | int res = node_estimate_size(ch, size, depth + 1); | 318 | plist_err_t res = node_estimate_size(ch, size, depth + 1); |
| 319 | if (res < 0) { | 319 | if (res < 0) { |
| 320 | return res; | 320 | return res; |
| 321 | } | 321 | } |
| @@ -390,7 +390,7 @@ static int node_estimate_size(node_t node, uint64_t *size, uint32_t depth) | |||
| 390 | 390 | ||
| 391 | static plist_err_t _plist_write_to_strbuf(plist_t plist, strbuf_t *outbuf, plist_write_options_t options) | 391 | static plist_err_t _plist_write_to_strbuf(plist_t plist, strbuf_t *outbuf, plist_write_options_t options) |
| 392 | { | 392 | { |
| 393 | int res = node_to_string(plist, &outbuf, 0); | 393 | plist_err_t res = node_to_string((node_t)plist, &outbuf, 0); |
| 394 | if (res < 0) { | 394 | if (res < 0) { |
| 395 | return res; | 395 | return res; |
| 396 | } | 396 | } |
| @@ -403,13 +403,13 @@ static plist_err_t _plist_write_to_strbuf(plist_t plist, strbuf_t *outbuf, plist | |||
| 403 | plist_err_t plist_write_to_string_plutil(plist_t plist, char **output, uint32_t* length, plist_write_options_t options) | 403 | plist_err_t plist_write_to_string_plutil(plist_t plist, char **output, uint32_t* length, plist_write_options_t options) |
| 404 | { | 404 | { |
| 405 | uint64_t size = 0; | 405 | uint64_t size = 0; |
| 406 | int res; | 406 | plist_err_t res; |
| 407 | 407 | ||
| 408 | if (!plist || !output || !length) { | 408 | if (!plist || !output || !length) { |
| 409 | return PLIST_ERR_INVALID_ARG; | 409 | return PLIST_ERR_INVALID_ARG; |
| 410 | } | 410 | } |
| 411 | 411 | ||
| 412 | res = node_estimate_size(plist, &size, 0); | 412 | res = node_estimate_size((node_t)plist, &size, 0); |
| 413 | if (res < 0) { | 413 | if (res < 0) { |
| 414 | return res; | 414 | return res; |
| 415 | } | 415 | } |
| @@ -431,7 +431,7 @@ plist_err_t plist_write_to_string_plutil(plist_t plist, char **output, uint32_t* | |||
| 431 | } | 431 | } |
| 432 | str_buf_append(outbuf, "\0", 1); | 432 | str_buf_append(outbuf, "\0", 1); |
| 433 | 433 | ||
| 434 | *output = outbuf->data; | 434 | *output = (char*)outbuf->data; |
| 435 | *length = outbuf->len - 1; | 435 | *length = outbuf->len - 1; |
| 436 | 436 | ||
| 437 | outbuf->data = NULL; | 437 | outbuf->data = NULL; |
| @@ -453,7 +453,7 @@ plist_err_t plist_write_to_stream_plutil(plist_t plist, FILE *stream, plist_writ | |||
| 453 | return PLIST_ERR_NO_MEM; | 453 | return PLIST_ERR_NO_MEM; |
| 454 | } | 454 | } |
| 455 | 455 | ||
| 456 | int res = _plist_write_to_strbuf(plist, outbuf, options); | 456 | plist_err_t res = _plist_write_to_strbuf(plist, outbuf, options); |
| 457 | if (res < 0) { | 457 | if (res < 0) { |
| 458 | str_buf_free(outbuf); | 458 | str_buf_free(outbuf); |
| 459 | return res; | 459 | return res; |
diff --git a/src/plist.c b/src/plist.c index ccb7359..d78f748 100644 --- a/src/plist.c +++ b/src/plist.c | |||
| @@ -47,6 +47,10 @@ | |||
| 47 | #include <hashtable.h> | 47 | #include <hashtable.h> |
| 48 | #include <ptrarray.h> | 48 | #include <ptrarray.h> |
| 49 | 49 | ||
| 50 | #ifdef _MSC_VER | ||
| 51 | typedef SSIZE_T ssize_t; | ||
| 52 | #endif | ||
| 53 | |||
| 50 | extern void plist_xml_init(void); | 54 | extern void plist_xml_init(void); |
| 51 | extern void plist_xml_deinit(void); | 55 | extern void plist_xml_deinit(void); |
| 52 | extern void plist_bin_init(void); | 56 | extern void plist_bin_init(void); |
| @@ -199,7 +203,7 @@ int plist_is_binary(const char *plist_data, uint32_t length) | |||
| 199 | 203 | ||
| 200 | plist_err_t plist_from_memory(const char *plist_data, uint32_t length, plist_t *plist, plist_format_t *format) | 204 | plist_err_t plist_from_memory(const char *plist_data, uint32_t length, plist_t *plist, plist_format_t *format) |
| 201 | { | 205 | { |
| 202 | int res = -1; | 206 | plist_err_t res = PLIST_ERR_UNKNOWN; |
| 203 | if (!plist) { | 207 | if (!plist) { |
| 204 | return PLIST_ERR_INVALID_ARG; | 208 | return PLIST_ERR_INVALID_ARG; |
| 205 | } | 209 | } |
| @@ -284,7 +288,7 @@ plist_err_t plist_read_from_file(const char *filename, plist_t *plist, plist_for | |||
| 284 | if (total == 0) { | 288 | if (total == 0) { |
| 285 | return PLIST_ERR_PARSE; | 289 | return PLIST_ERR_PARSE; |
| 286 | } | 290 | } |
| 287 | char *buf = malloc(total); | 291 | char *buf = (char*)malloc(total); |
| 288 | if (!buf) { | 292 | if (!buf) { |
| 289 | fclose(f); | 293 | fclose(f); |
| 290 | return PLIST_ERR_NO_MEM; | 294 | return PLIST_ERR_NO_MEM; |
| @@ -316,7 +320,7 @@ plist_data_t plist_get_data(plist_t node) | |||
| 316 | { | 320 | { |
| 317 | if (!node) | 321 | if (!node) |
| 318 | return NULL; | 322 | return NULL; |
| 319 | return ((node_t)node)->data; | 323 | return (plist_data_t)((node_t)node)->data; |
| 320 | } | 324 | } |
| 321 | 325 | ||
| 322 | plist_data_t plist_new_plist_data(void) | 326 | plist_data_t plist_new_plist_data(void) |
| @@ -364,10 +368,10 @@ void plist_free_data(plist_data_t data) | |||
| 364 | free(data->buff); | 368 | free(data->buff); |
| 365 | break; | 369 | break; |
| 366 | case PLIST_ARRAY: | 370 | case PLIST_ARRAY: |
| 367 | ptr_array_free(data->hashtable); | 371 | ptr_array_free((ptrarray_t*)data->hashtable); |
| 368 | break; | 372 | break; |
| 369 | case PLIST_DICT: | 373 | case PLIST_DICT: |
| 370 | hash_table_destroy(data->hashtable); | 374 | hash_table_destroy((hashtable_t*)data->hashtable); |
| 371 | break; | 375 | break; |
| 372 | default: | 376 | default: |
| 373 | break; | 377 | break; |
| @@ -506,7 +510,7 @@ void plist_free(plist_t plist) | |||
| 506 | { | 510 | { |
| 507 | if (plist) | 511 | if (plist) |
| 508 | { | 512 | { |
| 509 | plist_free_node(plist); | 513 | plist_free_node((node_t)plist); |
| 510 | } | 514 | } |
| 511 | } | 515 | } |
| 512 | 516 | ||
| @@ -565,7 +569,7 @@ static plist_t plist_copy_node(node_t node) | |||
| 565 | /* copy child node */ | 569 | /* copy child node */ |
| 566 | plist_t newch = plist_copy_node(ch); | 570 | plist_t newch = plist_copy_node(ch); |
| 567 | /* attach to new parent node */ | 571 | /* attach to new parent node */ |
| 568 | node_attach(newnode, newch); | 572 | node_attach((node_t)newnode, (node_t)newch); |
| 569 | /* if needed, add child node to lookup table of parent node */ | 573 | /* if needed, add child node to lookup table of parent node */ |
| 570 | switch (node_type) { | 574 | switch (node_type) { |
| 571 | case PLIST_ARRAY: | 575 | case PLIST_ARRAY: |
| @@ -588,7 +592,7 @@ static plist_t plist_copy_node(node_t node) | |||
| 588 | 592 | ||
| 589 | plist_t plist_copy(plist_t node) | 593 | plist_t plist_copy(plist_t node) |
| 590 | { | 594 | { |
| 591 | return node ? plist_copy_node(node) : NULL; | 595 | return node ? plist_copy_node((node_t)node) : NULL; |
| 592 | } | 596 | } |
| 593 | 597 | ||
| 594 | uint32_t plist_array_get_size(plist_t node) | 598 | uint32_t plist_array_get_size(plist_t node) |
| @@ -596,7 +600,7 @@ uint32_t plist_array_get_size(plist_t node) | |||
| 596 | uint32_t ret = 0; | 600 | uint32_t ret = 0; |
| 597 | if (node && PLIST_ARRAY == plist_get_node_type(node)) | 601 | if (node && PLIST_ARRAY == plist_get_node_type(node)) |
| 598 | { | 602 | { |
| 599 | ret = node_n_children(node); | 603 | ret = node_n_children((node_t)node); |
| 600 | } | 604 | } |
| 601 | return ret; | 605 | return ret; |
| 602 | } | 606 | } |
| @@ -606,11 +610,11 @@ plist_t plist_array_get_item(plist_t node, uint32_t n) | |||
| 606 | plist_t ret = NULL; | 610 | plist_t ret = NULL; |
| 607 | if (node && PLIST_ARRAY == plist_get_node_type(node) && n < INT_MAX) | 611 | if (node && PLIST_ARRAY == plist_get_node_type(node) && n < INT_MAX) |
| 608 | { | 612 | { |
| 609 | ptrarray_t *pa = ((plist_data_t)((node_t)node)->data)->hashtable; | 613 | ptrarray_t *pa = (ptrarray_t*)((plist_data_t)((node_t)node)->data)->hashtable; |
| 610 | if (pa) { | 614 | if (pa) { |
| 611 | ret = (plist_t)ptr_array_index(pa, n); | 615 | ret = (plist_t)ptr_array_index(pa, n); |
| 612 | } else { | 616 | } else { |
| 613 | ret = (plist_t)node_nth_child(node, n); | 617 | ret = (plist_t)node_nth_child((node_t)node, n); |
| 614 | } | 618 | } |
| 615 | } | 619 | } |
| 616 | return ret; | 620 | return ret; |
| @@ -621,14 +625,14 @@ uint32_t plist_array_get_item_index(plist_t node) | |||
| 621 | plist_t father = plist_get_parent(node); | 625 | plist_t father = plist_get_parent(node); |
| 622 | if (PLIST_ARRAY == plist_get_node_type(father)) | 626 | if (PLIST_ARRAY == plist_get_node_type(father)) |
| 623 | { | 627 | { |
| 624 | return node_child_position(father, node); | 628 | return node_child_position((node_t)father, (node_t)node); |
| 625 | } | 629 | } |
| 626 | return UINT_MAX; | 630 | return UINT_MAX; |
| 627 | } | 631 | } |
| 628 | 632 | ||
| 629 | static void _plist_array_post_insert(plist_t node, plist_t item, long n) | 633 | static void _plist_array_post_insert(plist_t node, plist_t item, long n) |
| 630 | { | 634 | { |
| 631 | ptrarray_t *pa = ((plist_data_t)((node_t)node)->data)->hashtable; | 635 | ptrarray_t *pa = (ptrarray_t*)((plist_data_t)((node_t)node)->data)->hashtable; |
| 632 | if (pa) { | 636 | if (pa) { |
| 633 | /* store pointer to item in array */ | 637 | /* store pointer to item in array */ |
| 634 | ptr_array_insert(pa, item, n); | 638 | ptr_array_insert(pa, item, n); |
| @@ -637,9 +641,9 @@ static void _plist_array_post_insert(plist_t node, plist_t item, long n) | |||
| 637 | /* make new lookup array */ | 641 | /* make new lookup array */ |
| 638 | pa = ptr_array_new(128); | 642 | pa = ptr_array_new(128); |
| 639 | plist_t current = NULL; | 643 | plist_t current = NULL; |
| 640 | for (current = (plist_t)node_first_child(node); | 644 | for (current = (plist_t)node_first_child((node_t)node); |
| 641 | pa && current; | 645 | pa && current; |
| 642 | current = (plist_t)node_next_sibling(current)) | 646 | current = (plist_t)node_next_sibling((node_t)current)) |
| 643 | { | 647 | { |
| 644 | ptr_array_add(pa, current); | 648 | ptr_array_add(pa, current); |
| 645 | } | 649 | } |
| @@ -655,13 +659,13 @@ void plist_array_set_item(plist_t node, plist_t item, uint32_t n) | |||
| 655 | plist_t old_item = plist_array_get_item(node, n); | 659 | plist_t old_item = plist_array_get_item(node, n); |
| 656 | if (old_item) | 660 | if (old_item) |
| 657 | { | 661 | { |
| 658 | int idx = plist_free_node(old_item); | 662 | int idx = plist_free_node((node_t)old_item); |
| 659 | assert(idx >= 0); | 663 | assert(idx >= 0); |
| 660 | if (idx < 0) { | 664 | if (idx < 0) { |
| 661 | return; | 665 | return; |
| 662 | } | 666 | } |
| 663 | node_insert(node, idx, item); | 667 | node_insert((node_t)node, idx, (node_t)item); |
| 664 | ptrarray_t* pa = ((plist_data_t)((node_t)node)->data)->hashtable; | 668 | ptrarray_t* pa = (ptrarray_t*)((plist_data_t)((node_t)node)->data)->hashtable; |
| 665 | if (pa) { | 669 | if (pa) { |
| 666 | ptr_array_set(pa, item, idx); | 670 | ptr_array_set(pa, item, idx); |
| 667 | } | 671 | } |
| @@ -673,7 +677,7 @@ void plist_array_append_item(plist_t node, plist_t item) | |||
| 673 | { | 677 | { |
| 674 | if (node && PLIST_ARRAY == plist_get_node_type(node)) | 678 | if (node && PLIST_ARRAY == plist_get_node_type(node)) |
| 675 | { | 679 | { |
| 676 | node_attach(node, item); | 680 | node_attach((node_t)node, (node_t)item); |
| 677 | _plist_array_post_insert(node, item, -1); | 681 | _plist_array_post_insert(node, item, -1); |
| 678 | } | 682 | } |
| 679 | } | 683 | } |
| @@ -682,7 +686,7 @@ void plist_array_insert_item(plist_t node, plist_t item, uint32_t n) | |||
| 682 | { | 686 | { |
| 683 | if (node && PLIST_ARRAY == plist_get_node_type(node) && n < INT_MAX) | 687 | if (node && PLIST_ARRAY == plist_get_node_type(node) && n < INT_MAX) |
| 684 | { | 688 | { |
| 685 | node_insert(node, n, item); | 689 | node_insert((node_t)node, n, (node_t)item); |
| 686 | _plist_array_post_insert(node, item, (long)n); | 690 | _plist_array_post_insert(node, item, (long)n); |
| 687 | } | 691 | } |
| 688 | } | 692 | } |
| @@ -694,7 +698,7 @@ void plist_array_remove_item(plist_t node, uint32_t n) | |||
| 694 | plist_t old_item = plist_array_get_item(node, n); | 698 | plist_t old_item = plist_array_get_item(node, n); |
| 695 | if (old_item) | 699 | if (old_item) |
| 696 | { | 700 | { |
| 697 | ptrarray_t* pa = ((plist_data_t)((node_t)node)->data)->hashtable; | 701 | ptrarray_t* pa = (ptrarray_t*)((plist_data_t)((node_t)node)->data)->hashtable; |
| 698 | if (pa) { | 702 | if (pa) { |
| 699 | ptr_array_remove(pa, n); | 703 | ptr_array_remove(pa, n); |
| 700 | } | 704 | } |
| @@ -708,9 +712,9 @@ void plist_array_item_remove(plist_t node) | |||
| 708 | plist_t father = plist_get_parent(node); | 712 | plist_t father = plist_get_parent(node); |
| 709 | if (PLIST_ARRAY == plist_get_node_type(father)) | 713 | if (PLIST_ARRAY == plist_get_node_type(father)) |
| 710 | { | 714 | { |
| 711 | int n = node_child_position(father, node); | 715 | int n = node_child_position((node_t)father, (node_t)node); |
| 712 | if (n < 0) return; | 716 | if (n < 0) return; |
| 713 | ptrarray_t* pa = ((plist_data_t)((node_t)father)->data)->hashtable; | 717 | ptrarray_t* pa = (ptrarray_t*)((plist_data_t)((node_t)father)->data)->hashtable; |
| 714 | if (pa) { | 718 | if (pa) { |
| 715 | ptr_array_remove(pa, n); | 719 | ptr_array_remove(pa, n); |
| 716 | } | 720 | } |
| @@ -723,7 +727,7 @@ void plist_array_new_iter(plist_t node, plist_array_iter *iter) | |||
| 723 | if (iter) | 727 | if (iter) |
| 724 | { | 728 | { |
| 725 | *iter = malloc(sizeof(node_t)); | 729 | *iter = malloc(sizeof(node_t)); |
| 726 | *((node_t*)(*iter)) = node_first_child(node); | 730 | *((node_t*)(*iter)) = node_first_child((node_t)node); |
| 727 | } | 731 | } |
| 728 | } | 732 | } |
| 729 | 733 | ||
| @@ -751,7 +755,7 @@ uint32_t plist_dict_get_size(plist_t node) | |||
| 751 | uint32_t ret = 0; | 755 | uint32_t ret = 0; |
| 752 | if (node && PLIST_DICT == plist_get_node_type(node)) | 756 | if (node && PLIST_DICT == plist_get_node_type(node)) |
| 753 | { | 757 | { |
| 754 | ret = node_n_children(node) / 2; | 758 | ret = node_n_children((node_t)node) / 2; |
| 755 | } | 759 | } |
| 756 | return ret; | 760 | return ret; |
| 757 | } | 761 | } |
| @@ -761,7 +765,7 @@ void plist_dict_new_iter(plist_t node, plist_dict_iter *iter) | |||
| 761 | if (iter) | 765 | if (iter) |
| 762 | { | 766 | { |
| 763 | *iter = malloc(sizeof(node_t)); | 767 | *iter = malloc(sizeof(node_t)); |
| 764 | *((node_t*)(*iter)) = node_first_child(node); | 768 | *((node_t*)(*iter)) = node_first_child((node_t)node); |
| 765 | } | 769 | } |
| 766 | } | 770 | } |
| 767 | 771 | ||
| @@ -798,7 +802,7 @@ void plist_dict_get_item_key(plist_t node, char **key) | |||
| 798 | plist_t father = plist_get_parent(node); | 802 | plist_t father = plist_get_parent(node); |
| 799 | if (PLIST_DICT == plist_get_node_type(father)) | 803 | if (PLIST_DICT == plist_get_node_type(father)) |
| 800 | { | 804 | { |
| 801 | plist_get_key_val( (plist_t) node_prev_sibling(node), key); | 805 | plist_get_key_val( (plist_t) node_prev_sibling((node_t)node), key); |
| 802 | } | 806 | } |
| 803 | } | 807 | } |
| 804 | 808 | ||
| @@ -808,7 +812,7 @@ plist_t plist_dict_item_get_key(plist_t node) | |||
| 808 | plist_t father = plist_get_parent(node); | 812 | plist_t father = plist_get_parent(node); |
| 809 | if (PLIST_DICT == plist_get_node_type(father)) | 813 | if (PLIST_DICT == plist_get_node_type(father)) |
| 810 | { | 814 | { |
| 811 | ret = (plist_t)node_prev_sibling(node); | 815 | ret = (plist_t)node_prev_sibling((node_t)node); |
| 812 | } | 816 | } |
| 813 | return ret; | 817 | return ret; |
| 814 | } | 818 | } |
| @@ -828,16 +832,16 @@ plist_t plist_dict_get_item(plist_t node, const char* key) | |||
| 828 | ret = (plist_t)hash_table_lookup(ht, &sdata); | 832 | ret = (plist_t)hash_table_lookup(ht, &sdata); |
| 829 | } else { | 833 | } else { |
| 830 | plist_t current = NULL; | 834 | plist_t current = NULL; |
| 831 | for (current = (plist_t)node_first_child(node); | 835 | for (current = (plist_t)node_first_child((node_t)node); |
| 832 | current; | 836 | current; |
| 833 | current = (plist_t)node_next_sibling(node_next_sibling(current))) | 837 | current = (plist_t)node_next_sibling(node_next_sibling((node_t)current))) |
| 834 | { | 838 | { |
| 835 | data = plist_get_data(current); | 839 | data = plist_get_data(current); |
| 836 | assert( PLIST_KEY == plist_get_node_type(current) ); | 840 | assert( PLIST_KEY == plist_get_node_type(current) ); |
| 837 | 841 | ||
| 838 | if (data && !strcmp(key, data->strval)) | 842 | if (data && !strcmp(key, data->strval)) |
| 839 | { | 843 | { |
| 840 | ret = (plist_t)node_next_sibling(current); | 844 | ret = (plist_t)node_next_sibling((node_t)current); |
| 841 | break; | 845 | break; |
| 842 | } | 846 | } |
| 843 | } | 847 | } |
| @@ -849,23 +853,23 @@ plist_t plist_dict_get_item(plist_t node, const char* key) | |||
| 849 | void plist_dict_set_item(plist_t node, const char* key, plist_t item) | 853 | void plist_dict_set_item(plist_t node, const char* key, plist_t item) |
| 850 | { | 854 | { |
| 851 | if (node && PLIST_DICT == plist_get_node_type(node)) { | 855 | if (node && PLIST_DICT == plist_get_node_type(node)) { |
| 852 | node_t old_item = plist_dict_get_item(node, key); | 856 | plist_t old_item = plist_dict_get_item(node, key); |
| 853 | plist_t key_node = NULL; | 857 | plist_t key_node = NULL; |
| 854 | if (old_item) { | 858 | if (old_item) { |
| 855 | int idx = plist_free_node(old_item); | 859 | int idx = plist_free_node((node_t)old_item); |
| 856 | assert(idx >= 0); | 860 | assert(idx >= 0); |
| 857 | if (idx < 0) { | 861 | if (idx < 0) { |
| 858 | return; | 862 | return; |
| 859 | } | 863 | } |
| 860 | node_insert(node, idx, item); | 864 | node_insert((node_t)node, idx, (node_t)item); |
| 861 | key_node = node_prev_sibling(item); | 865 | key_node = node_prev_sibling((node_t)item); |
| 862 | } else { | 866 | } else { |
| 863 | key_node = plist_new_key(key); | 867 | key_node = plist_new_key(key); |
| 864 | node_attach(node, key_node); | 868 | node_attach((node_t)node, (node_t)key_node); |
| 865 | node_attach(node, item); | 869 | node_attach((node_t)node, (node_t)item); |
| 866 | } | 870 | } |
| 867 | 871 | ||
| 868 | hashtable_t *ht = ((plist_data_t)((node_t)node)->data)->hashtable; | 872 | hashtable_t *ht = (hashtable_t*)((plist_data_t)((node_t)node)->data)->hashtable; |
| 869 | if (ht) { | 873 | if (ht) { |
| 870 | /* store pointer to item in hash table */ | 874 | /* store pointer to item in hash table */ |
| 871 | hash_table_insert(ht, (plist_data_t)((node_t)key_node)->data, item); | 875 | hash_table_insert(ht, (plist_data_t)((node_t)key_node)->data, item); |
| @@ -875,11 +879,11 @@ void plist_dict_set_item(plist_t node, const char* key, plist_t item) | |||
| 875 | ht = hash_table_new(dict_key_hash, dict_key_compare, NULL); | 879 | ht = hash_table_new(dict_key_hash, dict_key_compare, NULL); |
| 876 | /* calculate the hashes for all entries we have so far */ | 880 | /* calculate the hashes for all entries we have so far */ |
| 877 | plist_t current = NULL; | 881 | plist_t current = NULL; |
| 878 | for (current = (plist_t)node_first_child(node); | 882 | for (current = (plist_t)node_first_child((node_t)node); |
| 879 | ht && current; | 883 | ht && current; |
| 880 | current = (plist_t)node_next_sibling(node_next_sibling(current))) | 884 | current = (plist_t)node_next_sibling(node_next_sibling((node_t)current))) |
| 881 | { | 885 | { |
| 882 | hash_table_insert(ht, ((node_t)current)->data, node_next_sibling(current)); | 886 | hash_table_insert(ht, ((node_t)current)->data, node_next_sibling((node_t)current)); |
| 883 | } | 887 | } |
| 884 | ((plist_data_t)((node_t)node)->data)->hashtable = ht; | 888 | ((plist_data_t)((node_t)node)->data)->hashtable = ht; |
| 885 | } | 889 | } |
| @@ -894,8 +898,8 @@ void plist_dict_remove_item(plist_t node, const char* key) | |||
| 894 | plist_t old_item = plist_dict_get_item(node, key); | 898 | plist_t old_item = plist_dict_get_item(node, key); |
| 895 | if (old_item) | 899 | if (old_item) |
| 896 | { | 900 | { |
| 897 | plist_t key_node = node_prev_sibling(old_item); | 901 | plist_t key_node = node_prev_sibling((node_t)old_item); |
| 898 | hashtable_t* ht = ((plist_data_t)((node_t)node)->data)->hashtable; | 902 | hashtable_t* ht = (hashtable_t*)((plist_data_t)((node_t)node)->data)->hashtable; |
| 899 | if (ht) { | 903 | if (ht) { |
| 900 | hash_table_remove(ht, ((node_t)key_node)->data); | 904 | hash_table_remove(ht, ((node_t)key_node)->data); |
| 901 | } | 905 | } |
diff --git a/src/ptrarray.c b/src/ptrarray.c index c499773..3a11031 100644 --- a/src/ptrarray.c +++ b/src/ptrarray.c | |||
| @@ -45,7 +45,7 @@ void ptr_array_insert(ptrarray_t *pa, void *data, long array_index) | |||
| 45 | if (!pa || !pa->pdata) return; | 45 | if (!pa || !pa->pdata) return; |
| 46 | long remaining = pa->capacity-pa->len; | 46 | long remaining = pa->capacity-pa->len; |
| 47 | if (remaining == 0) { | 47 | if (remaining == 0) { |
| 48 | pa->pdata = realloc(pa->pdata, sizeof(void*) * (pa->capacity + pa->capacity_step)); | 48 | pa->pdata = (void**)realloc(pa->pdata, sizeof(void*) * (pa->capacity + pa->capacity_step)); |
| 49 | pa->capacity += pa->capacity_step; | 49 | pa->capacity += pa->capacity_step; |
| 50 | } | 50 | } |
| 51 | if (array_index < 0 || array_index >= pa->len) { | 51 | if (array_index < 0 || array_index >= pa->len) { |
diff --git a/src/xplist.c b/src/xplist.c index 4833a92..66e1dba 100644 --- a/src/xplist.c +++ b/src/xplist.c | |||
| @@ -133,7 +133,7 @@ static size_t dtostr(char *buf, size_t bufsize, double realval) | |||
| 133 | return len; | 133 | return len; |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | static int node_to_xml(node_t node, bytearray_t **outbuf, uint32_t depth) | 136 | static plist_err_t node_to_xml(node_t node, bytearray_t **outbuf, uint32_t depth) |
| 137 | { | 137 | { |
| 138 | plist_data_t node_data = NULL; | 138 | plist_data_t node_data = NULL; |
| 139 | 139 | ||
| @@ -366,7 +366,7 @@ static int node_to_xml(node_t node, bytearray_t **outbuf, uint32_t depth) | |||
| 366 | } | 366 | } |
| 367 | node_t ch; | 367 | node_t ch; |
| 368 | for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) { | 368 | for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) { |
| 369 | int res = node_to_xml(ch, outbuf, depth+1); | 369 | plist_err_t res = node_to_xml(ch, outbuf, depth+1); |
| 370 | if (res < 0) return res; | 370 | if (res < 0) return res; |
| 371 | } | 371 | } |
| 372 | 372 | ||
| @@ -444,7 +444,7 @@ static int num_digits_u(uint64_t i) | |||
| 444 | return n; | 444 | return n; |
| 445 | } | 445 | } |
| 446 | 446 | ||
| 447 | static int node_estimate_size(node_t node, uint64_t *size, uint32_t depth) | 447 | static plist_err_t node_estimate_size(node_t node, uint64_t *size, uint32_t depth) |
| 448 | { | 448 | { |
| 449 | plist_data_t data; | 449 | plist_data_t data; |
| 450 | if (!node) { | 450 | if (!node) { |
| @@ -532,13 +532,13 @@ static int node_estimate_size(node_t node, uint64_t *size, uint32_t depth) | |||
| 532 | plist_err_t plist_to_xml(plist_t plist, char **plist_xml, uint32_t * length) | 532 | plist_err_t plist_to_xml(plist_t plist, char **plist_xml, uint32_t * length) |
| 533 | { | 533 | { |
| 534 | uint64_t size = 0; | 534 | uint64_t size = 0; |
| 535 | int res; | 535 | plist_err_t res; |
| 536 | 536 | ||
| 537 | if (!plist || !plist_xml || !length) { | 537 | if (!plist || !plist_xml || !length) { |
| 538 | return PLIST_ERR_INVALID_ARG; | 538 | return PLIST_ERR_INVALID_ARG; |
| 539 | } | 539 | } |
| 540 | 540 | ||
| 541 | res = node_estimate_size(plist, &size, 0); | 541 | res = node_estimate_size((node_t)plist, &size, 0); |
| 542 | if (res < 0) { | 542 | if (res < 0) { |
| 543 | return res; | 543 | return res; |
| 544 | } | 544 | } |
| @@ -552,7 +552,7 @@ plist_err_t plist_to_xml(plist_t plist, char **plist_xml, uint32_t * length) | |||
| 552 | 552 | ||
| 553 | str_buf_append(outbuf, XML_PLIST_PROLOG, sizeof(XML_PLIST_PROLOG)-1); | 553 | str_buf_append(outbuf, XML_PLIST_PROLOG, sizeof(XML_PLIST_PROLOG)-1); |
| 554 | 554 | ||
| 555 | res = node_to_xml(plist, &outbuf, 0); | 555 | res = node_to_xml((node_t)plist, &outbuf, 0); |
| 556 | if (res < 0) { | 556 | if (res < 0) { |
| 557 | str_buf_free(outbuf); | 557 | str_buf_free(outbuf); |
| 558 | *plist_xml = NULL; | 558 | *plist_xml = NULL; |
| @@ -562,7 +562,7 @@ plist_err_t plist_to_xml(plist_t plist, char **plist_xml, uint32_t * length) | |||
| 562 | 562 | ||
| 563 | str_buf_append(outbuf, XML_PLIST_EPILOG, sizeof(XML_PLIST_EPILOG)); | 563 | str_buf_append(outbuf, XML_PLIST_EPILOG, sizeof(XML_PLIST_EPILOG)); |
| 564 | 564 | ||
| 565 | *plist_xml = outbuf->data; | 565 | *plist_xml = (char*)outbuf->data; |
| 566 | *length = outbuf->len - 1; | 566 | *length = outbuf->len - 1; |
| 567 | 567 | ||
| 568 | outbuf->data = NULL; | 568 | outbuf->data = NULL; |
| @@ -671,14 +671,14 @@ static void text_parts_free(text_part_t *tp) | |||
| 671 | { | 671 | { |
| 672 | while (tp) { | 672 | while (tp) { |
| 673 | text_part_t *tmp = tp; | 673 | text_part_t *tmp = tp; |
| 674 | tp = tp->next; | 674 | tp = (text_part_t*)tp->next; |
| 675 | free(tmp); | 675 | free(tmp); |
| 676 | } | 676 | } |
| 677 | } | 677 | } |
| 678 | 678 | ||
| 679 | static text_part_t* text_part_append(text_part_t* parts, const char *begin, size_t length, int is_cdata) | 679 | static text_part_t* text_part_append(text_part_t* parts, const char *begin, size_t length, int is_cdata) |
| 680 | { | 680 | { |
| 681 | text_part_t* newpart = malloc(sizeof(text_part_t)); | 681 | text_part_t* newpart = (text_part_t*)malloc(sizeof(text_part_t)); |
| 682 | assert(newpart); | 682 | assert(newpart); |
| 683 | parts->next = text_part_init(newpart, begin, length, is_cdata); | 683 | parts->next = text_part_init(newpart, begin, length, is_cdata); |
| 684 | return newpart; | 684 | return newpart; |
| @@ -930,9 +930,9 @@ static char* text_parts_get_content(text_part_t *tp, int unesc_entities, size_t | |||
| 930 | text_part_t *tmp = tp; | 930 | text_part_t *tmp = tp; |
| 931 | while (tp && tp->begin) { | 931 | while (tp && tp->begin) { |
| 932 | total_length += tp->length; | 932 | total_length += tp->length; |
| 933 | tp = tp->next; | 933 | tp = (text_part_t*)tp->next; |
| 934 | } | 934 | } |
| 935 | str = malloc(total_length + 1); | 935 | str = (char*)malloc(total_length + 1); |
| 936 | assert(str); | 936 | assert(str); |
| 937 | p = str; | 937 | p = str; |
| 938 | tp = tmp; | 938 | tp = tmp; |
| @@ -947,7 +947,7 @@ static char* text_parts_get_content(text_part_t *tp, int unesc_entities, size_t | |||
| 947 | } | 947 | } |
| 948 | } | 948 | } |
| 949 | p += len; | 949 | p += len; |
| 950 | tp = tp->next; | 950 | tp = (text_part_t*)tp->next; |
| 951 | } | 951 | } |
| 952 | *p = '\0'; | 952 | *p = '\0'; |
| 953 | if (length) { | 953 | if (length) { |
| @@ -959,7 +959,7 @@ static char* text_parts_get_content(text_part_t *tp, int unesc_entities, size_t | |||
| 959 | return str; | 959 | return str; |
| 960 | } | 960 | } |
| 961 | 961 | ||
| 962 | static int node_from_xml(parse_ctx ctx, plist_t *plist) | 962 | static plist_err_t node_from_xml(parse_ctx ctx, plist_t *plist) |
| 963 | { | 963 | { |
| 964 | char *tag = NULL; | 964 | char *tag = NULL; |
| 965 | char *keyname = NULL; | 965 | char *keyname = NULL; |
| @@ -1067,7 +1067,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist) | |||
| 1067 | goto err_out; | 1067 | goto err_out; |
| 1068 | } | 1068 | } |
| 1069 | int taglen = ctx->pos - p; | 1069 | int taglen = ctx->pos - p; |
| 1070 | tag = malloc(taglen + 1); | 1070 | tag = (char*)malloc(taglen + 1); |
| 1071 | strncpy(tag, p, taglen); | 1071 | strncpy(tag, p, taglen); |
| 1072 | tag[taglen] = '\0'; | 1072 | tag[taglen] = '\0'; |
| 1073 | if (*ctx->pos != '>') { | 1073 | if (*ctx->pos != '>') { |
| @@ -1105,7 +1105,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist) | |||
| 1105 | goto err_out; | 1105 | goto err_out; |
| 1106 | } | 1106 | } |
| 1107 | 1107 | ||
| 1108 | struct node_path_item *path_item = malloc(sizeof(struct node_path_item)); | 1108 | struct node_path_item *path_item = (struct node_path_item*)malloc(sizeof(struct node_path_item)); |
| 1109 | if (!path_item) { | 1109 | if (!path_item) { |
| 1110 | PLIST_XML_ERR("out of memory when allocating node path item\n"); | 1110 | PLIST_XML_ERR("out of memory when allocating node path item\n"); |
| 1111 | ctx->err++; | 1111 | ctx->err++; |
| @@ -1133,7 +1133,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist) | |||
| 1133 | goto err_out; | 1133 | goto err_out; |
| 1134 | } | 1134 | } |
| 1135 | struct node_path_item *path_item = node_path; | 1135 | struct node_path_item *path_item = node_path; |
| 1136 | node_path = node_path->prev; | 1136 | node_path = (struct node_path_item*)node_path->prev; |
| 1137 | free(path_item); | 1137 | free(path_item); |
| 1138 | 1138 | ||
| 1139 | free(tag); | 1139 | free(tag); |
| @@ -1156,7 +1156,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist) | |||
| 1156 | text_part_t *tp = get_text_parts(ctx, tag, taglen, 1, &first_part); | 1156 | text_part_t *tp = get_text_parts(ctx, tag, taglen, 1, &first_part); |
| 1157 | if (!tp) { | 1157 | if (!tp) { |
| 1158 | PLIST_XML_ERR("Could not parse text content for '%s' node\n", tag); | 1158 | PLIST_XML_ERR("Could not parse text content for '%s' node\n", tag); |
| 1159 | text_parts_free(first_part.next); | 1159 | text_parts_free((text_part_t*)first_part.next); |
| 1160 | ctx->err++; | 1160 | ctx->err++; |
| 1161 | goto err_out; | 1161 | goto err_out; |
| 1162 | } | 1162 | } |
| @@ -1165,7 +1165,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist) | |||
| 1165 | char *str_content = text_parts_get_content(tp, 0, NULL, &requires_free); | 1165 | char *str_content = text_parts_get_content(tp, 0, NULL, &requires_free); |
| 1166 | if (!str_content) { | 1166 | if (!str_content) { |
| 1167 | PLIST_XML_ERR("Could not get text content for '%s' node\n", tag); | 1167 | PLIST_XML_ERR("Could not get text content for '%s' node\n", tag); |
| 1168 | text_parts_free(first_part.next); | 1168 | text_parts_free((text_part_t*)first_part.next); |
| 1169 | ctx->err++; | 1169 | ctx->err++; |
| 1170 | goto err_out; | 1170 | goto err_out; |
| 1171 | } | 1171 | } |
| @@ -1194,7 +1194,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist) | |||
| 1194 | } else { | 1194 | } else { |
| 1195 | is_empty = 1; | 1195 | is_empty = 1; |
| 1196 | } | 1196 | } |
| 1197 | text_parts_free(tp->next); | 1197 | text_parts_free((text_part_t*)tp->next); |
| 1198 | } | 1198 | } |
| 1199 | if (is_empty) { | 1199 | if (is_empty) { |
| 1200 | data->intval = 0; | 1200 | data->intval = 0; |
| @@ -1207,7 +1207,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist) | |||
| 1207 | text_part_t *tp = get_text_parts(ctx, tag, taglen, 1, &first_part); | 1207 | text_part_t *tp = get_text_parts(ctx, tag, taglen, 1, &first_part); |
| 1208 | if (!tp) { | 1208 | if (!tp) { |
| 1209 | PLIST_XML_ERR("Could not parse text content for '%s' node\n", tag); | 1209 | PLIST_XML_ERR("Could not parse text content for '%s' node\n", tag); |
| 1210 | text_parts_free(first_part.next); | 1210 | text_parts_free((text_part_t*)first_part.next); |
| 1211 | ctx->err++; | 1211 | ctx->err++; |
| 1212 | goto err_out; | 1212 | goto err_out; |
| 1213 | } | 1213 | } |
| @@ -1216,7 +1216,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist) | |||
| 1216 | char *str_content = text_parts_get_content(tp, 0, NULL, &requires_free); | 1216 | char *str_content = text_parts_get_content(tp, 0, NULL, &requires_free); |
| 1217 | if (!str_content) { | 1217 | if (!str_content) { |
| 1218 | PLIST_XML_ERR("Could not get text content for '%s' node\n", tag); | 1218 | PLIST_XML_ERR("Could not get text content for '%s' node\n", tag); |
| 1219 | text_parts_free(first_part.next); | 1219 | text_parts_free((text_part_t*)first_part.next); |
| 1220 | ctx->err++; | 1220 | ctx->err++; |
| 1221 | goto err_out; | 1221 | goto err_out; |
| 1222 | } | 1222 | } |
| @@ -1225,7 +1225,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist) | |||
| 1225 | free(str_content); | 1225 | free(str_content); |
| 1226 | } | 1226 | } |
| 1227 | } | 1227 | } |
| 1228 | text_parts_free(tp->next); | 1228 | text_parts_free((text_part_t*)tp->next); |
| 1229 | } | 1229 | } |
| 1230 | data->type = PLIST_REAL; | 1230 | data->type = PLIST_REAL; |
| 1231 | data->length = 8; | 1231 | data->length = 8; |
| @@ -1251,12 +1251,12 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist) | |||
| 1251 | size_t length = 0; | 1251 | size_t length = 0; |
| 1252 | if (!tp) { | 1252 | if (!tp) { |
| 1253 | PLIST_XML_ERR("Could not parse text content for '%s' node\n", tag); | 1253 | PLIST_XML_ERR("Could not parse text content for '%s' node\n", tag); |
| 1254 | text_parts_free(first_part.next); | 1254 | text_parts_free((text_part_t*)first_part.next); |
| 1255 | ctx->err++; | 1255 | ctx->err++; |
| 1256 | goto err_out; | 1256 | goto err_out; |
| 1257 | } | 1257 | } |
| 1258 | str = text_parts_get_content(tp, 1, &length, NULL); | 1258 | str = text_parts_get_content(tp, 1, &length, NULL); |
| 1259 | text_parts_free(first_part.next); | 1259 | text_parts_free((text_part_t*)first_part.next); |
| 1260 | if (!str) { | 1260 | if (!str) { |
| 1261 | PLIST_XML_ERR("Could not get text content for '%s' node\n", tag); | 1261 | PLIST_XML_ERR("Could not get text content for '%s' node\n", tag); |
| 1262 | ctx->err++; | 1262 | ctx->err++; |
| @@ -1284,7 +1284,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist) | |||
| 1284 | text_part_t *tp = get_text_parts(ctx, tag, taglen, 1, &first_part); | 1284 | text_part_t *tp = get_text_parts(ctx, tag, taglen, 1, &first_part); |
| 1285 | if (!tp) { | 1285 | if (!tp) { |
| 1286 | PLIST_XML_ERR("Could not parse text content for '%s' node\n", tag); | 1286 | PLIST_XML_ERR("Could not parse text content for '%s' node\n", tag); |
| 1287 | text_parts_free(first_part.next); | 1287 | text_parts_free((text_part_t*)first_part.next); |
| 1288 | ctx->err++; | 1288 | ctx->err++; |
| 1289 | goto err_out; | 1289 | goto err_out; |
| 1290 | } | 1290 | } |
| @@ -1293,7 +1293,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist) | |||
| 1293 | char *str_content = text_parts_get_content(tp, 0, NULL, &requires_free); | 1293 | char *str_content = text_parts_get_content(tp, 0, NULL, &requires_free); |
| 1294 | if (!str_content) { | 1294 | if (!str_content) { |
| 1295 | PLIST_XML_ERR("Could not get text content for '%s' node\n", tag); | 1295 | PLIST_XML_ERR("Could not get text content for '%s' node\n", tag); |
| 1296 | text_parts_free(first_part.next); | 1296 | text_parts_free((text_part_t*)first_part.next); |
| 1297 | ctx->err++; | 1297 | ctx->err++; |
| 1298 | goto err_out; | 1298 | goto err_out; |
| 1299 | } | 1299 | } |
| @@ -1307,7 +1307,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist) | |||
| 1307 | free(str_content); | 1307 | free(str_content); |
| 1308 | } | 1308 | } |
| 1309 | } | 1309 | } |
| 1310 | text_parts_free(tp->next); | 1310 | text_parts_free((text_part_t*)tp->next); |
| 1311 | } | 1311 | } |
| 1312 | data->type = PLIST_DATA; | 1312 | data->type = PLIST_DATA; |
| 1313 | } else if (!strcmp(tag, XPLIST_DATE)) { | 1313 | } else if (!strcmp(tag, XPLIST_DATE)) { |
| @@ -1316,7 +1316,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist) | |||
| 1316 | text_part_t *tp = get_text_parts(ctx, tag, taglen, 1, &first_part); | 1316 | text_part_t *tp = get_text_parts(ctx, tag, taglen, 1, &first_part); |
| 1317 | if (!tp) { | 1317 | if (!tp) { |
| 1318 | PLIST_XML_ERR("Could not parse text content for '%s' node\n", tag); | 1318 | PLIST_XML_ERR("Could not parse text content for '%s' node\n", tag); |
| 1319 | text_parts_free(first_part.next); | 1319 | text_parts_free((text_part_t*)first_part.next); |
| 1320 | ctx->err++; | 1320 | ctx->err++; |
| 1321 | goto err_out; | 1321 | goto err_out; |
| 1322 | } | 1322 | } |
| @@ -1327,7 +1327,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist) | |||
| 1327 | char *str_content = text_parts_get_content(tp, 0, &length, &requires_free); | 1327 | char *str_content = text_parts_get_content(tp, 0, &length, &requires_free); |
| 1328 | if (!str_content) { | 1328 | if (!str_content) { |
| 1329 | PLIST_XML_ERR("Could not get text content for '%s' node\n", tag); | 1329 | PLIST_XML_ERR("Could not get text content for '%s' node\n", tag); |
| 1330 | text_parts_free(first_part.next); | 1330 | text_parts_free((text_part_t*)first_part.next); |
| 1331 | ctx->err++; | 1331 | ctx->err++; |
| 1332 | goto err_out; | 1332 | goto err_out; |
| 1333 | } | 1333 | } |
| @@ -1347,7 +1347,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist) | |||
| 1347 | free(str_content); | 1347 | free(str_content); |
| 1348 | } | 1348 | } |
| 1349 | } | 1349 | } |
| 1350 | text_parts_free(tp->next); | 1350 | text_parts_free((text_part_t*)tp->next); |
| 1351 | data->realval = (double)(timev - MAC_EPOCH); | 1351 | data->realval = (double)(timev - MAC_EPOCH); |
| 1352 | } | 1352 | } |
| 1353 | data->length = sizeof(double); | 1353 | data->length = sizeof(double); |
| @@ -1391,7 +1391,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist) | |||
| 1391 | } | 1391 | } |
| 1392 | } | 1392 | } |
| 1393 | if (!is_empty && (data->type == PLIST_DICT || data->type == PLIST_ARRAY)) { | 1393 | if (!is_empty && (data->type == PLIST_DICT || data->type == PLIST_ARRAY)) { |
| 1394 | struct node_path_item *path_item = malloc(sizeof(struct node_path_item)); | 1394 | struct node_path_item *path_item = (struct node_path_item*)malloc(sizeof(struct node_path_item)); |
| 1395 | if (!path_item) { | 1395 | if (!path_item) { |
| 1396 | PLIST_XML_ERR("out of memory when allocating node path item\n"); | 1396 | PLIST_XML_ERR("out of memory when allocating node path item\n"); |
| 1397 | ctx->err++; | 1397 | ctx->err++; |
| @@ -1416,7 +1416,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist) | |||
| 1416 | goto err_out; | 1416 | goto err_out; |
| 1417 | } | 1417 | } |
| 1418 | struct node_path_item *path_item = node_path; | 1418 | struct node_path_item *path_item = node_path; |
| 1419 | node_path = node_path->prev; | 1419 | node_path = (struct node_path_item*)node_path->prev; |
| 1420 | free(path_item); | 1420 | free(path_item); |
| 1421 | 1421 | ||
| 1422 | parent = ((node_t)parent)->parent; | 1422 | parent = ((node_t)parent)->parent; |
| @@ -1447,7 +1447,7 @@ err_out: | |||
| 1447 | /* clean up node_path if required */ | 1447 | /* clean up node_path if required */ |
| 1448 | while (node_path) { | 1448 | while (node_path) { |
| 1449 | struct node_path_item *path_item = node_path; | 1449 | struct node_path_item *path_item = node_path; |
| 1450 | node_path = path_item->prev; | 1450 | node_path = (struct node_path_item*)path_item->prev; |
| 1451 | free(path_item); | 1451 | free(path_item); |
| 1452 | } | 1452 | } |
| 1453 | 1453 | ||
