summaryrefslogtreecommitdiffstats
path: root/src/normal.c
diff options
context:
space:
mode:
authorGravatar Joshua Hill2010-06-05 18:09:06 -0400
committerGravatar Joshua Hill2010-06-05 18:09:06 -0400
commit255b285d22056dde283d33511c14387ea92e28c0 (patch)
treec039506ad319c2ec81f5a0aeb5ac4737b10d9389 /src/normal.c
parent5fe87e252c9c28a67277e21febb19027feb32372 (diff)
downloadidevicerestore-255b285d22056dde283d33511c14387ea92e28c0.tar.gz
idevicerestore-255b285d22056dde283d33511c14387ea92e28c0.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.c26
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;