summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dev/iphoneinfo.c95
1 files changed, 27 insertions, 68 deletions
diff --git a/dev/iphoneinfo.c b/dev/iphoneinfo.c
index 7c823e6..33ab3ac 100644
--- a/dev/iphoneinfo.c
+++ b/dev/iphoneinfo.c
@@ -46,7 +46,6 @@ static const char *domains[] = {
46 46
47int is_domain_known(char *domain); 47int is_domain_known(char *domain);
48void print_usage(int argc, char **argv); 48void print_usage(int argc, char **argv);
49void print_lckd_request_result(lockdownd_client_t client, const char *domain, const char *request, const char *key, int format);
50void plist_node_to_string(plist_t *node); 49void plist_node_to_string(plist_t *node);
51void plist_children_to_string(plist_t *node); 50void plist_children_to_string(plist_t *node);
52 51
@@ -60,6 +59,9 @@ int main(int argc, char *argv[])
60 char uuid[41]; 59 char uuid[41];
61 char *domain = NULL; 60 char *domain = NULL;
62 char *key = NULL; 61 char *key = NULL;
62 char *xml_doc = NULL;
63 uint32_t xml_length;
64 plist_t node = NULL;
63 uuid[0] = 0; 65 uuid[0] = 0;
64 66
65 /* parse cmdline args */ 67 /* parse cmdline args */
@@ -135,7 +137,30 @@ int main(int argc, char *argv[])
135 } 137 }
136 138
137 /* run query and output information */ 139 /* run query and output information */
138 print_lckd_request_result(client, domain, "GetValue", key, format); 140 if(lockdownd_get_value(client, domain, key, &node) == IPHONE_E_SUCCESS)
141 {
142 if (plist_get_node_type(node) == PLIST_DICT) {
143 if (plist_get_first_child(node))
144 {
145 switch (format) {
146 case FORMAT_XML:
147 plist_to_xml(node, &xml_doc, &xml_length);
148 printf(xml_doc);
149 free(xml_doc);
150 break;
151 case FORMAT_KEY_VALUE:
152 default:
153 plist_children_to_string(node);
154 break;
155 }
156 }
157 }
158 else if(node && (key != NULL))
159 plist_node_to_string(node);
160 if (node)
161 plist_free(node);
162 node = NULL;
163 }
139 164
140 if (domain != NULL) 165 if (domain != NULL)
141 free(domain); 166 free(domain);
@@ -249,69 +274,3 @@ void plist_children_to_string(plist_t *node)
249 } 274 }
250} 275}
251 276
252void print_lckd_request_result(lockdownd_client_t client, const char *domain, const char *request, const char *key, int format) {
253 char *xml_doc = NULL;
254 char *s = NULL;
255 uint32_t xml_length = 0;
256 iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR;
257
258 plist_t node = plist_new_dict();
259 if (domain) {
260 plist_add_sub_key_el(node, "Domain");
261 plist_add_sub_string_el(node, domain);
262 }
263 if (key) {
264 plist_add_sub_key_el(node, "Key");
265 plist_add_sub_string_el(node, key);
266 }
267 plist_add_sub_key_el(node, "Request");
268 plist_add_sub_string_el(node, request);
269
270 ret = lockdownd_send(client, node);
271 if (ret == IPHONE_E_SUCCESS) {
272 plist_free(node);
273 node = NULL;
274 ret = lockdownd_recv(client, &node);
275 if (ret == IPHONE_E_SUCCESS) {
276 /* seek to value node */
277 for (
278 node = plist_get_first_child(node);
279 node != NULL;
280 node = plist_get_next_sibling(node)
281 ) {
282 if(plist_get_node_type(node) == PLIST_KEY)
283 {
284 plist_get_key_val(node, &s);
285
286 if (strcmp("Value", s))
287 continue;
288
289 node = plist_get_next_sibling(node);
290
291 if (plist_get_node_type(node) == PLIST_DICT) {
292 if (plist_get_first_child(node))
293 {
294 switch (format) {
295 case FORMAT_XML:
296 plist_to_xml(node, &xml_doc, &xml_length);
297 printf(xml_doc);
298 free(xml_doc);
299 break;
300 case FORMAT_KEY_VALUE:
301 default:
302 plist_children_to_string(node);
303 break;
304 }
305 }
306 }
307 else if(node && (key != NULL))
308 plist_node_to_string(node);
309 }
310 }
311 }
312 }
313 if (node)
314 plist_free(node);
315 node = NULL;
316}
317