Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <unistd.h>
#include <CoreFoundation/CoreFoundation.h>
#include "MobileDevice.h"
#include <regex.h>

typedef struct {
service_conn_t connection;
Expand All @@ -13,6 +14,7 @@ static CFMutableDictionaryRef liveConnections;
static int debug;
static CFStringRef requiredDeviceId;
static char requiredProcessName[256];
static regex_t requiredProcessNamePattern;
static void (*printMessage)(int fd, const char *, size_t);
static void (*printSeparator)(int fd);

Expand Down Expand Up @@ -61,7 +63,7 @@ static unsigned char should_print_message(const char *buffer, size_t length)
if (processName[i]=='[')
processName[i]='\0';

if (strcmp(processName, requiredProcessName)!=0)
if (regexec(&requiredProcessNamePattern, processName, 0, NULL, 0))
return 0;
}

Expand Down Expand Up @@ -303,6 +305,10 @@ int main (int argc, char * const argv[])
break;
case 'p':
strcpy(requiredProcessName, optarg);
if (regcomp(&requiredProcessNamePattern, requiredProcessName, REG_EXTENDED)) {
fprintf(stderr, "Could not compile regex\n");
return 1;
}
break;
case '?':
if (optopt == 'u')
Expand Down