summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am2
-rw-r--r--include/plist/plist.h93
-rw-r--r--plutil/plutil.c1
-rw-r--r--src/bplist.c12
-rw-r--r--src/plist.c24
-rw-r--r--src/xplist.c11
6 files changed, 71 insertions, 72 deletions
diff --git a/Makefile.am b/Makefile.am
index 830abe2..6824a32 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -9,4 +9,4 @@ doc:
9 doxygen doxygen.cfg 9 doxygen doxygen.cfg
10 10
11indent: 11indent:
12 indent -kr -ut -ts4 -l120 src/*.c src/*.h plutil/*.c 12 indent -kr -ut -ts4 -l120 src/*.c src/*.h plutil/*.c include/plist/*.h
diff --git a/include/plist/plist.h b/include/plist/plist.h
index 2c0df11..9f82cb8 100644
--- a/include/plist/plist.h
+++ b/include/plist/plist.h
@@ -39,24 +39,27 @@ extern "C" {
39/** 39/**
40 * The basic plist abstract data type. 40 * The basic plist abstract data type.
41 */ 41 */
42typedef void* plist_t; 42 typedef void *plist_t;
43 43
44/** 44/**
45 * The enumeration of plist node types. 45 * The enumeration of plist node types.
46 */ 46 */
47typedef enum { 47 typedef enum {
48 PLIST_BOOLEAN, /**< Boolean, scalar type */ 48 PLIST_BOOLEAN,
49 PLIST_UINT, /**< Unsigned integer, scalar type */ 49 /**< Boolean, scalar type */
50 PLIST_REAL, /**< Real, scalar type */ 50 PLIST_UINT, /**< Unsigned integer, scalar type */
51 PLIST_STRING, /**< ASCII string, scalar type */ 51 PLIST_REAL, /**< Real, scalar type */
52 PLIST_UNICODE, /**< Unicode strin, scalar type */ 52 PLIST_STRING,
53 PLIST_ARRAY, /**< Ordered array, structured type */ 53 /**< ASCII string, scalar type */
54 PLIST_DICT, /**< Unordered dictionary (key/value pair), structured type */ 54 PLIST_UNICODE,
55 PLIST_DATE, /**< Date, scalar type */ 55 /**< Unicode strin, scalar type */
56 PLIST_DATA, /**< Binary data, scalar type */ 56 PLIST_ARRAY,/**< Ordered array, structured type */
57 PLIST_KEY, /**< Key in dictionaries (ASCII String), scalar type */ 57 PLIST_DICT, /**< Unordered dictionary (key/value pair), structured type */
58 PLIST_NONE /**< No type */ 58 PLIST_DATE, /**< Date, scalar type */
59} plist_type; 59 PLIST_DATA, /**< Binary data, scalar type */
60 PLIST_KEY, /**< Key in dictionaries (ASCII String), scalar type */
61 PLIST_NONE /**< No type */
62 } plist_type;
60 63
61 64
62/******************************************** 65/********************************************
@@ -71,7 +74,7 @@ typedef enum {
71 * @return the created plist 74 * @return the created plist
72 * @sa #plist_type 75 * @sa #plist_type
73 */ 76 */
74plist_t plist_new_dict(); 77 plist_t plist_new_dict();
75 78
76/** 79/**
77 * Create a new root plist_t type #PLIST_ARRAY 80 * Create a new root plist_t type #PLIST_ARRAY
@@ -79,14 +82,14 @@ plist_t plist_new_dict();
79 * @return the created plist 82 * @return the created plist
80 * @sa #plist_type 83 * @sa #plist_type
81 */ 84 */
82plist_t plist_new_array(); 85 plist_t plist_new_array();
83 86
84/** 87/**
85 * Destruct a plist_t node and all its children recursively 88 * Destruct a plist_t node and all its children recursively
86 * 89 *
87 * @param plist the plist to free 90 * @param plist the plist to free
88 */ 91 */
89void plist_free(plist_t plist); 92 void plist_free(plist_t plist);
90 93
91/******************************************** 94/********************************************
92 * * 95 * *
@@ -99,7 +102,7 @@ void plist_free(plist_t plist);
99 * 102 *
100 * @param node the first child 103 * @param node the first child
101 */ 104 */
102plist_t plist_get_first_child(plist_t node); 105 plist_t plist_get_first_child(plist_t node);
103 106
104 107
105/** 108/**
@@ -107,7 +110,7 @@ plist_t plist_get_first_child(plist_t node);
107 * 110 *
108 * @param node the next sibling 111 * @param node the next sibling
109 */ 112 */
110plist_t plist_get_next_sibling(plist_t node); 113 plist_t plist_get_next_sibling(plist_t node);
111 114
112 115
113/** 116/**
@@ -115,7 +118,7 @@ plist_t plist_get_next_sibling(plist_t node);
115 * 118 *
116 * @param node the previous sibling 119 * @param node the previous sibling
117 */ 120 */
118plist_t plist_get_prev_sibling(plist_t node); 121 plist_t plist_get_prev_sibling(plist_t node);
119 122
120/******************************************** 123/********************************************
121 * * 124 * *
@@ -131,7 +134,7 @@ plist_t plist_get_prev_sibling(plist_t node);
131 * @param node the node to add a children to 134 * @param node the node to add a children to
132 * @param subnode the children node 135 * @param subnode the children node
133 */ 136 */
134void plist_add_sub_node(plist_t node, plist_t subnode); 137 void plist_add_sub_node(plist_t node, plist_t subnode);
135 138
136/** 139/**
137 * Add a subnode of type #PLIST_KEY to a node. The node must be of a structured type 140 * Add a subnode of type #PLIST_KEY to a node. The node must be of a structured type
@@ -140,7 +143,7 @@ void plist_add_sub_node(plist_t node, plist_t subnode);
140 * @param node the node to add a children to 143 * @param node the node to add a children to
141 * @param val the key value encoded as an ASCII string (must be null terminated) 144 * @param val the key value encoded as an ASCII string (must be null terminated)
142 */ 145 */
143void plist_add_sub_key_el(plist_t node, const char* val); 146 void plist_add_sub_key_el(plist_t node, const char *val);
144 147
145/** 148/**
146 * Add a subnode of type #PLIST_STRING to a node. The node must be of a structured type 149 * Add a subnode of type #PLIST_STRING to a node. The node must be of a structured type
@@ -149,7 +152,7 @@ void plist_add_sub_key_el(plist_t node, const char* val);
149 * @param node the node to add a children to 152 * @param node the node to add a children to
150 * @param val the string value encoded as an ASCII string (must be null terminated) 153 * @param val the string value encoded as an ASCII string (must be null terminated)
151 */ 154 */
152void plist_add_sub_string_el(plist_t node, const char* val); 155 void plist_add_sub_string_el(plist_t node, const char *val);
153 156
154/** 157/**
155 * Add a subnode of type #PLIST_BOOLEAN to a node. The node must be of a structured type 158 * Add a subnode of type #PLIST_BOOLEAN to a node. The node must be of a structured type
@@ -158,7 +161,7 @@ void plist_add_sub_string_el(plist_t node, const char* val);
158 * @param node the node to add a children to 161 * @param node the node to add a children to
159 * @param val the boolean value (TRUE or FALSE) 162 * @param val the boolean value (TRUE or FALSE)
160 */ 163 */
161void plist_add_sub_bool_el(plist_t node, uint8_t val); 164 void plist_add_sub_bool_el(plist_t node, uint8_t val);
162 165
163/** 166/**
164 * Add a subnode of type #PLIST_UINT to a node. The node must be of a structured type 167 * Add a subnode of type #PLIST_UINT to a node. The node must be of a structured type
@@ -167,7 +170,7 @@ void plist_add_sub_bool_el(plist_t node, uint8_t val);
167 * @param node the node to add a children to 170 * @param node the node to add a children to
168 * @param val the unsigned integer value 171 * @param val the unsigned integer value
169 */ 172 */
170void plist_add_sub_uint_el(plist_t node, uint64_t val); 173 void plist_add_sub_uint_el(plist_t node, uint64_t val);
171 174
172/** 175/**
173 * Add a subnode of type #PLIST_REAL to a node. The node must be of a structured type 176 * Add a subnode of type #PLIST_REAL to a node. The node must be of a structured type
@@ -176,7 +179,7 @@ void plist_add_sub_uint_el(plist_t node, uint64_t val);
176 * @param node the node to add a children to 179 * @param node the node to add a children to
177 * @param val the real value 180 * @param val the real value
178 */ 181 */
179void plist_add_sub_real_el(plist_t node, double val); 182 void plist_add_sub_real_el(plist_t node, double val);
180 183
181/** 184/**
182 * Add a subnode of type #PLIST_DATA to a node. The node must be of a structured type 185 * Add a subnode of type #PLIST_DATA to a node. The node must be of a structured type
@@ -186,7 +189,7 @@ void plist_add_sub_real_el(plist_t node, double val);
186 * @param val the binary buffer 189 * @param val the binary buffer
187 * @param length the length of the buffer 190 * @param length the length of the buffer
188 */ 191 */
189void plist_add_sub_data_el(plist_t node, const char* val, uint64_t length); 192 void plist_add_sub_data_el(plist_t node, const char *val, uint64_t length);
190 193
191/** 194/**
192 * Add a subnode of type #PLIST_UNICODE to a node. The node must be of a structured type 195 * Add a subnode of type #PLIST_UNICODE to a node. The node must be of a structured type
@@ -195,7 +198,7 @@ void plist_add_sub_data_el(plist_t node, const char* val, uint64_t length);
195 * @param node the node to add a children to 198 * @param node the node to add a children to
196 * @param val the unicode string encoded in UTF-8 (must be null terminated) 199 * @param val the unicode string encoded in UTF-8 (must be null terminated)
197 */ 200 */
198void plist_add_sub_unicode_el(plist_t node, const char* val); 201 void plist_add_sub_unicode_el(plist_t node, const char *val);
199 202
200/** 203/**
201 * Add a subnode of type #PLIST_DATE to a node. The node must be of a structured type 204 * Add a subnode of type #PLIST_DATE to a node. The node must be of a structured type
@@ -205,7 +208,7 @@ void plist_add_sub_unicode_el(plist_t node, const char* val);
205 * @param sec the number of seconds since 01/01/2001 208 * @param sec the number of seconds since 01/01/2001
206 * @param usec the number of microseconds 209 * @param usec the number of microseconds
207 */ 210 */
208void plist_add_sub_date_el(plist_t node, int32_t sec, int32_t usec); 211 void plist_add_sub_date_el(plist_t node, int32_t sec, int32_t usec);
209 212
210 213
211/******************************************** 214/********************************************
@@ -220,7 +223,7 @@ void plist_add_sub_date_el(plist_t node, int32_t sec, int32_t usec);
220 * @param node the node 223 * @param node the node
221 * @return the type of the node 224 * @return the type of the node
222 */ 225 */
223plist_type plist_get_node_type(plist_t node); 226 plist_type plist_get_node_type(plist_t node);
224 227
225/** 228/**
226 * Get the value of a #PLIST_KEY node. 229 * Get the value of a #PLIST_KEY node.
@@ -230,7 +233,7 @@ plist_type plist_get_node_type(plist_t node);
230 * @param val a pointer to a C-string. This function allocates the memory, 233 * @param val a pointer to a C-string. This function allocates the memory,
231 * caller is responsible for freeing it. 234 * caller is responsible for freeing it.
232 */ 235 */
233void plist_get_key_val(plist_t node, char** val); 236 void plist_get_key_val(plist_t node, char **val);
234 237
235/** 238/**
236 * Get the value of a #PLIST_STRING node. 239 * Get the value of a #PLIST_STRING node.
@@ -240,7 +243,7 @@ void plist_get_key_val(plist_t node, char** val);
240 * @param val a pointer to a C-string. This function allocates the memory, 243 * @param val a pointer to a C-string. This function allocates the memory,
241 * caller is responsible for freeing it. 244 * caller is responsible for freeing it.
242 */ 245 */
243void plist_get_string_val(plist_t node, char** val); 246 void plist_get_string_val(plist_t node, char **val);
244 247
245/** 248/**
246 * Get the value of a #PLIST_BOOLEAN node. 249 * Get the value of a #PLIST_BOOLEAN node.
@@ -249,7 +252,7 @@ void plist_get_string_val(plist_t node, char** val);
249 * @param node the node 252 * @param node the node
250 * @param val a pointer to a uint8_t variable. 253 * @param val a pointer to a uint8_t variable.
251 */ 254 */
252void plist_get_bool_val(plist_t node, uint8_t* val); 255 void plist_get_bool_val(plist_t node, uint8_t * val);
253 256
254/** 257/**
255 * Get the value of a #PLIST_UINT node. 258 * Get the value of a #PLIST_UINT node.
@@ -258,7 +261,7 @@ void plist_get_bool_val(plist_t node, uint8_t* val);
258 * @param node the node 261 * @param node the node
259 * @param val a pointer to a uint64_t variable. 262 * @param val a pointer to a uint64_t variable.
260 */ 263 */
261void plist_get_uint_val(plist_t node, uint64_t* val); 264 void plist_get_uint_val(plist_t node, uint64_t * val);
262 265
263/** 266/**
264 * Get the value of a #PLIST_REAL node. 267 * Get the value of a #PLIST_REAL node.
@@ -267,7 +270,7 @@ void plist_get_uint_val(plist_t node, uint64_t* val);
267 * @param node the node 270 * @param node the node
268 * @param val a pointer to a double variable. 271 * @param val a pointer to a double variable.
269 */ 272 */
270void plist_get_real_val(plist_t node, double* val); 273 void plist_get_real_val(plist_t node, double *val);
271 274
272/** 275/**
273 * Get the value of a #PLIST_DATA node. 276 * Get the value of a #PLIST_DATA node.
@@ -277,7 +280,7 @@ void plist_get_real_val(plist_t node, double* val);
277 * @param val a pointer to an unallocated char buffer. This function allocates the memory, 280 * @param val a pointer to an unallocated char buffer. This function allocates the memory,
278 * caller is responsible for freeing it. 281 * caller is responsible for freeing it.
279 */ 282 */
280void plist_get_data_val(plist_t node, char** val, uint64_t* length); 283 void plist_get_data_val(plist_t node, char **val, uint64_t * length);
281 284
282/** 285/**
283 * Get the value of a #PLIST_UNICODE node. 286 * Get the value of a #PLIST_UNICODE node.
@@ -287,7 +290,7 @@ void plist_get_data_val(plist_t node, char** val, uint64_t* length);
287 * @param val a pointer to a C-string. This function allocates the memory, 290 * @param val a pointer to a C-string. This function allocates the memory,
288 * caller is responsible for freeing it. Data is UTF-8 encoded. 291 * caller is responsible for freeing it. Data is UTF-8 encoded.
289 */ 292 */
290void plist_get_unicode_val(plist_t node, char** val); 293 void plist_get_unicode_val(plist_t node, char **val);
291 294
292/** 295/**
293 * Get the value of a #PLIST_DATE node. 296 * Get the value of a #PLIST_DATE node.
@@ -297,7 +300,7 @@ void plist_get_unicode_val(plist_t node, char** val);
297 * @param sec a pointer to an int32_t variable. Represents the number of seconds since 01/01/2001. 300 * @param sec a pointer to an int32_t variable. Represents the number of seconds since 01/01/2001.
298 * @param usec a pointer to an int32_t variable. Represents the number of microseconds 301 * @param usec a pointer to an int32_t variable. Represents the number of microseconds
299 */ 302 */
300void plist_get_date_val(plist_t node, int32_t* sec, int32_t* usec); 303 void plist_get_date_val(plist_t node, int32_t * sec, int32_t * usec);
301 304
302 305
303 306
@@ -315,7 +318,7 @@ void plist_get_date_val(plist_t node, int32_t* sec, int32_t* usec);
315 * caller is responsible for freeing it. Data is UTF-8 encoded. 318 * caller is responsible for freeing it. Data is UTF-8 encoded.
316 * @param length a pointer to an uint32_t variable. Represents the length of the allocated buffer. 319 * @param length a pointer to an uint32_t variable. Represents the length of the allocated buffer.
317 */ 320 */
318void plist_to_xml(plist_t plist, char **plist_xml, uint32_t * length); 321 void plist_to_xml(plist_t plist, char **plist_xml, uint32_t * length);
319 322
320/** 323/**
321 * Export the #plist_t structure to binary format. 324 * Export the #plist_t structure to binary format.
@@ -325,7 +328,7 @@ void plist_to_xml(plist_t plist, char **plist_xml, uint32_t * length);
325 * caller is responsible for freeing it. 328 * caller is responsible for freeing it.
326 * @param length a pointer to an uint32_t variable. Represents the length of the allocated buffer. 329 * @param length a pointer to an uint32_t variable. Represents the length of the allocated buffer.
327 */ 330 */
328void plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length); 331 void plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length);
329 332
330/** 333/**
331 * Import the #plist_t structure from XML format. 334 * Import the #plist_t structure from XML format.
@@ -334,7 +337,7 @@ void plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length);
334 * @param length length of the buffer to read. 337 * @param length length of the buffer to read.
335 * @param plist a pointer to the imported plist. 338 * @param plist a pointer to the imported plist.
336 */ 339 */
337void plist_from_xml(const char *plist_xml, uint32_t length, plist_t * plist); 340 void plist_from_xml(const char *plist_xml, uint32_t length, plist_t * plist);
338 341
339/** 342/**
340 * Import the #plist_t structure from binary format. 343 * Import the #plist_t structure from binary format.
@@ -343,7 +346,7 @@ void plist_from_xml(const char *plist_xml, uint32_t length, plist_t * plist);
343 * @param length length of the buffer to read. 346 * @param length length of the buffer to read.
344 * @param plist a pointer to the imported plist. 347 * @param plist a pointer to the imported plist.
345 */ 348 */
346void plist_from_bin(const char *plist_bin, uint32_t length, plist_t * plist); 349 void plist_from_bin(const char *plist_bin, uint32_t length, plist_t * plist);
347 350
348 351
349 352
@@ -360,7 +363,7 @@ void plist_from_bin(const char *plist_bin, uint32_t length, plist_t * plist);
360 * @param plist the root node of the plist structure. 363 * @param plist the root node of the plist structure.
361 * @param value the ASCII Key to match. 364 * @param value the ASCII Key to match.
362 */ 365 */
363plist_t plist_find_node_by_key(plist_t plist, const char *value); 366 plist_t plist_find_node_by_key(plist_t plist, const char *value);
364 367
365/** 368/**
366 * Find the first encountered #PLIST_STRING node mathing that string. 369 * Find the first encountered #PLIST_STRING node mathing that string.
@@ -369,7 +372,7 @@ plist_t plist_find_node_by_key(plist_t plist, const char *value);
369 * @param plist the root node of the plist structure. 372 * @param plist the root node of the plist structure.
370 * @param value the ASCII String to match. 373 * @param value the ASCII String to match.
371 */ 374 */
372plist_t plist_find_node_by_string(plist_t plist, const char *value); 375 plist_t plist_find_node_by_string(plist_t plist, const char *value);
373 376
374 377
375/*@}*/ 378/*@}*/
@@ -378,6 +381,4 @@ plist_t plist_find_node_by_string(plist_t plist, const char *value);
378#ifdef __cplusplus 381#ifdef __cplusplus
379} 382}
380#endif 383#endif
381
382#endif 384#endif
383
diff --git a/plutil/plutil.c b/plutil/plutil.c
index 27932d1..0431dc6 100644
--- a/plutil/plutil.c
+++ b/plutil/plutil.c
@@ -37,7 +37,6 @@ int main(int argc, char *argv[])
37 print_usage(); 37 print_usage();
38 return 0; 38 return 0;
39 } 39 }
40
41 //read input file 40 //read input file
42 FILE *iplist = fopen(options->in_file, "r"); 41 FILE *iplist = fopen(options->in_file, "r");
43 if (!iplist) 42 if (!iplist)
diff --git a/src/bplist.c b/src/bplist.c
index 50840c2..6e00f39 100644
--- a/src/bplist.c
+++ b/src/bplist.c
@@ -343,7 +343,7 @@ static gpointer copy_plist_data(gconstpointer src, gpointer data)
343 dstdata->strval = strdup(srcdata->strval); 343 dstdata->strval = strdup(srcdata->strval);
344 break; 344 break;
345 case PLIST_UNICODE: 345 case PLIST_UNICODE:
346 dstdata->unicodeval = (gunichar2*) malloc(srcdata->length * sizeof(gunichar2)); 346 dstdata->unicodeval = (gunichar2 *) malloc(srcdata->length * sizeof(gunichar2));
347 memcpy(dstdata->unicodeval, srcdata->unicodeval, srcdata->length * sizeof(gunichar2)); 347 memcpy(dstdata->unicodeval, srcdata->unicodeval, srcdata->length * sizeof(gunichar2));
348 break; 348 break;
349 case PLIST_DATA: 349 case PLIST_DATA:
@@ -542,7 +542,7 @@ static gboolean plist_data_compare(gconstpointer a, gconstpointer b)
542 else 542 else
543 return FALSE; 543 return FALSE;
544 case PLIST_UNICODE: 544 case PLIST_UNICODE:
545 if (!memcmp(val_a->unicodeval, val_b->unicodeval,val_a->length)) 545 if (!memcmp(val_a->unicodeval, val_b->unicodeval, val_a->length))
546 return TRUE; 546 return TRUE;
547 else 547 else
548 return FALSE; 548 return FALSE;
@@ -557,7 +557,7 @@ static gboolean plist_data_compare(gconstpointer a, gconstpointer b)
557 return FALSE; 557 return FALSE;
558 break; 558 break;
559 case PLIST_DATE: 559 case PLIST_DATE:
560 if (!memcmp(&(val_a->timeval), &(val_b->timeval),sizeof(GTimeVal))) 560 if (!memcmp(&(val_a->timeval), &(val_b->timeval), sizeof(GTimeVal)))
561 return TRUE; 561 return TRUE;
562 else 562 else
563 return FALSE; 563 return FALSE;
@@ -664,11 +664,11 @@ static void write_string(GByteArray * bplist, char *val)
664 write_raw_data(bplist, BPLIST_STRING, (uint8_t *) val, size); 664 write_raw_data(bplist, BPLIST_STRING, (uint8_t *) val, size);
665} 665}
666 666
667static void write_unicode(GByteArray * bplist, gunichar2 *val, uint64_t size) 667static void write_unicode(GByteArray * bplist, gunichar2 * val, uint64_t size)
668{ 668{
669 uint64_t i = 0; 669 uint64_t i = 0;
670 uint64_t size2 = size * sizeof(gunichar2); 670 uint64_t size2 = size * sizeof(gunichar2);
671 uint8_t* buff = (uint8_t*) malloc(size2); 671 uint8_t *buff = (uint8_t *) malloc(size2);
672 memcpy(buff, val, size2); 672 memcpy(buff, val, size2);
673 for (i = 0; i < size; i++) 673 for (i = 0; i < size; i++)
674 byte_convert(buff + i * sizeof(gunichar2), sizeof(gunichar2)); 674 byte_convert(buff + i * sizeof(gunichar2), sizeof(gunichar2));
@@ -830,7 +830,7 @@ void plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length)
830 } 830 }
831 831
832 //experimental pad to reflect apple's files 832 //experimental pad to reflect apple's files
833 uint8_t pad[6] = {0, 0, 0, 0, 0, 0}; 833 uint8_t pad[6] = { 0, 0, 0, 0, 0, 0 };
834 g_byte_array_append(bplist_buff, pad, 6); 834 g_byte_array_append(bplist_buff, pad, 6);
835 835
836 //setup trailer 836 //setup trailer
diff --git a/src/plist.c b/src/plist.c
index 71059e4..758fe53 100644
--- a/src/plist.c
+++ b/src/plist.c
@@ -102,16 +102,16 @@ static plist_t plist_add_sub_element(plist_t node, plist_type type, const void *
102 data->strval = strdup((char *) value); 102 data->strval = strdup((char *) value);
103 break; 103 break;
104 case PLIST_UNICODE: 104 case PLIST_UNICODE:
105 len = strlen((char*)value); 105 len = strlen((char *) value);
106 data->unicodeval = g_utf8_to_utf16((char*) value, len, &items_read, &items_written, &error); 106 data->unicodeval = g_utf8_to_utf16((char *) value, len, &items_read, &items_written, &error);
107 data->length = items_written; 107 data->length = items_written;
108 break; 108 break;
109 case PLIST_DATA: 109 case PLIST_DATA:
110 memcpy(data->buff, value, length); 110 memcpy(data->buff, value, length);
111 break; 111 break;
112 case PLIST_DATE: 112 case PLIST_DATE:
113 data->timeval.tv_sec = ((GTimeVal*)value)->tv_sec; 113 data->timeval.tv_sec = ((GTimeVal *) value)->tv_sec;
114 data->timeval.tv_usec = ((GTimeVal*)value)->tv_usec; 114 data->timeval.tv_usec = ((GTimeVal *) value)->tv_usec;
115 break; 115 break;
116 case PLIST_ARRAY: 116 case PLIST_ARRAY:
117 case PLIST_DICT: 117 case PLIST_DICT:
@@ -250,13 +250,13 @@ static void plist_get_type_and_value(plist_t node, plist_type * type, void *valu
250 *((char **) value) = g_utf16_to_utf8(data->unicodeval, len, &items_read, &items_written, &error); 250 *((char **) value) = g_utf16_to_utf8(data->unicodeval, len, &items_read, &items_written, &error);
251 break; 251 break;
252 case PLIST_DATA: 252 case PLIST_DATA:
253 *((uint8_t**) value) = (uint8_t*) malloc( *length * sizeof(uint8_t)); 253 *((uint8_t **) value) = (uint8_t *) malloc(*length * sizeof(uint8_t));
254 memcpy(value, data->buff, *length * sizeof(uint8_t)); 254 memcpy(value, data->buff, *length * sizeof(uint8_t));
255 break; 255 break;
256 case PLIST_DATE: 256 case PLIST_DATE:
257 //exception : here we use memory on the stack since it is just a temporary buffer 257 //exception : here we use memory on the stack since it is just a temporary buffer
258 (*((GTimeVal**) value))->tv_sec = data->timeval.tv_sec; 258 (*((GTimeVal **) value))->tv_sec = data->timeval.tv_sec;
259 (*((GTimeVal**) value))->tv_usec = data->timeval.tv_usec; 259 (*((GTimeVal **) value))->tv_usec = data->timeval.tv_usec;
260 break; 260 break;
261 case PLIST_ARRAY: 261 case PLIST_ARRAY:
262 case PLIST_DICT: 262 case PLIST_DICT:
@@ -314,14 +314,14 @@ void plist_add_sub_data_el(plist_t node, const char *val, uint64_t length)
314 plist_add_sub_element(node, PLIST_DATA, val, length); 314 plist_add_sub_element(node, PLIST_DATA, val, length);
315} 315}
316 316
317void plist_add_sub_unicode_el(plist_t node, const char* val) 317void plist_add_sub_unicode_el(plist_t node, const char *val)
318{ 318{
319 plist_add_sub_element(node, PLIST_UNICODE, val, strlen(val)); 319 plist_add_sub_element(node, PLIST_UNICODE, val, strlen(val));
320} 320}
321 321
322void plist_add_sub_date_el(plist_t node, int32_t sec, int32_t usec) 322void plist_add_sub_date_el(plist_t node, int32_t sec, int32_t usec)
323{ 323{
324 GTimeVal val = {sec, usec}; 324 GTimeVal val = { sec, usec };
325 plist_add_sub_element(node, PLIST_UNICODE, &val, sizeof(GTimeVal)); 325 plist_add_sub_element(node, PLIST_UNICODE, &val, sizeof(GTimeVal));
326} 326}
327 327
@@ -377,7 +377,7 @@ void plist_get_data_val(plist_t node, char **val, uint64_t * length)
377 plist_get_type_and_value(node, &type, (void *) val, length); 377 plist_get_type_and_value(node, &type, (void *) val, length);
378} 378}
379 379
380void plist_get_unicode_val(plist_t node, char** val) 380void plist_get_unicode_val(plist_t node, char **val)
381{ 381{
382 plist_type type = plist_get_node_type(node); 382 plist_type type = plist_get_node_type(node);
383 uint64_t length = 0; 383 uint64_t length = 0;
@@ -386,11 +386,11 @@ void plist_get_unicode_val(plist_t node, char** val)
386 assert(length == strlen(*val)); 386 assert(length == strlen(*val));
387} 387}
388 388
389void plist_get_date_val(plist_t node, int32_t* sec, int32_t* usec) 389void plist_get_date_val(plist_t node, int32_t * sec, int32_t * usec)
390{ 390{
391 plist_type type = plist_get_node_type(node); 391 plist_type type = plist_get_node_type(node);
392 uint64_t length = 0; 392 uint64_t length = 0;
393 GTimeVal val = {0, 0}; 393 GTimeVal val = { 0, 0 };
394 if (PLIST_DATE == type) 394 if (PLIST_DATE == type)
395 plist_get_type_and_value(node, &type, (void *) &val, &length); 395 plist_get_type_and_value(node, &type, (void *) &val, &length);
396 assert(length == sizeof(GTimeVal)); 396 assert(length == sizeof(GTimeVal));
diff --git a/src/xplist.c b/src/xplist.c
index 0c1a6b9..20b2795 100644
--- a/src/xplist.c
+++ b/src/xplist.c
@@ -289,19 +289,18 @@ static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node)
289 289
290 if (!xmlStrcmp(node->name, XPLIST_STRING)) { 290 if (!xmlStrcmp(node->name, XPLIST_STRING)) {
291 291
292 unsigned char *tmp = xmlNodeGetContent(node); 292 unsigned char *tmp = xmlNodeGetContent(node);
293 glong len = strlen((char*)tmp); 293 glong len = strlen((char *) tmp);
294 glong items_read = 0; 294 glong items_read = 0;
295 glong items_written = 0; 295 glong items_written = 0;
296 GError *error = NULL; 296 GError *error = NULL;
297 int type = xmlDetectCharEncoding(tmp, len); 297 int type = xmlDetectCharEncoding(tmp, len);
298 298
299 if (XML_CHAR_ENCODING_UTF8 == type) { 299 if (XML_CHAR_ENCODING_UTF8 == type) {
300 data->unicodeval = g_utf8_to_utf16((char*) tmp, len, &items_read, &items_written, &error); 300 data->unicodeval = g_utf8_to_utf16((char *) tmp, len, &items_read, &items_written, &error);
301 data->type = PLIST_UNICODE; 301 data->type = PLIST_UNICODE;
302 data->length = items_written; 302 data->length = items_written;
303 } 303 } else if (XML_CHAR_ENCODING_ASCII == type || XML_CHAR_ENCODING_NONE == type) {
304 else if (XML_CHAR_ENCODING_ASCII == type || XML_CHAR_ENCODING_NONE == type) {
305 data->strval = strdup((char *) xmlNodeGetContent(node)); 304 data->strval = strdup((char *) xmlNodeGetContent(node));
306 data->type = PLIST_STRING; 305 data->type = PLIST_STRING;
307 data->length = strlen(data->strval); 306 data->length = strlen(data->strval);