summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2013-03-20 05:38:06 +0100
committerGravatar Nikias Bassen2013-03-20 05:38:06 +0100
commitb2924a1549d874fb86deaad5fd2438e567c65bf4 (patch)
treeead89f885a0492cdfc228a1c25326912e7d9b973 /tools
parentefca491e4c19868a68a099638552f9ba431dca4b (diff)
downloadlibimobiledevice-b2924a1549d874fb86deaad5fd2438e567c65bf4.tar.gz
libimobiledevice-b2924a1549d874fb86deaad5fd2438e567c65bf4.tar.bz2
use new internal common code for thread, mutex, and socket operations
Diffstat (limited to 'tools')
-rw-r--r--tools/Makefile.am2
-rw-r--r--tools/idevicesyslog.c29
2 files changed, 7 insertions, 24 deletions
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 57445d8..e668592 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -18,7 +18,7 @@ idevicepair_LDADD = ../src/libimobiledevice.la
18idevicesyslog_SOURCES = idevicesyslog.c 18idevicesyslog_SOURCES = idevicesyslog.c
19idevicesyslog_CFLAGS = $(AM_CFLAGS) 19idevicesyslog_CFLAGS = $(AM_CFLAGS)
20idevicesyslog_LDFLAGS = $(AM_LDFLAGS) 20idevicesyslog_LDFLAGS = $(AM_LDFLAGS)
21idevicesyslog_LDADD = ../src/libimobiledevice.la 21idevicesyslog_LDADD = $(top_srcdir)/common/libinternalcommon.la ../src/libimobiledevice.la
22 22
23idevice_id_SOURCES = idevice_id.c 23idevice_id_SOURCES = idevice_id.c
24idevice_id_CFLAGS = $(AM_CFLAGS) 24idevice_id_CFLAGS = $(AM_CFLAGS)
diff --git a/tools/idevicesyslog.c b/tools/idevicesyslog.c
index 32163e6..3dd2257 100644
--- a/tools/idevicesyslog.c
+++ b/tools/idevicesyslog.c
@@ -29,13 +29,13 @@
29#ifdef WIN32 29#ifdef WIN32
30#include <windows.h> 30#include <windows.h>
31#define sleep(x) Sleep(x*1000) 31#define sleep(x) Sleep(x*1000)
32#else
33#include <pthread.h>
34#endif 32#endif
35 33
36#include <libimobiledevice/libimobiledevice.h> 34#include <libimobiledevice/libimobiledevice.h>
37#include <libimobiledevice/lockdown.h> 35#include <libimobiledevice/lockdown.h>
38#include "../src/service.h" 36
37#include "src/service.h"
38#include "common/thread.h"
39 39
40static int quit_flag = 0; 40static int quit_flag = 0;
41 41
@@ -46,11 +46,7 @@ static char* udid = NULL;
46static idevice_t device = NULL; 46static idevice_t device = NULL;
47static service_client_t syslog = NULL; 47static service_client_t syslog = NULL;
48 48
49#ifdef WIN32 49thread_t worker = NULL;
50HANDLE worker = NULL;
51#else
52pthread_t worker;
53#endif
54 50
55static int logging = 0; 51static int logging = 0;
56 52
@@ -100,19 +96,10 @@ static int start_logging()
100 96
101 /* start worker thread */ 97 /* start worker thread */
102 logging = 1; 98 logging = 1;
103#ifdef WIN32 99 if (thread_create(&worker, syslog_worker, NULL) != 0) {
104 worker = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)syslog_worker, NULL, 0, NULL);
105 if (worker == INVALID_HANDLE_VALUE) {
106 logging = 0; 100 logging = 0;
107 return -1; 101 return -1;
108 } 102 }
109#else
110 if (pthread_create(&worker, NULL, syslog_worker, NULL) != 0) {
111 logging = 0;
112 return -1;
113 }
114#endif
115
116 return 0; 103 return 0;
117} 104}
118 105
@@ -127,11 +114,7 @@ static void stop_logging()
127 } 114 }
128 115
129 /* wait for thread to complete */ 116 /* wait for thread to complete */
130#ifdef WIN32 117 thread_join(worker);
131 WaitForSingleObject(worker, INFINITE);
132#else
133 pthread_join(worker, NULL);
134#endif
135 } 118 }
136 119
137 if (device) { 120 if (device) {