summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/idevice_id.c5
-rw-r--r--tools/idevicebackup.c11
-rw-r--r--tools/idevicebackup2.c16
-rw-r--r--tools/idevicedate.c21
-rw-r--r--tools/idevicedebugserverproxy.c24
-rw-r--r--tools/idevicediagnostics.c17
-rw-r--r--tools/ideviceenterrecovery.c5
-rw-r--r--tools/ideviceinfo.c21
-rw-r--r--tools/idevicescreenshot.c12
-rw-r--r--tools/idevicesyslog.c21
10 files changed, 60 insertions, 93 deletions
diff --git a/tools/idevice_id.c b/tools/idevice_id.c
index a2669b7..108aad4 100644
--- a/tools/idevice_id.c
+++ b/tools/idevice_id.c
@@ -53,8 +53,7 @@ int main(int argc, char **argv)
int ret = 0;
int i;
int mode = MODE_SHOW_ID;
- char udid[41];
- udid[0] = 0;
+ const char* udid = NULL;
/* parse cmdline args */
for (i = 1; i < argc; i++) {
@@ -79,7 +78,7 @@ int main(int argc, char **argv)
print_usage(argc, argv);
return 0;
}
- strcpy(udid, argv[i]);
+ udid = argv[i];
}
switch (mode) {
diff --git a/tools/idevicebackup.c b/tools/idevicebackup.c
index dbba217..8b862d6 100644
--- a/tools/idevicebackup.c
+++ b/tools/idevicebackup.c
@@ -820,9 +820,8 @@ int main(int argc, char *argv[])
{
idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR;
int i;
- char udid[41];
+ char* udid = NULL;
uint16_t port = 0;
- udid[0] = 0;
int cmd = -1;
int is_full_backup = 0;
char *backup_directory = NULL;
@@ -858,7 +857,7 @@ int main(int argc, char *argv[])
print_usage(argc, argv);
return 0;
}
- strcpy(udid, argv[i]);
+ udid = strdup(argv[i]);
continue;
}
else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) {
@@ -911,7 +910,7 @@ int main(int argc, char *argv[])
printf("Backup directory is \"%s\"\n", backup_directory);
- if (udid[0] != 0) {
+ if (udid) {
ret = idevice_new(&phone, udid);
if (ret != IDEVICE_E_SUCCESS) {
printf("No device found with udid %s, is it plugged in?\n", udid);
@@ -1700,6 +1699,10 @@ files_out:
idevice_free(phone);
+ if (udid) {
+ free(udid);
+ }
+
return 0;
}
diff --git a/tools/idevicebackup2.c b/tools/idevicebackup2.c
index 635a5ab..71afb5b 100644
--- a/tools/idevicebackup2.c
+++ b/tools/idevicebackup2.c
@@ -1197,9 +1197,8 @@ int main(int argc, char *argv[])
{
idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR;
int i;
- char udid[41];
+ char* udid = NULL;
uint16_t port = 0;
- udid[0] = 0;
int cmd = -1;
int cmd_flags = 0;
int is_full_backup = 0;
@@ -1230,7 +1229,7 @@ int main(int argc, char *argv[])
print_usage(argc, argv);
return 0;
}
- strcpy(udid, argv[i]);
+ udid = strdup(argv[i]);
continue;
}
else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) {
@@ -1294,7 +1293,7 @@ int main(int argc, char *argv[])
return -1;
}
- if (udid[0] != 0) {
+ if (udid) {
ret = idevice_new(&phone, udid);
if (ret != IDEVICE_E_SUCCESS) {
printf("No device found with udid %s, is it plugged in?\n", udid);
@@ -1308,10 +1307,7 @@ int main(int argc, char *argv[])
printf("No device found, is it plugged in?\n");
return -1;
}
- char *newudid = NULL;
- idevice_get_udid(phone, &newudid);
- strcpy(udid, newudid);
- free(newudid);
+ idevice_get_udid(phone, &udid);
}
/* backup directory must contain an Info.plist */
@@ -1893,6 +1889,10 @@ files_out:
idevice_free(phone);
+ if (udid) {
+ free(udid);
+ }
+
return 0;
}
diff --git a/tools/idevicedate.c b/tools/idevicedate.c
index 9de6ed0..19f7c1d 100644
--- a/tools/idevicedate.c
+++ b/tools/idevicedate.c
@@ -57,10 +57,9 @@ int main(int argc, char *argv[])
idevice_t phone = NULL;
idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR;
int i;
- char udid[41];
+ const char* udid = NULL;
time_t setdate = 0;
plist_t node = NULL;
- udid[0] = 0;
uint64_t datetime = 0;
time_t rawtime;
struct tm * tmp;
@@ -79,7 +78,7 @@ int main(int argc, char *argv[])
print_usage(argc, argv);
return 0;
}
- strcpy(udid, argv[i]);
+ udid = argv[i];
continue;
}
else if (!strcmp(argv[i], "-s") || !strcmp(argv[i], "--set")) {
@@ -124,20 +123,14 @@ int main(int argc, char *argv[])
}
}
- if (udid[0] != 0) {
- ret = idevice_new(&phone, udid);
- if (ret != IDEVICE_E_SUCCESS) {
+ ret = idevice_new(&phone, udid);
+ if (ret != IDEVICE_E_SUCCESS) {
+ if (udid) {
printf("No device found with udid %s, is it plugged in?\n", udid);
- return -1;
- }
- }
- else
- {
- ret = idevice_new(&phone, NULL);
- if (ret != IDEVICE_E_SUCCESS) {
+ } else {
printf("No device found, is it plugged in?\n");
- return -1;
}
+ return -1;
}
if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(phone, &client, "idevicedate")) {
diff --git a/tools/idevicedebugserverproxy.c b/tools/idevicedebugserverproxy.c
index 83aa479..1026fa2 100644
--- a/tools/idevicedebugserverproxy.c
+++ b/tools/idevicedebugserverproxy.c
@@ -227,8 +227,7 @@ int main(int argc, char *argv[])
idevice_connection_t connection = NULL;
idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR;
thread_t th;
- char udid[41];
- udid[0] = 0;
+ const char* udid = NULL;
uint16_t port = 0;
uint16_t local_port = 0;
int result = EXIT_SUCCESS;
@@ -256,7 +255,7 @@ int main(int argc, char *argv[])
print_usage(argc, argv);
return 0;
}
- strcpy(udid, argv[i]);
+ udid = argv[i];
continue;
}
else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) {
@@ -281,22 +280,15 @@ int main(int argc, char *argv[])
}
/* start services and connect to device */
- if (udid[0] != 0) {
- ret = idevice_new(&device, udid);
- if (ret != IDEVICE_E_SUCCESS) {
+ ret = idevice_new(&device, udid);
+ if (ret != IDEVICE_E_SUCCESS) {
+ if (udid) {
fprintf(stderr, "No device found with udid %s, is it plugged in?\n", udid);
- result = EXIT_FAILURE;
- goto leave_cleanup;
- }
- }
- else
- {
- ret = idevice_new(&device, NULL);
- if (ret != IDEVICE_E_SUCCESS) {
+ } else {
fprintf(stderr, "No device found, is it plugged in?\n");
- result = EXIT_FAILURE;
- goto leave_cleanup;
}
+ result = EXIT_FAILURE;
+ goto leave_cleanup;
}
if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(device, &lockdown, "idevicedebugserverproxy")) {
diff --git a/tools/idevicediagnostics.c b/tools/idevicediagnostics.c
index 3c7f0ac..10dab77 100644
--- a/tools/idevicediagnostics.c
+++ b/tools/idevicediagnostics.c
@@ -60,7 +60,7 @@ int main(int argc, char **argv)
uint16_t port = 0;
int result = -1;
int i;
- char *udid = NULL;
+ const char *udid = NULL;
int cmd = CMD_NONE;
char* cmd_arg = NULL;
plist_t node = NULL;
@@ -79,7 +79,7 @@ int main(int argc, char **argv)
result = 0;
goto cleanup;
}
- udid = strdup(argv[i]);
+ udid = argv[i];
continue;
}
else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) {
@@ -165,14 +165,14 @@ int main(int argc, char **argv)
}
if (IDEVICE_E_SUCCESS != idevice_new(&device, udid)) {
- printf("No device found, is it plugged in?\n");
+ if (udid) {
+ printf("No device found with udid %s, is it plugged in?\n", udid);
+ } else {
+ printf("No device found, is it plugged in?\n");
+ }
goto cleanup;
}
- if (udid) {
- free(udid);
- }
-
if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(device, &lockdown_client, NULL)) {
idevice_free(device);
printf("Unable to connect to lockdownd.\n");
@@ -261,9 +261,6 @@ int main(int argc, char **argv)
idevice_free(device);
cleanup:
- if (udid) {
- free(udid);
- }
if (node) {
plist_free(node);
}
diff --git a/tools/ideviceenterrecovery.c b/tools/ideviceenterrecovery.c
index fc46e75..62df70f 100644
--- a/tools/ideviceenterrecovery.c
+++ b/tools/ideviceenterrecovery.c
@@ -45,8 +45,7 @@ int main(int argc, char *argv[])
idevice_t phone = NULL;
idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR;
int i;
- char udid[41];
- udid[0] = 0;
+ const char* udid = NULL;
/* parse cmdline args */
for (i = 1; i < argc; i++) {
@@ -65,7 +64,7 @@ int main(int argc, char *argv[])
print_usage(argc, argv);
return 0;
}
- strcpy(udid, argv[i]);
+ udid = argv[i];
ret = idevice_new(&phone, udid);
if (ret != IDEVICE_E_SUCCESS) {
diff --git a/tools/ideviceinfo.c b/tools/ideviceinfo.c
index f3c8193..8635a48 100644
--- a/tools/ideviceinfo.c
+++ b/tools/ideviceinfo.c
@@ -285,14 +285,13 @@ int main(int argc, char *argv[])
int i;
int simple = 0;
int format = FORMAT_KEY_VALUE;
- char udid[41];
+ const char* udid = NULL;
char *domain = NULL;
char *key = NULL;
char *xml_doc = NULL;
uint32_t xml_length;
plist_t node = NULL;
plist_type node_type;
- udid[0] = 0;
/* parse cmdline args */
for (i = 1; i < argc; i++) {
@@ -306,7 +305,7 @@ int main(int argc, char *argv[])
print_usage(argc, argv);
return 0;
}
- strcpy(udid, argv[i]);
+ udid = argv[i];
continue;
}
else if (!strcmp(argv[i], "-q") || !strcmp(argv[i], "--domain")) {
@@ -348,20 +347,14 @@ int main(int argc, char *argv[])
}
}
- if (udid[0] != 0) {
- ret = idevice_new(&phone, udid);
- if (ret != IDEVICE_E_SUCCESS) {
+ ret = idevice_new(&phone, udid);
+ if (ret != IDEVICE_E_SUCCESS) {
+ if (udid) {
printf("No device found with udid %s, is it plugged in?\n", udid);
- return -1;
- }
- }
- else
- {
- ret = idevice_new(&phone, NULL);
- if (ret != IDEVICE_E_SUCCESS) {
+ } else {
printf("No device found, is it plugged in?\n");
- return -1;
}
+ return -1;
}
if (LOCKDOWN_E_SUCCESS != (simple ?
diff --git a/tools/idevicescreenshot.c b/tools/idevicescreenshot.c
index 766c7ac..cba62a2 100644
--- a/tools/idevicescreenshot.c
+++ b/tools/idevicescreenshot.c
@@ -39,7 +39,7 @@ int main(int argc, char **argv)
uint16_t port = 0;
int result = -1;
int i;
- char *udid = NULL;
+ const char *udid = NULL;
/* parse cmdline args */
for (i = 1; i < argc; i++) {
@@ -53,7 +53,7 @@ int main(int argc, char **argv)
print_usage(argc, argv);
return 0;
}
- udid = strdup(argv[i]);
+ udid = argv[i];
continue;
}
else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) {
@@ -67,15 +67,13 @@ int main(int argc, char **argv)
}
if (IDEVICE_E_SUCCESS != idevice_new(&device, udid)) {
- printf("No device found, is it plugged in?\n");
if (udid) {
- free(udid);
+ printf("No device found with udid %s, is it plugged in?\n", udid);
+ } else {
+ printf("No device found, is it plugged in?\n");
}
return -1;
}
- if (udid) {
- free(udid);
- }
if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(device, &lckd, NULL)) {
idevice_free(device);
diff --git a/tools/idevicesyslog.c b/tools/idevicesyslog.c
index 2adf327..73dd8e1 100644
--- a/tools/idevicesyslog.c
+++ b/tools/idevicesyslog.c
@@ -48,9 +48,8 @@ int main(int argc, char *argv[])
idevice_t phone = NULL;
idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR;
int i;
- char udid[41];
+ const char* udid = NULL;
uint16_t port = 0;
- udid[0] = 0;
signal(SIGINT, clean_exit);
signal(SIGTERM, clean_exit);
@@ -71,7 +70,7 @@ int main(int argc, char *argv[])
print_usage(argc, argv);
return 0;
}
- strcpy(udid, argv[i]);
+ udid = argv[i];
continue;
}
else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) {
@@ -84,20 +83,14 @@ int main(int argc, char *argv[])
}
}
- if (udid[0] != 0) {
- ret = idevice_new(&phone, udid);
- if (ret != IDEVICE_E_SUCCESS) {
+ ret = idevice_new(&phone, udid);
+ if (ret != IDEVICE_E_SUCCESS) {
+ if (udid) {
printf("No device found with udid %s, is it plugged in?\n", udid);
- return -1;
- }
- }
- else
- {
- ret = idevice_new(&phone, NULL);
- if (ret != IDEVICE_E_SUCCESS) {
+ } else {
printf("No device found, is it plugged in?\n");
- return -1;
}
+ return -1;
}
if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(phone, &client, "idevicesyslog")) {