summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bplist.c12
-rw-r--r--src/plist.c24
-rw-r--r--src/xplist.c11
3 files changed, 23 insertions, 24 deletions
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);