diff options
author | 2010-06-06 06:09:06 +0800 | |
---|---|---|
committer | 2010-06-09 17:17:29 +0800 | |
commit | 9279f889d7e296880fd7ea9d6c7cec499db62ea4 (patch) | |
tree | c039506ad319c2ec81f5a0aeb5ac4737b10d9389 /src/normal.c | |
parent | c21f7031b44e4cd61c1a6e630f9681742923ffa0 (diff) | |
download | idevicerestore-9279f889d7e296880fd7ea9d6c7cec499db62ea4.tar.gz idevicerestore-9279f889d7e296880fd7ea9d6c7cec499db62ea4.tar.bz2 |
Changed the device type to a structure array for cleaner code and cross state access
Diffstat (limited to 'src/normal.c')
-rw-r--r-- | src/normal.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/src/normal.c b/src/normal.c index ab9216c..b9270d8 100644 --- a/src/normal.c +++ b/src/normal.c @@ -62,6 +62,7 @@ int normal_check_mode(const char* uuid) { } int normal_check_device(const char* uuid) { + int i = 0; idevice_t device = NULL; char* product_type = NULL; plist_t product_type_node = NULL; @@ -87,30 +88,25 @@ int normal_check_device(const char* uuid) { return -1; } + lockdownd_client_free(lockdown); + idevice_free(device); + lockdown = NULL; + device = NULL; + if (!product_type_node || plist_get_node_type(product_type_node) != PLIST_STRING) { - if (product_type_node) - plist_free(product_type_node); - lockdownd_client_free(lockdown); - idevice_free(device); + if (product_type_node) plist_free(product_type_node); return -1; } plist_get_string_val(product_type_node, &product_type); plist_free(product_type_node); - lockdownd_client_free(lockdown); - idevice_free(device); - lockdown = NULL; - device = NULL; - - int i = 0; - for (i = 0; idevicerestore_products[i] != NULL; i++) { - if (!strcmp(product_type, idevicerestore_products[i])) { - idevicerestore_device = i; + for (i = 0; idevicerestore_devices[i].product != NULL; i++) { + if (!strcmp(product_type, idevicerestore_devices[i].product)) { break; } } - return idevicerestore_device; + return idevicerestore_devices[i].device_id; } int normal_enter_recovery(const char* uuid) { @@ -166,7 +162,7 @@ int normal_enter_recovery(const char* uuid) { return -1; } - idevicerestore_mode = RECOVERY_MODE; + idevicerestore_mode = MODE_RECOVERY; irecv_close(recovery); recovery = NULL; return 0; |