summaryrefslogtreecommitdiffstats
path: root/src/bplist.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bplist.c')
-rw-r--r--src/bplist.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/bplist.c b/src/bplist.c
index 6b2d2f3..f993d9e 100644
--- a/src/bplist.c
+++ b/src/bplist.c
@@ -80,7 +80,7 @@ static void byte_convert(uint8_t * address, size_t size)
80static uint32_t uint24_from_be(char *buff) 80static uint32_t uint24_from_be(char *buff)
81{ 81{
82 uint32_t ret = 0; 82 uint32_t ret = 0;
83 char *tmp = (char*) &ret; 83 char *tmp = (char *) &ret;
84 memcpy(tmp + 1, buff, 3 * sizeof(char)); 84 memcpy(tmp + 1, buff, 3 * sizeof(char));
85 byte_convert(tmp, sizeof(uint32_t)); 85 byte_convert(tmp, sizeof(uint32_t));
86 return ret; 86 return ret;
@@ -137,13 +137,13 @@ static plist_t parse_real_node(char *bnode, uint8_t size)
137 size = 1 << size; // make length less misleading 137 size = 1 << size; // make length less misleading
138 switch (size) { 138 switch (size) {
139 case sizeof(float): 139 case sizeof(float):
140 floatval = *(float*)bnode; 140 floatval = *(float *) bnode;
141 byte_convert((uint8_t*)&floatval, sizeof(float)); 141 byte_convert((uint8_t *) & floatval, sizeof(float));
142 data->realval = floatval; 142 data->realval = floatval;
143 break; 143 break;
144 case sizeof(double): 144 case sizeof(double):
145 data->realval = *(double*)bnode; 145 data->realval = *(double *) bnode;
146 byte_convert((uint8_t*)&(data->realval), sizeof(double)); 146 byte_convert((uint8_t *) & (data->realval), sizeof(double));
147 break; 147 break;
148 default: 148 default:
149 free(data); 149 free(data);
@@ -197,7 +197,7 @@ static plist_t parse_unicode_node(char *bnode, uint64_t size)
197 unicodestr = (gunichar2 *) malloc(sizeof(gunichar2) * size); 197 unicodestr = (gunichar2 *) malloc(sizeof(gunichar2) * size);
198 memcpy(unicodestr, bnode, sizeof(gunichar2) * size); 198 memcpy(unicodestr, bnode, sizeof(gunichar2) * size);
199 for (i = 0; i < size; i++) 199 for (i = 0; i < size; i++)
200 byte_convert((uint8_t*)(unicodestr + i), sizeof(gunichar2)); 200 byte_convert((uint8_t *) (unicodestr + i), sizeof(gunichar2));
201 201
202 tmpstr = g_utf16_to_utf8(unicodestr, size, &items_read, &items_written, &error); 202 tmpstr = g_utf16_to_utf8(unicodestr, size, &items_read, &items_written, &error);
203 free(unicodestr); 203 free(unicodestr);
@@ -426,7 +426,7 @@ void plist_from_bin(const char *plist_bin, uint32_t length, plist_t * plist)
426 return; 426 return;
427 427
428 //now parse trailer 428 //now parse trailer
429 trailer = (char*)(plist_bin + (length - BPLIST_TRL_SIZE)); 429 trailer = (char *) (plist_bin + (length - BPLIST_TRL_SIZE));
430 430
431 offset_size = trailer[BPLIST_TRL_OFFSIZE_IDX]; 431 offset_size = trailer[BPLIST_TRL_OFFSIZE_IDX];
432 dict_param_size = trailer[BPLIST_TRL_PARMSIZE_IDX]; 432 dict_param_size = trailer[BPLIST_TRL_PARMSIZE_IDX];
@@ -444,12 +444,12 @@ void plist_from_bin(const char *plist_bin, uint32_t length, plist_t * plist)
444 return; 444 return;
445 445
446 //parse serialized nodes 446 //parse serialized nodes
447 offset_table = (char*)(plist_bin + offset_table_index); 447 offset_table = (char *) (plist_bin + offset_table_index);
448 for (i = 0; i < num_objects; i++) { 448 for (i = 0; i < num_objects; i++) {
449 char *obj = NULL; 449 char *obj = NULL;
450 current_offset = UINT_TO_HOST(offset_table + i * offset_size, offset_size); 450 current_offset = UINT_TO_HOST(offset_table + i * offset_size, offset_size);
451 451
452 obj = (char*)(plist_bin + current_offset); 452 obj = (char *) (plist_bin + current_offset);
453 nodeslist[i] = parse_bin_node(obj, dict_param_size, &obj); 453 nodeslist[i] = parse_bin_node(obj, dict_param_size, &obj);
454 } 454 }
455 455
@@ -734,7 +734,7 @@ static void write_dict(GByteArray * bplist, GNode * node, GHashTable * ref_table
734 memcpy(buff + i * dict_param_size, &idx1, dict_param_size); 734 memcpy(buff + i * dict_param_size, &idx1, dict_param_size);
735 byte_convert(buff + i * dict_param_size, dict_param_size); 735 byte_convert(buff + i * dict_param_size, dict_param_size);
736 736
737 idx2 = *(uint64_t *)(g_hash_table_lookup(ref_table, cur->next)); 737 idx2 = *(uint64_t *) (g_hash_table_lookup(ref_table, cur->next));
738 memcpy(buff + (i + size) * dict_param_size, &idx2, dict_param_size); 738 memcpy(buff + (i + size) * dict_param_size, &idx2, dict_param_size);
739 byte_convert(buff + (i + size) * dict_param_size, dict_param_size); 739 byte_convert(buff + (i + size) * dict_param_size, dict_param_size);
740 } 740 }
@@ -828,8 +828,7 @@ void plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length)
828 unicodestr = g_utf8_to_utf16(data->strval, len, &items_read, &items_written, &error); 828 unicodestr = g_utf8_to_utf16(data->strval, len, &items_read, &items_written, &error);
829 write_unicode(bplist_buff, unicodestr, items_written); 829 write_unicode(bplist_buff, unicodestr, items_written);
830 g_free(unicodestr); 830 g_free(unicodestr);
831 } 831 } else if (XML_CHAR_ENCODING_ASCII == type || XML_CHAR_ENCODING_NONE == type) {
832 else if (XML_CHAR_ENCODING_ASCII == type || XML_CHAR_ENCODING_NONE == type) {
833 write_string(bplist_buff, data->strval); 832 write_string(bplist_buff, data->strval);
834 } 833 }
835 break; 834 break;