aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/ports/libimobiledevice/004_fix_tools_msvc.patch
blob: 395eb1d6dc77175d954c4d76ba2581633771e018 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
diff --git a/tools/idevicebackup.c b/tools/idevicebackup.c
index 5694c12..77fd81f 100644
--- a/tools/idevicebackup.c
+++ b/tools/idevicebackup.c
@@ -50,7 +50,9 @@
 #else
 #error No supported crypto library enabled
 #endif
+#ifndef _MSC_VER
 #include <unistd.h>
+#endif
 #include <ctype.h>
 #include <time.h>
 
@@ -68,6 +70,18 @@
 #define LOCK_ATTEMPTS 50
 #define LOCK_WAIT 200000
 
+#ifdef _MSC_VER
+static void usleep(__int64 usec) {
+    HANDLE timer;
+    LARGE_INTEGER ft;
+    ft.QuadPart = -(10*usec);
+    timer = CreateWaitableTimer(NULL, TRUE, NULL);
+    SetWaitableTimer(timer, &ft, 0, NULL, NULL, 0);
+    WaitForSingleObject(timer, INFINITE);
+    CloseHandle(timer);
+}
+#endif
+
 #ifdef WIN32
 #include <windows.h>
 #define sleep(x) Sleep(x*1000)
diff --git a/tools/idevicebackup2.c b/tools/idevicebackup2.c
index c73b269..33157c9 100644
--- a/tools/idevicebackup2.c
+++ b/tools/idevicebackup2.c
@@ -31,9 +31,13 @@
 #include <errno.h>
 #include <stdlib.h>
 #include <signal.h>
+#ifndef _MSC_VER
 #include <unistd.h>
+#endif
 #include <dirent.h>
+#ifndef _MSC_VER
 #include <libgen.h>
+#endif
 #include <ctype.h>
 #include <time.h>
 #include <getopt.h>
@@ -54,6 +58,62 @@
 #define LOCK_ATTEMPTS 50
 #define LOCK_WAIT 200000
 
+#ifdef _MSC_VER
+static void usleep(__int64 usec) {
+    HANDLE timer;
+    LARGE_INTEGER ft;
+    ft.QuadPart = -(10*usec);
+    timer = CreateWaitableTimer(NULL, TRUE, NULL);
+    SetWaitableTimer(timer, &ft, 0, NULL, NULL, 0);
+    WaitForSingleObject(timer, INFINITE);
+    CloseHandle(timer);
+}
+#ifndef ISSLASH
+#define ISSLASH(C) ((C) == '/' || (C) == '\\')
+#endif
+#ifndef FILESYSTEM_PREFIX_LEN
+#define FILESYSTEM_PREFIX_LEN(Filename) 0
+#endif
+static char *basename(char const *name) {
+    char const *base = name + FILESYSTEM_PREFIX_LEN(name);
+    char const *p;
+
+    for (p = base; *p; p++) {
+        if (ISSLASH(*p)) {
+            do p++;
+            while (ISSLASH(*p));
+
+            if (!*p) {
+                if (ISSLASH(*base))
+                    base = p - 1;
+                break;
+            }
+            base = p;
+        }
+    }
+
+    return (char *) base;
+}
+static size_t dirlen(char const *path) {
+    size_t prefix_length = FILESYSTEM_PREFIX_LEN(path);
+    size_t length;
+    for (length = basename(path) - path; prefix_length < length; length--)
+        if (!ISSLASH(path[length - 1]))
+            return length;
+    return prefix_length + ISSLASH(path[prefix_length]);
+}
+static char *dirname(char const *path) {
+    size_t length = dirlen(path);
+    int append_dot = (length == FILESYSTEM_PREFIX_LEN(path));
+    char *newpath = (char *) malloc(length + append_dot + 1);
+    memcpy(newpath, path, length);
+    if (append_dot)
+        newpath[length++] = '.';
+    newpath[length] = 0;
+    return newpath;
+}
+#endif
+
 #ifdef WIN32
 #include <windows.h>
 #include <conio.h>
diff --git a/tools/idevicebtlogger.c b/tools/idevicebtlogger.c
index 8de6b22..8fbf40d 100644
--- a/tools/idevicebtlogger.c
+++ b/tools/idevicebtlogger.c
@@ -31,7 +31,9 @@
 #include <errno.h>
 #include <signal.h>
 #include <stdlib.h>
+#ifndef _MSC_VER
 #include <unistd.h>
+#endif
 #include <getopt.h>
 #include <assert.h>
 #include <fcntl.h>
