summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plutil/plutil.c9
-rw-r--r--src/bplist.c5
-rw-r--r--src/plist.c36
-rw-r--r--src/xplist.c3
-rw-r--r--test/plist_cmp.c7
-rw-r--r--test/plist_test.c7
6 files changed, 15 insertions, 52 deletions
diff --git a/plutil/plutil.c b/plutil/plutil.c
index e9eaef1..88df080 100644
--- a/plutil/plutil.c
+++ b/plutil/plutil.c
@@ -38,7 +38,8 @@ int main(int argc, char *argv[])
38 FILE *iplist = NULL; 38 FILE *iplist = NULL;
39 plist_t root_node = NULL; 39 plist_t root_node = NULL;
40 char *plist_out = NULL; 40 char *plist_out = NULL;
41 int size = 0; 41 uint32_t size = 0;
42 int read_size = 0;
42 char *plist_entire = NULL; 43 char *plist_entire = NULL;
43 struct stat *filestats = (struct stat *) malloc(sizeof(struct stat)); 44 struct stat *filestats = (struct stat *) malloc(sizeof(struct stat));
44 Options *options = parse_arguments(argc, argv); 45 Options *options = parse_arguments(argc, argv);
@@ -55,7 +56,7 @@ int main(int argc, char *argv[])
55 return 1; 56 return 1;
56 stat(options->in_file, filestats); 57 stat(options->in_file, filestats);
57 plist_entire = (char *) malloc(sizeof(char) * (filestats->st_size + 1)); 58 plist_entire = (char *) malloc(sizeof(char) * (filestats->st_size + 1));
58 fread(plist_entire, sizeof(char), filestats->st_size, iplist); 59 read_size = fread(plist_entire, sizeof(char), filestats->st_size, iplist);
59 fclose(iplist); 60 fclose(iplist);
60 61
61 62
@@ -64,12 +65,12 @@ int main(int argc, char *argv[])
64 65
65 if (memcmp(plist_entire, "bplist00", 8) == 0) 66 if (memcmp(plist_entire, "bplist00", 8) == 0)
66 { 67 {
67 plist_from_bin(plist_entire, filestats->st_size, &root_node); 68 plist_from_bin(plist_entire, read_size, &root_node);
68 plist_to_xml(root_node, &plist_out, &size); 69 plist_to_xml(root_node, &plist_out, &size);
69 } 70 }
70 else 71 else
71 { 72 {
72 plist_from_xml(plist_entire, filestats->st_size, &root_node); 73 plist_from_xml(plist_entire, read_size, &root_node);
73 plist_to_bin(root_node, &plist_out, &size); 74 plist_to_bin(root_node, &plist_out, &size);
74 } 75 }
75 plist_free(root_node); 76 plist_free(root_node);
diff --git a/src/bplist.c b/src/bplist.c
index d37ed7a..a9e2638 100644
--- a/src/bplist.c
+++ b/src/bplist.c
@@ -82,7 +82,7 @@ static void byte_convert(uint8_t * address, size_t size)
82static uint32_t uint24_from_be(char *buff) 82static uint32_t uint24_from_be(char *buff)
83{ 83{
84 uint32_t ret = 0; 84 uint32_t ret = 0;
85 char *tmp = (char *) &ret; 85 uint8_t *tmp = (uint8_t *) &ret;
86 memcpy(tmp + 1, buff, 3 * sizeof(char)); 86 memcpy(tmp + 1, buff, 3 * sizeof(char));
87 byte_convert(tmp, sizeof(uint32_t)); 87 byte_convert(tmp, sizeof(uint32_t));
88 return ret; 88 return ret;
@@ -192,7 +192,6 @@ static plist_t parse_unicode_node(char *bnode, uint64_t size)
192 uint64_t i = 0; 192 uint64_t i = 0;
193 gunichar2 *unicodestr = NULL; 193 gunichar2 *unicodestr = NULL;
194 gchar *tmpstr = NULL; 194 gchar *tmpstr = NULL;
195 int type = 0;
196 glong items_read = 0; 195 glong items_read = 0;
197 glong items_written = 0; 196 glong items_written = 0;
198 GError *error = NULL; 197 GError *error = NULL;
@@ -858,7 +857,7 @@ void plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length)
858 case PLIST_KEY: 857 case PLIST_KEY:
859 case PLIST_STRING: 858 case PLIST_STRING:
860 len = strlen(data->strval); 859 len = strlen(data->strval);
861 type = xmlDetectCharEncoding(data->strval, len); 860 type = xmlDetectCharEncoding((const unsigned char *)data->strval, len);
862 if (XML_CHAR_ENCODING_UTF8 == type) 861 if (XML_CHAR_ENCODING_UTF8 == type)
863 { 862 {
864 unicodestr = g_utf8_to_utf16(data->strval, len, &items_read, &items_written, &error); 863 unicodestr = g_utf8_to_utf16(data->strval, len, &items_read, &items_written, &error);
diff --git a/src/plist.c b/src/plist.c
index 1abd0f9..7028d81 100644
--- a/src/plist.c
+++ b/src/plist.c
@@ -414,38 +414,6 @@ void plist_dict_remove_item(plist_t node, const char* key)
414 return; 414 return;
415} 415}
416 416
417static char compare_node_value(plist_type type, plist_data_t data, const void *value, uint64_t length)
418{
419 char res = FALSE;
420 switch (type)
421 {
422 case PLIST_BOOLEAN:
423 res = data->boolval == *((char *) value) ? TRUE : FALSE;
424 break;
425 case PLIST_UINT:
426 res = data->intval == *((uint64_t *) value) ? TRUE : FALSE;
427 break;
428 case PLIST_REAL:
429 res = data->realval == *((double *) value) ? TRUE : FALSE;
430 break;
431 case PLIST_KEY:
432 case PLIST_STRING:
433 res = !strcmp(data->strval, ((char *) value));
434 break;
435 case PLIST_DATA:
436 res = !memcmp(data->buff, (char *) value, length);
437 break;
438 case PLIST_DATE:
439 res = !memcmp(&(data->timeval), value, sizeof(GTimeVal));
440 break;
441 case PLIST_ARRAY:
442 case PLIST_DICT:
443 default:
444 break;
445 }
446 return res;
447}
448
449plist_t plist_access_pathv(plist_t plist, uint32_t length, va_list v) 417plist_t plist_access_pathv(plist_t plist, uint32_t length, va_list v)
450{ 418{
451 plist_t current = plist; 419 plist_t current = plist;
@@ -458,8 +426,8 @@ plist_t plist_access_pathv(plist_t plist, uint32_t length, va_list v)
458 426
459 if (type == PLIST_ARRAY) 427 if (type == PLIST_ARRAY)
460 { 428 {
461 uint32_t index = va_arg(v, uint32_t); 429 uint32_t n = va_arg(v, uint32_t);
462 current = plist_array_get_item(current, index); 430 current = plist_array_get_item(current, n);
463 } 431 }
464 else if (type == PLIST_DICT) 432 else if (type == PLIST_DICT)
465 { 433 {
diff --git a/src/xplist.c b/src/xplist.c
index ce8dec1..8b6a632 100644
--- a/src/xplist.c
+++ b/src/xplist.c
@@ -25,6 +25,7 @@
25#include <stdlib.h> 25#include <stdlib.h>
26#include <stdio.h> 26#include <stdio.h>
27 27
28#include <inttypes.h>
28 29
29#include <libxml/parser.h> 30#include <libxml/parser.h>
30#include <libxml/tree.h> 31#include <libxml/tree.h>
@@ -149,7 +150,7 @@ static void node_to_xml(GNode * node, gpointer xml_struct)
149 150
150 case PLIST_UINT: 151 case PLIST_UINT:
151 tag = XPLIST_INT; 152 tag = XPLIST_INT;
152 val = g_strdup_printf("%llu", node_data->intval); 153 val = g_strdup_printf("%"PRIu64, node_data->intval);
153 break; 154 break;
154 155
155 case PLIST_REAL: 156 case PLIST_REAL:
diff --git a/test/plist_cmp.c b/test/plist_cmp.c
index dcf961f..af54c4c 100644
--- a/test/plist_cmp.c
+++ b/test/plist_cmp.c
@@ -43,12 +43,7 @@ static plist_t plist_get_next_sibling(plist_t node)
43 return (plist_t) g_node_next_sibling((GNode *) node); 43 return (plist_t) g_node_next_sibling((GNode *) node);
44} 44}
45 45
46static plist_t plist_get_prev_sibling(plist_t node) 46static char compare_plist(plist_t node_l, plist_t node_r)
47{
48 return (plist_t) g_node_prev_sibling((GNode *) node);
49}
50
51char compare_plist(plist_t node_l, plist_t node_r)
52{ 47{
53 plist_t cur_l = NULL; 48 plist_t cur_l = NULL;
54 plist_t cur_r = NULL; 49 plist_t cur_r = NULL;
diff --git a/test/plist_test.c b/test/plist_test.c
index a0344e9..17be11a 100644
--- a/test/plist_test.c
+++ b/test/plist_test.c
@@ -35,15 +35,14 @@
35int main(int argc, char *argv[]) 35int main(int argc, char *argv[])
36{ 36{
37 FILE *iplist = NULL; 37 FILE *iplist = NULL;
38 FILE *oplist = NULL;
39 plist_t root_node1 = NULL; 38 plist_t root_node1 = NULL;
40 plist_t root_node2 = NULL; 39 plist_t root_node2 = NULL;
41 char *plist_xml = NULL; 40 char *plist_xml = NULL;
42 char *plist_xml2 = NULL; 41 char *plist_xml2 = NULL;
43 char *plist_bin = NULL; 42 char *plist_bin = NULL;
44 int size_in = 0; 43 int size_in = 0;
45 int size_out = 0; 44 uint32_t size_out = 0;
46 int size_out2 = 0; 45 uint32_t size_out2 = 0;
47 char *file_in = NULL; 46 char *file_in = NULL;
48 struct stat *filestats = (struct stat *) malloc(sizeof(struct stat)); 47 struct stat *filestats = (struct stat *) malloc(sizeof(struct stat));
49 if (argc!= 2) 48 if (argc!= 2)
@@ -123,7 +122,7 @@ int main(int argc, char *argv[])
123 free(plist_xml2); 122 free(plist_xml2);
124 free(filestats); 123 free(filestats);
125 124
126 if (size_in != size_out2) 125 if ((uint32_t)size_in != size_out2)
127 { 126 {
128 printf("Size of input and output is different\n"); 127 printf("Size of input and output is different\n");
129 printf("Input size : %i\n", size_in); 128 printf("Input size : %i\n", size_in);