summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2010-07-09 03:44:40 +0200
committerGravatar Martin Szulecki2010-07-09 03:44:40 +0200
commitbfd4f97062a89d046d73f9e7439ac5e74ef8dcdc (patch)
treea3adf0675cd21d7dd86a192b4fec46f1f6456961 /src
parentd1a5f28e6d1a3b7a24e406a215b4037dd68d41c9 (diff)
downloadidevicerestore-bfd4f97062a89d046d73f9e7439ac5e74ef8dcdc.tar.gz
idevicerestore-bfd4f97062a89d046d73f9e7439ac5e74ef8dcdc.tar.bz2
Add function to retrieve a component path from a build identity
Diffstat (limited to 'src')
-rw-r--r--src/idevicerestore.c65
-rw-r--r--src/idevicerestore.h1
2 files changed, 44 insertions, 22 deletions
diff --git a/src/idevicerestore.c b/src/idevicerestore.c
index 4a2b8ab..19ae8be 100644
--- a/src/idevicerestore.c
+++ b/src/idevicerestore.c
@@ -530,31 +530,11 @@ int get_build_count(plist_t buildmanifest) {
int extract_filesystem(struct idevicerestore_client_t* client, const char* ipsw, plist_t build_identity, char** filesystem) {
char* filename = NULL;
- plist_t manifest_node = plist_dict_get_item(build_identity, "Manifest");
- if (!manifest_node || plist_get_node_type(manifest_node) != PLIST_DICT) {
- error("ERROR: Unable to find manifest node\n");
- return -1;
- }
-
- plist_t filesystem_node = plist_dict_get_item(manifest_node, "OS");
- if (!filesystem_node || plist_get_node_type(filesystem_node) != PLIST_DICT) {
- error("ERROR: Unable to find filesystem node\n");
- return -1;
- }
-
- plist_t filesystem_info_node = plist_dict_get_item(filesystem_node, "Info");
- if (!filesystem_info_node || plist_get_node_type(filesystem_info_node) != PLIST_DICT) {
- error("ERROR: Unable to find filesystem info node\n");
+ if (build_identity_get_component_path(build_identity, "OS", &filename) < 0) {
+ error("ERROR: Unable get path for filesystem component\n");
return -1;
}
- plist_t filesystem_info_path_node = plist_dict_get_item(filesystem_info_node, "Path");
- if (!filesystem_info_path_node || plist_get_node_type(filesystem_info_path_node) != PLIST_STRING) {
- error("ERROR: Unable to find filesystem info path node\n");
- return -1;
- }
- plist_get_string_val(filesystem_info_path_node, &filename);
-
info("Extracting filesystem from IPSW\n");
if (ipsw_extract_to_file(ipsw, filename, filename) < 0) {
error("ERROR: Unable to extract filesystem\n");
@@ -623,3 +603,44 @@ int get_signed_component(struct idevicerestore_client_t* client, const char* ips
*size = component_size;
return 0;
}
+
+int build_identity_get_component_path(plist_t build_identity, const char* component, char** path) {
+ char* filename = NULL;
+
+ plist_t manifest_node = plist_dict_get_item(build_identity, "Manifest");
+ if (!manifest_node || plist_get_node_type(manifest_node) != PLIST_DICT) {
+ error("ERROR: Unable to find manifest node\n");
+ if (filename)
+ free(filename);
+ return -1;
+ }
+
+ plist_t component_node = plist_dict_get_item(manifest_node, component);
+ if (!component_node || plist_get_node_type(component_node) != PLIST_DICT) {
+ error("ERROR: Unable to find component node for %s\n", component);
+ if (filename)
+ free(filename);
+ return -1;
+ }
+
+ plist_t component_info_node = plist_dict_get_item(component_node, "Info");
+ if (!component_info_node || plist_get_node_type(component_info_node) != PLIST_DICT) {
+ error("ERROR: Unable to find component info node for %s\n", component);
+ if (filename)
+ free(filename);
+ return -1;
+ }
+
+ plist_t component_info_path_node = plist_dict_get_item(component_info_node, "Path");
+ if (!component_info_path_node || plist_get_node_type(component_info_path_node) != PLIST_STRING) {
+ error("ERROR: Unable to find component info path node for %s\n", component);
+ if (filename)
+ free(filename);
+ return -1;
+ }
+ plist_get_string_val(component_info_path_node, &filename);
+
+ *path = filename;
+ return 0;
+}
+
diff --git a/src/idevicerestore.h b/src/idevicerestore.h
index 407c0db..3213b0c 100644
--- a/src/idevicerestore.h
+++ b/src/idevicerestore.h
@@ -43,6 +43,7 @@ plist_t get_build_identity(struct idevicerestore_client_t* client, plist_t build
int get_shsh_blobs(struct idevicerestore_client_t* client, uint64_t ecid, plist_t build_identity, plist_t* tss);
int extract_filesystem(struct idevicerestore_client_t* client, const char* ipsw, plist_t buildmanifest, char** filesystem);
int get_signed_component(struct idevicerestore_client_t* client, const char* ipsw, plist_t tss, const char* path, char** data, uint32_t* size);
+int build_identity_get_component_path(plist_t build_identity, const char* component, char** path);
#ifdef __cplusplus
}