summaryrefslogtreecommitdiffstats
path: root/src/bplist.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bplist.c')
-rw-r--r--src/bplist.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/bplist.c b/src/bplist.c
index cbe53cd..b633535 100644
--- a/src/bplist.c
+++ b/src/bplist.c
@@ -59,7 +59,7 @@ enum {
59 BPLIST_MASK = 0xF0 59 BPLIST_MASK = 0xF0
60}; 60};
61 61
62static void byte_convert(uint8_t *address, size_t size) 62static void byte_convert(uint8_t * address, size_t size)
63{ 63{
64#if G_BYTE_ORDER == G_LITTLE_ENDIAN 64#if G_BYTE_ORDER == G_LITTLE_ENDIAN
65 uint8_t i = 0, j = 0; 65 uint8_t i = 0, j = 0;
@@ -124,7 +124,7 @@ static plist_t parse_real_node(char *bnode, uint8_t size)
124 switch (size) { 124 switch (size) {
125 case sizeof(float): 125 case sizeof(float):
126 case sizeof(double): 126 case sizeof(double):
127 data->intval = UINT_TO_HOST(bnode, size); //use the fact that we have an union to cheat byte swapping 127 data->intval = UINT_TO_HOST(bnode, size); //use the fact that we have an union to cheat byte swapping
128 break; 128 break;
129 default: 129 default:
130 free(data); 130 free(data);
@@ -140,8 +140,8 @@ static plist_t parse_date_node(char *bnode, uint8_t size)
140 plist_data_t data = plist_get_data(node); 140 plist_data_t data = plist_get_data(node);
141 141
142 double time_real = data->realval; 142 double time_real = data->realval;
143 data->timeval.tv_sec = (glong)time_real; 143 data->timeval.tv_sec = (glong) time_real;
144 data->timeval.tv_usec = (time_real - (glong)time_real) * G_USEC_PER_SEC; 144 data->timeval.tv_usec = (time_real - (glong) time_real) * G_USEC_PER_SEC;
145 data->type = PLIST_DATE; 145 data->type = PLIST_DATE;
146 return node; 146 return node;
147} 147}
@@ -475,7 +475,7 @@ static guint plist_data_hash(gconstpointer key)
475 case PLIST_BOOLEAN: 475 case PLIST_BOOLEAN:
476 case PLIST_UINT: 476 case PLIST_UINT:
477 case PLIST_REAL: 477 case PLIST_REAL:
478 buff = (char *) &data->intval; //works also for real as we use an union 478 buff = (char *) &data->intval; //works also for real as we use an union
479 size = 8; 479 size = 8;
480 break; 480 break;
481 case PLIST_KEY: 481 case PLIST_KEY:
@@ -574,7 +574,7 @@ static void serialize_plist(GNode * node, gpointer data)
574 return; 574 return;
575 } 575 }
576 //insert new ref 576 //insert new ref
577 uint64_t* index_val = (uint64_t*) malloc(sizeof(uint64_t)); 577 uint64_t *index_val = (uint64_t *) malloc(sizeof(uint64_t));
578 *index_val = current_index; 578 *index_val = current_index;
579 g_hash_table_insert(ser->ref_table, node, index_val); 579 g_hash_table_insert(ser->ref_table, node, index_val);
580 580
@@ -586,9 +586,9 @@ static void serialize_plist(GNode * node, gpointer data)
586 return; 586 return;
587} 587}
588 588
589static gboolean free_index (gpointer key, gpointer value, gpointer user_data) 589static gboolean free_index(gpointer key, gpointer value, gpointer user_data)
590{ 590{
591 free((uint64_t*)value); 591 free((uint64_t *) value);
592 return TRUE; 592 return TRUE;
593} 593}
594 594
@@ -618,7 +618,7 @@ static void write_real(GByteArray * bplist, double val)
618 618
619static void write_date(GByteArray * bplist, double val) 619static void write_date(GByteArray * bplist, double val)
620{ 620{
621 uint64_t size = 8; //dates always use 8 bytes 621 uint64_t size = 8; //dates always use 8 bytes
622 uint8_t *buff = (uint8_t *) malloc(sizeof(uint8_t) + size); 622 uint8_t *buff = (uint8_t *) malloc(sizeof(uint8_t) + size);
623 buff[0] = BPLIST_DATE | Log2(size); 623 buff[0] = BPLIST_DATE | Log2(size);
624 memcpy(buff + 1, &val, size); 624 memcpy(buff + 1, &val, size);
@@ -651,7 +651,7 @@ static void write_data(GByteArray * bplist, uint8_t * val, uint64_t size)
651static void write_string(GByteArray * bplist, char *val) 651static void write_string(GByteArray * bplist, char *val)
652{ 652{
653 uint64_t size = strlen(val); 653 uint64_t size = strlen(val);
654 write_raw_data(bplist, BPLIST_STRING, (uint8_t*) val, size); 654 write_raw_data(bplist, BPLIST_STRING, (uint8_t *) val, size);
655} 655}
656 656
657static void write_array(GByteArray * bplist, GNode * node, GHashTable * ref_table, uint8_t dict_param_size) 657static void write_array(GByteArray * bplist, GNode * node, GHashTable * ref_table, uint8_t dict_param_size)
@@ -672,7 +672,7 @@ static void write_array(GByteArray * bplist, GNode * node, GHashTable * ref_tabl
672 GNode *cur = NULL; 672 GNode *cur = NULL;
673 uint64_t i = 0; 673 uint64_t i = 0;
674 for (i = 0, cur = node->children; cur && i < size; cur = cur->next, i++) { 674 for (i = 0, cur = node->children; cur && i < size; cur = cur->next, i++) {
675 idx = *(uint64_t*)(g_hash_table_lookup(ref_table, cur)); 675 idx = *(uint64_t *) (g_hash_table_lookup(ref_table, cur));
676 memcpy(buff + i * dict_param_size, &idx, dict_param_size); 676 memcpy(buff + i * dict_param_size, &idx, dict_param_size);
677 byte_convert(buff + i * dict_param_size, dict_param_size); 677 byte_convert(buff + i * dict_param_size, dict_param_size);
678 } 678 }
@@ -787,7 +787,7 @@ void plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length)
787 write_dict(bplist_buff, g_ptr_array_index(objects, i), ref_table, dict_param_size); 787 write_dict(bplist_buff, g_ptr_array_index(objects, i), ref_table, dict_param_size);
788 break; 788 break;
789 case PLIST_DATE: 789 case PLIST_DATE:
790 write_date(bplist_buff, data->timeval.tv_sec + (double)data->timeval.tv_usec / G_USEC_PER_SEC ); 790 write_date(bplist_buff, data->timeval.tv_sec + (double) data->timeval.tv_usec / G_USEC_PER_SEC);
791 break; 791 break;
792 default: 792 default:
793 break; 793 break;
@@ -795,7 +795,7 @@ void plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length)
795 } 795 }
796 796
797 //free intermediate objects 797 //free intermediate objects
798 g_hash_table_foreach_remove (ref_table, free_index, NULL); 798 g_hash_table_foreach_remove(ref_table, free_index, NULL);
799 799
800 //write offsets 800 //write offsets
801 offset_size = get_needed_bytes(bplist_buff->len); 801 offset_size = get_needed_bytes(bplist_buff->len);