summaryrefslogtreecommitdiffstats
path: root/src/bplist.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bplist.c')
-rw-r--r--src/bplist.c22
1 files changed, 12 insertions, 10 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
50typedef struct __attribute__((packed)) { 50#pragma pack(push,1)
51typedef 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
59enum 61enum
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