summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2020-04-15 22:14:49 +0200
committerGravatar Nikias Bassen2020-04-15 22:14:49 +0200
commitdc20b07d9877ae0078930e1d977d10bfcda572e2 (patch)
tree853d21e12beaa9f811788bb59332023069870d15
parentcf5a60d75c2108261a6e848b352f798c1422349c (diff)
downloadlibimobiledevice-dc20b07d9877ae0078930e1d977d10bfcda572e2.tar.gz
libimobiledevice-dc20b07d9877ae0078930e1d977d10bfcda572e2.tar.bz2
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
-rw-r--r--tools/idevicesyslog.c12
1 files changed, 11 insertions, 1 deletions
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 @@ static void device_event_cb(const idevice_event_t* event, void* userdata)
if (syslog && (strcmp(udid, event->udid) == 0)) {
stop_logging();
fprintf(stdout, "[disconnected]\n");
+ if (exit_on_disconnect) {
+ quit_flag++;
+ }
}
}
}
@@ -179,6 +183,7 @@ static void print_usage(int argc, char **argv, int is_error)
" -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 @@ int main(int argc, char *argv[])
{ "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 @@ int main(int argc, char *argv[])
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 @@ int main(int argc, char *argv[])
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;