summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorGravatar Matt Colyer2008-08-19 09:48:24 -0700
committerGravatar Matt Colyer2008-08-19 09:48:24 -0700
commita55c3e762bceab49be53a76381ad28f818fb70b6 (patch)
tree241c56c92c32ca8ead393f0f4e4fa19705a89659 /src/main.c
parentbc68ec7c3b8d37a2d3b8127e5591e9b505fd14cd (diff)
downloadlibplist-a55c3e762bceab49be53a76381ad28f818fb70b6.tar.gz
libplist-a55c3e762bceab49be53a76381ad28f818fb70b6.tar.bz2
Put some very elementary error checking to ensure that initconf has been run.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c44
1 files changed, 17 insertions, 27 deletions
diff --git a/src/main.c b/src/main.c
index 31c2a76..0267dee 100644
--- a/src/main.c
+++ b/src/main.c
@@ -37,37 +37,29 @@
int debug = 1;
int main(int argc, char *argv[]) {
- /* char* host_id = NULL; */
- iPhone *phone = get_iPhone();
- if (argc > 1 && !strcasecmp(argv[1], "--debug")) debug = 1;
- else debug = 0;
int bytes = 0, port = 0, i = 0;
- if (phone) printf("I got a phone.\n");
- else { printf("oops\n"); return -1; }
-
lockdownd_client *control = NULL;
- lockdownd_init(phone, &control);
- /*
- lockdownd_client *control = new_lockdownd_client(phone);
- if (!lockdownd_hello(control)) {
- printf("Something went wrong in the lockdownd client, go take a look.\n");
+ iPhone *phone = get_iPhone();
+
+ if (argc > 1 && !strcasecmp(argv[1], "--debug")){
+ debug = 1;
} else {
- printf("We said hello. :)\n");
+ debug = 0;
}
-
- printf("Now starting SSL.\n");
+
+ if (!phone) {
+ printf("No iPhone found, is it plugged in?\n");
+ return -1;
+ }
- host_id = get_host_id();
- if (host_id && !lockdownd_start_SSL_session(control, host_id)) {
- printf("Error happened in GnuTLS...\n");
- } else {
- free(host_id);
- host_id = NULL;*/
- printf("... we're in SSL with the phone... !?\n");
- port = lockdownd_start_service(control, "com.apple.afc");
- //}
+ if (!lockdownd_init(phone, &control)){
+ free_iPhone(phone);
+ return -1;
+ }
+
+ port = lockdownd_start_service(control, "com.apple.afc");
+
if (port) {
- printf("Start Service successful -- connect on port %i\n", port);
AFClient *afc = afc_connect(phone, 3432, port);
if (afc) {
char **dirs;
@@ -139,8 +131,6 @@ int main(int argc, char *argv[]) {
printf("Start service failure.\n");
}
- printf("All done.\n");
-
free_iPhone(phone);
return 0;