From a55c3e762bceab49be53a76381ad28f818fb70b6 Mon Sep 17 00:00:00 2001 From: Matt Colyer Date: Tue, 19 Aug 2008 09:48:24 -0700 Subject: Put some very elementary error checking to ensure that initconf has been run. --- src/main.c | 44 +++++++++++++++++--------------------------- 1 file changed, 17 insertions(+), 27 deletions(-) (limited to 'src/main.c') 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; -- cgit v1.1-32-gdbae