Modified .fossil-settings/clean-glob
from [06b87ad48d]
to [0ae1b8a1ac].
︙ | | |
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
-
|
src/tls/Info.plist
tests/DerivedData
tests/EBOOT.PBP
tests/Info.plist
tests/PARAM.SFO
tests/objc_sync/objc_sync
tests/plugin/Info.plist
tests/serialization_xml.m
tests/terminal/terminal_tests
tests/testfile_bin.m
tests/testfile_ini.m
tests/tests
tests/tests.3dsx
tests/tests.arm9
tests/tests.nds
|
︙ | | |
Modified .fossil-settings/ignore-glob
from [23cb69850b]
to [eed8ea3523].
︙ | | |
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
-
|
tests/Info.plist
tests/PARAM.SFO
tests/iOS.xcodeproj/*.pbxuser
tests/iOS.xcodeproj/project.xcworkspace
tests/iOS.xcodeproj/xcuserdata
tests/objc_sync/objc_sync
tests/plugin/Info.plist
tests/serialization_xml.m
tests/terminal/terminal_tests
tests/testfile_bin.m
tests/testfile_ini.m
tests/tests
tests/tests.3dsx
tests/tests.arm9
tests/tests.nds
|
︙ | | |
Added .github/workflows/dragonflybsd.yml version [e4f8b62803].
|
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
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
name: dragonflybsd
on: [push, pull_request]
jobs:
tests:
runs-on: macos-12
strategy:
matrix:
configure_flags:
-
- --disable-shared
- --with-tls=gnutls
steps:
- uses: actions/checkout@v3
- uses: vmactions/dragonflybsd-vm@v0
with:
usesh: true
copyback: false
prepare: |
pkg install -y autoconf automake gnutls llvm pkgconf
run: |
./autogen.sh
./configure OBJC=clang ${{ matrix.configure_flags }}
make -j4
make check
make install
|
| | | | | | | | | | | | | | | | | | | | | | | |
Added .github/workflows/freebsd.yml version [9828c9c463].
|
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
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
name: freebsd
on: [push, pull_request]
jobs:
tests:
runs-on: macos-12
strategy:
matrix:
configure_flags:
-
- --disable-shared
- --with-tls=gnutls
steps:
- uses: actions/checkout@v3
- uses: vmactions/freebsd-vm@v0
with:
usesh: true
copyback: false
prepare: |
pkg install -y autoconf automake gnutls pkgconf
run: |
./autogen.sh
./configure OBJC=clang ${{ matrix.configure_flags }}
make -j4
make check
make install
|
| | | | | | | | | | | | | | | | | | | | | | | |
Added .github/workflows/netbsd-gcc.yml version [4694c85176].
|
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
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
name: netbsd-gcc
on: [push, pull_request]
jobs:
tests:
runs-on: macos-12
strategy:
matrix:
configure_flags:
-
- --disable-shared
- --with-tls=gnutls
steps:
- uses: actions/checkout@v3
- uses: vmactions/netbsd-vm@v0
with:
usesh: true
copyback: false
prepare: |
pkg_add autoconf automake gnutls pkgconf
run: |
./autogen.sh
./configure OBJC=gcc ${{ matrix.configure_flags }}
make -j4
make check
make install
|
| | | | | | | | | | | | | | | | | | | | | | | |
Added .github/workflows/netbsd.yml version [2c6f34efc4].
|
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
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
name: netbsd
on: [push, pull_request]
jobs:
tests:
runs-on: macos-12
strategy:
matrix:
configure_flags:
-
- --disable-shared
- --with-tls=gnutls
steps:
- uses: actions/checkout@v3
- uses: vmactions/netbsd-vm@v0
with:
usesh: true
copyback: false
prepare: |
pkg_add autoconf automake clang gnutls pkgconf
run: |
./autogen.sh
./configure OBJC=clang ${{ matrix.configure_flags }}
make -j4
make check
make install
|
| | | | | | | | | | | | | | | | | | | | | | | |
Added .github/workflows/openbsd.yml version [7e76f12fa8].
|
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
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
name: openbsd
on: [push, pull_request]
jobs:
tests:
runs-on: macos-12
strategy:
matrix:
configure_flags:
-
- --disable-shared
- --with-tls=gnutls
steps:
- uses: actions/checkout@v3
- uses: vmactions/openbsd-vm@v0
with:
usesh: true
copyback: false
prepare: |
pkg_add autoconf-2.71 automake-1.16.5 gnutls pkgconf
run: |
./autogen.sh
./configure OBJC=clang ${{ matrix.configure_flags }}
make -j4
make check
make install
|
| | | | | | | | | | | | | | | | | | | | | | | |
Modified .gitignore
from [726b780402]
to [9fa51c850c].
︙ | | |
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
-
|
tests/Info.plist
tests/PARAM.SFO
tests/iOS.xcodeproj/*.pbxuser
tests/iOS.xcodeproj/project.xcworkspace
tests/iOS.xcodeproj/xcuserdata
tests/objc_sync/objc_sync
tests/plugin/Info.plist
tests/serialization_xml.m
tests/terminal/terminal_tests
tests/testfile_bin.m
tests/testfile_ini.m
tests/tests
tests/tests.3dsx
tests/tests.arm9
tests/tests.nds
|
︙ | | |
Modified Doxyfile
from [6b8aa42255]
to [3c7cbc0d44].
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
|
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
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
PROJECT_NAME = "ObjFW"
OUTPUT_DIRECTORY = docs/
INPUT = src src/exceptions src/runtime
FILE_PATTERNS = *.h *.m
HTML_OUTPUT = .
HAVE_DOT = NO
GENERATE_LATEX = NO
HIDE_UNDOC_CLASSES = YES
HIDE_UNDOC_MEMBERS = YES
TYPEDEF_HIDES_STRUCT = YES
PREDEFINED = __OBJC__ \
_Nonnull= \
_Nullable= \
DOXYGEN \
OF_BOXABLE= \
OF_CONSUMED= \
OF_DESIGNATED_INITIALIZER= \
OF_GENERIC(...)= \
OF_HAVE_BLOCKS \
OF_HAVE_FILES \
OF_HAVE_SANDBOX \
OF_HAVE_SOCKETS \
OF_HAVE_THREADS \
OF_KINDOF(...)= \
OF_NO_RETURN= \
OF_NO_RETURN_FUNC= \
OF_NULLABLE_PROPERTY(...)= \
OF_NULL_RESETTABLE_PROPERTY(...)= \
OF_REQUIRES_SUPER= \
OF_RETURNS_INNER_POINTER= \
OF_RETURNS_NOT_RETAINED= \
OF_RETURNS_RETAINED= \
OF_ROOT_CLASS= \
OF_SENTINEL= \
OF_WARN_UNUSED_RESULT= \
OF_WEAK_UNAVAILABLE= \
SIGHUP \
SIGUSR1 \
PREDEFINED = __OBJC__ \
_Nonnull= \
_Nullable= \
DOXYGEN \
OF_BOXABLE= \
OF_CONSUMED= \
OF_DESIGNATED_INITIALIZER= \
OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES \
OF_FILE_MANAGER_SUPPORTS_LINKS \
OF_FILE_MANAGER_SUPPORTS_OWNER \
OF_FILE_MANAGER_SUPPORTS_PERMISSIONS \
OF_FILE_MANAGER_SUPPORTS_SYMLINKS \
OF_GENERIC(...)= \
OF_HAVE_APPLETALK \
OF_HAVE_BLOCKS \
OF_HAVE_FILES \
OF_HAVE_IPV6 \
OF_HAVE_IPX \
OF_HAVE_SANDBOX \
OF_HAVE_SOCKETS \
OF_HAVE_THREADS \
OF_KINDOF(...)= \
OF_NO_RETURN= \
OF_NO_RETURN_FUNC= \
OF_NULLABLE_PROPERTY(...)= \
OF_NULL_RESETTABLE_PROPERTY(...)= \
OF_REQUIRES_SUPER= \
OF_RETURNS_INNER_POINTER= \
OF_RETURNS_NOT_RETAINED= \
OF_RETURNS_RETAINED= \
OF_ROOT_CLASS= \
OF_SENTINEL= \
OF_WARN_UNUSED_RESULT= \
OF_WEAK_UNAVAILABLE= \
SIGHUP \
SIGUSR1 \
SIGUSR2
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = YES
IGNORE_PREFIX = OF of_
|
Modified Makefile
from [4341fed160]
to [fa94f358a5].
︙ | | |
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
-
+
|
config.h \
config.log \
config.status \
extra.mk
include buildsys.mk
.PHONY: docs release
.PHONY: check docs release
utils tests: src
check: tests
cd tests && ${MAKE} -s run
docs:
|
︙ | | |
Modified PLATFORMS.md
from [cb8b9b98c6]
to [1aba75e60e].
︙ | | |
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
|
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
|
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
|
* Runtimes: ObjFW
DragonFlyBSD
------------
* OS Versions: 3.0, 3.3-DEVELOPMENT
* Architectures: x86, x86_64
* Architectures: AMD64, x86
* Compilers: GCC 4.4.7
* Runtimes: ObjFW
FreeBSD
-------
* OS Versions: 9.1-rc3, 10.0
* Architectures: x86_64
* Architectures: AMD64
* Compilers: Clang 3.1, Clang 3.3
* Runtimes: ObjFW
GNU/Hurd
--------
* OS Versions: 0.9
* Architectures: i686
* Compilers: Clang 14.0.6
* Runtimes: ObjFW
* Limitations: No support for UNIX sockets (`AF_UNIX` with `SOCK_DGRAM` is
currently broken in Hurd)
Haiku
-----
* OS version: r1-alpha4
* Architectures: x86
* Compilers: Clang 3.2, GCC 4.6.3
|
︙ | | |
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
|
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
|
-
-
+
+
-
+
-
+
|
* Compilers: Clang
* Runtimes: Apple
Linux
-----
* Architectures: Alpha, ARMv6, ARMv7, ARM64, Itanium, m68k, MIPS (O32),
MIPS64 (N64), RISC-V 64, PowerPC, S390x, SuperH-4, x86,
* Architectures: Alpha, AMD64, ARMv6, ARMv7, ARM64, Itanium, m68k, MIPS (O32),
MIPS64 (N64), RISC-V 64, PowerPC, S390x, SuperH-4, x86
x86_64
* Compilers: Clang 3.0-10.0, GCC 4.6-10.0
* C libraries: glibc, musl
* Runtimes: ObjFW
macOS
-----
* OS Versions: 10.5, 10.7-10.15, Darling
* Architectures: PowerPC, PowerPC64, x86, x86_64
* Architectures: AMD64, PowerPC, PowerPC64, x86
* Compilers: Clang 3.1-10.0, Apple GCC 4.0.1 & 4.2.1
* Runtimes: Apple, ObjFW
MiNT
----
|
︙ | | |
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
-
-
+
+
|
* Runtimes: ObjFW
NetBSD
------
* OS Versions: 5.1-9.0
* Architectures: ARM, ARM (big endian, BE8 mode), MIPS (O32), PowerPC, SPARC,
SPARC64, x86, x86_64
* Architectures: AMD64, ARM, ARM (big endian, BE8 mode), MIPS (O32), PowerPC,
SPARC, SPARC64, x86
* Compilers: Clang 3.0-3.2, GCC 4.1.3 & 4.5.3 & 7.4.0
* Runtimes: ObjFW
Nintendo 3DS
------------
|
︙ | | |
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
-
+
|
* Limitations: No sockets, no shared libraries, not tested on real hardware
OpenBSD
-------
* OS Versions: 5.2-6.7
* Architectures: MIPS64, PA-RISC, PowerPC, SPARC64, x86_64
* Architectures: AMD64, MIPS64, PA-RISC, PowerPC, SPARC64
* Compilers: GCC 6.3.0, Clang 4.0
* Runtimes: ObjFW
PlayStation Portable
--------------------
|
︙ | | |
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
-
-
-
+
+
+
|
* Compilers: GCC 4.6.1
* Runtimes: ObjFW
Solaris
-------
* OS Versions: OpenIndiana 2015.03
* Architectures: x86, x86_64
* Compilers: Clang 3.4.2, GCC 4.8.3
* OS Versions: OpenIndiana 2015.03, OpenIndiana 2023.04, Oracle Solaris 11.4
* Architectures: AMD64, x86
* Compilers: Clang 3.4.2, Clang 11.0.0, Clang 13.0.1, GCC 4.8.3, GCC 10.4.0
* Runtimes: ObjFW
Wii
---
* OS Versions: 4.3E / Homebrew Channel 1.1.0
|
︙ | | |
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
|
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
|
-
-
+
+
-
+
|
Windows
-------
* OS Versions: 98 SE, NT 4.0, XP (x86), 7 (x64), 8 (x64), 8.1 (x64), 10, 11,
Wine (x86 & x64)
* Architectures: x86, x86_64, AArch64
* Compilers: GCC 5.3.0 & 6.2.0 from msys2 (x86 & x64),
* Architectures: AArch64, AMD64, x86
* Compilers: GCC 5.3.0 & 6.2.0 from msys2 (AMD64 & x86),
Clang 3.9.0 from msys2 (x86),
Clang 10.0 from msys2 (x86 & x86_64),
Clang 10.0 from msys2 (AMD64 & x86),
Clang 14.0.4 from msys2 (AArch64)
* Runtimes: ObjFW
Others
------
|
︙ | | |
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
|
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
+
-
|
==========
As forwarding needs hand-written assembly for each combination of CPU
architecture, executable format and calling convention, it is only available
for the following platforms (except resolveClassMethod: and
resolveInstanceMethod:, which are always available):
* AMD64 (SysV/ELF, Apple/Mach-O, Mach-O, Win64/PE)
* ARM (EABI/ELF, Apple/Mach-O)
* ARM64 (ARM64/ELF, Apple/Mach-O)
* MIPS (O32/ELF, EABI/ELF)
* PowerPC (SysV/ELF, EABI/ELF, Apple/Mach-O)
* SPARC (SysV/ELF)
* SPARC64 (SysV/ELF)
* x86 (SysV/ELF, Apple/Mach-O, Win32/PE)
* x86_64 (SysV/ELF, Apple/Mach-O, Mach-O, Win64/PE)
Apple/Mach-O means both, the Apple ABI and runtime, while Mach-O means the
ObjFW runtime on Mach-O.
|
Modified README.md
from [b12bc1a9ce]
to [2681c29664].
︙ | | |
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
|
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
|
-
-
-
-
+
+
+
+
-
-
+
+
-
-
-
+
+
|
To build for macOS, just follow the
<a href="#installation">regular instructions</a> above.
To build for iOS, follow the regular instructions, but instead of
`./configure` do something like this:
$ clang="clang -isysroot $(xcrun --sdk iphoneos --show-sdk-path)"
$ export OBJC="$clang -arch armv7 -arch arm64"
$ export OBJCPP="$clang -arch armv7 -E"
$ export IPHONEOS_DEPLOYMENT_TARGET="9.0"
$ clang="xcrun --sdk iphoneos clang"
$ export OBJC="$clang -arch arm64e -arch arm64"
$ export OBJCPP="$clang -arch arm64e -E"
$ export IPHONEOS_DEPLOYMENT_TARGET="10.0"
$ ./configure --prefix=/usr/local/ios --host=arm64-apple-darwin
To build for the iOS simulator, follow the regular instructions, but instead
of `./configure` use something like this:
$ clang="clang -isysroot $(xcrun --sdk iphonesimulator --show-sdk-path)"
$ export OBJC="$clang -arch arm64 -arch x86_64"
$ clang="xcrun --sdk iphonesimulator clang"
$ export OBJC="$clang -arch $(uname -m)"
$ export OBJCPP="$clang -arch arm64 -E"
$ export IPHONEOS_DEPLOYMENT_TARGET="9.0"
$ ./configure --prefix=/usr/local/iossim --host=arm64-apple-darwin
$ export IPHONEOS_DEPLOYMENT_TARGET="10.0"
$ ./configure --prefix=/usr/local/iossim --host=$(uname -m)-apple-darwin
<h3 id="framework-in-xcode">Using the macOS or iOS framework in Xcode</h3>
To use the macOS framework in Xcode, you need to add the `.framework`s to
your project and add the following flags to `Other C Flags`:
-fconstant-string-class=OFConstantString -fno-constant-cfstrings
|
︙ | | |
Modified autogen.sh
from [4f8a1648f4]
to [fd90c83211].
1
2
3
4
5
6
7
8
9
10
11
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
+
-
-
-
+
+
+
+
|
#!/bin/sh
set -e
# Set a version for OpenBSD
if test x"$(uname -s)" = x"OpenBSD"; then
: ${AUTOCONF_VERSION:=2.69}
: ${AUTOMAKE_VERSION:=1.16}
export AUTOCONF_VERSION AUTOMAKE_VERSION
: ${AUTOCONF_VERSION:=2.71}
: ${AUTOMAKE_VERSION:=1.16}
export AUTOCONF_VERSION AUTOMAKE_VERSION
fi
aclocal -I build-aux/m4
autoconf
autoheader
|
Modified build-aux/m4/buildsys.m4
from [8a265c0c72]
to [4066b24b6a].
1
2
3
4
5
6
7
8
9
10
|
1
2
3
4
5
6
7
8
9
10
|
-
+
|
dnl
dnl Copyright (c) 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2016, 2017,
dnl 2018, 2020, 2021, 2022
dnl 2018, 2020, 2021, 2022, 2023
dnl Jonathan Schleifer <js@nil.im>
dnl
dnl https://fossil.nil.im/buildsys
dnl
dnl Permission to use, copy, modify, and/or distribute this software for any
dnl purpose with or without fee is hereby granted, provided that the above
dnl copyright notice and this permission notice is present in all copies.
|
︙ | | |
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
+
|
#endif
], [
host_is_ios="yes"
], [
host_is_ios="no"
])
AC_MSG_RESULT($host_is_ios)
AC_CHECK_TOOL(CODESIGN, codesign)
;;
esac
])
AC_DEFUN([BUILDSYS_PROG_IMPLIB], [
AC_REQUIRE([AC_CANONICAL_HOST])
AC_MSG_CHECKING(whether we need an implib)
|
︙ | | |
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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
|
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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
|
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
AC_SUBST(PROG_IMPLIB_NEEDED)
AC_SUBST(PROG_IMPLIB_LDFLAGS)
])
AC_DEFUN([BUILDSYS_SHARED_LIB], [
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([BUILDSYS_CHECK_IOS])
AC_MSG_CHECKING(for shared library system)
AC_MSG_CHECKING(for shared library type)
case "$host" in
*-*-darwin*)
AC_MSG_RESULT(Darwin)
LIB_CFLAGS='-fPIC -DPIC'
LIB_LDFLAGS='-dynamiclib -current_version ${LIB_MAJOR}.${LIB_MINOR} -compatibility_version ${LIB_MAJOR}'
LIB_LDFLAGS_INSTALL_NAME='-Wl,-install_name,${libdir}/$${out%.dylib}.${LIB_MAJOR}.dylib'
LIB_PREFIX='lib'
LIB_SUFFIX='.dylib'
AS_IF([test x"$enable_rpath" != x"no"], [
LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
])
PLUGIN_CFLAGS='-fPIC -DPIC'
PLUGIN_LDFLAGS='-bundle ${PLUGIN_LDFLAGS_BUNDLE_LOADER}'
PLUGIN_SUFFIX='.bundle'
AS_IF([test x"$host_is_ios" = x"yes"], [
LINK_PLUGIN='rm -fr $$out && ${MKDIR_P} $$out && if test -f Info.plist; then ${INSTALL} -m 644 Info.plist $$out/Info.plist; fi && ${LD} -o $$out/$${out%${PLUGIN_SUFFIX}} ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS} && ${CODESIGN} -fs ${CODESIGN_IDENTITY} --timestamp=none $$out'
], [
LINK_PLUGIN='rm -fr $$out && ${MKDIR_P} $$out/Contents/MacOS && if test -f Info.plist; then ${INSTALL} -m 644 Info.plist $$out/Contents/Info.plist; fi && ${LD} -o $$out/Contents/MacOS/$${out%${PLUGIN_SUFFIX}} ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS} && ${CODESIGN} -fs ${CODESIGN_IDENTITY} --timestamp=none $$out'
])
INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib && ${LN_S} -f $${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.dylib && ${LN_S} -f $${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib ${DESTDIR}${libdir}/$$i'
UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.dylib ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib'
INSTALL_PLUGIN='&& rm -fr ${DESTDIR}${plugindir}/$$i && cp -R $$i ${DESTDIR}${plugindir}/'
UNINSTALL_PLUGIN='&& rm -fr ${DESTDIR}${plugindir}/$$i'
CLEAN_LIB=''
;;
*-*-mingw* | *-*-cygwin*)
AC_MSG_RESULT(MinGW / Cygwin)
LIB_CFLAGS=''
LIB_LDFLAGS='-shared -Wl,--export-all-symbols'
LIB_LDFLAGS_INSTALL_NAME=''
LIB_PREFIX=''
LIB_SUFFIX='${LIB_MAJOR}.dll'
LINK_LIB='&& rm -f lib$${out%${LIB_SUFFIX}}.dll.a && ${LN_S} $$out lib$${out%${LIB_SUFFIX}}.dll.a'
PLUGIN_CFLAGS=''
PLUGIN_LDFLAGS='-shared -Wl,--export-all-symbols'
PLUGIN_SUFFIX='.dll'
LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
INSTALL_LIB='&& ${MKDIR_P} ${DESTDIR}${bindir} && ${INSTALL} -m 755 $$i ${DESTDIR}${bindir}/$$i && ${INSTALL} -m 755 lib$${i%${LIB_SUFFIX}}.dll.a ${DESTDIR}${libdir}/lib$${i%${LIB_SUFFIX}}.dll.a'
UNINSTALL_LIB='&& rm -f ${DESTDIR}${bindir}/$$i ${DESTDIR}${libdir}/lib$${i%${LIB_SUFFIX}}.dll.a'
INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i'
UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i'
CLEAN_LIB='${SHARED_LIB}.a ${SHARED_LIB_NOINST}.a'
;;
*-*-openbsd* | *-*-mirbsd*)
AC_MSG_RESULT(OpenBSD)
LIB_CFLAGS='-fPIC -DPIC'
LIB_LDFLAGS='-shared'
LIB_LDFLAGS_INSTALL_NAME=''
LIB_PREFIX='lib'
LIB_SUFFIX='.so.${LIB_MAJOR}.${LIB_MINOR}'
AS_IF([test x"$enable_rpath" != x"no"], [
LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
])
PLUGIN_CFLAGS='-fPIC -DPIC'
PLUGIN_LDFLAGS='-shared'
PLUGIN_SUFFIX='.so'
LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i'
UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i'
INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i'
UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i'
CLEAN_LIB=''
;;
*-*-solaris*)
AC_MSG_RESULT(Solaris)
LIB_CFLAGS='-fPIC -DPIC'
LIB_LDFLAGS='-shared -Wl,-soname=$$out.${LIB_MAJOR}.${LIB_MINOR}'
LIB_LDFLAGS_INSTALL_NAME=''
LIB_PREFIX='lib'
LIB_SUFFIX='.so'
AS_IF([test x"$enable_rpath" != x"no"], [
LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
])
PLUGIN_CFLAGS='-fPIC -DPIC'
PLUGIN_LDFLAGS='-shared'
PLUGIN_SUFFIX='.so'
LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR} && rm -f ${DESTDIR}${libdir}/$$i && ${LN_S} $$i.${LIB_MAJOR}.${LIB_MINOR} ${DESTDIR}${libdir}/$$i'
UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}'
INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i'
UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i'
CLEAN_LIB=''
;;
*-*-android*)
AC_MSG_RESULT(Android)
LIB_CFLAGS='-fPIC -DPIC'
LIB_LDFLAGS='-shared -Wl,-soname=$$out.${LIB_MAJOR}'
LIB_LDFLAGS_INSTALL_NAME=''
LIB_PREFIX='lib'
LIB_SUFFIX='.so'
PLUGIN_CFLAGS='-fPIC -DPIC'
PLUGIN_LDFLAGS='-shared'
PLUGIN_SUFFIX='.so'
LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.0 && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.0 ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.0 ${DESTDIR}${libdir}/$$i'
UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.0'
INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i'
UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i'
CLEAN_LIB=''
;;
hppa*-*-hpux*)
AC_MSG_RESULT([HP-UX (PA-RISC)])
LIB_CFLAGS='-fPIC -DPIC'
LIB_LDFLAGS='-shared -Wl,+h,$$out'
LIB_LDFLAGS_INSTALL_NAME=''
LIB_PREFIX='lib'
LIB_SUFFIX='.${LIB_MAJOR}'
LINK_LIB='&& rm -f $${out%%.*}.sl && ${LN_S} $$out $${out%%.*}.sl'
AS_IF([test x"$enable_rpath" != x"no"], [
LDFLAGS_RPATH='-Wl,+b,${libdir}'
])
PLUGIN_CFLAGS='-fPIC -DPIC'
PLUGIN_LDFLAGS='-shared'
PLUGIN_SUFFIX='.sl'
LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i && ${LN_S} -f $$i ${DESTDIR}${libdir}/$${i%%.*}.sl'
UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$${i%%.*}.sl'
INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i'
UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i'
CLEAN_LIB=''
;;
ia64*-*-hpux*)
AC_MSG_RESULT([HP-UX (Itanium)])
LIB_CFLAGS='-fPIC -DPIC'
LIB_LDFLAGS='-shared -Wl,+h,$$out'
LIB_LDFLAGS_INSTALL_NAME=''
LIB_PREFIX='lib'
LIB_SUFFIX='.${LIB_MAJOR}'
LINK_LIB='&& rm -f $${out%%.*}.so && ${LN_S} $$out $${out%%.*}.so'
AS_IF([test x"$enable_rpath" != x"no"], [
LDFLAGS_RPATH='-Wl,+b,${libdir}'
])
PLUGIN_CFLAGS='-fPIC -DPIC'
PLUGIN_LDFLAGS='-shared'
PLUGIN_SUFFIX='.so'
LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i && ${LN_S} -f $$i ${DESTDIR}${libdir}/$${i%%.*}.so'
UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$${i%%.*}.so'
INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i'
UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i'
CLEAN_LIB=''
;;
*)
AC_MSG_RESULT(ELF)
LIB_CFLAGS='-fPIC -DPIC'
LIB_LDFLAGS='-shared -Wl,-soname=$$out.${LIB_MAJOR}'
LIB_LDFLAGS_INSTALL_NAME=''
LIB_PREFIX='lib'
LIB_SUFFIX='.so'
AS_IF([test x"$enable_rpath" != x"no"], [
LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
])
PLUGIN_CFLAGS='-fPIC -DPIC'
PLUGIN_LDFLAGS='-shared'
PLUGIN_SUFFIX='.so'
LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.0 && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.0 ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.0 ${DESTDIR}${libdir}/$$i'
UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.0'
INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i'
UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i'
CLEAN_LIB=''
;;
esac
AC_SUBST(LIB_CFLAGS)
AC_SUBST(LIB_LDFLAGS)
AC_SUBST(LIB_LDFLAGS_INSTALL_NAME)
AC_SUBST(LIB_PREFIX)
AC_SUBST(LIB_SUFFIX)
AC_SUBST(LINK_LIB)
AC_SUBST(LDFLAGS_RPATH)
AC_SUBST(PLUGIN_CFLAGS)
AC_SUBST(PLUGIN_LDFLAGS)
AC_SUBST(PLUGIN_SUFFIX)
AC_SUBST(LINK_PLUGIN)
AC_SUBST(INSTALL_LIB)
AC_SUBST(UNINSTALL_LIB)
AC_SUBST(INSTALL_PLUGIN)
AC_SUBST(UNINSTALL_PLUGIN)
AC_SUBST(CLEAN_LIB)
])
AC_DEFUN([BUILDSYS_FRAMEWORK], [
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([BUILDSYS_CHECK_IOS])
AC_REQUIRE([BUILDSYS_SHARED_LIB])
AC_CHECK_TOOL(CODESIGN, codesign)
case "$host_os" in
darwin*)
AS_IF([test x"$host_is_ios" = x"yes"], [
FRAMEWORK_LDFLAGS='-dynamiclib -current_version ${LIB_MAJOR}.${LIB_MINOR} -compatibility_version ${LIB_MAJOR}'
FRAMEWORK_LDFLAGS_INSTALL_NAME='-Wl,-install_name,@executable_path/Frameworks/$$out/$${out%.framework}'
], [
FRAMEWORK_LDFLAGS='-dynamiclib -current_version ${LIB_MAJOR}.${LIB_MINOR} -compatibility_version ${LIB_MAJOR}'
FRAMEWORK_LDFLAGS_INSTALL_NAME='-Wl,-install_name,@executable_path/../Frameworks/$$out/$${out%.framework}'
])
AC_SUBST(FRAMEWORK_LDFLAGS)
AC_SUBST(FRAMEWORK_LDFLAGS_INSTALL_NAME)
AC_SUBST(FRAMEWORK_LIBS)
$1
;;
esac
])
AC_DEFUN([BUILDSYS_PLUGIN], [
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([BUILDSYS_CHECK_IOS])
AC_MSG_CHECKING(for plugin type)
case "$host" in
*-*-darwin*)
AC_MSG_RESULT(Darwin)
PLUGIN_CFLAGS='-fPIC -DPIC'
PLUGIN_LDFLAGS='-bundle ${PLUGIN_LDFLAGS_BUNDLE_LOADER}'
PLUGIN_SUFFIX='.bundle'
AS_IF([test x"$host_is_ios" = x"yes"], [
LINK_PLUGIN='rm -fr $$out && ${MKDIR_P} $$out && if test -f Info.plist; then ${INSTALL} -m 644 Info.plist $$out/Info.plist; fi && ${LD} -o $$out/$${out%${PLUGIN_SUFFIX}} ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS} && ${CODESIGN} -fs ${CODESIGN_IDENTITY} --timestamp=none $$out'
], [
LINK_PLUGIN='rm -fr $$out && ${MKDIR_P} $$out/Contents/MacOS && if test -f Info.plist; then ${INSTALL} -m 644 Info.plist $$out/Contents/Info.plist; fi && ${LD} -o $$out/Contents/MacOS/$${out%${PLUGIN_SUFFIX}} ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS} && ${CODESIGN} -fs ${CODESIGN_IDENTITY} --timestamp=none $$out'
])
INSTALL_PLUGIN='&& rm -fr ${DESTDIR}${plugindir}/$$i && cp -R $$i ${DESTDIR}${plugindir}/'
UNINSTALL_PLUGIN='&& rm -fr ${DESTDIR}${plugindir}/$$i'
;;
*-*-mingw* | *-*-cygwin*)
AC_MSG_RESULT(MinGW / Cygwin)
PLUGIN_CFLAGS=''
PLUGIN_LDFLAGS='-shared -Wl,--export-all-symbols'
PLUGIN_SUFFIX='.dll'
LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i'
UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i'
;;
hppa*-*-hpux*)
AC_MSG_RESULT([HP-UX (PA-RISC)])
PLUGIN_CFLAGS='-fPIC -DPIC'
PLUGIN_LDFLAGS='-shared'
PLUGIN_SUFFIX='.sl'
LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i'
UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i'
;;
*)
AC_MSG_RESULT(ELF)
PLUGIN_CFLAGS='-fPIC -DPIC'
PLUGIN_LDFLAGS='-shared'
PLUGIN_SUFFIX='.so'
LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i'
UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i'
;;
esac
AC_SUBST(PLUGIN_CFLAGS)
AC_SUBST(PLUGIN_LDFLAGS)
AC_SUBST(PLUGIN_SUFFIX)
AC_SUBST(LINK_PLUGIN)
AC_SUBST(INSTALL_PLUGIN)
AC_SUBST(UNINSTALL_PLUGIN)
])
|
Modified buildsys.mk.in
from [e067a2f2b2]
to [b42288d277].
︙ | | |
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
|
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
|
-
+
|
else \
${INSTALL_FAILED}; \
fi \
done
install-extra:
uninstall: uninstall-extra
uninstall:
for i in "" ${SUBDIRS} ${SUBDIRS_AFTER}; do \
test x"$$i" = x"" && continue; \
${DIR_ENTER}; \
${MAKE} -s uninstall || exit $$?; \
${DIR_LEAVE}; \
done
|
︙ | | |
871
872
873
874
875
876
877
878
879
880
881
882
883
884
|
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
|
+
+
|
if rm -f ${DESTDIR}${mandir}/${mansubdir}/$$i; then \
${DELETE_OK}; \
else \
${DELETE_FAILED}; \
fi \
fi \
done
${MAKE} -s uninstall-extra
uninstall-extra:
clean:
for i in "" ${SUBDIRS} ${SUBDIRS_AFTER}; do \
test x"$$i" = x"" && continue; \
${DIR_ENTER}; \
|
︙ | | |
Modified configure.ac
from [40a1438a77]
to [1f8f03a89e].
1
2
3
4
5
6
7
8
|
1
2
3
4
5
6
7
8
|
-
+
|
AC_INIT(ObjFW, 1.1dev, js@nil.im)
AC_INIT(ObjFW, 1.1dev, js@nil.im, objfw, https://objfw.nil.im/)
AC_CONFIG_SRCDIR(src)
AC_CONFIG_AUX_DIR(build-aux)
AC_CONFIG_MACRO_DIR(build-aux/m4)
AC_DEFINE(OBJFW_VERSION_MAJOR, 1, [The major version of ObjFW])
AC_DEFINE(OBJFW_VERSION_MINOR, 1, [The minor version of ObjFW])
dnl This may only be set to 1.1 once 1.1 is released
|
︙ | | |
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
-
+
|
;;
*-msdosdjgpp*)
enable_shared="no"
enable_threads="no"
enable_sockets="no"
;;
*-*-mingw*)
LDFLAGS="$LDFLAGS -Wl,--allow-multiple-definition -static-libgcc"
LDFLAGS="$LDFLAGS -Wl,--allow-multiple-definition"
LIBS="$LIBS -lversion"
AC_SUBST(USE_SRCS_WINDOWS, '${SRCS_WINDOWS}')
;;
*-psp-*)
AS_IF([test x"$DEVKITPSP" = x""], [
AC_MSG_ERROR([DEVKITPSP is not set! Please set DEVKITPSP.])
|
︙ | | |
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
+
+
+
+
+
+
+
+
|
LIBS="$LIBS -latomic"
;;
*-*-mint*)
enable_shared="no"
enable_threads="no" # TODO
with_tls="no"
;;
*-apple-macos*)
enable_shared="no"
enable_threads="no" # TODO
enable_sockets="no" # TODO
AC_DEFINE(OF_CLASSIC_MACOS, 1,
[Whether we are compiling for classic macOS])
;;
esac
AS_IF([test x"$host_os" = x"msdosdjgpp" -a x"$build_os" = x"msdosdjgpp"], [
dnl Hack to make configure find these on DOS.
: ${AR:=ar.exe}
: ${GREP:=grep.exe}
: ${RANLIB:=ranlib.exe}
|
︙ | | |
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
-
|
*)
potential_compilers="clang egcc gcc"
;;
esac
AC_PROG_OBJC($potential_compilers)
AC_PROG_OBJCPP
AC_PROG_LN_S
AC_PROG_EGREP
BUILDSYS_CHECK_IOS
AC_ARG_WITH(wii,
AS_HELP_STRING([--with-wii], [build for Wii]))
AS_IF([test x"$with_wii" = x"yes"], [
AS_IF([test x"$DEVKITPRO" = x""], [
|
︙ | | |
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
|
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
|
+
+
-
+
|
AS_HELP_STRING([--disable-amiga-lib], [do not build Amiga library]))
AS_IF([test x"$supports_amiga_lib" != x"yes"], [enable_amiga_lib="no"])
AC_ARG_ENABLE(shared,
AS_HELP_STRING([--disable-shared], [do not build shared library]))
AS_IF([test x"$enable_shared" != x"no"], [
BUILDSYS_SHARED_LIB
BUILDSYS_PLUGIN
AC_SUBST(OBJFW_SHARED_LIB, "${LIB_PREFIX}objfw${LIB_SUFFIX}")
AC_SUBST(OBJFW_SHARED_LIB, '${LIB_PREFIX}objfw${LIB_SUFFIX}')
AC_SUBST(EXCEPTIONS_LIB_A, "exceptions.lib.a")
AC_SUBST(FORWARDING_LIB_A, "forwarding.lib.a")
AC_SUBST(LOOKUP_ASM_LIB_A, "lookup-asm.lib.a")
BUILDSYS_FRAMEWORK([
AC_SUBST(OBJFW_FRAMEWORK, "ObjFW.framework")
build_framework="yes"
|
︙ | | |
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
|
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
|
-
+
|
])
AC_SUBST(RUNTIME, "runtime")
AC_CONFIG_FILES(src/runtime/Info.plist)
AS_IF([test x"$enable_shared" != x"no"], [
AC_SUBST(OBJFWRT_SHARED_LIB,
"${LIB_PREFIX}objfwrt${LIB_SUFFIX}")
'${LIB_PREFIX}objfwrt${LIB_SUFFIX}')
])
AS_IF([test x"$enable_static" = x"yes"], [
AC_SUBST(OBJFWRT_STATIC_LIB, "libobjfwrt.a")
])
AS_IF([test x"$build_framework" = x"yes"], [
|
︙ | | |
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
|
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
|
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
|
AC_CHECK_FUNC(sched_yield, [
AC_DEFINE(OF_HAVE_SCHED_YIELD, 1,
[Whether we have sched_yield()])
])
AC_CHECK_FUNCS(pthread_attr_getschedpolicy)
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -Werror"
AC_MSG_CHECKING(for pthread_attr_setinheritsched)
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
#include <pthread.h>
], [
AC_CHECK_FUNCS(pthread_attr_setinheritsched)
pthread_attr_setinheritsched(
(pthread_attr_t *)-1, 0);
])
], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_PTHREAD_ATTR_SETINHERITSCHED, 1,
[Whether we have pthread_attr_setinheritsched])
], [
AC_MSG_RESULT(no)
])
OBJCFLAGS="$old_OBJCFLAGS"
AC_CHECK_HEADERS(pthread_np.h, [], [], [#include <pthread.h>])
AC_CHECK_FUNCS(pthread_set_name_np pthread_setname_np, break)
;;
esac
AC_DEFINE(OF_HAVE_THREADS, 1, [Whether we have threads])
|
︙ | | |
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
|
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
|
-
+
|
*)
AC_CHECK_HEADERS(fcntl.h)
AC_CHECK_FUNCS([fcntl nanosleep])
;;
esac
AC_CHECK_HEADERS(xlocale.h)
AC_CHECK_FUNCS([strtod_l strtof_l asprintf_l])
AC_CHECK_FUNCS([strtod_l strtof_l asprintf_l uselocale])
AS_IF([test x"$gnu_source" != x"yes" -a \( \
x"$ac_cv_func_strtod_l" = x"yes" -o x"$ac_cv_func_strtof_l" = x"yes" -o \
x"$ac_cv_func_asprintf_l" = x"yes" \)], [
AC_MSG_CHECKING(whether *_l functions need _GNU_SOURCE)
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
#include <stdlib.h>
|
︙ | | |
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
|
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
|
;;
esac
AC_CHECK_HEADER(sys/socket.h, [
AC_DEFINE(OF_HAVE_SYS_SOCKET_H, 1,
[Whether we have sys/socket.h])
])
AC_CHECK_TYPE([struct sockaddr_storage], [
AC_DEFINE(OF_HAVE_SOCKADDR_STORAGE, 1,
[Whether we have struct sockaddr_storage])
], [], [
#ifdef OF_HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef OF_HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef _WIN32
# include <winsock2.h>
#endif
])
AC_CHECK_HEADER(netinet/in.h, [
AC_DEFINE(OF_HAVE_NETINET_IN_H, 1,
[Whether we have netinet/in.h])
])
AC_CHECK_HEADER(netinet/tcp.h, [
AC_DEFINE(OF_HAVE_NETINET_TCP_H, 1,
[Whether we have netinet/tcp.h])
])
AC_CHECK_HEADERS([arpa/inet.h netdb.h net/if.h])
AC_CHECK_HEADERS([arpa/inet.h netdb.h])
AC_CHECK_HEADERS([net/if.h net/if_arp.h net/if_dl.h net/if_types.h])
AC_CHECK_FUNCS([if_indextoname if_nametoindex])
AC_CHECK_TYPES([struct sockaddr_dl], [], [], [
#ifdef HAVAE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_NET_IF_DL_H
# include <net/if_dl.h>
#endif
])
AC_CHECK_HEADER(sys/un.h, [
AC_DEFINE(OF_HAVE_SYS_UN_H, 1, [Whether we have sys/un.h])
])
AC_CHECK_MEMBER([struct sockaddr_in6.sin6_addr], [
AC_EGREP_CPP(egrep_cpp_yes, [
#ifdef _WIN32
typedef int BOOL;
|
︙ | | |
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
|
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
# include <winsock2.h>
#endif
])
AC_CHECK_MEMBER(struct sockaddr_un.sun_path, [
AC_DEFINE(OF_HAVE_UNIX_SOCKETS, 1,
[Whether we have UNIX sockets])
AC_SUBST(USE_SRCS_UNIX_SOCKETS, '${SRCS_UNIX_SOCKETS}')
AC_CHECK_MEMBERS(struct sockaddr_un.sun_len, [], [], [
#ifdef OF_HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef OF_HAVE_SYS_UN_H
# include <sys/un.h>
#endif
#ifdef _WIN32
# include <winsock2.h>
#endif
#ifdef HAVE_AFUNIX_H
# include <afunix.h>
#endif
])
], [], [
#ifdef OF_HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef OF_HAVE_SYS_UN_H
# include <sys/un.h>
#endif
|
︙ | | |
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
|
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
|
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
|
#ifdef __morphos__
# error MorphOS has the struct but does not support it
#endif
#ifdef __MINT__
# error Gives invalid argument at runtime
#endif
#ifdef __gnu_hurd__
# error Empty sun_path in the source given by recvfrom()
#endif
])
AC_CHECK_HEADER(netipx/ipx.h, [
AC_DEFINE(OF_HAVE_NETIPX_IPX_H, 1,
[Whether we have netipx/ipx.h])
])
AC_CHECK_MEMBER(struct sockaddr_ipx.sipx_network, [], [
AC_CHECK_MEMBER(struct sockaddr_ipx.sa_netnum, [], [], [
AC_CHECK_MEMBER(struct sockaddr_ipx.sa_netnum, [], [
AC_CHECK_MEMBER(struct sockaddr_ipx.sipx_addr.x_port, [
], [], [
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef OF_HAVE_NETIPX_IPX_H
# include <netipx/ipx.h>
#endif
])
], [
#ifdef _WIN32
typedef int BOOL;
#endif
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef OF_HAVE_NETIPX_IPX_H
# include <netipx/ipx.h>
#endif
#ifdef _WIN32
# ifdef __MINGW32__
# include <_mingw.h>
# ifdef __MINGW64_VERSION_MAJOR
# include <winsock2.h>
# endif
# endif
# include <windows.h>
# include <wsipx.h>
#endif
])
], [
#ifdef _WIN32
typedef int BOOL;
#endif
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef OF_HAVE_NETIPX_IPX_H
# include <netipx/ipx.h>
#endif
#ifdef _WIN32
# ifdef __MINGW32__
# include <_mingw.h>
# ifdef __MINGW64_VERSION_MAJOR
# include <winsock2.h>
# endif
# endif
# include <windows.h>
# include <wsipx.h>
#endif
])
AS_IF([test x"$ac_cv_member_struct_sockaddr_ipx_sipx_network" = x"yes" \
-o x"$ac_cv_member_struct_sockaddr_ipx_sa_netnum" = x"yes"], [
-o x"$ac_cv_member_struct_sockaddr_ipx_sa_netnum" = x"yes" -o \
x"$ac_cv_member_struct_sockaddr_ipx_sipx_addr_x_port" = x"yes"], [
AC_EGREP_CPP(egrep_cpp_yes, [
#ifdef _WIN32
typedef int BOOL;
#endif
#ifdef OF_HAVE_SYS_SOCKET_H
# include <sys/socket.h>
|
︙ | | |
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
|
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
|
+
+
+
-
+
-
-
-
-
+
-
-
-
+
-
-
-
|
[Whether we have select() or similar])
AC_SUBST(OF_SELECT_KERNEL_EVENT_OBSERVER_M,
"OFSelectKernelEventObserver.m")
])
;;
esac
AC_CHECK_HEADERS(net/if.h)
AC_CHECK_FUNCS(if_nameindex)
AC_ARG_WITH(tls,
AS_HELP_STRING([--with-tls], [
enable TLS support using the specified library
(yes, openssl, gnutls, securetransport or no)]))
AS_IF([test x"$with_tls" = x""], [with_tls="yes"])
tls_support="no"
AS_IF([test x"$with_tls" = x"securetransport" \
-o x"$with_tls" = x"yes"], [
-o x"$with_tls" = x"yes"], [
AC_CHECK_HEADERS(Security/SecureTransport.h, [
old_LIBS="$LIBS"
LIBS="-framework Security -framework Foundation $LIBS"
AC_CHECK_FUNC(SSLHandshake, [
AC_DEFINE(HAVE_SECURE_TRANSPORT, 1,
[Whether we have Secure Transport])
tls_support="Secure Transport"
TLS_LIBS="-framework Foundation $TLS_LIBS"
TLS_LIBS="-framework Security $TLS_LIBS"
AC_SUBST(OF_SECURE_TRANSPORT_TLS_STREAM_M,
"OFSecureTransportTLSStream.m")
AC_CHECK_FUNCS(SSLCreateContext)
], [])
LIBS="$old_LIBS"
])
])
AS_IF([test x"$with_tls" = x"gnutls" \
-o \( x"$with_tls" = x"yes" -a x"$tls_support" = x"no" \)], [
-o \( x"$with_tls" = x"yes" -a x"$tls_support" = x"no" \)], [
PKG_CHECK_MODULES(gnutls, [gnutls >= 3.5.0], [
AC_DEFINE(HAVE_GNUTLS, 1, [Whether we have GnuTLS])
tls_support="GnuTLS"
TLS_CPPFLAGS="$gnutls_CFLAGS $TLS_CPPFLAGS"
TLS_LIBS="$gnutls_LIBS $TLS_LIBS"
AC_SUBST(OF_GNUTLS_TLS_STREAM_M, "OFGnuTLSTLSStream.m")
], [
dnl Disable default action-if-not-found, which exits
dnl configure with an error.
:
])
])
AS_IF([test x"$with_tls" = x"openssl" \
-o \( x"$with_tls" = x"yes" -a x"$tls_support" = x"no" \)], [
-o \( x"$with_tls" = x"yes" -a x"$tls_support" = x"no" \)], [
case "$host_os" in
morphos*)
ssl="ssl_shared"
crypto="crypto_shared"
;;
*)
ssl="ssl"
crypto="crypto"
;;
esac
AC_CHECK_LIB($ssl, SSL_set1_host, [
AC_CHECK_HEADER(openssl/ssl.h, [
AC_DEFINE(HAVE_OPENSSL, 1,
[Whether we have OpenSSL])
tls_support="OpenSSL"
TLS_LIBS="-l$ssl -l$crypto $TLS_LIBS"
AC_SUBST(OF_OPENSSL_TLS_STREAM_M,
"OFOpenSSLTLSStream.m")
])
], [], [-l$crypto])
|
︙ | | |
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
|
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
|
-
+
|
[Whether we have an implementation for TLS])
AC_CONFIG_FILES(src/tls/Info.plist)
OFHTTP_LIBS="-lobjfwtls $TLS_LIBS $OFHTTP_LIBS"
AS_IF([test x"$enable_shared" != x"no"], [
AC_SUBST(OBJFWTLS_SHARED_LIB,
"${LIB_PREFIX}objfwtls${LIB_SUFFIX}")
'${LIB_PREFIX}objfwtls${LIB_SUFFIX}')
])
AS_IF([test x"$enable_static" = x"yes" \
-o x"$enable_shared" = x"no"], [
AC_SUBST(OBJFWTLS_STATIC_LIB, "libobjfwtls.a")
])
AS_IF([test x"$build_framework" = x"yes"], [
AC_SUBST(OBJFWTLS_FRAMEWORK, "ObjFWTLS.framework")
|
︙ | | |
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
|
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
|
-
-
-
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
-
+
-
+
-
+
|
#if (!defined(TARGET_OS_IPHONE) || !TARGET_OS_IPHONE) && \
(!defined(TARGET_OS_SIMULATOR) || !TARGET_OS_SIMULATOR)
egrep_cpp_yes
#endif
], [
AC_MSG_RESULT(yes)
have_subprocesses="yes"
AC_CHECK_FUNCS(posix_spawnp)
AC_CHECK_HEADERS(spawn.h)
], [
AC_MSG_RESULT(no)
have_subprocesses="no"
])
;;
mingw*)
have_subprocesses="yes"
;;
msdosdjgpp*)
have_subprocesses="no"
;;
*)
esac
AS_IF([test x"$have_subprocesses" = x""], [
AC_HEADER_SYS_WAIT
AC_CHECK_FUNCS(kill)
AC_CHECK_FUNCS(posix_spawnp, [
AS_IF([test x"$ac_cv_func_kill" = x"yes"], [
have_subprocesses="yes"
AC_CHECK_HEADERS(spawn.h, [have_subprocesses="yes"])
])
AC_CHECK_HEADERS(spawn.h)
])
], [
])
AS_IF([test x"$have_subprocesses" = x""], [
AC_CHECK_FUNCS([vfork dup2 execvp _exit], [
AS_IF([test x"$ac_cv_func_vfork" = x"yes" \
-a x"$ac_cv_func_pipe" = x"yes" \
-a x"$ac_cv_func_dup2" = x"yes" \
-a x"$ac_cv_func_execvp" = x"yes" \
-a x"$ac_cv_func_kill" = x"yes" \
-a x"$ac_cv_func__exit" = x"yes"], [
have_subprocesses="yes"
])
], [
break
])
])
;;
esac
])
AS_IF([test x"$have_subprocesses" = x"yes"], [
AC_SUBST(OF_SUBPROCESS_M, "OFSubprocess.m")
AC_DEFINE(OF_HAVE_SUBPROCESSES, 1, [Whether we have subprocesses])
])
AC_CHECK_HEADERS_ONCE([complex.h sys/ioctl.h sys/ttycom.h])
AC_CHECK_FUNCS(isatty)
AC_CHECK_FUNCS(ioctl isatty)
AC_CHECK_FUNC(pledge, [
AC_DEFINE(OF_HAVE_PLEDGE, 1, [Whether we have pledge()])
])
AS_IF([test x"$objc_runtime" = x"Apple runtime"], [
AC_CHECK_HEADER(Foundation/NSObject.h, [
AC_SUBST(BRIDGE, "bridge")
AC_CONFIG_FILES(src/bridge/Info.plist)
AS_IF([test x"$enable_shared" != x"no"], [
AC_SUBST(OBJFWBRIDGE_SHARED_LIB,
"${LIB_PREFIX}objfwbridge${LIB_SUFFIX}")
'${LIB_PREFIX}objfwbridge${LIB_SUFFIX}')
])
AS_IF([test x"$enable_static" = x"yes" \
-o x"$enable_shared" = x"no"], [
AC_SUBST(OBJFWBRIDGE_STATIC_LIB, "libobjfwbridge.a")
])
AS_IF([test x"$build_framework" = x"yes"], [
AC_SUBST(OBJFWBRIDGE_FRAMEWORK,
|
︙ | | |
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
|
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
], [
AC_MSG_RESULT(no)
], [
AC_MSG_RESULT(yes)
OBJCFLAGS="$old_OBJCFLAGS"
])
])
AC_MSG_CHECKING(whether we need -Wno-strict-prototypes)
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
#include <signal.h>
], [
signal(SIGINT, SIG_DFL);
])
], [
AC_MSG_RESULT(no)
], [
AC_MSG_RESULT(yes)
OBJCFLAGS="$OBJCFLAGS -Wno-strict-prototypes"
])
AS_IF([test x"$ac_cv_header_complex_h" = x"yes"], [
AC_MSG_CHECKING(whether we need -Wno-gnu-imaginary-constant)
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
#include <complex.h>
], [
|
︙ | | |
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
|
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
|
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
|
i?86-*-mingw*)
AC_CHECK_PROG(WINE, wine, wine)
;;
x86_64-*-mingw*)
AC_CHECK_PROG(WINE, wine64, wine64)
;;
esac
AS_IF([test x"$WINE" != x""], [
AS_IF([test x"$WINE" != x""], [AC_SUBST(WRAPPER, "$WINE")])
AC_SUBST(WRAPPER, "$WINE")
])
AS_IF([test x"$with_wii" = x"yes"], [
dnl Keep this lowercase, as WIILOAD is a variable used by
dnl wiiload and thus likely already set by the user to something
dnl that is not the path of the wiiload binary.
AC_CHECK_PROG(wiiload, wiiload, wiiload)
AS_IF([test x"$wiiload" != x""], [
AC_SUBST(WRAPPER, "$wiiload")
])
])
])
AC_ARG_WITH(fish_completions,
AS_HELP_STRING([--with-fish-completions],
[install completions for the fish shell]))
AS_IF([test x"$with_fish_completions" = x""], [
AC_CHECK_PROG(FISH, fish, fish)
AS_IF([test x"$FISH" != x""], [with_fish_completions="yes"])
])
AS_IF([test x"$with_fish_completions" = x"yes"], [
AC_SUBST(FISH_COMPLETIONS, fish)
])
dnl We don't call AC_PROG_CPP, but only AC_PROG_OBJCPP and set CPP to OBJCPP
dnl and add OBJCPPFLAGS to CPPFLAGS, thus we need to AC_SUBST these ourself.
AC_SUBST(CPP)
AC_SUBST(CPPFLAGS)
dnl We use the ObjC compiler as our assembler
AC_SUBST(AS, $OBJC)
AC_SUBST(ASFLAGS)
|
︙ | | |
Modified extra.mk.in
from [e1760eea9d]
to [bdbfcf399d].
︙ | | |
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
-
|
ENCODINGS_A = @ENCODINGS_A@
ENCODINGS_AMIGALIB_A = @ENCODINGS_AMIGALIB_A@
ENCODINGS_LIB_A = @ENCODINGS_LIB_A@
ENCODINGS_SRCS = @ENCODINGS_SRCS@
EXCEPTIONS_A = @EXCEPTIONS_A@
EXCEPTIONS_AMIGALIB_A = @EXCEPTIONS_AMIGALIB_A@
EXCEPTIONS_LIB_A = @EXCEPTIONS_LIB_A@
FISH_COMPLETIONS = @FISH_COMPLETIONS@
FORWARDING_A = @FORWARDING_A@
FORWARDING_AMIGALIB_A = @FORWARDING_AMIGALIB_A@
FORWARDING_LIB_A = @FORWARDING_LIB_A@
LIBBASES_M = @LIBBASES_M@
LIBOBJFWRT_DEP = @LIBOBJFWRT_DEP@
LIBOBJFWRT_DEP_LVL2 = @LIBOBJFWRT_DEP_LVL2@
LIBOBJFW_DEP = @LIBOBJFW_DEP@
|
︙ | | |
Modified generators/library/FuncArrayGenerator.h
from [2d0edf7996]
to [d8b783c7a3].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified generators/library/FuncArrayGenerator.m
from [4ed090453c]
to [71c76426fb].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified generators/library/GlueGenerator.h
from [df3f9366c5]
to [9ffcc85ae6].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified generators/library/GlueGenerator.m
from [a4f73aa06c]
to [ec62f49bc2].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified generators/library/LibraryGenerator.m
from [5f9c6926df]
to [d060eed3f3].
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
|
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
|
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
-
+
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#import "OFApplication.h"
#import "OFFile.h"
#import "OFFileManager.h"
#import "OFURI.h"
#import "OFIRI.h"
#import "OFXMLElement.h"
#import "FuncArrayGenerator.h"
#import "GlueGenerator.h"
#import "LinkLibGenerator.h"
@interface LibraryGenerator: OFObject <OFApplicationDelegate>
@end
OF_APPLICATION_DELEGATE(LibraryGenerator)
@implementation LibraryGenerator
- (void)generateInDirectory: (OFString *)directory
{
OFURI *sourcesURI = [[OFFileManager defaultManager].currentDirectoryURI
URIByAppendingPathComponent: directory];
OFURI *libraryURI = [sourcesURI
URIByAppendingPathComponent: @"amiga-library.xml"];
OFURI *linkLibURI = [sourcesURI
URIByAppendingPathComponent: @"linklib/linklib.m"];
OFURI *glueHeaderURI = [sourcesURI
URIByAppendingPathComponent: @"amiga-glue.h"];
OFURI *glueURI = [sourcesURI
URIByAppendingPathComponent: @"amiga-glue.m"];
OFURI *funcArrayURI = [sourcesURI
URIByAppendingPathComponent: @"amiga-funcarray.inc"];
OFIRI *sourcesIRI = [[OFFileManager defaultManager].currentDirectoryIRI
IRIByAppendingPathComponent: directory];
OFIRI *libraryIRI = [sourcesIRI
IRIByAppendingPathComponent: @"amiga-library.xml"];
OFIRI *linkLibIRI = [sourcesIRI
IRIByAppendingPathComponent: @"linklib/linklib.m"];
OFIRI *glueHeaderIRI = [sourcesIRI
IRIByAppendingPathComponent: @"amiga-glue.h"];
OFIRI *glueIRI = [sourcesIRI
IRIByAppendingPathComponent: @"amiga-glue.m"];
OFIRI *funcArrayIRI = [sourcesIRI
IRIByAppendingPathComponent: @"amiga-funcarray.inc"];
OFXMLElement *library = [OFXMLElement elementWithStream:
[OFFile fileWithPath: libraryURI.fileSystemRepresentation
[OFFile fileWithPath: libraryIRI.fileSystemRepresentation
mode: @"r"]];
OFFile *linkLib =
[OFFile fileWithPath: linkLibURI.fileSystemRepresentation
[OFFile fileWithPath: linkLibIRI.fileSystemRepresentation
mode: @"w"];
OFFile *glueHeader =
[OFFile fileWithPath: glueHeaderURI.fileSystemRepresentation
[OFFile fileWithPath: glueHeaderIRI.fileSystemRepresentation
mode: @"w"];
OFFile *glue =
[OFFile fileWithPath: glueURI.fileSystemRepresentation mode: @"w"];
[OFFile fileWithPath: glueIRI.fileSystemRepresentation mode: @"w"];
OFFile *funcArray =
[OFFile fileWithPath: funcArrayURI.fileSystemRepresentation
[OFFile fileWithPath: funcArrayIRI.fileSystemRepresentation
mode: @"w"];
LinkLibGenerator *linkLibGenerator = [[[LinkLibGenerator alloc]
initWithLibrary: library
implementation: linkLib] autorelease];
GlueGenerator *glueGenerator = [[[GlueGenerator alloc]
initWithLibrary: library
header: glueHeader
|
︙ | | |
Modified generators/library/LinkLibGenerator.h
from [58647bf17f]
to [fb82d2e9a6].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified generators/library/LinkLibGenerator.m
from [223399c150]
to [0ba5af7f3b].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified generators/library/copyright.h
from [c0b22b50fd]
to [210478e1ad].
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
|
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
|
-
+
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFString.h"
#define COPYRIGHT \
@"/*\n" \
@" * Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>\n" \
@" * Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>\n" \
@" *\n" \
@" * All rights reserved.\n" \
@" *\n" \
@" * This file is part of ObjFW. It may be distributed under the terms " \
@"of the\n" \
@" * Q Public License 1.0, which can be found in the file LICENSE.QPL " \
@"included in\n" \
|
︙ | | |
Modified generators/unicode/TableGenerator.h
from [d5ba8e12b8]
to [68e11922ac].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified generators/unicode/TableGenerator.m
from [f18304006d]
to [3403a36c8e].
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
|
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
|
-
+
-
+
-
-
+
+
-
-
-
+
+
+
-
+
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#include <string.h>
#import "OFString.h"
#import "OFApplication.h"
#import "OFArray.h"
#import "OFApplication.h"
#import "OFURI.h"
#import "OFFile.h"
#import "OFHTTPClient.h"
#import "OFHTTPRequest.h"
#import "OFHTTPResponse.h"
#import "OFHTTPClient.h"
#import "OFFile.h"
#import "OFStdIOStream.h"
#import "OFIRI.h"
#import "OFStdIOStream.h"
#import "OFString.h"
#import "OFOutOfRangeException.h"
#import "TableGenerator.h"
#import "copyright.h"
static OFString *const unicodeDataURI =
static OFString *const unicodeDataIRI =
@"http://www.unicode.org/Public/UNIDATA/UnicodeData.txt";
static OFString *const caseFoldingURI =
static OFString *const caseFoldingIRI =
@"http://www.unicode.org/Public/UNIDATA/CaseFolding.txt";
OF_APPLICATION_DELEGATE(TableGenerator)
@implementation TableGenerator
- (instancetype)init
{
|
︙ | | |
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
-
-
+
+
|
- (void)applicationDidFinishLaunching: (OFNotification *)notification
{
OFHTTPRequest *request;
[OFStdOut writeString: @"Downloading UnicodeData.txt…"];
_state = stateUnicodeData;
request = [OFHTTPRequest requestWithURI:
[OFURI URIWithString: unicodeDataURI]];
request = [OFHTTPRequest requestWithIRI:
[OFIRI IRIWithString: unicodeDataIRI]];
[_HTTPClient asyncPerformRequest: request];
}
- (void)client: (OFHTTPClient *)client
didPerformRequest: (OFHTTPRequest *)request
response: (OFHTTPResponse *)response
exception: (id)exception
|
︙ | | |
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
-
-
+
+
|
[self applyDecompositionRecursivelyForTable: _decompositionTable];
[self applyDecompositionRecursivelyForTable: _decompositionCompatTable];
[OFStdOut writeLine: @" done"];
[OFStdOut writeString: @"Downloading CaseFolding.txt…"];
_state = stateCaseFolding;
request = [OFHTTPRequest requestWithURI:
[OFURI URIWithString: caseFoldingURI]];
request = [OFHTTPRequest requestWithIRI:
[OFIRI IRIWithString: caseFoldingIRI]];
[_HTTPClient asyncPerformRequest: request];
}
- (void)parseCaseFolding: (OFHTTPResponse *)response
{
OFString *line;
|
︙ | | |
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
|
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
|
-
+
-
-
+
+
-
-
+
+
|
objc_autoreleasePoolPop(pool);
}
} while (!done);
}
- (void)writeFiles
{
OFURI *URI;
OFIRI *IRI;
[OFStdOut writeString: @"Writing files…"];
URI = [OFURI fileURIWithPath: @"../../src/unicode.m"];
[self writeTablesToFile: URI.fileSystemRepresentation];
IRI = [OFIRI fileIRIWithPath: @"../../src/unicode.m"];
[self writeTablesToFile: IRI.fileSystemRepresentation];
URI = [OFURI fileURIWithPath: @"../../src/unicode.h"];
[self writeHeaderToFile: URI.fileSystemRepresentation];
IRI = [OFIRI fileIRIWithPath: @"../../src/unicode.h"];
[self writeHeaderToFile: IRI.fileSystemRepresentation];
[OFStdOut writeLine: @" done"];
[OFApplication terminate];
}
- (void)writeTablesToFile: (OFString *)path
|
︙ | | |
Modified generators/unicode/copyright.h
from [c0b22b50fd]
to [210478e1ad].
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
|
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
|
-
+
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFString.h"
#define COPYRIGHT \
@"/*\n" \
@" * Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>\n" \
@" * Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>\n" \
@" *\n" \
@" * All rights reserved.\n" \
@" *\n" \
@" * This file is part of ObjFW. It may be distributed under the terms " \
@"of the\n" \
@" * Q Public License 1.0, which can be found in the file LICENSE.QPL " \
@"included in\n" \
|
︙ | | |
Modified objfw.spec
from [218ec62f80]
to [77fa467494].
︙ | | |
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
|
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
|
-
+
-
+
-
-
-
+
-
+
+
+
-
-
-
+
+
+
+
-
-
-
+
+
-
-
-
+
-
+
+
+
-
-
-
+
-
+
+
+
-
-
-
+
-
+
+
+
-
-
-
+
-
+
+
+
-
-
-
-
+
-
+
-
-
-
-
-
-
+
+
+
+
+
-
+
-
-
-
-
-
-
+
+
+
+
+
-
+
+
+
-
-
-
-
+
-
+
+
+
|
%post -n %{libobjfw_pkgname} -p /sbin/ldconfig
%postun -n %{libobjfw_pkgname} -p /sbin/ldconfig
%post -n %{libobjfwrt_pkgname} -p /sbin/ldconfig
%postun -n %{libobjfwrt_pkgname} -p /sbin/ldconfig
%endif
%files
%license LICENSE.QPL
%license LICENSE.GPLv2
%license LICENSE.GPLv3
%license LICENSE.GPLv2
%license LICENSE.QPL
%files -n %{libobjfw_pkgname}
%{_libdir}/libobjfw.so.%{libobjfw_major}
%{_libdir}/libobjfw.so.%{libobjfw_major}.%{libobjfw_minor}.0
%license LICENSE.QPL
%license LICENSE.GPLv2
%license LICENSE.GPLv3
%license LICENSE.GPLv2
%license LICENSE.QPL
%{_libdir}/libobjfw.so.%{libobjfw_major}
%{_libdir}/libobjfw.so.%{libobjfw_major}.%{libobjfw_minor}.0
%files -n %{libobjfw_pkgname}-devel
%{_libdir}/libobjfw.so
%dir %{_includedir}/ObjFW
%{_includedir}/ObjFW
%license LICENSE.GPLv2
%license LICENSE.GPLv3
%license LICENSE.QPL
%{_bindir}/objfw-compile
%{_bindir}/objfw-config
%{_bindir}/objfw-embed
%{_bindir}/objfw-new
%license LICENSE.QPL
%license LICENSE.GPLv3
%license LICENSE.GPLv2
%{_includedir}/ObjFW
%{_libdir}/libobjfw.so
%files -n %{libobjfwrt_pkgname}
%{_libdir}/libobjfwrt.so.%{libobjfwrt_major}
%{_libdir}/libobjfwrt.so.%{libobjfwrt_major}.%{libobjfwrt_minor}.0
%license LICENSE.QPL
%license LICENSE.GPLv2
%license LICENSE.GPLv3
%license LICENSE.GPLv2
%license LICENSE.QPL
%{_libdir}/libobjfwrt.so.%{libobjfwrt_major}
%{_libdir}/libobjfwrt.so.%{libobjfwrt_major}.%{libobjfwrt_minor}.0
%files -n %{libobjfwrt_pkgname}-devel
%{_libdir}/libobjfwrt.so
%{_includedir}/ObjFWRT/ObjFWRT.h
%license LICENSE.QPL
%license LICENSE.GPLv2
%license LICENSE.GPLv3
%license LICENSE.GPLv2
%license LICENSE.QPL
%{_includedir}/ObjFWRT
%{_libdir}/libobjfwrt.so
%files -n %{libobjfwtls_pkgname}
%{_libdir}/libobjfwtls.so.%{libobjfwtls_major}
%{_libdir}/libobjfwtls.so.%{libobjfwtls_major}.%{libobjfwtls_minor}.0
%license LICENSE.QPL
%license LICENSE.GPLv2
%license LICENSE.GPLv3
%license LICENSE.GPLv2
%license LICENSE.QPL
%{_libdir}/libobjfwtls.so.%{libobjfwtls_major}
%{_libdir}/libobjfwtls.so.%{libobjfwtls_major}.%{libobjfwtls_minor}.0
%files -n %{libobjfwtls_pkgname}-devel
%{_libdir}/libobjfwtls.so
%{_includedir}/ObjFWTLS/ObjFWTLS.h
%license LICENSE.QPL
%license LICENSE.GPLv2
%license LICENSE.GPLv3
%license LICENSE.GPLv2
%license LICENSE.QPL
%{_includedir}/ObjFWTLS
%{_libdir}/libobjfwtls.so
%files -n ofarc
%{_bindir}/ofarc
%{_datadir}/ofarc/lang/de.json
%{_datadir}/ofarc/lang/languages.json
%license LICENSE.QPL
%license LICENSE.GPLv2
%license LICENSE.GPLv3
%license LICENSE.GPLv2
%license LICENSE.QPL
%files -n ofdns
%{_bindir}/ofdns
%{_datadir}/ofdns/lang/de.json
%{_datadir}/ofdns/lang/languages.json
%license LICENSE.QPL
%{_bindir}/ofarc
%{_datadir}/ofarc
%files -n ofdns
%license LICENSE.GPLv2
%license LICENSE.GPLv3
%license LICENSE.GPLv2
%license LICENSE.QPL
%files -n ofhash
%{_bindir}/ofhash
%{_datadir}/ofhash/lang/de.json
%{_datadir}/ofhash/lang/languages.json
%license LICENSE.QPL
%{_bindir}/ofdns
%{_datadir}/ofdns
%files -n ofhash
%license LICENSE.GPLv2
%license LICENSE.GPLv3
%license LICENSE.GPLv2
%license LICENSE.QPL
%{_bindir}/ofhash
%{_datadir}/ofhash
%files -n ofhttp
%{_bindir}/ofhttp
%{_datadir}/ofhttp/lang/de.json
%{_datadir}/ofhttp/lang/languages.json
%license LICENSE.QPL
%license LICENSE.GPLv2
%license LICENSE.GPLv3
%license LICENSE.GPLv2
%license LICENSE.QPL
%{_bindir}/ofhttp
%{_datadir}/ofhttp
|
Modified src/Makefile
from [3a642b130e]
to [176138bf55].
︙ | | |
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
|
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
|
-
+
+
+
+
-
-
-
-
-
-
-
|
OFConstantString.m \
OFCountedSet.m \
OFData.m \
OFData+CryptographicHashing.m \
OFData+MessagePackParsing.m \
OFDate.m \
OFDictionary.m \
OFEmbeddedURIHandler.m \
OFEnumerator.m \
OFFileManager.m \
OFGZIPStream.m \
OFHMAC.m \
OFINICategory.m \
OFINIFile.m \
OFIRI.m \
OFIRIHandler.m \
OFInflate64Stream.m \
OFInflateStream.m \
OFInvocation.m \
OFLHAArchive.m \
OFLHAArchiveEntry.m \
OFList.m \
OFLocale.m \
OFMD5Hash.m \
OFMapTable.m \
OFMatrix4x4.m \
OFMemoryStream.m \
OFMessagePackExtension.m \
OFMethodSignature.m \
OFMutableArray.m \
OFMutableData.m \
OFMutableDictionary.m \
OFMutableIRI.m \
OFMutableLHAArchiveEntry.m \
OFMutablePair.m \
OFMutableSet.m \
OFMutableString.m \
OFMutableTarArchiveEntry.m \
OFMutableTriple.m \
OFMutableURI.m \
OFMutableZIPArchiveEntry.m \
OFNotification.m \
OFNotificationCenter.m \
OFNull.m \
OFNumber.m \
OFObject.m \
OFObject+KeyValueCoding.m \
OFObject+Serialization.m \
OFOnce.m \
OFOptionsParser.m \
OFPBKDF2.m \
OFPair.m \
OFRIPEMD160Hash.m \
OFRunLoop.m \
OFSHA1Hash.m \
OFSHA224Hash.m \
OFSHA224Or256Hash.m \
OFSHA256Hash.m \
OFSHA384Hash.m \
OFSHA384Or512Hash.m \
OFSHA512Hash.m \
OFScrypt.m \
OFSecureData.m \
OFSeekableStream.m \
OFSerialization.m \
OFSet.m \
OFSettings.m \
OFSortedList.m \
OFStdIOStream.m \
OFStream.m \
OFString.m \
OFString+CryptographicHashing.m \
OFString+JSONParsing.m \
OFString+PercentEncoding.m \
OFString+PropertyListParsing.m \
OFString+Serialization.m \
OFString+XMLEscaping.m \
OFString+XMLUnescaping.m \
${OF_SUBPROCESS_M} \
OFSystemInfo.m \
OFTarArchive.m \
OFTarArchiveEntry.m \
OFThread.m \
OFTimer.m \
OFTriple.m \
OFURI.m \
OFURIHandler.m \
OFUUID.m \
OFValue.m \
OFXMLAttribute.m \
OFXMLCDATA.m \
OFXMLCharacters.m \
OFXMLComment.m \
OFXMLElement.m \
OFXMLElement+Serialization.m \
OFXMLElementBuilder.m \
OFXMLNode.m \
OFXMLParser.m \
OFXMLProcessingInstruction.m \
OFZIPArchive.m \
OFZIPArchiveEntry.m \
${USE_SRCS_FILES} \
|
︙ | | |
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
+
|
OFHTTPCookieManager.m \
OFHTTPRequest.m \
OFHTTPResponse.m \
OFHTTPServer.m \
OFSequencedPacketSocket.m \
OFSocket.m \
OFStreamSocket.m \
OFSystemInfo+NetworkInterfaces.m \
OFTCPSocket.m \
OFTLSStream.m \
OFUDPSocket.m \
${USE_SRCS_APPLETALK} \
${USE_SRCS_IPX} \
${USE_SRCS_UNIX_SOCKETS}
SRCS_APPLETALK = OFDDPSocket.m
|
︙ | | |
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
-
+
+
|
objfw-defs.h \
platform.h \
${USE_INCLUDES_ATOMIC}
SRCS += OFASPrintF.m \
OFAdjacentArray.m \
OFAdjacentSubarray.m \
OFArchiveURIHandler.m \
OFArchiveIRIHandler.m \
OFBase64.m \
OFBitSetCharacterSet.m \
OFBytesValue.m \
OFCRC16.m \
OFCRC32.m \
OFCountedMapTableSet.m \
OFEmbeddedIRIHandler.m \
OFHuffmanTree.m \
OFINIFileSettings.m \
OFInvertedCharacterSet.m \
OFLHADecompressingStream.m \
OFMapTableDictionary.m \
OFMapTableSet.m \
OFMutableAdjacentArray.m \
|
︙ | | |
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
-
+
-
+
|
OFStrPTime.m \
OFSubarray.m \
OFUTF8String.m \
${LIBBASES_M} \
${RUNTIME_AUTORELEASE_M} \
${RUNTIME_INSTANCE_M} \
${UNICODE_M}
SRCS_FILES += OFFileURIHandler.m
SRCS_FILES += OFFileIRIHandler.m
SRCS_SOCKETS += OFAsyncIPSocketConnector.m \
OFDNSResolverSettings.m \
${OF_EPOLL_KERNEL_EVENT_OBSERVER_M} \
OFHTTPURIHandler.m \
OFHTTPIRIHandler.m \
OFHostAddressResolver.m \
OFKernelEventObserver.m \
${OF_KQUEUE_KERNEL_EVENT_OBSERVER_M} \
${OF_POLL_KERNEL_EVENT_OBSERVER_M} \
${OF_SELECT_KERNEL_EVENT_OBSERVER_M} \
OFTCPSocketSOCKS5Connector.m
SRCS_WINDOWS += platform/Windows/OFWin32ConsoleStdIOStream.m \
|
︙ | | |
262
263
264
265
266
267
268
|
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
|
+
+
+
+
+
+
+
+
|
AMIGA_LIB_LIBS := -Lruntime -Lruntime/linklib -lobjfwrt.library.amigalib ${LIBS}
LIBS := -Lruntime -Lruntime/linklib ${RUNTIME_LIBS} ${REEXPORT_RUNTIME} ${LIBS}
RCFLAGS = --use-temp-file \
-DOBJFW_LIB_MAJOR=${OBJFW_LIB_MAJOR} \
-DOBJFW_LIB_MINOR=${OBJFW_LIB_MINOR} \
-DOBJFW_LIB_VERSION=\"${OBJFW_LIB_MAJOR}.${OBJFW_LIB_MINOR}\" \
-DOBJFW_SHARED_LIB=\"${OBJFW_SHARED_LIB}\"
uninstall-extra:
for i in platform/GCC4 platform/GCC4.7 platform/PowerPC platform/macOS \
platform/x86 platform ""; do \
if test -d ${DESTDIR}${includedir}/${includesubdir}/$$i; then \
rmdir ${DESTDIR}${includedir}/${includesubdir}/$$i; \
fi; \
done
|
Modified src/OFASPrintF.h
from [090f42d33a]
to [a9b63bfa65].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFASPrintF.m
from [882db55cea]
to [84a6c0408a].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
-
+
|
#include <stdarg.h>
#include <stdbool.h>
#ifdef HAVE_WCHAR_H
# include <wchar.h>
#endif
#ifdef HAVE_ASPRINTF_L
#if defined(HAVE_ASPRINTF_L) || defined(HAVE_USELOCALE)
# include <locale.h>
#endif
#ifdef HAVE_XLOCALE_H
# include <xlocale.h>
#endif
#ifdef OF_HAVE_SYS_TYPES_H
|
︙ | | |
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
-
+
|
lengthModifierZ,
lengthModifierT,
lengthModifierCapitalL
} lengthModifier;
bool useLocale;
};
#ifdef HAVE_ASPRINTF_L
#if defined(HAVE_ASPRINTF_L) || defined(HAVE_USELOCALE)
static locale_t cLocale;
OF_CONSTRUCTOR()
{
if ((cLocale = newlocale(LC_ALL_MASK, "C", NULL)) == NULL)
@throw [OFInitializationFailedException exception];
}
|
︙ | | |
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
|
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
|
-
+
|
}
static bool
formatConversionSpecifierState(struct Context *ctx)
{
char *tmp = NULL;
int tmpLen = 0;
#ifndef HAVE_ASPRINTF_L
#if !defined(HAVE_ASPRINTF_L) && !defined(HAVE_USELOCALE)
OFString *point;
#endif
if (!appendSubformat(ctx, ctx->format + ctx->i, 1))
return false;
switch (ctx->format[ctx->i]) {
|
︙ | | |
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
|
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
|
-
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
-
+
-
-
-
+
+
+
|
case 'g':
case 'G':
case 'a':
case 'A':
switch (ctx->lengthModifier) {
case lengthModifierNone:
case lengthModifierL:
#ifdef HAVE_ASPRINTF_L
#if defined(HAVE_ASPRINTF_L)
if (!ctx->useLocale)
tmpLen = asprintf_l(&tmp, cLocale,
ctx->subformat,
va_arg(ctx->arguments, double));
else
#elif defined(HAVE_USELOCALE)
if (!ctx->useLocale) {
locale_t previousLocale = uselocale(cLocale);
tmpLen = asprintf(&tmp, ctx->subformat,
va_arg(ctx->arguments, double));
uselocale(previousLocale);
} else
#endif
tmpLen = asprintf(&tmp, ctx->subformat,
va_arg(ctx->arguments, double));
break;
case lengthModifierCapitalL:
#ifdef HAVE_ASPRINTF_L
#if defined(HAVE_ASPRINTF_L)
if (!ctx->useLocale)
tmpLen = asprintf_l(&tmp, cLocale,
ctx->subformat,
va_arg(ctx->arguments, long double));
else
#elif defined(HAVE_USELOCALE)
if (!ctx->useLocale) {
locale_t previousLocale = uselocale(cLocale);
tmpLen = asprintf(&tmp, ctx->subformat,
va_arg(ctx->arguments, long double));
uselocale(previousLocale);
} else
#endif
tmpLen = asprintf(&tmp, ctx->subformat,
va_arg(ctx->arguments, long double));
break;
default:
return false;
}
#ifndef HAVE_ASPRINTF_L
#if !defined(HAVE_ASPRINTF_L) && !defined(HAVE_USELOCALE)
if (tmpLen == -1)
return false;
/*
* If there's no asprintf_l, we have no other choice than to
* use this ugly hack to replace the locale's decimal point
* back to ".".
* If there's no asprintf_l and no uselocale, we have no other
* choice than to use this ugly hack to replace the locale's
* decimal point back to ".".
*/
point = [OFLocale decimalSeparator];
if (!ctx->useLocale && point != nil && ![point isEqual: @"."]) {
void *pool = objc_autoreleasePoolPush();
char *tmp2;
|
︙ | | |
Modified src/OFAdjacentArray.h
from [9facc27db0]
to [e6ee87088b].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFAdjacentArray.m
from [e305e33733]
to [3d57d1e63c].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
-
|
#include <stdarg.h>
#import "OFAdjacentArray.h"
#import "OFAdjacentSubarray.h"
#import "OFData.h"
#import "OFMutableAdjacentArray.h"
#import "OFString.h"
#import "OFXMLElement.h"
#import "OFEnumerationMutationException.h"
#import "OFInvalidArgumentException.h"
#import "OFOutOfRangeException.h"
@implementation OFAdjacentArray
- (instancetype)init
|
︙ | | |
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
|
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
for (size_t i = 0; i < count; i++)
[objects[i] release];
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
self = [self init];
@try {
void *pool = objc_autoreleasePoolPush();
if ((![element.name isEqual: @"OFArray"] &&
![element.name isEqual: @"OFMutableArray"]) ||
![element.namespace isEqual: OFSerializationNS])
@throw [OFInvalidArgumentException exception];
for (OFXMLElement *child in
[element elementsForNamespace: OFSerializationNS]) {
void *pool2 = objc_autoreleasePoolPush();
id object;
object = child.objectByDeserializing;
[_array addItem: &object];
[object retain];
objc_autoreleasePoolPop(pool2);
}
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (size_t)count
{
return _array.count;
}
|
︙ | | |
Modified src/OFAdjacentSubarray.h
from [08f4f942e1]
to [abbd5bb00b].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFAdjacentSubarray.m
from [76d5c349a9]
to [c5bbd0c071].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFApplication.h
from [df94634a83]
to [e5cf81a0bb].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
-
+
|
* @brief A class which represents the application as an object.
*
* In order to create a new OFApplication, you should create a class conforming
* to the optional @ref OFApplicationDelegate protocol and put
* `OF_APPLICATION_DELEGATE(NameOfYourClass)` in the .m file of that class.
*
* When the application is about to be terminated,
* @ref OFApplicationDelegate#applicationWillTerminate will be called on the
* @ref OFApplicationDelegate#applicationWillTerminate: will be called on the
* delegate and an @ref OFApplicationWillTerminateNotification will be sent.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFApplication: OFObject
{
OFString *_programName;
OFArray OF_GENERIC(OFString *) *_arguments;
|
︙ | | |
Modified src/OFApplication.m
from [d6f9eb583b]
to [594a3c0f6e].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
+
+
|
#if defined(OF_MACOS)
# include <crt_externs.h>
#elif defined(OF_WINDOWS)
# include <windows.h>
extern int _CRT_glob;
extern void __wgetmainargs(int *, wchar_t ***, wchar_t ***, int, int *);
#elif defined(OF_AMIGAOS)
# define Class IntuitionClass
# include <proto/exec.h>
# include <proto/dos.h>
# undef Class
#elif !defined(OF_IOS)
extern char **environ;
#endif
#ifdef OF_PSP
# include <pspkerneltypes.h>
# include <psploadexec.h>
|
︙ | | |
Modified src/OFArchiveEntry.h
from [70aea150d9]
to [a5b126fe56].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Renamed and modified
src/OFArchiveURIHandler.h
[7c81cf8db2]
to src/OFArchiveIRIHandler.h
[328a2eb672].
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
|
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
|
-
+
-
+
-
+
-
-
+
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFURIHandler.h"
#import "OFIRIHandler.h"
OF_ASSUME_NONNULL_BEGIN
@interface OFArchiveURIHandler: OFURIHandler
@interface OFArchiveIRIHandler: OFIRIHandler
@end
#ifdef __cplusplus
extern "C" {
#endif
extern OFURI *OFArchiveURIHandlerURIForFileInArchive(OFString *, OFString *,
OFURI *);
extern OFIRI *OFArchiveIRIHandlerIRIForFileInArchive(OFString *, OFString *,
OFIRI *);
#ifdef __cplusplus
}
#endif
OF_ASSUME_NONNULL_END
|
Renamed and modified
src/OFArchiveURIHandler.m
[010e8050b6]
to src/OFArchiveIRIHandler.m
[e770c9f1e9].
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
|
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
|
-
+
-
+
+
-
-
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#include <errno.h>
#import "OFArchiveURIHandler.h"
#import "OFArchiveIRIHandler.h"
#import "OFCharacterSet.h"
#import "OFGZIPStream.h"
#import "OFIRI.h"
#import "OFLHAArchive.h"
#import "OFStream.h"
#import "OFTarArchive.h"
#import "OFURI.h"
#import "OFZIPArchive.h"
#import "OFInvalidArgumentException.h"
#import "OFOpenItemFailedException.h"
@interface OFArchiveURIHandlerPathAllowedCharacterSet: OFCharacterSet
@interface OFArchiveIRIHandlerPathAllowedCharacterSet: OFCharacterSet
{
OFCharacterSet *_characterSet;
bool (*_characterIsMember)(id, SEL, OFUnichar);
}
@end
static OFCharacterSet *pathAllowedCharacters;
static void
initPathAllowedCharacters(void)
{
pathAllowedCharacters =
[[OFArchiveURIHandlerPathAllowedCharacterSet alloc] init];
[[OFArchiveIRIHandlerPathAllowedCharacterSet alloc] init];
}
@implementation OFArchiveURIHandler
- (OFStream *)openItemAtURI: (OFURI *)URI mode: (OFString *)mode
@implementation OFArchiveIRIHandler
- (OFStream *)openItemAtIRI: (OFIRI *)IRI mode: (OFString *)mode
{
void *pool = objc_autoreleasePoolPush();
OFString *scheme = URI.scheme;
OFString *scheme = IRI.scheme;
OFString *percentEncodedPath, *path;
size_t pos;
OFURI *archiveURI;
OFIRI *archiveIRI;
OFStream *stream;
if (URI.host != nil || URI.port != nil || URI.user != nil ||
URI.password != nil || URI.query != nil || URI.fragment != nil)
if (IRI.host != nil || IRI.port != nil || IRI.user != nil ||
IRI.password != nil || IRI.query != nil || IRI.fragment != nil)
@throw [OFInvalidArgumentException exception];
if (![mode isEqual: @"r"])
/*
* Writing has some implications that are not decided yet: Will
* it always append to an archive? What happens if the file
* already exists?
*/
@throw [OFInvalidArgumentException exception];
/*
* GZIP only compresses one file and thus has no path inside an
* archive.
*/
if ([scheme isEqual: @"gzip"]) {
stream = [OFURIHandler openItemAtURI: [OFURI URIWithString:
URI.path]
stream = [OFIRIHandler openItemAtIRI: [OFIRI IRIWithString:
IRI.path]
mode: @"r"];
stream = [OFGZIPStream streamWithStream: stream mode: @"r"];
goto end;
}
percentEncodedPath = URI.percentEncodedPath;
percentEncodedPath = IRI.percentEncodedPath;
pos = [percentEncodedPath rangeOfString: @"!"].location;
if (pos == OFNotFound)
@throw [OFInvalidArgumentException exception];
archiveURI = [OFURI URIWithString:
archiveIRI = [OFIRI IRIWithString:
[percentEncodedPath substringWithRange: OFMakeRange(0, pos)]
.stringByRemovingPercentEncoding];
path = [percentEncodedPath substringWithRange:
OFMakeRange(pos + 1, percentEncodedPath.length - pos - 1)]
.stringByRemovingPercentEncoding;
if ([scheme isEqual: @"lha"]) {
OFLHAArchive *archive = [OFLHAArchive archiveWithURI: archiveURI
OFLHAArchive *archive = [OFLHAArchive archiveWithIRI: archiveIRI
mode: @"r"];
OFLHAArchiveEntry *entry;
while ((entry = [archive nextEntry]) != nil) {
if ([entry.fileName isEqual: path]) {
stream = [archive streamForReadingCurrentEntry];
goto end;
}
}
@throw [OFOpenItemFailedException exceptionWithURI: URI
@throw [OFOpenItemFailedException exceptionWithIRI: IRI
mode: mode
errNo: ENOENT];
} else if ([scheme isEqual: @"tar"]) {
OFTarArchive *archive = [OFTarArchive archiveWithURI: archiveURI
OFTarArchive *archive = [OFTarArchive archiveWithIRI: archiveIRI
mode: @"r"];
OFTarArchiveEntry *entry;
while ((entry = [archive nextEntry]) != nil) {
if ([entry.fileName isEqual: path]) {
stream = [archive streamForReadingCurrentEntry];
goto end;
}
}
@throw [OFOpenItemFailedException exceptionWithURI: URI
@throw [OFOpenItemFailedException exceptionWithIRI: IRI
mode: mode
errNo: ENOENT];
} else if ([scheme isEqual: @"zip"]) {
OFZIPArchive *archive = [OFZIPArchive archiveWithURI: archiveURI
OFZIPArchive *archive = [OFZIPArchive archiveWithIRI: archiveIRI
mode: @"r"];
stream = [archive streamForReadingFile: path];
} else
@throw [OFInvalidArgumentException exception];
end:
stream = [stream retain];
objc_autoreleasePoolPop(pool);
return [stream autorelease];
}
@end
@implementation OFArchiveURIHandlerPathAllowedCharacterSet
@implementation OFArchiveIRIHandlerPathAllowedCharacterSet
- (instancetype)init
{
self = [super init];
@try {
_characterSet =
[[OFCharacterSet URIPathAllowedCharacterSet] retain];
[[OFCharacterSet IRIPathAllowedCharacterSet] retain];
_characterIsMember = (bool (*)(id, SEL, OFUnichar))
[_characterSet methodForSelector:
@selector(characterIsMember:)];
} @catch (id e) {
[self release];
@throw e;
}
|
︙ | | |
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
|
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
|
-
-
-
+
+
+
-
+
-
+
-
+
-
+
|
- (bool)characterIsMember: (OFUnichar)character
{
return (character != '!' && _characterIsMember(_characterSet,
@selector(characterIsMember:), character));
}
@end
OFURI *
OFArchiveURIHandlerURIForFileInArchive(OFString *scheme,
OFString *pathInArchive, OFURI *archiveURI)
OFIRI *
OFArchiveIRIHandlerIRIForFileInArchive(OFString *scheme,
OFString *pathInArchive, OFIRI *archiveIRI)
{
static OFOnceControl onceControl = OFOnceControlInitValue;
OFMutableURI *ret = [OFMutableURI URIWithScheme: scheme];
OFMutableIRI *ret = [OFMutableIRI IRIWithScheme: scheme];
void *pool = objc_autoreleasePoolPush();
OFString *archiveURIString;
OFString *archiveIRIString;
OFOnce(&onceControl, initPathAllowedCharacters);
pathInArchive = [pathInArchive
stringByAddingPercentEncodingWithAllowedCharacters:
pathAllowedCharacters];
archiveURIString = [archiveURI.string
archiveIRIString = [archiveIRI.string
stringByAddingPercentEncodingWithAllowedCharacters:
pathAllowedCharacters];
ret.percentEncodedPath = [OFString
stringWithFormat: @"%@!%@", archiveURIString, pathInArchive];
stringWithFormat: @"%@!%@", archiveIRIString, pathInArchive];
[ret makeImmutable];
objc_autoreleasePoolPop(pool);
return ret;
}
|
Modified src/OFArray+Private.h
from [9a457a5499]
to [6c89dad268].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFArray.h
from [f90f803ff9]
to [3d63ad7d51].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
-
|
#endif
#include <stdarg.h>
#import "OFObject.h"
#import "OFCollection.h"
#import "OFEnumerator.h"
#import "OFSerialization.h"
#import "OFJSONRepresentation.h"
#import "OFMessagePackRepresentation.h"
OF_ASSUME_NONNULL_BEGIN
/** @file */
|
︙ | | |
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
-
+
|
* @class OFArray OFArray.h ObjFW/OFArray.h
*
* @brief An abstract class for storing objects in an array.
*
* @note Subclasses must implement @ref count and @ref objectAtIndex:.
*/
@interface OFArray OF_GENERIC(ObjectType): OFObject <OFCopying,
OFMutableCopying, OFCollection, OFSerialization, OFJSONRepresentation,
OFMutableCopying, OFCollection, OFJSONRepresentation,
OFMessagePackRepresentation>
#if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN)
# define ObjectType id
#endif
/**
* @brief The objects of the array as a C array.
*
|
︙ | | |
401
402
403
404
405
406
407
408
409
410
411
412
413
414
|
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
* @param options The options to use when sorting the array
* @return A sorted copy of the array
*/
- (OFArray OF_GENERIC(ObjectType) *)
sortedArrayUsingSelector: (SEL)selector
options: (OFArraySortOptions)options;
/**
* @brief Returns a copy of the array sorted using the specified function and
* options.
*
* @param compare The function to use to sort the array
* @param context Context passed to the function to compare
* @param options The options to use when sorting the array
* @return A sorted copy of the array
*/
- (OFArray OF_GENERIC(ObjectType) *)
sortedArrayUsingFunction: (OFCompareFunction)compare
context: (nullable void *)context
options: (OFArraySortOptions)options;
#ifdef OF_HAVE_BLOCKS
/**
* @brief Returns a copy of the array sorted using the specified selector and
* options.
*
* @param comparator The comparator to use to sort the array
* @param options The options to use when sorting the array
|
︙ | | |
Modified src/OFArray.m
from [26b9b812f3]
to [79e2c56f24].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
-
|
#import "OFArray.h"
#import "OFArray+Private.h"
#import "OFAdjacentArray.h"
#import "OFData.h"
#import "OFNull.h"
#import "OFString.h"
#import "OFSubarray.h"
#import "OFXMLElement.h"
#import "OFEnumerationMutationException.h"
#import "OFInvalidArgumentException.h"
#import "OFOutOfRangeException.h"
static struct {
Class isa;
|
︙ | | |
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
-
-
-
-
-
|
- (instancetype)initWithObjects: (id const *)objects
count: (size_t)count
{
return (id)[[OFAdjacentArray alloc] initWithObjects: objects
count: count];
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
return (id)[[OFAdjacentArray alloc] initWithSerialization: element];
}
- (instancetype)retain
{
return self;
}
- (instancetype)autorelease
{
|
︙ | | |
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
|
204
205
206
207
208
209
210
211
212
213
214
215
216
217
|
-
-
-
-
-
|
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithObjects: (id const *)objects
count: (size_t)count
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
OF_INVALID_INIT_METHOD
}
- (size_t)count
{
OF_UNRECOGNIZED_SELECTOR
}
|
︙ | | |
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
|
533
534
535
536
537
538
539
540
541
542
543
544
545
546
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
objc_autoreleasePoolPop(pool);
[ret makeImmutable];
return [ret autorelease];
}
- (OFXMLElement *)XMLElementBySerializing
{
void *pool = objc_autoreleasePoolPush();
OFXMLElement *element;
if ([self isKindOfClass: [OFMutableArray class]])
element = [OFXMLElement elementWithName: @"OFMutableArray"
namespace: OFSerializationNS];
else
element = [OFXMLElement elementWithName: @"OFArray"
namespace: OFSerializationNS];
for (id <OFSerialization> object in self) {
void *pool2 = objc_autoreleasePoolPush();
[element addChild: object.XMLElementBySerializing];
objc_autoreleasePoolPop(pool2);
}
[element retain];
objc_autoreleasePoolPop(pool);
return [element autorelease];
}
- (OFString *)JSONRepresentation
{
return [self of_JSONRepresentationWithOptions: 0 depth: 0];
}
- (OFString *)JSONRepresentationWithOptions:
(OFJSONRepresentationOptions)options
|
︙ | | |
721
722
723
724
725
726
727
728
729
730
731
732
733
734
|
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
|
+
+
+
+
+
+
+
+
+
+
|
options: (OFArraySortOptions)options
{
OFMutableArray *new = [[self mutableCopy] autorelease];
[new sortUsingSelector: selector options: options];
[new makeImmutable];
return new;
}
- (OFArray *)sortedArrayUsingFunction: (OFCompareFunction)compare
context: (void *)context
options: (OFArraySortOptions)options
{
OFMutableArray *new = [[self mutableCopy] autorelease];
[new sortUsingFunction: compare context: context options: options];
[new makeImmutable];
return new;
}
#ifdef OF_HAVE_BLOCKS
- (OFArray *)sortedArrayUsingComparator: (OFComparator)comparator
options: (OFArraySortOptions)options
{
OFMutableArray *new = [[self mutableCopy] autorelease];
[new sortUsingComparator: comparator options: options];
|
︙ | | |
Modified src/OFAsyncIPSocketConnector.h
from [00aff2415e]
to [82fab4738c].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFAsyncIPSocketConnector.m
from [b9084cfb8c]
to [4db6b7d2e4].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFAtomic.h
from [25c89d25b5]
to [7b3ed1a98e].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
-
+
|
}
static OF_INLINE void
OFReleaseMemoryBarrier(void)
{
/* nop */
}
#elif (defined(OF_X86_64) || defined(OF_X86)) && defined(__GNUC__)
#elif (defined(OF_AMD64) || defined(OF_X86)) && defined(__GNUC__)
# import "platform/x86/OFAtomic.h"
#elif defined(OF_POWERPC) && defined(__GNUC__) && !defined(__APPLE_CC__) && \
!defined(OF_AIX)
# import "platform/PowerPC/OFAtomic.h"
#elif defined(OF_HAVE_ATOMIC_BUILTINS)
# import "platform/GCC4.7/OFAtomic.h"
#elif defined(OF_HAVE_SYNC_BUILTINS)
# import "platform/GCC4/OFAtomic.h"
#elif defined(OF_HAVE_OSATOMIC)
# import "platform/macOS/OFAtomic.h"
#else
# error No atomic operations available!
#endif
|
Modified src/OFBase64.h
from [14838b60d0]
to [dc1538a199].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFBase64.m
from [7cc5f21d9d]
to [65e2efa6c1].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFBitSetCharacterSet.h
from [6dd7022dff]
to [3881bf645d].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFBitSetCharacterSet.m
from [d65aed83c7]
to [86d9bb92c4].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFBlock.h
from [ae09bf0d6b]
to [f1e51ec3d8].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFBlock.m
from [ab07b43024]
to [d7b2cab799].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFBytesValue.h
from [ca1dbf0669]
to [fa7ec42d63].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFBytesValue.m
from [b331442837]
to [b82083e896].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFCRC16.h
from [6bd74791bc]
to [2c8e24788e].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFCRC16.m
from [ba4e599142]
to [4dacc44a0d].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFCRC32.h
from [139d8dccac]
to [854faab2ac].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFCRC32.m
from [b50ad38210]
to [1fe12fcc7a].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFCharacterSet.h
from [20dd965c47]
to [380acae6ed].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFCharacterSet.m
from [76e8828364]
to [272d843979].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFCollection.h
from [8d8461caff]
to [5762c77876].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFColor.h
from [bce9432d45]
to [de724e96d7].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFColor.m
from [ff82ab6aae]
to [2f23670cfa].
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
|
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
|
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#include <math.h>
#import "OFColor.h"
#import "OFOnce.h"
#import "OFString.h"
#import "OFInvalidArgumentException.h"
@interface OFColor ()
+ (instancetype)of_alloc;
@end
@interface OFColorSingleton: OFColor
@end
@interface OFColorPlaceholder: OFColorSingleton
@end
#ifdef OF_OBJFW_RUNTIME
@interface OFTaggedPointerColor: OFColorSingleton
@end
static const float allowedImprecision = 0.0000001;
#endif
static struct {
Class isa;
} placeholder;
#ifdef OF_OBJFW_RUNTIME
static int colorTag;
#endif
@implementation OFColorSingleton
- (instancetype)autorelease
{
return self;
}
- (instancetype)retain
{
return self;
}
- (void)release
{
}
- (unsigned int)retainCount
{
return OFMaxRetainCount;
}
@end
@implementation OFColorPlaceholder
- (instancetype)initWithRed: (float)red
green: (float)green
blue: (float)blue
alpha: (float)alpha
{
#ifdef OF_OBJFW_RUNTIME
uint8_t redInt = nearbyintf(red * 255);
uint8_t greenInt = nearbyintf(green * 255);
uint8_t blueInt = nearbyintf(blue * 255);
if (fabsf(red * 255 - redInt) < allowedImprecision &&
fabsf(green * 255 - greenInt) < allowedImprecision &&
fabsf(blue * 255 - blueInt) < allowedImprecision && alpha == 1) {
id ret = objc_createTaggedPointer(colorTag,
(uintptr_t)redInt << 16 | (uintptr_t)greenInt << 8 |
(uintptr_t)blueInt);
if (ret != nil)
return ret;
}
#endif
return (id)[[OFColor of_alloc] initWithRed: red
green: green
blue: blue
alpha: alpha];
}
@end
#ifdef OF_OBJFW_RUNTIME
@implementation OFTaggedPointerColor
- (void)getRed: (float *)red
green: (float *)green
blue: (float *)blue
alpha: (float *)alpha
{
uintptr_t value = object_getTaggedPointerValue(self);
*red = (float)(value >> 16) / 255;
*green = (float)((value >> 8) & 0xFF) / 255;
*blue = (float)(value & 0xFF) / 255;
if (alpha != NULL)
*alpha = 1;
}
@end
#endif
@implementation OFColor
+ (void)initialize
{
if (self != [OFColor class])
return;
placeholder.isa = [OFColorPlaceholder class];
#ifdef OF_OBJFW_RUNTIME
colorTag =
objc_registerTaggedPointerClass([OFTaggedPointerColor class]);
#endif
}
+ (instancetype)of_alloc
{
return [super alloc];
}
+ (instancetype)alloc
{
if (self == [OFColor class])
return (id)&placeholder;
return [super alloc];
}
#define PREDEFINED_COLOR(name, redValue, greenValue, blueValue) \
static OFColor *name##Color = nil; \
\
static void \
initPredefinedColor_##name(void) \
{ \
name##Color = [[OFColorSingleton alloc] \
name##Color = [[OFColor alloc] initWithRed: redValue \
green: greenValue \
blue: blueValue \
alpha: 1]; \
initWithRed: redValue \
green: greenValue \
blue: blueValue \
alpha: 1]; \
} \
\
+ (OFColor *)name \
{ \
static OFOnceControl onceControl = OFOnceControlInitValue; \
OFOnce(&onceControl, initPredefinedColor_##name); \
\
|
︙ | | |
155
156
157
158
159
160
161
162
|
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
|
+
+
+
+
+
+
+
+
+
+
+
|
*red = _red;
*green = _green;
*blue = _blue;
if (alpha != NULL)
*alpha = _alpha;
}
- (OFString *)description
{
float red, green, blue, alpha;
[self getRed: &red green: &green blue: &blue alpha: &alpha];
return [OFString stringWithFormat:
@"<%@ red=%f green=%f blue=%f alpha=%f>",
self.class, red, green, blue, alpha];
}
@end
|
Modified src/OFCondition.h
from [2de2d56fa5]
to [e9f86d3ccf].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFCondition.m
from [28f8553bac]
to [46420e8064].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFConstantString.h
from [4428a8bf71]
to [bf7c0894b9].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFConstantString.m
from [3adc07df05]
to [01f4965770].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
|
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
|
-
+
-
+
-
+
-
+
|
- (void)writeToFile: (OFString *)path encoding: (OFStringEncoding)encoding
{
[self finishInitialization];
[self writeToFile: path encoding: encoding];
}
#endif
- (void)writeToURI: (OFURI *)URI
- (void)writeToIRI: (OFIRI *)IRI
{
[self finishInitialization];
[self writeToURI: URI];
[self writeToIRI: IRI];
}
- (void)writeToURI: (OFURI *)URI encoding: (OFStringEncoding)encoding
- (void)writeToIRI: (OFIRI *)IRI encoding: (OFStringEncoding)encoding
{
[self finishInitialization];
[self writeToURI: URI encoding: encoding];
[self writeToIRI: IRI encoding: encoding];
}
#ifdef OF_HAVE_BLOCKS
- (void)enumerateLinesUsingBlock: (OFStringLineEnumerationBlock)block
{
[self finishInitialization];
[self enumerateLinesUsingBlock: block];
}
#endif
@end
|
Modified src/OFCountedMapTableSet.h
from [1da95cb48f]
to [05ce680e3e].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFCountedMapTableSet.m
from [d7ae224517]
to [7a63d8437b].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
-
|
#import "OFCountedMapTableSet.h"
#import "OFArray.h"
#import "OFMapTable.h"
#import "OFMutableMapTableSet.h"
#import "OFString.h"
#import "OFXMLAttribute.h"
#import "OFXMLElement.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFEnumerationMutationException.h"
#import "OFOutOfRangeException.h"
@implementation OFCountedMapTableSet
|
︙ | | |
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
|
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
while ((object = va_arg(arguments, id)) != nil)
[self addObject: object];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
self = [self init];
@try {
void *pool = objc_autoreleasePoolPush();
if (![element.name isEqual: @"OFCountedSet"] ||
![element.namespace isEqual: OFSerializationNS])
@throw [OFInvalidArgumentException exception];
for (OFXMLElement *objectElement in
[element elementsForName: @"object"
namespace: OFSerializationNS]) {
void *pool2 = objc_autoreleasePoolPush();
OFXMLElement *object;
OFXMLAttribute *countAttribute;
unsigned long long count;
object = [objectElement elementsForNamespace:
OFSerializationNS].firstObject;
countAttribute =
[objectElement attributeForName: @"count"];
if (object == nil || countAttribute == nil)
@throw [OFInvalidFormatException exception];
count = countAttribute.unsignedLongLongValue;
if (count > SIZE_MAX || count > UINTPTR_MAX)
@throw [OFOutOfRangeException exception];
[_mapTable setObject: (void *)(uintptr_t)count
forKey: object.objectByDeserializing];
objc_autoreleasePoolPop(pool2);
}
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (size_t)countForObject: (id)object
{
return (size_t)(uintptr_t)[_mapTable objectForKey: object];
}
|
︙ | | |
Modified src/OFCountedSet.h
from [b22ee9691d]
to [e9f2d45c4d].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFCountedSet.m
from [985e10aa24]
to [2550c38e59].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
-
|
#include <stdlib.h>
#import "OFCountedSet.h"
#import "OFCountedMapTableSet.h"
#import "OFNumber.h"
#import "OFString.h"
#import "OFXMLElement.h"
static struct {
Class isa;
} placeholder;
@interface OFCountedSetPlaceholder: OFCountedSet
@end
|
︙ | | |
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
-
-
-
-
-
-
|
- (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments
{
return (id)[[OFCountedMapTableSet alloc] initWithObject: firstObject
arguments: arguments];
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
return (id)[[OFCountedMapTableSet alloc]
initWithSerialization: element];
}
- (instancetype)retain
{
return self;
}
- (instancetype)autorelease
{
|
︙ | | |
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
|
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
}
- (id)mutableCopy
{
return [[OFCountedSet alloc] initWithSet: self];
}
- (OFXMLElement *)XMLElementBySerializing
{
void *pool = objc_autoreleasePoolPush();
OFXMLElement *element;
element = [OFXMLElement elementWithName: @"OFCountedSet"
namespace: OFSerializationNS];
for (id <OFSerialization> object in self) {
void *pool2 = objc_autoreleasePoolPush();
OFXMLElement *objectElement;
OFString *count;
count =
[OFString stringWithFormat: @"%zu",
[self countForObject: object]];
objectElement = [OFXMLElement
elementWithName: @"object"
namespace: OFSerializationNS];
[objectElement addAttributeWithName: @"count"
stringValue: count];
[objectElement addChild: object.XMLElementBySerializing];
[element addChild: objectElement];
objc_autoreleasePoolPop(pool2);
}
[element retain];
objc_autoreleasePoolPop(pool);
return [element autorelease];
}
#ifdef OF_HAVE_BLOCKS
- (void)enumerateObjectsAndCountUsingBlock: (OFCountedSetEnumerationBlock)block
{
[self enumerateObjectsUsingBlock: ^ (id object, bool *stop) {
block(object, [self countForObject: object], stop);
}];
}
|
︙ | | |
Modified src/OFCryptographicHash.h
from [635d4f982a]
to [bcec3c10c5].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFDDPSocket.h
from [86e7a28476]
to [d9acc0eea7].
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
|
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
|
-
+
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFDatagramSocket.h"
OF_ASSUME_NONNULL_BEGIN
@class OFString;
@class OFDictionary OF_GENERIC(KeyType, ObjectType);
/**
* @protocol OFDDPSocketDelegate OFDDPSocket.h ObjFW/OFDDPSocket.h
*
* @brief A delegate for OFDDPSocket.
*/
@protocol OFDDPSocketDelegate <OFDatagramSocketDelegate>
|
︙ | | |
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
-
+
|
* @ref OFSocketAddressAppleTalkNode to get the AppleTalk node and
* @ref OFSocketAddressAppleTalkPort to get the port (sometimes also called
* socket number).
*
* @note On some systems, packets received with the wrong protocol type just
* get filtered by the kernel, however, on other systems, the packet is
* queued up and will raise an @ref OFReadFailedException with the
* @ref errNo set to `ENOMSG` when being received.
* @ref OFReadFailedException#errNo set to `ENOMSG` when being received.
*
* @warning Even though the OFCopying protocol is implemented, it does *not*
* return an independent copy of the socket, but instead retains it.
* This is so that the socket can be used as a key for a dictionary,
* so context can be associated with a socket. Using a socket in more
* than one thread at the same time is not thread-safe, even if copy
* was called to create one "instance" for every thread!
|
︙ | | |
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
-
+
|
* @param port The port to bind to. 0 means to pick one and return it via the
* returned socket address.
* @param protocolType The DDP protocol type to use. Must not be 0. If you want
* to use DDP directly and not a protocol built on top of
* it, use 11 for compatibility with Open Transport.
* @return The address on which this socket can be reached
* @throw OFBindDDPSockeFailedException Binding failed
* @throw OFAlreadyConnectedException The socket is already bound
* @throw OFAlreadyOpenException The socket is already bound
*/
- (OFSocketAddress)bindToNetwork: (uint16_t)network
node: (uint8_t)node
port: (uint8_t)port
protocolType: (uint8_t)protocolType;
@end
OF_ASSUME_NONNULL_END
|
Modified src/OFDDPSocket.m
from [d532fdd70f]
to [0f90d0e13f].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
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
|
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
|
#include <errno.h>
#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#endif
#import "OFDDPSocket.h"
#import "OFDictionary.h"
#import "OFNumber.h"
#import "OFPair.h"
#import "OFSocket.h"
#import "OFSocket+Private.h"
#import "OFAlreadyConnectedException.h"
#import "OFAlreadyOpenException.h"
#import "OFBindDDPSocketFailedException.h"
#import "OFGetOptionFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFNotOpenException.h"
#import "OFOutOfRangeException.h"
#import "OFReadFailedException.h"
#import "OFSetOptionFailedException.h"
#import "OFWriteFailedException.h"
#ifdef HAVE_NET_IF_H
# include <net/if.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
#ifdef OF_HAVE_NETAT_APPLETALK_H
# include <netat/ddp.h>
# include <sys/ioctl.h>
/* Unfortulately, there is no struct for the following in userland headers */
struct ATInterfaceConfig {
|
︙ | | |
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
-
+
|
int flags;
#endif
if (protocolType == 0)
@throw [OFInvalidArgumentException exception];
if (_socket != OFInvalidSocketHandle)
@throw [OFAlreadyConnectedException exceptionWithSocket: self];
@throw [OFAlreadyOpenException exceptionWithObject: self];
address = OFSocketAddressMakeAppleTalk(network, node, port);
#if defined(OF_MACOS)
if ((_socket = socket(address.sockaddr.at.sat_family,
SOCK_RAW | SOCK_CLOEXEC, protocolType)) == OFInvalidSocketHandle)
#elif defined(OF_WINDOWS)
|
︙ | | |
Modified src/OFDNSQuery.h
from [b49f52a5a4]
to [d9763523d4].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFDNSQuery.m
from [eb5858939c]
to [f7f99b0724].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
-
+
|
@try {
void *pool = objc_autoreleasePoolPush();
if (![domainName hasSuffix: @"."])
domainName = [domainName stringByAppendingString: @"."];
_domainName = [domainName copy];
_domainName = [domainName.lowercaseString copy];
_DNSClass = DNSClass;
_recordType = recordType;
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
|
︙ | | |
Modified src/OFDNSResolver.h
from [a91104c174]
to [511ca7b000].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
-
+
-
+
|
/**
* @brief The minimum number of dots for a name to be considered absolute.
*/
@property (nonatomic) unsigned int minNumberOfDotsInAbsoluteName;
/**
* @brief Whether the resolver uses TCP to talk to a name server.
* @brief Whether the resolver forces TCP to talk to a name server.
*/
@property (nonatomic) bool usesTCP;
@property (nonatomic) bool forcesTCP;
/**
* @brief The interval in seconds in which the config should be reloaded.
*
* Setting this to 0 disables config reloading.
*/
@property (nonatomic) OFTimeInterval configReloadInterval;
|
︙ | | |
Modified src/OFDNSResolver.m
from [9048cbfc52]
to [1f222a13ca].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
|
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
|
-
+
|
{
OFMutableDictionary *ret = [OFMutableDictionary dictionary];
OFEnumerator OF_GENERIC(OFMutableArray *) *objectEnumerator;
OFMutableArray *array;
for (uint_fast16_t j = 0; j < count; j++) {
OFString *name = parseName(buffer, length, i,
maxAllowedPointers);
maxAllowedPointers).lowercaseString;
OFDNSClass DNSClass;
OFDNSRecordType recordType;
uint32_t TTL;
uint16_t dataLength;
OFDNSResourceRecord *record;
if (*i + 10 > length)
|
︙ | | |
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
|
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
|
-
+
-
+
-
+
-
+
|
- (void)setMinNumberOfDotsInAbsoluteName:
(unsigned int)minNumberOfDotsInAbsoluteName
{
_settings->_minNumberOfDotsInAbsoluteName =
minNumberOfDotsInAbsoluteName;
}
- (bool)usesTCP
- (bool)forcesTCP
{
return _settings->_usesTCP;
return _settings->_forcesTCP;
}
- (void)setUsesTCP: (bool)usesTCP
- (void)setForcesTCP: (bool)forcesTCP
{
_settings->_usesTCP = usesTCP;
_settings->_forcesTCP = forcesTCP;
}
- (OFTimeInterval)configReloadInterval
{
return _settings->_configReloadInterval;
}
|
︙ | | |
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
|
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
|
-
+
|
repeats: false];
[[OFRunLoop currentRunLoop] addTimer: context->_cancelTimer
forMode: runLoopMode];
nameServer = [context->_settings->_nameServers
objectAtIndex: context->_nameServersIndex];
if (context->_settings->_usesTCP) {
if (context->_settings->_forcesTCP) {
OFEnsure(context->_TCPSocket == nil);
context->_TCPSocket = [[OFTCPSocket alloc] init];
[_TCPQueries setObject: context forKey: context->_TCPSocket];
context->_TCPSocket.delegate = self;
[context->_TCPSocket asyncConnectToHost: nameServer
|
︙ | | |
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
|
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
|
-
+
-
+
|
if ((buffer[2] & 0x78) != (queryDataBuffer[2] & 0x78))
@throw [OFInvalidServerResponseException exception];
/* TC */
if (buffer[2] & 0x02) {
OFRunLoopMode runLoopMode;
if (context->_settings->_usesTCP)
if (context->_settings->_forcesTCP)
@throw [OFTruncatedDataException exception];
context->_settings->_usesTCP = true;
context->_settings->_forcesTCP = true;
runLoopMode = [OFRunLoop currentRunLoop].currentMode;
[self of_sendQueryForContext: context
runLoopMode: runLoopMode];
return false;
}
/* RCODE */
|
︙ | | |
Modified src/OFDNSResolverSettings.h
from [1250cc4b4c]
to [59a97ffd04].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
-
+
|
OFDictionary OF_GENERIC(OFString *, OFArray OF_GENERIC(OFString *) *)
*_staticHosts;
OFArray OF_GENERIC(OFString *) *_nameServers;
OFString *_Nullable _localDomain;
OFArray OF_GENERIC(OFString *) *_searchDomains;
OFTimeInterval _timeout;
unsigned int _maxAttempts, _minNumberOfDotsInAbsoluteName;
bool _usesTCP;
bool _forcesTCP;
OFTimeInterval _configReloadInterval;
@protected
OFDate *_lastConfigReload;
}
- (void)reload;
@end
OF_ASSUME_NONNULL_END
|
Modified src/OFDNSResolverSettings.m
from [1a84838633]
to [179fc83ef4].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
+
+
+
+
|
#import "OFString.h"
#ifdef OF_WINDOWS
# import "OFWindowsRegistryKey.h"
#endif
#import "OFInvalidFormatException.h"
#import "OFOpenItemFailedException.h"
#ifdef OF_WINDOWS
# import "OFOpenWindowsRegistryKeyFailedException.h"
#endif
#import "OFOutOfMemoryException.h"
#import "OFOutOfRangeException.h"
#import "OFUndefinedKeyException.h"
#ifdef OF_WINDOWS
# define interface struct
# include <iphlpapi.h>
# undef interface
#endif
|
︙ | | |
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
|
-
+
|
copy->_nameServers = [_nameServers copy];
copy->_localDomain = [_localDomain copy];
copy->_searchDomains = [_searchDomains copy];
copy->_timeout = _timeout;
copy->_maxAttempts = _maxAttempts;
copy->_minNumberOfDotsInAbsoluteName =
_minNumberOfDotsInAbsoluteName;
copy->_usesTCP = _usesTCP;
copy->_forcesTCP = _forcesTCP;
copy->_configReloadInterval = _configReloadInterval;
copy->_lastConfigReload = [_lastConfigReload copy];
} @catch (id e) {
[copy release];
@throw e;
}
|
︙ | | |
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
|
-
+
|
[_searchDomains release];
_searchDomains = nil;
_timeout = 2;
_maxAttempts = 3;
_minNumberOfDotsInAbsoluteName = 1;
_usesTCP = false;
_forcesTCP = false;
#ifndef OF_NINTENDO_3DS
_configReloadInterval = 2;
#else
_configReloadInterval = 0;
#endif
}
|
︙ | | |
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
|
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
|
-
-
+
+
+
+
|
continue;
address = components.firstObject;
hosts = [components objectsInRange:
OFMakeRange(1, components.count - 1)];
for (OFString *host in hosts) {
OFMutableArray *addresses =
[staticHosts objectForKey: host];
OFMutableArray *addresses;
host = host.lowercaseString;
addresses = [staticHosts objectForKey: host];
if (addresses == nil) {
addresses = [OFMutableArray array];
[staticHosts setObject: addresses forKey: host];
}
[addresses addObject: address];
|
︙ | | |
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
|
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
|
-
+
|
_maxAttempts = (unsigned int)number;
} else if ([option hasPrefix: @"reload-period:"]) {
option = [option substringFromIndex: 14];
_configReloadInterval = option.unsignedLongLongValue;
} else if ([option isEqual: @"tcp"])
_usesTCP = true;
_forcesTCP = true;
} @catch (OFInvalidFormatException *e) {
}
}
- (void)parseResolvConf: (OFString *)path
{
void *pool = objc_autoreleasePoolPush();
|
︙ | | |
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
|
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
|
-
-
+
+
+
-
+
+
+
+
+
|
PIP_ADDR_STRING iter;
if (GetNetworkParams(fixedInfo, &length) != ERROR_SUCCESS)
return;
nameServers = [OFMutableArray array];
for (iter = &fixedInfo->DnsServerList; iter != NULL; iter = iter->Next)
[nameServers addObject:
for (iter = &fixedInfo->DnsServerList; iter != NULL;
iter = iter->Next) {
OFString *nameServer =
[OFString stringWithCString: iter->IpAddress.String
encoding: encoding]];
encoding: encoding];
if (nameServer.length > 0)
[nameServers addObject: nameServer];
}
if (nameServers.count > 0) {
[nameServers makeImmutable];
_nameServers = [nameServers copy];
}
if (fixedInfo->DomainName[0] != '\0')
|
︙ | | |
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
|
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
|
-
-
+
+
+
+
|
continue;
address = components.firstObject;
hosts = [components objectsInRange:
OFMakeRange(1, components.count - 1)];
for (OFString *host in hosts) {
OFMutableArray *addresses =
[staticHosts objectForKey: host];
OFMutableArray *addresses;
host = host.lowercaseString;
addresses = [staticHosts objectForKey: host];
if (addresses == nil) {
addresses = [OFMutableArray array];
[staticHosts setObject: addresses forKey: host];
}
[addresses addObject: address];
|
︙ | | |
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
|
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
|
-
-
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
_nameServers = [nameServers copy];
}
}
#endif
- (void)reload
{
void *pool;
#ifdef OF_WINDOWS
OFString *path;
OFString *path = nil;
#endif
void *pool;
/*
* TODO: Rather than reparsing every time, check what actually changed
* (mtime) and only reset those.
*/
if (_lastConfigReload != nil && _configReloadInterval > 0 &&
_lastConfigReload.timeIntervalSinceNow < _configReloadInterval)
return;
pool = objc_autoreleasePoolPush();
[self setDefaults];
#if defined(OF_WINDOWS)
# ifdef OF_HAVE_FILES
@try {
OFWindowsRegistryKey *key = [[OFWindowsRegistryKey localMachineKey]
openSubkeyAtPath: @"SYSTEM\\CurrentControlSet\\Services\\"
@"Tcpip\\Parameters"
accessRights: KEY_QUERY_VALUE
options: 0];
path = [[[key stringForValueNamed: @"DataBasePath"]
stringByAppendingPathComponent: @"hosts"]
stringByExpandingWindowsEnvironmentStrings];
OFWindowsRegistryKey *key;
key = [[OFWindowsRegistryKey localMachineKey]
openSubkeyAtPath: @"SYSTEM\\CurrentControlSet\\Services\\"
@"Tcpip\\Parameters"
accessRights: KEY_QUERY_VALUE
options: 0];
path = [[[key stringForValueNamed: @"DataBasePath"]
stringByAppendingPathComponent: @"hosts"]
stringByExpandingWindowsEnvironmentStrings];
} @catch (OFOpenWindowsRegistryKeyFailedException *e) {
/* Ignore */
} @catch (OFUndefinedKeyException *e) {
/* Ignore */
}
if (path != nil)
[self parseHosts: path];
# endif
[self obtainWindowsSystemConfig];
#elif defined(OF_MORPHOS)
|
︙ | | |
Modified src/OFDNSResourceRecord.h
from [30273f1f1b]
to [967b25e8fc].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFDNSResourceRecord.m
from [b7ec251a31]
to [b264bcb878].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFDNSResponse.h
from [229f42ebfc]
to [2edd119b7d].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFDNSResponse.m
from [6e61ece6f0]
to [ced7000804].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFData+CryptographicHashing.h
from [7264dfad2c]
to [6577c2d747].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFData+CryptographicHashing.m
from [caf70aabc2]
to [d27651b9f8].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFData+MessagePackParsing.h
from [1a7c410992]
to [b81c76becd].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFData+MessagePackParsing.m
from [8bd7ef8227]
to [5961e97b5f].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFData.h
from [750f7eff94]
to [c6b9b129b7].
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
|
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
|
-
+
-
-
-
+
+
-
-
-
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFObject.h"
#import "OFSerialization.h"
#import "OFMessagePackRepresentation.h"
/*! @file */
OF_ASSUME_NONNULL_BEGIN
@class OFString;
@class OFURI;
@class OFIRI;
@class OFString;
/**
* @brief Options for searching in data.
*
* This is a bit mask.
*/
typedef enum {
/** Search backwards in the data */
OFDataSearchBackwards = 1
} OFDataSearchOptions;
/**
* @class OFData OFData.h ObjFW/OFData.h
*
* @brief A class for storing arbitrary data in an array.
*
* For security reasons, serialization and deserialization is only implemented
* for OFData with item size 1.
*/
@interface OFData: OFObject <OFCopying, OFMutableCopying, OFComparing,
OFSerialization, OFMessagePackRepresentation>
OFMessagePackRepresentation>
{
unsigned char *_Nullable _items;
size_t _count, _itemSize;
bool _freeWhenDone;
@private
OFData *_Nullable _parentData;
OF_RESERVE_IVARS(OFData, 4)
|
︙ | | |
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
-
+
-
+
-
+
|
* @return A new autoreleased OFData
*/
+ (instancetype)dataWithContentsOfFile: (OFString *)path;
#endif
/**
* @brief Creates a new OFData with an item size of 1, containing the data of
* the specified URI.
* the specified IRI.
*
* @param URI The URI to the contents for the OFData
* @param IRI The IRI to the contents for the OFData
* @return A new autoreleased OFData
*/
+ (instancetype)dataWithContentsOfURI: (OFURI *)URI;
+ (instancetype)dataWithContentsOfIRI: (OFIRI *)IRI;
/**
* @brief Creates a new OFData with an item size of 1, containing the data of
* the hex string representation.
*
* @param string The hex string representation of the data
* @return A new autoreleased OFData
|
︙ | | |
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
|
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
|
-
+
-
+
-
+
|
* @return An initialized OFData
*/
- (instancetype)initWithContentsOfFile: (OFString *)path;
#endif
/**
* @brief Initializes an already allocated OFData with an item size of 1,
* containing the data of the specified URI.
* containing the data of the specified IRI.
*
* @param URI The URI to the contents for the OFData
* @param IRI The IRI to the contents for the OFData
* @return A new autoreleased OFData
*/
- (instancetype)initWithContentsOfURI: (OFURI *)URI;
- (instancetype)initWithContentsOfIRI: (OFIRI *)IRI;
/**
* @brief Initializes an already allocated OFData with an item size of 1,
* containing the data of the hex string representation.
*
* @param string The hex string representation of the data
* @return A new autoreleased OFData
|
︙ | | |
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
|
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
|
-
+
-
+
-
+
|
*
* @param path The path of the file to write to
*/
- (void)writeToFile: (OFString *)path;
#endif
/**
* @brief Writes the OFData to the specified URI.
* @brief Writes the OFData to the specified IRI.
*
* @param URI The URI to write to
* @param IRI The IRI to write to
*/
- (void)writeToURI: (OFURI *)URI;
- (void)writeToIRI: (OFIRI *)IRI;
@end
OF_ASSUME_NONNULL_END
#import "OFMutableData.h"
#import "OFData+CryptographicHashing.h"
#import "OFData+MessagePackParsing.h"
|
Modified src/OFData.m
from [b0fcc38dae]
to [fedaecf95c].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
+
+
-
-
-
|
#import "OFData.h"
#import "OFBase64.h"
#import "OFDictionary.h"
#ifdef OF_HAVE_FILES
# import "OFFile.h"
# import "OFFileManager.h"
#endif
#import "OFIRI.h"
#import "OFIRIHandler.h"
#import "OFStream.h"
#import "OFString.h"
#import "OFSystemInfo.h"
#import "OFURI.h"
#import "OFURIHandler.h"
#import "OFXMLElement.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFNotImplementedException.h"
#import "OFOutOfMemoryException.h"
#import "OFOutOfRangeException.h"
#import "OFTruncatedDataException.h"
|
︙ | | |
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
-
+
-
+
|
#ifdef OF_HAVE_FILES
+ (instancetype)dataWithContentsOfFile: (OFString *)path
{
return [[[self alloc] initWithContentsOfFile: path] autorelease];
}
#endif
+ (instancetype)dataWithContentsOfURI: (OFURI *)URI
+ (instancetype)dataWithContentsOfIRI: (OFIRI *)IRI
{
return [[[self alloc] initWithContentsOfURI: URI] autorelease];
return [[[self alloc] initWithContentsOfIRI: IRI] autorelease];
}
+ (instancetype)dataWithStringRepresentation: (OFString *)string
{
return [[[self alloc]
initWithStringRepresentation: string] autorelease];
}
|
︙ | | |
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
|
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
|
-
+
-
+
|
@throw e;
}
return self;
}
#endif
- (instancetype)initWithContentsOfURI: (OFURI *)URI
- (instancetype)initWithContentsOfIRI: (OFIRI *)IRI
{
self = [super init];
@try {
void *pool = objc_autoreleasePoolPush();
OFStream *stream = [OFURIHandler openItemAtURI: URI mode: @"r"];
OFStream *stream = [OFIRIHandler openItemAtIRI: IRI mode: @"r"];
size_t pageSize;
unsigned char *buffer;
_count = 0;
_itemSize = 1;
_freeWhenDone = true;
|
︙ | | |
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
|
329
330
331
332
333
334
335
336
337
338
339
340
341
342
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
[self release];
@throw e;
}
if (!mutable)
[(OFMutableData *)self makeImmutable];
return self;
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
void *pool = objc_autoreleasePoolPush();
OFString *stringValue;
@try {
if (![element.name isEqual: self.className] ||
![element.namespace isEqual: OFSerializationNS])
@throw [OFInvalidArgumentException exception];
stringValue = element.stringValue;
} @catch (id e) {
[self release];
@throw e;
}
self = [self initWithBase64EncodedString: stringValue];
objc_autoreleasePoolPop(pool);
return self;
}
- (void)dealloc
{
if (_freeWhenDone)
OFFreeMemory(_items);
|
︙ | | |
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
|
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
|
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
[file writeBuffer: _items length: _count * _itemSize];
} @finally {
[file release];
}
}
#endif
- (void)writeToURI: (OFURI *)URI
- (void)writeToIRI: (OFIRI *)IRI
{
void *pool = objc_autoreleasePoolPush();
[[OFURIHandler openItemAtURI: URI mode: @"w"] writeData: self];
[[OFIRIHandler openItemAtIRI: IRI mode: @"w"] writeData: self];
objc_autoreleasePoolPop(pool);
}
- (OFXMLElement *)XMLElementBySerializing
{
void *pool;
OFXMLElement *element;
if (_itemSize != 1)
@throw [OFNotImplementedException exceptionWithSelector: _cmd
object: self];
pool = objc_autoreleasePoolPush();
element = [OFXMLElement
elementWithName: self.className
namespace: OFSerializationNS
stringValue: OFBase64Encode(_items, _count * _itemSize)];
[element retain];
objc_autoreleasePoolPop(pool);
return [element autorelease];
}
- (OFData *)messagePackRepresentation
{
OFMutableData *data;
if (_itemSize != 1)
|
︙ | | |
Modified src/OFDatagramSocket.h
from [81b28eb069]
to [c25f58addd].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFDatagramSocket.m
from [ea19c6b109]
to [0e772bf0c7].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFDate.h
from [ba59d767f1]
to [5d6447d0f7].
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
|
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
|
-
+
-
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFObject.h"
#import "OFMessagePackRepresentation.h"
#import "OFSerialization.h"
OF_ASSUME_NONNULL_BEGIN
@class OFString;
@class OFConstantString;
/**
* @class OFDate OFDate.h ObjFW/OFDate.h
*
* @brief A class for storing, accessing and comparing dates.
*/
#ifndef OF_DATE_M
OF_SUBCLASSING_RESTRICTED
#endif
@interface OFDate: OFObject <OFCopying, OFComparing, OFSerialization,
@interface OFDate: OFObject <OFCopying, OFComparing,
OFMessagePackRepresentation>
{
OFTimeInterval _seconds;
}
#ifdef OF_HAVE_CLASS_PROPERTIES
@property (class, readonly, nonatomic) OFDate *distantFuture;
|
︙ | | |
Modified src/OFDate.m
from [692871b1cf]
to [8b8a822187].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
-
|
#ifdef OF_HAVE_THREADS
# import "OFMutex.h"
#endif
#import "OFStrPTime.h"
#import "OFString.h"
#import "OFSystemInfo.h"
#import "OFXMLAttribute.h"
#import "OFXMLElement.h"
#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFOutOfMemoryException.h"
#import "OFOutOfRangeException.h"
|
︙ | | |
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
|
491
492
493
494
495
496
497
498
499
500
501
502
503
504
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
seconds = tmAndTzToTime(&tm, tz);
objc_autoreleasePoolPop(pool);
return [self initWithTimeIntervalSince1970: seconds];
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
OFTimeInterval seconds;
@try {
void *pool = objc_autoreleasePoolPush();
unsigned long long value;
if (![element.name isEqual: @"OFDate"] ||
![element.namespace isEqual: OFSerializationNS])
@throw [OFInvalidArgumentException exception];
if (![[element attributeForName: @"encoding"].stringValue
isEqual: @"hex"])
@throw [OFInvalidFormatException exception];
value = [element unsignedLongLongValueWithBase: 16];
if (value > UINT64_MAX)
@throw [OFOutOfRangeException exception];
seconds = OFFromBigEndianDouble(OFRawUInt64ToDouble(
OFToBigEndian64(value)));
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return [self initWithTimeIntervalSince1970: seconds];
}
- (bool)isEqual: (id)object
{
OFDate *otherDate;
if (object == self)
return true;
|
︙ | | |
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
|
549
550
551
552
553
554
555
556
557
558
559
560
561
562
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
}
- (OFString *)description
{
return [self dateStringWithFormat: @"%Y-%m-%dT%H:%M:%SZ"];
}
- (OFXMLElement *)XMLElementBySerializing
{
void *pool = objc_autoreleasePoolPush();
OFXMLElement *element;
element = [OFXMLElement elementWithName: @"OFDate"
namespace: OFSerializationNS];
[element addAttributeWithName: @"encoding" stringValue: @"hex"];
element.stringValue = [OFString stringWithFormat: @"%016" PRIx64,
OFFromBigEndian64(OFDoubleToRawUInt64(OFToBigEndianDouble(
self.timeIntervalSince1970)))];
[element retain];
objc_autoreleasePoolPop(pool);
return [element autorelease];
}
- (OFData *)messagePackRepresentation
{
void *pool = objc_autoreleasePoolPush();
OFTimeInterval timeInterval = self.timeIntervalSince1970;
int64_t seconds = (int64_t)timeInterval;
uint32_t nanoseconds =
(uint32_t)((timeInterval - trunc(timeInterval)) * 1000000000);
|
︙ | | |
Modified src/OFDictionary.h
from [73af2a9ef3]
to [b2fad599b6].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
-
|
#endif
#include <stdarg.h>
#import "OFObject.h"
#import "OFCollection.h"
#import "OFEnumerator.h"
#import "OFSerialization.h"
#import "OFJSONRepresentation.h"
#import "OFMessagePackRepresentation.h"
OF_ASSUME_NONNULL_BEGIN
@class OFArray OF_GENERIC(ObjectType);
|
︙ | | |
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
-
+
|
* @note Fast enumeration on a dictionary enumerates through the keys of the
* dictionary.
*
* @note Subclasses must implement @ref objectForKey:, @ref count and
* @ref keyEnumerator.
*/
@interface OFDictionary OF_GENERIC(KeyType, ObjectType): OFObject <OFCopying,
OFMutableCopying, OFCollection, OFSerialization, OFJSONRepresentation,
OFMutableCopying, OFCollection, OFJSONRepresentation,
OFMessagePackRepresentation>
#if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN)
# define KeyType id
# define ObjectType id
#endif
/**
* @brief An array of all keys.
|
︙ | | |
Modified src/OFDictionary.m
from [cbf5abac37]
to [12d43fb634].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
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
|
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
|
-
-
-
-
-
-
-
-
|
#import "OFDictionary.h"
#import "OFArray.h"
#import "OFCharacterSet.h"
#import "OFData.h"
#import "OFEnumerator.h"
#import "OFMapTableDictionary.h"
#import "OFString.h"
#import "OFXMLElement.h"
#import "OFInvalidArgumentException.h"
#import "OFOutOfRangeException.h"
#import "OFUndefinedKeyException.h"
static struct {
Class isa;
} placeholder;
static OFCharacterSet *URIQueryPartAllowedCharacterSet = nil;
@interface OFDictionary ()
- (OFString *)
of_JSONRepresentationWithOptions: (OFJSONRepresentationOptions)options
depth: (size_t)depth;
@end
@interface OFDictionaryPlaceholder: OFDictionary
@end
OF_DIRECT_MEMBERS
@interface OFDictionaryObjectEnumerator: OFEnumerator
{
OFDictionary *_dictionary;
OFEnumerator *_keyEnumerator;
}
- (instancetype)initWithDictionary: (OFDictionary *)dictionary;
@end
OF_DIRECT_MEMBERS
@interface OFURIQueryPartAllowedCharacterSet: OFCharacterSet
+ (OFCharacterSet *)URIQueryPartAllowedCharacterSet;
@end
@implementation OFDictionaryPlaceholder
- (instancetype)init
{
return (id)[[OFMapTableDictionary alloc] init];
}
- (instancetype)initWithDictionary: (OFDictionary *)dictionary
|
︙ | | |
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
|
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
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
- (instancetype)initWithKey: (id <OFCopying>)firstKey
arguments: (va_list)arguments
{
return (id)[[OFMapTableDictionary alloc] initWithKey: firstKey
arguments: arguments];
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
return (id)[[OFMapTableDictionary alloc]
initWithSerialization: element];
}
- (instancetype)retain
{
return self;
}
- (instancetype)autorelease
{
return self;
}
- (void)release
{
}
- (void)dealloc
{
OF_DEALLOC_UNSUPPORTED
}
@end
@implementation OFURIQueryPartAllowedCharacterSet
+ (void)initialize
{
if (self != [OFURIQueryPartAllowedCharacterSet class])
return;
URIQueryPartAllowedCharacterSet =
[[OFURIQueryPartAllowedCharacterSet alloc] init];
}
+ (OFCharacterSet *)URIQueryPartAllowedCharacterSet
{
return URIQueryPartAllowedCharacterSet;
}
- (instancetype)autorelease
{
return self;
}
- (instancetype)retain
{
return self;
}
- (void)release
{
}
- (unsigned int)retainCount
{
return OFMaxRetainCount;
}
- (bool)characterIsMember: (OFUnichar)character
{
if (character < CHAR_MAX && OFASCIIIsAlnum(character))
return true;
switch (character) {
case '-':
case '.':
case '_':
case '~':
case '!':
case '$':
case '\'':
case '(':
case ')':
case '*':
case '+':
case ',':
case ';':
return true;
default:
return false;
}
}
@end
@implementation OFDictionary
+ (void)initialize
{
if (self == [OFDictionary class])
placeholder.isa = [OFDictionaryPlaceholder class];
|
︙ | | |
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
|
252
253
254
255
256
257
258
259
260
261
262
263
264
265
|
-
-
-
-
-
|
va_end(arguments);
return ret;
}
- (instancetype)initWithKey: (id)firstKey arguments: (va_list)arguments
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
OF_INVALID_INIT_METHOD
}
- (id)objectForKey: (id)key
{
OF_UNRECOGNIZED_SELECTOR
}
|
︙ | | |
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
|
554
555
556
557
558
559
560
561
562
563
564
565
566
567
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
[ret makeImmutable];
objc_autoreleasePoolPop(pool);
return ret;
}
- (OFXMLElement *)XMLElementBySerializing
{
void *pool = objc_autoreleasePoolPush();
OFXMLElement *element;
OFEnumerator *keyEnumerator, *objectEnumerator;
id <OFSerialization> key, object;
if ([self isKindOfClass: [OFMutableDictionary class]])
element = [OFXMLElement elementWithName: @"OFMutableDictionary"
namespace: OFSerializationNS];
else
element = [OFXMLElement elementWithName: @"OFDictionary"
namespace: OFSerializationNS];
keyEnumerator = [self keyEnumerator];
objectEnumerator = [self objectEnumerator];
while ((key = [keyEnumerator nextObject]) != nil &&
(object = [objectEnumerator nextObject]) != nil) {
void *pool2 = objc_autoreleasePoolPush();
OFXMLElement *keyElement, *objectElement;
keyElement = [OFXMLElement
elementWithName: @"key"
namespace: OFSerializationNS];
[keyElement addChild: key.XMLElementBySerializing];
objectElement = [OFXMLElement
elementWithName: @"object"
namespace: OFSerializationNS];
[objectElement addChild: object.XMLElementBySerializing];
[element addChild: keyElement];
[element addChild: objectElement];
objc_autoreleasePoolPop(pool2);
}
[element retain];
objc_autoreleasePoolPop(pool);
return [element autorelease];
}
- (OFString *)JSONRepresentation
{
return [self of_JSONRepresentationWithOptions: 0 depth: 0];
}
- (OFString *)JSONRepresentationWithOptions:
(OFJSONRepresentationOptions)options
|
︙ | | |
Renamed and modified
src/OFEmbeddedURIHandler.h
[c72607aa86]
to src/OFEmbeddedIRIHandler.h
[e6c81f46fa].
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
|
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
|
-
+
-
+
-
+
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFURIHandler.h"
#import "OFIRIHandler.h"
OF_ASSUME_NONNULL_BEGIN
@interface OFEmbeddedURIHandler: OFURIHandler
@interface OFEmbeddedIRIHandler: OFIRIHandler
@end
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Register a file for the `embedded:` URI scheme.
* @brief Register a file for the `embedded:` IRI scheme.
*
* Usually, you should not use the directly, but rather generate a source file
* for a file to be embedded using the `objfw-embed` tool.
*
* @param path The path to the file under the `embedded:` scheme. This is not
* retained, so you must either pass a constant string or pass a
* string that is already retained!
|
︙ | | |
Renamed and modified
src/OFEmbeddedURIHandler.m
[1976c624c2]
to src/OFEmbeddedIRIHandler.m
[3c1f214812].
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
|
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
|
-
+
-
-
-
+
+
+
+
-
+
-
-
+
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
-
+
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#import "OFEmbeddedURIHandler.h"
#import "OFMemoryStream.h"
#import "OFURI.h"
#import "OFEmbeddedIRIHandler.h"
#import "OFIRI.h"
#import "OFMemoryStream.h"
#import "OFInvalidArgumentException.h"
#import "OFOpenItemFailedException.h"
#ifdef OF_HAVE_THREADS
# import "OFOnce.h"
# import "OFPlainMutex.h"
#endif
struct EmbeddedFile {
OFString *path;
const uint8_t *bytes;
size_t size;
} *embeddedFiles = NULL;
size_t numEmbeddedFiles = 0;
#ifdef OF_HAVE_THREADS
static OFPlainMutex mutex;
static OFOnceControl mutexOnceControl = OFOnceControlInitValue;
static void
init(void)
initMutex(void)
{
OFEnsure(OFPlainMutexNew(&mutex) == 0);
}
#endif
void
OFRegisterEmbeddedFile(OFString *path, const uint8_t *bytes, size_t size)
{
#ifdef OF_HAVE_THREADS
static OFOnceControl onceControl = OFOnceControlInitValue;
OFOnce(&onceControl, init);
OFOnce(&mutexOnceControl, initMutex);
OFEnsure(OFPlainMutexLock(&mutex) == 0);
#endif
embeddedFiles = realloc(embeddedFiles,
sizeof(*embeddedFiles) * (numEmbeddedFiles + 1));
OFEnsure(embeddedFiles != NULL);
embeddedFiles[numEmbeddedFiles].path = path;
embeddedFiles[numEmbeddedFiles].bytes = bytes;
embeddedFiles[numEmbeddedFiles].size = size;
numEmbeddedFiles++;
#ifdef OF_HAVE_THREADS
OFEnsure(OFPlainMutexUnlock(&mutex) == 0);
#endif
}
@implementation OFEmbeddedURIHandler
- (OFStream *)openItemAtURI: (OFURI *)URI mode: (OFString *)mode
@implementation OFEmbeddedIRIHandler
#ifdef OF_HAVE_THREADS
+ (void)initialize
{
if (self == [OFEmbeddedIRIHandler class])
OFOnce(&mutexOnceControl, initMutex);
}
#endif
- (OFStream *)openItemAtIRI: (OFIRI *)IRI mode: (OFString *)mode
{
OFString *path;
if (![URI.scheme isEqual: @"embedded"] || URI.host.length > 0 ||
URI.port != nil || URI.user != nil || URI.password != nil ||
URI.query != nil || URI.fragment != nil)
if (![IRI.scheme isEqual: @"embedded"] || IRI.host.length > 0 ||
IRI.port != nil || IRI.user != nil || IRI.password != nil ||
IRI.query != nil || IRI.fragment != nil)
@throw [OFInvalidArgumentException exception];
if (![mode isEqual: @"r"])
@throw [OFOpenItemFailedException exceptionWithURI: URI
@throw [OFOpenItemFailedException exceptionWithIRI: IRI
mode: mode
errNo: EROFS];
if ((path = URI.path) == nil) {
if ((path = IRI.path) == nil) {
@throw [OFInvalidArgumentException exception];
}
#ifdef OF_HAVE_THREADS
OFEnsure(OFPlainMutexLock(&mutex) == 0);
@try {
#endif
|
︙ | | |
106
107
108
109
110
111
112
113
114
115
116
117
|
114
115
116
117
118
119
120
121
122
123
124
125
|
-
+
|
}
#ifdef OF_HAVE_THREADS
} @finally {
OFEnsure(OFPlainMutexUnlock(&mutex) == 0);
}
#endif
@throw [OFOpenItemFailedException exceptionWithURI: URI
@throw [OFOpenItemFailedException exceptionWithIRI: IRI
mode: mode
errNo: ENOENT];
}
@end
|
Modified src/OFEnumerator.h
from [bebf66139d]
to [d1ff19008a].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFEnumerator.m
from [bb10b4629e]
to [ad753eb610].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFEpollKernelEventObserver.h
from [d3c4bbd7da]
to [c12b332835].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFEpollKernelEventObserver.m
from [68ed1a2421]
to [7b99a4a097].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFFile.h
from [b56cdf66da]
to [95a6d86e52].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
-
-
|
#else
typedef struct _OFFileHandle *OFFileHandle;
static const OFFileHandle OFInvalidFileHandle = NULL;
#endif
OF_ASSUME_NONNULL_BEGIN
@class OFURI;
/**
* @class OFFile OFFile.h ObjFW/OFFile.h
*
* @brief A class which provides methods to read and write files.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFFile: OFSeekableStream
|
︙ | | |
Modified src/OFFile.m
from [c784d31e2e]
to [11d5a8e0e1].
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
|
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
|
-
+
+
-
+
+
-
+
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#ifndef _LARGEFILE64_SOURCE
#define _LARGEFILE64_SOURCE
# define _LARGEFILE64_SOURCE
#endif
#include <errno.h>
#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#endif
#include "unistd_wrapper.h"
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
#import "OFFile.h"
#import "OFLocale.h"
#import "OFString.h"
#import "OFSystemInfo.h"
#import "OFURI.h"
#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFNotOpenException.h"
#import "OFOpenItemFailedException.h"
#import "OFOutOfMemoryException.h"
#import "OFOutOfRangeException.h"
#import "OFReadFailedException.h"
#import "OFSeekFailedException.h"
#import "OFWriteFailedException.h"
#ifdef OF_WINDOWS
# include <windows.h>
#endif
#ifdef OF_AMIGAOS
# define Class IntuitionClass
# include <proto/exec.h>
# include <proto/dos.h>
# undef Class
#endif
#ifdef OF_WII
# include <fat.h>
#endif
#ifdef OF_NINTENDO_DS
|
︙ | | |
Renamed and modified
src/OFFileURIHandler.h
[24ec18a27d]
to src/OFFileIRIHandler.h
[5f206fb1d4].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
-
+
-
+
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFURIHandler.h"
#import "OFIRIHandler.h"
OF_ASSUME_NONNULL_BEGIN
@interface OFFileURIHandler: OFURIHandler
@interface OFFileIRIHandler: OFIRIHandler
+ (bool)of_directoryExistsAtPath: (OFString *)path OF_DIRECT;
@end
OF_ASSUME_NONNULL_END
|
Renamed and modified
src/OFFileURIHandler.m
[d74cbf6f89]
to src/OFFileIRIHandler.m
[624183587b].
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
|
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
|
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
-
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#ifndef _LARGEFILE64_SOURCE
#define _LARGEFILE64_SOURCE
# define _LARGEFILE64_SOURCE
#endif
#include <errno.h>
#include <math.h>
#ifdef HAVE_DIRENT_H
# include <dirent.h>
#endif
#include "unistd_wrapper.h"
#include "platform.h"
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
#include <sys/time.h>
#if defined(OF_LINUX) || defined(OF_MACOS)
# include <sys/xattr.h>
#endif
#ifdef OF_WINDOWS
# include <utime.h>
#endif
#ifdef OF_DJGPP
# include <syslimits.h>
#endif
#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#endif
#ifdef HAVE_PWD_H
# include <pwd.h>
#endif
#ifdef HAVE_GRP_H
# include <grp.h>
#endif
#import "OFFileURIHandler.h"
#import "OFFileIRIHandler.h"
#import "OFArray.h"
#import "OFData.h"
#import "OFDate.h"
#import "OFFile.h"
#import "OFFileManager.h"
#import "OFIRI.h"
#import "OFLocale.h"
#import "OFNumber.h"
#import "OFSystemInfo.h"
#import "OFURI.h"
#ifdef OF_HAVE_THREADS
# import "OFMutex.h"
#endif
#import "OFCreateDirectoryFailedException.h"
#import "OFCreateSymbolicLinkFailedException.h"
|
︙ | | |
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
+
+
|
# include <windows.h>
# include <direct.h>
# include <ntdef.h>
# include <wchar.h>
#endif
#ifdef OF_AMIGAOS
# define Class IntuitionClass
# include <proto/exec.h>
# include <proto/dos.h>
# include <proto/locale.h>
# undef Class
# ifdef OF_AMIGAOS4
# define DeleteFile(path) Delete(path)
# endif
#endif
#if defined(OF_WINDOWS) || defined(OF_AMIGAOS)
typedef struct {
|
︙ | | |
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
|
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
|
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
|
# endif
#endif
}
#ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS
static void
setSymbolicLinkDestinationAttribute(OFMutableFileAttributes attributes,
OFURI *URI)
OFIRI *IRI)
{
OFString *path = URI.fileSystemRepresentation;
# ifndef OF_WINDOWS
OFString *path = IRI.fileSystemRepresentation;
# ifdef OF_WINDOWS
OFStringEncoding encoding = [OFLocale encoding];
char destinationC[PATH_MAX];
ssize_t length;
OFString *destination;
length = readlink([path cStringWithEncoding: encoding], destinationC,
PATH_MAX);
if (length < 0)
@throw [OFGetItemAttributesFailedException
exceptionWithURI: URI
errNo: errno];
destination = [OFString stringWithCString: destinationC
encoding: encoding
length: length];
[attributes setObject: destination
forKey: OFFileSymbolicLinkDestination];
# else
HANDLE handle;
OFString *destination;
if (createSymbolicLinkWFuncPtr == NULL)
return;
if ((handle = CreateFileW(path.UTF16String, 0, (FILE_SHARE_READ |
FILE_SHARE_WRITE), NULL, OPEN_EXISTING,
FILE_FLAG_OPEN_REPARSE_POINT, NULL)) == INVALID_HANDLE_VALUE)
@throw [OFGetItemAttributesFailedException
exceptionWithURI: URI
exceptionWithIRI: IRI
errNo: lastError()];
@try {
union {
char bytes[MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
REPARSE_DATA_BUFFER data;
} buffer;
DWORD size;
wchar_t *tmp;
if (!DeviceIoControl(handle, FSCTL_GET_REPARSE_POINT, NULL, 0,
buffer.bytes, MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &size,
NULL))
@throw [OFGetItemAttributesFailedException
exceptionWithURI: URI
exceptionWithIRI: IRI
errNo: lastError()];
if (buffer.data.ReparseTag != IO_REPARSE_TAG_SYMLINK)
@throw [OFGetItemAttributesFailedException
exceptionWithURI: URI
exceptionWithIRI: IRI
errNo: lastError()];
# define slrb buffer.data.SymbolicLinkReparseBuffer
tmp = slrb.PathBuffer +
(slrb.SubstituteNameOffset / sizeof(wchar_t));
destination = [OFString
stringWithUTF16String: tmp
length: slrb.SubstituteNameLength /
sizeof(wchar_t)];
[attributes setObject: OFFileTypeSymbolicLink
forKey: OFFileType];
[attributes setObject: destination
forKey: OFFileSymbolicLinkDestination];
# undef slrb
} @finally {
CloseHandle(handle);
}
# elif defined(OF_HURD)
OFStringEncoding encoding = [OFLocale encoding];
int fd;
OFMutableData *destinationData;
OFString *destination;
fd = open([path cStringWithEncoding: encoding], O_RDONLY | O_NOLINK);
if (fd == -1)
@throw [OFGetItemAttributesFailedException
exceptionWithIRI: IRI
errNo: errno];
@try {
char buffer[512];
ssize_t length;
destinationData = [OFMutableData data];
while ((length = read(fd, buffer, 512)) > 0)
[destinationData addItems: buffer count: length];
} @finally {
close(fd);
}
destination = [OFString stringWithCString: destinationData.items
encoding: encoding
length: destinationData.count];
[attributes setObject: destination
forKey: OFFileSymbolicLinkDestination];
# else
OFStringEncoding encoding = [OFLocale encoding];
char destinationC[PATH_MAX];
ssize_t length;
OFString *destination;
length = readlink([path cStringWithEncoding: encoding], destinationC,
PATH_MAX);
if (length < 0)
@throw [OFGetItemAttributesFailedException
exceptionWithIRI: IRI
errNo: errno];
destination = [OFString stringWithCString: destinationC
encoding: encoding
length: length];
[attributes setObject: destination
forKey: OFFileSymbolicLinkDestination];
# endif
}
#endif
#ifdef OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES
static void
setExtendedAttributes(OFMutableFileAttributes attributes, OFIRI *IRI)
{
OFString *path = IRI.fileSystemRepresentation;
OFStringEncoding encoding = [OFLocale encoding];
const char *cPath = [path cStringWithEncoding: encoding];
# if defined(OF_LINUX)
ssize_t size = llistxattr(cPath, NULL, 0);
# elif defined(OF_MACOS)
ssize_t size = listxattr(cPath, NULL, 0, XATTR_NOFOLLOW);
# endif
char *list = OFAllocMemory(1, size);
OFMutableArray *names = nil;
@try {
char *name;
# if defined(OF_LINUX)
if ((size = llistxattr(cPath, list, size)) < 0)
# elif defined(OF_MACOS)
if ((size = listxattr(cPath, list, size, XATTR_NOFOLLOW)) < 0)
# endif
return;
names = [OFMutableArray array];
name = list;
while (size > 0) {
size_t length = strlen(name);
[names addObject: [OFString stringWithCString: name
encoding: encoding
length: length]];
name += length + 1;
size -= length + 1;
}
} @finally {
OFFreeMemory(list);
}
[attributes setObject: names forKey: OFFileExtendedAttributesNames];
}
#endif
@implementation OFFileURIHandler
@implementation OFFileIRIHandler
+ (void)initialize
{
#ifdef OF_WINDOWS
HMODULE module;
#endif
if (self != [OFFileURIHandler class])
if (self != [OFFileIRIHandler class])
return;
#if defined(OF_FILE_MANAGER_SUPPORTS_OWNER) && defined(OF_HAVE_THREADS)
passwdMutex = [[OFMutex alloc] init];
atexit(releasePasswdMutex);
#endif
#if !defined(HAVE_READDIR_R) && !defined(OF_WINDOWS) && defined(OF_HAVE_THREADS)
|
︙ | | |
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
|
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
+
+
+
+
-
+
-
+
-
+
+
+
+
+
+
-
+
-
+
+
-
+
+
+
+
+
+
-
+
-
+
+
|
if (statWrapper(path, &s) != 0)
return false;
return S_ISDIR(s.st_mode);
}
- (OFStream *)openItemAtURI: (OFURI *)URI mode: (OFString *)mode
- (OFStream *)openItemAtIRI: (OFIRI *)IRI mode: (OFString *)mode
{
void *pool = objc_autoreleasePoolPush();
OFFile *file = [[OFFile alloc]
initWithPath: URI.fileSystemRepresentation
initWithPath: IRI.fileSystemRepresentation
mode: mode];
objc_autoreleasePoolPop(pool);
return [file autorelease];
}
- (OFFileAttributes)attributesOfItemAtURI: (OFURI *)URI
- (OFFileAttributes)attributesOfItemAtIRI: (OFIRI *)IRI
{
OFMutableFileAttributes ret = [OFMutableDictionary dictionary];
void *pool = objc_autoreleasePoolPush();
OFString *path;
int error;
Stat s;
if (URI == nil)
if (IRI == nil)
@throw [OFInvalidArgumentException exception];
if (![[URI scheme] isEqual: _scheme])
if (![[IRI scheme] isEqual: _scheme])
@throw [OFInvalidArgumentException exception];
path = URI.fileSystemRepresentation;
path = IRI.fileSystemRepresentation;
if ((error = lstatWrapper(path, &s)) != 0)
@throw [OFGetItemAttributesFailedException
exceptionWithURI: URI
exceptionWithIRI: IRI
errNo: error];
if (s.st_size < 0)
@throw [OFOutOfRangeException exception];
[ret setObject: [NSNumber numberWithUnsignedLongLong: s.st_size]
forKey: OFFileSize];
setTypeAttribute(ret, &s);
[ret setObject: [NSNumber numberWithUnsignedLong: s.st_mode]
forKey: OFFilePOSIXPermissions];
setOwnerAndGroupAttributes(ret, &s);
setDateAttributes(ret, &s);
#ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS
if (S_ISLNK(s.st_mode))
setSymbolicLinkDestinationAttribute(ret, URI);
setSymbolicLinkDestinationAttribute(ret, IRI);
#endif
#ifdef OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES
setExtendedAttributes(ret, IRI);
#endif
objc_autoreleasePoolPop(pool);
return ret;
}
- (void)of_setLastAccessDate: (OFDate *)lastAccessDate
andModificationDate: (OFDate *)modificationDate
ofItemAtURI: (OFURI *)URI
ofItemAtIRI: (OFIRI *)IRI
attributes: (OFFileAttributes)attributes OF_DIRECT
{
OFString *path = URI.fileSystemRepresentation;
OFString *path = IRI.fileSystemRepresentation;
OFFileAttributeKey attributeKey = (modificationDate != nil
? OFFileModificationDate : OFFileLastAccessDate);
if (lastAccessDate == nil)
lastAccessDate = modificationDate;
if (modificationDate == nil)
modificationDate = lastAccessDate;
#if defined(OF_WINDOWS)
if (_wutime64FuncPtr != NULL) {
struct __utimbuf64 times = {
.actime =
(__time64_t)lastAccessDate.timeIntervalSince1970,
.modtime =
(__time64_t)modificationDate.timeIntervalSince1970
};
if (_wutime64FuncPtr([path UTF16String], ×) != 0)
if (_wutime64FuncPtr([path UTF16String], ×) != 0) {
int errNo = errno;
if (errNo == EACCES && [self directoryExistsAtIRI: IRI])
errNo = EISDIR;
@throw [OFSetItemAttributesFailedException
exceptionWithURI: URI
exceptionWithIRI: IRI
attributes: attributes
failedAttribute: attributeKey
errNo: errno];
errNo: errNo];
}
} else {
struct _utimbuf times = {
.actime = (time_t)lastAccessDate.timeIntervalSince1970,
.modtime =
(time_t)modificationDate.timeIntervalSince1970
};
int status;
if ([OFSystemInfo isWindowsNT])
status = _wutime([path UTF16String], ×);
else
status = _utime(
[path cStringWithEncoding: [OFLocale encoding]],
×);
if (status != 0)
if (status != 0) {
int errNo = errno;
if (errNo == EACCES && [self directoryExistsAtIRI: IRI])
errNo = EISDIR;
@throw [OFSetItemAttributesFailedException
exceptionWithURI: URI
exceptionWithIRI: IRI
attributes: attributes
failedAttribute: attributeKey
errNo: errno];
errNo: errNo];
}
}
#elif defined(OF_AMIGAOS)
/* AmigaOS does not support access time. */
OFTimeInterval modificationTime =
modificationDate.timeIntervalSince1970;
struct Locale *locale;
struct DateStamp date;
|
︙ | | |
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
|
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
|
-
+
|
if (!SetDate([path cStringWithEncoding: [OFLocale encoding]],
&date) != 0)
# else
if (!SetFileDate([path cStringWithEncoding: [OFLocale encoding]],
&date) != 0)
# endif
@throw [OFSetItemAttributesFailedException
exceptionWithURI: URI
exceptionWithIRI: IRI
attributes: attributes
failedAttribute: attributeKey
errNo: lastError()];
#else
OFTimeInterval lastAccessTime = lastAccessDate.timeIntervalSince1970;
OFTimeInterval modificationTime =
modificationDate.timeIntervalSince1970;
|
︙ | | |
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
|
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
|
.tv_usec = (int)((modificationTime - times[1].tv_sec) *
1000000)
},
};
if (utimes([path cStringWithEncoding: [OFLocale encoding]], times) != 0)
@throw [OFSetItemAttributesFailedException
exceptionWithURI: URI
exceptionWithIRI: IRI
attributes: attributes
failedAttribute: attributeKey
errNo: errno];
#endif
}
- (void)of_setPOSIXPermissions: (OFNumber *)permissions
ofItemAtURI: (OFURI *)URI
ofItemAtIRI: (OFIRI *)IRI
attributes: (OFFileAttributes)attributes OF_DIRECT
{
#ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS
mode_t mode = (mode_t)permissions.unsignedLongValue;
OFString *path = URI.fileSystemRepresentation;
OFString *path = IRI.fileSystemRepresentation;
int status;
# ifdef OF_WINDOWS
if ([OFSystemInfo isWindowsNT])
status = _wchmod(path.UTF16String, mode);
else
# endif
status = chmod(
[path cStringWithEncoding: [OFLocale encoding]], mode);
if (status != 0)
@throw [OFSetItemAttributesFailedException
exceptionWithURI: URI
exceptionWithIRI: IRI
attributes: attributes
failedAttribute: OFFilePOSIXPermissions
errNo: errno];
#else
OF_UNRECOGNIZED_SELECTOR
#endif
}
- (void)of_setOwnerAccountName: (OFString *)owner
andGroupOwnerAccountName: (OFString *)group
ofItemAtURI: (OFURI *)URI
ofItemAtIRI: (OFIRI *)IRI
attributeKey: (OFFileAttributeKey)attributeKey
attributes: (OFFileAttributes)attributes OF_DIRECT
{
#ifdef OF_FILE_MANAGER_SUPPORTS_OWNER
OFString *path = URI.fileSystemRepresentation;
OFString *path = IRI.fileSystemRepresentation;
uid_t uid = -1;
gid_t gid = -1;
OFStringEncoding encoding;
if (owner == nil && group == nil)
@throw [OFInvalidArgumentException exception];
encoding = [OFLocale encoding];
# ifdef OF_HAVE_THREADS
[passwdMutex lock];
@try {
# endif
if (owner != nil) {
struct passwd *passwd;
if ((passwd = getpwnam([owner
cStringWithEncoding: encoding])) == NULL)
@throw [OFSetItemAttributesFailedException
exceptionWithURI: URI
exceptionWithIRI: IRI
attributes: attributes
failedAttribute: attributeKey
errNo: errno];
uid = passwd->pw_uid;
}
if (group != nil) {
struct group *group_;
if ((group_ = getgrnam([group
cStringWithEncoding: encoding])) == NULL)
@throw [OFSetItemAttributesFailedException
exceptionWithURI: URI
exceptionWithIRI: IRI
attributes: attributes
failedAttribute: attributeKey
errNo: errno];
gid = group_->gr_gid;
}
# ifdef OF_HAVE_THREADS
} @finally {
[passwdMutex unlock];
}
# endif
if (chown([path cStringWithEncoding: encoding], uid, gid) != 0)
@throw [OFSetItemAttributesFailedException
exceptionWithURI: URI
exceptionWithIRI: IRI
attributes: attributes
failedAttribute: attributeKey
errNo: errno];
#else
OF_UNRECOGNIZED_SELECTOR
#endif
}
- (void)setAttributes: (OFFileAttributes)attributes ofItemAtURI: (OFURI *)URI
- (void)setAttributes: (OFFileAttributes)attributes ofItemAtIRI: (OFIRI *)IRI
{
void *pool = objc_autoreleasePoolPush();
OFEnumerator OF_GENERIC(OFFileAttributeKey) *keyEnumerator;
OFEnumerator *objectEnumerator;
OFFileAttributeKey key;
id object;
OFDate *lastAccessDate, *modificationDate;
if (URI == nil)
if (IRI == nil)
@throw [OFInvalidArgumentException exception];
if (![URI.scheme isEqual: _scheme])
if (![IRI.scheme isEqual: _scheme])
@throw [OFInvalidArgumentException exception];
keyEnumerator = [attributes keyEnumerator];
objectEnumerator = [attributes objectEnumerator];
while ((key = [keyEnumerator nextObject]) != nil &&
(object = [objectEnumerator nextObject]) != nil) {
if ([key isEqual: OFFileModificationDate] ||
[key isEqual: OFFileLastAccessDate])
continue;
else if ([key isEqual: OFFilePOSIXPermissions])
[self of_setPOSIXPermissions: object
ofItemAtURI: URI
ofItemAtIRI: IRI
attributes: attributes];
else if ([key isEqual: OFFileOwnerAccountName])
[self of_setOwnerAccountName: object
andGroupOwnerAccountName: nil
ofItemAtURI: URI
ofItemAtIRI: IRI
attributeKey: key
attributes: attributes];
else if ([key isEqual: OFFileGroupOwnerAccountName])
[self of_setOwnerAccountName: nil
andGroupOwnerAccountName: object
ofItemAtURI: URI
ofItemAtIRI: IRI
attributeKey: key
attributes: attributes];
else
@throw [OFNotImplementedException
exceptionWithSelector: _cmd
object: self];
}
lastAccessDate = [attributes objectForKey: OFFileLastAccessDate];
modificationDate = [attributes objectForKey: OFFileModificationDate];
if (lastAccessDate != nil || modificationDate != nil)
[self of_setLastAccessDate: lastAccessDate
andModificationDate: modificationDate
ofItemAtURI: URI
ofItemAtIRI: IRI
attributes: attributes];
objc_autoreleasePoolPop(pool);
}
- (bool)fileExistsAtURI: (OFURI *)URI
- (bool)fileExistsAtIRI: (OFIRI *)IRI
{
void *pool = objc_autoreleasePoolPush();
Stat s;
bool ret;
if (URI == nil)
if (IRI == nil)
@throw [OFInvalidArgumentException exception];
if (![URI.scheme isEqual: _scheme])
if (![IRI.scheme isEqual: _scheme])
@throw [OFInvalidArgumentException exception];
if (statWrapper(URI.fileSystemRepresentation, &s) != 0) {
if (statWrapper(IRI.fileSystemRepresentation, &s) != 0) {
objc_autoreleasePoolPop(pool);
return false;
}
ret = S_ISREG(s.st_mode);
objc_autoreleasePoolPop(pool);
return ret;
}
- (bool)directoryExistsAtURI: (OFURI *)URI
- (bool)directoryExistsAtIRI: (OFIRI *)IRI
{
void *pool = objc_autoreleasePoolPush();
Stat s;
bool ret;
if (URI == nil)
if (IRI == nil)
@throw [OFInvalidArgumentException exception];
if (![URI.scheme isEqual: _scheme])
if (![IRI.scheme isEqual: _scheme])
@throw [OFInvalidArgumentException exception];
if (statWrapper(URI.fileSystemRepresentation, &s) != 0) {
if (statWrapper(IRI.fileSystemRepresentation, &s) != 0) {
objc_autoreleasePoolPop(pool);
return false;
}
ret = S_ISDIR(s.st_mode);
objc_autoreleasePoolPop(pool);
return ret;
}
- (void)createDirectoryAtURI: (OFURI *)URI
- (void)createDirectoryAtIRI: (OFIRI *)IRI
{
void *pool = objc_autoreleasePoolPush();
OFString *path;
if (URI == nil)
if (IRI == nil)
@throw [OFInvalidArgumentException exception];
if (![URI.scheme isEqual: _scheme])
if (![IRI.scheme isEqual: _scheme])
@throw [OFInvalidArgumentException exception];
path = URI.fileSystemRepresentation;
path = IRI.fileSystemRepresentation;
#if defined(OF_WINDOWS)
int status;
if ([OFSystemInfo isWindowsNT])
status = _wmkdir(path.UTF16String);
else
status = _mkdir(
[path cStringWithEncoding: [OFLocale encoding]]);
if (status != 0)
@throw [OFCreateDirectoryFailedException
exceptionWithURI: URI
exceptionWithIRI: IRI
errNo: errno];
#elif defined(OF_AMIGAOS)
BPTR lock;
if ((lock = CreateDir(
[path cStringWithEncoding: [OFLocale encoding]])) == 0)
@throw [OFCreateDirectoryFailedException
exceptionWithURI: URI
exceptionWithIRI: IRI
errNo: lastError()];
UnLock(lock);
#else
if (mkdir([path cStringWithEncoding: [OFLocale encoding]], 0777) != 0)
@throw [OFCreateDirectoryFailedException
exceptionWithURI: URI
exceptionWithIRI: IRI
errNo: errno];
#endif
objc_autoreleasePoolPop(pool);
}
- (OFArray OF_GENERIC(OFURI *) *)contentsOfDirectoryAtURI: (OFURI *)URI
- (OFArray OF_GENERIC(OFIRI *) *)contentsOfDirectoryAtIRI: (OFIRI *)IRI
{
OFMutableArray *URIs = [OFMutableArray array];
OFMutableArray *IRIs = [OFMutableArray array];
void *pool = objc_autoreleasePoolPush();
OFString *path;
if (URI == nil)
if (IRI == nil)
@throw [OFInvalidArgumentException exception];
if (![URI.scheme isEqual: _scheme])
if (![IRI.scheme isEqual: _scheme])
@throw [OFInvalidArgumentException exception];
path = URI.fileSystemRepresentation;
path = IRI.fileSystemRepresentation;
#if defined(OF_WINDOWS)
HANDLE handle;
path = [path stringByAppendingString: @"\\*"];
if ([OFSystemInfo isWindowsNT]) {
WIN32_FIND_DATAW fd;
if ((handle = FindFirstFileW(path.UTF16String,
&fd)) == INVALID_HANDLE_VALUE)
@throw [OFOpenItemFailedException
exceptionWithURI: URI
exceptionWithIRI: IRI
mode: nil
errNo: lastError()];
@try {
do {
OFString *file;
if (wcscmp(fd.cFileName, L".") == 0 ||
wcscmp(fd.cFileName, L"..") == 0)
continue;
file = [[OFString alloc]
initWithUTF16String: fd.cFileName];
@try {
[URIs addObject: [URI
URIByAppendingPathComponent: file]];
[IRIs addObject: [IRI
IRIByAppendingPathComponent: file]];
} @finally {
[file release];
}
} while (FindNextFileW(handle, &fd));
if (GetLastError() != ERROR_NO_MORE_FILES)
@throw [OFReadFailedException
|
︙ | | |
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
|
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
|
-
+
-
-
+
+
|
OFStringEncoding encoding = [OFLocale encoding];
WIN32_FIND_DATA fd;
if ((handle = FindFirstFileA(
[path cStringWithEncoding: encoding], &fd)) ==
INVALID_HANDLE_VALUE)
@throw [OFOpenItemFailedException
exceptionWithURI: URI
exceptionWithIRI: IRI
mode: nil
errNo: lastError()];
@try {
do {
OFString *file;
if (strcmp(fd.cFileName, ".") == 0 ||
strcmp(fd.cFileName, "..") == 0)
continue;
file = [[OFString alloc]
initWithCString: fd.cFileName
encoding: encoding];
@try {
[URIs addObject: [URI
URIByAppendingPathComponent: file]];
[IRIs addObject: [IRI
IRIByAppendingPathComponent: file]];
} @finally {
[file release];
}
} while (FindNextFileA(handle, &fd));
if (GetLastError() != ERROR_NO_MORE_FILES)
@throw [OFReadFailedException
|
︙ | | |
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
|
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
|
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
|
#elif defined(OF_AMIGAOS)
OFStringEncoding encoding = [OFLocale encoding];
BPTR lock;
if ((lock = Lock([path cStringWithEncoding: encoding],
SHARED_LOCK)) == 0)
@throw [OFOpenItemFailedException
exceptionWithURI: URI
exceptionWithIRI: IRI
mode: nil
errNo: lastError()];
@try {
# ifdef OF_AMIGAOS4
struct ExamineData *ed;
APTR context;
if ((context = ObtainDirContextTags(EX_FileLockInput, lock,
EX_DoCurrentDir, TRUE, EX_DataFields, EXF_NAME,
TAG_END)) == NULL)
@throw [OFOpenItemFailedException
exceptionWithURI: URI
exceptionWithIRI: IRI
mode: nil
errNo: lastError()];
@try {
while ((ed = ExamineDir(context)) != NULL) {
OFString *file = [[OFString alloc]
initWithCString: ed->Name
encoding: encoding];
@try {
[URIs addObject: [URI
URIByAppendingPathComponent: file]];
[IRIs addObject: [IRI
IRIByAppendingPathComponent: file]];
} @finally {
[file release];
}
}
} @finally {
ReleaseDirContext(context);
}
# else
struct FileInfoBlock fib;
if (!Examine(lock, &fib))
@throw [OFOpenItemFailedException
exceptionWithURI: URI
exceptionWithIRI: IRI
mode: nil
errNo: lastError()];
while (ExNext(lock, &fib)) {
OFString *file = [[OFString alloc]
initWithCString: fib.fib_FileName
encoding: encoding];
@try {
[URIs addObject:
[URI URIByAppendingPathComponent: file]];
[IRIs addObject:
[IRI IRIByAppendingPathComponent: file]];
} @finally {
[file release];
}
}
# endif
if (IoErr() != ERROR_NO_MORE_ENTRIES)
@throw [OFReadFailedException
exceptionWithObject: self
requestedLength: 0
errNo: lastError()];
} @finally {
UnLock(lock);
}
#else
OFStringEncoding encoding = [OFLocale encoding];
DIR *dir;
if ((dir = opendir([path cStringWithEncoding: encoding])) == NULL)
@throw [OFOpenItemFailedException exceptionWithURI: URI
@throw [OFOpenItemFailedException exceptionWithIRI: IRI
mode: nil
errNo: errno];
# if !defined(HAVE_READDIR_R) && defined(OF_HAVE_THREADS)
@try {
[readdirMutex lock];
} @catch (id e) {
|
︙ | | |
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
|
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
|
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
|
if (strcmp(dirent->d_name, ".") == 0 ||
strcmp(dirent->d_name, "..") == 0)
continue;
file = [[OFString alloc] initWithCString: dirent->d_name
encoding: encoding];
@try {
[URIs addObject:
[URI URIByAppendingPathComponent: file]];
[IRIs addObject:
[IRI IRIByAppendingPathComponent: file]];
} @finally {
[file release];
}
}
} @finally {
closedir(dir);
# if !defined(HAVE_READDIR_R) && defined(OF_HAVE_THREADS)
[readdirMutex unlock];
# endif
}
#endif
[URIs makeImmutable];
[IRIs makeImmutable];
objc_autoreleasePoolPop(pool);
return URIs;
return IRIs;
}
- (void)removeItemAtURI: (OFURI *)URI
- (void)removeItemAtIRI: (OFIRI *)IRI
{
void *pool = objc_autoreleasePoolPush();
OFString *path;
int error;
Stat s;
if (URI == nil)
if (IRI == nil)
@throw [OFInvalidArgumentException exception];
if (![URI.scheme isEqual: _scheme])
if (![IRI.scheme isEqual: _scheme])
@throw [OFInvalidArgumentException exception];
path = URI.fileSystemRepresentation;
path = IRI.fileSystemRepresentation;
if ((error = lstatWrapper(path, &s)) != 0)
@throw [OFRemoveItemFailedException exceptionWithURI: URI
@throw [OFRemoveItemFailedException exceptionWithIRI: IRI
errNo: error];
if (S_ISDIR(s.st_mode)) {
OFArray OF_GENERIC(OFURI *) *contents;
OFArray OF_GENERIC(OFIRI *) *contents;
@try {
contents = [self contentsOfDirectoryAtURI: URI];
contents = [self contentsOfDirectoryAtIRI: IRI];
} @catch (id e) {
/*
* Only convert exceptions to
* OFRemoveItemFailedException that have an errNo
* property. This covers all I/O related exceptions
* from the operations used to remove an item, all
* others should be left as is.
*/
if ([e respondsToSelector: @selector(errNo)])
@throw [OFRemoveItemFailedException
exceptionWithURI: URI
exceptionWithIRI: IRI
errNo: [e errNo]];
@throw e;
}
for (OFURI *item in contents) {
for (OFIRI *item in contents) {
void *pool2 = objc_autoreleasePoolPush();
[self removeItemAtURI: item];
[self removeItemAtIRI: item];
objc_autoreleasePoolPop(pool2);
}
#ifndef OF_AMIGAOS
int status;
# ifdef OF_WINDOWS
if ([OFSystemInfo isWindowsNT])
status = _wrmdir(path.UTF16String);
else
# endif
status = rmdir(
[path cStringWithEncoding: [OFLocale encoding]]);
if (status != 0)
@throw [OFRemoveItemFailedException
exceptionWithURI: URI
exceptionWithIRI: IRI
errNo: errno];
} else {
int status;
# ifdef OF_WINDOWS
if ([OFSystemInfo isWindowsNT])
status = _wunlink(path.UTF16String);
else
# endif
status = unlink(
[path cStringWithEncoding: [OFLocale encoding]]);
if (status != 0)
@throw [OFRemoveItemFailedException
exceptionWithURI: URI
exceptionWithIRI: IRI
errNo: errno];
#endif
}
#ifdef OF_AMIGAOS
if (!DeleteFile([path cStringWithEncoding: [OFLocale encoding]]))
@throw [OFRemoveItemFailedException
exceptionWithURI: URI
exceptionWithIRI: IRI
errNo: lastError()];
#endif
objc_autoreleasePoolPop(pool);
}
#ifdef OF_FILE_MANAGER_SUPPORTS_LINKS
- (void)linkItemAtURI: (OFURI *)source toURI: (OFURI *)destination
- (void)linkItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination
{
void *pool = objc_autoreleasePoolPush();
OFString *sourcePath, *destinationPath;
if (source == nil || destination == nil)
@throw [OFInvalidArgumentException exception];
if (![source.scheme isEqual: _scheme] ||
![destination.scheme isEqual: _scheme])
@throw [OFInvalidArgumentException exception];
sourcePath = source.fileSystemRepresentation;
destinationPath = destination.fileSystemRepresentation;
# ifndef OF_WINDOWS
OFStringEncoding encoding = [OFLocale encoding];
if (link([sourcePath cStringWithEncoding: encoding],
[destinationPath cStringWithEncoding: encoding]) != 0)
@throw [OFLinkItemFailedException
exceptionWithSourceURI: source
destinationURI: destination
exceptionWithSourceIRI: source
destinationIRI: destination
errNo: errno];
# else
if (createHardLinkWFuncPtr == NULL)
@throw [OFNotImplementedException exceptionWithSelector: _cmd
object: self];
if (!createHardLinkWFuncPtr(destinationPath.UTF16String,
sourcePath.UTF16String, NULL))
@throw [OFLinkItemFailedException
exceptionWithSourceURI: source
destinationURI: destination
exceptionWithSourceIRI: source
destinationIRI: destination
errNo: lastError()];
# endif
objc_autoreleasePoolPop(pool);
}
#endif
#ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS
- (void)createSymbolicLinkAtURI: (OFURI *)URI
- (void)createSymbolicLinkAtIRI: (OFIRI *)IRI
withDestinationPath: (OFString *)target
{
void *pool = objc_autoreleasePoolPush();
OFString *path;
if (URI == nil || target == nil)
if (IRI == nil || target == nil)
@throw [OFInvalidArgumentException exception];
if (![URI.scheme isEqual: _scheme])
if (![IRI.scheme isEqual: _scheme])
@throw [OFInvalidArgumentException exception];
path = URI.fileSystemRepresentation;
path = IRI.fileSystemRepresentation;
# ifndef OF_WINDOWS
OFStringEncoding encoding = [OFLocale encoding];
if (symlink([target cStringWithEncoding: encoding],
[path cStringWithEncoding: encoding]) != 0)
@throw [OFCreateSymbolicLinkFailedException
exceptionWithURI: URI
exceptionWithIRI: IRI
target: target
errNo: errno];
# else
if (createSymbolicLinkWFuncPtr == NULL)
@throw [OFNotImplementedException exceptionWithSelector: _cmd
object: self];
if (!createSymbolicLinkWFuncPtr(path.UTF16String, target.UTF16String,
0))
@throw [OFCreateSymbolicLinkFailedException
exceptionWithURI: URI
exceptionWithIRI: IRI
target: target
errNo: lastError()];
# endif
objc_autoreleasePoolPop(pool);
}
#endif
- (bool)moveItemAtURI: (OFURI *)source toURI: (OFURI *)destination
- (bool)moveItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination
{
void *pool;
if (![source.scheme isEqual: _scheme] ||
![destination.scheme isEqual: _scheme])
return false;
if ([self fileExistsAtURI: destination])
if ([self fileExistsAtIRI: destination])
@throw [OFMoveItemFailedException
exceptionWithSourceURI: source
destinationURI: destination
exceptionWithSourceIRI: source
destinationIRI: destination
errNo: EEXIST];
pool = objc_autoreleasePoolPush();
#ifdef OF_AMIGAOS
OFStringEncoding encoding = [OFLocale encoding];
if (!Rename([source.fileSystemRepresentation
cStringWithEncoding: encoding],
[destination.fileSystemRepresentation
cStringWithEncoding: encoding]))
@throw [OFMoveItemFailedException
exceptionWithSourceURI: source
destinationURI: destination
exceptionWithSourceIRI: source
destinationIRI: destination
errNo: lastError()];
#else
int status;
# ifdef OF_WINDOWS
if ([OFSystemInfo isWindowsNT])
status = _wrename(source.fileSystemRepresentation.UTF16String,
|
︙ | | |
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
|
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
|
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
cStringWithEncoding: encoding]);
# ifdef OF_WINDOWS
}
# endif
if (status != 0)
@throw [OFMoveItemFailedException
exceptionWithSourceURI: source
destinationURI: destination
exceptionWithSourceIRI: source
destinationIRI: destination
errNo: errno];
#endif
objc_autoreleasePoolPop(pool);
return true;
}
#ifdef OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES
- (OFData *)extendedAttributeDataForName: (OFString *)name
ofItemAtIRI: (OFIRI *)IRI
{
void *pool = objc_autoreleasePoolPush();
OFString *path = IRI.fileSystemRepresentation;
OFStringEncoding encoding = [OFLocale encoding];
const char *cPath = [path cStringWithEncoding: encoding];
const char *cName = [name cStringWithEncoding: encoding];
# if defined(OF_LINUX)
ssize_t size = lgetxattr(cPath, cName, NULL, 0);
# elif defined(OF_MACOS)
ssize_t size = getxattr(cPath, cName, NULL, 0, 0, XATTR_NOFOLLOW);
# endif
void *value = OFAllocMemory(1, size);
OFData *data;
@try {
# if defined(OF_LINUX)
if ((size = lgetxattr(cPath, cName, value, size)) < 0)
# elif defined(OF_MACOS)
if ((size = getxattr(cPath, cName, value, size, 0,
XATTR_NOFOLLOW)) < 0)
# endif
@throw [OFGetItemAttributesFailedException
exceptionWithIRI: IRI
errNo: errno];
data = [OFData dataWithItems: value count: size];
} @finally {
OFFreeMemory(value);
}
[data retain];
objc_autoreleasePoolPop(pool);
return [data autorelease];
}
- (void)setExtendedAttributeData: (OFData *)data
forName: (OFString *)name
ofItemAtIRI: (OFIRI *)IRI
{
void *pool = objc_autoreleasePoolPush();
OFString *path = IRI.fileSystemRepresentation;
OFStringEncoding encoding = [OFLocale encoding];
# if defined(OF_LINUX)
if (lsetxattr([path cStringWithEncoding: encoding],
[name cStringWithEncoding: encoding], data.items,
data.count * data.itemSize, 0) != 0) {
# elif defined(OF_MACOS)
if (setxattr([path cStringWithEncoding: encoding],
[name cStringWithEncoding: encoding], data.items,
data.count * data.itemSize, 0, XATTR_NOFOLLOW) != 0) {
# endif
int errNo = errno;
/* TODO: Add an attribute (prefix?) for extended attributes? */
@throw [OFSetItemAttributesFailedException
exceptionWithIRI: IRI
attributes: [OFDictionary dictionary]
failedAttribute: @""
errNo: errNo];
}
objc_autoreleasePoolPop(pool);
}
- (void)removeExtendedAttributeForName: (OFString *)name
ofItemAtIRI: (OFIRI *)IRI
{
void *pool = objc_autoreleasePoolPush();
OFString *path = IRI.fileSystemRepresentation;
OFStringEncoding encoding = [OFLocale encoding];
# if defined(OF_LINUX)
if (lremovexattr([path cStringWithEncoding: encoding],
[name cStringWithEncoding: encoding]) != 0) {
# elif defined(OF_MACOS)
if (removexattr([path cStringWithEncoding: encoding],
[name cStringWithEncoding: encoding], XATTR_NOFOLLOW) != 0) {
# endif
int errNo = errno;
/* TODO: Add an attribute (prefix?) for extended attributes? */
@throw [OFSetItemAttributesFailedException
exceptionWithIRI: IRI
attributes: [OFDictionary dictionary]
failedAttribute: @""
errNo: errNo];
}
objc_autoreleasePoolPop(pool);
}
#endif
@end
|
Modified src/OFFileManager.h
from [1cfc8cfdf6]
to [eca60449c1].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
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
|
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
|
+
+
+
-
-
+
+
-
+
+
-
+
-
+
-
+
|
# endif
# if (defined(OF_HAVE_LINK) && !defined(OF_AMIGAOS)) || defined(OF_WINDOWS)
# define OF_FILE_MANAGER_SUPPORTS_LINKS
# endif
# if (defined(OF_HAVE_SYMLINK) && !defined(OF_AMIGAOS)) || defined(OF_WINDOWS)
# define OF_FILE_MANAGER_SUPPORTS_SYMLINKS
# endif
# if defined(OF_LINUX) || defined(OF_MACOS)
# define OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES
# endif
#endif
@class OFArray OF_GENERIC(ObjectType);
@class OFConstantString;
@class OFDate;
@class OFString;
@class OFURI;
@class OFIRI;
@class OFString;
/**
* @brief A key for a file attribute in the file attributes dictionary.
*
* Possible keys for file URIs are:
* Possible keys for file IRIs are:
*
* * @ref OFFileSize
* * @ref OFFileType
* * @ref OFFilePOSIXPermissions
* * @ref OFFileOwnerAccountID
* * @ref OFFileGroupOwnerAccountID
* * @ref OFFileOwnerAccountName
* * @ref OFFileGroupOwnerAccountName
* * @ref OFFileLastAccessDate
* * @ref OFFileModificationDate
* * @ref OFFileStatusChangeDate
* * @ref OFFileCreationDate
* * @ref OFFileSymbolicLinkDestination
* * @ref OFFileExtendedAttributesNames
*
* Other URI schemes might not have all keys and might have keys not listed.
* Other IRI schemes might not have all keys and might have keys not listed.
*/
typedef OFConstantString *OFFileAttributeKey;
/**
* @brief The type of a file.
*
* Possibles values for file URIs are:
* Possibles values for file IRIs are:
*
* * @ref OFFileTypeRegular
* * @ref OFFileTypeDirectory
* * @ref OFFileTypeSymbolicLink
* * @ref OFFileTypeFIFO
* * @ref OFFileTypeCharacterSpecial
* * @ref OFFileTypeBlockSpecial
* * @ref OFFileTypeSocket
* * @ref OFFileTypeUnknown
*
* Other URI schemes might not have all types and might have types not listed.
* Other IRI schemes might not have all types and might have types not listed.
*/
typedef OFConstantString *OFFileAttributeType;
/**
* @brief A dictionary mapping keys of type @ref OFFileAttributeKey to their
* attribute values.
*/
|
︙ | | |
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
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
|
-
+
+
+
+
+
+
+
+
+
+
|
*
* For convenience, a category on @ref OFDictionary is provided to access this
* via @ref OFDictionary#fileCreationDate.
*/
extern const OFFileAttributeKey OFFileCreationDate;
/**
* @brief The destination of a symbolic link as an OFString.
* @brief The destination of a symbolic link as an @ref OFString.
*
* For convenience, a category on @ref OFDictionary is provided to access this
* via @ref OFDictionary#fileSymbolicLinkDestination.
*/
extern const OFFileAttributeKey OFFileSymbolicLinkDestination;
/**
* @brief The names of the extended attributes as an @ref OFArray of
* @ref OFString.
*
* For convenience, a category on @ref OFDictionary is provided to access this
* via @ref OFDictionary#fileExtendedAttributesNames.
*/
extern const OFFileAttributeKey OFFileExtendedAttributesNames;
/**
* @brief A regular file.
*/
extern const OFFileAttributeType OFFileTypeRegular;
/**
* @brief A directory.
|
︙ | | |
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
|
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
|
-
+
-
+
|
* @brief The path of the current working directory.
*
* @throw OFGetCurrentDirectoryFailedException Couldn't get current directory
*/
@property (readonly, nonatomic) OFString *currentDirectoryPath;
/**
* @brief The URI of the current working directory.
* @brief The IRI of the current working directory.
*
* @throw OFGetCurrentDirectoryFailedException Couldn't get current directory
*/
@property (readonly, nonatomic) OFURI *currentDirectoryURI;
@property (readonly, nonatomic) OFIRI *currentDirectoryIRI;
#endif
/**
* @brief Returns the default file manager.
*/
+ (OFFileManager *)defaultManager;
|
︙ | | |
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
|
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
|
-
+
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
-
-
+
+
+
-
+
-
+
-
-
-
+
+
+
-
+
|
* @throw OFGetItemAttributesFailedException Failed to get the attributes of
* the item
*/
- (OFFileAttributes)attributesOfItemAtPath: (OFString *)path;
#endif
/**
* @brief Returns the attributes for the item at the specified URI.
* @brief Returns the attributes for the item at the specified IRI.
*
* @param URI The URI to return the attributes for
* @return A dictionary of attributes for the specified URI, with the keys of
* @param IRI The IRI to return the attributes for
* @return A dictionary of attributes for the specified IRI, with the keys of
* type @ref OFFileAttributeKey
* @throw OFGetItemAttributesFailedException Failed to get the attributes of
* the item
* @throw OFUnsupportedProtocolException No handler is registered for the URI's
* @throw OFUnsupportedProtocolException No handler is registered for the IRI's
* scheme
*/
- (OFFileAttributes)attributesOfItemAtURI: (OFURI *)URI;
- (OFFileAttributes)attributesOfItemAtIRI: (OFIRI *)IRI;
#ifdef OF_HAVE_FILES
/**
* @brief Sets the attributes for the item at the specified path.
*
* All attributes not part of the dictionary are left unchanged.
*
* @param attributes The attributes to set for the specified path
* @param path The path of the item to set the attributes for
* @throw OFSetItemAttributesFailedException Failed to set the attributes of
* the item
* @throw OFNotImplementedException Setting one or more of the specified
* attributes is not implemented for the
* specified item
*/
- (void)setAttributes: (OFFileAttributes)attributes
ofItemAtPath: (OFString *)path;
#endif
/**
* @brief Sets the attributes for the item at the specified URI.
* @brief Sets the attributes for the item at the specified IRI.
*
* All attributes not part of the dictionary are left unchanged.
*
* @param attributes The attributes to set for the specified URI
* @param URI The URI of the item to set the attributes for
* @param attributes The attributes to set for the specified IRI
* @param IRI The IRI of the item to set the attributes for
* @throw OFSetItemAttributesFailedException Failed to set the attributes of
* the item
* @throw OFUnsupportedProtocolException No handler is registered for the URI's
* @throw OFUnsupportedProtocolException No handler is registered for the IRI's
* scheme
* @throw OFNotImplementedException Setting one or more of the specified
* attributes is not implemented for the
* specified item
*/
- (void)setAttributes: (OFFileAttributes)attributes ofItemAtURI: (OFURI *)URI;
- (void)setAttributes: (OFFileAttributes)attributes ofItemAtIRI: (OFIRI *)IRI;
#ifdef OF_HAVE_FILES
/**
* @brief Checks whether a file exists at the specified path.
*
* @param path The path to check
* @return A boolean whether there is a file at the specified path
*/
- (bool)fileExistsAtPath: (OFString *)path;
#endif
/**
* @brief Checks whether a file exists at the specified URI.
* @brief Checks whether a file exists at the specified IRI.
*
* @param URI The URI to check
* @return A boolean whether there is a file at the specified URI
* @throw OFUnsupportedProtocolException No handler is registered for the URI's
* @param IRI The IRI to check
* @return A boolean whether there is a file at the specified IRI
* @throw OFUnsupportedProtocolException No handler is registered for the IRI's
* scheme
*/
- (bool)fileExistsAtURI: (OFURI *)URI;
- (bool)fileExistsAtIRI: (OFIRI *)IRI;
#ifdef OF_HAVE_FILES
/**
* @brief Checks whether a directory exists at the specified path.
*
* @param path The path to check
* @return A boolean whether there is a directory at the specified path
*/
- (bool)directoryExistsAtPath: (OFString *)path;
#endif
/**
* @brief Checks whether a directory exists at the specified URI.
* @brief Checks whether a directory exists at the specified IRI.
*
* @param URI The URI to check
* @return A boolean whether there is a directory at the specified URI
* @throw OFUnsupportedProtocolException No handler is registered for the URI's
* @param IRI The IRI to check
* @return A boolean whether there is a directory at the specified IRI
* @throw OFUnsupportedProtocolException No handler is registered for the IRI's
* scheme
*/
- (bool)directoryExistsAtURI: (OFURI *)URI;
- (bool)directoryExistsAtIRI: (OFIRI *)IRI;
#ifdef OF_HAVE_FILES
/**
* @brief Creates a directory at the specified path.
*
* @param path The path of the directory to create
* @throw OFCreateDirectoryFailedException Creating the directory failed
|
︙ | | |
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
|
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
|
* parents failed
*/
- (void)createDirectoryAtPath: (OFString *)path
createParents: (bool)createParents;
#endif
/**
* @brief Creates a directory at the specified URI.
* @brief Creates a directory at the specified IRI.
*
* @param URI The URI of the directory to create
* @param IRI The IRI of the directory to create
* @throw OFCreateDirectoryFailedException Creating the directory failed
* @throw OFUnsupportedProtocolException No handler is registered for the URI's
* @throw OFUnsupportedProtocolException No handler is registered for the IRI's
* scheme
*/
- (void)createDirectoryAtURI: (OFURI *)URI;
- (void)createDirectoryAtIRI: (OFIRI *)IRI;
/**
* @brief Creates a directory at the specified URI.
* @brief Creates a directory at the specified IRI.
*
* @param URI The URI of the directory to create
* @param IRI The IRI of the directory to create
* @param createParents Whether to create the parents of the directory
* @throw OFCreateDirectoryFailedException Creating the directory or one of its
* parents failed
* @throw OFUnsupportedProtocolException No handler is registered for the URI's
* @throw OFUnsupportedProtocolException No handler is registered for the IRI's
* scheme
*/
- (void)createDirectoryAtURI: (OFURI *)URI createParents: (bool)createParents;
- (void)createDirectoryAtIRI: (OFIRI *)IRI createParents: (bool)createParents;
#ifdef OF_HAVE_FILES
/**
* @brief Returns an array with the items in the specified directory.
*
* @note `.` and `..` are not part of the returned array.
*
* @param path The path to the directory whose items should be returned
* @return An array of OFString with the items in the specified directory
* @throw OFOpenItemFailedException Opening the directory failed
* @throw OFReadFailedException Reading from the directory failed
*/
- (OFArray OF_GENERIC(OFString *) *)contentsOfDirectoryAtPath: (OFString *)path;
#endif
/**
* @brief Returns an array with the URIs of the items in the specified
* @brief Returns an array with the IRIs of the items in the specified
* directory.
*
* @note `.` and `..` are not part of the returned array.
*
* @param URI The URI to the directory whose items should be returned
* @return An array with the URIs of the items in the specified directory
* @param IRI The IRI to the directory whose items should be returned
* @return An array with the IRIs of the items in the specified directory
* @throw OFOpenItemFailedException Opening the directory failed
* @throw OFReadFailedException Reading from the directory failed
* @throw OFUnsupportedProtocolException No handler is registered for the URI's
* @throw OFUnsupportedProtocolException No handler is registered for the IRI's
* scheme
*/
- (OFArray OF_GENERIC(OFURI *) *)contentsOfDirectoryAtURI: (OFURI *)URI;
- (OFArray OF_GENERIC(OFIRI *) *)contentsOfDirectoryAtIRI: (OFIRI *)IRI;
#ifdef OF_HAVE_FILES
/**
* @brief Returns an array with all subpaths of the specified directory.
*
* @note `.` and `..` (of the directory itself or any subdirectory) are not
* part of the returned array.
|
︙ | | |
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
|
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
|
-
+
-
+
|
* directory failed
*/
- (void)changeCurrentDirectoryPath: (OFString *)path;
/**
* @brief Changes the current working directory.
*
* @param URI The new directory to change to
* @param IRI The new directory to change to
* @throw OFChangeCurrentDirectoryFailedException Changing the current working
* directory failed
*/
- (void)changeCurrentDirectoryURI: (OFURI *)URI;
- (void)changeCurrentDirectoryIRI: (OFIRI *)IRI;
/**
* @brief Copies a file, directory or symbolic link (if supported by the OS).
*
* The destination path must be a full path, which means it must include the
* name of the item.
*
|
︙ | | |
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
|
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
|
-
+
-
+
-
+
-
+
|
*/
- (void)copyItemAtPath: (OFString *)source toPath: (OFString *)destination;
#endif
/**
* @brief Copies a file, directory or symbolic link (if supported by the OS).
*
* The destination URI must have a full path, which means it must include the
* The destination IRI must have a full path, which means it must include the
* name of the item.
*
* If an item already exists, the copy operation fails. This is also the case
* if a directory is copied and an item already exists in the destination
* directory.
*
* @param source The file, directory or symbolic link to copy
* @param destination The destination URI
* @param destination The destination IRI
* @throw OFCopyItemFailedException Copying failed
* @throw OFCreateDirectoryFailedException Creating a destination directory
* failed
* @throw OFUnsupportedProtocolException No handler is registered for either of
* the URI's scheme
* the IRI's scheme
*/
- (void)copyItemAtURI: (OFURI *)source toURI: (OFURI *)destination;
- (void)copyItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination;
#ifdef OF_HAVE_FILES
/**
* @brief Moves an item.
*
* The destination path must be a full path, which means it must include the
* name of the item.
|
︙ | | |
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
|
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
*/
- (void)moveItemAtPath: (OFString *)source toPath: (OFString *)destination;
#endif
/**
* @brief Moves an item.
*
* The destination URI must have a full path, which means it must include the
* The destination IRI must have a full path, which means it must include the
* name of the item.
*
* If the destination is on a different logical device or uses a different
* scheme, the source will be copied to the destination using
* @ref copyItemAtURI:toURI: and the source removed using @ref removeItemAtURI:.
* @ref copyItemAtIRI:toIRI: and the source removed using @ref removeItemAtIRI:.
*
* @param source The item to rename
* @param destination The new name for the item
* @throw OFMoveItemFailedException Moving failed
* @throw OFCopyItemFailedException Copying (to move between different devices)
* failed
* @throw OFRemoveItemFailedException Removing the source after copying to the
* destination (to move between different
* devices) failed
* @throw OFCreateDirectoryFailedException Creating a destination directory
* failed
* @throw OFUnsupportedProtocolException No handler is registered for either of
* the URI's scheme
* the IRI's scheme
*/
- (void)moveItemAtURI: (OFURI *)source toURI: (OFURI *)destination;
- (void)moveItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination;
#ifdef OF_HAVE_FILES
/**
* @brief Removes the item at the specified path.
*
* If the item at the specified path is a directory, it is removed recursively.
*
* @param path The path to the item which should be removed
* @throw OFRemoveItemFailedException Removing the item failed
*/
- (void)removeItemAtPath: (OFString *)path;
#endif
/**
* @brief Removes the item at the specified URI.
* @brief Removes the item at the specified IRI.
*
* If the item at the specified URI is a directory, it is removed recursively.
* If the item at the specified IRI is a directory, it is removed recursively.
*
* @param URI The URI to the item which should be removed
* @param IRI The IRI to the item which should be removed
* @throw OFRemoveItemFailedException Removing the item failed
* @throw OFUnsupportedProtocolException No handler is registered for the URI's
* @throw OFUnsupportedProtocolException No handler is registered for the IRI's
* scheme
*/
- (void)removeItemAtURI: (OFURI *)URI;
- (void)removeItemAtIRI: (OFIRI *)IRI;
#ifdef OF_FILE_MANAGER_SUPPORTS_LINKS
/**
* @brief Creates a hard link for the specified item.
*
* The destination path must be a full path, which means it must include the
* name of the item.
*
* This method is not available on some systems.
*
* @param source The path to the item for which a link should be created
* @param destination The path to the item which should link to the source
* @throw OFLinkItemFailedException Linking the item failed
* @throw OFNotImplementedException Hardlinks are not implemented for the
* specified URI
* specified IRI
*/
- (void)linkItemAtPath: (OFString *)source toPath: (OFString *)destination;
#endif
/**
* @brief Creates a hard link for the specified item.
*
* The destination URI must have a full path, which means it must include the
* The destination IRI must have a full path, which means it must include the
* name of the item.
*
* This method is not available for all URIs.
* This method is not available for all IRIs.
*
* @param source The URI to the item for which a link should be created
* @param destination The URI to the item which should link to the source
* @param source The IRI to the item for which a link should be created
* @param destination The IRI to the item which should link to the source
* @throw OFLinkItemFailedException Linking the item failed
* @throw OFUnsupportedProtocolException No handler is registered for the URI's
* @throw OFUnsupportedProtocolException No handler is registered for the IRI's
* scheme
* @throw OFNotImplementedException Hardlinks are not implemented for the
* specified URI
* specified IRI
*/
- (void)linkItemAtURI: (OFURI *)source toURI: (OFURI *)destination;
- (void)linkItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination;
#ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS
/**
* @brief Creates a symbolic link for an item.
*
* The destination path must be a full path, which means it must include the
* name of the item.
*
* This method is not available on some systems.
*
* @note On Windows, this requires at least Windows Vista and administrator
* privileges!
*
* @param path The path to the item which should symbolically link to the target
* @param target The target of the symbolic link
* @throw OFCreateSymbolicLinkFailedException Creating the symbolic link failed
* @throw OFNotImplementedException Symbolic links are not implemented for the
* specified URI
* specified IRI
*/
- (void)createSymbolicLinkAtPath: (OFString *)path
withDestinationPath: (OFString *)target;
#endif
/**
* @brief Creates a symbolic link for an item.
*
* The destination URI must have a full path, which means it must include the
* The destination IRI must have a full path, which means it must include the
* name of the item.
*
* This method is not available for all URIs.
* This method is not available for all IRIs.
*
* @note On Windows, this requires at least Windows Vista and administrator
* privileges!
* @note For file IRIs on Windows, this requires at least Windows Vista and
* administrator privileges!
*
* @param URI The URI to the item which should symbolically link to the target
* @param IRI The IRI to the item which should symbolically link to the target
* @param target The target of the symbolic link
* @throw OFOFCreateSymbolicLinkFailedException Creating a symbolic link failed
* @throw OFUnsupportedProtocolException No handler is registered for the URI's
* @throw OFUnsupportedProtocolException No handler is registered for the IRI's
* scheme
*/
- (void)createSymbolicLinkAtURI: (OFURI *)URI
- (void)createSymbolicLinkAtIRI: (OFIRI *)IRI
withDestinationPath: (OFString *)target;
#ifdef OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES
/**
* @brief Returns the extended attribute data for the specified name of the
* item at the specified path.
*
* This method is not available on some systems.
*
* @param name The name of the extended attribute
* @param path The path of the item to return the extended attribute from
* @throw OFGetItemAttributesFailedException Getting the extended attribute
* failed
* @throw OFNotImplementedException Getting extended attributes is not
* implemented for the specified item
*/
- (OFData *)extendedAttributeDataForName: (OFString *)name
ofItemAtPath: (OFString *)path;
#endif
/**
* @brief Returns the extended attribute data for the specified name of the
* item at the specified IRI.
*
* This method is not available for all IRIs.
*
* @param name The name of the extended attribute
* @param IRI The IRI of the item to return the extended attribute from
* @throw OFGetItemAttributesFailedException Getting the extended attribute
* failed
* @throw OFUnsupportedProtocolException No handler is registered for the IRI's
* scheme
* @throw OFNotImplementedException Getting extended attributes is not
* implemented for the specified item
*/
- (OFData *)extendedAttributeDataForName: (OFString *)name
ofItemAtIRI: (OFIRI *)IRI;
#ifdef OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES
/**
* @brief Sets the extended attribute data for the specified name of the item
* at the specified path.
*
* This method is not available on some systems.
*
* @param data The data for the extended attribute
* @param name The name of the extended attribute
* @param path The path of the item to set the extended attribute on
* @throw OFSetItemAttributesFailedException Setting the extended attribute
* failed
* @throw OFNotImplementedException Setting extended attributes is not
* implemented for the specified item
*/
- (void)setExtendedAttributeData: (OFData *)data
forName: (OFString *)name
ofItemAtPath: (OFString *)path;
#endif
/**
* @brief Sets the extended attribute data for the specified name of the item
* at the specified IRI.
*
* This method is not available for all IRIs.
*
* @param data The data for the extended attribute
* @param name The name of the extended attribute
* @param IRI The IRI of the item to set the extended attribute on
* @throw OFSetItemAttributesFailedException Setting the extended attribute
* failed
* @throw OFUnsupportedProtocolException No handler is registered for the IRI's
* scheme
* @throw OFNotImplementedException Setting extended attributes is not
* implemented for the specified item
*/
- (void)setExtendedAttributeData: (OFData *)data
forName: (OFString *)name
ofItemAtIRI: (OFIRI *)IRI;
#ifdef OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES
/**
* @brief Removes the extended attribute for the specified name wof the item at
* the specified path.
*
* This method is not available on some systems.
*
* @param name The name of the extended attribute to remove
* @param path The path of the item to remove the extended attribute from
* @throw OFSetItemAttributesFailedException Removing the extended attribute
* failed
* @throw OFNotImplementedException Removing extended attributes is not
* implemented for the specified item
*/
- (void)removeExtendedAttributeForName: (OFString *)name
ofItemAtPath: (OFString *)path;
#endif
/**
* @brief Removes the extended attribute for the specified name wof the item at
* the specified IRI.
*
* This method is not available for all IRIs.
*
* @param name The name of the extended attribute to remove
* @param IRI The IRI of the item to remove the extended attribute from
* @throw OFSetItemAttributesFailedException Removing the extended attribute
* failed
* @throw OFUnsupportedProtocolException No handler is registered for the IRI's
* scheme
* @throw OFNotImplementedException Removing extended attributes is not
* implemented for the specified item
*/
- (void)removeExtendedAttributeForName: (OFString *)name
ofItemAtIRI: (OFIRI *)IRI;
@end
@interface OFDictionary (FileAttributes)
/**
* @brief The @ref OFFileSize key from the dictionary.
*
* @throw OFUndefinedKeyException The key is missing
|
︙ | | |
751
752
753
754
755
756
757
758
759
760
|
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
|
+
+
+
+
+
+
+
+
|
/**
* @brief The @ref OFFileSymbolicLinkDestination key from the dictionary.
*
* @throw OFUndefinedKeyException The key is missing
*/
@property (readonly, nonatomic) OFString *fileSymbolicLinkDestination;
/**
* @brief The @ref OFFileExtendedAttributesNames key from the dictionary.
*
* @throw OFUndefinedKeyException The key is missing
*/
@property (readonly, nonatomic)
OFArray OF_GENERIC(OFString *) *fileExtendedAttributesNames;
@end
OF_ASSUME_NONNULL_END
|
Modified src/OFFileManager.m
from [5dfeac045a]
to [c425786752].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
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
|
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
|
+
+
+
+
+
+
-
-
|
#include <errno.h>
#include <limits.h>
#include "unistd_wrapper.h"
#include "platform.h"
#ifdef OF_DJGPP
# include <syslimits.h>
#endif
#ifdef OF_PSP
# include <sys/syslimits.h>
#endif
#import "OFArray.h"
#import "OFData.h"
#import "OFDate.h"
#import "OFDictionary.h"
#ifdef OF_HAVE_FILES
# import "OFFile.h"
#endif
#import "OFFileManager.h"
#import "OFIRI.h"
#import "OFIRIHandler.h"
#import "OFLocale.h"
#import "OFNumber.h"
#import "OFStream.h"
#import "OFString.h"
#import "OFSystemInfo.h"
#import "OFURI.h"
#import "OFURIHandler.h"
#import "OFChangeCurrentDirectoryFailedException.h"
#import "OFCopyItemFailedException.h"
#import "OFCreateDirectoryFailedException.h"
#import "OFGetCurrentDirectoryFailedException.h"
#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
|
︙ | | |
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
+
+
|
#ifdef OF_WINDOWS
# include <windows.h>
# include <direct.h>
# include <ntdef.h>
#endif
#ifdef OF_AMIGAOS
# define Class IntuitionClass
# include <proto/exec.h>
# include <proto/dos.h>
# undef Class
#endif
#ifdef OF_MINT
# include <bits/local_lim.h>
#endif
@interface OFDefaultFileManager: OFFileManager
|
︙ | | |
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
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
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
@throw [OFOutOfRangeException exception];
return nil;
}
return [OFString stringWithCString: buffer
encoding: [OFLocale encoding]];
# elif defined(OF_GLIBC)
char *buffer;
OFString *path;
if ((buffer = getcwd(NULL, 0)) == NULL)
@throw [OFGetCurrentDirectoryFailedException
exceptionWithErrNo: errno];
@try {
path = [OFString stringWithCString: buffer
encoding: [OFLocale encoding]];
} @finally {
free(buffer);
}
return path;
# else
char buffer[PATH_MAX];
if ((getcwd(buffer, PATH_MAX)) == NULL)
@throw [OFGetCurrentDirectoryFailedException
exceptionWithErrNo: errno];
|
︙ | | |
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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
|
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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
|
-
+
-
+
-
+
+
-
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
-
-
+
+
+
+
-
+
-
-
-
+
+
+
-
-
-
-
+
+
+
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
-
+
+
-
+
|
# endif
return [OFString stringWithCString: buffer
encoding: [OFLocale encoding]];
# endif
}
- (OFURI *)currentDirectoryURI
- (OFIRI *)currentDirectoryIRI
{
void *pool = objc_autoreleasePoolPush();
OFURI *ret;
OFIRI *ret;
ret = [OFURI fileURIWithPath: self.currentDirectoryPath];
ret = [OFIRI fileIRIWithPath: self.currentDirectoryPath];
ret = [ret retain];
[ret retain];
objc_autoreleasePoolPop(pool);
return [ret autorelease];
}
#endif
- (OFFileAttributes)attributesOfItemAtURI: (OFURI *)URI
- (OFFileAttributes)attributesOfItemAtIRI: (OFIRI *)IRI
{
OFURIHandler *URIHandler;
OFIRIHandler *IRIHandler;
if (URI == nil)
if (IRI == nil)
@throw [OFInvalidArgumentException exception];
if ((URIHandler = [OFURIHandler handlerForURI: URI]) == nil)
@throw [OFUnsupportedProtocolException exceptionWithURI: URI];
if ((IRIHandler = [OFIRIHandler handlerForIRI: IRI]) == nil)
@throw [OFUnsupportedProtocolException exceptionWithIRI: IRI];
return [URIHandler attributesOfItemAtURI: URI];
return [IRIHandler attributesOfItemAtIRI: IRI];
}
#ifdef OF_HAVE_FILES
- (OFFileAttributes)attributesOfItemAtPath: (OFString *)path
{
void *pool = objc_autoreleasePoolPush();
OFFileAttributes ret;
ret = [self attributesOfItemAtURI: [OFURI fileURIWithPath: path]];
ret = [self attributesOfItemAtIRI: [OFIRI fileIRIWithPath: path]];
[ret retain];
ret = [ret retain];
objc_autoreleasePoolPop(pool);
return [ret autorelease];
}
#endif
- (void)setAttributes: (OFFileAttributes)attributes ofItemAtURI: (OFURI *)URI
- (void)setAttributes: (OFFileAttributes)attributes ofItemAtIRI: (OFIRI *)IRI
{
OFURIHandler *URIHandler;
OFIRIHandler *IRIHandler;
if (URI == nil)
if (IRI == nil)
@throw [OFInvalidArgumentException exception];
if ((URIHandler = [OFURIHandler handlerForURI: URI]) == nil)
@throw [OFUnsupportedProtocolException exceptionWithURI: URI];
if ((IRIHandler = [OFIRIHandler handlerForIRI: IRI]) == nil)
@throw [OFUnsupportedProtocolException exceptionWithIRI: IRI];
[URIHandler setAttributes: attributes ofItemAtURI: URI];
[IRIHandler setAttributes: attributes ofItemAtIRI: IRI];
}
#ifdef OF_HAVE_FILES
- (void)setAttributes: (OFFileAttributes)attributes
ofItemAtPath: (OFString *)path
{
void *pool = objc_autoreleasePoolPush();
[self setAttributes: attributes
ofItemAtURI: [OFURI fileURIWithPath: path]];
ofItemAtIRI: [OFIRI fileIRIWithPath: path]];
objc_autoreleasePoolPop(pool);
}
#endif
- (bool)fileExistsAtURI: (OFURI *)URI
- (bool)fileExistsAtIRI: (OFIRI *)IRI
{
OFURIHandler *URIHandler;
OFIRIHandler *IRIHandler;
if (URI == nil)
if (IRI == nil)
@throw [OFInvalidArgumentException exception];
if ((URIHandler = [OFURIHandler handlerForURI: URI]) == nil)
@throw [OFUnsupportedProtocolException exceptionWithURI: URI];
if ((IRIHandler = [OFIRIHandler handlerForIRI: IRI]) == nil)
@throw [OFUnsupportedProtocolException exceptionWithIRI: IRI];
return [URIHandler fileExistsAtURI: URI];
return [IRIHandler fileExistsAtIRI: IRI];
}
#ifdef OF_HAVE_FILES
- (bool)fileExistsAtPath: (OFString *)path
{
void *pool = objc_autoreleasePoolPush();
bool ret;
ret = [self fileExistsAtURI: [OFURI fileURIWithPath: path]];
ret = [self fileExistsAtIRI: [OFIRI fileIRIWithPath: path]];
objc_autoreleasePoolPop(pool);
return ret;
}
#endif
- (bool)directoryExistsAtURI: (OFURI *)URI
- (bool)directoryExistsAtIRI: (OFIRI *)IRI
{
OFURIHandler *URIHandler;
OFIRIHandler *IRIHandler;
if (URI == nil)
if (IRI == nil)
@throw [OFInvalidArgumentException exception];
if ((URIHandler = [OFURIHandler handlerForURI: URI]) == nil)
@throw [OFUnsupportedProtocolException exceptionWithURI: URI];
if ((IRIHandler = [OFIRIHandler handlerForIRI: IRI]) == nil)
@throw [OFUnsupportedProtocolException exceptionWithIRI: IRI];
return [URIHandler directoryExistsAtURI: URI];
return [IRIHandler directoryExistsAtIRI: IRI];
}
#ifdef OF_HAVE_FILES
- (bool)directoryExistsAtPath: (OFString *)path
{
void *pool = objc_autoreleasePoolPush();
bool ret;
ret = [self directoryExistsAtURI: [OFURI fileURIWithPath: path]];
ret = [self directoryExistsAtIRI: [OFIRI fileIRIWithPath: path]];
objc_autoreleasePoolPop(pool);
return ret;
}
#endif
- (void)createDirectoryAtURI: (OFURI *)URI
- (void)createDirectoryAtIRI: (OFIRI *)IRI
{
OFURIHandler *URIHandler;
OFIRIHandler *IRIHandler;
if (URI == nil)
if (IRI == nil)
@throw [OFInvalidArgumentException exception];
if ((URIHandler = [OFURIHandler handlerForURI: URI]) == nil)
@throw [OFUnsupportedProtocolException exceptionWithURI: URI];
if ((IRIHandler = [OFIRIHandler handlerForIRI: IRI]) == nil)
@throw [OFUnsupportedProtocolException exceptionWithIRI: IRI];
[URIHandler createDirectoryAtURI: URI];
[IRIHandler createDirectoryAtIRI: IRI];
}
- (void)createDirectoryAtURI: (OFURI *)URI createParents: (bool)createParents
- (void)createDirectoryAtIRI: (OFIRI *)IRI createParents: (bool)createParents
{
void *pool = objc_autoreleasePoolPush();
OFMutableURI *mutableURI;
OFMutableIRI *mutableIRI;
OFArray OF_GENERIC(OFString *) *components;
OFMutableArray OF_GENERIC(OFURI *) *componentURIs;
size_t componentURIsCount;
OFMutableArray OF_GENERIC(OFIRI *) *componentIRIs;
size_t componentIRIsCount;
ssize_t i;
if (URI == nil)
if (IRI == nil)
@throw [OFInvalidArgumentException exception];
if (!createParents) {
[self createDirectoryAtURI: URI];
[self createDirectoryAtIRI: IRI];
return;
}
/*
* Try blindly creating the directory first.
*
* The reason for this is that we might be sandboxed, so attempting to
* create any of the parent directories will fail, while creating the
* directory itself will work.
*/
if ([self directoryExistsAtURI: URI])
if ([self directoryExistsAtIRI: IRI])
return;
@try {
[self createDirectoryAtURI: URI];
[self createDirectoryAtIRI: IRI];
return;
} @catch (OFCreateDirectoryFailedException *e) {
/*
* If we didn't fail because any of the parents is missing,
* there is no point in trying to create the parents.
*/
if (e.errNo != ENOENT)
@throw e;
}
/*
* Because we might be sandboxed (and for remote URIs don't even know
* anything at all), we generate the URI for every component. We then
* Because we might be sandboxed (and for remote IRIs don't even know
* anything at all), we generate the IRI for every component. We then
* iterate them in reverse order until we find the first existing
* directory, and then create subdirectories from there.
*/
mutableURI = [[URI mutableCopy] autorelease];
mutableURI.percentEncodedPath = @"/";
components = URI.pathComponents;
componentURIs = [OFMutableArray arrayWithCapacity: components.count];
mutableIRI = [[IRI mutableCopy] autorelease];
mutableIRI.percentEncodedPath = @"/";
components = IRI.pathComponents;
componentIRIs = [OFMutableArray arrayWithCapacity: components.count];
for (OFString *component in components) {
[mutableURI appendPathComponent: component];
[mutableIRI appendPathComponent: component];
if (![mutableURI.percentEncodedPath isEqual: @"/"])
[componentURIs addObject:
[[mutableURI copy] autorelease]];
if (![mutableIRI.percentEncodedPath isEqual: @"/"])
[componentIRIs addObject:
[[mutableIRI copy] autorelease]];
}
componentURIsCount = componentURIs.count;
for (i = componentURIsCount - 1; i > 0; i--) {
if ([self directoryExistsAtURI:
[componentURIs objectAtIndex: i]])
componentIRIsCount = componentIRIs.count;
for (i = componentIRIsCount - 1; i > 0; i--) {
if ([self directoryExistsAtIRI:
[componentIRIs objectAtIndex: i]])
break;
}
if (++i == (ssize_t)componentURIsCount) {
if (++i == (ssize_t)componentIRIsCount) {
/*
* The URI exists, even though before we made sure it did not.
* The IRI exists, even though before we made sure it did not.
* That means it was created in the meantime by something else,
* so we're done here.
*/
objc_autoreleasePoolPop(pool);
return;
}
for (; i < (ssize_t)componentURIsCount; i++)
[self createDirectoryAtURI: [componentURIs objectAtIndex: i]];
for (; i < (ssize_t)componentIRIsCount; i++)
[self createDirectoryAtIRI: [componentIRIs objectAtIndex: i]];
objc_autoreleasePoolPop(pool);
}
#ifdef OF_HAVE_FILES
- (void)createDirectoryAtPath: (OFString *)path
{
void *pool = objc_autoreleasePoolPush();
[self createDirectoryAtURI: [OFURI fileURIWithPath: path]];
[self createDirectoryAtIRI: [OFIRI fileIRIWithPath: path]];
objc_autoreleasePoolPop(pool);
}
- (void)createDirectoryAtPath: (OFString *)path
createParents: (bool)createParents
{
void *pool = objc_autoreleasePoolPush();
[self createDirectoryAtURI: [OFURI fileURIWithPath: path]
[self createDirectoryAtIRI: [OFIRI fileIRIWithPath: path]
createParents: createParents];
objc_autoreleasePoolPop(pool);
}
#endif
- (OFArray OF_GENERIC(OFURI *) *)contentsOfDirectoryAtURI: (OFURI *)URI
- (OFArray OF_GENERIC(OFIRI *) *)contentsOfDirectoryAtIRI: (OFIRI *)IRI
{
OFURIHandler *URIHandler;
OFIRIHandler *IRIHandler;
if (URI == nil)
if (IRI == nil)
@throw [OFInvalidArgumentException exception];
if ((URIHandler = [OFURIHandler handlerForURI: URI]) == nil)
@throw [OFUnsupportedProtocolException exceptionWithURI: URI];
if ((IRIHandler = [OFIRIHandler handlerForIRI: IRI]) == nil)
@throw [OFUnsupportedProtocolException exceptionWithIRI: IRI];
return [URIHandler contentsOfDirectoryAtURI: URI];
return [IRIHandler contentsOfDirectoryAtIRI: IRI];
}
#ifdef OF_HAVE_FILES
- (OFArray OF_GENERIC(OFString *) *)contentsOfDirectoryAtPath: (OFString *)path
{
void *pool = objc_autoreleasePoolPush();
OFArray OF_GENERIC(OFURI *) *URIs;
OFArray OF_GENERIC(OFIRI *) *IRIs;
OFMutableArray OF_GENERIC(OFString *) *ret;
URIs = [self contentsOfDirectoryAtURI: [OFURI fileURIWithPath: path]];
ret = [OFMutableArray arrayWithCapacity: URIs.count];
IRIs = [self contentsOfDirectoryAtIRI: [OFIRI fileIRIWithPath: path]];
ret = [OFMutableArray arrayWithCapacity: IRIs.count];
for (OFURI *URI in URIs)
[ret addObject: URI.lastPathComponent];
for (OFIRI *IRI in IRIs)
[ret addObject: IRI.lastPathComponent];
[ret makeImmutable];
[ret retain];
ret = [ret retain];
objc_autoreleasePoolPop(pool);
return [ret autorelease];
}
- (OFArray OF_GENERIC(OFString *) *)subpathsOfDirectoryAtPath: (OFString *)path
|
︙ | | |
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
|
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
|
-
+
|
else
[ret addObject: fullSubpath];
objc_autoreleasePoolPop(pool2);
}
[ret makeImmutable];
[ret retain];
ret = [ret retain];
objc_autoreleasePoolPop(pool);
return [ret autorelease];
}
- (void)changeCurrentDirectoryPath: (OFString *)path
|
︙ | | |
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
|
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
|
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
|
if (status != 0)
@throw [OFChangeCurrentDirectoryFailedException
exceptionWithPath: path
errNo: errno];
# endif
}
- (void)changeCurrentDirectoryURI: (OFURI *)URI
- (void)changeCurrentDirectoryIRI: (OFIRI *)IRI
{
void *pool = objc_autoreleasePoolPush();
[self changeCurrentDirectoryPath: URI.fileSystemRepresentation];
[self changeCurrentDirectoryPath: IRI.fileSystemRepresentation];
objc_autoreleasePoolPop(pool);
}
- (void)copyItemAtPath: (OFString *)source toPath: (OFString *)destination
{
void *pool = objc_autoreleasePoolPush();
[self copyItemAtURI: [OFURI fileURIWithPath: source]
toURI: [OFURI fileURIWithPath: destination]];
[self copyItemAtIRI: [OFIRI fileIRIWithPath: source]
toIRI: [OFIRI fileIRIWithPath: destination]];
objc_autoreleasePoolPop(pool);
}
#endif
- (void)copyItemAtURI: (OFURI *)source toURI: (OFURI *)destination
- (void)copyItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination
{
void *pool;
OFURIHandler *URIHandler;
OFIRIHandler *IRIHandler;
OFFileAttributes attributes;
OFFileAttributeType type;
if (source == nil || destination == nil)
@throw [OFInvalidArgumentException exception];
pool = objc_autoreleasePoolPush();
if ((URIHandler = [OFURIHandler handlerForURI: source]) == nil)
if ((IRIHandler = [OFIRIHandler handlerForIRI: source]) == nil)
@throw [OFUnsupportedProtocolException
exceptionWithURI: source];
exceptionWithIRI: source];
if ([URIHandler copyItemAtURI: source toURI: destination])
if ([IRIHandler copyItemAtIRI: source toIRI: destination])
return;
if ([self fileExistsAtURI: destination])
if ([self fileExistsAtIRI: destination])
@throw [OFCopyItemFailedException
exceptionWithSourceURI: source
destinationURI: destination
exceptionWithSourceIRI: source
destinationIRI: destination
errNo: EEXIST];
@try {
attributes = [self attributesOfItemAtURI: source];
attributes = [self attributesOfItemAtIRI: source];
} @catch (OFGetItemAttributesFailedException *e) {
@throw [OFCopyItemFailedException
exceptionWithSourceURI: source
destinationURI: destination
exceptionWithSourceIRI: source
destinationIRI: destination
errNo: e.errNo];
}
type = attributes.fileType;
if ([type isEqual: OFFileTypeDirectory]) {
OFArray OF_GENERIC(OFURI *) *contents;
OFArray OF_GENERIC(OFIRI *) *contents;
@try {
[self createDirectoryAtURI: destination];
[self createDirectoryAtIRI: destination];
@try {
OFFileAttributeKey key = OFFilePOSIXPermissions;
OFNumber *permissions =
[attributes objectForKey: key];
OFFileAttributes destinationAttributes;
if (permissions != nil) {
destinationAttributes = [OFDictionary
dictionaryWithObject: permissions
forKey: key];
[self
setAttributes: destinationAttributes
ofItemAtURI: destination];
ofItemAtIRI: destination];
}
} @catch (OFNotImplementedException *e) {
}
contents = [self contentsOfDirectoryAtURI: source];
contents = [self contentsOfDirectoryAtIRI: source];
} @catch (id e) {
/*
* Only convert exceptions to OFCopyItemFailedException
* that have an errNo property. This covers all I/O
* related exceptions from the operations used to copy
* an item, all others should be left as is.
*/
if ([e respondsToSelector: @selector(errNo)])
@throw [OFCopyItemFailedException
exceptionWithSourceURI: source
destinationURI: destination
exceptionWithSourceIRI: source
destinationIRI: destination
errNo: [e errNo]];
@throw e;
}
for (OFURI *item in contents) {
for (OFIRI *item in contents) {
void *pool2 = objc_autoreleasePoolPush();
OFURI *destinationURI = [destination
URIByAppendingPathComponent:
OFIRI *destinationIRI = [destination
IRIByAppendingPathComponent:
item.lastPathComponent];
[self copyItemAtURI: item toURI: destinationURI];
[self copyItemAtIRI: item toIRI: destinationIRI];
objc_autoreleasePoolPop(pool2);
}
} else if ([type isEqual: OFFileTypeRegular]) {
size_t pageSize = [OFSystemInfo pageSize];
OFStream *sourceStream = nil;
OFStream *destinationStream = nil;
char *buffer;
buffer = OFAllocMemory(1, pageSize);
@try {
sourceStream = [OFURIHandler openItemAtURI: source
sourceStream = [OFIRIHandler openItemAtIRI: source
mode: @"r"];
destinationStream = [OFURIHandler
openItemAtURI: destination
destinationStream = [OFIRIHandler
openItemAtIRI: destination
mode: @"w"];
while (!sourceStream.atEndOfStream) {
size_t length;
length = [sourceStream
readIntoBuffer: buffer
|
︙ | | |
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
|
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
|
-
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
if (permissions != nil) {
destinationAttributes = [OFDictionary
dictionaryWithObject: permissions
forKey: key];
[self
setAttributes: destinationAttributes
ofItemAtURI: destination];
ofItemAtIRI: destination];
}
} @catch (OFNotImplementedException *e) {
}
} @catch (id e) {
/*
* Only convert exceptions to OFCopyItemFailedException
* that have an errNo property. This covers all I/O
* related exceptions from the operations used to copy
* an item, all others should be left as is.
*/
if ([e respondsToSelector: @selector(errNo)])
@throw [OFCopyItemFailedException
exceptionWithSourceURI: source
destinationURI: destination
exceptionWithSourceIRI: source
destinationIRI: destination
errNo: [e errNo]];
@throw e;
} @finally {
[sourceStream close];
[destinationStream close];
OFFreeMemory(buffer);
}
} else if ([type isEqual: OFFileTypeSymbolicLink]) {
@try {
OFString *linkDestination =
attributes.fileSymbolicLinkDestination;
[self createSymbolicLinkAtURI: destination
[self createSymbolicLinkAtIRI: destination
withDestinationPath: linkDestination];
} @catch (id e) {
/*
* Only convert exceptions to OFCopyItemFailedException
* that have an errNo property. This covers all I/O
* related exceptions from the operations used to copy
* an item, all others should be left as is.
*/
if ([e respondsToSelector: @selector(errNo)])
@throw [OFCopyItemFailedException
exceptionWithSourceURI: source
destinationURI: destination
exceptionWithSourceIRI: source
destinationIRI: destination
errNo: [e errNo]];
@throw e;
}
} else
@throw [OFCopyItemFailedException
exceptionWithSourceURI: source
destinationURI: destination
exceptionWithSourceIRI: source
destinationIRI: destination
errNo: EINVAL];
objc_autoreleasePoolPop(pool);
}
#ifdef OF_HAVE_FILES
- (void)moveItemAtPath: (OFString *)source toPath: (OFString *)destination
{
void *pool = objc_autoreleasePoolPush();
[self moveItemAtURI: [OFURI fileURIWithPath: source]
toURI: [OFURI fileURIWithPath: destination]];
[self moveItemAtIRI: [OFIRI fileIRIWithPath: source]
toIRI: [OFIRI fileIRIWithPath: destination]];
objc_autoreleasePoolPop(pool);
}
#endif
- (void)moveItemAtURI: (OFURI *)source toURI: (OFURI *)destination
- (void)moveItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination
{
void *pool;
OFURIHandler *URIHandler;
OFIRIHandler *IRIHandler;
if (source == nil || destination == nil)
@throw [OFInvalidArgumentException exception];
pool = objc_autoreleasePoolPush();
if ((URIHandler = [OFURIHandler handlerForURI: source]) == nil)
if ((IRIHandler = [OFIRIHandler handlerForIRI: source]) == nil)
@throw [OFUnsupportedProtocolException
exceptionWithURI: source];
exceptionWithIRI: source];
@try {
if ([URIHandler moveItemAtURI: source toURI: destination])
if ([IRIHandler moveItemAtIRI: source toIRI: destination])
return;
} @catch (OFMoveItemFailedException *e) {
if (e.errNo != EXDEV)
@throw e;
}
if ([self fileExistsAtURI: destination])
if ([self fileExistsAtIRI: destination])
@throw [OFMoveItemFailedException
exceptionWithSourceURI: source
destinationURI: destination
exceptionWithSourceIRI: source
destinationIRI: destination
errNo: EEXIST];
@try {
[self copyItemAtURI: source toURI: destination];
[self copyItemAtIRI: source toIRI: destination];
} @catch (OFCopyItemFailedException *e) {
[self removeItemAtURI: destination];
[self removeItemAtIRI: destination];
@throw [OFMoveItemFailedException
exceptionWithSourceURI: source
destinationURI: destination
exceptionWithSourceIRI: source
destinationIRI: destination
errNo: e.errNo];
}
@try {
[self removeItemAtURI: source];
[self removeItemAtIRI: source];
} @catch (OFRemoveItemFailedException *e) {
@throw [OFMoveItemFailedException
exceptionWithSourceURI: source
destinationURI: destination
exceptionWithSourceIRI: source
destinationIRI: destination
errNo: e.errNo];
}
objc_autoreleasePoolPop(pool);
}
- (void)removeItemAtURI: (OFURI *)URI
- (void)removeItemAtIRI: (OFIRI *)IRI
{
OFURIHandler *URIHandler;
OFIRIHandler *IRIHandler;
if (URI == nil)
if (IRI == nil)
@throw [OFInvalidArgumentException exception];
if ((URIHandler = [OFURIHandler handlerForURI: URI]) == nil)
@throw [OFUnsupportedProtocolException exceptionWithURI: URI];
if ((IRIHandler = [OFIRIHandler handlerForIRI: IRI]) == nil)
@throw [OFUnsupportedProtocolException exceptionWithIRI: IRI];
[URIHandler removeItemAtURI: URI];
[IRIHandler removeItemAtIRI: IRI];
}
#ifdef OF_HAVE_FILES
- (void)removeItemAtPath: (OFString *)path
{
void *pool = objc_autoreleasePoolPush();
[self removeItemAtURI: [OFURI fileURIWithPath: path]];
[self removeItemAtIRI: [OFIRI fileIRIWithPath: path]];
objc_autoreleasePoolPop(pool);
}
#endif
- (void)linkItemAtURI: (OFURI *)source toURI: (OFURI *)destination
- (void)linkItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination
{
void *pool = objc_autoreleasePoolPush();
OFURIHandler *URIHandler;
OFIRIHandler *IRIHandler;
if (source == nil || destination == nil)
@throw [OFInvalidArgumentException exception];
if (![destination.scheme isEqual: source.scheme])
@throw [OFInvalidArgumentException exception];
URIHandler = [OFURIHandler handlerForURI: source];
IRIHandler = [OFIRIHandler handlerForIRI: source];
if (URIHandler == nil)
if (IRIHandler == nil)
@throw [OFUnsupportedProtocolException
exceptionWithURI: source];
exceptionWithIRI: source];
[URIHandler linkItemAtURI: source toURI: destination];
[IRIHandler linkItemAtIRI: source toIRI: destination];
objc_autoreleasePoolPop(pool);
}
#ifdef OF_FILE_MANAGER_SUPPORTS_LINKS
- (void)linkItemAtPath: (OFString *)source toPath: (OFString *)destination
{
void *pool = objc_autoreleasePoolPush();
[self linkItemAtURI: [OFURI fileURIWithPath: source]
toURI: [OFURI fileURIWithPath: destination]];
[self linkItemAtIRI: [OFIRI fileIRIWithPath: source]
toIRI: [OFIRI fileIRIWithPath: destination]];
objc_autoreleasePoolPop(pool);
}
#endif
- (void)createSymbolicLinkAtURI: (OFURI *)URI
- (void)createSymbolicLinkAtIRI: (OFIRI *)IRI
withDestinationPath: (OFString *)target
{
void *pool = objc_autoreleasePoolPush();
OFURIHandler *URIHandler;
OFIRIHandler *IRIHandler;
if (URI == nil || target == nil)
if (IRI == nil || target == nil)
@throw [OFInvalidArgumentException exception];
URIHandler = [OFURIHandler handlerForURI: URI];
IRIHandler = [OFIRIHandler handlerForIRI: IRI];
if (URIHandler == nil)
@throw [OFUnsupportedProtocolException exceptionWithURI: URI];
if (IRIHandler == nil)
@throw [OFUnsupportedProtocolException exceptionWithIRI: IRI];
[URIHandler createSymbolicLinkAtURI: URI withDestinationPath: target];
[IRIHandler createSymbolicLinkAtIRI: IRI withDestinationPath: target];
objc_autoreleasePoolPop(pool);
}
#ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS
- (void)createSymbolicLinkAtPath: (OFString *)path
withDestinationPath: (OFString *)target
{
void *pool = objc_autoreleasePoolPush();
[self createSymbolicLinkAtURI: [OFURI fileURIWithPath: path]
[self createSymbolicLinkAtIRI: [OFIRI fileIRIWithPath: path]
withDestinationPath: target];
objc_autoreleasePoolPop(pool);
}
#endif
- (OFData *)extendedAttributeDataForName: (OFString *)name
ofItemAtIRI: (OFIRI *)IRI
{
OFIRIHandler *IRIHandler;
if (IRI == nil)
@throw [OFInvalidArgumentException exception];
if ((IRIHandler = [OFIRIHandler handlerForIRI: IRI]) == nil)
@throw [OFUnsupportedProtocolException exceptionWithIRI: IRI];
return [IRIHandler extendedAttributeDataForName: name ofItemAtIRI: IRI];
}
#ifdef OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES
- (OFData *)extendedAttributeDataForName: (OFString *)name
ofItemAtPath: (OFString *)path
{
void *pool = objc_autoreleasePoolPush();
OFData *ret;
ret = [self
extendedAttributeDataForName: name
ofItemAtIRI: [OFIRI fileIRIWithPath: path]];
ret = [ret retain];
objc_autoreleasePoolPop(pool);
return [ret autorelease];
}
#endif
- (void)setExtendedAttributeData: (OFData *)data
forName: (OFString *)name
ofItemAtIRI: (OFIRI *)IRI
{
OFIRIHandler *IRIHandler;
if (IRI == nil)
@throw [OFInvalidArgumentException exception];
if ((IRIHandler = [OFIRIHandler handlerForIRI: IRI]) == nil)
@throw [OFUnsupportedProtocolException exceptionWithIRI: IRI];
[IRIHandler setExtendedAttributeData: data
forName: name
ofItemAtIRI: IRI];
}
#ifdef OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES
- (void)setExtendedAttributeData: (OFData *)data
forName: (OFString *)name
ofItemAtPath: (OFString *)path
{
void *pool = objc_autoreleasePoolPush();
[self setExtendedAttributeData: data
forName: name
ofItemAtIRI: [OFIRI fileIRIWithPath: path]];
objc_autoreleasePoolPop(pool);
}
#endif
- (void)removeExtendedAttributeForName: (OFString *)name
ofItemAtIRI: (OFIRI *)IRI
{
OFIRIHandler *IRIHandler;
if (IRI == nil)
@throw [OFInvalidArgumentException exception];
if ((IRIHandler = [OFIRIHandler handlerForIRI: IRI]) == nil)
@throw [OFUnsupportedProtocolException exceptionWithIRI: IRI];
[IRIHandler removeExtendedAttributeForName: name ofItemAtIRI: IRI];
}
#ifdef OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES
- (void)removeExtendedAttributeForName: (OFString *)name
ofItemAtPath: (OFString *)path
{
void *pool = objc_autoreleasePoolPush();
[self removeExtendedAttributeForName: name
ofItemAtIRI: [OFIRI fileIRIWithPath: path]];
objc_autoreleasePoolPop(pool);
}
#endif
@end
@implementation OFDefaultFileManager
- (instancetype)autorelease
{
return self;
}
|
︙ | | |
968
969
970
971
972
973
974
975
|
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
|
+
+
+
+
+
|
return attributeForKeyOrException(self, OFFileCreationDate);
}
- (OFString *)fileSymbolicLinkDestination
{
return attributeForKeyOrException(self, OFFileSymbolicLinkDestination);
}
- (OFArray OF_GENERIC(OFString *) *)fileExtendedAttributesNames
{
return attributeForKeyOrException(self, OFFileExtendedAttributesNames);
}
@end
|
Modified src/OFFileManagerConstants.inc
from [7a3eb9bf4f]
to [9aaf7f17d6].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
+
+
|
@"OFFileGroupOwnerAccountName";
const OFFileAttributeKey OFFileLastAccessDate = @"OFFileLastAccessDate";
const OFFileAttributeKey OFFileModificationDate = @"OFFileModificationDate";
const OFFileAttributeKey OFFileStatusChangeDate = @"OFFileStatusChangeDate";
const OFFileAttributeKey OFFileCreationDate = @"OFFileCreationDate";
const OFFileAttributeKey OFFileSymbolicLinkDestination =
@"OFFileSymbolicLinkDestination";
const OFFileAttributeKey OFFileExtendedAttributesNames =
@"OFFileExtendedAttributesNames";
const OFFileAttributeType OFFileTypeRegular = @"OFFileTypeRegular";
const OFFileAttributeType OFFileTypeDirectory = @"OFFileTypeDirectory";
const OFFileAttributeType OFFileTypeSymbolicLink = @"OFFileTypeSymbolicLink";
const OFFileAttributeType OFFileTypeFIFO = @"OFFileTypeFIFO";
const OFFileAttributeType OFFileTypeCharacterSpecial =
@"OFFileTypeCharacterSpecial";
const OFFileAttributeType OFFileTypeBlockSpecial = @"OFFileTypeBlockSpecial";
const OFFileAttributeType OFFileTypeSocket = @"OFFileTypeSocket";
const OFFileAttributeType OFFileTypeUnknown = @"OFFileTypeUnknown";
|
Modified src/OFGZIPStream.h
from [40a91bbae5]
to [0581f33830].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFGZIPStream.m
from [947da42ac6]
to [1ebfe8e246].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFHMAC.h
from [2d8e8879fb]
to [2091f0e079].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFHMAC.m
from [2ceebc7fc2]
to [8e66f29fa5].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFHTTPClient.h
from [d5da950339]
to [67bbe697a1].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
+
-
|
OF_ASSUME_NONNULL_BEGIN
@class OFDictionary OF_GENERIC(KeyType, ObjectType);
@class OFHTTPClient;
@class OFHTTPRequest;
@class OFHTTPResponse;
@class OFIRI;
@class OFStream;
@class OFTCPSocket;
@class OFTLSStream;
@class OFURI;
/**
* @protocol OFHTTPClientDelegate OFHTTPClient.h ObjFW/OFHTTPClient.h
*
* @brief A delegate for OFHTTPClient.
*/
@protocol OFHTTPClientDelegate <OFObject>
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
|
* to detect a redirect.
*
* This callback will only be called if the OFHTTPClient will follow a
* redirect. If the maximum number of redirects has been reached already, this
* callback will not be called.
*
* @param client The OFHTTPClient which wants to follow a redirect
* @param URI The URI to which it will follow a redirect
* @param IRI The IRI to which it will follow a redirect
* @param statusCode The status code for the redirection
* @param request The request for which the OFHTTPClient wants to redirect.
* You are allowed to change the request's headers from this
* callback and they will be used when following the redirect
* (e.g. to set the cookies for the new URI), however, keep in
* (e.g. to set the cookies for the new IRI), however, keep in
* mind that this will change the request you originally passed.
* @param response The response indicating the redirect
* @return A boolean whether the OFHTTPClient should follow the redirect
*/
- (bool)client: (OFHTTPClient *)client
shouldFollowRedirectToURI: (OFURI *)URI
shouldFollowRedirectToIRI: (OFIRI *)IRI
statusCode: (short)statusCode
request: (OFHTTPRequest *)request
response: (OFHTTPResponse *)response;
@end
/**
* @class OFHTTPClient OFHTTPClient.h ObjFW/OFHTTPClient.h
*
* @brief A class for performing HTTP requests.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFHTTPClient: OFObject
{
#ifdef OF_HTTP_CLIENT_M
@public
#endif
OFObject <OFHTTPClientDelegate> *_Nullable _delegate;
bool _allowsInsecureRedirects, _inProgress;
OFStream *_Nullable _stream;
OFURI *_Nullable _lastURI;
OFIRI *_Nullable _lastIRI;
bool _lastWasHEAD;
OFHTTPResponse *_Nullable _lastResponse;
}
/**
* @brief The delegate of the HTTP request.
*/
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
|
*
* @param request The request to perform
* @return The OFHTTPResponse for the request
* @throw OFHTTPRequestFailedException The HTTP request failed
* @throw OFInvalidServerResponseException The server sent an invalid response
* @throw OFUnsupportedVersionException The server responded in an unsupported
* version
* @throw OFAlreadyConnectedException The client is already performing a request
* @throw OFAlreadyOpenException The client is already performing a request
*/
- (OFHTTPResponse *)performRequest: (OFHTTPRequest *)request;
/**
* @brief Synchronously performs the specified HTTP request.
*
* @note You must not change the delegate while a synchronous request is
* running! If you want to change the delegate during the request,
* perform an asynchronous request instead!
*
* @param request The request to perform
* @param redirects The maximum number of redirects after which no further
* attempt is done to follow the redirect, but instead the
* redirect is treated as an OFHTTPResponse
* @return The OFHTTPResponse for the request
* @throw OFHTTPRequestFailedException The HTTP request failed
* @throw OFInvalidServerResponseException The server sent an invalid response
* @throw OFUnsupportedVersionException The server responded in an unsupported
* version
* @throw OFAlreadyConnectedException The client is already performing a request
* @throw OFAlreadyOpenException The client is already performing a request
*/
- (OFHTTPResponse *)performRequest: (OFHTTPRequest *)request
redirects: (unsigned int)redirects;
/**
* @brief Asynchronously performs the specified HTTP request.
*
* @param request The request to perform
* @throw OFAlreadyConnectedException The client is already performing a request
* @throw OFAlreadyOpenException The client is already performing a request
*/
- (void)asyncPerformRequest: (OFHTTPRequest *)request;
/**
* @brief Asynchronously performs the specified HTTP request.
*
* @param request The request to perform
* @param redirects The maximum number of redirects after which no further
* attempt is done to follow the redirect, but instead the
* redirect is treated as an OFHTTPResponse
* @throw OFAlreadyConnectedException The client is already performing a request
* @throw OFAlreadyOpenException The client is already performing a request
*/
- (void)asyncPerformRequest: (OFHTTPRequest *)request
redirects: (unsigned int)redirects;
/**
* @brief Closes connections that are still open due to keep-alive.
*/
- (void)close;
@end
OF_ASSUME_NONNULL_END
|
Modified src/OFHTTPClient.m
from [e887f99bf5]
to [feb32daab7].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
+
-
-
+
|
#include <string.h>
#import "OFHTTPClient.h"
#import "OFData.h"
#import "OFDictionary.h"
#import "OFHTTPRequest.h"
#import "OFHTTPResponse.h"
#import "OFIRI.h"
#import "OFKernelEventObserver.h"
#import "OFNumber.h"
#import "OFRunLoop.h"
#import "OFString.h"
#import "OFTCPSocket.h"
#import "OFTLSStream.h"
#import "OFURI.h"
#import "OFAlreadyConnectedException.h"
#import "OFAlreadyOpenException.h"
#import "OFHTTPRequestFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidEncodingException.h"
#import "OFInvalidFormatException.h"
#import "OFInvalidServerResponseException.h"
#import "OFNotImplementedException.h"
#import "OFNotOpenException.h"
|
︙ | | |
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
|
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
|
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
|
@end
static OFString *
constructRequestString(OFHTTPRequest *request)
{
void *pool = objc_autoreleasePoolPush();
OFHTTPRequestMethod method = request.method;
OFURI *URI = request.URI;
OFIRI *IRI = request.IRI.IRIByAddingPercentEncodingForUnicodeCharacters;
OFString *path;
OFString *user = URI.user, *password = URI.password;
OFString *user = IRI.user, *password = IRI.password;
OFMutableString *requestString;
OFMutableDictionary OF_GENERIC(OFString *, OFString *) *headers;
bool hasContentLength, chunked;
OFEnumerator OF_GENERIC(OFString *) *keyEnumerator, *objectEnumerator;
OFString *key, *object;
if (URI.path.length > 0)
path = URI.percentEncodedPath;
if (IRI.path.length > 0)
path = IRI.percentEncodedPath;
else
path = @"/";
requestString = [OFMutableString stringWithFormat:
@"%s %@", OFHTTPRequestMethodName(method), path];
if (URI.query != nil) {
if (IRI.query != nil) {
[requestString appendString: @"?"];
[requestString appendString: URI.percentEncodedQuery];
[requestString appendString: IRI.percentEncodedQuery];
}
[requestString appendString: @" HTTP/"];
[requestString appendString: request.protocolVersionString];
[requestString appendString: @"\r\n"];
headers = [[request.headers mutableCopy] autorelease];
if (headers == nil)
headers = [OFMutableDictionary dictionary];
if ([headers objectForKey: @"Host"] == nil) {
OFNumber *port = URI.port;
OFNumber *port = IRI.port;
if (port != nil) {
OFString *host = [OFString stringWithFormat:
@"%@:%@", URI.percentEncodedHost, port];
@"%@:%@", IRI.percentEncodedHost, port];
[headers setObject: host forKey: @"Host"];
} else
[headers setObject: URI.percentEncodedHost
[headers setObject: IRI.percentEncodedHost
forKey: @"Host"];
}
if ((user.length > 0 || password.length > 0) &&
[headers objectForKey: @"Authorization"] == nil) {
OFMutableData *authorizationData = [OFMutableData data];
OFString *authorization;
|
︙ | | |
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
|
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
|
-
+
|
didPerformRequest: _request
response: nil
exception: exception];
}
- (void)createResponseWithStreamOrThrow: (OFStream *)stream
{
OFURI *URI = _request.URI;
OFIRI *IRI = _request.IRI;
OFHTTPClientResponse *response;
OFString *connectionHeader;
bool keepAlive;
OFString *location;
id exception;
response = [[[OFHTTPClientResponse alloc] initWithStream: stream]
|
︙ | | |
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
|
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
|
-
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
keepAlive = false;
}
if (keepAlive) {
response.of_keepAlive = true;
_client->_stream = [stream retain];
_client->_lastURI = [URI copy];
_client->_lastIRI = [IRI copy];
_client->_lastWasHEAD =
(_request.method == OFHTTPRequestMethodHead);
_client->_lastResponse = [response retain];
}
if (_redirects > 0 && (_status == 301 || _status == 302 ||
_status == 303 || _status == 307) &&
(location = [_serverHeaders objectForKey: @"Location"]) != nil) {
bool follow = true;
OFURI *newURI;
OFString *newURIScheme;
OFIRI *newIRI;
OFString *newIRIScheme;
newURI = [OFURI URIWithString: location relativeToURI: URI];
newURIScheme = newURI.scheme;
newIRI = [OFIRI IRIWithString: location relativeToIRI: IRI];
newIRIScheme = newIRI.scheme;
if ([newURIScheme caseInsensitiveCompare: @"http"] !=
if ([newIRIScheme caseInsensitiveCompare: @"http"] !=
OFOrderedSame &&
[newURIScheme caseInsensitiveCompare: @"https"] !=
[newIRIScheme caseInsensitiveCompare: @"https"] !=
OFOrderedSame)
follow = false;
if (!_client->_allowsInsecureRedirects &&
[URI.scheme caseInsensitiveCompare: @"https"] ==
[IRI.scheme caseInsensitiveCompare: @"https"] ==
OFOrderedSame &&
[newURIScheme caseInsensitiveCompare: @"http"] ==
[newIRIScheme caseInsensitiveCompare: @"http"] ==
OFOrderedSame)
follow = false;
if (follow && [_client->_delegate respondsToSelector:
@selector(client:shouldFollowRedirectToURI:statusCode:
@selector(client:shouldFollowRedirectToIRI:statusCode:
request:response:)])
follow = [_client->_delegate client: _client
shouldFollowRedirectToURI: newURI
shouldFollowRedirectToIRI: newIRI
statusCode: _status
request: _request
response: response];
else if (follow)
follow = defaultShouldFollow(_request.method, _status);
if (follow) {
OFDictionary OF_GENERIC(OFString *, OFString *)
*headers = _request.headers;
OFHTTPRequest *newRequest =
[[_request copy] autorelease];
OFMutableDictionary *newHeaders =
[[headers mutableCopy] autorelease];
if (![newURI.host isEqual: URI.host])
if (![newIRI.host isEqual: IRI.host])
[newHeaders removeObjectForKey: @"Host"];
/*
* 303 means the request should be converted to a GET
* request before redirection. This also means stripping
* the entity of the request.
*/
|
︙ | | |
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
|
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
|
-
+
|
[key hasPrefix: @"Transfer-"])
[newHeaders
removeObjectForKey: key];
newRequest.method = OFHTTPRequestMethodGet;
}
newRequest.URI = newURI;
newRequest.IRI = newIRI;
newRequest.headers = newHeaders;
_client->_inProgress = false;
[_client asyncPerformRequest: newRequest
redirects: _redirects - 1];
return;
|
︙ | | |
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
|
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
|
-
+
-
+
-
+
+
|
if ([_client->_delegate respondsToSelector:
@selector(client:didCreateTCPSocket:request:)])
[_client->_delegate client: _client
didCreateTCPSocket: sock
request: _request];
if ([_request.URI.scheme caseInsensitiveCompare: @"https"] ==
if ([_request.IRI.scheme caseInsensitiveCompare: @"https"] ==
OFOrderedSame) {
OFTLSStream *stream;
@try {
stream = [OFTLSStream streamWithStream: sock];
} @catch (OFNotImplementedException *e) {
[self raiseException:
[OFUnsupportedProtocolException
exceptionWithURI: _request.URI]];
exceptionWithIRI: _request.IRI]];
return;
}
if ([_client->_delegate respondsToSelector:
@selector(client:didCreateTLSStream:request:)])
[_client->_delegate client: _client
didCreateTLSStream: stream
request: _request];
stream.delegate = self;
[stream asyncPerformClientHandshakeWithHost: _request.URI.host];
[stream asyncPerformClientHandshakeWithHost: _request.IRI
.IRIByAddingPercentEncodingForUnicodeCharacters.host];
} else {
sock.delegate = self;
[self performSelector: @selector(handleStream:)
withObject: sock
afterDelay: 0];
}
}
|
︙ | | |
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
|
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
|
-
+
-
-
-
-
+
+
+
+
-
-
+
+
-
+
+
-
+
-
+
-
-
-
+
+
+
-
+
|
[self performSelector: @selector(handleStream:)
withObject: stream
afterDelay: 0];
}
- (void)start
{
OFURI *URI = _request.URI;
OFIRI *IRI = _request.IRI;
OFStream *stream;
/* Can we reuse the last socket? */
if (_client->_stream != nil && !_client->_stream.atEndOfStream &&
[_client->_lastURI.scheme isEqual: URI.scheme] &&
[_client->_lastURI.host isEqual: URI.host] &&
(_client->_lastURI.port == URI.port ||
[_client->_lastURI.port isEqual: URI.port]) &&
[_client->_lastIRI.scheme isEqual: IRI.scheme] &&
[_client->_lastIRI.host isEqual: IRI.host] &&
(_client->_lastIRI.port == IRI.port ||
[_client->_lastIRI.port isEqual: IRI.port]) &&
(_client->_lastWasHEAD || _client->_lastResponse.atEndOfStream)) {
/*
* Set _stream to nil, so that in case of an error it won't be
* reused. If everything is successful, we set _stream again
* at the end.
*/
stream = [_client->_stream autorelease];
_client->_stream = nil;
[_client->_lastURI release];
_client->_lastURI = nil;
[_client->_lastIRI release];
_client->_lastIRI = nil;
[_client->_lastResponse release];
_client->_lastResponse = nil;
stream.delegate = self;
[self performSelector: @selector(handleStream:)
withObject: stream
afterDelay: 0];
} else
[self closeAndReconnect];
}
- (void)closeAndReconnect
{
@try {
OFURI *URI = _request.URI;
OFIRI *IRI =
_request.IRI.IRIByAddingPercentEncodingForUnicodeCharacters;
OFTCPSocket *sock;
uint16_t port;
OFNumber *URIPort;
OFNumber *IRIPort;
[_client close];
sock = [OFTCPSocket socket];
if ([URI.scheme caseInsensitiveCompare: @"https"] ==
if ([IRI.scheme caseInsensitiveCompare: @"https"] ==
OFOrderedSame)
port = 443;
else
port = 80;
URIPort = URI.port;
if (URIPort != nil)
port = URIPort.unsignedShortValue;
IRIPort = IRI.port;
if (IRIPort != nil)
port = IRIPort.unsignedShortValue;
sock.delegate = self;
[sock asyncConnectToHost: URI.host port: port];
[sock asyncConnectToHost: IRI.host port: port];
} @catch (id e) {
[self raiseException: e];
}
}
@end
@implementation OFHTTPClientRequestBodyStream
|
︙ | | |
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
|
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
|
-
+
-
+
-
+
|
[_delegate client: client
didReceiveHeaders: headers
statusCode: statusCode
request: request];
}
- (bool)client: (OFHTTPClient *)client
shouldFollowRedirectToURI: (OFURI *)URI
shouldFollowRedirectToIRI: (OFIRI *)IRI
statusCode: (short)statusCode
request: (OFHTTPRequest *)request
response: (OFHTTPResponse *)response
{
if ([_delegate respondsToSelector: @selector(
client:shouldFollowRedirectToURI:statusCode:request:response:)])
client:shouldFollowRedirectToIRI:statusCode:request:response:)])
return [_delegate client: client
shouldFollowRedirectToURI: URI
shouldFollowRedirectToIRI: IRI
statusCode: statusCode
request: request
response: response];
else
return defaultShouldFollow(request.method, statusCode);
}
@end
|
︙ | | |
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
|
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
|
-
-
+
+
-
+
-
+
-
-
+
+
|
[self asyncPerformRequest: request redirects: defaultRedirects];
}
- (void)asyncPerformRequest: (OFHTTPRequest *)request
redirects: (unsigned int)redirects
{
void *pool = objc_autoreleasePoolPush();
OFURI *URI = request.URI;
OFString *scheme = URI.scheme;
OFIRI *IRI = request.IRI;
OFString *scheme = IRI.scheme;
if ([scheme caseInsensitiveCompare: @"http"] != OFOrderedSame &&
[scheme caseInsensitiveCompare: @"https"] != OFOrderedSame)
@throw [OFUnsupportedProtocolException exceptionWithURI: URI];
@throw [OFUnsupportedProtocolException exceptionWithIRI: IRI];
if (_inProgress)
@throw [OFAlreadyConnectedException exception];
@throw [OFAlreadyOpenException exceptionWithObject: self];
_inProgress = true;
[[[[OFHTTPClientRequestHandler alloc]
initWithClient: self
request: request
redirects: redirects] autorelease] start];
objc_autoreleasePoolPop(pool);
}
- (void)close
{
[_stream release];
_stream = nil;
[_lastURI release];
_lastURI = nil;
[_lastIRI release];
_lastIRI = nil;
[_lastResponse release];
_lastResponse = nil;
}
@end
|
Modified src/OFHTTPCookie.h
from [ff53970b1e]
to [b9b2600bbf].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
+
-
|
#import "OFString.h"
OF_ASSUME_NONNULL_BEGIN
@class OFArray OF_GENERIC(ObjectType);
@class OFDate;
@class OFDictionary OF_GENERIC(KeyType, ObjectType);
@class OFIRI;
@class OFMutableArray OF_GENERIC(ObjectType);
@class OFURI;
/**
* @class OFHTTPCookie OFHTTPCookie.h ObjFW/OFHTTPCookie.h
*
* @brief A class for storing and manipulating HTTP cookies.
*/
OF_SUBCLASSING_RESTRICTED
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
|
/**
* @brief An array of other attributes.
*/
@property (readonly, nonatomic)
OFMutableArray OF_GENERIC(OFString *) *extensions;
/**
* @brief Parses the specified response header fields for the specified URI and
* @brief Parses the specified response header fields for the specified IRI and
* returns an array of cookies.
*
* @param headerFields The response header fields to parse
* @param URI The URI for the response header fields to parse
* @param IRI The IRI for the response header fields to parse
* @return An array of cookies
* @throw OFInvalidFormatException The specified response header has an invalid
* format
*/
+ (OFArray OF_GENERIC(OFHTTPCookie *) *)cookiesWithResponseHeaderFields:
(OFDictionary OF_GENERIC(OFString *, OFString *) *)headerFields
forURI: (OFURI *)URI;
forIRI: (OFIRI *)IRI;
/**
* @brief Returns the request header fields for the specified cookies.
*
* @param cookies The cookies to return the request header fields for
* @return The request header fields for the specified cookies
*/
|
︙ | | |
Modified src/OFHTTPCookie.m
from [a7d6a07918]
to [25b009e19f].
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
|
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
|
-
+
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#import "OFHTTPCookie.h"
#import "OFArray.h"
#import "OFDate.h"
#import "OFDictionary.h"
#import "OFURI.h"
#import "OFIRI.h"
#import "OFInvalidFormatException.h"
static void
handleAttribute(OFHTTPCookie *cookie, OFString *name, OFString *value)
{
OFString *lowercaseName = name.lowercaseString;
|
︙ | | |
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
-
+
-
+
+
|
@implementation OFHTTPCookie
@synthesize name = _name, value = _value, domain = _domain, path = _path;
@synthesize expires = _expires, secure = _secure, HTTPOnly = _HTTPOnly;
@synthesize extensions = _extensions;
+ (OFArray OF_GENERIC(OFHTTPCookie *) *)cookiesWithResponseHeaderFields:
(OFDictionary OF_GENERIC(OFString *, OFString *) *)headerFields
forURI: (OFURI *)URI
forIRI: (OFIRI *)IRI
{
OFMutableArray OF_GENERIC(OFHTTPCookie *) *ret = [OFMutableArray array];
void *pool = objc_autoreleasePoolPush();
OFString *string = [headerFields objectForKey: @"Set-Cookie"];
OFString *domain = URI.host;
OFString *domain = IRI.IRIByAddingPercentEncodingForUnicodeCharacters
.host;
const OFUnichar *characters = string.characters;
size_t length = string.length, last = 0;
enum {
statePreName,
stateName,
stateExpectValue,
stateValue,
|
︙ | | |
Modified src/OFHTTPCookieManager.h
from [3cc0432376]
to [97276ce2e8].
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
|
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
|
-
+
+
-
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFObject.h"
OF_ASSUME_NONNULL_BEGIN
@class OFArray OF_GENERIC(ObjectType);
@class OFHTTPCookie;
@class OFIRI;
@class OFMutableArray OF_GENERIC(ObjectType);
@class OFURI;
/**
* @class OFHTTPCookieManager OFHTTPCookieManager.h ObjFW/OFHTTPCookieManager.h
*
* @brief A class for managing cookies for multiple domains.
*/
OF_SUBCLASSING_RESTRICTED
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
|
* @brief Create a new cookie manager.
*
* @return A new, autoreleased OFHTTPCookieManager
*/
+ (instancetype)manager;
/**
* @brief Adds the specified cookie for the specified URI.
* @brief Adds the specified cookie for the specified IRI.
*
* @warning This modifies the cookie (e.g. it sets the domain if it is unset)!
* If you do not want this, pass a copy!
*
* @param cookie The cookie to add to the manager
* @param URI The URI for which the cookie should be added
* @param IRI The IRI for which the cookie should be added
*/
- (void)addCookie: (OFHTTPCookie *)cookie forURI: (OFURI *)URI;
- (void)addCookie: (OFHTTPCookie *)cookie forIRI: (OFIRI *)IRI;
/**
* @brief Adds the specified cookies for the specified URI.
* @brief Adds the specified cookies for the specified IRI.
*
* @warning This modifies the cookies (e.g. it sets the domain if it is unset)!
* If you do not want this, pass copies!
*
* @param cookies An array of cookies to add to the manager
* @param URI The URI for which the cookies should be added
* @param IRI The IRI for which the cookies should be added
*/
- (void)addCookies: (OFArray OF_GENERIC(OFHTTPCookie *) *)cookies
forURI: (OFURI *)URI;
forIRI: (OFIRI *)IRI;
/**
* @brief Returns the cookies for the specified URI.
* @brief Returns the cookies for the specified IRI.
*
* @param URI The URI for which the cookies should be returned
* @return The cookies for the specified URI
* @param IRI The IRI for which the cookies should be returned
* @return The cookies for the specified IRI
*/
- (OFArray OF_GENERIC(OFHTTPCookie *) *)cookiesForURI: (OFURI *)URI;
- (OFArray OF_GENERIC(OFHTTPCookie *) *)cookiesForIRI: (OFIRI *)IRI;
/**
* @brief Purges all expired cookies.
*/
- (void)purgeExpiredCookies;
@end
OF_ASSUME_NONNULL_END
|
Modified src/OFHTTPCookieManager.m
from [1dd74fe07e]
to [8d1e7efb55].
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
|
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
|
-
+
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#import "OFHTTPCookieManager.h"
#import "OFArray.h"
#import "OFDate.h"
#import "OFHTTPCookie.h"
#import "OFURI.h"
#import "OFIRI.h"
@implementation OFHTTPCookieManager
+ (instancetype)manager
{
return [[[self alloc] init] autorelease];
}
|
︙ | | |
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
|
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
|
-
+
-
+
+
+
-
+
-
-
-
+
+
+
-
+
|
}
- (OFArray OF_GENERIC(OFHTTPCookie *) *)cookies
{
return [[_cookies copy] autorelease];
}
- (void)addCookie: (OFHTTPCookie *)cookie forURI: (OFURI *)URI
- (void)addCookie: (OFHTTPCookie *)cookie forIRI: (OFIRI *)IRI
{
void *pool = objc_autoreleasePoolPush();
OFString *cookieDomain, *URIHost;
OFString *cookieDomain, *IRIHost;
size_t i;
IRI = IRI.IRIByAddingPercentEncodingForUnicodeCharacters;
if (![cookie.path hasPrefix: @"/"])
cookie.path = @"/";
if (cookie.secure &&
[URI.scheme caseInsensitiveCompare: @"https"] != OFOrderedSame) {
[IRI.scheme caseInsensitiveCompare: @"https"] != OFOrderedSame) {
objc_autoreleasePoolPop(pool);
return;
}
cookieDomain = cookie.domain.lowercaseString;
cookie.domain = cookieDomain;
URIHost = URI.host.lowercaseString;
if (![cookieDomain isEqual: URIHost]) {
URIHost = [@"." stringByAppendingString: URIHost];
IRIHost = IRI.host.lowercaseString;
if (![cookieDomain isEqual: IRIHost]) {
IRIHost = [@"." stringByAppendingString: IRIHost];
if (![cookieDomain hasSuffix: URIHost]) {
if (![cookieDomain hasSuffix: IRIHost]) {
objc_autoreleasePoolPop(pool);
return;
}
}
i = 0;
for (OFHTTPCookie *iter in _cookies) {
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
+
+
|
[_cookies addObject: cookie];
objc_autoreleasePoolPop(pool);
}
- (void)addCookies: (OFArray OF_GENERIC(OFHTTPCookie *) *)cookies
forURI: (OFURI *)URI
forIRI: (OFIRI *)IRI
{
for (OFHTTPCookie *cookie in cookies)
[self addCookie: cookie forURI: URI];
[self addCookie: cookie forIRI: IRI];
}
- (OFArray OF_GENERIC(OFHTTPCookie *) *)cookiesForURI: (OFURI *)URI
- (OFArray OF_GENERIC(OFHTTPCookie *) *)cookiesForIRI: (OFIRI *)IRI
{
OFMutableArray *ret = [OFMutableArray array];
void *pool = objc_autoreleasePoolPush();
IRI = IRI.IRIByAddingPercentEncodingForUnicodeCharacters;
for (OFHTTPCookie *cookie in _cookies) {
void *pool;
void *pool2;
OFDate *expires;
OFString *cookieDomain, *URIHost, *cookiePath, *URIPath;
OFString *cookieDomain, *IRIHost, *cookiePath, *IRIPath;
bool match;
expires = cookie.expires;
if (expires != nil && expires.timeIntervalSinceNow <= 0)
continue;
if (cookie.secure && [URI.scheme caseInsensitiveCompare:
if (cookie.secure && [IRI.scheme caseInsensitiveCompare:
@"https"] != OFOrderedSame)
continue;
pool = objc_autoreleasePoolPush();
pool2 = objc_autoreleasePoolPush();
cookieDomain = cookie.domain.lowercaseString;
URIHost = URI.host.lowercaseString;
IRIHost = IRI.host.lowercaseString;
if ([cookieDomain hasPrefix: @"."]) {
if ([URIHost hasSuffix: cookieDomain])
if ([IRIHost hasSuffix: cookieDomain])
match = true;
else {
cookieDomain =
[cookieDomain substringFromIndex: 1];
match = [cookieDomain isEqual: URIHost];
match = [cookieDomain isEqual: IRIHost];
}
} else
match = [cookieDomain isEqual: URIHost];
match = [cookieDomain isEqual: IRIHost];
if (!match) {
objc_autoreleasePoolPop(pool);
objc_autoreleasePoolPop(pool2);
continue;
}
cookiePath = cookie.path;
URIPath = URI.path;
IRIPath = IRI.path;
if (![cookiePath isEqual: @"/"]) {
if ([cookiePath isEqual: URIPath])
if ([cookiePath isEqual: IRIPath])
match = true;
else {
if (![cookiePath hasSuffix: @"/"])
cookiePath = [cookiePath
stringByAppendingString: @"/"];
match = [URIPath hasPrefix: cookiePath];
match = [IRIPath hasPrefix: cookiePath];
}
if (!match) {
objc_autoreleasePoolPop(pool);
objc_autoreleasePoolPop(pool2);
continue;
}
}
[ret addObject: cookie];
}
[ret makeImmutable];
objc_autoreleasePoolPop(pool);
return ret;
}
- (void)purgeExpiredCookies
{
for (size_t i = 0, count = _cookies.count; i < count; i++) {
|
︙ | | |
Renamed and modified
src/OFHTTPURIHandler.h
[1fbd933246]
to src/OFHTTPIRIHandler.h
[e3a6563685].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
-
+
-
+
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFURIHandler.h"
#import "OFIRIHandler.h"
OF_ASSUME_NONNULL_BEGIN
@interface OFHTTPURIHandler: OFURIHandler
@interface OFHTTPIRIHandler: OFIRIHandler
@end
OF_ASSUME_NONNULL_END
|
Renamed and modified
src/OFHTTPURIHandler.m
[9e6fa9d3fe]
to src/OFHTTPIRIHandler.m
[b9d37cc0a5].
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
|
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
|
-
+
-
+
-
-
+
+
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#import "OFHTTPURIHandler.h"
#import "OFHTTPIRIHandler.h"
#import "OFHTTPClient.h"
#import "OFHTTPRequest.h"
#import "OFHTTPResponse.h"
@implementation OFHTTPURIHandler
- (OFStream *)openItemAtURI: (OFURI *)URI mode: (OFString *)mode
@implementation OFHTTPIRIHandler
- (OFStream *)openItemAtIRI: (OFIRI *)IRI mode: (OFString *)mode
{
void *pool = objc_autoreleasePoolPush();
OFHTTPClient *client = [OFHTTPClient client];
OFHTTPRequest *request = [OFHTTPRequest requestWithURI: URI];
OFHTTPRequest *request = [OFHTTPRequest requestWithIRI: IRI];
OFHTTPResponse *response = [client performRequest: request];
[response retain];
objc_autoreleasePoolPop(pool);
return [response autorelease];
}
@end
|
Modified src/OFHTTPRequest.h
from [1278addd47]
to [f431611fce].
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
|
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
|
-
+
-
+
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFObject.h"
#import "OFSocket.h"
#import "OFString.h"
OF_ASSUME_NONNULL_BEGIN
@class OFURI;
@class OFData;
@class OFDictionary OF_GENERIC(KeyType, ObjectType);
@class OFData;
@class OFIRI;
@class OFString;
/** @file */
/**
* @brief The type of an HTTP request.
*/
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
|
* @class OFHTTPRequest OFHTTPRequest.h ObjFW/OFHTTPRequest.h
*
* @brief A class for storing HTTP requests.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFHTTPRequest: OFObject <OFCopying>
{
OFURI *_URI;
OFIRI *_IRI;
OFHTTPRequestMethod _method;
OFHTTPRequestProtocolVersion _protocolVersion;
OFDictionary OF_GENERIC(OFString *, OFString *) *_Nullable _headers;
OFSocketAddress _remoteAddress;
bool _hasRemoteAddress;
}
/**
* @brief The URI of the HTTP request.
* @brief The IRI of the HTTP request.
*/
@property (copy, nonatomic) OFURI *URI;
@property (copy, nonatomic) OFIRI *IRI;
/**
* @brief The protocol version of the HTTP request.
*
* @throw OFUnsupportedVersionException The specified version cannot be set
* because it is not supported
*/
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
-
+
-
+
|
* @brief The remote address from which the request originates.
*
* @note The setter creates a copy of the remote address.
*/
@property OF_NULLABLE_PROPERTY (nonatomic) const OFSocketAddress *remoteAddress;
/**
* @brief Creates a new OFHTTPRequest with the specified URI.
* @brief Creates a new OFHTTPRequest with the specified IRI.
*
* @param URI The URI for the request
* @param IRI The IRI for the request
* @return A new, autoreleased OFHTTPRequest
*/
+ (instancetype)requestWithURI: (OFURI *)URI;
+ (instancetype)requestWithIRI: (OFIRI *)IRI;
/**
* @brief Initializes an already allocated OFHTTPRequest with the specified URI.
* @brief Initializes an already allocated OFHTTPRequest with the specified IRI.
*
* @param URI The URI for the request
* @param IRI The IRI for the request
* @return An initialized OFHTTPRequest
*/
- (instancetype)initWithURI: (OFURI *)URI;
- (instancetype)initWithIRI: (OFIRI *)IRI;
- (instancetype)init OF_UNAVAILABLE;
@end
#ifdef __cplusplus
extern "C" {
#endif
|
︙ | | |
Modified src/OFHTTPRequest.m
from [c85955ea02]
to [f630f4e80b].
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
|
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
|
-
+
-
-
+
+
-
-
+
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#include <string.h>
#import "OFHTTPRequest.h"
#import "OFString.h"
#import "OFURI.h"
#import "OFArray.h"
#import "OFData.h"
#import "OFDictionary.h"
#import "OFData.h"
#import "OFArray.h"
#import "OFIRI.h"
#import "OFString.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFOutOfRangeException.h"
#import "OFUnsupportedVersionException.h"
const char *
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
-
+
-
+
|
if ([string isEqual: @"CONNECT"])
return OFHTTPRequestMethodConnect;
@throw [OFInvalidFormatException exception];
}
@implementation OFHTTPRequest
@synthesize URI = _URI, method = _method, headers = _headers;
@synthesize IRI = _IRI, method = _method, headers = _headers;
+ (instancetype)requestWithURI: (OFURI *)URI
+ (instancetype)requestWithIRI: (OFIRI *)IRI
{
return [[[self alloc] initWithURI: URI] autorelease];
return [[[self alloc] initWithIRI: IRI] autorelease];
}
- (instancetype)initWithURI: (OFURI *)URI
- (instancetype)initWithIRI: (OFIRI *)IRI
{
self = [super init];
@try {
_URI = [URI copy];
_IRI = [IRI copy];
_method = OFHTTPRequestMethodGet;
_protocolVersion.major = 1;
_protocolVersion.minor = 1;
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (void)dealloc
{
[_URI release];
[_IRI release];
[_headers release];
[super dealloc];
}
- (void)setRemoteAddress: (const OFSocketAddress *)remoteAddress
{
|
︙ | | |
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
-
+
|
return &_remoteAddress;
return NULL;
}
- (id)copy
{
OFHTTPRequest *copy = [[OFHTTPRequest alloc] initWithURI: _URI];
OFHTTPRequest *copy = [[OFHTTPRequest alloc] initWithIRI: _IRI];
@try {
copy->_method = _method;
copy->_protocolVersion = _protocolVersion;
copy.headers = _headers;
copy.remoteAddress = self.remoteAddress;
} @catch (id e) {
|
︙ | | |
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
|
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
|
-
+
-
+
|
return false;
request = object;
if (request->_method != _method ||
request->_protocolVersion.major != _protocolVersion.major ||
request->_protocolVersion.minor != _protocolVersion.minor ||
![request->_URI isEqual: _URI] ||
![request->_IRI isEqual: _IRI] ||
![request->_headers isEqual: _headers])
return false;
if (request.remoteAddress != self.remoteAddress &&
!OFSocketAddressEqual(request.remoteAddress, self.remoteAddress))
return false;
return true;
}
- (unsigned long)hash
{
unsigned long hash;
OFHashInit(&hash);
OFHashAddByte(&hash, _method);
OFHashAddByte(&hash, _protocolVersion.major);
OFHashAddByte(&hash, _protocolVersion.minor);
OFHashAddHash(&hash, _URI.hash);
OFHashAddHash(&hash, _IRI.hash);
OFHashAddHash(&hash, _headers.hash);
if (_hasRemoteAddress)
OFHashAddHash(&hash, OFSocketAddressHash(&_remoteAddress));
OFHashFinalize(&hash);
return hash;
|
︙ | | |
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
|
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
|
-
+
-
+
|
if (_hasRemoteAddress)
remoteAddress = OFSocketAddressString(&_remoteAddress);
else
remoteAddress = nil;
ret = [[OFString alloc] initWithFormat:
@"<%@:\n\tURI = %@\n"
@"<%@:\n\tIRI = %@\n"
@"\tMethod = %s\n"
@"\tHeaders = %@\n"
@"\tRemote address = %@\n"
@">",
self.class, _URI, method, indentedHeaders, remoteAddress];
self.class, _IRI, method, indentedHeaders, remoteAddress];
objc_autoreleasePoolPop(pool);
return [ret autorelease];
}
@end
|
Modified src/OFHTTPResponse.h
from [3c482db81b]
to [a7b884a494].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFHTTPResponse.m
from [17a72a5d36]
to [dd8060da94].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFHTTPServer.h
from [ba5fc5aae1]
to [3618d652f0].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
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
|
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
|
-
-
+
+
-
-
+
+
-
-
+
+
|
OFArray *_threadPool;
#endif
}
/**
* @brief The host on which the HTTP server will listen.
*
* @throw OFAlreadyConnectedException The host could not be set because
* @ref start had already been called
* @throw OFAlreadyOpenException The host could not be set because @ref start
* had already been called
*/
@property OF_NULLABLE_PROPERTY (copy, nonatomic) OFString *host;
/**
* @brief The port on which the HTTP server will listen.
*
* @throw OFAlreadyConnectedException The port could not be set because
* @ref start had already been called
* @throw OFAlreadyOpenException The port could not be set because @ref start
* had already been called
*/
@property (nonatomic) uint16_t port;
/**
* @brief The delegate for the HTTP server.
*/
@property OF_NULLABLE_PROPERTY (assign, nonatomic)
id <OFHTTPServerDelegate> delegate;
#ifdef OF_HAVE_THREADS
/**
* @brief The number of threads the OFHTTPServer should use.
*
* If this is larger than 1 (the default), one thread will be used to accept
* incoming connections and all others will be used to handle connections.
*
* For maximum CPU utilization, set this to `[OFSystemInfo numberOfCPUs] + 1`.
*
* @throw OFAlreadyConnectedException The number of threads could not be set
* because @ref start had already been called
* @throw OFAlreadyOpenException The number of threads could not be set because
* @ref start had already been called
*/
@property (nonatomic) size_t numberOfThreads;
#endif
/**
* @brief The server name the server presents to clients.
*
|
︙ | | |
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
-
+
|
* @return A new HTTP server
*/
+ (instancetype)server;
/**
* @brief Starts the HTTP server in the current thread's run loop.
*
* @throw OFAlreadyConnectedException The server had already been started
* @throw OFAlreadyOpenException The server had already been started
*/
- (void)start;
/**
* @brief Stops the HTTP server, meaning it will not accept any new incoming
* connections, but still handle existing connections until they are
* finished or timed out.
*/
- (void)stop;
@end
OF_ASSUME_NONNULL_END
|
Modified src/OFHTTPServer.m
from [e75cf57b42]
to [df8e40fa8b].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
+
-
-
+
|
#import "OFHTTPServer.h"
#import "OFArray.h"
#import "OFData.h"
#import "OFDate.h"
#import "OFDictionary.h"
#import "OFHTTPRequest.h"
#import "OFHTTPResponse.h"
#import "OFIRI.h"
#import "OFNumber.h"
#import "OFSocket+Private.h"
#import "OFTCPSocket.h"
#import "OFThread.h"
#import "OFTimer.h"
#import "OFURI.h"
#import "OFAlreadyConnectedException.h"
#import "OFAlreadyOpenException.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidEncodingException.h"
#import "OFInvalidFormatException.h"
#import "OFNotOpenException.h"
#import "OFOutOfMemoryException.h"
#import "OFOutOfRangeException.h"
#import "OFTruncatedDataException.h"
|
︙ | | |
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
|
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
|
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
+
|
date, _server.name];
return false;
}
- (void)createResponse
{
void *pool = objc_autoreleasePoolPush();
OFMutableURI *URI;
OFMutableIRI *IRI;
OFHTTPRequest *request;
OFHTTPServerResponse *response;
size_t pos;
[_timer invalidate];
[_timer release];
_timer = nil;
if (_host == nil || _port == 0) {
if (_HTTPMinorVersion > 0) {
[self sendErrorAndClose: 400];
return;
}
[_host release];
_host = [_server.host copy];
_port = [_server port];
}
URI = [OFMutableURI URIWithScheme: @"http"];
URI.host = _host;
IRI = [OFMutableIRI IRIWithScheme: @"http"];
IRI.host = _host;
if (_port != 80)
URI.port = [OFNumber numberWithUnsignedShort: _port];
IRI.port = [OFNumber numberWithUnsignedShort: _port];
@try {
if ((pos = [_path rangeOfString: @"?"].location) !=
OFNotFound) {
OFString *path, *query;
path = [_path substringToIndex: pos];
query = [_path substringFromIndex: pos + 1];
URI.percentEncodedPath = path;
URI.percentEncodedQuery = query;
IRI.percentEncodedPath = path;
IRI.percentEncodedQuery = query;
} else
URI.percentEncodedPath = _path;
IRI.percentEncodedPath = _path;
} @catch (OFInvalidFormatException *e) {
objc_autoreleasePoolPop(pool);
[self sendErrorAndClose: 400];
return;
}
[URI makeImmutable];
[IRI makeImmutable];
request = [OFHTTPRequest requestWithURI: URI];
request = [OFHTTPRequest requestWithIRI: IRI];
request.method = _method;
request.protocolVersion =
(OFHTTPRequestProtocolVersion){ 1, _HTTPMinorVersion };
request.headers = _headers;
request.remoteAddress = _socket.remoteAddress;
response = [[[OFHTTPServerResponse alloc]
|
︙ | | |
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
|
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
|
-
+
-
+
-
+
+
-
+
-
+
+
|
}
- (void)setHost: (OFString *)host
{
OFString *old;
if (_listeningSocket != nil)
@throw [OFAlreadyConnectedException exception];
@throw [OFAlreadyOpenException exceptionWithObject: self];
old = _host;
_host = [host copy];
[old release];
}
- (OFString *)host
{
return _host;
}
- (void)setPort: (uint16_t)port
{
if (_listeningSocket != nil)
@throw [OFAlreadyConnectedException exception];
@throw [OFAlreadyOpenException exceptionWithObject: self];
_port = port;
}
- (uint16_t)port
{
return _port;
}
#ifdef OF_HAVE_THREADS
- (void)setNumberOfThreads: (size_t)numberOfThreads
{
if (numberOfThreads == 0)
@throw [OFInvalidArgumentException exception];
if (_listeningSocket != nil)
@throw [OFAlreadyConnectedException exception];
@throw [OFAlreadyOpenException exceptionWithObject: self];
_numberOfThreads = numberOfThreads;
}
- (size_t)numberOfThreads
{
return _numberOfThreads;
}
#endif
- (void)start
{
void *pool = objc_autoreleasePoolPush();
OFSocketAddress address;
if (_host == nil)
@throw [OFInvalidArgumentException exception];
if (_listeningSocket != nil)
@throw [OFAlreadyConnectedException exception];
@throw [OFAlreadyOpenException exceptionWithObject: self];
_listeningSocket = [[OFTCPSocket alloc] init];
_port = [_listeningSocket bindToHost: _host port: _port];
address = [_listeningSocket bindToHost: _host port: _port];
_port = OFSocketAddressIPPort(&address);
[_listeningSocket listen];
#ifdef OF_HAVE_THREADS
if (_numberOfThreads > 1) {
OFMutableArray *threads =
[OFMutableArray arrayWithCapacity: _numberOfThreads - 1];
|
︙ | | |
Modified src/OFHostAddressResolver.h
from [5c6783fd03]
to [449bceebed].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFHostAddressResolver.m
from [3275d58c93]
to [1a75dd0a5b].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
-
-
+
+
+
+
+
|
}
- (void)sendQueries
{
OFString *domainName;
if (!_isFQDN) {
OFString *searchDomain = [_settings->_searchDomains
objectAtIndex: _searchDomainIndex];
OFString *searchDomain = @"";
if (_searchDomainIndex < _settings->_searchDomains.count)
searchDomain = [_settings->_searchDomains
objectAtIndex: _searchDomainIndex];
domainName = [OFString stringWithFormat: @"%@.%@",
_host, searchDomain];
} else
domainName = _host;
#ifdef OF_HAVE_IPV6
|
︙ | | |
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
|
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
|
-
+
+
|
addresses, exception);
objc_autoreleasePoolPop(pool);
return;
} @catch (OFInvalidFormatException *e) {
}
if ((aliases = [_settings->_staticHosts objectForKey: _host]) != nil) {
if ((aliases = [_settings->_staticHosts objectForKey:
_host.lowercaseString]) != nil) {
OFMutableData *addresses = [OFMutableData
dataWithItemSize: sizeof(OFSocketAddress)];
id exception = nil;
for (OFString *alias in aliases) {
OFSocketAddress address;
|
︙ | | |
Modified src/OFHuffmanTree.h
from [0152a399af]
to [55fb6bc288].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFHuffmanTree.m
from [13f0a946b0]
to [a61d8159f9].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFINICategory+Private.h
from [6b757dc025]
to [1882471bdd].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFINICategory.h
from [8e0c968abf]
to [78e7ff0afc].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFINICategory.m
from [1db2d24df3]
to [cc663f3e2a].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFINIFile.h
from [f35fd21473]
to [b499732126].
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
|
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
|
-
+
+
-
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFObject.h"
#import "OFString.h"
#import "OFINICategory.h"
OF_ASSUME_NONNULL_BEGIN
@class OFIRI;
@class OFMutableArray OF_GENERIC(ObjectType);
@class OFURI;
/**
* @class OFINIFile OFINIFile.h ObjFW/OFINIFile.h
*
* @brief A class for reading, creating and modifying INI files.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFINIFile: OFObject
{
OFMutableArray OF_GENERIC(OFINICategory *) *_categories;
}
/**
* @brief All categories in the INI file.
*/
@property (readonly, nonatomic) OFArray OF_GENERIC(OFINICategory *) *categories;
/**
* @brief Creates a new OFINIFile with the contents of the specified file.
*
* @param URI The URI to the file whose contents the OFINIFile should contain
* @param IRI The IRI to the file whose contents the OFINIFile should contain
*
* @return A new, autoreleased OFINIFile with the contents of the specified file
* @throw OFInvalidFormatException The format of the specified INI file is
* invalid
* @throw OFInvalidEncodingException The INI file is not in the specified
* encoding
*/
+ (instancetype)fileWithURI: (OFURI *)URI;
+ (instancetype)fileWithIRI: (OFIRI *)IRI;
/**
* @brief Creates a new OFINIFile with the contents of the specified file in
* the specified encoding.
*
* @param URI The URI to the file whose contents the OFINIFile should contain
* @param IRI The IRI to the file whose contents the OFINIFile should contain
* @param encoding The encoding of the specified file
* @return A new, autoreleased OFINIFile with the contents of the specified file
* @throw OFInvalidFormatException The format of the specified INI file is
* invalid
* @throw OFInvalidEncodingException The INI file is not in the specified
* encoding
*/
+ (instancetype)fileWithURI: (OFURI *)URI encoding: (OFStringEncoding)encoding;
+ (instancetype)fileWithIRI: (OFIRI *)IRI encoding: (OFStringEncoding)encoding;
- (instancetype)init OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated OFINIFile with the contents of the
* specified file.
*
* @param URI The URI to the file whose contents the OFINIFile should contain
* @param IRI The IRI to the file whose contents the OFINIFile should contain
*
* @return An initialized OFINIFile with the contents of the specified file
* @throw OFInvalidFormatException The format of the specified INI file is
* invalid
* @throw OFInvalidEncodingException The INI file is not in the specified
* encoding
*/
- (instancetype)initWithURI: (OFURI *)URI;
- (instancetype)initWithIRI: (OFIRI *)IRI;
/**
* @brief Initializes an already allocated OFINIFile with the contents of the
* specified file in the specified encoding.
*
* @param URI The URI to the file whose contents the OFINIFile should contain
* @param IRI The IRI to the file whose contents the OFINIFile should contain
* @param encoding The encoding of the specified file
* @return An initialized OFINIFile with the contents of the specified file
* @throw OFInvalidFormatException The format of the specified INI file is
* invalid
* @throw OFInvalidEncodingException The INI file is not in the specified
* encoding
*/
- (instancetype)initWithURI: (OFURI *)URI
- (instancetype)initWithIRI: (OFIRI *)IRI
encoding: (OFStringEncoding)encoding
OF_DESIGNATED_INITIALIZER;
/**
* @brief Returns an @ref OFINICategory for the category with the specified
* name.
*
* @param name The name of the category for which an @ref OFINICategory should
* be returned
*
* @return An @ref OFINICategory for the category with the specified name
*/
- (OFINICategory *)categoryForName: (OFString *)name;
/**
* @brief Writes the contents of the OFINIFile to a file.
*
* @param URI The URI of the file to write to
* @param IRI The IRI of the file to write to
*/
- (void)writeToURI: (OFURI *)URI;
- (void)writeToIRI: (OFIRI *)IRI;
/**
* @brief Writes the contents of the OFINIFile to a file in the specified
* encoding.
*
* @param URI The URI of the file to write to
* @param IRI The IRI of the file to write to
* @param encoding The encoding to use
*/
- (void)writeToURI: (OFURI *)URI encoding: (OFStringEncoding)encoding;
- (void)writeToIRI: (OFIRI *)IRI encoding: (OFStringEncoding)encoding;
@end
OF_ASSUME_NONNULL_END
|
Modified src/OFINIFile.m
from [7850530cf1]
to [462321b787].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
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
|
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
|
-
-
-
-
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
#include <errno.h>
#import "OFINIFile.h"
#import "OFArray.h"
#import "OFINICategory+Private.h"
#import "OFINICategory.h"
#import "OFStream.h"
#import "OFString.h"
#import "OFURI.h"
#import "OFURIHandler.h"
#import "OFIRI.h"
#import "OFIRIHandler.h"
#import "OFStream.h"
#import "OFString.h"
#import "OFInvalidFormatException.h"
#import "OFOpenItemFailedException.h"
OF_DIRECT_MEMBERS
@interface OFINIFile ()
- (void)of_parseURI: (OFURI *)URI encoding: (OFStringEncoding)encoding;
- (void)of_parseIRI: (OFIRI *)IRI encoding: (OFStringEncoding)encoding;
@end
static bool
isWhitespaceLine(OFString *line)
{
const char *cString = line.UTF8String;
size_t length = line.UTF8StringLength;
for (size_t i = 0; i < length; i++)
if (!OFASCIIIsSpace(cString[i]))
return false;
return true;
}
@implementation OFINIFile
@synthesize categories = _categories;
+ (instancetype)fileWithURI: (OFURI *)URI
+ (instancetype)fileWithIRI: (OFIRI *)IRI
{
return [[[self alloc] initWithURI: URI] autorelease];
return [[[self alloc] initWithIRI: IRI] autorelease];
}
+ (instancetype)fileWithURI: (OFURI *)URI encoding: (OFStringEncoding)encoding
+ (instancetype)fileWithIRI: (OFIRI *)IRI encoding: (OFStringEncoding)encoding
{
return [[[self alloc] initWithURI: URI encoding: encoding] autorelease];
return [[[self alloc] initWithIRI: IRI encoding: encoding] autorelease];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithURI: (OFURI *)URI
- (instancetype)initWithIRI: (OFIRI *)IRI
{
return [self initWithURI: URI encoding: OFStringEncodingAutodetect];
return [self initWithIRI: IRI encoding: OFStringEncodingAutodetect];
}
- (instancetype)initWithURI: (OFURI *)URI encoding: (OFStringEncoding)encoding
- (instancetype)initWithIRI: (OFIRI *)IRI encoding: (OFStringEncoding)encoding
{
self = [super init];
@try {
_categories = [[OFMutableArray alloc] init];
[self of_parseURI: URI encoding: encoding];
[self of_parseIRI: IRI encoding: encoding];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
|
︙ | | |
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
|
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
|
-
+
-
+
|
[_categories addObject: category];
objc_autoreleasePoolPop(pool);
return category;
}
- (void)of_parseURI: (OFURI *)URI encoding: (OFStringEncoding)encoding
- (void)of_parseIRI: (OFIRI *)IRI encoding: (OFStringEncoding)encoding
{
void *pool = objc_autoreleasePoolPush();
OFStream *file;
OFINICategory *category = nil;
OFString *line;
if (encoding == OFStringEncodingAutodetect)
encoding = OFStringEncodingUTF8;
@try {
file = [OFURIHandler openItemAtURI: URI mode: @"r"];
file = [OFIRIHandler openItemAtIRI: IRI mode: @"r"];
} @catch (OFOpenItemFailedException *e) {
/* Handle missing file like an empty file */
if (e.errNo == ENOENT)
return;
@throw e;
}
|
︙ | | |
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
-
+
-
+
-
+
-
+
|
[category of_parseLine: line];
}
}
objc_autoreleasePoolPop(pool);
}
- (void)writeToURI: (OFURI *)URI
- (void)writeToIRI: (OFIRI *)IRI
{
[self writeToURI: URI encoding: OFStringEncodingUTF8];
[self writeToIRI: IRI encoding: OFStringEncodingUTF8];
}
- (void)writeToURI: (OFURI *)URI encoding: (OFStringEncoding)encoding
- (void)writeToIRI: (OFIRI *)IRI encoding: (OFStringEncoding)encoding
{
void *pool = objc_autoreleasePoolPush();
OFStream *file = [OFURIHandler openItemAtURI: URI mode: @"w"];
OFStream *file = [OFIRIHandler openItemAtIRI: IRI mode: @"w"];
bool first = true;
for (OFINICategory *category in _categories)
if ([category of_writeToStream: file
encoding: encoding
first: first])
first = false;
|
︙ | | |
Modified src/OFINIFileSettings.h
from [125e92a3e8]
to [a0a2ba7635].
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
|
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
|
-
+
-
-
+
+
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFSettings.h"
OF_ASSUME_NONNULL_BEGIN
@class OFINIFile;
@class OFString;
@class OFURI;
@class OFIRI;
@class OFString;
@interface OFINIFileSettings: OFSettings
{
OFURI *_fileURI;
OFIRI *_fileIRI;
OFINIFile *_INIFile;
}
@end
OF_ASSUME_NONNULL_END
|
Modified src/OFINIFileSettings.m
from [b3d1a39e2b]
to [1fd7fce291].
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
|
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
|
-
+
-
-
-
+
+
+
-
-
-
+
+
+
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#import "OFINIFileSettings.h"
#import "OFArray.h"
#import "OFINIFile.h"
#import "OFString.h"
#import "OFSystemInfo.h"
#import "OFURI.h"
#import "OFIRI.h"
#import "OFString.h"
#import "OFSystemInfo.h"
@implementation OFINIFileSettings
- (instancetype)initWithApplicationName: (OFString *)applicationName
{
self = [super initWithApplicationName: applicationName];
@try {
void *pool = objc_autoreleasePoolPush();
OFString *fileName;
fileName = [applicationName stringByAppendingString: @".ini"];
_fileURI = [[[OFSystemInfo userConfigURI]
URIByAppendingPathComponent: fileName] copy];
_INIFile = [[OFINIFile alloc] initWithURI: _fileURI];
_fileIRI = [[[OFSystemInfo userConfigIRI]
IRIByAppendingPathComponent: fileName] copy];
_INIFile = [[OFINIFile alloc] initWithIRI: _fileIRI];
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[_fileURI release];
[_fileIRI release];
[_INIFile release];
[super dealloc];
}
- (void)of_getCategory: (OFString **)category
andKey: (OFString **)key
|
︙ | | |
239
240
241
242
243
244
245
246
247
248
|
239
240
241
242
243
244
245
246
247
248
|
-
+
|
[[_INIFile categoryForName: category] removeValueForKey: key];
objc_autoreleasePoolPop(pool);
}
- (void)save
{
[_INIFile writeToURI: _fileURI];
[_INIFile writeToIRI: _fileIRI];
}
@end
|
Modified src/OFIPXSocket.h
from [8dc615311a]
to [6b971bfd5b].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
-
+
|
* @class OFIPXSocket OFIPXSocket.h ObjFW/OFIPXSocket.h
*
* @brief A class which provides methods to create and use IPX sockets.
*
* Addresses are of type @ref OFSocketAddress. You can use
* @ref OFSocketAddressMakeIPX to create an address or
* @ref OFSocketAddressIPXNetwork to get the IPX network,
* @ref OFSocketAddressIPXNode to get the IPX node and
* @ref OFSocketAddressGetIPXNode to get the IPX node and
* @ref OFSocketAddressIPXPort to get the port (sometimes also called
* socket number).
*
* @warning Even though the OFCopying protocol is implemented, it does *not*
* return an independent copy of the socket, but instead retains it.
* This is so that the socket can be used as a key for a dictionary,
* so context can be associated with a socket. Using a socket in more
|
︙ | | |
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
-
+
|
* @param node The IPX network to bind to. An all zero node means the
* computer's node.
* @param port The port (sometimes called socket number) to bind to. 0 means to
* pick one and return via the returned socket address.
* @param packetType The packet type to use on the socket
* @return The address on which this socket can be reached
* @throw OFBindIPXSocketFailedException Binding failed
* @throw OFAlreadyConnectedException The socket is already bound
* @throw OFAlreadyOpenException The socket is already bound
*/
- (OFSocketAddress)
bindToNetwork: (uint32_t)network
node: (const unsigned char [_Nonnull IPX_NODE_LEN])node
port: (uint16_t)port
packetType: (uint8_t)packetType;
@end
OF_ASSUME_NONNULL_END
|
Modified src/OFIPXSocket.m
from [1dc137a6b3]
to [137cbc4465].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
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
|
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
|
-
+
+
+
+
+
-
+
-
+
|
# include <fcntl.h>
#endif
#import "OFIPXSocket.h"
#import "OFSocket.h"
#import "OFSocket+Private.h"
#import "OFAlreadyConnectedException.h"
#import "OFAlreadyOpenException.h"
#import "OFBindIPXSocketFailedException.h"
#ifndef NSPROTO_IPX
# define NSPROTO_IPX 0
#endif
@implementation OFIPXSocket
@dynamic delegate;
- (OFSocketAddress)bindToNetwork: (uint32_t)network
node: (const unsigned char [IPX_NODE_LEN])node
port: (uint16_t)port
packetType: (uint8_t)packetType
{
OFSocketAddress address;
int protocol = 0;
#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC)
int flags;
#endif
if (_socket != OFInvalidSocketHandle)
@throw [OFAlreadyConnectedException exceptionWithSocket: self];
@throw [OFAlreadyOpenException exceptionWithObject: self];
address = OFSocketAddressMakeIPX(network, node, port);
#ifdef OF_WINDOWS
#if defined(OF_WINDOWS) || defined(OF_FREEBSD)
protocol = NSPROTO_IPX + packetType;
#else
_packetType = address.sockaddr.ipx.sipx_type = packetType;
#endif
if ((_socket = socket(address.sockaddr.ipx.sipx_family,
SOCK_DGRAM | SOCK_CLOEXEC, protocol)) == OFInvalidSocketHandle)
|
︙ | | |
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
-
+
|
socket: self
errNo: EAFNOSUPPORT];
}
return address;
}
#ifndef OF_WINDOWS
#if !defined(OF_WINDOWS) && !defined(OF_FREEBSD)
- (void)sendBuffer: (const void *)buffer
length: (size_t)length
receiver: (const OFSocketAddress *)receiver
{
OFSocketAddress fixedReceiver;
memcpy(&fixedReceiver, receiver, sizeof(fixedReceiver));
|
︙ | | |
Renamed and modified
src/OFURI+Private.h
[c5dc8bc44b]
to src/OFIRI+Private.h
[89abd85c72].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
-
+
-
+
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFURI.h"
#import "OFIRI.h"
OF_ASSUME_NONNULL_BEGIN
@interface OFURI ()
@interface OFIRI ()
- (instancetype)of_init OF_METHOD_FAMILY(init);
@end
OF_ASSUME_NONNULL_END
|
Renamed and modified
src/OFURI.h
[90c837e175]
to src/OFIRI.h
[659e656a72].
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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
|
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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
|
-
+
-
-
+
+
-
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
+
+
+
+
+
-
+
+
-
+
-
+
-
+
-
-
-
+
+
+
-
+
-
-
+
+
-
-
-
-
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
+
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFObject.h"
#import "OFCharacterSet.h"
#import "OFSerialization.h"
OF_ASSUME_NONNULL_BEGIN
@class OFArray OF_GENERIC(ObjectType);
@class OFDictionary OF_GENERIC(KeyType, ObjectType);
@class OFNumber;
@class OFPair OF_GENERIC(FirstType, SecondType);
@class OFString;
/**
* @class OFURI OFURI.h ObjFW/OFURI.h
* @class OFIRI OFIRI.h ObjFW/OFIRI.h
*
* @brief A class for representing IRIs, URIs, URLs and URNs, for parsing them
* @brief A class for parsing URIs as per RFC 3986 and accessing parts of it.
* as well as accessing parts of them.
*
* This class follows RFC 3976 and RFC 3987.
*/
@interface OFURI: OFObject <OFCopying, OFMutableCopying, OFSerialization>
@interface OFIRI: OFObject <OFCopying, OFMutableCopying>
{
OFString *_scheme;
OFString *_Nullable _percentEncodedHost;
OFNumber *_Nullable _port;
OFString *_Nullable _percentEncodedUser;
OFString *_Nullable _percentEncodedPassword;
OFString *_percentEncodedPath;
OFString *_Nullable _percentEncodedQuery;
OFString *_Nullable _percentEncodedFragment;
OF_RESERVE_IVARS(OFURI, 4)
OF_RESERVE_IVARS(OFIRI, 4)
}
/**
* @brief The scheme part of the URI.
* @brief The scheme part of the IRI.
*/
@property (readonly, copy, nonatomic) OFString *scheme;
/**
* @brief The host part of the URI.
* @brief The host part of the IRI.
*/
@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *host;
/**
* @brief The host part of the URI in percent-encoded form.
* @brief The host part of the IRI in percent-encoded form.
*/
@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
OFString *percentEncodedHost;
/**
* @brief The port part of the URI.
* @brief The port part of the IRI.
*/
@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFNumber *port;
/**
* @brief The user part of the URI.
* @brief The user part of the IRI.
*/
@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *user;
/**
* @brief The user part of the URI in percent-encoded form.
* @brief The user part of the IRI in percent-encoded form.
*/
@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
OFString *percentEncodedUser;
/**
* @brief The password part of the URI.
* @brief The password part of the IRI.
*/
@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *password;
/**
* @brief The password part of the URI in percent-encoded form.
* @brief The password part of the IRI in percent-encoded form.
*/
@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
OFString *percentEncodedPassword;
/**
* @brief The path part of the URI.
* @brief The path part of the IRI.
*/
@property (readonly, copy, nonatomic) OFString *path;
/**
* @brief The path part of the URI in percent-encoded form.
* @brief The path part of the IRI in percent-encoded form.
*/
@property (readonly, copy, nonatomic) OFString *percentEncodedPath;
/**
* @brief The path of the URI split into components.
* @brief The path of the IRI split into components.
*
* The first component must always be `/` to designate the root.
*/
@property (readonly, copy, nonatomic)
OFArray OF_GENERIC(OFString *) *pathComponents;
/**
* @brief The last path component of the URI.
* @brief The last path component of the IRI.
*
* Returns the empty string if the path is the root.
*/
@property (readonly, copy, nonatomic) OFString *lastPathComponent;
/**
* @brief The query part of the URI.
* @brief The query part of the IRI.
*/
@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *query;
/**
* @brief The query part of the URI in percent-encoded form.
* @brief The query part of the IRI in percent-encoded form.
*/
@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
OFString *percentEncodedQuery;
/**
* @brief The query part of the URI as an array.
* @brief The query part of the IRI as an array.
*
* For example, a query like `key1=value1&key2=value2` would correspond to the
* following array:
*
* @[
* [OFPair pairWithFirstObject: @"key1" secondObject: @"value1"],
* [OFPair pairWithFirstObject: @"key2" secondObject: @"value2"],
* ]
*
* @throw OFInvalidFormatException The query is not in the correct format
*/
@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
OFArray OF_GENERIC(OFPair OF_GENERIC(OFString *, OFString *) *) *queryItems;
/**
* @brief The fragment part of the URI.
* @brief The fragment part of the IRI.
*/
@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *fragment;
/**
* @brief The fragment part of the URI in URI-encoded form.
* @brief The fragment part of the IRI in percent-encoded form.
*/
@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
OFString *percentEncodedFragment;
/**
* @brief The URI as a string.
* @brief The IRI as a string.
*/
@property (readonly, nonatomic) OFString *string;
/**
* @brief The URI with relative subpaths resolved.
* @brief The IRI with relative subpaths resolved.
*/
@property (readonly, nonatomic) OFIRI *IRIByStandardizingPath;
/**
* @brief The IRI with percent-encoding added for all Unicode characters.
*/
@property (readonly, nonatomic) OFURI *URIByStandardizingPath;
@property (readonly, nonatomic)
OFIRI *IRIByAddingPercentEncodingForUnicodeCharacters;
#ifdef OF_HAVE_FILES
/**
* @brief The local file system representation for a file URI.
* @brief The local file system representation for a file IRI.
*
* @note This only exists for URIs with the file scheme and throws an exception
* @note This only exists for IRIs with the file scheme and throws an exception
* otherwise.
*/
@property OF_NULLABLE_PROPERTY (readonly, nonatomic)
OFString *fileSystemRepresentation;
#endif
/**
* @brief Creates a new URI with the specified string.
* @brief Creates a new IRI with the specified string.
*
* @param string A string describing a URI
* @return A new, autoreleased OFURI
* @throw OFInvalidFormatException The specified string is not a valid URI
* @param string A string describing an IRI
* @return A new, autoreleased OFIRI
* @throw OFInvalidFormatException The specified string is not a valid IRI
* string
*/
+ (instancetype)URIWithString: (OFString *)string;
+ (instancetype)IRIWithString: (OFString *)string;
/**
* @brief Creates a new URI with the specified string relative to the
* specified URI.
* @brief Creates a new IRI with the specified string relative to the
* specified IRI.
*
* @param string A string describing a relative or absolute URI
* @param URI An URI to which the string is relative
* @return A new, autoreleased OFURI
* @throw OFInvalidFormatException The specified string is not a valid URI
* @param string A string describing a relative or absolute IRI
* @param IRI An IRI to which the string is relative
* @return A new, autoreleased OFIRI
* @throw OFInvalidFormatException The specified string is not a valid IRI
* string
*/
+ (instancetype)URIWithString: (OFString *)string relativeToURI: (OFURI *)URI;
+ (instancetype)IRIWithString: (OFString *)string relativeToIRI: (OFIRI *)IRI;
#ifdef OF_HAVE_FILES
/**
* @brief Creates a new URI with the specified local file path.
* @brief Creates a new IRI with the specified local file path.
*
* If a directory exists at the specified path, a slash is appended if there is
* no slash yet.
*
* @param path The local file path
* @return A new, autoreleased OFURI
* @return A new, autoreleased OFIRI
* @throw OFInvalidFormatException The specified path is not a valid path
*/
+ (instancetype)fileURIWithPath: (OFString *)path;
+ (instancetype)fileIRIWithPath: (OFString *)path;
/**
* @brief Creates a new URI with the specified local file path.
* @brief Creates a new IRI with the specified local file path.
*
* @param path The local file path
* @param isDirectory Whether the path is a directory, in which case a slash is
* appened if there is no slash yet
* @return An initialized OFURI
* @return An initialized OFIRI
*/
+ (instancetype)fileURIWithPath: (OFString *)path
+ (instancetype)fileIRIWithPath: (OFString *)path
isDirectory: (bool)isDirectory;
#endif
/**
* @brief Initializes an already allocated OFURI with the specified string.
* @brief Initializes an already allocated OFIRI with the specified string.
*
* @param string A string describing a URI
* @return An initialized OFURI
* @throw OFInvalidFormatException The specified string is not a valid URI
* @param string A string describing an IRI
* @return An initialized OFIRI
* @throw OFInvalidFormatException The specified string is not a valid IRI
* string
*/
- (instancetype)initWithString: (OFString *)string;
/**
* @brief Initializes an already allocated OFURI with the specified string and
* relative URI.
* @brief Initializes an already allocated OFIRI with the specified string and
* relative IRI.
*
* @param string A string describing a relative or absolute URI
* @param URI A URI to which the string is relative
* @return An initialized OFURI
* @throw OFInvalidFormatException The specified string is not a valid URI
* @param string A string describing a relative or absolute IRI
* @param IRI An IRI to which the string is relative
* @return An initialized OFIRI
* @throw OFInvalidFormatException The specified string is not a valid IRI
* string
*/
- (instancetype)initWithString: (OFString *)string relativeToURI: (OFURI *)URI;
- (instancetype)initWithString: (OFString *)string relativeToIRI: (OFIRI *)IRI;
#ifdef OF_HAVE_FILES
/**
* @brief Initializes an already allocated OFURI with the specified local file
* @brief Initializes an already allocated OFIRI with the specified local file
* path.
*
* If a directory exists at the specified path, a slash is appended if there is
* no slash yet.
*
* @param path The local file path
* @return An initialized OFURI
* @return An initialized OFIRI
* @throw OFInvalidFormatException The specified path is not a valid path
*/
- (instancetype)initFileURIWithPath: (OFString *)path;
- (instancetype)initFileIRIWithPath: (OFString *)path;
/**
* @brief Initializes an already allocated OFURI with the specified local file
* @brief Initializes an already allocated OFIRI with the specified local file
* path.
*
* @param path The local file path
* @param isDirectory Whether the path is a directory, in which case a slash is
* appened if there is no slash yet
* @return An initialized OFURI
* @return An initialized OFIRI
*/
- (instancetype)initFileURIWithPath: (OFString *)path
- (instancetype)initFileIRIWithPath: (OFString *)path
isDirectory: (bool)isDirectory;
#endif
- (instancetype)init OF_UNAVAILABLE;
/**
* @brief Returns a new URI with the specified path component appended.
* @brief Returns a new IRI with the specified path component appended.
*
* If the URI is a file URI, the file system is queried whether the appended
* If the IRI is a file IRI, the file system is queried whether the appended
* component is a directory.
*
* @param component The path component to append. If it starts with the slash,
* the component is not appended, but replaces the path
* instead.
* @return A new URI with the specified path component appended
* @return A new IRI with the specified path component appended
*/
- (OFURI *)URIByAppendingPathComponent: (OFString *)component;
- (OFIRI *)IRIByAppendingPathComponent: (OFString *)component;
/**
* @brief Returns a new URI with the specified path component appended.
* @brief Returns a new IRI with the specified path component appended.
*
* @param component The path component to append. If it starts with the slash,
* the component is not appended, but replaces the path
* instead.
* @param isDirectory Whether the appended component is a directory, meaning
* that the URI path should have a trailing slash
* @return A new URI with the specified path component appended
* that the IRI path should have a trailing slash
* @return A new IRI with the specified path component appended
*/
- (OFURI *)URIByAppendingPathComponent: (OFString *)component
- (OFIRI *)IRIByAppendingPathComponent: (OFString *)component
isDirectory: (bool)isDirectory;
@end
@interface OFCharacterSet (URICharacterSets)
@interface OFCharacterSet (IRICharacterSets)
#ifdef OF_HAVE_CLASS_PROPERTIES
@property (class, readonly, nonatomic)
OFCharacterSet *URISchemeAllowedCharacterSet;
OFCharacterSet *IRISchemeAllowedCharacterSet;
@property (class, readonly, nonatomic)
OFCharacterSet *URIHostAllowedCharacterSet;
OFCharacterSet *IRIHostAllowedCharacterSet;
@property (class, readonly, nonatomic)
OFCharacterSet *URIUserAllowedCharacterSet;
OFCharacterSet *IRIUserAllowedCharacterSet;
@property (class, readonly, nonatomic)
OFCharacterSet *URIPasswordAllowedCharacterSet;
OFCharacterSet *IRIPasswordAllowedCharacterSet;
@property (class, readonly, nonatomic)
OFCharacterSet *URIPathAllowedCharacterSet;
OFCharacterSet *IRIPathAllowedCharacterSet;
@property (class, readonly, nonatomic)
OFCharacterSet *URIQueryAllowedCharacterSet;
OFCharacterSet *IRIQueryAllowedCharacterSet;
@property (class, readonly, nonatomic)
OFCharacterSet *URIQueryKeyValueAllowedCharacterSet;
OFCharacterSet *IRIQueryKeyValueAllowedCharacterSet;
@property (class, readonly, nonatomic)
OFCharacterSet *URIFragmentAllowedCharacterSet;
OFCharacterSet *IRIFragmentAllowedCharacterSet;
#endif
/**
* @brief Returns the characters allowed in the scheme part of a URI.
* @brief Returns the characters allowed in the scheme part of an IRI.
*
* @return The characters allowed in the scheme part of a URI.
* @return The characters allowed in the scheme part of an IRI.
*/
+ (OFCharacterSet *)URISchemeAllowedCharacterSet;
+ (OFCharacterSet *)IRISchemeAllowedCharacterSet;
/**
* @brief Returns the characters allowed in the host part of a URI.
* @brief Returns the characters allowed in the host part of an IRI.
*
* @return The characters allowed in the host part of a URI.
* @return The characters allowed in the host part of an IRI.
*/
+ (OFCharacterSet *)URIHostAllowedCharacterSet;
+ (OFCharacterSet *)IRIHostAllowedCharacterSet;
/**
* @brief Returns the characters allowed in the user part of a URI.
* @brief Returns the characters allowed in the user part of an IRI.
*
* @return The characters allowed in the user part of a URI.
* @return The characters allowed in the user part of an IRI.
*/
+ (OFCharacterSet *)URIUserAllowedCharacterSet;
+ (OFCharacterSet *)IRIUserAllowedCharacterSet;
/**
* @brief Returns the characters allowed in the password part of a URI.
* @brief Returns the characters allowed in the password part of an IRI.
*
* @return The characters allowed in the password part of a URI.
* @return The characters allowed in the password part of an IRI.
*/
+ (OFCharacterSet *)URIPasswordAllowedCharacterSet;
+ (OFCharacterSet *)IRIPasswordAllowedCharacterSet;
/**
* @brief Returns the characters allowed in the path part of a URI.
* @brief Returns the characters allowed in the path part of an IRI.
*
* @return The characters allowed in the path part of a URI.
* @return The characters allowed in the path part of an IRI.
*/
+ (OFCharacterSet *)URIPathAllowedCharacterSet;
+ (OFCharacterSet *)IRIPathAllowedCharacterSet;
/**
* @brief Returns the characters allowed in the query part of a URI.
* @brief Returns the characters allowed in the query part of an IRI.
*
* @return The characters allowed in the query part of a URI.
* @return The characters allowed in the query part of an IRI.
*/
+ (OFCharacterSet *)URIQueryAllowedCharacterSet;
+ (OFCharacterSet *)IRIQueryAllowedCharacterSet;
/**
* @brief Returns the characters allowed in a key/value in the query part of a
* URI.
* IRI.
*
* @return The characters allowed in a key/value in the query part of a URI.
* @return The characters allowed in a key/value in the query part of an IRI.
*/
+ (OFCharacterSet *)URIQueryKeyValueAllowedCharacterSet;
+ (OFCharacterSet *)IRIQueryKeyValueAllowedCharacterSet;
/**
* @brief Returns the characters allowed in the fragment part of a URI.
* @brief Returns the characters allowed in the fragment part of an IRI.
*
* @return The characters allowed in the fragment part of a URI.
* @return The characters allowed in the fragment part of an IRI.
*/
+ (OFCharacterSet *)URIFragmentAllowedCharacterSet;
+ (OFCharacterSet *)IRIFragmentAllowedCharacterSet;
@end
#ifdef __cplusplus
extern "C" {
#endif
extern bool OFURIIsIPv6Host(OFString *host);
extern void OFURIVerifyIsEscaped(OFString *, OFCharacterSet *, bool);
extern bool OFIRIIsIPv6Host(OFString *host);
extern void OFIRIVerifyIsEscaped(OFString *, OFCharacterSet *, bool);
#ifdef __cplusplus
}
#endif
OF_ASSUME_NONNULL_END
#import "OFMutableURI.h"
#import "OFMutableIRI.h"
|
Renamed and modified
src/OFURI.m
[fd812a6a57]
to src/OFIRI.m
[fdb5d156bf].
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
|
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
|
-
+
-
+
-
+
-
-
+
-
+
-
+
-
+
-
+
-
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
-
+
-
-
-
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
+
+
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#import "OFURI.h"
#import "OFIRI.h"
#import "OFArray.h"
#import "OFDictionary.h"
#ifdef OF_HAVE_FILES
# import "OFFileManager.h"
# import "OFFileURIHandler.h"
# import "OFFileIRIHandler.h"
#endif
#import "OFNumber.h"
#import "OFOnce.h"
#import "OFPair.h"
#import "OFString.h"
#import "OFXMLElement.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFOutOfMemoryException.h"
@interface OFURIAllowedCharacterSetBase: OFCharacterSet
@interface OFIRIAllowedCharacterSetBase: OFCharacterSet
@end
@interface OFURIAllowedCharacterSet: OFURIAllowedCharacterSetBase
@interface OFIRIAllowedCharacterSet: OFIRIAllowedCharacterSetBase
@end
@interface OFURISchemeAllowedCharacterSet: OFURIAllowedCharacterSetBase
@interface OFIRISchemeAllowedCharacterSet: OFIRIAllowedCharacterSetBase
@end
@interface OFURIPathAllowedCharacterSet: OFURIAllowedCharacterSetBase
@interface OFIRIPathAllowedCharacterSet: OFIRIAllowedCharacterSetBase
@end
@interface OFURIQueryOrFragmentAllowedCharacterSet: OFURIAllowedCharacterSetBase
@interface OFIRIQueryAllowedCharacterSet: OFIRIAllowedCharacterSetBase
@end
@interface OFURIQueryKeyValueAllowedCharacterSet: OFURIAllowedCharacterSetBase
@interface OFIRIQueryKeyValueAllowedCharacterSet: OFIRIAllowedCharacterSetBase
@end
@interface OFIRIFragmentAllowedCharacterSet: OFIRIAllowedCharacterSetBase
@end
OF_DIRECT_MEMBERS
@interface OFInvertedCharacterSetWithoutPercent: OFCharacterSet
{
OFCharacterSet *_characterSet;
bool (*_characterIsMember)(id, SEL, OFUnichar);
}
- (instancetype)initWithCharacterSet: (OFCharacterSet *)characterSet;
@end
static OFCharacterSet *URIAllowedCharacterSet = nil;
static OFCharacterSet *URISchemeAllowedCharacterSet = nil;
static OFCharacterSet *URIPathAllowedCharacterSet = nil;
static OFCharacterSet *URIQueryOrFragmentAllowedCharacterSet = nil;
static OFCharacterSet *URIQueryKeyValueAllowedCharacterSet = nil;
static OFCharacterSet *IRIAllowedCharacterSet = nil;
static OFCharacterSet *IRISchemeAllowedCharacterSet = nil;
static OFCharacterSet *IRIPathAllowedCharacterSet = nil;
static OFCharacterSet *IRIQueryAllowedCharacterSet = nil;
static OFCharacterSet *IRIQueryKeyValueAllowedCharacterSet = nil;
static OFCharacterSet *IRIFragmentAllowedCharacterSet = nil;
static OFOnceControl URIAllowedCharacterSetOnce = OFOnceControlInitValue;
static OFOnceControl IRIAllowedCharacterSetOnce = OFOnceControlInitValue;
static OFOnceControl URIQueryOrFragmentAllowedCharacterSetOnce =
OFOnceControlInitValue;
static void
initURIAllowedCharacterSet(void)
initIRIAllowedCharacterSet(void)
{
URIAllowedCharacterSet = [[OFURIAllowedCharacterSet alloc] init];
IRIAllowedCharacterSet = [[OFIRIAllowedCharacterSet alloc] init];
}
static void
initURISchemeAllowedCharacterSet(void)
initIRISchemeAllowedCharacterSet(void)
{
URISchemeAllowedCharacterSet =
[[OFURISchemeAllowedCharacterSet alloc] init];
IRISchemeAllowedCharacterSet =
[[OFIRISchemeAllowedCharacterSet alloc] init];
}
static void
initURIPathAllowedCharacterSet(void)
initIRIPathAllowedCharacterSet(void)
{
URIPathAllowedCharacterSet =
[[OFURIPathAllowedCharacterSet alloc] init];
IRIPathAllowedCharacterSet =
[[OFIRIPathAllowedCharacterSet alloc] init];
}
static void
initURIQueryOrFragmentAllowedCharacterSet(void)
initIRIQueryAllowedCharacterSet(void)
{
URIQueryOrFragmentAllowedCharacterSet =
[[OFURIQueryOrFragmentAllowedCharacterSet alloc] init];
IRIQueryAllowedCharacterSet =
[[OFIRIQueryAllowedCharacterSet alloc] init];
}
static void
initURIQueryKeyValueAllowedCharacterSet(void)
initIRIQueryKeyValueAllowedCharacterSet(void)
{
URIQueryKeyValueAllowedCharacterSet =
[[OFURIQueryKeyValueAllowedCharacterSet alloc] init];
IRIQueryKeyValueAllowedCharacterSet =
[[OFIRIQueryKeyValueAllowedCharacterSet alloc] init];
}
static void
initIRIFragmentAllowedCharacterSet(void)
{
IRIFragmentAllowedCharacterSet =
[[OFIRIFragmentAllowedCharacterSet alloc] init];
}
bool
OFURIIsIPv6Host(OFString *host)
OFIRIIsIPv6Host(OFString *host)
{
const char *UTF8String = host.UTF8String;
bool hasColon = false;
while (*UTF8String != '\0') {
if (!OFASCIIIsDigit(*UTF8String) && *UTF8String != ':' &&
(*UTF8String < 'a' || *UTF8String > 'f') &&
(*UTF8String < 'A' || *UTF8String > 'F'))
return false;
if (*UTF8String == ':')
hasColon = true;
UTF8String++;
}
return hasColon;
}
static bool
isUnicode(OFUnichar character)
{
if (character >= 0xA0 && character <= 0xD7FF)
return true;
if (character >= 0xF900 && character <= 0xFDCF)
return true;
if (character >= 0xFDF0 && character <= 0xFFEF)
return true;
if (character >= 0x10000 && character <= 0x1FFFD)
return true;
if (character >= 0x20000 && character <= 0x2FFFD)
return true;
if (character >= 0x30000 && character <= 0x3FFFD)
return true;
if (character >= 0x40000 && character <= 0x4FFFD)
return true;
if (character >= 0x50000 && character <= 0x5FFFD)
return true;
if (character >= 0x60000 && character <= 0x6FFFD)
return true;
if (character >= 0x70000 && character <= 0x7FFFD)
return true;
if (character >= 0x80000 && character <= 0x8FFFD)
return true;
if (character >= 0x90000 && character <= 0x9FFFD)
return true;
if (character >= 0xA0000 && character <= 0xAFFFD)
return true;
if (character >= 0xB0000 && character <= 0xBFFFD)
return true;
if (character >= 0xC0000 && character <= 0xCFFFD)
return true;
if (character >= 0xD0000 && character <= 0xDFFFD)
return true;
if (character >= 0xE0000 && character <= 0xEFFFD)
return true;
return false;
}
static bool
isUnicodePrivate(OFUnichar character)
{
if (character >= 0xE00 && character <= 0xF8FF)
return true;
if (character >= 0xF0000 && character <= 0xFFFFD)
return true;
if (character >= 0x100000 && character <= 0x10FFFD)
return true;
return false;
}
@implementation OFURIAllowedCharacterSetBase
@implementation OFIRIAllowedCharacterSetBase
- (instancetype)autorelease
{
return self;
}
- (instancetype)retain
{
return self;
}
- (void)release
{
}
- (unsigned int)retainCount
{
return OFMaxRetainCount;
}
@end
@implementation OFURIAllowedCharacterSet
@implementation OFIRIAllowedCharacterSet
- (bool)characterIsMember: (OFUnichar)character
{
if (character < CHAR_MAX && OFASCIIIsAlnum(character))
return true;
if (isUnicode(character))
return true;
switch (character) {
case '-':
case '.':
case '_':
case '~':
case '!':
|
︙ | | |
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
|
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
274
275
276
277
|
-
+
-
+
+
+
+
|
return true;
default:
return false;
}
}
@end
@implementation OFURISchemeAllowedCharacterSet
@implementation OFIRISchemeAllowedCharacterSet
- (bool)characterIsMember: (OFUnichar)character
{
if (character < CHAR_MAX && OFASCIIIsAlnum(character))
return true;
switch (character) {
case '+':
case '-':
case '.':
return true;
default:
return false;
}
}
@end
@implementation OFURIPathAllowedCharacterSet
@implementation OFIRIPathAllowedCharacterSet
- (bool)characterIsMember: (OFUnichar)character
{
if (character < CHAR_MAX && OFASCIIIsAlnum(character))
return true;
if (isUnicode(character))
return true;
switch (character) {
case '-':
case '.':
case '_':
case '~':
case '!':
|
︙ | | |
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
|
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
|
-
+
+
+
+
|
return true;
default:
return false;
}
}
@end
@implementation OFURIQueryOrFragmentAllowedCharacterSet
@implementation OFIRIQueryAllowedCharacterSet
- (bool)characterIsMember: (OFUnichar)character
{
if (character < CHAR_MAX && OFASCIIIsAlnum(character))
return true;
if (isUnicode(character) || isUnicodePrivate(character))
return true;
switch (character) {
case '-':
case '.':
case '_':
case '~':
case '!':
|
︙ | | |
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
|
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
|
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
return true;
default:
return false;
}
}
@end
@implementation OFURIQueryKeyValueAllowedCharacterSet
@implementation OFIRIQueryKeyValueAllowedCharacterSet
- (bool)characterIsMember: (OFUnichar)character
{
if (character < CHAR_MAX && OFASCIIIsAlnum(character))
return true;
if (isUnicode(character) || isUnicodePrivate(character))
return true;
switch (character) {
case '-':
case '.':
case '_':
case '~':
case '!':
case '$':
case '\'':
case '(':
case ')':
case '*':
case '+':
case ',':
case ';':
case ':':
case '@':
case '/':
case '?':
return true;
default:
return false;
}
}
@end
@implementation OFIRIFragmentAllowedCharacterSet
- (bool)characterIsMember: (OFUnichar)character
{
if (character < CHAR_MAX && OFASCIIIsAlnum(character))
return true;
if (isUnicode(character))
return true;
switch (character) {
case '-':
case '.':
case '_':
case '~':
case '!':
case '$':
case '&':
case '\'':
case '(':
case ')':
case '*':
case '+':
case ',':
case ';':
case '=':
case ':':
case '@':
case '/':
case '?':
return true;
default:
return false;
|
︙ | | |
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
|
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
|
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
-
+
-
+
-
+
-
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
+
|
{
return (character != '%' && !_characterIsMember(_characterSet,
@selector(characterIsMember:), character));
}
@end
void
OFURIVerifyIsEscaped(OFString *string, OFCharacterSet *characterSet,
OFIRIVerifyIsEscaped(OFString *string, OFCharacterSet *characterSet,
bool allowPercent)
{
void *pool = objc_autoreleasePoolPush();
if (allowPercent)
characterSet = [[[OFInvertedCharacterSetWithoutPercent alloc]
initWithCharacterSet: characterSet] autorelease];
else
characterSet = characterSet.invertedSet;
if ([string indexOfCharacterFromSet: characterSet] != OFNotFound)
@throw [OFInvalidFormatException exception];
objc_autoreleasePoolPop(pool);
}
@implementation OFCharacterSet (URICharacterSets)
+ (OFCharacterSet *)URISchemeAllowedCharacterSet
@implementation OFCharacterSet (IRICharacterSets)
+ (OFCharacterSet *)IRISchemeAllowedCharacterSet
{
static OFOnceControl onceControl = OFOnceControlInitValue;
OFOnce(&onceControl, initURISchemeAllowedCharacterSet);
OFOnce(&onceControl, initIRISchemeAllowedCharacterSet);
return URISchemeAllowedCharacterSet;
return IRISchemeAllowedCharacterSet;
}
+ (OFCharacterSet *)URIHostAllowedCharacterSet
+ (OFCharacterSet *)IRIHostAllowedCharacterSet
{
OFOnce(&URIAllowedCharacterSetOnce, initURIAllowedCharacterSet);
OFOnce(&IRIAllowedCharacterSetOnce, initIRIAllowedCharacterSet);
return URIAllowedCharacterSet;
return IRIAllowedCharacterSet;
}
+ (OFCharacterSet *)URIUserAllowedCharacterSet
+ (OFCharacterSet *)IRIUserAllowedCharacterSet
{
OFOnce(&URIAllowedCharacterSetOnce, initURIAllowedCharacterSet);
OFOnce(&IRIAllowedCharacterSetOnce, initIRIAllowedCharacterSet);
return URIAllowedCharacterSet;
return IRIAllowedCharacterSet;
}
+ (OFCharacterSet *)URIPasswordAllowedCharacterSet
+ (OFCharacterSet *)IRIPasswordAllowedCharacterSet
{
OFOnce(&URIAllowedCharacterSetOnce, initURIAllowedCharacterSet);
OFOnce(&IRIAllowedCharacterSetOnce, initIRIAllowedCharacterSet);
return URIAllowedCharacterSet;
return IRIAllowedCharacterSet;
}
+ (OFCharacterSet *)URIPathAllowedCharacterSet
+ (OFCharacterSet *)IRIPathAllowedCharacterSet
{
static OFOnceControl onceControl = OFOnceControlInitValue;
OFOnce(&onceControl, initURIPathAllowedCharacterSet);
OFOnce(&onceControl, initIRIPathAllowedCharacterSet);
return URIPathAllowedCharacterSet;
return IRIPathAllowedCharacterSet;
}
+ (OFCharacterSet *)URIQueryAllowedCharacterSet
+ (OFCharacterSet *)IRIQueryAllowedCharacterSet
{
OFOnce(&URIQueryOrFragmentAllowedCharacterSetOnce,
initURIQueryOrFragmentAllowedCharacterSet);
static OFOnceControl onceControl = OFOnceControlInitValue;
OFOnce(&onceControl, initIRIQueryAllowedCharacterSet);
return URIQueryOrFragmentAllowedCharacterSet;
return IRIQueryAllowedCharacterSet;
}
+ (OFCharacterSet *)URIQueryKeyValueAllowedCharacterSet
+ (OFCharacterSet *)IRIQueryKeyValueAllowedCharacterSet
{
static OFOnceControl onceControl = OFOnceControlInitValue;
OFOnce(&onceControl, initURIQueryKeyValueAllowedCharacterSet);
OFOnce(&onceControl, initIRIQueryKeyValueAllowedCharacterSet);
return URIQueryKeyValueAllowedCharacterSet;
return IRIQueryKeyValueAllowedCharacterSet;
}
+ (OFCharacterSet *)URIFragmentAllowedCharacterSet
+ (OFCharacterSet *)IRIFragmentAllowedCharacterSet
{
OFOnce(&URIQueryOrFragmentAllowedCharacterSetOnce,
initURIQueryOrFragmentAllowedCharacterSet);
static OFOnceControl onceControl = OFOnceControlInitValue;
OFOnce(&onceControl, initIRIFragmentAllowedCharacterSet);
return URIQueryOrFragmentAllowedCharacterSet;
return IRIFragmentAllowedCharacterSet;
}
@end
@implementation OFURI
+ (instancetype)URI
@implementation OFIRI
+ (instancetype)IRI
{
return [[[self alloc] init] autorelease];
}
+ (instancetype)URIWithString: (OFString *)string
+ (instancetype)IRIWithString: (OFString *)string
{
return [[[self alloc] initWithString: string] autorelease];
}
+ (instancetype)URIWithString: (OFString *)string
+ (instancetype)IRIWithString: (OFString *)string relativeToIRI: (OFIRI *)IRI
relativeToURI: (OFURI *)URI
{
return [[[self alloc] initWithString: string
relativeToURI: URI] autorelease];
relativeToIRI: IRI] autorelease];
}
#ifdef OF_HAVE_FILES
+ (instancetype)fileURIWithPath: (OFString *)path
+ (instancetype)fileIRIWithPath: (OFString *)path
{
return [[[self alloc] initFileURIWithPath: path] autorelease];
return [[[self alloc] initFileIRIWithPath: path] autorelease];
}
+ (instancetype)fileURIWithPath: (OFString *)path
isDirectory: (bool)isDirectory
+ (instancetype)fileIRIWithPath: (OFString *)path isDirectory: (bool)isDirectory
{
return [[[self alloc] initFileURIWithPath: path
return [[[self alloc] initFileIRIWithPath: path
isDirectory: isDirectory] autorelease];
}
#endif
static void
parseUserInfo(OFURI *self, const char *UTF8String, size_t length)
parseUserInfo(OFIRI *self, const char *UTF8String, size_t length)
{
const char *colon;
if ((colon = memchr(UTF8String, ':', length)) != NULL) {
self->_percentEncodedUser = [[OFString alloc]
initWithUTF8String: UTF8String
length: colon - UTF8String];
self->_percentEncodedPassword = [[OFString alloc]
initWithUTF8String: colon + 1
length: length - (colon - UTF8String) - 1];
OFURIVerifyIsEscaped(self->_percentEncodedPassword,
[OFCharacterSet URIPasswordAllowedCharacterSet], true);
OFIRIVerifyIsEscaped(self->_percentEncodedPassword,
[OFCharacterSet IRIPasswordAllowedCharacterSet], true);
} else
self->_percentEncodedUser = [[OFString alloc]
initWithUTF8String: UTF8String
length: length];
OFURIVerifyIsEscaped(self->_percentEncodedUser,
[OFCharacterSet URIUserAllowedCharacterSet], true);
OFIRIVerifyIsEscaped(self->_percentEncodedUser,
[OFCharacterSet IRIUserAllowedCharacterSet], true);
}
static void
parseHostPort(OFURI *self, const char *UTF8String, size_t length)
parseHostPort(OFIRI *self, const char *UTF8String, size_t length)
{
OFString *portString;
if (*UTF8String == '[') {
const char *end = memchr(UTF8String, ']', length);
if (end == NULL)
|
︙ | | |
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
|
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
|
-
-
+
+
|
initWithUTF8String: UTF8String
length: length];
UTF8String += length;
length = 0;
}
OFURIVerifyIsEscaped(self->_percentEncodedHost,
[OFCharacterSet URIHostAllowedCharacterSet], true);
OFIRIVerifyIsEscaped(self->_percentEncodedHost,
[OFCharacterSet IRIHostAllowedCharacterSet], true);
}
if (length == 0)
return;
if (length <= 1 || *UTF8String != ':')
@throw [OFInvalidFormatException exception];
|
︙ | | |
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
|
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
|
-
+
|
@throw [OFInvalidFormatException exception];
self->_port = [[OFNumber alloc] initWithUnsignedShort:
(unsigned short)portString.unsignedLongLongValue];
}
static size_t
parseAuthority(OFURI *self, const char *UTF8String, size_t length)
parseAuthority(OFIRI *self, const char *UTF8String, size_t length)
{
size_t ret;
const char *slash, *at;
if ((slash = memchr(UTF8String, '/', length)) != NULL)
length = slash - UTF8String;
|
︙ | | |
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
|
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
|
-
-
+
+
-
-
+
+
-
-
+
+
|
const char *fragment, *query;
if ((fragment = memchr(UTF8String, '#', length)) != NULL) {
*fragmentString = [OFString
stringWithUTF8String: fragment + 1
length: length - (fragment - UTF8String) - 1];
OFURIVerifyIsEscaped(*fragmentString,
[OFCharacterSet URIQueryAllowedCharacterSet], true);
OFIRIVerifyIsEscaped(*fragmentString,
[OFCharacterSet IRIQueryAllowedCharacterSet], true);
length = fragment - UTF8String;
}
if ((query = memchr(UTF8String, '?', length)) != NULL) {
*queryString = [OFString
stringWithUTF8String: query + 1
length: length - (query - UTF8String) - 1];
OFURIVerifyIsEscaped(*queryString,
[OFCharacterSet URIFragmentAllowedCharacterSet], true);
OFIRIVerifyIsEscaped(*queryString,
[OFCharacterSet IRIFragmentAllowedCharacterSet], true);
length = query - UTF8String;
}
*pathString = [OFString stringWithUTF8String: UTF8String
length: length];
OFURIVerifyIsEscaped(*pathString,
[OFCharacterSet URIQueryAllowedCharacterSet], true);
OFIRIVerifyIsEscaped(*pathString,
[OFCharacterSet IRIPathAllowedCharacterSet], true);
}
- (instancetype)initWithString: (OFString *)string
{
self = [super init];
@try {
|
︙ | | |
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
|
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
|
-
-
+
+
|
colon - UTF8String < 1 || !OFASCIIIsAlpha(UTF8String[0]))
@throw [OFInvalidFormatException exception];
_scheme = [[[OFString stringWithUTF8String: UTF8String
length: colon - UTF8String]
lowercaseString] copy];
OFURIVerifyIsEscaped(_scheme,
[OFCharacterSet URISchemeAllowedCharacterSet], false);
OFIRIVerifyIsEscaped(_scheme,
[OFCharacterSet IRISchemeAllowedCharacterSet], false);
length -= colon - UTF8String + 1;
UTF8String = colon + 1;
if (length >= 2 && UTF8String[0] == '/' &&
UTF8String[1] == '/') {
size_t authorityLength;
|
︙ | | |
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
|
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
|
-
+
|
else
[components replaceObjectAtIndex: components.count - 1
withObject: path];
return [components componentsJoinedByString: @"/"];
}
- (instancetype)initWithString: (OFString *)string relativeToURI: (OFURI *)URI
- (instancetype)initWithString: (OFString *)string relativeToIRI: (OFIRI *)IRI
{
bool absolute;
@try {
absolute = isAbsolute(string);
} @catch (id e) {
[self release];
|
︙ | | |
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
|
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
|
-
+
-
-
-
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
@try {
void *pool = objc_autoreleasePoolPush();
const char *UTF8String = string.UTF8String;
size_t length = string.UTF8StringLength;
bool hasAuthority = false;
OFString *path, *query = nil, *fragment = nil;
_scheme = [URI->_scheme copy];
_scheme = [IRI->_scheme copy];
if (length >= 2 && UTF8String[0] == '/' &&
UTF8String[1] == '/') {
size_t authorityLength;
hasAuthority = true;
UTF8String += 2;
length -= 2;
authorityLength = parseAuthority(self,
UTF8String, length);
UTF8String += authorityLength;
length -= authorityLength;
if (length > 0)
OFEnsure(UTF8String[0] == '/');
} else {
_percentEncodedHost = [URI->_percentEncodedHost copy];
_port = [URI->_port copy];
_percentEncodedUser = [URI->_percentEncodedUser copy];
_percentEncodedHost = [IRI->_percentEncodedHost copy];
_port = [IRI->_port copy];
_percentEncodedUser = [IRI->_percentEncodedUser copy];
_percentEncodedPassword =
[URI->_percentEncodedPassword copy];
[IRI->_percentEncodedPassword copy];
}
parsePathQueryFragment(UTF8String, length,
&path, &query, &fragment);
_percentEncodedFragment = [fragment copy];
if (hasAuthority) {
_percentEncodedPath = [path copy];
_percentEncodedQuery = [query copy];
} else {
if (path.length == 0) {
_percentEncodedPath =
[URI->_percentEncodedPath copy];
[IRI->_percentEncodedPath copy];
_percentEncodedQuery = (query != nil
? [query copy]
: [URI->_percentEncodedQuery copy]);
: [IRI->_percentEncodedQuery copy]);
} else {
if ([path hasPrefix: @"/"])
_percentEncodedPath = [path copy];
else
_percentEncodedPath = [merge(
URI->_percentEncodedPath, path)
IRI->_percentEncodedPath, path)
copy];
_percentEncodedQuery = [query copy];
}
}
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
#ifdef OF_HAVE_FILES
- (instancetype)initFileURIWithPath: (OFString *)path
- (instancetype)initFileIRIWithPath: (OFString *)path
{
bool isDirectory;
@try {
void *pool = objc_autoreleasePoolPush();
isDirectory = [path of_isDirectoryPath];
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
self = [self initFileURIWithPath: path isDirectory: isDirectory];
self = [self initFileIRIWithPath: path isDirectory: isDirectory];
return self;
}
- (instancetype)initFileURIWithPath: (OFString *)path
- (instancetype)initFileIRIWithPath: (OFString *)path
isDirectory: (bool)isDirectory
{
self = [super init];
@try {
void *pool = objc_autoreleasePoolPush();
OFString *percentEncodedHost = nil;
if (!path.absolutePath) {
OFString *currentDirectoryPath = [OFFileManager
defaultManager].currentDirectoryPath;
path = [currentDirectoryPath
stringByAppendingPathComponent: path];
path = path.stringByStandardizingPath;
}
path = [path of_pathToURIPathWithPercentEncodedHost:
path = [path of_pathToIRIPathWithPercentEncodedHost:
&percentEncodedHost];
_percentEncodedHost = [percentEncodedHost copy];
if (isDirectory && ![path hasSuffix: @"/"])
path = [path stringByAppendingString: @"/"];
_scheme = @"file";
_percentEncodedPath = [[path
stringByAddingPercentEncodingWithAllowedCharacters:
[OFCharacterSet URIPathAllowedCharacterSet]] copy];
[OFCharacterSet IRIPathAllowedCharacterSet]] copy];
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
|
︙ | | |
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
|
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
|
}
- (instancetype)of_init
{
return [super init];
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
void *pool = objc_autoreleasePoolPush();
OFString *stringValue;
@try {
if (![element.name isEqual: self.className] ||
![element.namespace isEqual: OFSerializationNS])
@throw [OFInvalidArgumentException exception];
stringValue = element.stringValue;
} @catch (id e) {
[self release];
@throw e;
}
self = [self initWithString: stringValue];
objc_autoreleasePoolPop(pool);
return self;
}
- (void)dealloc
{
[_scheme release];
[_percentEncodedHost release];
[_port release];
[_percentEncodedUser release];
[_percentEncodedPassword release];
[_percentEncodedPath release];
[_percentEncodedQuery release];
[_percentEncodedFragment release];
[super dealloc];
}
- (bool)isEqual: (id)object
{
OFURI *URI;
OFIRI *IRI;
if (object == self)
return true;
if (![object isKindOfClass: [OFURI class]])
if (![object isKindOfClass: [OFIRI class]])
return false;
URI = object;
IRI = object;
if (![URI->_scheme isEqual: _scheme])
if (![IRI->_scheme isEqual: _scheme])
return false;
if (URI->_percentEncodedHost != _percentEncodedHost &&
![URI->_percentEncodedHost isEqual: _percentEncodedHost])
if (IRI->_percentEncodedHost != _percentEncodedHost &&
![IRI->_percentEncodedHost isEqual: _percentEncodedHost])
return false;
if (URI->_port != _port && ![URI->_port isEqual: _port])
if (IRI->_port != _port && ![IRI->_port isEqual: _port])
return false;
if (URI->_percentEncodedUser != _percentEncodedUser &&
![URI->_percentEncodedUser isEqual: _percentEncodedUser])
if (IRI->_percentEncodedUser != _percentEncodedUser &&
![IRI->_percentEncodedUser isEqual: _percentEncodedUser])
return false;
if (URI->_percentEncodedPassword != _percentEncodedPassword &&
![URI->_percentEncodedPassword isEqual: _percentEncodedPassword])
if (IRI->_percentEncodedPassword != _percentEncodedPassword &&
![IRI->_percentEncodedPassword isEqual: _percentEncodedPassword])
return false;
if (![URI->_percentEncodedPath isEqual: _percentEncodedPath])
if (![IRI->_percentEncodedPath isEqual: _percentEncodedPath])
return false;
if (URI->_percentEncodedQuery != _percentEncodedQuery &&
![URI->_percentEncodedQuery isEqual: _percentEncodedQuery])
if (IRI->_percentEncodedQuery != _percentEncodedQuery &&
![IRI->_percentEncodedQuery isEqual: _percentEncodedQuery])
return false;
if (URI->_percentEncodedFragment != _percentEncodedFragment &&
![URI->_percentEncodedFragment isEqual: _percentEncodedFragment])
if (IRI->_percentEncodedFragment != _percentEncodedFragment &&
![IRI->_percentEncodedFragment isEqual: _percentEncodedFragment])
return false;
return true;
}
- (unsigned long)hash
{
|
︙ | | |
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
|
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
|
-
+
|
- (OFString *)host
{
if ([_percentEncodedHost hasPrefix: @"["] &&
[_percentEncodedHost hasSuffix: @"]"]) {
OFString *host = [_percentEncodedHost substringWithRange:
OFMakeRange(1, _percentEncodedHost.length - 2)];
if (!OFURIIsIPv6Host(host))
if (!OFIRIIsIPv6Host(host))
@throw [OFInvalidArgumentException exception];
return host;
}
return _percentEncodedHost.stringByRemovingPercentEncoding;
}
|
︙ | | |
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
|
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
|
-
+
-
+
|
#endif
OFMutableArray *ret;
size_t count;
#ifdef OF_HAVE_FILES
if (isFile) {
OFString *path = [_percentEncodedPath
of_URIPathToPathWithPercentEncodedHost: nil];
of_IRIPathToPathWithPercentEncodedHost: nil];
ret = [[path.pathComponents mutableCopy] autorelease];
if (![ret.firstObject isEqual: @"/"])
[ret insertObject: @"/" atIndex: 0];
} else
#endif
ret = [[[_percentEncodedPath componentsSeparatedByString: @"/"]
mutableCopy] autorelease];
count = ret.count;
if (count > 0 && [ret.firstObject length] == 0)
[ret replaceObjectAtIndex: 0 withObject: @"/"];
for (size_t i = 0; i < count; i++) {
OFString *component = [ret objectAtIndex: i];
#ifdef OF_HAVE_FILES
if (isFile)
component =
[component of_pathComponentToURIPathComponent];
[component of_pathComponentToIRIPathComponent];
#endif
component = component.stringByRemovingPercentEncoding;
[ret replaceObjectAtIndex: i withObject: component];
}
[ret makeImmutable];
|
︙ | | |
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
|
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
|
-
+
|
- (id)copy
{
return [self retain];
}
- (id)mutableCopy
{
OFURI *copy = [[OFMutableURI alloc] initWithScheme: _scheme];
OFIRI *copy = [[OFMutableIRI alloc] initWithScheme: _scheme];
@try {
copy->_percentEncodedHost = [_percentEncodedHost copy];
copy->_port = [_port copy];
copy->_percentEncodedUser = [_percentEncodedUser copy];
copy->_percentEncodedPassword = [_percentEncodedPassword copy];
copy->_percentEncodedPath = [_percentEncodedPath copy];
|
︙ | | |
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
|
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
|
-
+
-
+
-
-
-
-
+
+
+
+
-
+
-
-
-
-
+
+
+
+
-
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
if (![_scheme isEqual: @"file"])
@throw [OFInvalidArgumentException exception];
if (![_percentEncodedPath hasPrefix: @"/"])
@throw [OFInvalidFormatException exception];
path = [self.path
of_URIPathToPathWithPercentEncodedHost: _percentEncodedHost];
of_IRIPathToPathWithPercentEncodedHost: _percentEncodedHost];
[path retain];
objc_autoreleasePoolPop(pool);
return [path autorelease];
}
#endif
- (OFURI *)URIByAppendingPathComponent: (OFString *)component
- (OFIRI *)IRIByAppendingPathComponent: (OFString *)component
{
OFMutableURI *URI = [[self mutableCopy] autorelease];
[URI appendPathComponent: component];
[URI makeImmutable];
return URI;
OFMutableIRI *IRI = [[self mutableCopy] autorelease];
[IRI appendPathComponent: component];
[IRI makeImmutable];
return IRI;
}
- (OFURI *)URIByAppendingPathComponent: (OFString *)component
- (OFIRI *)IRIByAppendingPathComponent: (OFString *)component
isDirectory: (bool)isDirectory
{
OFMutableURI *URI = [[self mutableCopy] autorelease];
[URI appendPathComponent: component isDirectory: isDirectory];
[URI makeImmutable];
return URI;
OFMutableIRI *IRI = [[self mutableCopy] autorelease];
[IRI appendPathComponent: component isDirectory: isDirectory];
[IRI makeImmutable];
return IRI;
}
- (OFURI *)URIByStandardizingPath
- (OFIRI *)IRIByStandardizingPath
{
OFMutableURI *URI = [[self mutableCopy] autorelease];
[URI standardizePath];
[URI makeImmutable];
return URI;
OFMutableIRI *IRI = [[self mutableCopy] autorelease];
[IRI standardizePath];
[IRI makeImmutable];
return IRI;
}
- (OFIRI *)IRIByAddingPercentEncodingForUnicodeCharacters
{
OFMutableIRI *IRI = [[self mutableCopy] autorelease];
void *pool = objc_autoreleasePoolPush();
OFCharacterSet *ASCII =
[OFCharacterSet characterSetWithRange: OFMakeRange(0, 0x80)];
IRI.percentEncodedHost = [_percentEncodedHost
stringByAddingPercentEncodingWithAllowedCharacters: ASCII];
IRI.percentEncodedUser = [_percentEncodedUser
stringByAddingPercentEncodingWithAllowedCharacters: ASCII];
IRI.percentEncodedPassword = [_percentEncodedPassword
stringByAddingPercentEncodingWithAllowedCharacters: ASCII];
IRI.percentEncodedPath = [_percentEncodedPath
stringByAddingPercentEncodingWithAllowedCharacters: ASCII];
IRI.percentEncodedQuery = [_percentEncodedQuery
stringByAddingPercentEncodingWithAllowedCharacters: ASCII];
IRI.percentEncodedFragment = [_percentEncodedFragment
stringByAddingPercentEncodingWithAllowedCharacters: ASCII];
[IRI makeImmutable];
objc_autoreleasePoolPop(pool);
return IRI;
}
- (OFString *)description
{
return [OFString stringWithFormat: @"<%@: %@>",
self.class, self.string];
}
- (OFXMLElement *)XMLElementBySerializing
{
void *pool = objc_autoreleasePoolPush();
OFXMLElement *element;
element = [OFXMLElement elementWithName: self.className
namespace: OFSerializationNS
stringValue: self.string];
[element retain];
objc_autoreleasePoolPop(pool);
return [element autorelease];
}
@end
|
Renamed and modified
src/OFURIHandler.h
[09864efcca]
to src/OFIRIHandler.h
[907c8f4d42].
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
|
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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
|
-
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
+
+
+
+
-
+
-
+
-
-
+
+
+
+
+
+
+
+
+
-
+
-
+
-
-
+
+
+
+
-
+
-
+
-
-
+
+
+
+
-
+
-
+
-
+
+
+
+
-
+
-
+
-
-
+
+
+
+
+
+
-
+
-
+
-
+
-
+
+
+
+
-
+
-
+
-
+
-
-
+
+
+
+
+
+
+
-
+
-
+
-
+
-
+
+
+
+
-
+
-
+
-
+
+
+
+
-
+
-
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFFileManager.h"
#import "OFObject.h"
#import "OFString.h"
OF_ASSUME_NONNULL_BEGIN
@class OFArray OF_GENERIC(ObjectType);
@class OFData;
@class OFDate;
@class OFStream;
@class OFURI;
@class OFIRI;
@class OFStream;
/**
* @class OFURIHandler OFURIHandler.h ObjFW/OFURIHandler.h
* @class OFIRIHandler OFIRIHandler.h ObjFW/OFIRIHandler.h
*
* @brief A handler for a URI scheme.
* @brief A handler for an IRI scheme.
*/
@interface OFURIHandler: OFObject
@interface OFIRIHandler: OFObject
{
OFString *_scheme;
OF_RESERVE_IVARS(OFURIHandler, 4)
OF_RESERVE_IVARS(OFIRIHandler, 4)
}
/**
* @brief The scheme this OFURIHandler handles.
* @brief The scheme this OFIRIHandler handles.
*/
@property (readonly, nonatomic) OFString *scheme;
/**
* @brief Registers the specified class as the handler for the specified scheme.
*
* If the same class is specified for two schemes, one instance of it is
* created per scheme.
*
* @param class_ The class to register as the handler for the specified scheme
* @param scheme The scheme for which to register the handler
* @return Whether the class was successfully registered. If a handler for the
* same scheme is already registered, registration fails.
*/
+ (bool)registerClass: (Class)class_ forScheme: (OFString *)scheme;
/**
* @brief Returns the handler for the specified URI.
* @brief Returns the handler for the specified IRI.
*
* @return The handler for the specified URI.
* @throw OFUnsupportedProtocolException The specified URI is not supported
* @return The handler for the specified IRI.
* @throw OFUnsupportedProtocolException The specified IRI is not supported
*/
+ (OFURIHandler *)handlerForURI: (OFURI *)URI;
+ (OFIRIHandler *)handlerForIRI: (OFIRI *)IRI;
/**
* @brief Opens the item at the specified URI.
* @brief Opens the item at the specified IRI.
*
* @param URI The URI of the item which should be opened
* @param IRI The IRI of the item which should be opened
* @param mode The mode in which the file should be opened.@n
* Possible modes are:
* @n
* Mode | Description
* ---------------|-------------------------------------
* `r` | Read-only
* `r+` | Read-write
* `w` | Write-only, create or truncate
* `wx` | Write-only, create or fail, exclusive
* `w+` | Read-write, create or truncate
* `w+x` | Read-write, create or fail, exclusive
* `a` | Write-only, create or append
* `a+` | Read-write, create or append
* @n
* The handler is allowed to not implement all modes and is also
* allowed to implement additional, scheme-specific modes.
* @return The opened stream if it was successfully opened
* @throw OFOpenItemFailedException Opening the item failed
* @throw OFUnsupportedProtocolException The specified URI is not supported
* @throw OFUnsupportedProtocolException The specified IRI is not supported
*/
+ (OFStream *)openItemAtURI: (OFURI *)URI mode: (OFString *)mode;
+ (OFStream *)openItemAtIRI: (OFIRI *)IRI mode: (OFString *)mode;
- (instancetype)init OF_UNAVAILABLE;
/**
* @brief Initializes the handler for the specified scheme.
*
* @param scheme The scheme to initialize for
* @return An initialized URI handler
* @return An initialized IRI handler
*/
- (instancetype)initWithScheme: (OFString *)scheme OF_DESIGNATED_INITIALIZER;
/**
* @brief Opens the item at the specified URI.
* @brief Opens the item at the specified IRI.
*
* @param URI The URI of the item which should be opened
* @param IRI The IRI of the item which should be opened
* @param mode The mode in which the file should be opened.@n
* Possible modes are:
* @n
* Mode | Description
* ---------------|-------------------------------------
* `r` | Read-only
* `r+` | Read-write
* `w` | Write-only, create or truncate
* `wx` | Write-only, create or fail, exclusive
* `w+` | Read-write, create or truncate
* `w+x` | Read-write, create or fail, exclusive
* `a` | Write-only, create or append
* `a+` | Read-write, create or append
* @n
* The handler is allowed to not implement all modes and is also
* allowed to implement additional, scheme-specific modes.
* @return The opened stream if it was successfully opened
* @throw OFOpenItemFailedException Opening the item failed
* @throw OFUnsupportedProtocolException The specified URI is not supported by
* @throw OFUnsupportedProtocolException The specified IRI is not supported by
* the handler
*/
- (OFStream *)openItemAtURI: (OFURI *)URI mode: (OFString *)mode;
- (OFStream *)openItemAtIRI: (OFIRI *)IRI mode: (OFString *)mode;
/**
* @brief Returns the attributes for the item at the specified URI.
* @brief Returns the attributes for the item at the specified IRI.
*
* @param URI The URI to return the attributes for
* @return A dictionary of attributes for the specified URI, with the keys of
* @param IRI The IRI to return the attributes for
* @return A dictionary of attributes for the specified IRI, with the keys of
* type @ref OFFileAttributeKey
* @throw OFGetItemAttributesFailedException Failed to get the attributes of
* the item
* @throw OFUnsupportedProtocolException The handler cannot handle the IRI's
* scheme
*/
- (OFFileAttributes)attributesOfItemAtURI: (OFURI *)URI;
- (OFFileAttributes)attributesOfItemAtIRI: (OFIRI *)IRI;
/**
* @brief Sets the attributes for the item at the specified URI.
* @brief Sets the attributes for the item at the specified IRI.
*
* All attributes not part of the dictionary are left unchanged.
*
* @param attributes The attributes to set for the specified URI
* @param URI The URI of the item to set the attributes for
* @param attributes The attributes to set for the specified IRI
* @param IRI The IRI of the item to set the attributes for
* @@throw OFSetItemAttributesFailedException Failed to set the attributes of
* the item
* @throw OFUnsupportedProtocolException The handler cannot handle the IRI's
* scheme
* @throw OFNotImplementedException Setting one or more of the specified
* attributes is not implemented for the
* specified item
*/
- (void)setAttributes: (OFFileAttributes)attributes ofItemAtURI: (OFURI *)URI;
- (void)setAttributes: (OFFileAttributes)attributes ofItemAtIRI: (OFIRI *)IRI;
/**
* @brief Checks whether a file exists at the specified URI.
* @brief Checks whether a file exists at the specified IRI.
*
* @param URI The URI to check
* @return A boolean whether there is a file at the specified URI
* @param IRI The IRI to check
* @return A boolean whether there is a file at the specified IRI
* @throw OFUnsupportedProtocolException The handler cannot handle the IRI's
* scheme
*/
- (bool)fileExistsAtURI: (OFURI *)URI;
- (bool)fileExistsAtIRI: (OFIRI *)IRI;
/**
* @brief Checks whether a directory exists at the specified URI.
* @brief Checks whether a directory exists at the specified IRI.
*
* @param URI The URI to check
* @return A boolean whether there is a directory at the specified URI
* @param IRI The IRI to check
* @return A boolean whether there is a directory at the specified IRI
* @throw OFUnsupportedProtocolException The handler cannot handle the IRI's
* scheme
*/
- (bool)directoryExistsAtURI: (OFURI *)URI;
- (bool)directoryExistsAtIRI: (OFIRI *)IRI;
/**
* @brief Creates a directory at the specified URI.
* @brief Creates a directory at the specified IRI.
*
* @param URI The URI of the directory to create
* @param IRI The IRI of the directory to create
* @throw OFCreateDirectoryFailedException Creating the directory failed
* @throw OFUnsupportedProtocolException The handler cannot handle the IRI's
* scheme
*/
- (void)createDirectoryAtURI: (OFURI *)URI;
- (void)createDirectoryAtIRI: (OFIRI *)IRI;
/**
* @brief Returns an array with the URIs of the items in the specified
* @brief Returns an array with the IRIs of the items in the specified
* directory.
*
* @note `.` and `..` are not part of the returned array.
*
* @param URI The URI to the directory whose items should be returned
* @return An array with the URIs of the items in the specified directory
* @param IRI The IRI to the directory whose items should be returned
* @return An array with the IRIs of the items in the specified directory
* @throw OFOpenItemFailedException Opening the directory failed
* @throw OFReadFailedException Reading from the directory failed
* @throw OFUnsupportedProtocolException The handler cannot handle the IRI's
* scheme
*/
- (OFArray OF_GENERIC(OFURI *) *)contentsOfDirectoryAtURI: (OFURI *)URI;
- (OFArray OF_GENERIC(OFIRI *) *)contentsOfDirectoryAtIRI: (OFIRI *)IRI;
/**
* @brief Removes the item at the specified URI.
* @brief Removes the item at the specified IRI.
*
* If the item at the specified URI is a directory, it is removed recursively.
* If the item at the specified IRI is a directory, it is removed recursively.
*
* @param URI The URI to the item which should be removed
* @param IRI The IRI to the item which should be removed
* @throw OFRemoveItemFailedException Removing the item failed
* @throw OFUnsupportedProtocolException The handler cannot handle the IRI's
* scheme
*/
- (void)removeItemAtURI: (OFURI *)URI;
- (void)removeItemAtIRI: (OFIRI *)IRI;
/**
* @brief Creates a hard link for the specified item.
*
* The destination URI must have a full path, which means it must include the
* The destination IRI must have a full path, which means it must include the
* name of the item.
*
* This method is not available for all URIs.
* This method is not available for all IRIs.
*
* @param source The URI to the item for which a link should be created
* @param destination The URI to the item which should link to the source
* @param source The IRI to the item for which a link should be created
* @param destination The IRI to the item which should link to the source
* @throw OFLinkItemFailedException Linking the item failed
* @throw OFUnsupportedProtocolException The handler cannot handle the scheme
* of one of the IRIs
* @throw OFNotImplementedException Hardlinks are not implemented for the
* specified IRI
*/
- (void)linkItemAtURI: (OFURI *)source toURI: (OFURI *)destination;
- (void)linkItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination;
/**
* @brief Creates a symbolic link for an item.
*
* The destination URI must have a full path, which means it must include the
* The destination IRI must have a full path, which means it must include the
* name of the item.
*
* This method is not available for all URIs.
* This method is not available for all IRIs.
*
* @note On Windows, this requires at least Windows Vista and administrator
* privileges!
*
* @param URI The URI to the item which should symbolically link to the target
* @param IRI The IRI to the item which should symbolically link to the target
* @param target The target of the symbolic link
* @throw OFCreateSymbolicLinkFailed Creating a symbolic link failed
* @throw OFUnsupportedProtocolException The handler cannot handle the IRI's
* scheme
*/
- (void)createSymbolicLinkAtURI: (OFURI *)URI
- (void)createSymbolicLinkAtIRI: (OFIRI *)IRI
withDestinationPath: (OFString *)target;
/**
* @brief Tries to efficiently copy an item. If a copy would only be possible
* by reading the entire item and then writing it, it returns false.
*
* The destination URI must have a full path, which means it must include the
* The destination IRI must have a full path, which means it must include the
* name of the item.
*
* If an item already exists, the copy operation fails. This is also the case
* if a directory is copied and an item already exists in the destination
* directory.
*
* @param source The file, directory or symbolic link to copy
* @param destination The destination URI
* @param destination The destination IRI
* @return True if an efficient copy was performed, false if an efficient copy
* was not possible. Note that errors while performing a copy are
* reported via exceptions and not by returning false!
* @throw OFCopyItemFailedException Copying failed
* @throw OFUnsupportedProtocolException The handler cannot handle the IRI's
* scheme
*/
- (bool)copyItemAtURI: (OFURI *)source toURI: (OFURI *)destination;
- (bool)copyItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination;
/**
* @brief Tries to efficiently move an item. If a move would only be possible
* by copying the source and deleting it, it returns false.
*
* The destination URI must have a full path, which means it must include the
* The destination IRI must have a full path, which means it must include the
* name of the item.
*
* If the destination is on a different logical device or uses a different
* scheme, an efficient move is not possible and false is returned.
*
* @param source The item to rename
* @param destination The new name for the item
* @return True if an efficient move was performed, false if an efficient move
* was not possible. Note that errors while performing a move are
* reported via exceptions and not by returning false!
* @throw OFMoveItemFailedException Moving failed
* @throw OFUnsupportedProtocolException The handler cannot handle the IRI's
* scheme
*/
- (bool)moveItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination;
- (bool)moveItemAtURI: (OFURI *)source toURI: (OFURI *)destination;
/**
* @brief Returns the extended attribute data for the specified name of the
* item at the specified IRI.
*
* This method is not available for all IRIs.
*
* @param name The name of the extended attribute
* @param IRI The IRI of the item to return the extended attribute from
* @throw OFGetItemAttributesFailedException Getting the extended attribute
* failed
* @throw OFUnsupportedProtocolException The handler cannot handle the IRI's
* scheme
* @throw OFNotImplementedException Getting extended attributes is not
* implemented for the specified item
*/
- (OFData *)extendedAttributeDataForName: (OFString *)name
ofItemAtIRI: (OFIRI *)IRI;
/**
* @brief Sets the extended attribute data for the specified name of the item
* at the specified IRI.
*
* This method is not available for all IRIs.
*
* @param data The data for the extended attribute
* @param name The name of the extended attribute
* @param IRI The IRI of the item to set the extended attribute on
* @throw OFSetItemAttributesFailedException Setting the extended attribute
* failed
* @throw OFUnsupportedProtocolException The handler cannot handle the IRI's
* scheme
* @throw OFNotImplementedException Setting extended attributes is not
* implemented for the specified item
*/
- (void)setExtendedAttributeData: (OFData *)data
forName: (OFString *)name
ofItemAtIRI: (OFIRI *)IRI;
/**
* @brief Removes the extended attribute for the specified name wof the item at
* the specified IRI.
*
* This method is not available for all IRIs.
*
* @param name The name of the extended attribute to remove
* @param IRI The IRI of the item to remove the extended attribute from
* @throw OFSetItemAttributesFailedException Removing the extended attribute
* failed
* @throw OFUnsupportedProtocolException The handler cannot handle the IRI's
* scheme
* @throw OFNotImplementedException Removing extended attributes is not
* implemented for the specified item
*/
- (void)removeExtendedAttributeForName: (OFString *)name
ofItemAtIRI: (OFIRI *)IRI;
@end
OF_ASSUME_NONNULL_END
|
Renamed and modified
src/OFURIHandler.m
[1cc8c8dac2]
to src/OFIRIHandler.m
[706a9b9e6c].
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
|
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
|
-
+
-
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
-
-
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#import "OFURIHandler.h"
#import "OFIRIHandler.h"
#import "OFDictionary.h"
#import "OFNumber.h"
#import "OFURI.h"
#import "OFIRI.h"
#import "OFNumber.h"
#ifdef OF_HAVE_THREADS
# import "OFMutex.h"
#endif
#import "OFArchiveURIHandler.h"
#import "OFEmbeddedURIHandler.h"
#import "OFArchiveIRIHandler.h"
#import "OFEmbeddedIRIHandler.h"
#ifdef OF_HAVE_FILES
# import "OFFileURIHandler.h"
# import "OFFileIRIHandler.h"
#endif
#if defined(OF_HAVE_SOCKETS) && defined(OF_HAVE_THREADS)
# import "OFHTTPURIHandler.h"
# import "OFHTTPIRIHandler.h"
#endif
#import "OFUnsupportedProtocolException.h"
static OFMutableDictionary OF_GENERIC(OFString *, OFURIHandler *) *handlers;
static OFMutableDictionary OF_GENERIC(OFString *, OFIRIHandler *) *handlers;
#ifdef OF_HAVE_THREADS
static OFMutex *mutex;
static void
releaseMutex(void)
{
[mutex release];
}
#endif
@implementation OFURIHandler
@implementation OFIRIHandler
@synthesize scheme = _scheme;
+ (void)initialize
{
if (self != [OFURIHandler class])
if (self != [OFIRIHandler class])
return;
handlers = [[OFMutableDictionary alloc] init];
#ifdef OF_HAVE_THREADS
mutex = [[OFMutex alloc] init];
atexit(releaseMutex);
#endif
[self registerClass: [OFEmbeddedURIHandler class]
[self registerClass: [OFEmbeddedIRIHandler class]
forScheme: @"embedded"];
#ifdef OF_HAVE_FILES
[self registerClass: [OFFileURIHandler class] forScheme: @"file"];
[self registerClass: [OFFileIRIHandler class] forScheme: @"file"];
#endif
#if defined(OF_HAVE_SOCKETS) && defined(OF_HAVE_THREADS)
[self registerClass: [OFHTTPURIHandler class] forScheme: @"http"];
[self registerClass: [OFHTTPURIHandler class] forScheme: @"https"];
[self registerClass: [OFHTTPIRIHandler class] forScheme: @"http"];
[self registerClass: [OFHTTPIRIHandler class] forScheme: @"https"];
#endif
[self registerClass: [OFArchiveURIHandler class] forScheme: @"gzip"];
[self registerClass: [OFArchiveURIHandler class] forScheme: @"lha"];
[self registerClass: [OFArchiveURIHandler class] forScheme: @"tar"];
[self registerClass: [OFArchiveURIHandler class] forScheme: @"zip"];
[self registerClass: [OFArchiveIRIHandler class] forScheme: @"gzip"];
[self registerClass: [OFArchiveIRIHandler class] forScheme: @"lha"];
[self registerClass: [OFArchiveIRIHandler class] forScheme: @"tar"];
[self registerClass: [OFArchiveIRIHandler class] forScheme: @"zip"];
}
+ (bool)registerClass: (Class)class forScheme: (OFString *)scheme
{
#ifdef OF_HAVE_THREADS
[mutex lock];
@try {
#endif
OFURIHandler *handler;
OFIRIHandler *handler;
if ([handlers objectForKey: scheme] != nil)
return false;
handler = [[class alloc] initWithScheme: scheme];
@try {
[handlers setObject: handler forKey: scheme];
} @finally {
[handler release];
}
#ifdef OF_HAVE_THREADS
} @finally {
[mutex unlock];
}
#endif
return true;
}
+ (OFURIHandler *)handlerForURI: (OFURI *)URI
+ (OFIRIHandler *)handlerForIRI: (OFIRI *)IRI
{
OF_KINDOF(OFURIHandler *) handler;
OF_KINDOF(OFIRIHandler *) handler;
#ifdef OF_HAVE_THREADS
[mutex lock];
@try {
#endif
handler = [handlers objectForKey: URI.scheme];
handler = [handlers objectForKey: IRI.scheme];
#ifdef OF_HAVE_THREADS
} @finally {
[mutex unlock];
}
#endif
if (handler == nil)
@throw [OFUnsupportedProtocolException exceptionWithURI: URI];
@throw [OFUnsupportedProtocolException exceptionWithIRI: IRI];
return handler;
}
+ (OFStream *)openItemAtURI: (OFURI *)URI mode: (OFString *)mode
+ (OFStream *)openItemAtIRI: (OFIRI *)IRI mode: (OFString *)mode
{
return [[self handlerForURI: URI] openItemAtURI: URI mode: mode];
return [[self handlerForIRI: IRI] openItemAtIRI: IRI mode: mode];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
+
+
+
+
-
+
+
+
+
+
+
+
-
+
+
+
+
+
+
-
+
+
+
+
+
|
- (void)dealloc
{
[_scheme release];
[super dealloc];
}
- (OFStream *)openItemAtURI: (OFURI *)URI mode: (OFString *)mode
- (OFStream *)openItemAtIRI: (OFIRI *)IRI mode: (OFString *)mode
{
OF_UNRECOGNIZED_SELECTOR
}
- (OFFileAttributes)attributesOfItemAtURI: (OFURI *)URI
- (OFFileAttributes)attributesOfItemAtIRI: (OFIRI *)IRI
{
OF_UNRECOGNIZED_SELECTOR
}
- (void)setAttributes: (OFFileAttributes)attributes ofItemAtURI: (OFURI *)URI
- (void)setAttributes: (OFFileAttributes)attributes ofItemAtIRI: (OFIRI *)IRI
{
OF_UNRECOGNIZED_SELECTOR
}
- (bool)fileExistsAtURI: (OFURI *)URI
- (bool)fileExistsAtIRI: (OFIRI *)IRI
{
OF_UNRECOGNIZED_SELECTOR
}
- (bool)directoryExistsAtURI: (OFURI *)URI
- (bool)directoryExistsAtIRI: (OFIRI *)IRI
{
OF_UNRECOGNIZED_SELECTOR
}
- (void)createDirectoryAtURI: (OFURI *)URI
- (void)createDirectoryAtIRI: (OFIRI *)IRI
{
OF_UNRECOGNIZED_SELECTOR
}
- (OFArray OF_GENERIC(OFURI *) *)contentsOfDirectoryAtURI: (OFURI *)URI
- (OFArray OF_GENERIC(OFIRI *) *)contentsOfDirectoryAtIRI: (OFIRI *)IRI
{
OF_UNRECOGNIZED_SELECTOR
}
- (void)removeItemAtURI: (OFURI *)URI
- (void)removeItemAtIRI: (OFIRI *)IRI
{
OF_UNRECOGNIZED_SELECTOR
}
- (void)linkItemAtURI: (OFURI *)source toURI: (OFURI *)destination
- (void)linkItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination
{
OF_UNRECOGNIZED_SELECTOR
}
- (void)createSymbolicLinkAtURI: (OFURI *)destination
- (void)createSymbolicLinkAtIRI: (OFIRI *)destination
withDestinationPath: (OFString *)source
{
OF_UNRECOGNIZED_SELECTOR
}
- (bool)copyItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination
{
return false;
}
- (bool)copyItemAtURI: (OFURI *)source toURI: (OFURI *)destination
- (bool)moveItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination
{
return false;
}
- (OFData *)extendedAttributeDataForName: (OFString *)name
ofItemAtIRI: (OFIRI *)IRI
{
OF_UNRECOGNIZED_SELECTOR
}
- (bool)moveItemAtURI: (OFURI *)source toURI: (OFURI *)destination
- (void)setExtendedAttributeData: (OFData *)data
forName: (OFString *)name
ofItemAtIRI: (OFIRI *)IRI
{
OF_UNRECOGNIZED_SELECTOR
}
return false;
- (void)removeExtendedAttributeForName: (OFString *)name
ofItemAtIRI: (OFIRI *)IRI
{
OF_UNRECOGNIZED_SELECTOR
}
@end
|
Modified src/OFInflate64Stream.h
from [2f3dc057f8]
to [95b4831491].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFInflate64Stream.m
from [96e65e9055]
to [d53c241e14].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFInflateStream.h
from [fe62e030fd]
to [4379fb100c].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFInflateStream.m
from [a61e69ad62]
to [2767dcbcf2].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFInvertedCharacterSet.h
from [d4b8559d77]
to [df83d3fc6a].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFInvertedCharacterSet.m
from [1e78ebb0a4]
to [997128430d].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFInvocation.h
from [ab7d9433d5]
to [ce48bec833].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFInvocation.m
from [5937b080ad]
to [9633190806].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFJSONRepresentation.h
from [2bd85161f3]
to [45a20e67ee].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFKernelEventObserver.h
from [81efdafa0c]
to [3a6c883edd].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFKernelEventObserver.m
from [8d008316fd]
to [65045f52e2].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
+
+
|
#endif
#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFOutOfRangeException.h"
#ifdef OF_AMIGAOS
# define Class IntuitionClass
# include <proto/exec.h>
# undef Class
#endif
@implementation OFKernelEventObserver
@synthesize delegate = _delegate;
#ifdef OF_AMIGAOS
@synthesize execSignalMask = _execSignalMask;
#endif
|
︙ | | |
Modified src/OFKeyValueCoding.h
from [3568d90874]
to [d758bb12c8].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFKqueueKernelEventObserver.h
from [79cac968ba]
to [e0150163de].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFKqueueKernelEventObserver.m
from [12f411060e]
to [8ae46a5559].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFLHAArchive.h
from [038ec719a6]
to [7c1ac55459].
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
|
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
|
-
+
-
-
+
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFObject.h"
#import "OFKernelEventObserver.h"
#import "OFLHAArchiveEntry.h"
#import "OFString.h"
OF_ASSUME_NONNULL_BEGIN
@class OFStream;
@class OFURI;
@class OFIRI;
@class OFStream;
/**
* @class OFLHAArchive OFLHAArchive.h ObjFW/OFLHAArchive.h
*
* @brief A class for accessing and manipulating LHA files.
*/
OF_SUBCLASSING_RESTRICTED
|
︙ | | |
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
|
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
|
-
+
-
+
-
-
+
+
-
-
+
+
-
+
|
* @return A new, autoreleased OFLHAArchive
*/
+ (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode;
/**
* @brief Creates a new OFLHAArchive object with the specified file.
*
* @param URI The URI to the LHA file
* @param IRI The IRI to the LHA file
* @param mode The mode for the LHA file. Valid modes are "r" for reading,
* "w" for creating a new file and "a" for appending to an existing
* archive.
* @return A new, autoreleased OFLHAArchive
*/
+ (instancetype)archiveWithURI: (OFURI *)URI mode: (OFString *)mode;
+ (instancetype)archiveWithIRI: (OFIRI *)IRI mode: (OFString *)mode;
/**
* @brief Creates a URI for accessing a the specified file within the specified
* LHA archive.
* @brief Creates an IRI for accessing a the specified file within the
* specified LHA archive.
*
* @param path The path of the file within the archive
* @param URI The URI of the archive
* @return A URI for accessing the specified file within the specified LHA
* @param IRI The IRI of the archive
* @return An IRI for accessing the specified file within the specified LHA
* archive
*/
+ (OFURI *)URIForFilePath: (OFString *)path inArchiveWithURI: (OFURI *)URI;
+ (OFIRI *)IRIForFilePath: (OFString *)path inArchiveWithIRI: (OFIRI *)IRI;
- (instancetype)init OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated OFLHAArchive object with the
* specified stream.
*
|
︙ | | |
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
-
+
-
+
|
- (instancetype)initWithStream: (OFStream *)stream
mode: (OFString *)mode OF_DESIGNATED_INITIALIZER;
/**
* @brief Initializes an already allocated OFLHAArchive object with the
* specified file.
*
* @param URI The URI to the LHA file
* @param IRI The IRI to the LHA file
* @param mode The mode for the LHA file. Valid modes are "r" for reading,
* "w" for creating a new file and "a" for appending to an existing
* archive.
* @return An initialized OFLHAArchive
*/
- (instancetype)initWithURI: (OFURI *)URI mode: (OFString *)mode;
- (instancetype)initWithIRI: (OFIRI *)IRI mode: (OFString *)mode;
/**
* @brief Returns the next entry from the LHA archive or `nil` if all entries
* have been read.
*
* @note This is only available in read mode.
*
|
︙ | | |
Modified src/OFLHAArchive.m
from [fa04eb799a]
to [9e5bf54c20].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
-
+
+
+
-
-
|
#include "config.h"
#include <errno.h>
#import "OFLHAArchive.h"
#import "OFLHAArchiveEntry.h"
#import "OFLHAArchiveEntry+Private.h"
#import "OFArchiveURIHandler.h"
#import "OFArchiveIRIHandler.h"
#import "OFCRC16.h"
#import "OFIRI.h"
#import "OFIRIHandler.h"
#import "OFLHADecompressingStream.h"
#import "OFSeekableStream.h"
#import "OFStream.h"
#import "OFString.h"
#import "OFURI.h"
#import "OFURIHandler.h"
#import "OFChecksumMismatchException.h"
#import "OFInvalidArgumentException.h"
#import "OFNotImplementedException.h"
#import "OFNotOpenException.h"
#import "OFOutOfRangeException.h"
#import "OFTruncatedDataException.h"
|
︙ | | |
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
-
+
-
+
-
+
-
+
|
@synthesize encoding = _encoding;
+ (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode
{
return [[[self alloc] initWithStream: stream mode: mode] autorelease];
}
+ (instancetype)archiveWithURI: (OFURI *)URI mode: (OFString *)mode
+ (instancetype)archiveWithIRI: (OFIRI *)IRI mode: (OFString *)mode
{
return [[[self alloc] initWithURI: URI mode: mode] autorelease];
return [[[self alloc] initWithIRI: IRI mode: mode] autorelease];
}
+ (OFURI *)URIForFilePath: (OFString *)path inArchiveWithURI: (OFURI *)URI
+ (OFIRI *)IRIForFilePath: (OFString *)path inArchiveWithIRI: (OFIRI *)IRI
{
return OFArchiveURIHandlerURIForFileInArchive(@"lha", path, URI);
return OFArchiveIRIHandlerIRIForFileInArchive(@"lha", path, IRI);
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
|
︙ | | |
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
-
+
-
+
-
+
|
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithURI: (OFURI *)URI mode: (OFString *)mode
- (instancetype)initWithIRI: (OFIRI *)IRI mode: (OFString *)mode
{
void *pool = objc_autoreleasePoolPush();
OFStream *stream;
@try {
if ([mode isEqual: @"a"])
stream = [OFURIHandler openItemAtURI: URI mode: @"r+"];
stream = [OFIRIHandler openItemAtIRI: IRI mode: @"r+"];
else
stream = [OFURIHandler openItemAtURI: URI mode: mode];
stream = [OFIRIHandler openItemAtIRI: IRI mode: mode];
} @catch (id e) {
[self release];
@throw e;
}
self = [self initWithStream: stream mode: mode];
|
︙ | | |
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
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
|
+
+
+
+
+
+
+
+
+
+
+
+
+
|
- (OFLHAArchiveEntry *)nextEntry
{
char header[21];
size_t headerLen;
if (_mode != modeRead)
@throw [OFInvalidArgumentException exception];
if (_currentEntry != nil && _lastReturnedStream == nil) {
/*
* No read stream was created since the last call to
* -[nextEntry]. Create it so that we can properly skip the
* data.
*/
void *pool = objc_autoreleasePoolPush();
[self streamForReadingCurrentEntry];
objc_autoreleasePoolPop(pool);
}
[_currentEntry release];
_currentEntry = nil;
[(OFLHAArchiveFileReadStream *)_lastReturnedStream of_skip];
@try {
[_lastReturnedStream close];
|
︙ | | |
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
|
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
|
-
+
|
@throw [OFTruncatedDataException exception];
}
headerLen += [_stream readIntoBuffer: header + headerLen
length: 21 - headerLen];
}
_currentEntry= [[OFLHAArchiveEntry alloc]
_currentEntry = [[OFLHAArchiveEntry alloc]
of_initWithHeader: header
stream: _stream
encoding: _encoding];
return _currentEntry;
}
|
︙ | | |
Modified src/OFLHAArchiveEntry+Private.h
from [521b95b2fc]
to [481462ccc6].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFLHAArchiveEntry.h
from [89ea23a8c1]
to [3e354e177e].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFLHAArchiveEntry.m
from [b338459827]
to [1e7711c5fc].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFLHADecompressingStream.h
from [1061027b73]
to [825738c9bf].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFLHADecompressingStream.m
from [c9a31f2d2f]
to [a9c8d0ec12].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFList.h
from [f2ae387af6]
to [e9e426b5c4].
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
|
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
|
-
+
-
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFObject.h"
#import "OFCollection.h"
#import "OFEnumerator.h"
#import "OFSerialization.h"
OF_ASSUME_NONNULL_BEGIN
/** @file */
/*
* Make clang's -Wdocumentation shut about about using @struct on someting it
|
︙ | | |
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
-
+
-
|
#endif
/**
* @class OFList OFList.h ObjFW/OFList.h
*
* @brief A class which provides easy to use double-linked lists.
*/
@interface OFList OF_GENERIC(ObjectType): OFObject <OFCopying, OFCollection,
@interface OFList OF_GENERIC(ObjectType): OFObject <OFCopying, OFCollection>
OFSerialization>
#if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN)
# define ObjectType id
#endif
{
OFListItem _Nullable _firstListItem;
OFListItem _Nullable _lastListItem;
size_t _count;
|
︙ | | |
Modified src/OFList.m
from [f4144af409]
to [9b79071582].
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
|
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
|
-
+
-
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#include <string.h>
#import "OFList.h"
#import "OFString.h"
#import "OFXMLElement.h"
#import "OFArray.h"
#import "OFEnumerationMutationException.h"
#import "OFInvalidArgumentException.h"
struct _OFListItem {
struct _OFListItem *previous, *next;
|
︙ | | |
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
|
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
@synthesize firstListItem = _firstListItem, lastListItem = _lastListItem;
+ (instancetype)list
{
return [[[self alloc] init] autorelease];
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
self = [self init];
@try {
void *pool = objc_autoreleasePoolPush();
if (![element.name isEqual: self.className] ||
![element.namespace isEqual: OFSerializationNS])
@throw [OFInvalidArgumentException exception];
for (OFXMLElement *child in
[element elementsForNamespace: OFSerializationNS]) {
void *pool2 = objc_autoreleasePoolPush();
[self appendObject: child.objectByDeserializing];
objc_autoreleasePoolPop(pool2);
}
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
OFListItem next;
for (OFListItem iter = _firstListItem; iter != NULL; iter = next) {
[iter->object release];
next = iter->next;
|
︙ | | |
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
|
339
340
341
342
343
344
345
346
347
348
349
350
351
352
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
[ret appendString: @"\n]"];
[ret makeImmutable];
return ret;
}
- (OFXMLElement *)XMLElementBySerializing
{
OFXMLElement *element =
[OFXMLElement elementWithName: self.className
namespace: OFSerializationNS];
for (OFListItem iter = _firstListItem;
iter != NULL; iter = iter->next) {
void *pool = objc_autoreleasePoolPush();
[element addChild: [iter->object XMLElementBySerializing]];
objc_autoreleasePoolPop(pool);
}
return element;
}
- (int)countByEnumeratingWithState: (OFFastEnumerationState *)state
objects: (id *)objects
count: (int)count
{
OFListItem listItem;
memcpy(&listItem, state->extra, sizeof(listItem));
|
︙ | | |
Modified src/OFLocale.h
from [ca12b9c93f]
to [231ed8a762].
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
|
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
|
-
+
+
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFObject.h"
#import "OFString.h"
OF_ASSUME_NONNULL_BEGIN
@class OFIRI;
/** @file */
/**
* @def OF_LOCALIZED
*
* @brief Returns the localized string for the specified ID with the specified
|
︙ | | |
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
|
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
|
-
-
+
-
+
-
-
-
+
-
+
-
|
/**
* @brief Returns the decimal point of the system's locale.
*
* @return The decimal point of the system's locale
*/
+ (nullable OFString *)decimalSeparator;
#ifdef OF_HAVE_FILES
/**
* @brief Adds a directory to scan for localizations.
*
* @param path The path to the directory to scan for localizations
* @param IRI The IRI to the directory to scan for localizations
*/
+ (void)addLocalizationDirectory: (OFString *)path;
+ (void)addLocalizationDirectoryIRI: (OFIRI *)IRI;
#endif
/**
* @brief Initializes the current OFLocale.
*
* @warning This sets the locale via `setlocale()`!
*
* @warning You should never call this yourself, except if you do not use
* @ref OFApplication. In this case, you need to allocate exactly one
* instance of OFLocale, which will become the current locale, and
* call this method.
*/
- (instancetype)init;
#ifdef OF_HAVE_FILES
/**
* @brief Adds a directory to scan for localizations.
*
* @param path The path to the directory to scan for localizations
* @param IRI The IRI to the directory to scan for localizations
*/
- (void)addLocalizationDirectory: (OFString *)path;
- (void)addLocalizationDirectoryIRI: (OFIRI *)IRI;
#endif
/**
* @brief Returns the localized string for the specified ID, using the fallback
* string if it cannot be looked up or is missing.
*
* @note This takes a variadic argument, terminated by `nil`, that consists of
* pairs of variable names and variable values, which will be replaced
|
︙ | | |
Modified src/OFLocale.m
from [e8b5569b76]
to [7cfd367431].
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
|
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
|
-
+
-
-
-
+
+
+
+
+
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#include <locale.h>
#import "OFLocale.h"
#import "OFString.h"
#import "OFArray.h"
#import "OFDictionary.h"
#import "OFArray.h"
#import "OFDictionary.h"
#import "OFIRI.h"
#import "OFNumber.h"
#import "OFString.h"
#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFOpenItemFailedException.h"
#ifdef OF_AMIGAOS
# define Class IntuitionClass
# include <proto/dos.h>
# include <proto/exec.h>
# include <proto/locale.h>
# undef Class
#endif
static OFLocale *currentLocale = nil;
static OFDictionary *operatorPrecedences = nil;
#ifndef OF_AMIGAOS
static void
|
︙ | | |
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
|
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
|
-
-
+
-
+
-
+
+
+
+
|
}
+ (OFString *)decimalSeparator
{
return currentLocale.decimalSeparator;
}
#ifdef OF_HAVE_FILES
+ (void)addLocalizationDirectory: (OFString *)path
+ (void)addLocalizationDirectoryIRI: (OFIRI *)IRI
{
[currentLocale addLocalizationDirectory: path];
[currentLocale addLocalizationDirectoryIRI: IRI];
}
#endif
- (instancetype)init
{
self = [super init];
@try {
#ifndef OF_AMIGAOS
char *locale, *messagesLocale = NULL;
if (currentLocale != nil)
@throw [OFInitializationFailedException
exceptionWithClass: self.class];
# ifdef OF_MSDOS
_encoding = OFStringEncodingCodepage437;
# else
_encoding = OFStringEncodingUTF8;
# endif
_decimalSeparator = @".";
_localizedStrings = [[OFMutableArray alloc] init];
if ((locale = setlocale(LC_ALL, "")) != NULL)
_decimalSeparator = [[OFString alloc]
initWithCString: localeconv()->decimal_point
encoding: _encoding];
|
︙ | | |
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
|
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
|
-
-
+
+
-
+
-
+
-
+
|
[_countryCode release];
[_decimalSeparator release];
[_localizedStrings release];
[super dealloc];
}
#ifdef OF_HAVE_FILES
- (void)addLocalizationDirectory: (OFString *)path
- (void)addLocalizationDirectoryIRI: (OFIRI *)IRI
{
void *pool;
OFIRI *mapIRI, *localizationIRI;
OFString *mapPath, *languageCode, *countryCode, *localizationFile;
OFString *languageCode, *countryCode, *localizationFile;
OFDictionary *map;
if (_languageCode == nil)
return;
pool = objc_autoreleasePoolPush();
mapPath = [path stringByAppendingPathComponent: @"localizations.json"];
mapIRI = [IRI IRIByAppendingPathComponent: @"localizations.json"];
@try {
map = [[OFString stringWithContentsOfFile: mapPath]
map = [[OFString stringWithContentsOfIRI: mapIRI]
objectByParsingJSON];
} @catch (OFOpenItemFailedException *e) {
objc_autoreleasePoolPop(pool);
return;
}
languageCode = _languageCode.lowercaseString;
|
︙ | | |
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
|
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
|
-
+
-
-
+
+
-
|
objectForKey: @""];
if (localizationFile == nil) {
objc_autoreleasePoolPop(pool);
return;
}
localizationFile = [path stringByAppendingPathComponent:
localizationIRI = [IRI IRIByAppendingPathComponent:
[localizationFile stringByAppendingString: @".json"]];
[_localizedStrings addObject: [[OFString stringWithContentsOfFile:
localizationFile] objectByParsingJSON]];
[_localizedStrings addObject: [[OFString stringWithContentsOfIRI:
localizationIRI] objectByParsingJSON]];
objc_autoreleasePoolPop(pool);
}
#endif
- (OFString *)localizedStringForID: (OFConstantString *)ID
fallback: (id)fallback, ...
{
OFString *ret;
va_list args;
|
︙ | | |
Modified src/OFLocking.h
from [155544ed9e]
to [fb6e822d44].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFMD5Hash.h
from [cdd5a3515e]
to [2f12b2aa8f].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFMD5Hash.m
from [190d96fa7c]
to [f3d5c8a60c].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFMapTable+Private.h
from [34b0bddd51]
to [dd6291788e].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFMapTable.h
from [382835ac81]
to [0187aff28b].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFMapTable.m
from [2885d27493]
to [fd0add4a94].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFMapTableDictionary.h
from [23bbcf2cb0]
to [f2de5e0f29].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFMapTableDictionary.m
from [509fe49186]
to [7d4c6241d2].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
-
|
#import "OFMapTableDictionary.h"
#import "OFArray.h"
#import "OFMapTable+Private.h"
#import "OFMapTable.h"
#import "OFMutableMapTableDictionary.h"
#import "OFString.h"
#import "OFXMLElement.h"
#import "OFEnumerationMutationException.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
static void *
copy(void *object)
|
︙ | | |
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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
|
222
223
224
225
226
227
228
229
230
231
232
233
234
235
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
[_mapTable setObject: object forKey: key];
}
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
self = [super init];
@try {
void *pool = objc_autoreleasePoolPush();
OFArray *keys, *objects;
OFEnumerator *keyEnumerator, *objectEnumerator;
OFXMLElement *keyElement, *objectElement;
keys = [element elementsForName: @"key"
namespace: OFSerializationNS];
objects = [element elementsForName: @"object"
namespace: OFSerializationNS];
if (keys.count != objects.count)
@throw [OFInvalidFormatException exception];
_mapTable = [[OFMapTable alloc]
initWithKeyFunctions: keyFunctions
objectFunctions: objectFunctions
capacity: keys.count];
keyEnumerator = [keys objectEnumerator];
objectEnumerator = [objects objectEnumerator];
while ((keyElement = [keyEnumerator nextObject]) != nil &&
(objectElement = [objectEnumerator nextObject]) != nil) {
void *pool2 = objc_autoreleasePoolPush();
OFXMLElement *key, *object;
key = [keyElement elementsForNamespace:
OFSerializationNS].firstObject;
object = [objectElement elementsForNamespace:
OFSerializationNS].firstObject;
if (key == nil || object == nil)
@throw [OFInvalidFormatException exception];
[_mapTable setObject: object.objectByDeserializing
forKey: key.objectByDeserializing];
objc_autoreleasePoolPop(pool2);
}
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[_mapTable release];
|
︙ | | |
Modified src/OFMapTableSet.h
from [1664d9d036]
to [98f1d6ac4b].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
Modified src/OFMapTableSet.m
from [87bc750df2]
to [c087e53711].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
|
-
+
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | |
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
-
|
#import "OFMapTableSet.h"
#import "OFArray.h"
#import "OFCountedMapTableSet.h"
#import "OFMapTable.h"
#import "OFMapTable+Private.h"
#import "OFMutableMapTableSet.h"
#import "OFString.h"
#import "OFXMLElement.h"
#import "OFInvalidArgumentException.h"
#import "OFEnumerationMutationException.h"
static void *
retain(void *object)
{
|
︙ | | |
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
|
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
while ((object = va_arg(arguments, id)) != nil)
[_mapTable setObject: (void *)1 forKey: object];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
self = [self init];
@try {
void *pool = objc_autoreleasePoolPush();
if ((![element.name isEqual: @"OFSet"] &&
![element.name isEqual: @"OFMutableSet"]) ||
![element.namespace isEqual: OFSerializationNS])
@throw [OFInvalidArgumentException exception];
for (OFXMLElement *child in
[element elementsForNamespace: OFSerializationNS]) {
void *pool2 = objc_autoreleasePoolPush();
[_mapTable setObject: (void *)1
forKey: [child objectByDeserializing]];
objc_autoreleasePoolPop(pool2);
}
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[_mapTable release];
|
︙ | | |
Added src/OFMatrix4x4.h version [c303f1010a].