diff options
Diffstat (limited to 'tools/idevicesyslog.c')
| -rw-r--r-- | tools/idevicesyslog.c | 12 |
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 @@ | |||
| 41 | #include <libimobiledevice/syslog_relay.h> | 41 | #include <libimobiledevice/syslog_relay.h> |
| 42 | 42 | ||
| 43 | static int quit_flag = 0; | 43 | static int quit_flag = 0; |
| 44 | static int exit_on_disconnect = 0; | ||
| 44 | 45 | ||
| 45 | static char* udid = NULL; | 46 | static char* udid = NULL; |
| 46 | 47 | ||
| @@ -155,6 +156,9 @@ static void device_event_cb(const idevice_event_t* event, void* userdata) | |||
| 155 | if (syslog && (strcmp(udid, event->udid) == 0)) { | 156 | if (syslog && (strcmp(udid, event->udid) == 0)) { |
| 156 | stop_logging(); | 157 | stop_logging(); |
| 157 | fprintf(stdout, "[disconnected]\n"); | 158 | fprintf(stdout, "[disconnected]\n"); |
| 159 | if (exit_on_disconnect) { | ||
| 160 | quit_flag++; | ||
| 161 | } | ||
| 158 | } | 162 | } |
| 159 | } | 163 | } |
| 160 | } | 164 | } |
| @@ -179,6 +183,7 @@ static void print_usage(int argc, char **argv, int is_error) | |||
| 179 | " -n, --network connect to network device even if available via USB\n" \ | 183 | " -n, --network connect to network device even if available via USB\n" \ |
| 180 | " -h, --help prints usage information\n" \ | 184 | " -h, --help prints usage information\n" \ |
| 181 | " -d, --debug enable communication debugging\n" \ | 185 | " -d, --debug enable communication debugging\n" \ |
| 186 | " -x, --exit exit when device disconnects\n" \ | ||
| 182 | "\n" \ | 187 | "\n" \ |
| 183 | "Homepage: <" PACKAGE_URL ">\n" | 188 | "Homepage: <" PACKAGE_URL ">\n" |
| 184 | ); | 189 | ); |
| @@ -191,6 +196,8 @@ int main(int argc, char *argv[]) | |||
| 191 | { "debug", no_argument, NULL, 'd' }, | 196 | { "debug", no_argument, NULL, 'd' }, |
| 192 | { "help", no_argument, NULL, 'h' }, | 197 | { "help", no_argument, NULL, 'h' }, |
| 193 | { "udid", required_argument, NULL, 'u' }, | 198 | { "udid", required_argument, NULL, 'u' }, |
| 199 | { "network", no_argument, NULL, 'n' }, | ||
| 200 | { "exit", no_argument, NULL, 'x' }, | ||
| 194 | { NULL, 0, NULL, 0} | 201 | { NULL, 0, NULL, 0} |
| 195 | }; | 202 | }; |
| 196 | 203 | ||
| @@ -201,7 +208,7 @@ int main(int argc, char *argv[]) | |||
| 201 | signal(SIGPIPE, SIG_IGN); | 208 | signal(SIGPIPE, SIG_IGN); |
| 202 | #endif | 209 | #endif |
| 203 | 210 | ||
| 204 | while ((c = getopt_long(argc, argv, "dhu:n", longopts, NULL)) != -1) { | 211 | while ((c = getopt_long(argc, argv, "dhu:nx", longopts, NULL)) != -1) { |
| 205 | switch (c) { | 212 | switch (c) { |
| 206 | case 'd': | 213 | case 'd': |
| 207 | idevice_set_debug_level(1); | 214 | idevice_set_debug_level(1); |
| @@ -218,6 +225,9 @@ int main(int argc, char *argv[]) | |||
| 218 | case 'n': | 225 | case 'n': |
| 219 | lookup_opts |= IDEVICE_LOOKUP_PREFER_NETWORK; | 226 | lookup_opts |= IDEVICE_LOOKUP_PREFER_NETWORK; |
| 220 | break; | 227 | break; |
| 228 | case 'x': | ||
| 229 | exit_on_disconnect = 1; | ||
| 230 | break; | ||
| 221 | case 'h': | 231 | case 'h': |
| 222 | print_usage(argc, argv, 0); | 232 | print_usage(argc, argv, 0); |
| 223 | return 0; | 233 | return 0; |
