summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Jonathan Beck2008-12-10 23:42:21 +0100
committerGravatar Jonathan Beck2008-12-10 23:42:21 +0100
commitcd95e9bc6e23949b5cef3996132b79bd8803467a (patch)
treea435658908e506a5cb77a9bdabf8a158144ea6d8
parent625633203a27f569bea8890cb269132fea83b497 (diff)
downloadlibimobiledevice-cd95e9bc6e23949b5cef3996132b79bd8803467a.tar.gz
libimobiledevice-cd95e9bc6e23949b5cef3996132b79bd8803467a.tar.bz2
fix minor programming erro plus enhance plutil to convert bin to xml and xml to bin.
-rw-r--r--dev/plutil.c29
-rw-r--r--src/plist.c8
2 files changed, 17 insertions, 20 deletions
diff --git a/dev/plutil.c b/dev/plutil.c
index 4a34077..e76506e 100644
--- a/dev/plutil.c
+++ b/dev/plutil.c
@@ -18,8 +18,6 @@ int main(int argc, char *argv[])
18 Options *options = parse_arguments(argc, argv); 18 Options *options = parse_arguments(argc, argv);
19 int argh = 0; 19 int argh = 0;
20 20
21 printf("plistutil version 0.2 written by FxChiP\n");
22
23 if (!options) { 21 if (!options) {
24 print_usage(); 22 print_usage();
25 return 0; 23 return 0;
@@ -31,26 +29,25 @@ int main(int argc, char *argv[])
31 29
32 stat(options->in_file, filestats); 30 stat(options->in_file, filestats);
33 31
34 printf("here?\n");
35 char *bplist_entire = (char *) malloc(sizeof(char) * (filestats->st_size + 1)); 32 char *bplist_entire = (char *) malloc(sizeof(char) * (filestats->st_size + 1));
36 //argh = fgets(bplist_entire, filestats->st_size, bplist);
37 argh = fread(bplist_entire, sizeof(char), filestats->st_size, bplist); 33 argh = fread(bplist_entire, sizeof(char), filestats->st_size, bplist);
38 printf("read %i bytes\n", argh);
39 fclose(bplist); 34 fclose(bplist);
40 printf("or here?\n");
41 // bplist_entire contains our stuff 35 // bplist_entire contains our stuff
36
42 plist_t root_node = NULL; 37 plist_t root_node = NULL;
43 bin_to_plist(bplist_entire, filestats->st_size, &root_node); 38 char *plist_out = NULL;
44 printf("plutil debug mode\n\n");
45 printf("file size %i\n\n", (int) filestats->st_size);
46 if (!root_node) {
47 printf("Invalid binary plist (or some other error occurred.)\n");
48 return 0;
49 }
50 char *plist_xml = NULL;
51 int size = 0; 39 int size = 0;
52 plist_to_xml(root_node, &plist_xml, &size); 40
53 printf("%s\n", plist_xml); 41 if (memcmp(bplist_entire, "bplist00", 8) == 0) {
42 bin_to_plist(bplist_entire, filestats->st_size, &root_node);
43 plist_to_xml(root_node, &plist_out, &size);
44 } else {
45 xml_to_plist(bplist_entire, filestats->st_size, &root_node);
46 plist_to_bin(root_node, &plist_out, &size);
47 }
48
49
50 printf("%s\n", plist_out);
54 return 0; 51 return 0;
55} 52}
56 53
diff --git a/src/plist.c b/src/plist.c
index 431c64a..2a6d4bc 100644
--- a/src/plist.c
+++ b/src/plist.c
@@ -1014,16 +1014,16 @@ guint plist_data_hash(gconstpointer key)
1014 case PLIST_REAL: 1014 case PLIST_REAL:
1015 buff = (char *) &data->intval; 1015 buff = (char *) &data->intval;
1016 size = 8; 1016 size = 8;
1017 1017 break;
1018 case PLIST_KEY: 1018 case PLIST_KEY:
1019 case PLIST_STRING: 1019 case PLIST_STRING:
1020 buff = data->strval; 1020 buff = data->strval;
1021 size = strlen(buff); 1021 size = strlen(buff);
1022 1022 break;
1023 case PLIST_UNICODE: 1023 case PLIST_UNICODE:
1024 buff = data->unicodeval; 1024 buff = data->unicodeval;
1025 size = strlen(buff) * sizeof(wchar_t); 1025 size = strlen(buff) * sizeof(wchar_t);
1026 1026 break;
1027 case PLIST_DATA: 1027 case PLIST_DATA:
1028 case PLIST_ARRAY: 1028 case PLIST_ARRAY:
1029 case PLIST_DICT: 1029 case PLIST_DICT:
@@ -1267,7 +1267,7 @@ void plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length)
1267 uint8_t *buff = NULL; 1267 uint8_t *buff = NULL;
1268 uint8_t size = 0; 1268 uint8_t size = 0;
1269 uint64_t offsets[num_objects]; 1269 uint64_t offsets[num_objects];
1270 for (i = 0; i <= num_objects; i++) { 1270 for (i = 0; i < num_objects; i++) {
1271 1271
1272 offsets[i] = bplist_buff->len; 1272 offsets[i] = bplist_buff->len;
1273 struct plist_data *data = (struct plist_data *) ((GNode *) g_ptr_array_index(objects, i))->data; 1273 struct plist_data *data = (struct plist_data *) ((GNode *) g_ptr_array_index(objects, i))->data;