idevicesyslog: Add command line switch to exit when device disconnects

Also adds support for the long argument `--network` for `-n` as stated in the usage
diff --git a/tools/idevicesyslog.c b/tools/idevicesyslog.c
index a22c910..619b51b 100644
--- a/tools/idevicesyslog.c
+++ b/tools/idevicesyslog.c
@@ -41,6 +41,7 @@
 #include <libimobiledevice/syslog_relay.h>
 
 static int quit_flag = 0;
+static int exit_on_disconnect = 0;
 
 static char* udid = NULL;
 
@@ -155,6 +156,9 @@
 		if (syslog && (strcmp(udid, event->udid) == 0)) {
 			stop_logging();
 			fprintf(stdout, "[disconnected]\n");
+			if (exit_on_disconnect) {
+				quit_flag++;
+			}
 		}
 	}
 }
@@ -179,6 +183,7 @@
 	  "  -n, --network    connect to network device even if available via USB\n" \
 	  "  -h, --help       prints usage information\n" \
 	  "  -d, --debug      enable communication debugging\n" \
+	  "  -x, --exit       exit when device disconnects\n" \
 	  "\n" \
 	  "Homepage: <" PACKAGE_URL ">\n"
 	);
@@ -191,6 +196,8 @@
 		{ "debug", no_argument, NULL, 'd' },
 		{ "help", no_argument, NULL, 'h' },
 		{ "udid", required_argument, NULL, 'u' },
+		{ "network", no_argument, NULL, 'n' },
+		{ "exit", no_argument, NULL, 'x' },
 		{ NULL, 0, NULL, 0}
 	};
 
@@ -201,7 +208,7 @@
 	signal(SIGPIPE, SIG_IGN);
 #endif
 
-	while ((c = getopt_long(argc, argv, "dhu:n", longopts, NULL)) != -1) {
+	while ((c = getopt_long(argc, argv, "dhu:nx", longopts, NULL)) != -1) {
 		switch (c) {
 		case 'd':
 			idevice_set_debug_level(1);
@@ -218,6 +225,9 @@
 		case 'n':
 			lookup_opts |= IDEVICE_LOOKUP_PREFER_NETWORK;
 			break;
+		case 'x':
+			exit_on_disconnect = 1;
+			break;
 		case 'h':
 			print_usage(argc, argv, 0);
 			return 0;