diff --git a/tools/idevicecrashreport.c b/tools/idevicecrashreport.c
index 09bd537..9f53b30 100644
--- a/tools/idevicecrashreport.c
+++ b/tools/idevicecrashreport.c
@@ -29,7 +29,14 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#ifndef _MSC_VER
 #include <unistd.h>
+#else
+#define S_IFIFO _S_IFIFO
+#define S_IFBLK 0x3000
+#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
+#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
+#endif
 #include <getopt.h>
 #ifndef WIN32
 #include <signal.h>
diff --git a/tools/idevicedebug.c b/tools/idevicedebug.c
index 36c594e..9c11781 100644
--- a/tools/idevicedebug.c
+++ b/tools/idevicedebug.c
@@ -30,8 +30,12 @@
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
+#ifndef _MSC_VER
 #include <unistd.h>
+#endif
+#ifndef _MSC_VER
 #include <libgen.h>
+#endif
 #include <getopt.h>
 
 #ifdef WIN32
diff --git a/tools/idevicedevmodectl.c b/tools/idevicedevmodectl.c
index ba9b935..8e28e4b 100644
--- a/tools/idevicedevmodectl.c
+++ b/tools/idevicedevmodectl.c
@@ -30,7 +30,9 @@
 #include <string.h>
 #include <getopt.h>
 #include <sys/stat.h>
+#ifndef _MSC_VER
 #include <unistd.h>
+#endif
 #include <errno.h>
 #ifndef WIN32
 #include <signal.h>
diff --git a/tools/ideviceimagemounter.c b/tools/ideviceimagemounter.c
index f551b6c..26bb80c 100644
--- a/tools/ideviceimagemounter.c
+++ b/tools/ideviceimagemounter.c
@@ -32,9 +32,13 @@
 #include <string.h>
 #include <getopt.h>
 #include <errno.h>
+#ifndef _MSC_VER
 #include <libgen.h>
+#endif
 #include <time.h>
+#ifndef _MSC_VER
 #include <sys/time.h>
+#endif
 #include <inttypes.h>
 #ifndef WIN32
 #include <signal.h>
diff --git a/tools/idevicename.c b/tools/idevicename.c
index 69b76f6..cb8c9a6 100644
--- a/tools/idevicename.c
+++ b/tools/idevicename.c
@@ -27,7 +27,9 @@
 
 #include <stdio.h>
 #include <string.h>
+#ifndef _MSC_VER
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <getopt.h>
 #ifndef WIN32
diff --git a/tools/idevicepair.c b/tools/idevicepair.c
index 94d3f04..129c409 100644
--- a/tools/idevicepair.c
+++ b/tools/idevicepair.c
@@ -31,7 +31,9 @@
 #include <stdlib.h>
 #include <getopt.h>
 #include <ctype.h>
+#ifndef _MSC_VER
 #include <unistd.h>
+#endif
 #ifdef WIN32
 #include <windows.h>
 #include <conio.h>
diff --git a/tools/ideviceprovision.c b/tools/ideviceprovision.c
index 4080a28..f64e2c4 100644
--- a/tools/ideviceprovision.c
+++ b/tools/ideviceprovision.c
@@ -42,6 +42,14 @@
 #include <arpa/inet.h>
 #endif
 
+#ifdef _MSC_VER
+#include <Winsock2.h>
+#ifndef _S_ISTYPE
+#define _S_ISTYPE(mode, mask)  (((mode) & _S_IFMT) == (mask))
+#define S_ISDIR(mode) _S_ISTYPE((mode), _S_IFDIR)
+#endif
+#endif
+
 #include <libimobiledevice/libimobiledevice.h>
 #include <libimobiledevice/lockdown.h>
 #include <libimobiledevice/misagent.h>
diff --git a/tools/idevicescreenshot.c b/tools/idevicescreenshot.c
index 0e694c7..6f4b1c5 100644
--- a/tools/idevicescreenshot.c
+++ b/tools/idevicescreenshot.c
@@ -31,7 +31,11 @@
 #include <getopt.h>
 #include <errno.h>
 #include <time.h>
+#ifndef _MSC_VER
 #include <unistd.h>
+#else
+#define F_OK 0
+#endif
 #ifndef WIN32
 #include <signal.h>
 #endif
diff --git a/tools/idevicesyslog.c b/tools/idevicesyslog.c
index 5600be2..69b7b03 100644
--- a/tools/idevicesyslog.c
+++ b/tools/idevicesyslog.c
@@ -31,7 +31,9 @@
 #include <errno.h>
 #include <signal.h>
 #include <stdlib.h>
+#ifndef _MSC_VER
 #include <unistd.h>
+#endif
 #include <getopt.h>
 
 #ifdef WIN32