summaryrefslogtreecommitdiffstats
path: root/src/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common.c')
-rw-r--r--src/common.c72
1 files changed, 70 insertions, 2 deletions
diff --git a/src/common.c b/src/common.c
index 4dbabc0..499509d 100644
--- a/src/common.c
+++ b/src/common.c
@@ -63,6 +63,7 @@ struct idevicerestore_mode_t idevicerestore_modes[] = {
{ 3, "Recovery" },
{ 4, "Restore" },
{ 5, "Normal" },
+ { 6, "Port DFU" },
};
int idevicerestore_debug = 0;
@@ -467,7 +468,7 @@ void idevicerestore_progress(struct idevicerestore_client_t* client, int step, d
client->progress_cb(step, progress, client->progress_cb_data);
} else {
// we don't want to be too verbose in regular idevicerestore.
- if ((step == RESTORE_STEP_UPLOAD_FS) || (step == RESTORE_STEP_VERIFY_FS) || (step == RESTORE_STEP_FLASH_FW)) {
+ if ((step == RESTORE_STEP_UPLOAD_FS) || (step == RESTORE_STEP_VERIFY_FS) || (step == RESTORE_STEP_FLASH_FW) || (step == RESTORE_STEP_UPLOAD_IMG)) {
print_progress_bar(100.0 * progress);
}
}
@@ -564,7 +565,7 @@ uint64_t _plist_dict_get_uint(plist_t dict, const char *key)
uint64_t strsz = 0;
plist_t node = plist_dict_get_item(dict, key);
if (!node) {
- return (uint64_t)-1LL;
+ return uintval;
}
switch (plist_get_node_type(node)) {
case PLIST_UINT:
@@ -645,3 +646,70 @@ uint8_t _plist_dict_get_bool(plist_t dict, const char *key)
}
return bval;
}
+
+int _plist_dict_copy_uint(plist_t target_dict, plist_t source_dict, const char *key, const char *alt_source_key)
+{
+ if (plist_dict_get_item(source_dict, (alt_source_key) ? alt_source_key : key) == NULL) {
+ return -1;
+ }
+ uint64_t u64val = _plist_dict_get_uint(source_dict, (alt_source_key) ? alt_source_key : key);
+ plist_dict_set_item(target_dict, key, plist_new_uint(u64val));
+ return 0;
+}
+
+int _plist_dict_copy_bool(plist_t target_dict, plist_t source_dict, const char *key, const char *alt_source_key)
+{
+ if (plist_dict_get_item(source_dict, (alt_source_key) ? alt_source_key : key) == NULL) {
+ return -1;
+ }
+ uint64_t bval = _plist_dict_get_bool(source_dict, (alt_source_key) ? alt_source_key : key);
+ plist_dict_set_item(target_dict, key, plist_new_bool(bval));
+ return 0;
+}
+
+int _plist_dict_copy_data(plist_t target_dict, plist_t source_dict, const char *key, const char *alt_source_key)
+{
+ plist_t node = plist_dict_get_item(source_dict, (alt_source_key) ? alt_source_key : key);
+ if (!PLIST_IS_DATA(node)) {
+ return -1;
+ }
+ plist_dict_set_item(target_dict, key, plist_copy(node));
+ return 0;
+}
+
+int _plist_dict_copy_string(plist_t target_dict, plist_t source_dict, const char *key, const char *alt_source_key)
+{
+ plist_t node = plist_dict_get_item(source_dict, (alt_source_key) ? alt_source_key : key);
+ if (!PLIST_IS_STRING(node)) {
+ return -1;
+ }
+ plist_dict_set_item(target_dict, key, plist_copy(node));
+ return 0;
+}
+
+int _plist_dict_copy_item(plist_t target_dict, plist_t source_dict, const char *key, const char *alt_source_key)
+{
+ plist_t node = plist_dict_get_item(source_dict, (alt_source_key) ? alt_source_key : key);
+ if (!node) {
+ return -1;
+ }
+ plist_dict_set_item(target_dict, key, plist_copy(node));
+ return 0;
+}
+
+const char* path_get_basename(const char* path)
+{
+#ifdef WIN32
+ const char *p = path + strlen(path);
+ while (p > path) {
+ if ((*p == '/') || (*p == '\\')) {
+ return p+1;
+ }
+ p--;
+ }
+ return p;
+#else
+ const char *p = strrchr(path, '/');
+ return p ? p + 1 : path;
+#endif
+}