diff options
Diffstat (limited to 'tools/iphoneinfo.c')
| -rw-r--r-- | tools/iphoneinfo.c | 72 |
1 files changed, 50 insertions, 22 deletions
diff --git a/tools/iphoneinfo.c b/tools/iphoneinfo.c index 4414b14..5ee92f5 100644 --- a/tools/iphoneinfo.c +++ b/tools/iphoneinfo.c | |||
| @@ -71,7 +71,23 @@ static int is_domain_known(char *domain) | |||
| 71 | 71 | ||
| 72 | static void plist_node_to_string(plist_t node); | 72 | static void plist_node_to_string(plist_t node); |
| 73 | 73 | ||
| 74 | static void plist_children_to_string(plist_t node) | 74 | static void plist_array_to_string(plist_t node) |
| 75 | { | ||
| 76 | /* iterate over items */ | ||
| 77 | int i, count; | ||
| 78 | plist_t subnode = NULL; | ||
| 79 | |||
| 80 | count = plist_array_get_size(node); | ||
| 81 | |||
| 82 | for (i = 0; i < count; i++) { | ||
| 83 | subnode = plist_array_get_item(node, i); | ||
| 84 | printf("%*s", indent_level, ""); | ||
| 85 | printf("%d: ", i); | ||
| 86 | plist_node_to_string(subnode); | ||
| 87 | } | ||
| 88 | } | ||
| 89 | |||
| 90 | static void plist_dict_to_string(plist_t node) | ||
| 75 | { | 91 | { |
| 76 | /* iterate over key/value pairs */ | 92 | /* iterate over key/value pairs */ |
| 77 | plist_dict_iter it = NULL; | 93 | plist_dict_iter it = NULL; |
| @@ -83,7 +99,11 @@ static void plist_children_to_string(plist_t node) | |||
| 83 | while (subnode) | 99 | while (subnode) |
| 84 | { | 100 | { |
| 85 | printf("%*s", indent_level, ""); | 101 | printf("%*s", indent_level, ""); |
| 86 | printf("%s: ", key); | 102 | printf("%s", key); |
| 103 | if (plist_get_node_type(subnode) == PLIST_ARRAY) | ||
| 104 | printf("[%d]: ", plist_array_get_size(subnode)); | ||
| 105 | else | ||
| 106 | printf(": "); | ||
| 87 | free(key); | 107 | free(key); |
| 88 | key = NULL; | 108 | key = NULL; |
| 89 | plist_node_to_string(subnode); | 109 | plist_node_to_string(subnode); |
| @@ -152,10 +172,16 @@ static void plist_node_to_string(plist_t node) | |||
| 152 | break; | 172 | break; |
| 153 | 173 | ||
| 154 | case PLIST_ARRAY: | 174 | case PLIST_ARRAY: |
| 175 | printf("\n"); | ||
| 176 | indent_level++; | ||
| 177 | plist_array_to_string(node); | ||
| 178 | indent_level--; | ||
| 179 | break; | ||
| 180 | |||
| 155 | case PLIST_DICT: | 181 | case PLIST_DICT: |
| 156 | printf("\n"); | 182 | printf("\n"); |
| 157 | indent_level++; | 183 | indent_level++; |
| 158 | plist_children_to_string(node); | 184 | plist_dict_to_string(node); |
| 159 | indent_level--; | 185 | indent_level--; |
| 160 | break; | 186 | break; |
| 161 | 187 | ||
| @@ -199,6 +225,7 @@ int main(int argc, char *argv[]) | |||
| 199 | char *xml_doc = NULL; | 225 | char *xml_doc = NULL; |
| 200 | uint32_t xml_length; | 226 | uint32_t xml_length; |
| 201 | plist_t node = NULL; | 227 | plist_t node = NULL; |
| 228 | plist_type node_type; | ||
| 202 | uuid[0] = 0; | 229 | uuid[0] = 0; |
| 203 | 230 | ||
| 204 | /* parse cmdline args */ | 231 | /* parse cmdline args */ |
| @@ -273,29 +300,30 @@ int main(int argc, char *argv[]) | |||
| 273 | } | 300 | } |
| 274 | 301 | ||
| 275 | /* run query and output information */ | 302 | /* run query and output information */ |
| 276 | if(lockdownd_get_value(client, domain, key, &node) == LOCKDOWN_E_SUCCESS) | 303 | if(lockdownd_get_value(client, domain, key, &node) == LOCKDOWN_E_SUCCESS) { |
| 277 | { | 304 | if (node) { |
| 278 | if (plist_get_node_type(node) == PLIST_DICT) { | 305 | switch (format) { |
| 279 | if (plist_dict_get_size(node)) | 306 | case FORMAT_XML: |
| 280 | { | 307 | plist_to_xml(node, &xml_doc, &xml_length); |
| 281 | switch (format) { | 308 | printf("%s", xml_doc); |
| 282 | case FORMAT_XML: | 309 | free(xml_doc); |
| 283 | plist_to_xml(node, &xml_doc, &xml_length); | 310 | break; |
| 284 | printf("%s", xml_doc); | 311 | case FORMAT_KEY_VALUE: |
| 285 | free(xml_doc); | 312 | node_type = plist_get_node_type(node); |
| 286 | break; | 313 | if (node_type == PLIST_DICT) { |
| 287 | case FORMAT_KEY_VALUE: | 314 | plist_dict_to_string(node); |
| 288 | default: | 315 | } else if (node_type == PLIST_ARRAY) { |
| 289 | plist_children_to_string(node); | 316 | plist_array_to_string(node); |
| 290 | break; | 317 | break; |
| 291 | } | 318 | } |
| 319 | default: | ||
| 320 | if (key != NULL) | ||
| 321 | plist_node_to_string(node); | ||
| 322 | break; | ||
| 292 | } | 323 | } |
| 293 | } | ||
| 294 | else if(node && (key != NULL)) | ||
| 295 | plist_node_to_string(node); | ||
| 296 | if (node) | ||
| 297 | plist_free(node); | 324 | plist_free(node); |
| 298 | node = NULL; | 325 | node = NULL; |
| 326 | } | ||
| 299 | } | 327 | } |
| 300 | 328 | ||
| 301 | if (domain != NULL) | 329 | if (domain != NULL) |
