Changes In Branch 1.1
Through [84853039f8]
Excluding Merge-Ins
This is equivalent to a diff from
f61f430bfb
to 84853039f8
Added .github/workflows/macos-12.yml version [ee9ffcacad].
|
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
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
name: macos-12
on: [push, pull_request]
jobs:
tests:
runs-on: macos-12
strategy:
matrix:
configure_flags:
-
- --disable-threads
- --disable-threads --disable-sockets
- --disable-threads --disable-files
- --disable-threads --disable-sockets --disable-files
- --disable-sockets
- --disable-sockets --disable-files
- --disable-files
- --disable-shared
steps:
- name: Install dependencies
run: brew install autoconf automake
- uses: actions/checkout@v4
- name: autogen.sh
run: ./autogen.sh
- name: configure
run: ./configure ${{ matrix.configure_flags }}
- name: make
run: make -j$(sysctl -n hw.logicalcpu)
- name: make check
run: make check
- name: make install
run: sudo make install
|
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
Deleted .github/workflows/macos-latest.yml version [2ffa2189c3].
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
|
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
name: macos-latest
on: [push, pull_request]
jobs:
tests:
runs-on: macos-latest
strategy:
matrix:
configure_flags:
-
- --disable-threads
- --disable-threads --disable-sockets
- --disable-threads --disable-files
- --disable-threads --disable-sockets --disable-files
- --disable-sockets
- --disable-sockets --disable-files
- --disable-files
- --disable-shared
steps:
- name: Install dependencies
run: brew install autoconf automake
- uses: actions/checkout@v4
- name: autogen.sh
run: ./autogen.sh
- name: configure
run: ./configure ${{ matrix.configure_flags }}
- name: make
run: make -j$(sysctl -n hw.logicalcpu)
- name: make check
run: make check
- name: make install
run: sudo make install
|
Modified ChangeLog
from [7f06c4f76b]
to [a211fb83e7].
1
2
3
4
5
6
7
8
9
10
11
12
13
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
+
+
+
+
+
+
+
+
+
+
|
Legend:
* Changes of existing features or bugfixes
+ New features
This file only contains the most significant changes.
ObjFW 1.1.2 -> ObjFW 1.1.3, 2024-05-12
* Fixes +[OFSystemInfo networkInterfaces] on NetBSD.
* Properly hides private symbols so they can't be used accidentally anymore.
* Adds missing documentation for various functions and macros.
* Uses RtlGenRandom to get proper randomness on Windows now.
* No longer uses _wutime64, which is buggy in some MinGW distributions.
* Only uses blx on ARM if it is available now.
* Adds a workaround for OFSubprocess tests on Windows 9x.
* Skips symlink tests if symlinks are unavailable.
ObjFW 1.1.1 -> ObjFW 1.1.2, 2024-04-20
* Fixes configure script on systems using BusyBox for tr.
* Fixes compiling for Haiku.
* Fixes -[contentsOfDirectoryAtIRI:] corrupting the stack on Solaris.
* Fixes compiling for Wii with newer SDK.
* Fixes missing endbr / bti.
* Minor optimizations to ARM64 assembly.
|
︙ | | |
Modified Doxyfile
from [75514e9314]
to [ea0872cd8b].
︙ | | |
46
47
48
49
50
51
52
|
46
47
48
49
50
51
52
53
|
+
|
OF_WEAK_UNAVAILABLE= \
SIGHUP \
SIGUSR1 \
SIGUSR2
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = YES
IGNORE_PREFIX = OF OF_ OT OT_
EXTRACT_STATIC = yes
|
Modified README.md
from [e80110edc6]
to [1d97f3d87c].
︙ | | |
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
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
|
+
+
|
ObjFW packages are available for various operating systems and can be
installed as following:
Operating System | Command
---------------------------|---------------------------------------------
Alpine Linux | `doas apk add objfw`
CRUX | `sudo prt-get depinst objfw`
Debian | `sudo apt install objfw`
Fedora | `sudo dnf install objfw`
FreeBSD | `sudo pkg install objfw`
Haiku | `pkgman install objfw`
Haiku (gcc2h) | `pkgman install objfw_x86`
macOS (Homebrew) | `brew install objfw`
macOS (pkgsrc) | `cd $PKGSRCDIR/devel/objfw && make install`
NetBSD | `cd /usr/pkgsrc/devel/objfw && make install`
OpenBSD | `doas pkg_add objfw`
OpenIndiana | `sudo pkg install developer/objfw`
Ubuntu | `sudo apt install objfw`
Windows (MSYS2/CLANG64) | `pacman -S mingw-w64-clang-x86_64-objfw`
Windows (MSYS2/CLANGARM64) | `pacman -S mingw-w64-clang-aarch64-objfw`
Windows (MSYS2/UCRT64) | `pacman -S mingw-w64-ucrt-x86_64-objfw`
Windows (MSYS2/MINGW32) | `pacman -S mingw-w64-i686-objfw`
If your operating system is not listed, you can
<a href="#building-from-source">build ObjFW from source</a>.
|
︙ | | |
Modified configure.ac
from [63f2b5a434]
to [aa1242302f].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
-
+
-
+
-
-
+
|
AC_INIT(ObjFW, 1.2dev, js@nil.im, objfw, https://objfw.nil.im/)
AC_INIT(ObjFW, 1.1.3, 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, 2, [The minor version of ObjFW])
AC_DEFINE(OBJFW_VERSION_MINOR, 1, [The minor version of ObjFW])
dnl This may only be set to 1.2 once 1.2 is released
AC_SUBST(BUNDLE_VERSION, 1.1.0)
AC_SUBST(BUNDLE_VERSION, 1.1.3)
AC_SUBST(BUNDLE_SHORT_VERSION, 1.1)
for i in configure.ac build-aux/m4/*; do
AS_IF([test $i -nt configure], [
AC_MSG_ERROR([$i is newer than configure! Run ./autogen.sh!])
])
done
|
︙ | | |
301
302
303
304
305
306
307
308
309
310
311
312
313
314
|
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
|
+
|
case "$host" in
mips*-*-*)
dnl Clang generates MIPS assembly not accepted by GNU as,
dnl however, Clang's integrated assembler doesn't accept
dnl everything used in ObjFW's assembly files. Therefore, use
dnl the integrated assembler for ObjC files, but not for
dnl assembly files.
ASFLAGS="$ASFLAGS -no-integrated-as"
OBJCFLAGS="$OBJCFLAGS -integrated-as"
OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -integrated-as"
;;
i?86-*-darwin* | x86_64-*-darwin*)
dnl Don't use -no-integrated-as on Darwin. It breaks building
dnl for the iOS simulator.
;;
|
︙ | | |
837
838
839
840
841
842
843
844
845
846
847
848
849
850
|
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
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
AC_MSG_RESULT($fp_endianess)
AS_IF([test x"$fp_endianess" = x"unknown"], [
AC_MSG_ERROR(
[Floating point implementation does not conform to IEEE 754!])])
case "$host_cpu" in
arm* | earm*)
AC_MSG_CHECKING(for blx)
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([], [
#if !defined(__arm64__) && !defined(__arch64__) && \
!defined(__ARM64_ARCH_8__)
__asm__ __volatile__ (
"blx r12"
);
#endif
])
], [
AC_DEFINE(HAVE_BLX, 1, [Whether we have blx])
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
])
AC_MSG_CHECKING(for VFP2 or above)
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([], [
#if !defined(__arm64__) && !defined(__aarch64__) && \
!defined(__ARM64_ARCH_8__)
__asm__ __volatile__ (
"vstmdb sp!, {d0-d7}"
|
︙ | | |
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
|
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
|
-
+
|
])
AS_IF([test x"$GOBJC" = x"yes"], [
OBJCFLAGS="$OBJCFLAGS -Wwrite-strings -Wpointer-arith"
AC_ARG_ENABLE(werror,
AS_HELP_STRING([--disable-werror], [do not build with -Werror]))
AS_IF([test x"$enable_werror" != x"no"], [
AS_IF([test x"$enable_werror" = x"yes"], [
OBJCFLAGS="$OBJCFLAGS -Werror"
])
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -Werror"
AC_MSG_CHECKING(whether we need -Wno-strict-aliasing due to GCC bugs)
AC_COMPILE_IFELSE([
|
︙ | | |
Modified extra.mk.in
from [22670d3586]
to [882f275473].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
-
+
-
+
|
OBJFW_SHARED_LIB = @OBJFW_SHARED_LIB@
OBJFW_STATIC_LIB = @OBJFW_STATIC_LIB@
OBJFW_FRAMEWORK = @OBJFW_FRAMEWORK@
OBJFW_LIB_MAJOR = 1
OBJFW_LIB_MINOR = 1
OBJFW_LIB_PATCH = 0
OBJFW_LIB_PATCH = 2
OBJFW_LIB_MAJOR_MINOR = ${OBJFW_LIB_MAJOR}.${OBJFW_LIB_MINOR}
OBJFWRT_SHARED_LIB = @OBJFWRT_SHARED_LIB@
OBJFWRT_STATIC_LIB = @OBJFWRT_STATIC_LIB@
OBJFWRT_FRAMEWORK = @OBJFWRT_FRAMEWORK@
OBJFWRT_LIB_MAJOR = 1
OBJFWRT_LIB_MINOR = 1
OBJFWRT_LIB_PATCH = 0
OBJFWRT_LIB_PATCH = 1
OBJFWRT_LIB_MAJOR_MINOR = ${OBJFWRT_LIB_MAJOR}.${OBJFWRT_LIB_MINOR}
OBJFWBRIDGE_SHARED_LIB = @OBJFWBRIDGE_SHARED_LIB@
OBJFWBRIDGE_STATIC_LIB = @OBJFWBRIDGE_STATIC_LIB@
OBJFWBRIDGE_FRAMEWORK = @OBJFWBRIDGE_FRAMEWORK@
OBJFWBRIDGE_LIB_MAJOR = 1
OBJFWBRIDGE_LIB_MINOR = 0
|
︙ | | |
Modified generators/unicode/TableGenerator.m
from [4286c92f40]
to [49e6ad1d3f].
︙ | | |
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
-
+
+
|
void *pool = objc_autoreleasePoolPush();
OFFile *file = [OFFile fileWithPath: path
mode: @"w"];
[file writeString: COPYRIGHT
@"#include \"config.h\"\n"
@"\n"
@"#import \"OFString.h\"\n\n"
@"#import \"unicode.h\"\n"
@"\n"
@"static const OFUnichar emptyPage[0x100] = { 0 };\n"
@"\n"];
/* Write uppercasePage%u */
for (OFUnichar i = 0; i < 0x110000; i += 0x100) {
bool isEmpty = true;
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
* But from now on, we need the size.
*/
_uppercaseTableSize++;
_lowercaseTableSize++;
_titlecaseTableSize++;
_caseFoldingTableSize++;
/* Write OFUnicodeUppercaseTable */
/* Write _OFUnicodeUppercaseTable */
[file writeFormat: @"const OFUnichar *const "
@"OFUnicodeUppercaseTable[0x%X] = {\n\t",
@"_OFUnicodeUppercaseTable[0x%X] = {\n\t",
_uppercaseTableSize];
for (OFUnichar i = 0; i < _uppercaseTableSize; i++) {
if (_uppercaseTableUsed[i])
[file writeFormat: @"uppercasePage%u", i];
else
[file writeString: @"emptyPage"];
if (i + 1 < _uppercaseTableSize) {
if ((i + 1) % 4 == 0)
[file writeString: @",\n\t"];
else
[file writeString: @", "];
}
}
[file writeString: @"\n};\n\n"];
/* Write OFUnicodeLowercaseTable */
/* Write _OFUnicodeLowercaseTable */
[file writeFormat: @"const OFUnichar *const "
@"OFUnicodeLowercaseTable[0x%X] = {\n\t",
@"_OFUnicodeLowercaseTable[0x%X] = {\n\t",
_lowercaseTableSize];
for (OFUnichar i = 0; i < _lowercaseTableSize; i++) {
if (_lowercaseTableUsed[i])
[file writeFormat: @"lowercasePage%u", i];
else
[file writeString: @"emptyPage"];
if (i + 1 < _lowercaseTableSize) {
if ((i + 1) % 4 == 0)
[file writeString: @",\n\t"];
else
[file writeString: @", "];
}
}
[file writeString: @"\n};\n\n"];
/* Write OFUnicodeTitlecaseTable */
/* Write _OFUnicodeTitlecaseTable */
[file writeFormat: @"const OFUnichar *const "
@"OFUnicodeTitlecaseTable[0x%X] = {\n\t",
@"_OFUnicodeTitlecaseTable[0x%X] = {\n\t",
_titlecaseTableSize];
for (OFUnichar i = 0; i < _titlecaseTableSize; i++) {
if (_titlecaseTableUsed[i] == 1)
[file writeFormat: @"titlecasePage%u", i];
else if (_titlecaseTableUsed[i] == 2)
[file writeFormat: @"uppercasePage%u", i];
else
[file writeString: @"emptyPage"];
if (i + 1 < _titlecaseTableSize) {
if ((i + 1) % 4 == 0)
[file writeString: @",\n\t"];
else
[file writeString: @", "];
}
}
[file writeString: @"\n};\n\n"];
/* Write OFUnicodeCaseFoldingTable */
/* Write _OFUnicodeCaseFoldingTable */
[file writeFormat: @"const OFUnichar *const "
@"OFUnicodeCaseFoldingTable[0x%X] = {\n\t",
@"_OFUnicodeCaseFoldingTable[0x%X] = {\n\t",
_caseFoldingTableSize];
for (OFUnichar i = 0; i < _caseFoldingTableSize; i++) {
if (_caseFoldingTableUsed[i] == 1)
[file writeFormat: @"caseFoldingPage%u", i];
else if (_caseFoldingTableUsed[i] == 2)
[file writeFormat: @"lowercasePage%u", i];
|
︙ | | |
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
|
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
|
-
-
-
-
+
+
+
+
-
+
+
-
+
+
-
+
+
-
+
+
|
OFFile *file = [OFFile fileWithPath: path
mode: @"w"];
[file writeString: COPYRIGHT
@"#import \"OFString.h\"\n\n"];
[file writeFormat:
@"#define OFUnicodeUppercaseTableSize 0x%X\n"
@"#define OFUnicodeLowercaseTableSize 0x%X\n"
@"#define OFUnicodeTitlecaseTableSize 0x%X\n"
@"#define OFUnicodeCaseFoldingTableSize 0x%X\n\n",
@"#define _OFUnicodeUppercaseTableSize 0x%X\n"
@"#define _OFUnicodeLowercaseTableSize 0x%X\n"
@"#define _OFUnicodeTitlecaseTableSize 0x%X\n"
@"#define _OFUnicodeCaseFoldingTableSize 0x%X\n\n",
_uppercaseTableSize, _lowercaseTableSize, _titlecaseTableSize,
_caseFoldingTableSize];
[file writeString:
@"#ifdef __cplusplus\n"
@"extern \"C\" {\n"
@"#endif\n"
@"extern const OFUnichar *const _Nonnull\n"
@" OFUnicodeUppercaseTable[OFUnicodeUppercaseTableSize];\n"
@" _OFUnicodeUppercaseTable[_OFUnicodeUppercaseTableSize] "
@"OF_VISIBILITY_HIDDEN;\n"
@"extern const OFUnichar *const _Nonnull\n"
@" OFUnicodeLowercaseTable[OFUnicodeLowercaseTableSize];\n"
@" _OFUnicodeLowercaseTable[_OFUnicodeLowercaseTableSize] "
@"OF_VISIBILITY_HIDDEN;\n"
@"extern const OFUnichar *const _Nonnull\n"
@" OFUnicodeTitlecaseTable[OFUnicodeTitlecaseTableSize];\n"
@" _OFUnicodeTitlecaseTable[_OFUnicodeTitlecaseTableSize] "
@"OF_VISIBILITY_HIDDEN;\n"
@"extern const OFUnichar *const _Nonnull\n"
@" OFUnicodeCaseFoldingTable[OFUnicodeCaseFoldingTableSize];\n"
@" _OFUnicodeCaseFoldingTable[_OFUnicodeCaseFoldingTableSize]\n"
@" OF_VISIBILITY_HIDDEN;\n"
@"#ifdef __cplusplus\n"
@"}\n"
@"#endif\n"];
objc_autoreleasePoolPop(pool);
}
@end
|
Modified src/OFASPrintF.h
from [e19f4f7099]
to [934e8a3e26].
︙ | | |
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
-
-
+
+
+
|
#import "macros.h"
OF_ASSUME_NONNULL_BEGIN
#ifdef __cplusplus
extern "C" {
#endif
extern int OFVASPrintF(
char *_Nullable *_Nonnull, const char *_Nonnull, va_list);
extern int _OFVASPrintF(
char *_Nullable *_Nonnull, const char *_Nonnull, va_list)
OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
OF_ASSUME_NONNULL_END
|
Modified src/OFASPrintF.m
from [e60e10983b]
to [862e4e73cc].
︙ | | |
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
|
-
+
|
if (ctx->lengthModifier != lengthModifierNone)
return false;
ctx->subformat[ctx->subformatLen - 1] = 's';
{
char buffer[5];
size_t len = OFUTF8StringEncode(
size_t len = _OFUTF8StringEncode(
va_arg(ctx->arguments, OFUnichar), buffer);
if (len == 0)
return false;
buffer[len] = 0;
tmpLen = asprintf(&tmp, ctx->subformat, buffer);
|
︙ | | |
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
|
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
|
-
+
|
return false;
if ((buffer = malloc((len * 4) + 1)) == NULL)
return false;
j = 0;
for (size_t i = 0; i < len; i++) {
size_t clen = OFUTF8StringEncode(arg[i],
size_t clen = _OFUTF8StringEncode(arg[i],
buffer + j);
if (clen == 0) {
free(buffer);
return false;
}
|
︙ | | |
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
|
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
|
-
+
|
formatFlagsState,
formatFieldWidthState,
formatLengthModifierState,
formatConversionSpecifierState
};
int
OFVASPrintF(char **string, const char *format, va_list arguments)
_OFVASPrintF(char **string, const char *format, va_list arguments)
{
struct Context ctx;
ctx.format = format;
ctx.formatLen = strlen(format);
memset(ctx.subformat, 0, maxSubformatLen + 1);
ctx.subformatLen = 0;
|
︙ | | |
Modified src/OFApplication.m
from [f87eabe4cc]
to [a1d7561a5b].
︙ | | |
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
-
+
|
[delegate release];
[[OFNotificationCenter defaultCenter] postNotification: notification];
#if defined(OF_HAVE_THREADS) && defined(OF_HAVE_SOCKETS) && \
defined(OF_AMIGAOS) && !defined(OF_MORPHOS)
OFSocketDeinit();
_OFSocketDeinit();
#endif
}
int
OFApplicationMain(int *argc, char **argv[], id <OFApplicationDelegate> delegate)
{
[OFLocale currentLocale];
|
︙ | | |
Modified src/OFArchiveIRIHandler.h
from [4bae7280e5]
to [e82e471b8d].
︙ | | |
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
-
-
+
+
|
@interface OFArchiveIRIHandler: OFIRIHandler
@end
#ifdef __cplusplus
extern "C" {
#endif
extern OFIRI *OFArchiveIRIHandlerIRIForFileInArchive(OFString *, OFString *,
OFIRI *);
extern OFIRI *_OFArchiveIRIHandlerIRIForFileInArchive(OFString *, OFString *,
OFIRI *) OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
OF_ASSUME_NONNULL_END
|
Modified src/OFArchiveIRIHandler.m
from [0a5674435c]
to [4da1115176].
︙ | | |
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
-
+
|
{
return (character != '!' && _characterIsMember(_characterSet,
@selector(characterIsMember:), character));
}
@end
OFIRI *
OFArchiveIRIHandlerIRIForFileInArchive(OFString *scheme,
_OFArchiveIRIHandlerIRIForFileInArchive(OFString *scheme,
OFString *pathInArchive, OFIRI *archiveIRI)
{
static OFOnceControl onceControl = OFOnceControlInitValue;
OFMutableIRI *ret = [OFMutableIRI IRIWithScheme: scheme];
void *pool = objc_autoreleasePoolPush();
OFOnce(&onceControl, initPathAllowedCharacters);
|
︙ | | |
Modified src/OFBase64.h
from [c69641ab41]
to [2f3db0b163].
︙ | | |
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
-
-
+
+
+
|
@class OFString;
@class OFMutableData;
#ifdef __cplusplus
extern "C" {
#endif
extern OFString *OFBase64Encode(const void *, size_t);
extern bool OFBase64Decode(OFMutableData *, const char *, size_t);
extern OFString *_OFBase64Encode(const void *, size_t) OF_VISIBILITY_HIDDEN;
extern bool _OFBase64Decode(OFMutableData *, const char *, size_t)
OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
OF_ASSUME_NONNULL_END
|
Modified src/OFBase64.m
from [1bbfb68f90]
to [2e8e2f6efd].
︙ | | |
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
|
-
+
|
3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 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, -1, -1, -1, -1, -1
};
OFString *
OFBase64Encode(const void *data, size_t length)
_OFBase64Encode(const void *data, size_t length)
{
OFMutableString *ret = [OFMutableString string];
uint8_t *buffer = (uint8_t *)data;
size_t i;
uint8_t rest;
char tb[4];
uint32_t sb;
|
︙ | | |
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
-
+
|
[ret makeImmutable];
return ret;
}
bool
OFBase64Decode(OFMutableData *data, const char *string, size_t length)
_OFBase64Decode(OFMutableData *data, const char *string, size_t length)
{
const uint8_t *buffer = (const uint8_t *)string;
size_t i;
if ((length & 3) != 0)
return false;
|
︙ | | |
Modified src/OFCRC16.h
from [3f16abe72b]
to [53c7fedb47].
︙ | | |
25
26
27
28
29
30
31
32
33
34
35
36
|
25
26
27
28
29
30
31
32
33
34
35
36
|
-
-
+
+
|
#endif
#import "macros.h"
#ifdef __cplusplus
extern "C" {
#endif
extern uint16_t OFCRC16(uint16_t crc, const void *_Nonnull bytes,
size_t length);
extern uint16_t _OFCRC16(uint16_t crc, const void *_Nonnull bytes,
size_t length) OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
|
Modified src/OFCRC16.m
from [84c30fd412]
to [d62b8e5364].
︙ | | |
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
-
+
|
#include "config.h"
#import "OFCRC16.h"
static const uint16_t CRC16Magic = 0xA001;
uint16_t
OFCRC16(uint16_t CRC, const void *bytes_, size_t length)
_OFCRC16(uint16_t CRC, const void *bytes_, size_t length)
{
const unsigned char *bytes = bytes_;
for (size_t i = 0; i < length; i++) {
CRC ^= bytes[i];
for (uint8_t j = 0; j < 8; j++)
|
︙ | | |
Modified src/OFCRC32.h
from [8d31bcaac4]
to [24126b7a03].
︙ | | |
25
26
27
28
29
30
31
32
33
34
35
36
|
25
26
27
28
29
30
31
32
33
34
35
36
|
-
-
+
+
|
#endif
#import "macros.h"
#ifdef __cplusplus
extern "C" {
#endif
extern uint32_t OFCRC32(uint32_t crc, const void *_Nonnull bytes,
size_t length);
extern uint32_t _OFCRC32(uint32_t crc, const void *_Nonnull bytes,
size_t length) OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
|
Modified src/OFCRC32.m
from [9efe742312]
to [033a9d1abd].
︙ | | |
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
-
+
|
#include "config.h"
#import "OFCRC32.h"
static const uint32_t CRC32Magic = 0xEDB88320;
uint32_t
OFCRC32(uint32_t CRC, const void *bytes_, size_t length)
_OFCRC32(uint32_t CRC, const void *bytes_, size_t length)
{
const unsigned char *bytes = bytes_;
for (size_t i = 0; i < length; i++) {
CRC ^= bytes[i];
for (uint8_t j = 0; j < 8; j++)
|
︙ | | |
Modified src/OFConcreteValue.m
from [8933b62636]
to [4982399c1c].
︙ | | |
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
-
+
|
- (instancetype)initWithBytes: (const void *)bytes
objCType: (const char *)objCType
{
self = [super initWithBytes: bytes objCType: objCType];
@try {
_size = OFSizeOfTypeEncoding(objCType);
_objCType = OFStrDup(objCType);
_objCType = _OFStrDup(objCType);
_bytes = OFAllocMemory(1, _size);
memcpy(_bytes, bytes, _size);
} @catch (id e) {
[self release];
@throw e;
}
|
︙ | | |
Modified src/OFConstantString.m
from [cde23b7b44]
to [e20d1bfa3e].
︙ | | |
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
-
+
|
if ([self isMemberOfClass: [OFConstantUTF8String class]])
return;
ivars = OFAllocZeroedMemory(1, sizeof(*ivars));
ivars->cString = _cString;
ivars->cStringLength = _cStringLength;
switch (OFUTF8StringCheck(ivars->cString, ivars->cStringLength,
switch (_OFUTF8StringCheck(ivars->cString, ivars->cStringLength,
&ivars->length)) {
case 1:
ivars->isUTF8 = true;
break;
case -1:
OFFreeMemory(ivars);
@throw [OFInvalidEncodingException exception];
|
︙ | | |
Modified src/OFDDPSocket.m
from [9c71163b23]
to [ff7f44acd0].
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
|
#endif
@throw [OFBindDDPSocketFailedException
exceptionWithNetwork: network
node: node
port: port
protocolType: protocolType
socket: self
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
_canBlock = true;
#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC)
if ((flags = fcntl(_socket, F_GETFD, 0)) != -1)
fcntl(_socket, F_SETFD, flags | FD_CLOEXEC);
#endif
if (bind(_socket, (struct sockaddr *)&address.sockaddr,
address.length) != 0) {
int errNo = OFSocketErrNo();
int errNo = _OFSocketErrNo();
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindDDPSocketFailedException
exceptionWithNetwork: network
node: node
port: port
protocolType: protocolType
socket: self
errNo: errNo];
}
memset(&address, 0, sizeof(address));
address.family = OFSocketAddressFamilyAppleTalk;
address.length = (socklen_t)sizeof(address.sockaddr);
if (OFGetSockName(_socket, (struct sockaddr *)&address.sockaddr,
if (_OFGetSockName(_socket, (struct sockaddr *)&address.sockaddr,
&address.length) != 0) {
int errNo = OFSocketErrNo();
int errNo = _OFSocketErrNo();
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindDDPSocketFailedException
exceptionWithNetwork: network
node: node
|
︙ | | |
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
-
+
|
struct ATInterfaceConfig), &config) != 0)
@throw [OFBindDDPSocketFailedException
exceptionWithNetwork: network
node: node
port: port
protocolType: protocolType
socket: self
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
OFSocketAddressSetAppleTalkNetwork(&address, config.address.s_net);
OFSocketAddressSetAppleTalkNode(&address, config.address.s_node);
#endif
#if !defined(OF_MACOS) && !defined(OF_WINDOWS)
_protocolType = protocolType;
|
︙ | | |
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
|
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
|
-
+
|
if (_socket == OFInvalidSocketHandle)
@throw [OFNotOpenException exceptionWithObject: self];
if ((ret = recvmsg(_socket, &msg, 0)) < 0)
@throw [OFReadFailedException
exceptionWithObject: self
requestedLength: length
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
if (ret < 1 || protocolType != _protocolType)
@throw [OFReadFailedException exceptionWithObject: self
requestedLength: length
errNo: ENOMSG];
if (sender != NULL) {
|
︙ | | |
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
|
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
|
-
+
|
@throw [OFNotOpenException exceptionWithObject: self];
if ((bytesWritten = sendmsg(_socket, &msg, 0)) < 0)
@throw [OFWriteFailedException
exceptionWithObject: self
requestedLength: length
bytesWritten: 0
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
if ((size_t)bytesWritten != length + 1) {
bytesWritten--;
if (bytesWritten < 0)
bytesWritten = 0;
|
︙ | | |
Modified src/OFDNSResolver.m
from [ae23ada8bd]
to [8787fec7e7].
︙ | | |
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
|
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
|
-
+
|
@implementation OFDNSResolver
#ifdef OF_AMIGAOS
+ (void)initialize
{
if (self != [OFDNSResolver class])
return;
if (!OFSocketInit())
if (!_OFSocketInit())
@throw [OFInitializationFailedException
exceptionWithClass: self];
}
#endif
+ (instancetype)resolver
{
|
︙ | | |
Modified src/OFData+CryptographicHashing.h
from [d846d34b23]
to [5b986251d6].
︙ | | |
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
-
+
|
OF_ASSUME_NONNULL_BEGIN
@class OFString;
#ifdef __cplusplus
extern "C" {
#endif
extern int _OFData_CryptographicHashing_reference;
extern int _OFData_CryptographicHashing_reference OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
@interface OFData (CryptographicHashing)
/**
* @brief The MD5 hash of the data as a string.
|
︙ | | |
Modified src/OFData+MessagePackParsing.h
from [6de5acbf5d]
to [958119ddca].
︙ | | |
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
-
+
|
#import "OFData.h"
OF_ASSUME_NONNULL_BEGIN
#ifdef __cplusplus
extern "C" {
#endif
extern int _OFData_MessagePackParsing_reference;
extern int _OFData_MessagePackParsing_reference OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
@interface OFData (MessagePackParsing)
/**
* @brief The data interpreted as MessagePack representation and parsed as an
|
︙ | | |
Modified src/OFData.m
from [4dc9cb934e]
to [1f60c6d11f].
︙ | | |
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
-
+
|
Class isa;
} placeholder;
@interface OFPlaceholderData: OFString
@end
/* References for static linking */
void
void OF_VISIBILITY_HIDDEN
_references_to_categories_of_OFData(void)
{
_OFData_CryptographicHashing_reference = 1;
_OFData_MessagePackParsing_reference = 1;
}
@implementation OFPlaceholderData
|
︙ | | |
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
|
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
|
-
+
|
{
void *pool = objc_autoreleasePoolPush();
OFMutableData *data;
@try {
data = [OFMutableData data];
if (!OFBase64Decode(data,
if (!_OFBase64Decode(data,
[string cStringWithEncoding: OFStringEncodingASCII],
[string cStringLengthWithEncoding: OFStringEncodingASCII]))
@throw [OFInvalidFormatException exception];
} @catch (id e) {
[self release];
@throw e;
}
|
︙ | | |
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
|
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
|
-
+
|
[ret makeImmutable];
return ret;
}
- (OFString *)stringByBase64Encoding
{
return OFBase64Encode(self.items, self.count * self.itemSize);
return _OFBase64Encode(self.items, self.count * self.itemSize);
}
- (OFRange)rangeOfData: (OFData *)data
options: (OFDataSearchOptions)options
range: (OFRange)range
{
const unsigned char *items = self.items;
|
︙ | | |
Modified src/OFDatagramSocket.m
from [65c253c5c9]
to [9ad188ca92].
︙ | | |
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
-
+
|
@synthesize delegate = _delegate;
+ (void)initialize
{
if (self != [OFDatagramSocket class])
return;
if (!OFSocketInit())
if (!_OFSocketInit())
@throw [OFInitializationFailedException
exceptionWithClass: self];
}
+ (instancetype)socket
{
return [[[self alloc] init] autorelease];
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
|
_canBlock = canBlock;
#elif defined(OF_WINDOWS)
u_long v = !canBlock;
if (ioctlsocket(_socket, FIONBIO, &v) == SOCKET_ERROR)
@throw [OFSetOptionFailedException
exceptionWithObject: self
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
_canBlock = canBlock;
#else
OF_UNRECOGNIZED_SELECTOR
#endif
}
- (void)setCanSendToBroadcastAddresses: (bool)canSendToBroadcastAddresses
{
int v = canSendToBroadcastAddresses;
if (setsockopt(_socket, SOL_SOCKET, SO_BROADCAST,
(char *)&v, (socklen_t)sizeof(v)) != 0)
@throw [OFSetOptionFailedException
exceptionWithObject: self
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
#ifdef OF_WII
_canSendToBroadcastAddresses = canSendToBroadcastAddresses;
#endif
}
- (bool)canSendToBroadcastAddresses
{
#ifndef OF_WII
int v;
socklen_t len = sizeof(v);
if (getsockopt(_socket, SOL_SOCKET, SO_BROADCAST,
(char *)&v, &len) != 0 || len != sizeof(v))
@throw [OFGetOptionFailedException
exceptionWithObject: self
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
return v;
#else
return _canSendToBroadcastAddresses;
#endif
}
|
︙ | | |
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
|
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
|
-
+
-
+
|
#ifndef OF_WINDOWS
if ((ret = recvfrom(_socket, buffer, length, 0,
(sender != NULL ? (struct sockaddr *)&sender->sockaddr : NULL),
(sender != NULL ? &sender->length : NULL))) < 0)
@throw [OFReadFailedException
exceptionWithObject: self
requestedLength: length
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
#else
if (length > INT_MAX)
@throw [OFOutOfRangeException exception];
if ((ret = recvfrom(_socket, buffer, (int)length, 0,
(sender != NULL ? (struct sockaddr *)&sender->sockaddr : NULL),
(sender != NULL ? &sender->length : NULL))) < 0)
@throw [OFReadFailedException
exceptionWithObject: self
requestedLength: length
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
#endif
if (sender != NULL) {
struct sockaddr *sa = (struct sockaddr *)&sender->sockaddr;
if (sender->length >= (socklen_t)sizeof(sa->sa_family)) {
switch (sa->sa_family) {
|
︙ | | |
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
|
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
|
-
+
-
+
|
if ((bytesWritten = sendto(_socket, (void *)buffer, length, 0,
(struct sockaddr *)&receiver->sockaddr, receiver->length)) < 0)
@throw [OFWriteFailedException
exceptionWithObject: self
requestedLength: length
bytesWritten: 0
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
#else
int bytesWritten;
if (length > INT_MAX)
@throw [OFOutOfRangeException exception];
if ((bytesWritten = sendto(_socket, buffer, (int)length, 0,
(struct sockaddr *)&receiver->sockaddr, receiver->length)) < 0)
@throw [OFWriteFailedException
exceptionWithObject: self
requestedLength: length
bytesWritten: 0
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
#endif
if ((size_t)bytesWritten != length)
@throw [OFWriteFailedException exceptionWithObject: self
requestedLength: length
bytesWritten: bytesWritten
errNo: 0];
|
︙ | | |
Modified src/OFDate.m
from [ae00d275b0]
to [ddae0ab707].
︙ | | |
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
|
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
|
-
-
+
+
|
if (seconds == 0) {
static OFOnceControl once = OFOnceControlInitValue;
OFOnce(&once, initZeroDate);
return (id)zeroDate;
}
#if defined(OF_OBJFW_RUNTIME) && UINTPTR_MAX == UINT64_MAX
value = OFFromBigEndian64(OFDoubleToRawUInt64(OFToBigEndianDouble(
seconds)));
value = OFFromBigEndian64(OFBitConvertDoubleToUInt64(
OFToBigEndianDouble(seconds)));
/* Almost all dates fall into this range. */
if (value & (UINT64_C(4) << 60)) {
id ret = [OFTaggedPointerDate
dateWithUInt64TimeIntervalSince1970: value];
if (ret != nil)
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
|
format: (OFString *)format
{
void *pool = objc_autoreleasePoolPush();
const char *UTF8String = string.UTF8String;
struct tm tm = { .tm_isdst = -1 };
short tz = 0;
if (OFStrPTime(UTF8String, format.UTF8String, &tm, &tz) !=
if (_OFStrPTime(UTF8String, format.UTF8String, &tm, &tz) !=
UTF8String + string.UTF8StringLength)
@throw [OFInvalidFormatException exception];
objc_autoreleasePoolPop(pool);
return [self initWithTimeIntervalSince1970: tmAndTzToTime(&tm, tz)];
}
- (instancetype)initWithLocalDateString: (OFString *)string
format: (OFString *)format
{
void *pool = objc_autoreleasePoolPush();
const char *UTF8String = string.UTF8String;
struct tm tm = { .tm_isdst = -1 };
/*
* OFStrPTime() can never set this to SHRT_MAX, no matter what is
* _OFStrPTime() can never set this to SHRT_MAX, no matter what is
* passed to it, so this is a safe way to figure out if the date
* contains a time zone.
*/
short tz = SHRT_MAX;
OFTimeInterval seconds;
if (OFStrPTime(UTF8String, format.UTF8String, &tm, &tz) !=
if (_OFStrPTime(UTF8String, format.UTF8String, &tm, &tz) !=
UTF8String + string.UTF8StringLength)
@throw [OFInvalidFormatException exception];
if (tz == SHRT_MAX) {
#ifdef OF_WINDOWS
if (_mktime64FuncPtr != NULL) {
if ((seconds = _mktime64FuncPtr(&tm)) == -1)
|
︙ | | |
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
|
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
|
-
+
|
}
# endif
#endif
pageSize = [OFSystemInfo pageSize];
buffer = OFAllocMemory(1, pageSize);
@try {
if (OFStrFTime(buffer, pageSize, format.UTF8String, &tm,
if (_OFStrFTime(buffer, pageSize, format.UTF8String, &tm,
0) == 0)
@throw [OFOutOfRangeException exception];
ret = [OFString stringWithUTF8String: buffer];
} @finally {
OFFreeMemory(buffer);
}
|
︙ | | |
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
|
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
|
-
+
|
}
# endif
#endif
pageSize = [OFSystemInfo pageSize];
buffer = OFAllocMemory(1, pageSize);
@try {
if (OFStrFTime(buffer, pageSize, format.UTF8String, &tm,
if (_OFStrFTime(buffer, pageSize, format.UTF8String, &tm,
0) == 0)
@throw [OFOutOfRangeException exception];
ret = [OFString stringWithUTF8String: buffer];
} @finally {
OFFreeMemory(buffer);
}
|
︙ | | |
Modified src/OFEmbeddedIRIHandler.m
from [0aa22bc193]
to [275cbe280f].
︙ | | |
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
-
+
-
+
|
#import "OFOpenItemFailedException.h"
#ifdef OF_HAVE_THREADS
# import "OFOnce.h"
# import "OFPlainMutex.h"
#endif
struct EmbeddedFile {
static struct EmbeddedFile {
OFString *path;
const uint8_t *bytes;
size_t size;
} *embeddedFiles = NULL;
size_t numEmbeddedFiles = 0;
static size_t numEmbeddedFiles = 0;
#ifdef OF_HAVE_THREADS
static OFPlainMutex mutex;
static OFOnceControl mutexOnceControl = OFOnceControlInitValue;
static void
initMutex(void)
{
|
︙ | | |
Modified src/OFGZIPStream.m
from [ba433e4a1c]
to [7c25979fa6].
︙ | | |
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
|
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
|
-
+
|
initWithStream: _stream];
if (!_inflateStream.atEndOfStream) {
size_t bytesRead = [_inflateStream
readIntoBuffer: buffer
length: length];
_CRC32 = OFCRC32(_CRC32, buffer, bytesRead);
_CRC32 = _OFCRC32(_CRC32, buffer, bytesRead);
_uncompressedSize += bytesRead;
return bytesRead;
}
[_inflateStream release];
_inflateStream = nil;
|
︙ | | |
Modified src/OFHTTPServer.m
from [61bb060e07]
to [c0539be083].
︙ | | |
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
-
+
|
- (void)stop;
@end
#endif
static OFString *
normalizedKey(OFString *key)
{
char *cString = OFStrDup(key.UTF8String);
char *cString = _OFStrDup(key.UTF8String);
unsigned char *tmp = (unsigned char *)cString;
bool firstLetter = true;
OFString *ret;
while (*tmp != '\0') {
if (!OFASCIIIsAlpha(*tmp)) {
firstLetter = true;
|
︙ | | |
Modified src/OFHuffmanTree.h
from [3269a83550]
to [e004c2a98a].
︙ | | |
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
-
+
|
typedef struct _OFHuffmanTree {
struct _OFHuffmanTree *_Nullable leaves[2];
uint16_t value;
} *OFHuffmanTree;
/* Inlined for performance. */
static OF_INLINE bool
OFHuffmanTreeWalk(id _Nullable stream,
_OFHuffmanTreeWalk(id _Nullable stream,
bool (*bitReader)(id _Nullable, uint16_t *_Nonnull, uint8_t),
OFHuffmanTree _Nonnull *_Nonnull tree, uint16_t *_Nonnull value)
{
OFHuffmanTree iter = *tree;
uint16_t bits;
while (iter->value == 0xFFFF) {
|
︙ | | |
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
-
-
-
-
+
+
+
+
+
+
|
*value = iter->value;
return true;
}
#ifdef __cplusplus
extern "C" {
#endif
extern OFHuffmanTree _Nonnull OFHuffmanTreeNew(uint8_t lengths[_Nonnull],
uint16_t count);
extern OFHuffmanTree _Nonnull OFHuffmanTreeNewSingle(uint16_t value);
extern void OFHuffmanTreeFree(OFHuffmanTree _Nonnull tree);
extern OFHuffmanTree _Nonnull _OFHuffmanTreeNew(uint8_t lengths[_Nonnull],
uint16_t count) OF_VISIBILITY_HIDDEN;
extern OFHuffmanTree _Nonnull _OFHuffmanTreeNewSingle(uint16_t value)
OF_VISIBILITY_HIDDEN;
extern void _OFHuffmanTreeFree(OFHuffmanTree _Nonnull tree)
OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
OF_ASSUME_NONNULL_END
|
Modified src/OFHuffmanTree.m
from [7caeda826b]
to [02fde5269c].
︙ | | |
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
-
+
|
tree = tree->leaves[bit];
}
tree->value = value;
}
OFHuffmanTree
OFHuffmanTreeNew(uint8_t lengths[], uint16_t count)
_OFHuffmanTreeNew(uint8_t lengths[], uint16_t count)
{
OFHuffmanTree tree;
uint16_t *lengthCount = NULL;
uint16_t code, maxCode = 0, *nextCode = NULL;
uint_fast8_t maxBit = 0;
@try {
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
|
OFFreeMemory(nextCode);
}
return tree;
}
OFHuffmanTree
OFHuffmanTreeNewSingle(uint16_t value)
_OFHuffmanTreeNewSingle(uint16_t value)
{
OFHuffmanTree tree = newTree();
tree->value = value;
return tree;
}
void
OFHuffmanTreeFree(OFHuffmanTree tree)
_OFHuffmanTreeFree(OFHuffmanTree tree)
{
for (uint_fast8_t i = 0; i < 2; i++)
if OF_LIKELY (tree->leaves[i] != NULL)
OFHuffmanTreeFree(tree->leaves[i]);
_OFHuffmanTreeFree(tree->leaves[i]);
OFFreeMemory(tree);
}
|
Modified src/OFIPXSocket.m
from [71dcaf90af]
to [a4ad2996ac].
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
|
SOCK_DGRAM | SOCK_CLOEXEC, protocol)) == OFInvalidSocketHandle)
@throw [OFBindIPXSocketFailedException
exceptionWithNetwork: network
node: node
port: port
packetType: packetType
socket: self
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
_canBlock = true;
#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC)
if ((flags = fcntl(_socket, F_GETFD, 0)) != -1)
fcntl(_socket, F_SETFD, flags | FD_CLOEXEC);
#endif
if (bind(_socket, (struct sockaddr *)&address.sockaddr,
address.length) != 0) {
int errNo = OFSocketErrNo();
int errNo = _OFSocketErrNo();
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindIPXSocketFailedException
exceptionWithNetwork: network
node: node
port: port
packetType: packetType
socket: self
errNo: errNo];
}
memset(&address, 0, sizeof(address));
address.family = OFSocketAddressFamilyIPX;
address.length = (socklen_t)sizeof(address.sockaddr);
if (OFGetSockName(_socket, (struct sockaddr *)&address.sockaddr,
if (_OFGetSockName(_socket, (struct sockaddr *)&address.sockaddr,
&address.length) != 0) {
int errNo = OFSocketErrNo();
int errNo = _OFSocketErrNo();
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindIPXSocketFailedException
exceptionWithNetwork: network
node: node
|
︙ | | |
Modified src/OFIRI.h
from [46c48a2808]
to [6f424a4bd0].
︙ | | |
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
|
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
|
-
-
+
+
+
|
*/
+ (OFCharacterSet *)IRIFragmentAllowedCharacterSet;
@end
#ifdef __cplusplus
extern "C" {
#endif
extern bool OFIRIIsIPv6Host(OFString *host);
extern void OFIRIVerifyIsEscaped(OFString *, OFCharacterSet *, bool);
extern bool _OFIRIIsIPv6Host(OFString *host) OF_VISIBILITY_HIDDEN;
extern void _OFIRIVerifyIsEscaped(OFString *, OFCharacterSet *, bool)
OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
OF_ASSUME_NONNULL_END
#import "OFMutableIRI.h"
|
Modified src/OFIRI.m
from [8ff2bb9721]
to [47f2aa9acb].
︙ | | |
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
-
+
|
initIRIFragmentAllowedCharacterSet(void)
{
IRIFragmentAllowedCharacterSet =
[[OFIRIFragmentAllowedCharacterSet alloc] init];
}
bool
OFIRIIsIPv6Host(OFString *host)
_OFIRIIsIPv6Host(OFString *host)
{
const char *UTF8String = host.UTF8String;
bool hasColon = false;
while (*UTF8String != '\0') {
if (!OFASCIIIsDigit(*UTF8String) && *UTF8String != ':' &&
(*UTF8String < 'a' || *UTF8String > 'f') &&
|
︙ | | |
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
|
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
|
-
+
|
{
return (character != '%' && !_characterIsMember(_characterSet,
@selector(characterIsMember:), character));
}
@end
void
OFIRIVerifyIsEscaped(OFString *string, OFCharacterSet *characterSet,
_OFIRIVerifyIsEscaped(OFString *string, OFCharacterSet *characterSet,
bool allowPercent)
{
void *pool = objc_autoreleasePoolPush();
if (allowPercent)
characterSet = [[[OFInvertedCharacterSetWithoutPercent alloc]
initWithCharacterSet: characterSet] autorelease];
|
︙ | | |
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
|
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
|
-
+
-
+
|
self->_percentEncodedUser = [[OFString alloc]
initWithUTF8String: UTF8String
length: colon - UTF8String];
self->_percentEncodedPassword = [[OFString alloc]
initWithUTF8String: colon + 1
length: length - (colon - UTF8String) - 1];
OFIRIVerifyIsEscaped(self->_percentEncodedPassword,
_OFIRIVerifyIsEscaped(self->_percentEncodedPassword,
[OFCharacterSet IRIPasswordAllowedCharacterSet], true);
} else
self->_percentEncodedUser = [[OFString alloc]
initWithUTF8String: UTF8String
length: length];
OFIRIVerifyIsEscaped(self->_percentEncodedUser,
_OFIRIVerifyIsEscaped(self->_percentEncodedUser,
[OFCharacterSet IRIUserAllowedCharacterSet], true);
}
static void
parseHostPort(OFIRI *self, const char *UTF8String, size_t length)
{
OFString *portString;
|
︙ | | |
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
|
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
|
-
+
|
initWithUTF8String: UTF8String
length: length];
UTF8String += length;
length = 0;
}
OFIRIVerifyIsEscaped(self->_percentEncodedHost,
_OFIRIVerifyIsEscaped(self->_percentEncodedHost,
[OFCharacterSet IRIHostAllowedCharacterSet], true);
}
if (length == 0)
return;
if (length <= 1 || *UTF8String != ':')
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
|
const char *fragment, *query;
if ((fragment = memchr(UTF8String, '#', length)) != NULL) {
*fragmentString = [OFString
stringWithUTF8String: fragment + 1
length: length - (fragment - UTF8String) - 1];
OFIRIVerifyIsEscaped(*fragmentString,
_OFIRIVerifyIsEscaped(*fragmentString,
[OFCharacterSet IRIQueryAllowedCharacterSet], true);
length = fragment - UTF8String;
}
if ((query = memchr(UTF8String, '?', length)) != NULL) {
*queryString = [OFString
stringWithUTF8String: query + 1
length: length - (query - UTF8String) - 1];
OFIRIVerifyIsEscaped(*queryString,
_OFIRIVerifyIsEscaped(*queryString,
[OFCharacterSet IRIFragmentAllowedCharacterSet], true);
length = query - UTF8String;
}
*pathString = [OFString stringWithUTF8String: UTF8String
length: length];
OFIRIVerifyIsEscaped(*pathString,
_OFIRIVerifyIsEscaped(*pathString,
[OFCharacterSet IRIPathAllowedCharacterSet], true);
}
- (instancetype)initWithString: (OFString *)string
{
self = [super init];
|
︙ | | |
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
|
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
|
-
+
|
colon - UTF8String < 1 || !OFASCIIIsAlpha(UTF8String[0]))
@throw [OFInvalidFormatException exception];
_scheme = [[[OFString stringWithUTF8String: UTF8String
length: colon - UTF8String]
lowercaseString] copy];
OFIRIVerifyIsEscaped(_scheme,
_OFIRIVerifyIsEscaped(_scheme,
[OFCharacterSet IRISchemeAllowedCharacterSet], false);
length -= colon - UTF8String + 1;
UTF8String = colon + 1;
if (length >= 2 && UTF8String[0] == '/' &&
UTF8String[1] == '/') {
|
︙ | | |
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
|
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
|
-
+
|
- (OFString *)host
{
if ([_percentEncodedHost hasPrefix: @"["] &&
[_percentEncodedHost hasSuffix: @"]"]) {
OFString *host = [_percentEncodedHost substringWithRange:
OFMakeRange(1, _percentEncodedHost.length - 2)];
if (!OFIRIIsIPv6Host(host))
if (!_OFIRIIsIPv6Host(host))
@throw [OFInvalidArgumentException exception];
return host;
}
return _percentEncodedHost.stringByRemovingPercentEncoding;
}
|
︙ | | |
Modified src/OFInflateStream.m
from [5f2d55b677]
to [ee0deaa4d9].
︙ | | |
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
-
+
-
+
|
for (uint16_t i = 144; i <= 255; i++)
lengths[i] = 9;
for (uint16_t i = 256; i <= 279; i++)
lengths[i] = 7;
for (uint16_t i = 280; i <= 287; i++)
lengths[i] = 8;
fixedLitLenTree = OFHuffmanTreeNew(lengths, 288);
fixedLitLenTree = _OFHuffmanTreeNew(lengths, 288);
for (uint16_t i = 0; i <= 31; i++)
lengths[i] = 5;
fixedDistTree = OFHuffmanTreeNew(lengths, 32);
fixedDistTree = _OFHuffmanTreeNew(lengths, 32);
}
+ (instancetype)streamWithStream: (OFStream *)stream
{
return [[[self alloc] initWithStream: stream] autorelease];
}
|
︙ | | |
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
-
+
-
+
-
+
|
OFFreeMemory(_slidingWindow);
if (_state == stateHuffmanTree) {
OFFreeMemory(_context.huffmanTree.lengths);
if (_context.huffmanTree.codeLenTree != NULL)
OFHuffmanTreeFree(_context.huffmanTree.codeLenTree);
_OFHuffmanTreeFree(_context.huffmanTree.codeLenTree);
}
if (_state == stateHuffmanTree || _state == stateHuffmanBlock) {
if (_context.huffman.litLenTree != fixedLitLenTree)
OFHuffmanTreeFree(_context.huffman.litLenTree);
_OFHuffmanTreeFree(_context.huffman.litLenTree);
if (_context.huffman.distTree != fixedDistTree)
OFHuffmanTreeFree(_context.huffman.distTree);
_OFHuffmanTreeFree(_context.huffman.distTree);
}
[super dealloc];
}
- (size_t)lowlevelReadIntoBuffer: (void *)buffer_
length: (size_t)length
|
︙ | | |
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
|
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
|
-
+
-
+
|
CTX.receivedCount = i;
return bytesWritten;
}
CTX.lengths[codeLengthsOrder[i]] = bits;
}
CTX.codeLenTree = OFHuffmanTreeNew(CTX.lengths, 19);
CTX.codeLenTree = _OFHuffmanTreeNew(CTX.lengths, 19);
CTX.treeIter = CTX.codeLenTree;
OFFreeMemory(CTX.lengths);
CTX.lengths = NULL;
CTX.receivedCount = 0;
CTX.value = 0xFF;
}
if OF_LIKELY (CTX.lengths == NULL)
CTX.lengths = OFAllocMemory(
CTX.litLenCodesCount + CTX.distCodesCount + 258, 1);
for (uint16_t i = CTX.receivedCount;
i < CTX.litLenCodesCount + CTX.distCodesCount + 258;) {
uint8_t j, count;
if OF_LIKELY (CTX.value == 0xFF) {
if OF_UNLIKELY (!OFHuffmanTreeWalk(self,
if OF_UNLIKELY (!_OFHuffmanTreeWalk(self,
tryReadBits, &CTX.treeIter, &value)) {
CTX.receivedCount = i;
return bytesWritten;
}
CTX.treeIter = CTX.codeLenTree;
|
︙ | | |
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
|
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
|
-
+
-
+
-
+
|
for (j = 0; j < count; j++)
CTX.lengths[i++] = value;
CTX.value = 0xFF;
}
OFHuffmanTreeFree(CTX.codeLenTree);
_OFHuffmanTreeFree(CTX.codeLenTree);
CTX.codeLenTree = NULL;
CTX.litLenTree = OFHuffmanTreeNew(CTX.lengths,
CTX.litLenTree = _OFHuffmanTreeNew(CTX.lengths,
CTX.litLenCodesCount + 257);
CTX.distTree = OFHuffmanTreeNew(
CTX.distTree = _OFHuffmanTreeNew(
CTX.lengths + CTX.litLenCodesCount + 257,
CTX.distCodesCount + 1);
OFFreeMemory(CTX.lengths);
/*
* litLenTree and distTree are at the same location in
|
︙ | | |
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
|
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
|
-
+
|
CTX.state = huffmanStateAwaitDistance;
CTX.treeIter = CTX.distTree;
}
/* Distance of length distance pair */
if (CTX.state == huffmanStateAwaitDistance) {
if OF_UNLIKELY (!OFHuffmanTreeWalk(self,
if OF_UNLIKELY (!_OFHuffmanTreeWalk(self,
tryReadBits, &CTX.treeIter, &value))
return bytesWritten;
if OF_UNLIKELY (value >= numDistanceCodes)
@throw [OFInvalidFormatException
exception];
|
︙ | | |
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
|
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
|
-
+
-
+
-
+
|
_slidingWindowMask;
}
CTX.state = huffmanStateAwaitCode;
CTX.treeIter = CTX.litLenTree;
}
if OF_UNLIKELY (!OFHuffmanTreeWalk(self, tryReadBits,
if OF_UNLIKELY (!_OFHuffmanTreeWalk(self, tryReadBits,
&CTX.treeIter, &value))
return bytesWritten;
/* End of block */
if OF_UNLIKELY (value == 256) {
if (CTX.litLenTree != fixedLitLenTree)
OFHuffmanTreeFree(CTX.litLenTree);
_OFHuffmanTreeFree(CTX.litLenTree);
if (CTX.distTree != fixedDistTree)
OFHuffmanTreeFree(CTX.distTree);
_OFHuffmanTreeFree(CTX.distTree);
_state = stateBlockHeader;
goto start;
}
/* Literal byte */
if OF_LIKELY (value < 256) {
|
︙ | | |
Modified src/OFKernelEventObserver.m
from [c5333a4c56]
to [0c63190dd8].
︙ | | |
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
-
+
|
#endif
+ (void)initialize
{
if (self != [OFKernelEventObserver class])
return;
if (!OFSocketInit())
if (!_OFSocketInit())
@throw [OFInitializationFailedException
exceptionWithClass: self];
}
+ (instancetype)observer
{
return [[[self alloc] init] autorelease];
|
︙ | | |
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
|
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
|
-
+
-
+
|
# if !defined(OF_WII) && !defined(OF_NINTENDO_3DS)
if (bind(_cancelFD[0], (struct sockaddr *)&_cancelAddr,
sizeof(_cancelAddr)) != 0)
@throw [OFInitializationFailedException
exceptionWithClass: self.class];
cancelAddrLen = sizeof(_cancelAddr);
if (OFGetSockName(_cancelFD[0],
if (_OFGetSockName(_cancelFD[0],
(struct sockaddr *)&_cancelAddr, &cancelAddrLen) != 0)
@throw [OFInitializationFailedException
exceptionWithClass: self.class];
# else
for (;;) {
uint16_t rnd = 0;
int ret;
while (rnd < 1024)
rnd = (uint16_t)rand();
_cancelAddr.sin_port = OFToBigEndian16(rnd);
ret = bind(_cancelFD[0],
(struct sockaddr *)&_cancelAddr,
sizeof(_cancelAddr));
if (ret == 0)
break;
if (OFSocketErrNo() != EADDRINUSE)
if (_OFSocketErrNo() != EADDRINUSE)
@throw [OFInitializationFailedException
exceptionWithClass: self.class];
}
# endif
#endif
} @catch (id e) {
[self release];
|
︙ | | |
Modified src/OFLHAArchive.m
from [3329a01d33]
to [784284b8aa].
︙ | | |
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
|
-
+
|
+ (instancetype)archiveWithIRI: (OFIRI *)IRI mode: (OFString *)mode
{
return [[[self alloc] initWithIRI: IRI mode: mode] autorelease];
}
+ (OFIRI *)IRIForFilePath: (OFString *)path inArchiveWithIRI: (OFIRI *)IRI
{
return OFArchiveIRIHandlerIRIForFileInArchive(@"lha", path, IRI);
return _OFArchiveIRIHandlerIRIForFileInArchive(@"lha", path, IRI);
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
|
︙ | | |
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
|
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
|
-
+
|
if (length > _toRead)
length = (size_t)_toRead;
ret = [_decompressedStream readIntoBuffer: buffer length: length];
_toRead -= ret;
_CRC16 = OFCRC16(_CRC16, buffer, ret);
_CRC16 = _OFCRC16(_CRC16, buffer, ret);
if (_toRead == 0) {
_atEndOfStream = true;
if (_CRC16 != _entry.CRC16) {
OFString *actualChecksum = [OFString stringWithFormat:
@"%04" @PRIX16, _CRC16];
|
︙ | | |
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
|
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
|
-
+
-
+
|
@try {
[_stream writeBuffer: buffer length: length];
} @catch (OFWriteFailedException *e) {
OFEnsure(e.bytesWritten <= length);
_bytesWritten += (uint64_t)e.bytesWritten;
_CRC16 = OFCRC16(_CRC16, buffer, e.bytesWritten);
_CRC16 = _OFCRC16(_CRC16, buffer, e.bytesWritten);
if (e.errNo == EWOULDBLOCK || e.errNo == EAGAIN)
return e.bytesWritten;
@throw e;
}
_bytesWritten += (uint64_t)length;
_CRC16 = OFCRC16(_CRC16, buffer, length);
_CRC16 = _OFCRC16(_CRC16, buffer, length);
return length;
}
- (bool)lowlevelIsAtEndOfStream
{
if (_stream == nil)
|
︙ | | |
Modified src/OFLHAArchiveEntry.m
from [14cbf19d20]
to [9d58a40bb8].
︙ | | |
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
|
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
|
-
+
|
if (headerSize > UINT16_MAX)
@throw [OFOutOfRangeException exception];
/* Now fill in the size and CRC16 for the entire header */
tmp16 = OFToLittleEndian16(headerSize);
memcpy([data mutableItemAtIndex: 0], &tmp16, sizeof(tmp16));
tmp16 = OFCRC16(0, data.items, data.count);
tmp16 = _OFCRC16(0, data.items, data.count);
tmp16 = OFToLittleEndian16(tmp16);
memcpy([data mutableItemAtIndex: 27], &tmp16, sizeof(tmp16));
[stream writeData: data];
objc_autoreleasePoolPop(pool);
}
|
︙ | | |
Modified src/OFLHADecompressingStream.m
from [83126d0266]
to [7c63af9a2f].
︙ | | |
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
-
+
-
+
-
+
|
{
if (_stream != nil)
[self close];
OFFreeMemory(_slidingWindow);
if (_codeLenTree != NULL)
OFHuffmanTreeFree(_codeLenTree);
_OFHuffmanTreeFree(_codeLenTree);
if (_litLenTree != NULL)
OFHuffmanTreeFree(_litLenTree);
_OFHuffmanTreeFree(_litLenTree);
if (_distTree != NULL)
OFHuffmanTreeFree(_distTree);
_OFHuffmanTreeFree(_distTree);
OFFreeMemory(_codesLengths);
[super dealloc];
}
- (size_t)lowlevelReadIntoBuffer: (void *)buffer_
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
|
if OF_UNLIKELY (bits == 7) {
_currentIsExtendedLength = true;
continue;
} else
_codesReceived++;
}
_codeLenTree = OFHuffmanTreeNew(_codesLengths, _codesCount);
_codeLenTree = _OFHuffmanTreeNew(_codesLengths, _codesCount);
OFFreeMemory(_codesLengths);
_codesLengths = NULL;
_state = stateLitLenCodesCount;
goto start;
case stateCodeLenTreeSingle:
if OF_UNLIKELY (!tryReadBits(self, &bits, 5))
return bytesWritten;
_codeLenTree = OFHuffmanTreeNewSingle(bits);
_codeLenTree = _OFHuffmanTreeNewSingle(bits);
_state = stateLitLenCodesCount;
goto start;
case stateLitLenCodesCount:
if OF_UNLIKELY (!tryReadBits(self, &bits, 9))
return bytesWritten;
if OF_UNLIKELY (bits > 510)
@throw [OFInvalidFormatException exception];
if OF_UNLIKELY (bits == 0) {
OFHuffmanTreeFree(_codeLenTree);
_OFHuffmanTreeFree(_codeLenTree);
_codeLenTree = NULL;
_state = stateLitLenTreeSingle;
goto start;
}
_codesCount = bits;
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
|
for (uint_fast16_t j = 0; j < skipCount; j++)
_codesLengths[_codesReceived++] = 0;
_skip = false;
continue;
}
if (!OFHuffmanTreeWalk(self, tryReadBits, &_treeIter,
if (!_OFHuffmanTreeWalk(self, tryReadBits, &_treeIter,
&value))
return bytesWritten;
_treeIter = _codeLenTree;
if (value < 3) {
_codesLengths[_codesReceived] = value;
_skip = true;
} else
_codesLengths[_codesReceived++] = value - 2;
}
_litLenTree = OFHuffmanTreeNew(_codesLengths, _codesCount);
_litLenTree = _OFHuffmanTreeNew(_codesLengths, _codesCount);
OFFreeMemory(_codesLengths);
_codesLengths = NULL;
OFHuffmanTreeFree(_codeLenTree);
_OFHuffmanTreeFree(_codeLenTree);
_codeLenTree = NULL;
_state = stateDistCodesCount;
goto start;
case stateLitLenTreeSingle:
if OF_UNLIKELY (!tryReadBits(self, &bits, 9))
return bytesWritten;
_litLenTree = OFHuffmanTreeNewSingle(bits);
_litLenTree = _OFHuffmanTreeNewSingle(bits);
_state = stateDistCodesCount;
goto start;
case stateDistCodesCount:
if OF_UNLIKELY (!tryReadBits(self, &bits, _distanceBits))
return bytesWritten;
|
︙ | | |
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
|
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
|
-
+
-
+
-
-
+
+
|
if OF_UNLIKELY (bits == 7) {
_currentIsExtendedLength = true;
continue;
} else
_codesReceived++;
}
_distTree = OFHuffmanTreeNew(_codesLengths, _codesCount);
_distTree = _OFHuffmanTreeNew(_codesLengths, _codesCount);
OFFreeMemory(_codesLengths);
_codesLengths = NULL;
_treeIter = _litLenTree;
_state = stateBlockLitLen;
goto start;
case stateDistTreeSingle:
if OF_UNLIKELY (!tryReadBits(self, &bits, _distanceBits))
return bytesWritten;
_distTree = OFHuffmanTreeNewSingle(bits);
_distTree = _OFHuffmanTreeNewSingle(bits);
_treeIter = _litLenTree;
_state = stateBlockLitLen;
goto start;
case stateBlockLitLen:
if OF_UNLIKELY (_symbolsLeft == 0) {
OFHuffmanTreeFree(_litLenTree);
OFHuffmanTreeFree(_distTree);
_OFHuffmanTreeFree(_litLenTree);
_OFHuffmanTreeFree(_distTree);
_litLenTree = _distTree = NULL;
_state = stateBlockHeader;
/*
* We must return here, as there is no indication
* whether this was the last block. Whoever called this
|
︙ | | |
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
|
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
|
-
+
|
return bytesWritten;
}
if OF_UNLIKELY (length == 0)
return bytesWritten;
if OF_UNLIKELY (!OFHuffmanTreeWalk(self, tryReadBits,
if OF_UNLIKELY (!_OFHuffmanTreeWalk(self, tryReadBits,
&_treeIter, &value))
return bytesWritten;
if OF_LIKELY (value < 256) {
buffer[bytesWritten++] = value;
length--;
|
︙ | | |
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
|
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
|
-
+
|
_length = value - 253;
_treeIter = _distTree;
_state = stateBlockDistLength;
}
goto start;
case stateBlockDistLength:
if OF_UNLIKELY (!OFHuffmanTreeWalk(self, tryReadBits,
if OF_UNLIKELY (!_OFHuffmanTreeWalk(self, tryReadBits,
&_treeIter, &value))
return bytesWritten;
_distance = value;
_state = (value < 2
? stateBlockLenDistPair : stateBlockDistLengthExtra);
|
︙ | | |
Modified src/OFLocale.m
from [86262efe96]
to [8fa54b1d3c].
︙ | | |
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
-
+
|
}
#ifndef OF_AMIGAOS
static void
parseLocale(char *locale, OFStringEncoding *encoding,
OFString **languageCode, OFString **countryCode)
{
locale = OFStrDup(locale);
locale = _OFStrDup(locale);
@try {
OFStringEncoding enc = OFStringEncodingASCII;
char *tmp;
/* We don't care for extras behind the @ */
if ((tmp = strrchr(locale, '@')) != NULL)
|
︙ | | |
Modified src/OFMatrix4x4.m
from [a90d32dcbf]
to [c9b2db710c].
︙ | | |
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
|
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
|
-
+
+
|
{
unsigned long hash;
OFHashInit(&hash);
for (uint_fast8_t i = 0; i < 4; i++)
for (uint_fast8_t j = 0; j < 4; j++)
OFHashAddHash(&hash, OFFloatToRawUInt32(_values[i][j]));
OFHashAddHash(&hash,
OFBitConvertFloatToUInt32(_values[i][j]));
OFHashFinalize(&hash);
return hash;
}
- (void)multiplyWithMatrix: (OFMatrix4x4 *)matrix
|
︙ | | |
Modified src/OFMutableIRI.m
from [0e3da0ee00]
to [e9bc07b350].
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
|
{
void *pool = objc_autoreleasePoolPush();
OFString *old = _scheme;
if (scheme.length < 1 || !OFASCIIIsAlpha(*scheme.UTF8String))
@throw [OFInvalidFormatException exception];
OFIRIVerifyIsEscaped(scheme,
_OFIRIVerifyIsEscaped(scheme,
[OFCharacterSet IRISchemeAllowedCharacterSet], false);
_scheme = [scheme.lowercaseString copy];
[old release];
objc_autoreleasePoolPop(pool);
}
- (void)setHost: (OFString *)host
{
void *pool = objc_autoreleasePoolPush();
OFString *old = _percentEncodedHost;
if (OFIRIIsIPv6Host(host))
if (_OFIRIIsIPv6Host(host))
_percentEncodedHost = [[OFString alloc]
initWithFormat: @"[%@]", host];
else
_percentEncodedHost = [[host
stringByAddingPercentEncodingWithAllowedCharacters:
[OFCharacterSet IRIHostAllowedCharacterSet]] copy];
[old release];
objc_autoreleasePoolPop(pool);
}
- (void)setPercentEncodedHost: (OFString *)percentEncodedHost
{
OFString *old;
if ([percentEncodedHost hasPrefix: @"["] &&
[percentEncodedHost hasSuffix: @"]"]) {
if (!OFIRIIsIPv6Host([percentEncodedHost substringWithRange:
if (!_OFIRIIsIPv6Host([percentEncodedHost substringWithRange:
OFMakeRange(1, percentEncodedHost.length - 2)]))
@throw [OFInvalidFormatException exception];
} else if (percentEncodedHost != nil)
OFIRIVerifyIsEscaped(percentEncodedHost,
_OFIRIVerifyIsEscaped(percentEncodedHost,
[OFCharacterSet IRIHostAllowedCharacterSet], true);
old = _percentEncodedHost;
_percentEncodedHost = [percentEncodedHost copy];
[old release];
}
|
︙ | | |
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
-
+
|
}
- (void)setPercentEncodedUser: (OFString *)percentEncodedUser
{
OFString *old;
if (percentEncodedUser != nil)
OFIRIVerifyIsEscaped(percentEncodedUser,
_OFIRIVerifyIsEscaped(percentEncodedUser,
[OFCharacterSet IRIUserAllowedCharacterSet], true);
old = _percentEncodedUser;
_percentEncodedUser = [percentEncodedUser copy];
[old release];
}
|
︙ | | |
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
-
+
|
}
- (void)setPercentEncodedPassword: (OFString *)percentEncodedPassword
{
OFString *old;
if (percentEncodedPassword != nil)
OFIRIVerifyIsEscaped(percentEncodedPassword,
_OFIRIVerifyIsEscaped(percentEncodedPassword,
[OFCharacterSet IRIPasswordAllowedCharacterSet], true);
old = _percentEncodedPassword;
_percentEncodedPassword = [percentEncodedPassword copy];
[old release];
}
|
︙ | | |
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
-
+
|
objc_autoreleasePoolPop(pool);
}
- (void)setPercentEncodedPath: (OFString *)percentEncodedPath
{
OFString *old;
OFIRIVerifyIsEscaped(percentEncodedPath,
_OFIRIVerifyIsEscaped(percentEncodedPath,
[OFCharacterSet IRIPathAllowedCharacterSet], true);
old = _percentEncodedPath;
_percentEncodedPath = [percentEncodedPath copy];
[old release];
}
|
︙ | | |
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
|
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
|
-
+
|
}
- (void)setPercentEncodedQuery: (OFString *)percentEncodedQuery
{
OFString *old;
if (percentEncodedQuery != nil)
OFIRIVerifyIsEscaped(percentEncodedQuery,
_OFIRIVerifyIsEscaped(percentEncodedQuery,
[OFCharacterSet IRIQueryAllowedCharacterSet], true);
old = _percentEncodedQuery;
_percentEncodedQuery = [percentEncodedQuery copy];
[old release];
}
|
︙ | | |
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
|
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
|
-
+
|
}
- (void)setPercentEncodedFragment: (OFString *)percentEncodedFragment
{
OFString *old;
if (percentEncodedFragment != nil)
OFIRIVerifyIsEscaped(percentEncodedFragment,
_OFIRIVerifyIsEscaped(percentEncodedFragment,
[OFCharacterSet IRIFragmentAllowedCharacterSet], true);
old = _percentEncodedFragment;
_percentEncodedFragment = [percentEncodedFragment copy];
[old release];
}
|
︙ | | |
Modified src/OFMutableString.m
from [f4575ddf27]
to [152dfafa6a].
︙ | | |
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
|
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
|
-
+
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
|
{
char *UTF8String;
int UTF8StringLength;
if (format == nil)
@throw [OFInvalidArgumentException exception];
if ((UTF8StringLength = OFVASPrintF(&UTF8String, format.UTF8String,
if ((UTF8StringLength = _OFVASPrintF(&UTF8String, format.UTF8String,
arguments)) == -1)
@throw [OFInvalidFormatException exception];
@try {
[self appendUTF8String: UTF8String length: UTF8StringLength];
} @finally {
free(UTF8String);
}
}
#ifdef OF_HAVE_UNICODE_TABLES
- (void)uppercase
{
[self of_convertWithWordStartTable: OFUnicodeUppercaseTable
wordMiddleTable: OFUnicodeUppercaseTable
wordStartTableSize: OFUnicodeUppercaseTableSize
wordMiddleTableSize: OFUnicodeUppercaseTableSize];
[self of_convertWithWordStartTable: _OFUnicodeUppercaseTable
wordMiddleTable: _OFUnicodeUppercaseTable
wordStartTableSize: _OFUnicodeUppercaseTableSize
wordMiddleTableSize: _OFUnicodeUppercaseTableSize];
}
- (void)lowercase
{
[self of_convertWithWordStartTable: OFUnicodeLowercaseTable
wordMiddleTable: OFUnicodeLowercaseTable
wordStartTableSize: OFUnicodeLowercaseTableSize
wordMiddleTableSize: OFUnicodeLowercaseTableSize];
[self of_convertWithWordStartTable: _OFUnicodeLowercaseTable
wordMiddleTable: _OFUnicodeLowercaseTable
wordStartTableSize: _OFUnicodeLowercaseTableSize
wordMiddleTableSize: _OFUnicodeLowercaseTableSize];
}
- (void)capitalize
{
[self of_convertWithWordStartTable: OFUnicodeTitlecaseTable
wordMiddleTable: OFUnicodeLowercaseTable
wordStartTableSize: OFUnicodeTitlecaseTableSize
wordMiddleTableSize: OFUnicodeLowercaseTableSize];
[self of_convertWithWordStartTable: _OFUnicodeTitlecaseTable
wordMiddleTable: _OFUnicodeLowercaseTable
wordStartTableSize: _OFUnicodeTitlecaseTableSize
wordMiddleTableSize: _OFUnicodeLowercaseTableSize];
}
#else
- (void)uppercase
{
convert(self, OFASCIIToUpper, OFASCIIToUpper);
}
|
︙ | | |
Modified src/OFMutableUTF8String.m
from [3ea1ecdd6c]
to [0d2c04f6f8].
︙ | | |
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
-
+
|
table = startTable;
tableSize = middleTableSize;
} else {
table = middleTable;
tableSize = middleTableSize;
}
cLen = OFUTF8StringDecode(_s->cString + i,
cLen = _OFUTF8StringDecode(_s->cString + i,
_s->cStringLength - i, &c);
if (cLen <= 0 || c > 0x10FFFF) {
OFFreeMemory(unicodeString);
@throw [OFInvalidEncodingException exception];
}
|
︙ | | |
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
-
+
|
}
j = 0;
for (i = 0; i < unicodeLen; i++) {
size_t d;
if ((d = OFUTF8StringEncode(unicodeString[i],
if ((d = _OFUTF8StringEncode(unicodeString[i],
newCString + j)) == 0) {
OFFreeMemory(unicodeString);
OFFreeMemory(newCString);
@throw [OFInvalidEncodingException exception];
}
j += d;
}
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
|
{
char buffer[4];
OFUnichar c;
size_t lenNew;
ssize_t lenOld;
if (_s->isUTF8)
idx = OFUTF8StringIndexToPosition(_s->cString, idx,
idx = _OFUTF8StringIndexToPosition(_s->cString, idx,
_s->cStringLength);
if (idx >= _s->cStringLength)
@throw [OFOutOfRangeException exception];
/* Shortcut if old and new character both are ASCII */
if (character < 0x80 && !(_s->cString[idx] & 0x80)) {
_s->hasHash = false;
_s->cString[idx] = character;
return;
}
if ((lenNew = OFUTF8StringEncode(character, buffer)) == 0)
if ((lenNew = _OFUTF8StringEncode(character, buffer)) == 0)
@throw [OFInvalidEncodingException exception];
if ((lenOld = OFUTF8StringDecode(_s->cString + idx,
if ((lenOld = _OFUTF8StringDecode(_s->cString + idx,
_s->cStringLength - idx, &c)) <= 0)
@throw [OFInvalidEncodingException exception];
_s->hasHash = false;
if (lenNew == (size_t)lenOld)
memcpy(_s->cString + idx, buffer, lenNew);
|
︙ | | |
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
-
+
|
if (UTF8StringLength >= 3 &&
memcmp(UTF8String, "\xEF\xBB\xBF", 3) == 0) {
UTF8String += 3;
UTF8StringLength -= 3;
}
switch (OFUTF8StringCheck(UTF8String, UTF8StringLength, &length)) {
switch (_OFUTF8StringCheck(UTF8String, UTF8StringLength, &length)) {
case 1:
_s->isUTF8 = true;
break;
case -1:
@throw [OFInvalidEncodingException exception];
}
|
︙ | | |
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
|
-
+
|
if (UTF8StringLength >= 3 &&
memcmp(UTF8String, "\xEF\xBB\xBF", 3) == 0) {
UTF8String += 3;
UTF8StringLength -= 3;
}
switch (OFUTF8StringCheck(UTF8String, UTF8StringLength, &length)) {
switch (_OFUTF8StringCheck(UTF8String, UTF8StringLength, &length)) {
case 1:
_s->isUTF8 = true;
break;
case -1:
@throw [OFInvalidEncodingException exception];
}
|
︙ | | |
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
|
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
|
-
+
+
|
char *tmp = OFAllocMemory((length * 4) + 1, 1);
@try {
size_t j = 0;
bool isUTF8 = false;
for (size_t i = 0; i < length; i++) {
size_t len = OFUTF8StringEncode(characters[i], tmp + j);
size_t len = _OFUTF8StringEncode(characters[i],
tmp + j);
if (len == 0)
@throw [OFInvalidEncodingException exception];
if (len > 1)
isUTF8 = true;
|
︙ | | |
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
|
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
|
-
+
-
+
|
{
char *UTF8String;
int UTF8StringLength;
if (format == nil)
@throw [OFInvalidArgumentException exception];
if ((UTF8StringLength = OFVASPrintF(&UTF8String, format.UTF8String,
if ((UTF8StringLength = _OFVASPrintF(&UTF8String, format.UTF8String,
arguments)) == -1)
@throw [OFInvalidFormatException exception];
@try {
[self appendUTF8String: UTF8String length: UTF8StringLength];
} @finally {
free(UTF8String);
}
}
- (void)insertString: (OFString *)string atIndex: (size_t)idx
{
size_t newCStringLength;
if (idx > _s->length)
@throw [OFOutOfRangeException exception];
if (_s->isUTF8)
idx = OFUTF8StringIndexToPosition(_s->cString, idx,
idx = _OFUTF8StringIndexToPosition(_s->cString, idx,
_s->cStringLength);
newCStringLength = _s->cStringLength + string.UTF8StringLength;
_s->hasHash = false;
_s->cString = OFResizeMemory(_s->cString, newCStringLength + 1, 1);
memmove(_s->cString + idx + string.UTF8StringLength,
|
︙ | | |
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
|
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
|
-
+
-
+
|
size_t start = range.location;
size_t end = range.location + range.length;
if (range.length > SIZE_MAX - range.location || end > _s->length)
@throw [OFOutOfRangeException exception];
if (_s->isUTF8) {
start = OFUTF8StringIndexToPosition(_s->cString, start,
start = _OFUTF8StringIndexToPosition(_s->cString, start,
_s->cStringLength);
end = OFUTF8StringIndexToPosition(_s->cString, end,
end = _OFUTF8StringIndexToPosition(_s->cString, end,
_s->cStringLength);
}
memmove(_s->cString + start, _s->cString + end,
_s->cStringLength - end);
_s->hasHash = false;
_s->length -= range.length;
|
︙ | | |
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
|
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
|
-
+
-
+
|
if (range.length > SIZE_MAX - range.location || end > _s->length)
@throw [OFOutOfRangeException exception];
newLength = _s->length - range.length + replacement.length;
if (_s->isUTF8) {
start = OFUTF8StringIndexToPosition(_s->cString, start,
start = _OFUTF8StringIndexToPosition(_s->cString, start,
_s->cStringLength);
end = OFUTF8StringIndexToPosition(_s->cString, end,
end = _OFUTF8StringIndexToPosition(_s->cString, end,
_s->cStringLength);
}
newCStringLength = _s->cStringLength - (end - start) +
replacement.UTF8StringLength;
_s->hasHash = false;
|
︙ | | |
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
|
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
|
-
+
-
+
|
@throw [OFInvalidArgumentException exception];
if (range.length > SIZE_MAX - range.location ||
range.location + range.length > self.length)
@throw [OFOutOfRangeException exception];
if (_s->isUTF8) {
range.location = OFUTF8StringIndexToPosition(_s->cString,
range.location = _OFUTF8StringIndexToPosition(_s->cString,
range.location, _s->cStringLength);
range.length = OFUTF8StringIndexToPosition(
range.length = _OFUTF8StringIndexToPosition(
_s->cString + range.location, range.length,
_s->cStringLength - range.location);
}
if (string.UTF8StringLength > range.length)
return;
|
︙ | | |
Modified src/OFObject+KeyValueCoding.h
from [0118a5fa63]
to [2c8a0862b7].
︙ | | |
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
|
-
+
|
#import "OFKeyValueCoding.h"
OF_ASSUME_NONNULL_BEGIN
#ifdef __cplusplus
extern "C" {
#endif
extern int _OFObject_KeyValueCoding_reference;
extern int _OFObject_KeyValueCoding_reference OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
@interface OFObject (KeyValueCoding) <OFKeyValueCoding>
@end
|
︙ | | |
Modified src/OFObject.h
from [08353423b4]
to [7b8537b8d6].
︙ | | |
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
|
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
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
const void *_Nonnull key, id _Nullable value,
objc_associationPolicy policy);
extern id _Nullable objc_getAssociatedObject(id _Nonnull object,
const void *_Nonnull key);
extern void objc_removeAssociatedObjects(id _Nonnull object);
# endif
#endif
/**
* @brief Allocates a new object.
*
* This is useful to override @ref OFObject#alloc in a subclass that can then
* allocate extra memory in the same memory allocation.
*
* @param class_ The class of which to allocate an object
* @param extraSize Extra space after the ivars to allocate
* @param extraAlignment Alignment of the extra space after the ivars
* @param extra A pointer to set to a pointer to the extra space
* @return The allocated object
*/
extern id OFAllocObject(Class class_, size_t extraSize, size_t extraAlignment,
void *_Nullable *_Nullable extra);
/**
* @brief This function is called when a method is not found.
*
* It can also be called intentionally to indicate that a method is not
* implemetned, for example in an abstract method. However, instead of calling
* OFMethodNotFound directly, it is preferred to do the following:
*
* - (void)abstractMethod
* {
* OF_UNRECOGNIZED_SELECTOR
* }
*
* However, do not use this for init methods. Instead, use the following:
*
* - (instancetype)init
* {
* OF_INVALID_INIT_METHOD
* }
*
* @param self The object which does not have the method
* @param _cmd The selector of the method that does not exist
*/
extern void OF_NO_RETURN_FUNC OFMethodNotFound(id self, SEL _cmd);
/**
* @brief Initializes the specified hash.
*
* @param hash A pointer to the hash to initialize
*/
|
︙ | | |
Modified src/OFObject.m
from [aac1ccf77b]
to [8a5a49c0ca].
︙ | | |
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
|
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
|
-
+
|
const char *
_NSPrintForDebugger(id object)
{
return [[object description] cStringWithEncoding: [OFLocale encoding]];
}
/* References for static linking */
void
void OF_VISIBILITY_HIDDEN
_references_to_categories_of_OFObject(void)
{
_OFObject_KeyValueCoding_reference = 1;
}
@implementation OFObject
+ (void)load
|
︙ | | |
Modified src/OFPlainCondition.h
from [bbdacbeb4f]
to [2b26bbac16].
︙ | | |
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
|
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
|
+
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
(!defined(OF_HAVE_PTHREADS) && !defined(OF_WINDOWS) && !defined(OF_AMIGAOS))
# error No conditions available!
#endif
/* For OFTimeInterval */
#import "OFObject.h"
#import "OFPlainMutex.h"
/** @file */
#if defined(OF_HAVE_PTHREADS)
# include <pthread.h>
typedef pthread_cond_t OFPlainCondition;
#elif defined(OF_WINDOWS)
# include <windows.h>
typedef struct {
HANDLE event;
volatile int count;
} OFPlainCondition;
#elif defined(OF_AMIGAOS)
# include <exec/tasks.h>
typedef struct {
struct OFPlainConditionWaitingTask {
struct _OFPlainConditionWaitingTask {
struct Task *task;
unsigned char sigBit;
struct OFPlainConditionWaitingTask *next;
struct _OFPlainConditionWaitingTask *next;
} *waitingTasks;
} OFPlainCondition;
#endif
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Creates a new plain condition.
*
* A plain condition is similar to an @ref OFCondition, but does not use
* exceptions and can be used from pure C code.
*
* @param condition A pointer to the condition to create
* @return 0 on success, or an error number from `<errno.h>` on error
*/
extern int OFPlainConditionNew(OFPlainCondition *condition);
/**
* @brief Signals the specified condition.
*
* @param condition A pointer to the condition to signal
* @return 0 on success, or an error number from `<errno.h>` on error
*/
extern int OFPlainConditionSignal(OFPlainCondition *condition);
/**
* @brief Broadcasts the specified condition, meaning it will be signaled to
* everyone waiting.
*
* @param condition A pointer to the condition to broadcast
* @return 0 on success, or an error number from `<errno.h>` on error
*/
extern int OFPlainConditionBroadcast(OFPlainCondition *condition);
/**
* @brief Waits on the specified condition with the specified mutex.
*
* @param condition A pointer to the condition to wait on
* @param mutex The mutex to wait with
* @return 0 on success, or an error number from `<errno.h>` on error
*/
extern int OFPlainConditionWait(OFPlainCondition *condition,
OFPlainMutex *mutex);
/**
* @brief Waits on the specified condition with the specified mutex with a
* timeout.
*
* @param condition A pointer to the condition to wait on
* @param mutex The mutex to wait with
* @param timeout The timeout after which to give up
* @return 0 on success, or an error number from `<errno.h>` on error
*/
extern int OFPlainConditionTimedWait(OFPlainCondition *condition,
OFPlainMutex *mutex, OFTimeInterval timeout);
#if defined(OF_AMIGAOS) || defined(DOXYGEN)
/**
* @brief Waits on the specified condition with the specified mutex or the
* specified Exec signal.
*
* @param condition A pointer to the condition to wait on
* @param mutex The mutex to wait with
* @param signalMask The Exec signal mask to wait for
* @return 0 on success, or an error number from `<errno.h>` on error
*/
extern int OFPlainConditionWaitOrExecSignal(OFPlainCondition *condition,
OFPlainMutex *mutex, ULONG *signalMask);
/**
* @brief Waits on the specified condition with the specified mutex or the
* specified Exec signal, up until the timeout is reached.
*
* @param condition A pointer to the condition to wait on
* @param mutex The mutex to wait with
* @param signalMask The Exec signal mask to wait for
* @param timeout The timeout after which to give up
* @return 0 on success, or an error number from `<errno.h>` on error
*/
extern int OFPlainConditionTimedWaitOrExecSignal(OFPlainCondition *condition,
OFPlainMutex *mutex, OFTimeInterval timeout, ULONG *signalMask);
#endif
/**
* @brief Destroys the specified plain condition.
*
* @param condition A pointer to the condition to destroy
* @return 0 on success, or an error number from `<errno.h>` on error
*/
extern int OFPlainConditionFree(OFPlainCondition *condition);
#ifdef __cplusplus
}
#endif
|
Modified src/OFPlainMutex.h
from [b1091dda6a]
to [31506d7dcf].
︙ | | |
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
+
+
|
#if !defined(OF_HAVE_THREADS) || \
(!defined(OF_HAVE_PTHREADS) && !defined(OF_WINDOWS) && !defined(OF_AMIGAOS))
# error No mutexes available!
#endif
#import "macros.h"
/** @file */
#if defined(OF_HAVE_PTHREADS)
# include <pthread.h>
typedef pthread_mutex_t OFPlainMutex;
#elif defined(OF_WINDOWS)
# include <windows.h>
typedef CRITICAL_SECTION OFPlainMutex;
|
︙ | | |
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
|
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
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
OFTLSKey count;
} OFPlainRecursiveMutex;
#endif
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Creates a new plain mutex.
*
* A plain mutex is similar to an @ref OFMutex, but does not use exceptions and
* is just a lightweight wrapper around the system's mutex implementation.
*
* @param mutex A pointer to the mutex to create
* @return 0 on success, or an error number from `<errno.h>` on error
*/
extern int OFPlainMutexNew(OFPlainMutex *mutex);
/**
* @brief Locks the specified mutex.
*
* @param mutex A pointer to the mutex to lock
* @return 0 on success, or an error number from `<errno.h>` on error
*/
extern int OFPlainMutexLock(OFPlainMutex *mutex);
/**
* @brief Tries to lock the specified mutex without blocking.
*
* @param mutex A pointer to the mutex to try to lock
* @return 0 on success, or an error number from `<errno.h>` on error
*/
extern int OFPlainMutexTryLock(OFPlainMutex *mutex);
/**
* @brief Unlocks the specified mutex.
*
* @param mutex A pointer to the mutex to unlock
* @return 0 on success, or an error number from `<errno.h>` on error
*/
extern int OFPlainMutexUnlock(OFPlainMutex *mutex);
/**
* @brief Destroys the specified mutex
*
* @param mutex A pointer to the mutex to destruct
* @return 0 on success, or an error number from `<errno.h>` on error
*/
extern int OFPlainMutexFree(OFPlainMutex *mutex);
/**
* @brief Creates a new plain recursive mutex.
*
* A plain recursive mutex is similar to an @ref OFRecursiveMutex, but does not
* use exceptions and is just a lightweight wrapper around the system's
* recursive mutex implementation (or lacking that, a simple implementation of
* recursive mutexes via regular mutexes).
*
* @param rmutex A pointer to the recursive mutex to create
* @return 0 on success, or an error number from `<errno.h>` on error
*/
extern int OFPlainRecursiveMutexNew(OFPlainRecursiveMutex *rmutex);
/**
* @brief Locks the specified recursive mutex.
*
* @param rmutex A pointer to the recursive mutex to lock
* @return 0 on success, or an error number from `<errno.h>` on error
*/
extern int OFPlainRecursiveMutexLock(OFPlainRecursiveMutex *rmutex);
/**
* @brief Tries to lock the specified recursive mutex without blocking.
*
* @param rmutex A pointer to the recursive mutex to try to lock
* @return 0 on success, or an error number from `<errno.h>` on error
*/
extern int OFPlainRecursiveMutexTryLock(OFPlainRecursiveMutex *rmutex);
/**
* @brief Unlocks the specified recursive mutex.
*
* @param rmutex A pointer to the recursive mutex to unlock
* @return 0 on success, or an error number from `<errno.h>` on error
*/
extern int OFPlainRecursiveMutexUnlock(OFPlainRecursiveMutex *rmutex);
/**
* @brief Destroys the specified recursive mutex
*
* @param rmutex A pointer to the recursive mutex to destruct
* @return 0 on success, or an error number from `<errno.h>` on error
*/
extern int OFPlainRecursiveMutexFree(OFPlainRecursiveMutex *rmutex);
#ifdef __cplusplus
}
#endif
/* Spinlocks are inlined for performance. */
/**
* @brief Yield the current thread, indicating to the OS that another thread
* should execute instead.
*/
static OF_INLINE void
OFYieldThread(void)
{
#if defined(OF_HAVE_SCHED_YIELD)
sched_yield();
#elif defined(OF_WINDOWS)
Sleep(0);
#endif
}
/**
* @brief Creates a new spinlock.
*
* @param spinlock A pointer to the spinlock to create
* @return 0 on success, or an error number from `<errno.h>` on error
*/
static OF_INLINE int
OFSpinlockNew(OFSpinlock *spinlock)
{
#if defined(OF_HAVE_ATOMIC_OPS)
*spinlock = 0;
return 0;
#elif defined(OF_HAVE_PTHREAD_SPINLOCKS)
return pthread_spin_init(spinlock, 0);
#else
return OFPlainMutexNew(spinlock);
#endif
}
/**
* @brief Tries to lock a spinlock.
*
* @param spinlock A pointer to the spinlock to try to lock
* @return 0 on success, or an error number from `<errno.h>` on error
*/
static OF_INLINE int
OFSpinlockTryLock(OFSpinlock *spinlock)
{
#if defined(OF_HAVE_ATOMIC_OPS)
if (OFAtomicIntCompareAndSwap(spinlock, 0, 1)) {
OFAcquireMemoryBarrier();
return 0;
}
return EBUSY;
#elif defined(OF_HAVE_PTHREAD_SPINLOCKS)
return pthread_spin_trylock(spinlock);
#else
return OFPlainMutexTryLock(spinlock);
#endif
}
/**
* @brief Locks a spinlock.
*
* @param spinlock A pointer to the spinlock to lock
* @return 0 on success, or an error number from `<errno.h>` on error
*/
static OF_INLINE int
OFSpinlockLock(OFSpinlock *spinlock)
{
#if defined(OF_HAVE_ATOMIC_OPS)
size_t i;
for (i = 0; i < 10; i++)
|
︙ | | |
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
|
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
|
+
+
+
+
+
+
+
+
+
+
+
+
|
#elif defined(OF_HAVE_PTHREAD_SPINLOCKS)
return pthread_spin_lock(spinlock);
#else
return OFPlainMutexLock(spinlock);
#endif
}
/**
* @brief Unlocks a spinlock.
*
* @param spinlock A pointer to the spinlock to unlock
* @return 0 on success, or an error number from `<errno.h>` on error
*/
static OF_INLINE int
OFSpinlockUnlock(OFSpinlock *spinlock)
{
#if defined(OF_HAVE_ATOMIC_OPS)
bool ret = OFAtomicIntCompareAndSwap(spinlock, 1, 0);
OFReleaseMemoryBarrier();
return (ret ? 0 : EINVAL);
#elif defined(OF_HAVE_PTHREAD_SPINLOCKS)
return pthread_spin_unlock(spinlock);
#else
return OFPlainMutexUnlock(spinlock);
#endif
}
/**
* @brief Destroys a spinlock.
*
* @param spinlock A pointer to the spinlock to destroy
* @return 0 on success, or an error number from `<errno.h>` on error
*/
static OF_INLINE int
OFSpinlockFree(OFSpinlock *spinlock)
{
#if defined(OF_HAVE_ATOMIC_OPS)
return 0;
#elif defined(OF_HAVE_PTHREAD_SPINLOCKS)
return pthread_spin_destroy(spinlock);
#else
return OFPlainMutexFree(spinlock);
#endif
}
|
Modified src/OFPlainThread.h
from [3654325ef3]
to [3b3df80df6].
︙ | | |
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
+
+
|
#if !defined(OF_HAVE_THREADS) || \
(!defined(OF_HAVE_PTHREADS) && !defined(OF_WINDOWS) && !defined(OF_AMIGAOS))
# error No threads available!
#endif
#import "OFObject.h"
/** @file */
#if defined(OF_HAVE_PTHREADS)
# include <pthread.h>
typedef pthread_t OFPlainThread;
#elif defined(OF_WINDOWS)
# include <windows.h>
typedef HANDLE OFPlainThread;
|
︙ | | |
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
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
|
-
+
+
+
+
+
+
+
+
+
+
+
+
|
#endif
typedef struct {
float priority;
size_t stackSize;
} OFPlainThreadAttributes;
#if defined(OF_HAVE_PTHREADS)
#if defined(OF_HAVE_PTHREADS) || defined(DOXYGEN)
/**
* @brief Returns the current plain thread.
*
* @return The current plain thread
*/
static OF_INLINE OFPlainThread
OFCurrentPlainThread(void)
{
return pthread_self();
}
/**
* @brief Returns whether the specified plain thread is the current thread.
*
* @param thread The thread to check
* @return Whether the specified plain thread is the current thread
*/
static OF_INLINE bool
OFPlainThreadIsCurrent(OFPlainThread thread)
{
return pthread_equal(thread, pthread_self());
}
#elif defined(OF_WINDOWS)
static OF_INLINE OFPlainThread
|
︙ | | |
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
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
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
extern OFPlainThread OFCurrentPlainThread(void);
extern bool OFPlainThreadIsCurrent(OFPlainThread);
#endif
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initializes the specified thread attributes.
*
* @param attr A pointer to the thread attributes to initialize
* @return 0 on success, or an error number from `<errno.h>` on error
*/
extern int OFPlainThreadAttributesInit(OFPlainThreadAttributes *attr);
/**
* @brief Creates a new plain thread.
*
* A plain thread is similar to @ref OFThread, but does not use exceptions and
* is just a lightweight wrapper around the system's thread implementation.
*
* @param thread A pointer to the thread to create
* @param name A name for the thread
* @param function The function the thread should execute
* @param object The object to pass to the thread as an argument
* @param attr Thread attributes
* @return 0 on success, or an error number from `<errno.h>` on error
*/
extern int OFPlainThreadNew(OFPlainThread *thread, const char *name,
void (*function)(id), id object, const OFPlainThreadAttributes *attr);
/**
* @brief Sets the name of the current thread.
*
* @param name The name for the current thread
*/
extern void OFSetThreadName(const char *name);
/**
* @brief Joins the specified thread.
*
* @param thread The thread to join
* @return 0 on success, or an error number from `<errno.h>` on error
*/
extern int OFPlainThreadJoin(OFPlainThread thread);
/**
* @brief Detaches the specified thread.
*
* @param thread The thread to detach
* @return 0 on success, or an error number from `<errno.h>` on error
*/
extern int OFPlainThreadDetach(OFPlainThread thread);
#ifdef __cplusplus
}
#endif
|
Modified src/OFSPXSocket.m
from [007210b145]
to [6998eecec7].
︙ | | |
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
|
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
|
-
+
-
+
|
if (_socket != OFInvalidSocketHandle)
@throw [OFAlreadyOpenException exceptionWithObject: self];
if ((_socket = socket(address->sockaddr.ipx.sipx_family,
SOCK_SEQPACKET | SOCK_CLOEXEC, NSPROTO_SPX)) ==
OFInvalidSocketHandle) {
*errNo = OFSocketErrNo();
*errNo = _OFSocketErrNo();
return false;
}
#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC)
if ((flags = fcntl(_socket, F_GETFD, 0)) != -1)
fcntl(_socket, F_SETFD, flags | FD_CLOEXEC);
#endif
return true;
}
- (bool)of_connectSocketToAddress: (const OFSocketAddress *)address
errNo: (int *)errNo
{
if (_socket == OFInvalidSocketHandle)
@throw [OFNotOpenException exceptionWithObject: self];
if (connect(_socket, (struct sockaddr *)&address->sockaddr,
address->length) != 0) {
*errNo = OFSocketErrNo();
*errNo = _OFSocketErrNo();
return false;
}
return true;
}
- (void)of_closeSocket
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
|
OFInvalidSocketHandle)
@throw [OFBindIPXSocketFailedException
exceptionWithNetwork: network
node: node
port: port
packetType: SPXPacketType
socket: self
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
_canBlock = true;
#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC)
if ((flags = fcntl(_socket, F_GETFD, 0)) != -1)
fcntl(_socket, F_SETFD, flags | FD_CLOEXEC);
#endif
if (bind(_socket, (struct sockaddr *)&address.sockaddr,
address.length) != 0) {
int errNo = OFSocketErrNo();
int errNo = _OFSocketErrNo();
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindIPXSocketFailedException
exceptionWithNetwork: network
node: node
port: port
packetType: SPXPacketType
socket: self
errNo: errNo];
}
memset(&address, 0, sizeof(address));
address.family = OFSocketAddressFamilyIPX;
address.length = (socklen_t)sizeof(address.sockaddr);
if (OFGetSockName(_socket, (struct sockaddr *)&address.sockaddr,
if (_OFGetSockName(_socket, (struct sockaddr *)&address.sockaddr,
&address.length) != 0) {
int errNo = OFSocketErrNo();
int errNo = _OFSocketErrNo();
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindIPXSocketFailedException
exceptionWithNetwork: network
node: node
|
︙ | | |
Modified src/OFSPXStreamSocket.m
from [90372031f9]
to [a3f34f0fcf].
︙ | | |
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
|
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
|
-
+
-
+
|
if (_socket != OFInvalidSocketHandle)
@throw [OFAlreadyOpenException exceptionWithObject: self];
if ((_socket = socket(address->sockaddr.ipx.sipx_family,
SOCK_STREAM | SOCK_CLOEXEC, NSPROTO_SPX)) ==
OFInvalidSocketHandle) {
*errNo = OFSocketErrNo();
*errNo = _OFSocketErrNo();
return false;
}
#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC)
if ((flags = fcntl(_socket, F_GETFD, 0)) != -1)
fcntl(_socket, F_SETFD, flags | FD_CLOEXEC);
#endif
return true;
}
- (bool)of_connectSocketToAddress: (const OFSocketAddress *)address
errNo: (int *)errNo
{
if (_socket == OFInvalidSocketHandle)
@throw [OFNotOpenException exceptionWithObject: self];
if (connect(_socket, (struct sockaddr *)&address->sockaddr,
address->length) != 0) {
*errNo = OFSocketErrNo();
*errNo = _OFSocketErrNo();
return false;
}
return true;
}
- (void)of_closeSocket
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
|
SOCK_STREAM | SOCK_CLOEXEC, NSPROTO_SPX)) == OFInvalidSocketHandle)
@throw [OFBindIPXSocketFailedException
exceptionWithNetwork: network
node: node
port: port
packetType: SPXPacketType
socket: self
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
_canBlock = true;
#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC)
if ((flags = fcntl(_socket, F_GETFD, 0)) != -1)
fcntl(_socket, F_SETFD, flags | FD_CLOEXEC);
#endif
if (bind(_socket, (struct sockaddr *)&address.sockaddr,
address.length) != 0) {
int errNo = OFSocketErrNo();
int errNo = _OFSocketErrNo();
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindIPXSocketFailedException
exceptionWithNetwork: network
node: node
port: port
packetType: SPXPacketType
socket: self
errNo: errNo];
}
memset(&address, 0, sizeof(address));
address.family = OFSocketAddressFamilyIPX;
address.length = (socklen_t)sizeof(address.sockaddr);
if (OFGetSockName(_socket, (struct sockaddr *)&address.sockaddr,
if (_OFGetSockName(_socket, (struct sockaddr *)&address.sockaddr,
&address.length) != 0) {
int errNo = OFSocketErrNo();
int errNo = _OFSocketErrNo();
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindIPXSocketFailedException
exceptionWithNetwork: network
node: node
|
︙ | | |
Modified src/OFScrypt.h
from [76bac8d2f2]
to [b9cb45c890].
︙ | | |
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
+
-
-
+
+
-
+
|
/** @brief Whether data may be stored in swappable memory. */
bool allowsSwappableMemory;
} OFScryptParameters;
#ifdef __cplusplus
extern "C" {
#endif
/* No OF_VISIBILITY_HIDDEN so tests can call it. */
extern void OFSalsa20_8Core(uint32_t buffer[_Nonnull 16]);
extern void OFScryptBlockMix(uint32_t *output, const uint32_t *input,
extern void _OFSalsa20_8Core(uint32_t buffer[_Nonnull 16]);
extern void _OFScryptBlockMix(uint32_t *output, const uint32_t *input,
size_t blockSize);
extern void OFScryptROMix(uint32_t *buffer, size_t blockSize,
extern void _OFScryptROMix(uint32_t *buffer, size_t blockSize,
size_t costFactor, uint32_t *tmp);
/**
* @brief Derives a key from a password and a salt using scrypt.
*
* @param parameters The parameters to use
*/
|
︙ | | |
Modified src/OFScrypt.m
from [94500350d8]
to [480d9e7945].
︙ | | |
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
-
+
|
#import "OFOutOfMemoryException.h"
#import "OFOutOfRangeException.h"
#import "OFScrypt.h"
#import "OFPBKDF2.h"
void
OFSalsa20_8Core(uint32_t buffer[16])
_OFSalsa20_8Core(uint32_t buffer[16])
{
uint32_t tmp[16];
for (uint_fast8_t i = 0; i < 16; i++)
tmp[i] = OFToLittleEndian32(buffer[i]);
for (uint_fast8_t i = 0; i < 8; i += 2) {
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
-
+
|
buffer[i] = OFToLittleEndian32(OFFromLittleEndian32(buffer[i]) +
tmp[i]);
OFZeroMemory(tmp, sizeof(tmp));
}
void
OFScryptBlockMix(uint32_t *output, const uint32_t *input, size_t blockSize)
_OFScryptBlockMix(uint32_t *output, const uint32_t *input, size_t blockSize)
{
uint32_t tmp[16];
/* Check defined here and executed in OFScrypt() */
#define OVERFLOW_CHECK_1 \
if (param.blockSize > SIZE_MAX / 2 || \
2 * param.blockSize - 1 > SIZE_MAX / 16) \
@throw [OFOutOfRangeException exception];
memcpy(tmp, input + (2 * blockSize - 1) * 16, 64);
for (size_t i = 0; i < 2 * blockSize; i++) {
for (size_t j = 0; j < 16; j++)
tmp[j] ^= input[i * 16 + j];
OFSalsa20_8Core(tmp);
_OFSalsa20_8Core(tmp);
/*
* Even indices are stored in the first half and odd ones in
* the second.
*/
memcpy(output + ((i / 2) + (i & 1) * blockSize) * 16, tmp, 64);
}
OFZeroMemory(tmp, sizeof(tmp));
}
void
OFScryptROMix(uint32_t *buffer, size_t blockSize, size_t costFactor,
_OFScryptROMix(uint32_t *buffer, size_t blockSize, size_t costFactor,
uint32_t *tmp)
{
/* Check defined here and executed in OFScrypt() */
#define OVERFLOW_CHECK_2 \
if (param.blockSize > SIZE_MAX / 128 / param.costFactor) \
@throw [OFOutOfRangeException exception];
uint32_t *tmp2 = tmp + 32 * blockSize;
memcpy(tmp, buffer, 128 * blockSize);
for (size_t i = 0; i < costFactor; i++) {
memcpy(tmp2 + i * 32 * blockSize, tmp, 128 * blockSize);
OFScryptBlockMix(tmp, tmp2 + i * 32 * blockSize, blockSize);
_OFScryptBlockMix(tmp, tmp2 + i * 32 * blockSize, blockSize);
}
for (size_t i = 0; i < costFactor; i++) {
uint32_t j = OFFromLittleEndian32(
tmp[(2 * blockSize - 1) * 16]) & (costFactor - 1);
for (size_t k = 0; k < 32 * blockSize; k++)
tmp[k] ^= tmp2[j * 32 * blockSize + k];
OFScryptBlockMix(buffer, tmp, blockSize);
_OFScryptBlockMix(buffer, tmp, blockSize);
if (i < costFactor - 1)
memcpy(tmp, buffer, 128 * blockSize);
}
}
void
|
︙ | | |
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
|
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
|
-
+
|
.key = (unsigned char *)bufferItems,
.keyLength = param.parallelization * 128 *
param.blockSize,
.allowsSwappableMemory = param.allowsSwappableMemory
});
for (size_t i = 0; i < param.parallelization; i++)
OFScryptROMix(bufferItems + i * 32 * param.blockSize,
_OFScryptROMix(bufferItems + i * 32 * param.blockSize,
param.blockSize, param.costFactor, tmpItems);
OFPBKDF2((OFPBKDF2Parameters){
.HMAC = HMAC,
.iterations = 1,
.salt = (unsigned char *)bufferItems,
.saltLength = param.parallelization * 128 *
|
︙ | | |
Modified src/OFSelectKernelEventObserver.m
from [93d2c09c3e]
to [5b2b3251fe].
︙ | | |
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
|
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
|
-
+
|
events = select(_maxFD + 1, &readFDs, &writeFDs, NULL,
(timeInterval != -1 ? &timeout : NULL));
#endif
if (events < 0)
@throw [OFObserveKernelEventsFailedException
exceptionWithObserver: self
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
#ifdef OF_AMIGAOS
if (execSignalMask != 0 &&
[_delegate respondsToSelector: @selector(execSignalWasReceived:)])
[_delegate execSignalWasReceived: execSignalMask];
#else
if (FD_ISSET(_cancelFD[0], &readFDs)) {
|
︙ | | |
Modified src/OFSequencedPacketSocket.m
from [ccecd9e1f0]
to [93df6d6776].
︙ | | |
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
-
+
|
@synthesize listening = _listening, delegate = _delegate;
+ (void)initialize
{
if (self != [OFSequencedPacketSocket class])
return;
if (!OFSocketInit())
if (!_OFSocketInit())
@throw [OFInitializationFailedException
exceptionWithClass: self];
}
+ (instancetype)socket
{
return [[[self alloc] init] autorelease];
|
︙ | | |
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
-
+
|
- (int)of_socketError
{
int errNo;
socklen_t len = sizeof(errNo);
if (getsockopt(_socket, SOL_SOCKET, SO_ERROR, (char *)&errNo,
&len) != 0)
return OFSocketErrNo();
return _OFSocketErrNo();
return errNo;
}
#endif
- (id)copy
{
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
|
_canBlock = canBlock;
#elif defined(OF_WINDOWS)
u_long v = !canBlock;
if (ioctlsocket(_socket, FIONBIO, &v) == SOCKET_ERROR)
@throw [OFSetOptionFailedException
exceptionWithObject: self
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
_canBlock = canBlock;
#else
OF_UNRECOGNIZED_SELECTOR
#endif
}
- (size_t)receiveIntoBuffer: (void *)buffer length: (size_t)length
{
ssize_t ret;
if (_socket == OFInvalidSocketHandle)
@throw [OFNotOpenException exceptionWithObject: self];
#ifndef OF_WINDOWS
if ((ret = recv(_socket, buffer, length, 0)) < 0)
@throw [OFReadFailedException
exceptionWithObject: self
requestedLength: length
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
#else
if (length > INT_MAX)
@throw [OFOutOfRangeException exception];
if ((ret = recv(_socket, buffer, (int)length, 0)) < 0)
@throw [OFReadFailedException
exceptionWithObject: self
requestedLength: length
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
#endif
return ret;
}
- (void)asyncReceiveIntoBuffer: (void *)buffer length: (size_t)length
{
|
︙ | | |
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
|
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
|
-
+
-
+
|
@throw [OFOutOfRangeException exception];
if ((bytesWritten = send(_socket, (void *)buffer, length, 0)) < 0)
@throw [OFWriteFailedException
exceptionWithObject: self
requestedLength: length
bytesWritten: 0
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
#else
int bytesWritten;
if (length > INT_MAX)
@throw [OFOutOfRangeException exception];
if ((bytesWritten = send(_socket, buffer, (int)length, 0)) < 0)
@throw [OFWriteFailedException
exceptionWithObject: self
requestedLength: length
bytesWritten: 0
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
#endif
if ((size_t)bytesWritten != length)
@throw [OFWriteFailedException exceptionWithObject: self
requestedLength: length
bytesWritten: bytesWritten
errNo: 0];
|
︙ | | |
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
|
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
|
-
+
|
if (_socket == OFInvalidSocketHandle)
@throw [OFNotOpenException exceptionWithObject: self];
if (listen(_socket, backlog) == -1)
@throw [OFListenOnSocketFailedException
exceptionWithSocket: self
backlog: backlog
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
_listening = true;
}
- (instancetype)accept
{
OFSequencedPacketSocket *client;
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
|
#if defined(HAVE_PACCEPT) && defined(SOCK_CLOEXEC)
if ((client->_socket = paccept(_socket,
(struct sockaddr *)&client->_remoteAddress.sockaddr,
&client->_remoteAddress.length, NULL, SOCK_CLOEXEC)) ==
OFInvalidSocketHandle)
@throw [OFAcceptSocketFailedException
exceptionWithSocket: self
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
#elif defined(HAVE_ACCEPT4) && defined(SOCK_CLOEXEC)
if ((client->_socket = accept4(_socket,
(struct sockaddr *)&client->_remoteAddress.sockaddr,
&client->_remoteAddress.length, SOCK_CLOEXEC)) ==
OFInvalidSocketHandle)
@throw [OFAcceptSocketFailedException
exceptionWithSocket: self
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
#else
if ((client->_socket = accept(_socket,
(struct sockaddr *)&client->_remoteAddress.sockaddr,
&client->_remoteAddress.length)) == OFInvalidSocketHandle)
@throw [OFAcceptSocketFailedException
exceptionWithSocket: self
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
# if defined(HAVE_FCNTL) && defined(FD_CLOEXEC)
if ((flags = fcntl(client->_socket, F_GETFD, 0)) != -1)
fcntl(client->_socket, F_SETFD, flags | FD_CLOEXEC);
# endif
#endif
|
︙ | | |
Modified src/OFSocket+Private.h
from [85d93768ea]
to [3e7201b279].
︙ | | |
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
-
+
-
+
|
# endif
# include <sys/filio.h>
# define closesocket(sock) CloseSocket(sock)
# define ioctlsocket(fd, req, arg) IoctlSocket(fd, req, arg)
# define hstrerror(err) "unknown (no hstrerror)"
# define SOCKET_ERROR -1
# if defined(OF_HAVE_THREADS) && !defined(OF_MORPHOS)
# define SocketBase ((struct Library *)OFTLSKeyGet(OFSocketBaseKey))
# define SocketBase ((struct Library *)OFTLSKeyGet(_OFSocketBaseKey))
# ifdef OF_AMIGAOS4
# define ISocket ((struct SocketIFace *)OFTLSKeyGet(OFSocketInterfaceKey))
# define ISocket ((struct SocketIFace *)OFTLSKeyGet(_OFSocketInterfaceKey))
# endif
# endif
# ifdef OF_MORPHOS
typedef uint32_t in_addr_t;
# endif
#elif !defined(OF_WINDOWS) && !defined(OF_WII)
# define closesocket(sock) close(sock)
|
︙ | | |
Modified src/OFSocket.h
from [5622251aeb]
to [48d578681c].
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
-
+
+
-
+
-
+
|
*
* @param address The address on which to get the port
* @return The port of the address
*/
extern uint8_t OFSocketAddressAppleTalkPort(
const OFSocketAddress *_Nonnull address);
extern bool OFSocketInit(void);
extern bool _OFSocketInit(void) OF_VISIBILITY_HIDDEN;
#if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS) && !defined(OF_MORPHOS)
extern void OFSocketDeinit(void);
extern void _OFSocketDeinit(void) OF_VISIBILITY_HIDDEN;
#endif
extern int OFSocketErrNo(void);
extern int _OFSocketErrNo(void) OF_VISIBILITY_HIDDEN;
#if !defined(OF_WII) && !defined(OF_NINTENDO_3DS)
extern int OFGetSockName(OFSocketHandle sock, struct sockaddr *restrict addr,
socklen_t *restrict addrLen);
extern int _OFGetSockName(OFSocketHandle sock, struct sockaddr *restrict addr,
socklen_t *restrict addrLen) OF_VISIBILITY_HIDDEN;
#endif
#if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS) && !defined(OF_MORPHOS)
extern OFTLSKey OFSocketBaseKey;
extern OFTLSKey _OFSocketBaseKey OF_VISIBILITY_HIDDEN;
# ifdef OF_AMIGAOS4
extern OFTLSKey OFSocketInterfaceKey;
extern OFTLSKey _OFSocketInterfaceKey OF_VISIBILITY_HIDDEN;
# endif
#endif
#ifdef __cplusplus
}
#endif
OF_ASSUME_NONNULL_END
|
Modified src/OFSocket.m
from [b9e69c4209]
to [0dcfbd34b6].
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
|
#endif
#if !defined(OF_AMIGAOS) || defined(OF_MORPHOS) || !defined(OF_HAVE_THREADS)
static bool initSuccessful = false;
#endif
#ifdef OF_AMIGAOS
# if defined(OF_HAVE_THREADS) && !defined(OF_MORPHOS)
OFTLSKey OFSocketBaseKey;
OFTLSKey _OFSocketBaseKey;
# ifdef OF_AMIGAOS4
OFTLSKey OFSocketInterfaceKey;
OFTLSKey _OFSocketInterfaceKey;
# endif
# else
struct Library *SocketBase;
# ifdef OF_AMIGAOS4
struct SocketIFace *ISocket = NULL;
# endif
# endif
#endif
#if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS) && !defined(OF_MORPHOS)
OF_CONSTRUCTOR()
{
if (OFTLSKeyNew(&OFSocketBaseKey) != 0)
if (OFTLSKeyNew(&_OFSocketBaseKey) != 0)
@throw [OFInitializationFailedException exception];
# ifdef OF_AMIGAOS4
if (OFTLSKeyNew(&OFSocketInterfaceKey) != 0)
if (OFTLSKeyNew(&_OFSocketInterfaceKey) != 0)
@throw [OFInitializationFailedException exception];
# endif
}
#endif
#if !defined(OF_AMIGAOS) || defined(OF_MORPHOS) || !defined(OF_HAVE_THREADS)
static void
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
+
-
+
|
if (SocketBase != NULL)
CloseLibrary(SocketBase);
# endif
}
#endif
bool
OFSocketInit(void)
_OFSocketInit(void)
{
#if !defined(OF_AMIGAOS) || defined(OF_MORPHOS) || !defined(OF_HAVE_THREADS)
static OFOnceControl onceControl = OFOnceControlInitValue;
OFOnce(&onceControl, init);
return initSuccessful;
#else
struct Library *socketBase;
# ifdef OF_AMIGAOS4
struct SocketIFace *socketInterface;
# endif
# ifdef OF_AMIGAOS4
if ((socketInterface = OFTLSKeyGet(OFSocketInterfaceKey)) != NULL)
if ((socketInterface = OFTLSKeyGet(_OFSocketInterfaceKey)) != NULL)
# else
if ((socketBase = OFTLSKeyGet(OFSocketBaseKey)) != NULL)
if ((socketBase = OFTLSKeyGet(_OFSocketBaseKey)) != NULL)
# endif
return true;
if ((socketBase = OpenLibrary("bsdsocket.library", 4)) == NULL)
return false;
# ifdef OF_AMIGAOS4
if ((socketInterface = (struct SocketIFace *)
GetInterface(socketBase, "main", 1, NULL)) == NULL) {
CloseLibrary(socketBase);
return false;
}
# endif
if (OFTLSKeySet(OFSocketBaseKey, socketBase) != 0) {
if (OFTLSKeySet(_OFSocketBaseKey, socketBase) != 0) {
CloseLibrary(socketBase);
# ifdef OF_AMIGAOS4
DropInterface((struct Interface *)socketInterface);
# endif
return false;
}
# ifdef OF_AMIGAOS4
if (OFTLSKeySet(OFSocketInterfaceKey, socketInterface) != 0) {
if (OFTLSKeySet(_OFSocketInterfaceKey, socketInterface) != 0) {
CloseLibrary(socketBase);
DropInterface((struct Interface *)socketInterface);
return false;
}
# endif
return true;
#endif
}
#if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS) && !defined(OF_MORPHOS)
void
OFSocketDeinit(void)
_OFSocketDeinit(void)
{
struct Library *socketBase = OFTLSKeyGet(OFSocketBaseKey);
struct Library *socketBase = OFTLSKeyGet(_OFSocketBaseKey);
# ifdef OF_AMIGAOS4
struct SocketIFace *socketInterface = OFTLSKeyGet(OFSocketInterfaceKey);
struct SocketIFace *socketInterface =
OFTLSKeyGet(_OFSocketInterfaceKey);
if (socketInterface != NULL)
DropInterface((struct Interface *)socketInterface);
# endif
if (socketBase != NULL)
CloseLibrary(socketBase);
}
#endif
int
OFSocketErrNo(void)
_OFSocketErrNo(void)
{
#if defined(OF_WINDOWS)
switch (WSAGetLastError()) {
case WSAEACCES:
return EACCES;
case WSAEADDRINUSE:
return EADDRINUSE;
|
︙ | | |
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
|
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
|
-
+
|
#else
return errno;
#endif
}
#ifndef OF_WII
int
OFGetSockName(OFSocketHandle sock, struct sockaddr *restrict addr,
_OFGetSockName(OFSocketHandle sock, struct sockaddr *restrict addr,
socklen_t *restrict addrLen)
{
int ret;
# if defined(OF_HAVE_THREADS) && (!defined(OF_AMIGAOS) || defined(OF_MORPHOS))
[mutex lock];
# endif
|
︙ | | |
Modified src/OFStrFTime.h
from [6360971f27]
to [7b37c32abd].
︙ | | |
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
-
-
+
+
|
#import "macros.h"
OF_ASSUME_NONNULL_BEGIN
#ifdef __cplusplus
extern "C" {
#endif
extern size_t OFStrFTime(char *buffer, size_t bufferLen, const char *format,
struct tm *tm, short tz);
extern size_t _OFStrFTime(char *buffer, size_t bufferLen, const char *format,
struct tm *tm, short tz) OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
OF_ASSUME_NONNULL_END
|
Modified src/OFStrFTime.m
from [c155cb6b03]
to [91040bd990].
︙ | | |
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
44
|
-
+
|
};
static const char monthNames[12][4] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct",
"Nov", "Dec"
};
size_t
OFStrFTime(char *buffer, size_t bufferLen, const char *format, struct tm *tm,
_OFStrFTime(char *buffer, size_t bufferLen, const char *format, struct tm *tm,
short tz)
{
enum {
stateSearchConversionSpecifier,
stateInConversionSpecifier
} state = stateSearchConversionSpecifier;
size_t j, formatLen;
|
︙ | | |
Modified src/OFStrPTime.h
from [8d156c2ae2]
to [2f70689b01].
︙ | | |
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
+
-
+
|
#import "macros.h"
OF_ASSUME_NONNULL_BEGIN
#ifdef __cplusplus
extern "C" {
#endif
/* No OF_VISIBILITY_HIDDEN so tests can call it. */
extern const char *_Nullable OFStrPTime(const char *buffer, const char *format,
extern const char *_Nullable _OFStrPTime(const char *buffer, const char *format,
struct tm *tm, short *_Nullable tz);
#ifdef __cplusplus
}
#endif
OF_ASSUME_NONNULL_END
|
Modified src/OFStrPTime.m
from [7d3b878a87]
to [88f29fe94b].
︙ | | |
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 <string.h>
#import "OFStrPTime.h"
#import "macros.h"
const char *
OFStrPTime(const char *buffer, const char *format, struct tm *tm, short *tz)
_OFStrPTime(const char *buffer, const char *format, struct tm *tm, short *tz)
{
enum {
stateSearchConversionSpecifier,
stateInConversionSpecifier
} state = stateSearchConversionSpecifier;
size_t j, bufferLen, formatLen;
|
︙ | | |
Modified src/OFStream.m
from [4f4737a0de]
to [f7de880ff7].
︙ | | |
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
|
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
|
-
+
|
{
char *UTF8String;
int length;
if (format == nil)
@throw [OFInvalidArgumentException exception];
if ((length = OFVASPrintF(&UTF8String, format.UTF8String,
if ((length = _OFVASPrintF(&UTF8String, format.UTF8String,
arguments)) == -1)
@throw [OFInvalidFormatException exception];
@try {
[self writeBuffer: UTF8String length: length];
} @finally {
free(UTF8String);
|
︙ | | |
Modified src/OFStreamSocket.m
from [a8d59e0323]
to [83fbf8313f].
︙ | | |
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
-
+
|
@synthesize listening = _listening;
+ (void)initialize
{
if (self != [OFStreamSocket class])
return;
if (!OFSocketInit())
if (!_OFSocketInit())
@throw [OFInitializationFailedException
exceptionWithClass: self];
}
+ (instancetype)socket
{
return [[[self alloc] init] autorelease];
|
︙ | | |
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
-
+
-
+
|
@throw [OFNotOpenException exceptionWithObject: self];
#ifndef OF_WINDOWS
if ((ret = recv(_socket, buffer, length, 0)) < 0)
@throw [OFReadFailedException
exceptionWithObject: self
requestedLength: length
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
#else
if (length > INT_MAX)
@throw [OFOutOfRangeException exception];
if ((ret = recv(_socket, buffer, (int)length, 0)) < 0)
@throw [OFReadFailedException
exceptionWithObject: self
requestedLength: length
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
#endif
if (ret == 0)
_atEndOfStream = true;
return ret;
}
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
|
@throw [OFOutOfRangeException exception];
if ((bytesWritten = send(_socket, (void *)buffer, length, 0)) < 0)
@throw [OFWriteFailedException
exceptionWithObject: self
requestedLength: length
bytesWritten: 0
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
#else
int bytesWritten;
if (length > INT_MAX)
@throw [OFOutOfRangeException exception];
if ((bytesWritten = send(_socket, buffer, (int)length, 0)) < 0)
@throw [OFWriteFailedException
exceptionWithObject: self
requestedLength: length
bytesWritten: 0
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
#endif
return (size_t)bytesWritten;
}
#if defined(OF_WINDOWS) || defined(OF_AMIGAOS)
- (void)setCanBlock: (bool)canBlock
{
# ifdef OF_WINDOWS
u_long v = !canBlock;
# else
char v = !canBlock;
# endif
if (ioctlsocket(_socket, FIONBIO, &v) == SOCKET_ERROR)
@throw [OFSetOptionFailedException
exceptionWithObject: self
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
_canBlock = canBlock;
}
#endif
- (int)fileDescriptorForReading
{
|
︙ | | |
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
|
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
|
-
+
-
+
|
- (int)of_socketError
{
int errNo;
socklen_t len = sizeof(errNo);
if (getsockopt(_socket, SOL_SOCKET, SO_ERROR, (char *)&errNo,
&len) != 0)
return OFSocketErrNo();
return _OFSocketErrNo();
return errNo;
}
#endif
- (void)listen
{
[self listenWithBacklog: SOMAXCONN];
}
- (void)listenWithBacklog: (int)backlog
{
if (_socket == OFInvalidSocketHandle)
@throw [OFNotOpenException exceptionWithObject: self];
if (listen(_socket, backlog) == -1)
@throw [OFListenOnSocketFailedException
exceptionWithSocket: self
backlog: backlog
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
_listening = true;
}
- (instancetype)accept
{
OFStreamSocket *client;
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
|
#if defined(HAVE_PACCEPT) && defined(SOCK_CLOEXEC)
if ((client->_socket = paccept(_socket,
(struct sockaddr *)&client->_remoteAddress.sockaddr,
&client->_remoteAddress.length, NULL, SOCK_CLOEXEC)) ==
OFInvalidSocketHandle)
@throw [OFAcceptSocketFailedException
exceptionWithSocket: self
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
#elif defined(HAVE_ACCEPT4) && defined(SOCK_CLOEXEC)
if ((client->_socket = accept4(_socket,
(struct sockaddr * )&client->_remoteAddress.sockaddr,
&client->_remoteAddress.length, SOCK_CLOEXEC)) ==
OFInvalidSocketHandle)
@throw [OFAcceptSocketFailedException
exceptionWithSocket: self
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
#else
if ((client->_socket = accept(_socket,
(struct sockaddr *)&client->_remoteAddress.sockaddr,
&client->_remoteAddress.length)) == OFInvalidSocketHandle)
@throw [OFAcceptSocketFailedException
exceptionWithSocket: self
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
# if defined(HAVE_FCNTL) && defined(FD_CLOEXEC)
if ((flags = fcntl(client->_socket, F_GETFD, 0)) != -1)
fcntl(client->_socket, F_SETFD, flags | FD_CLOEXEC);
# endif
#endif
|
︙ | | |
Modified src/OFString+CryptographicHashing.h
from [3d01f675bb]
to [fa228a3cf2].
︙ | | |
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
-
+
|
#import "OFString.h"
OF_ASSUME_NONNULL_BEGIN
#ifdef __cplusplus
extern "C" {
#endif
extern int _OFString_CryptographicHashing_reference;
extern int _OFString_CryptographicHashing_reference OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
@interface OFString (CryptographicHashing)
/**
* @brief The MD5 hash of the string as a string.
|
︙ | | |
Modified src/OFString+JSONParsing.h
from [eb9d46998c]
to [db00c1631e].
︙ | | |
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
-
+
|
#import "OFString.h"
OF_ASSUME_NONNULL_BEGIN
#ifdef __cplusplus
extern "C" {
#endif
extern int _OFString_JSONParsing_reference;
extern int _OFString_JSONParsing_reference OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
@interface OFString (JSONParsing)
/**
* @brief The string interpreted as JSON and parsed as an object.
|
︙ | | |
Modified src/OFString+JSONParsing.m
from [b1d14c6372]
to [16ebad3f2c].
︙ | | |
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
-
+
|
if ((c1 & 0xFC00) == 0xDC00) {
OFFreeMemory(buffer);
return nil;
}
/* Normal character */
if ((c1 & 0xFC00) != 0xD800) {
l = OFUTF8StringEncode(c1, buffer + i);
l = _OFUTF8StringEncode(c1, buffer + i);
if (l == 0) {
OFFreeMemory(buffer);
return nil;
}
i += l;
*pointer += 5;
|
︙ | | |
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
|
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
|
-
+
|
OFFreeMemory(buffer);
return nil;
}
c = (((c1 & 0x3FF) << 10) |
(c2 & 0x3FF)) + 0x10000;
l = OFUTF8StringEncode(c, buffer + i);
l = _OFUTF8StringEncode(c, buffer + i);
if (l == 0) {
OFFreeMemory(buffer);
return nil;
}
i += l;
*pointer += 11;
|
︙ | | |
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
|
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
|
-
+
|
if ((c1 & 0xFC00) == 0xDC00) {
OFFreeMemory(buffer);
return nil;
}
/* Normal character */
if ((c1 & 0xFC00) != 0xD800) {
l = OFUTF8StringEncode(c1, buffer + i);
l = _OFUTF8StringEncode(c1, buffer + i);
if (l == 0) {
OFFreeMemory(buffer);
return nil;
}
i += l;
*pointer += 5;
|
︙ | | |
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
|
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
|
-
+
|
if (c2 == 0xFFFF) {
OFFreeMemory(buffer);
return nil;
}
c = (((c1 & 0x3FF) << 10) | (c2 & 0x3FF)) + 0x10000;
l = OFUTF8StringEncode(c, buffer + i);
l = _OFUTF8StringEncode(c, buffer + i);
if (l == 0) {
OFFreeMemory(buffer);
return nil;
}
i += l;
*pointer += 11;
|
︙ | | |
Modified src/OFString+PathAdditions.h
from [da8b9e10be]
to [a5a01edfc3].
︙ | | |
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
-
+
|
#import "OFString.h"
OF_ASSUME_NONNULL_BEGIN
#ifdef __cplusplus
extern "C" {
#endif
extern int _OFString_PathAdditions_reference;
extern int _OFString_PathAdditions_reference OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
@interface OFString (PathAdditions)
/**
* @brief Whether the path is an absolute path.
|
︙ | | |
Modified src/OFString+PercentEncoding.h
from [31b4cb4844]
to [10eac820fb].
︙ | | |
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
-
+
|
OF_ASSUME_NONNULL_BEGIN
@class OFCharacterSet;
#ifdef __cplusplus
extern "C" {
#endif
extern int _OFString_PercentEncoding_reference;
extern int _OFString_PercentEncoding_reference OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
@interface OFString (PercentEncoding)
/**
* @brief The string with percent encoding removed.
|
︙ | | |
Modified src/OFString+PercentEncoding.m
from [a22716408b]
to [e783c0987e].
︙ | | |
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
-
+
|
if (characterIsMember(allowedCharacters,
@selector(characterIsMember:), c))
[ret appendCharacters: &c length: 1];
else {
char buffer[4];
size_t bufferLen;
if ((bufferLen = OFUTF8StringEncode(c, buffer)) == 0)
if ((bufferLen = _OFUTF8StringEncode(c, buffer)) == 0)
@throw [OFInvalidEncodingException exception];
for (size_t j = 0; j < bufferLen; j++) {
unsigned char byte = buffer[j];
unsigned char high = byte >> 4;
unsigned char low = byte & 0x0F;
char escaped[3];
|
︙ | | |
Modified src/OFString+PropertyListParsing.h
from [6464166de9]
to [1f14e12c20].
︙ | | |
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
-
+
|
#import "OFString.h"
OF_ASSUME_NONNULL_BEGIN
#ifdef __cplusplus
extern "C" {
#endif
extern int _OFString_PropertyListParsing_reference;
extern int _OFString_PropertyListParsing_reference OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
@interface OFString (PropertyListParsing)
/**
* @brief The string interpreted as a property list and parsed as an object.
|
︙ | | |
Modified src/OFString+XMLEscaping.h
from [e61bc93090]
to [b627ccd424].
︙ | | |
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
-
+
|
#import "OFString.h"
OF_ASSUME_NONNULL_BEGIN
#ifdef __cplusplus
extern "C" {
#endif
extern int _OFString_XMLEscaping_reference;
extern int _OFString_XMLEscaping_reference OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
@interface OFString (XMLEscaping)
/**
* @brief The string in a form escaped for use in an XML document.
|
︙ | | |
Modified src/OFString+XMLUnescaping.h
from [5e3aafdb56]
to [a3d8075ac3].
︙ | | |
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
-
+
|
OF_ASSUME_NONNULL_BEGIN
/** @file */
#ifdef __cplusplus
extern "C" {
#endif
extern int _OFString_XMLUnescaping_reference;
extern int _OFString_XMLUnescaping_reference OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
#ifdef OF_HAVE_BLOCKS
/**
* @brief A block which is called to replace unknown XML entities in an XML
|
︙ | | |
Modified src/OFString+XMLUnescaping.m
from [0faab389ff]
to [faf5398fe6].
︙ | | |
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
-
+
|
if (entity[i] >= '0' && entity[i] <= '9')
c = (c * 10) + (entity[i] - '0');
else
return nil;
}
}
if ((i = OFUTF8StringEncode(c, buffer)) == 0)
if ((i = _OFUTF8StringEncode(c, buffer)) == 0)
return nil;
buffer[i] = 0;
return [OFString stringWithUTF8String: buffer length: i];
}
static OFString *
|
︙ | | |
Modified src/OFString.h
from [4b582c4c17]
to [5ec6a2e4f7].
︙ | | |
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
|
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
|
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
* @brief Returns the name of the specified OFStringEncoding.
*
* @param encoding The encoding for which to return the name
* @return The name of the specified OFStringEncoding
*/
extern OFString *_Nullable OFStringEncodingName(OFStringEncoding encoding);
extern char *_Nullable OFStrDup(const char *_Nonnull);
extern size_t OFUTF8StringEncode(OFUnichar, char *);
extern ssize_t OFUTF8StringDecode(const char *, size_t, OFUnichar *);
extern size_t OFUTF16StringLength(const OFChar16 *);
extern size_t OFUTF32StringLength(const OFChar32 *);
/**
* @brief Returns the length of the specified UTF-16 string.
*
* @param string The UTF-16 string
* @return The length of the specified UTF-16 string
*/
extern size_t OFUTF16StringLength(const OFChar16 *string);
/**
* @brief Returns the length of the specified UTF-32 string.
*
* @param string The UTF-32 string
* @return The length of the specified UTF-32 string
*/
extern size_t OFUTF32StringLength(const OFChar32 *string);
extern char *_Nullable _OFStrDup(const char *_Nonnull) OF_VISIBILITY_HIDDEN;
extern size_t _OFUTF8StringEncode(OFUnichar, char *) OF_VISIBILITY_HIDDEN;
extern ssize_t _OFUTF8StringDecode(const char *, size_t, OFUnichar *)
OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
OF_ASSUME_NONNULL_END
#import "OFConstantString.h"
|
︙ | | |
Modified src/OFString.m
from [a5a923c44c]
to [7205f31b8d].
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
of_JSONRepresentationWithOptions: (OFJSONRepresentationOptions)options
depth: (size_t)depth;
@end
@interface OFPlaceholderString: OFString
@end
extern bool OFUnicodeToISO8859_2(const OFUnichar *, unsigned char *,
extern bool _OFUnicodeToISO8859_2(const OFUnichar *, unsigned char *,
size_t, bool);
extern bool OFUnicodeToISO8859_3(const OFUnichar *, unsigned char *,
extern bool _OFUnicodeToISO8859_3(const OFUnichar *, unsigned char *,
size_t, bool);
extern bool OFUnicodeToISO8859_15(const OFUnichar *, unsigned char *,
extern bool _OFUnicodeToISO8859_15(const OFUnichar *, unsigned char *,
size_t, bool);
extern bool OFUnicodeToWindows1251(const OFUnichar *, unsigned char *,
extern bool _OFUnicodeToWindows1251(const OFUnichar *, unsigned char *,
size_t, bool);
extern bool OFUnicodeToWindows1252(const OFUnichar *, unsigned char *,
extern bool _OFUnicodeToWindows1252(const OFUnichar *, unsigned char *,
size_t, bool);
extern bool OFUnicodeToCodepage437(const OFUnichar *, unsigned char *,
extern bool _OFUnicodeToCodepage437(const OFUnichar *, unsigned char *,
size_t, bool);
extern bool OFUnicodeToCodepage850(const OFUnichar *, unsigned char *,
extern bool _OFUnicodeToCodepage850(const OFUnichar *, unsigned char *,
size_t, bool);
extern bool OFUnicodeToCodepage858(const OFUnichar *, unsigned char *,
extern bool _OFUnicodeToCodepage858(const OFUnichar *, unsigned char *,
size_t, bool);
extern bool OFUnicodeToMacRoman(const OFUnichar *, unsigned char *,
extern bool _OFUnicodeToMacRoman(const OFUnichar *, unsigned char *,
size_t, bool);
extern bool OFUnicodeToKOI8R(const OFUnichar *, unsigned char *,
extern bool _OFUnicodeToKOI8R(const OFUnichar *, unsigned char *,
size_t, bool);
extern bool OFUnicodeToKOI8U(const OFUnichar *, unsigned char *,
extern bool _OFUnicodeToKOI8U(const OFUnichar *, unsigned char *,
size_t, bool);
/* References for static linking */
void
void OF_VISIBILITY_HIDDEN
_references_to_categories_of_OFString(void)
{
_OFString_CryptographicHashing_reference = 1;
_OFString_JSONParsing_reference = 1;
#ifdef OF_HAVE_FILES
_OFString_PathAdditions_reference = 1;
#endif
_OFString_PercentEncoding_reference = 1;
_OFString_PropertyListParsing_reference = 1;
_OFString_XMLEscaping_reference = 1;
_OFString_XMLUnescaping_reference = 1;
}
void
void OF_VISIBILITY_HIDDEN
_reference_to_OFConstantString(void)
{
[OFConstantString class];
}
OFStringEncoding
OFStringEncodingParseName(OFString *string)
|
︙ | | |
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
|
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
|
-
+
|
return @"autodetect";
}
return nil;
}
size_t
OFUTF8StringEncode(OFUnichar character, char *buffer)
_OFUTF8StringEncode(OFUnichar character, char *buffer)
{
if (character < 0x80) {
buffer[0] = character;
return 1;
} else if (character < 0x800) {
buffer[0] = 0xC0 | (character >> 6);
buffer[1] = 0x80 | (character & 0x3F);
|
︙ | | |
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
|
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
|
-
+
|
return 4;
}
return 0;
}
ssize_t
OFUTF8StringDecode(const char *buffer_, size_t length, OFUnichar *ret)
_OFUTF8StringDecode(const char *buffer_, size_t length, OFUnichar *ret)
{
const unsigned char *buffer = (const unsigned char *)buffer_;
if (!(*buffer & 0x80)) {
*ret = buffer[0];
return 1;
}
|
︙ | | |
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
|
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
|
-
+
|
while (*string++ != 0)
length++;
return length;
}
char *
OFStrDup(const char *string)
_OFStrDup(const char *string)
{
size_t length = strlen(string);
char *copy = (char *)OFAllocMemory(1, length + 1);
memcpy(copy, string, length + 1);
return copy;
}
|
︙ | | |
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
|
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
|
-
+
|
switch (encoding) {
case OFStringEncodingUTF8:;
size_t j = 0;
for (i = 0; i < length; i++) {
char buffer[4];
size_t len = OFUTF8StringEncode(characters[i], buffer);
size_t len = _OFUTF8StringEncode(characters[i], buffer);
/*
* Check for one more than the current index, as we
* need one for the terminating zero.
*/
if (j + len >= maxLength)
@throw [OFOutOfRangeException exception];
|
︙ | | |
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
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
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
|
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
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
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
|
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
return length;
#ifdef HAVE_ISO_8859_2
case OFStringEncodingISO8859_2:
if (length + 1 > maxLength)
@throw [OFOutOfRangeException exception];
if (!OFUnicodeToISO8859_2(characters, (unsigned char *)cString,
if (!_OFUnicodeToISO8859_2(characters, (unsigned char *)cString,
length, lossy))
@throw [OFInvalidEncodingException exception];
cString[length] = '\0';
return length;
#endif
#ifdef HAVE_ISO_8859_3
case OFStringEncodingISO8859_3:
if (length + 1 > maxLength)
@throw [OFOutOfRangeException exception];
if (!OFUnicodeToISO8859_3(characters, (unsigned char *)cString,
if (!_OFUnicodeToISO8859_3(characters, (unsigned char *)cString,
length, lossy))
@throw [OFInvalidEncodingException exception];
cString[length] = '\0';
return length;
#endif
#ifdef HAVE_ISO_8859_15
case OFStringEncodingISO8859_15:
if (length + 1 > maxLength)
@throw [OFOutOfRangeException exception];
if (!OFUnicodeToISO8859_15(characters, (unsigned char *)cString,
length, lossy))
if (!_OFUnicodeToISO8859_15(characters,
(unsigned char *)cString, length, lossy))
@throw [OFInvalidEncodingException exception];
cString[length] = '\0';
return length;
#endif
#ifdef HAVE_WINDOWS_1251
case OFStringEncodingWindows1251:
if (length + 1 > maxLength)
@throw [OFOutOfRangeException exception];
if (!OFUnicodeToWindows1251(characters,
if (!_OFUnicodeToWindows1251(characters,
(unsigned char *)cString, length, lossy))
@throw [OFInvalidEncodingException exception];
cString[length] = '\0';
return length;
#endif
#ifdef HAVE_WINDOWS_1252
case OFStringEncodingWindows1252:
if (length + 1 > maxLength)
@throw [OFOutOfRangeException exception];
if (!OFUnicodeToWindows1252(characters,
if (!_OFUnicodeToWindows1252(characters,
(unsigned char *)cString, length, lossy))
@throw [OFInvalidEncodingException exception];
cString[length] = '\0';
return length;
#endif
#ifdef HAVE_CODEPAGE_437
case OFStringEncodingCodepage437:
if (length + 1 > maxLength)
@throw [OFOutOfRangeException exception];
if (!OFUnicodeToCodepage437(characters,
if (!_OFUnicodeToCodepage437(characters,
(unsigned char *)cString, length, lossy))
@throw [OFInvalidEncodingException exception];
cString[length] = '\0';
return length;
#endif
#ifdef HAVE_CODEPAGE_850
case OFStringEncodingCodepage850:
if (length + 1 > maxLength)
@throw [OFOutOfRangeException exception];
if (!OFUnicodeToCodepage850(characters,
if (!_OFUnicodeToCodepage850(characters,
(unsigned char *)cString, length, lossy))
@throw [OFInvalidEncodingException exception];
cString[length] = '\0';
return length;
#endif
#ifdef HAVE_CODEPAGE_858
case OFStringEncodingCodepage858:
if (length + 1 > maxLength)
@throw [OFOutOfRangeException exception];
if (!OFUnicodeToCodepage858(characters,
if (!_OFUnicodeToCodepage858(characters,
(unsigned char *)cString, length, lossy))
@throw [OFInvalidEncodingException exception];
cString[length] = '\0';
return length;
#endif
#ifdef HAVE_MAC_ROMAN
case OFStringEncodingMacRoman:
if (length + 1 > maxLength)
@throw [OFOutOfRangeException exception];
if (!OFUnicodeToMacRoman(characters, (unsigned char *)cString,
if (!_OFUnicodeToMacRoman(characters, (unsigned char *)cString,
length, lossy))
@throw [OFInvalidEncodingException exception];
cString[length] = '\0';
return length;
#endif
#ifdef HAVE_KOI8_R
case OFStringEncodingKOI8R:
if (length + 1 > maxLength)
@throw [OFOutOfRangeException exception];
if (!OFUnicodeToKOI8R(characters, (unsigned char *)cString,
if (!_OFUnicodeToKOI8R(characters, (unsigned char *)cString,
length, lossy))
@throw [OFInvalidEncodingException exception];
cString[length] = '\0';
return length;
#endif
#ifdef HAVE_KOI8_U
case OFStringEncodingKOI8U:
if (length + 1 > maxLength)
@throw [OFOutOfRangeException exception];
if (!OFUnicodeToKOI8U(characters, (unsigned char *)cString,
if (!_OFUnicodeToKOI8U(characters, (unsigned char *)cString,
length, lossy))
@throw [OFInvalidEncodingException exception];
cString[length] = '\0';
return length;
#endif
|
︙ | | |
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
|
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
|
-
+
|
size_t length, UTF8StringLength = 0;
characters = self.characters;
length = self.length;
for (size_t i = 0; i < length; i++) {
char buffer[4];
size_t len = OFUTF8StringEncode(characters[i], buffer);
size_t len = _OFUTF8StringEncode(characters[i], buffer);
if (len == 0)
@throw [OFInvalidEncodingException exception];
UTF8StringLength += len;
}
|
︙ | | |
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
|
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
|
-
+
-
+
-
+
-
+
|
minimumLength = (length > otherLength ? otherLength : length);
for (size_t i = 0; i < minimumLength; i++) {
OFUnichar c = characters[i];
OFUnichar oc = otherCharacters[i];
#ifdef OF_HAVE_UNICODE_TABLES
if (c >> 8 < OFUnicodeCaseFoldingTableSize) {
if (c >> 8 < _OFUnicodeCaseFoldingTableSize) {
OFUnichar tc =
OFUnicodeCaseFoldingTable[c >> 8][c & 0xFF];
_OFUnicodeCaseFoldingTable[c >> 8][c & 0xFF];
if (tc)
c = tc;
}
if (oc >> 8 < OFUnicodeCaseFoldingTableSize) {
if (oc >> 8 < _OFUnicodeCaseFoldingTableSize) {
OFUnichar tc =
OFUnicodeCaseFoldingTable[oc >> 8][oc & 0xFF];
_OFUnicodeCaseFoldingTable[oc >> 8][oc & 0xFF];
if (tc)
oc = tc;
}
#else
c = OFASCIIToUpper(c);
oc = OFASCIIToUpper(oc);
|
︙ | | |
Modified src/OFTCPSocket.m
from [80e19ef290]
to [21bc19a6d7].
︙ | | |
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
|
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
|
-
+
-
+
|
if (_socket != OFInvalidSocketHandle)
@throw [OFAlreadyOpenException exceptionWithObject: self];
if ((_socket = socket(
((struct sockaddr *)&address->sockaddr)->sa_family,
SOCK_STREAM | SOCK_CLOEXEC, 0)) == OFInvalidSocketHandle) {
*errNo = OFSocketErrNo();
*errNo = _OFSocketErrNo();
return false;
}
#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC)
if ((flags = fcntl(_socket, F_GETFD, 0)) != -1)
fcntl(_socket, F_SETFD, flags | FD_CLOEXEC);
#endif
return true;
}
- (bool)of_connectSocketToAddress: (const OFSocketAddress *)address
errNo: (int *)errNo
{
if (_socket == OFInvalidSocketHandle)
@throw [OFNotOpenException exceptionWithObject: self];
/* Cast needed for AmigaOS, where the argument is declared non-const */
if (connect(_socket, (struct sockaddr *)&address->sockaddr,
address->length) != 0) {
*errNo = OFSocketErrNo();
*errNo = _OFSocketErrNo();
return false;
}
return true;
}
- (void)of_closeSocket
|
︙ | | |
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
|
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
|
-
+
-
+
|
if ((_socket = socket(
((struct sockaddr *)&address.sockaddr)->sa_family,
SOCK_STREAM | SOCK_CLOEXEC, 0)) == OFInvalidSocketHandle)
@throw [OFBindIPSocketFailedException
exceptionWithHost: host
port: port
socket: self
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
_canBlock = true;
#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC)
if ((flags = fcntl(_socket, F_GETFD, 0)) != -1)
fcntl(_socket, F_SETFD, flags | FD_CLOEXEC);
#endif
setsockopt(_socket, SOL_SOCKET, SO_REUSEADDR,
(char *)&one, (socklen_t)sizeof(one));
#if defined(OF_HPUX) || defined(OF_WII) || defined(OF_NINTENDO_3DS)
if (port != 0) {
#endif
if (bind(_socket, (struct sockaddr *)&address.sockaddr,
address.length) != 0) {
int errNo = OFSocketErrNo();
int errNo = _OFSocketErrNo();
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindIPSocketFailedException
exceptionWithHost: host
port: port
|
︙ | | |
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
|
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
|
-
-
+
+
-
+
-
+
|
OFSocketAddressSetIPPort(&address, rnd);
if ((ret = bind(_socket,
(struct sockaddr *)&address.sockaddr,
address.length)) == 0)
break;
if (OFSocketErrNo() != EADDRINUSE) {
int errNo = OFSocketErrNo();
if (_OFSocketErrNo() != EADDRINUSE) {
int errNo = _OFSocketErrNo();
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindIPSocketFailedException
exceptionWithHost: host
port: port
socket: self
errNo: errNo];
}
}
}
#endif
#if !defined(OF_HPUX) && !defined(OF_WII) && !defined(OF_NINTENDO_3DS)
memset(&address, 0, sizeof(address));
address.length = (socklen_t)sizeof(address.sockaddr);
if (OFGetSockName(_socket, (struct sockaddr *)&address.sockaddr,
if (_OFGetSockName(_socket, (struct sockaddr *)&address.sockaddr,
&address.length) != 0) {
int errNo = OFSocketErrNo();
int errNo = _OFSocketErrNo();
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindIPSocketFailedException exceptionWithHost: host
port: port
socket: self
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
|
{
int v = sendsKeepAlives;
if (setsockopt(_socket, SOL_SOCKET, SO_KEEPALIVE,
(char *)&v, (socklen_t)sizeof(v)) != 0)
@throw [OFSetOptionFailedException
exceptionWithObject: self
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
}
- (bool)sendsKeepAlives
{
int v;
socklen_t len = sizeof(v);
if (getsockopt(_socket, SOL_SOCKET, SO_KEEPALIVE,
(char *)&v, &len) != 0 || len != sizeof(v))
@throw [OFGetOptionFailedException
exceptionWithObject: self
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
return v;
}
#endif
#ifndef OF_WII
- (void)setCanDelaySendingSegments: (bool)canDelaySendingSegments
{
int v = !canDelaySendingSegments;
if (setsockopt(_socket, IPPROTO_TCP, TCP_NODELAY,
(char *)&v, (socklen_t)sizeof(v)) != 0)
@throw [OFSetOptionFailedException
exceptionWithObject: self
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
}
- (bool)canDelaySendingSegments
{
int v;
socklen_t len = sizeof(v);
if (getsockopt(_socket, IPPROTO_TCP, TCP_NODELAY,
(char *)&v, &len) != 0 || len != sizeof(v))
@throw [OFGetOptionFailedException
exceptionWithObject: self
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
return !v;
}
#endif
- (void)close
{
|
︙ | | |
Modified src/OFTLSKey.h
from [0f3980a25d]
to [4742ef8bb4].
︙ | | |
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
|
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
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
#if !defined(OF_HAVE_THREADS) || \
(!defined(OF_HAVE_PTHREADS) && !defined(OF_WINDOWS) && !defined(OF_AMIGAOS))
# error No thread-local storage available!
#endif
#import "macros.h"
/** @file */
#if defined(OF_HAVE_PTHREADS)
# include <pthread.h>
typedef pthread_key_t OFTLSKey;
#elif defined(OF_WINDOWS)
# include <windows.h>
typedef DWORD OFTLSKey;
#elif defined(OF_MORPHOS)
# include <proto/exec.h>
typedef ULONG OFTLSKey;
#elif defined(OF_AMIGAOS)
typedef struct _OFTLSKey {
struct objc_hashtable *table;
struct _OFTLSKey *next, *previous;
} *OFTLSKey;
#endif
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Creates a new Thread Local Storage key.
*
* @param key A pointer to the key to create
* @return 0 on success, or an error number from `<errno.h>` on error
*/
extern int OFTLSKeyNew(OFTLSKey *key);
/**
* @brief Destroys the specified Thread Local Storage key.
*
* @param key A pointer to the key to destroy
* @return 0 on success, or an error number from `<errno.h>` on error
*/
extern int OFTLSKeyFree(OFTLSKey key);
#ifdef __cplusplus
}
#endif
/* TLS keys are inlined for performance. */
#if defined(OF_HAVE_PTHREADS)
#if defined(OF_HAVE_PTHREADS) || defined(DOXYGEN)
/**
* @brief Returns the current value for the specified Thread Local Storage key.
*
* @param key A pointer to the key whose value to return
* @return The current value for the specified Thread Local Storage key
*/
static OF_INLINE void *
OFTLSKeyGet(OFTLSKey key)
{
return pthread_getspecific(key);
}
/**
* @brief Sets the current value for the specified Thread Local Storage key.
*
* @param key A pointer to the key whose value to set
* @param value The new value for the key
*/
static OF_INLINE int
OFTLSKeySet(OFTLSKey key, void *ptr)
OFTLSKeySet(OFTLSKey key, void *value)
{
return pthread_setspecific(key, ptr);
return pthread_setspecific(key, value);
}
#elif defined(OF_WINDOWS)
static OF_INLINE void *
OFTLSKeyGet(OFTLSKey key)
{
return TlsGetValue(key);
}
static OF_INLINE int
OFTLSKeySet(OFTLSKey key, void *ptr)
OFTLSKeySet(OFTLSKey key, void *value)
{
return (TlsSetValue(key, ptr) ? 0 : EINVAL);
return (TlsSetValue(key, value) ? 0 : EINVAL);
}
#elif defined(OF_MORPHOS)
static OF_INLINE void *
OFTLSKeyGet(OFTLSKey key)
{
return (void *)TLSGetValue(key);
}
static OF_INLINE int
OFTLSKeySet(OFTLSKey key, void *ptr)
OFTLSKeySet(OFTLSKey key, void *value)
{
return (TLSSetValue(key, (APTR)ptr) ? 0 : EINVAL);
return (TLSSetValue(key, (APTR)value) ? 0 : EINVAL);
}
#elif defined(OF_AMIGAOS)
/* Those are too big too inline. */
# ifdef __cplusplus
extern "C" {
# endif
extern void *OFTLSKeyGet(OFTLSKey key);
extern int OFTLSKeySet(OFTLSKey key, void *ptr);
extern int OFTLSKeySet(OFTLSKey key, void *value);
# ifdef __cplusplus
}
# endif
#endif
|
Modified src/OFTLSStream.m
from [cdc1005db6]
to [9bf5b732e6].
︙ | | |
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
-
+
|
static const OFRunLoopMode handshakeRunLoopMode =
@"OFTLSStreamHandshakeRunLoopMode";
/*
* References to exceptions. This is needed because they are only used by
* subclasses that are in a different library.
*/
void
void OF_VISIBILITY_HIDDEN
_references_to_exceptions_of_OFTLSStream(void)
{
_OFTLSHandshakeFailedException_reference = 1;
}
OFString *
OFTLSStreamErrorCodeDescription(OFTLSStreamErrorCode errorCode)
|
︙ | | |
Modified src/OFTaggedPointerDate.m
from [3a7c65c57a]
to [d646100367].
︙ | | |
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
-
+
|
- (OFTimeInterval)timeIntervalSince1970
{
uint64_t value = (uint64_t)object_getTaggedPointerValue(self);
value |= UINT64_C(4) << 60;
return OFFromBigEndianDouble(OFRawUInt64ToDouble(OFToBigEndian64(
return OFFromBigEndianDouble(OFBitConvertUInt64ToDouble(OFToBigEndian64(
value)));
}
OF_SINGLETON_METHODS
@end
#endif
|
Modified src/OFTarArchive.m
from [67f03e487e]
to [300800373d].
︙ | | |
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
-
+
|
+ (instancetype)archiveWithIRI: (OFIRI *)IRI mode: (OFString *)mode
{
return [[[self alloc] initWithIRI: IRI mode: mode] autorelease];
}
+ (OFIRI *)IRIForFilePath: (OFString *)path inArchiveWithIRI: (OFIRI *)IRI
{
return OFArchiveIRIHandlerIRIForFileInArchive(@"tar", path, IRI);
return _OFArchiveIRIHandlerIRIForFileInArchive(@"tar", path, IRI);
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
|
︙ | | |
Modified src/OFThread.m
from [c590c3dc16]
to [f0b78222ad].
︙ | | |
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
-
+
|
OFSetThreadName(
[name cStringWithEncoding: [OFLocale encoding]]);
else
OFSetThreadName(object_getClassName(thread));
#if defined(OF_AMIGAOS) && defined(OF_HAVE_SOCKETS)
if (thread.supportsSockets)
if (!OFSocketInit())
if (!_OFSocketInit())
@throw [OFInitializationFailedException
exceptionWithClass: thread.class];
#endif
/*
* Nasty workaround for thread implementations which can't return a
* pointer on join, or don't have a way to exit a thread.
|
︙ | | |
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
-
+
|
objc_autoreleasePoolPop((void *)(uintptr_t)-1);
#else
objc_autoreleasePoolPop(thread->_pool);
#endif
#if defined(OF_AMIGAOS) && !defined(OF_MORPHOS) && defined(OF_HAVE_SOCKETS)
if (thread.supportsSockets)
OFSocketDeinit();
_OFSocketDeinit();
#endif
thread->_running = OFThreadStateWaitingForJoin;
[thread release];
}
|
︙ | | |
Modified src/OFUDPSocket.m
from [d9b5e328f7]
to [b9116525f2].
︙ | | |
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
|
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
|
-
+
-
+
|
if ((_socket = socket(
((struct sockaddr *)&address->sockaddr)->sa_family,
SOCK_DGRAM | SOCK_CLOEXEC | extraType, 0)) == OFInvalidSocketHandle)
@throw [OFBindIPSocketFailedException
exceptionWithHost: OFSocketAddressString(address)
port: OFSocketAddressIPPort(address)
socket: self
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
_canBlock = true;
#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC)
/* {} needed to avoid warning with Clang 10 if next #if is false. */
if ((flags = fcntl(_socket, F_GETFD, 0)) != -1) {
fcntl(_socket, F_SETFD, flags | FD_CLOEXEC);
}
#endif
#if defined(OF_HPUX) || defined(OF_WII) || defined(OF_NINTENDO_3DS)
if (OFSocketAddressIPPort(address) != 0) {
#endif
if (bind(_socket, (struct sockaddr *)&address->sockaddr,
address->length) != 0) {
int errNo = OFSocketErrNo();
int errNo = _OFSocketErrNo();
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindIPSocketFailedException
exceptionWithHost: OFSocketAddressString(address)
port: OFSocketAddressIPPort(address)
|
︙ | | |
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
-
-
+
+
|
OFSocketAddressSetIPPort(address, rnd);
if ((ret = bind(_socket,
(struct sockaddr *)&address->sockaddr,
address->length)) == 0)
break;
if (OFSocketErrNo() != EADDRINUSE) {
int errNo = OFSocketErrNo();
if (_OFSocketErrNo() != EADDRINUSE) {
int errNo = _OFSocketErrNo();
OFString *host = OFSocketAddressString(address);
uint16_t port = OFSocketAddressIPPort(address);
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindIPSocketFailedException
|
︙ | | |
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
-
+
-
+
|
#if !defined(OF_HPUX) && !defined(OF_WII) && !defined(OF_NINTENDO_3DS)
host = OFSocketAddressString(address);
port = OFSocketAddressIPPort(address);
memset(address, 0, sizeof(*address));
address->length = (socklen_t)sizeof(address->sockaddr);
if (OFGetSockName(_socket, (struct sockaddr *)&address->sockaddr,
if (_OFGetSockName(_socket, (struct sockaddr *)&address->sockaddr,
&address->length) != 0) {
int errNo = OFSocketErrNo();
int errNo = _OFSocketErrNo();
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindIPSocketFailedException exceptionWithHost: host
port: port
socket: self
|
︙ | | |
Modified src/OFUNIXDatagramSocket.m
from [2627547b65]
to [86033fc2cb].
︙ | | |
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
|
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
|
-
+
-
+
|
}
if ((_socket = socket(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC, 0)) ==
OFInvalidSocketHandle)
@throw [OFBindUNIXSocketFailedException
exceptionWithPath: path
socket: self
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
_canBlock = true;
#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC)
if ((flags = fcntl(_socket, F_GETFD, 0)) != -1)
fcntl(_socket, F_SETFD, flags | FD_CLOEXEC);
#endif
if (path != nil) {
if (bind(_socket, (struct sockaddr *)&address.sockaddr,
address.length) != 0) {
int errNo = OFSocketErrNo();
int errNo = _OFSocketErrNo();
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindUNIXSocketFailedException
exceptionWithPath: path
socket: self
|
︙ | | |
Modified src/OFUNIXStreamSocket.m
from [3bba9beb8b]
to [fdc5ad3c80].
︙ | | |
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
|
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
|
-
+
-
+
|
address = OFSocketAddressMakeUNIX(path);
if ((_socket = socket(address.sockaddr.un.sun_family,
SOCK_STREAM | SOCK_CLOEXEC, 0)) == OFInvalidSocketHandle)
@throw [OFConnectUNIXSocketFailedException
exceptionWithPath: path
socket: self
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
_canBlock = true;
#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC)
if ((flags = fcntl(_socket, F_GETFD, 0)) != -1)
fcntl(_socket, F_SETFD, flags | FD_CLOEXEC);
#endif
if (connect(_socket, (struct sockaddr *)&address.sockaddr,
address.length) != 0) {
int errNo = OFSocketErrNo();
int errNo = _OFSocketErrNo();
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFConnectUNIXSocketFailedException
exceptionWithPath: path
socket: self
|
︙ | | |
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
|
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
|
-
+
-
+
|
address = OFSocketAddressMakeUNIX(path);
if ((_socket = socket(address.sockaddr.un.sun_family,
SOCK_STREAM | SOCK_CLOEXEC, 0)) == OFInvalidSocketHandle)
@throw [OFBindUNIXSocketFailedException
exceptionWithPath: path
socket: self
errNo: OFSocketErrNo()];
errNo: _OFSocketErrNo()];
_canBlock = true;
#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC)
if ((flags = fcntl(_socket, F_GETFD, 0)) != -1)
fcntl(_socket, F_SETFD, flags | FD_CLOEXEC);
#endif
if (bind(_socket, (struct sockaddr *)&address.sockaddr,
address.length) != 0) {
int errNo = OFSocketErrNo();
int errNo = _OFSocketErrNo();
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindUNIXSocketFailedException
exceptionWithPath: path
socket: self
errNo: errNo];
}
}
@end
|
Modified src/OFUTF8String.h
from [cef941820b]
to [f1efc16deb].
︙ | | |
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
-
-
+
+
+
+
|
struct OFUTF8StringIvars _storage;
}
@end
#ifdef __cplusplus
extern "C" {
#endif
extern int OFUTF8StringCheck(const char *, size_t, size_t *);
extern size_t OFUTF8StringIndexToPosition(const char *, size_t, size_t);
extern int _OFUTF8StringCheck(const char *, size_t, size_t *)
OF_VISIBILITY_HIDDEN;
extern size_t _OFUTF8StringIndexToPosition(const char *, size_t, size_t)
OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
OF_ASSUME_NONNULL_END
|
Modified src/OFUTF8String.m
from [720c0708e2]
to [97ab3896de].
︙ | | |
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
|
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
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
#import "OFInvalidEncodingException.h"
#import "OFInvalidFormatException.h"
#import "OFOutOfMemoryException.h"
#import "OFOutOfRangeException.h"
#import "unicode.h"
extern const OFChar16 OFISO8859_2Table[];
extern const size_t OFISO8859_2TableOffset;
extern const OFChar16 OFISO8859_3Table[];
extern const size_t OFISO8859_3TableOffset;
extern const OFChar16 OFISO8859_15Table[];
extern const size_t OFISO8859_15TableOffset;
extern const OFChar16 OFWindows1251Table[];
extern const size_t OFWindows1251TableOffset;
extern const OFChar16 OFWindows1252Table[];
extern const size_t OFWindows1252TableOffset;
extern const OFChar16 OFCodepage437Table[];
extern const size_t OFCodepage437TableOffset;
extern const OFChar16 OFCodepage850Table[];
extern const size_t OFCodepage850TableOffset;
extern const OFChar16 OFCodepage858Table[];
extern const size_t OFCodepage858TableOffset;
extern const OFChar16 OFMacRomanTable[];
extern const size_t OFMacRomanTableOffset;
extern const OFChar16 OFKOI8RTable[];
extern const size_t OFKOI8RTableOffset;
extern const OFChar16 OFKOI8UTable[];
extern const size_t OFKOI8UTableOffset;
extern const OFChar16 _OFISO8859_2Table[];
extern const size_t _OFISO8859_2TableOffset;
extern const OFChar16 _OFISO8859_3Table[];
extern const size_t _OFISO8859_3TableOffset;
extern const OFChar16 _OFISO8859_15Table[];
extern const size_t _OFISO8859_15TableOffset;
extern const OFChar16 _OFWindows1251Table[];
extern const size_t _OFWindows1251TableOffset;
extern const OFChar16 _OFWindows1252Table[];
extern const size_t _OFWindows1252TableOffset;
extern const OFChar16 _OFCodepage437Table[];
extern const size_t _OFCodepage437TableOffset;
extern const OFChar16 _OFCodepage850Table[];
extern const size_t _OFCodepage850TableOffset;
extern const OFChar16 _OFCodepage858Table[];
extern const size_t _OFCodepage858TableOffset;
extern const OFChar16 _OFMacRomanTable[];
extern const size_t _OFMacRomanTableOffset;
extern const OFChar16 _OFKOI8RTable[];
extern const size_t _OFKOI8RTableOffset;
extern const OFChar16 _OFKOI8UTable[];
extern const size_t _OFKOI8UTableOffset;
static inline int
memcasecmp(const char *first, const char *second, size_t length)
{
for (size_t i = 0; i < length; i++) {
unsigned char f = first[i];
unsigned char s = second[i];
|
︙ | | |
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
-
+
|
return OFOrderedAscending;
}
return OFOrderedSame;
}
int
OFUTF8StringCheck(const char *UTF8String, size_t UTF8Length, size_t *length)
_OFUTF8StringCheck(const char *UTF8String, size_t UTF8Length, size_t *length)
{
size_t tmpLength = UTF8Length;
int isUTF8 = 0;
for (size_t i = 0; i < UTF8Length; i++) {
/* No sign of UTF-8 here */
if OF_LIKELY (!(UTF8String[i] & 0x80))
|
︙ | | |
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
|
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
|
-
+
-
+
|
if (length != NULL)
*length = tmpLength;
return isUTF8;
}
size_t
static size_t
positionToIndex(const char *string, size_t position)
{
size_t idx = position;
for (size_t i = 0; i < position; i++)
if OF_UNLIKELY ((string[i] & 0xC0) == 0x80)
idx--;
return idx;
}
size_t
OFUTF8StringIndexToPosition(const char *string, size_t idx, size_t length)
_OFUTF8StringIndexToPosition(const char *string, size_t idx, size_t length)
{
for (size_t i = 0; i <= idx; i++)
if OF_UNLIKELY ((string[i] & 0xC0) == 0x80)
if (++idx > length)
@throw [OFInvalidFormatException exception];
return idx;
|
︙ | | |
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
|
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
|
-
+
|
}
_s = &_storage;
_s->cString = storage;
_s->cStringLength = UTF8StringLength;
switch (OFUTF8StringCheck(UTF8String, UTF8StringLength,
switch (_OFUTF8StringCheck(UTF8String, UTF8StringLength,
&_s->length)) {
case 1:
_s->isUTF8 = true;
break;
case -1:
@throw [OFInvalidEncodingException exception];
}
|
︙ | | |
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
|
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
|
-
+
|
_s->cString = OFAllocMemory(cStringLength + 1, 1);
_s->cStringLength = cStringLength;
_s->freeWhenDone = true;
if (encoding == OFStringEncodingUTF8 ||
encoding == OFStringEncodingASCII) {
switch (OFUTF8StringCheck(cString, cStringLength,
switch (_OFUTF8StringCheck(cString, cStringLength,
&_s->length)) {
case 1:
if (encoding == OFStringEncodingASCII)
@throw [OFInvalidEncodingException
exception];
_s->isUTF8 = true;
|
︙ | | |
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
|
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
|
-
+
|
if (!(cString[i] & 0x80)) {
_s->cString[j++] = cString[i];
continue;
}
_s->isUTF8 = true;
bytes = OFUTF8StringEncode(
bytes = _OFUTF8StringEncode(
(uint8_t)cString[i], buffer);
if (bytes == 0)
@throw [OFInvalidEncodingException
exception];
_s->cStringLength += bytes - 1;
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
switch (encoding) {
#define CASE(encoding, var) \
case encoding: \
table = var; \
tableOffset = var##Offset; \
break;
#ifdef HAVE_ISO_8859_2
CASE(OFStringEncodingISO8859_2, OFISO8859_2Table)
CASE(OFStringEncodingISO8859_2, _OFISO8859_2Table)
#endif
#ifdef HAVE_ISO_8859_3
CASE(OFStringEncodingISO8859_3, OFISO8859_3Table)
CASE(OFStringEncodingISO8859_3, _OFISO8859_3Table)
#endif
#ifdef HAVE_ISO_8859_15
CASE(OFStringEncodingISO8859_15, OFISO8859_15Table)
CASE(OFStringEncodingISO8859_15, _OFISO8859_15Table)
#endif
#ifdef HAVE_WINDOWS_1251
CASE(OFStringEncodingWindows1251, OFWindows1251Table)
CASE(OFStringEncodingWindows1251, _OFWindows1251Table)
#endif
#ifdef HAVE_WINDOWS_1252
CASE(OFStringEncodingWindows1252, OFWindows1252Table)
CASE(OFStringEncodingWindows1252, _OFWindows1252Table)
#endif
#ifdef HAVE_CODEPAGE_437
CASE(OFStringEncodingCodepage437, OFCodepage437Table)
CASE(OFStringEncodingCodepage437, _OFCodepage437Table)
#endif
#ifdef HAVE_CODEPAGE_850
CASE(OFStringEncodingCodepage850, OFCodepage850Table)
CASE(OFStringEncodingCodepage850, _OFCodepage850Table)
#endif
#ifdef HAVE_CODEPAGE_858
CASE(OFStringEncodingCodepage858, OFCodepage858Table)
CASE(OFStringEncodingCodepage858, _OFCodepage858Table)
#endif
#ifdef HAVE_MAC_ROMAN
CASE(OFStringEncodingMacRoman, OFMacRomanTable)
CASE(OFStringEncodingMacRoman, _OFMacRomanTable)
#endif
#ifdef HAVE_KOI8_R
CASE(OFStringEncodingKOI8R, OFKOI8RTable)
CASE(OFStringEncodingKOI8R, _OFKOI8RTable)
#endif
#ifdef HAVE_KOI8_U
CASE(OFStringEncodingKOI8U, OFKOI8UTable)
CASE(OFStringEncodingKOI8U, _OFKOI8UTable)
#endif
#undef CASE
default:
@throw [OFInvalidArgumentException exception];
}
j = 0;
|
︙ | | |
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
|
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
|
-
+
|
unichar = table[character - tableOffset];
if (unichar == 0xFFFF)
@throw [OFInvalidEncodingException exception];
_s->isUTF8 = true;
byteLength = OFUTF8StringEncode(unichar, buffer);
byteLength = _OFUTF8StringEncode(unichar, buffer);
if (byteLength == 0)
@throw [OFInvalidEncodingException exception];
_s->cStringLength += byteLength - 1;
_s->cString = OFResizeMemory(_s->cString,
_s->cStringLength + 1, 1);
|
︙ | | |
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
|
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
|
-
+
|
if (UTF8StringLength >= 3 &&
memcmp(UTF8String, "\xEF\xBB\xBF", 3) == 0) {
UTF8String += 3;
UTF8StringLength -= 3;
}
switch (OFUTF8StringCheck(UTF8String, UTF8StringLength,
switch (_OFUTF8StringCheck(UTF8String, UTF8StringLength,
&_s->length)) {
case 1:
_s->isUTF8 = true;
break;
case -1:
@throw [OFInvalidEncodingException exception];
}
|
︙ | | |
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
|
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
|
-
+
|
_s->cString = OFAllocMemory((length * 4) + 1, 1);
_s->length = length;
_s->freeWhenDone = true;
j = 0;
for (size_t i = 0; i < length; i++) {
size_t len = OFUTF8StringEncode(characters[i],
size_t len = _OFUTF8StringEncode(characters[i],
_s->cString + j);
if (len == 0)
@throw [OFInvalidEncodingException exception];
if (len > 1)
_s->isUTF8 = true;
|
︙ | | |
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
|
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
|
-
+
|
character = (((character & 0x3FF) << 10) |
(nextCharacter & 0x3FF)) + 0x10000;
i++;
_s->length--;
}
len = OFUTF8StringEncode(character, _s->cString + j);
len = _OFUTF8StringEncode(character, _s->cString + j);
if (len == 0)
@throw [OFInvalidEncodingException exception];
if (len > 1)
_s->isUTF8 = true;
|
︙ | | |
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
|
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
|
-
+
|
_s->cString = OFAllocMemory((length * 4) + 1, 1);
_s->length = length;
_s->freeWhenDone = true;
j = 0;
for (size_t i = 0; i < length; i++) {
char buffer[4];
size_t len = OFUTF8StringEncode((swap
size_t len = _OFUTF8StringEncode((swap
? OFByteSwap32(characters[i])
: characters[i]),
buffer);
switch (len) {
case 1:
_s->cString[j++] = buffer[0];
|
︙ | | |
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
|
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
|
-
+
-
+
|
int cStringLength;
if (format == nil)
@throw [OFInvalidArgumentException exception];
_s = &_storage;
if ((cStringLength = OFVASPrintF(&tmp, format.UTF8String,
if ((cStringLength = _OFVASPrintF(&tmp, format.UTF8String,
arguments)) == -1)
@throw [OFInvalidFormatException exception];
_s->cStringLength = cStringLength;
@try {
switch (OFUTF8StringCheck(tmp, cStringLength,
switch (_OFUTF8StringCheck(tmp, cStringLength,
&_s->length)) {
case 1:
_s->isUTF8 = true;
break;
case -1:
@throw [OFInvalidEncodingException exception];
}
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
-
+
-
+
|
i = j = 0;
while (i < _s->cStringLength && j < otherCStringLength) {
OFUnichar c1, c2;
ssize_t l1, l2;
l1 = OFUTF8StringDecode(_s->cString + i,
l1 = _OFUTF8StringDecode(_s->cString + i,
_s->cStringLength - i, &c1);
l2 = OFUTF8StringDecode(otherCString + j,
l2 = _OFUTF8StringDecode(otherCString + j,
otherCStringLength - j, &c2);
if (l1 <= 0 || l2 <= 0 || c1 > 0x10FFFF || c2 > 0x10FFFF)
@throw [OFInvalidEncodingException exception];
if (c1 >> 8 < OFUnicodeCaseFoldingTableSize) {
if (c1 >> 8 < _OFUnicodeCaseFoldingTableSize) {
OFUnichar tc =
OFUnicodeCaseFoldingTable[c1 >> 8][c1 & 0xFF];
_OFUnicodeCaseFoldingTable[c1 >> 8][c1 & 0xFF];
if (tc)
c1 = tc;
}
if (c2 >> 8 < OFUnicodeCaseFoldingTableSize) {
if (c2 >> 8 < _OFUnicodeCaseFoldingTableSize) {
OFUnichar tc =
OFUnicodeCaseFoldingTable[c2 >> 8][c2 & 0xFF];
_OFUnicodeCaseFoldingTable[c2 >> 8][c2 & 0xFF];
if (tc)
c2 = tc;
}
if (c1 > c2)
return OFOrderedDescending;
|
︙ | | |
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
|
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
|
-
+
|
OFHashInit(&hash);
for (size_t i = 0; i < _s->cStringLength; i++) {
OFUnichar c;
ssize_t length;
if ((length = OFUTF8StringDecode(_s->cString + i,
if ((length = _OFUTF8StringDecode(_s->cString + i,
_s->cStringLength - i, &c)) <= 0)
@throw [OFInvalidEncodingException exception];
OFHashAddByte(&hash, (c & 0xFF0000) >> 16);
OFHashAddByte(&hash, (c & 0x00FF00) >> 8);
OFHashAddByte(&hash, c & 0x0000FF);
|
︙ | | |
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
|
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
|
-
+
-
+
|
if (idx >= _s->length)
@throw [OFOutOfRangeException exception];
if (!_s->isUTF8)
return _s->cString[idx];
idx = OFUTF8StringIndexToPosition(_s->cString, idx, _s->cStringLength);
idx = _OFUTF8StringIndexToPosition(_s->cString, idx, _s->cStringLength);
if (OFUTF8StringDecode(_s->cString + idx, _s->cStringLength - idx,
if (_OFUTF8StringDecode(_s->cString + idx, _s->cStringLength - idx,
&character) <= 0)
@throw [OFInvalidEncodingException exception];
return character;
}
- (void)getCharacters: (OFUnichar *)buffer inRange: (OFRange)range
|
︙ | | |
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
|
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
|
-
+
-
+
|
size_t rangeLocation, rangeLength;
if (range.length > SIZE_MAX - range.location ||
range.location + range.length > _s->length)
@throw [OFOutOfRangeException exception];
if (_s->isUTF8) {
rangeLocation = OFUTF8StringIndexToPosition(
rangeLocation = _OFUTF8StringIndexToPosition(
_s->cString, range.location, _s->cStringLength);
rangeLength = OFUTF8StringIndexToPosition(
rangeLength = _OFUTF8StringIndexToPosition(
_s->cString + rangeLocation, range.length,
_s->cStringLength - rangeLocation);
} else {
rangeLocation = range.location;
rangeLength = range.length;
}
|
︙ | | |
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
|
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
|
-
+
-
+
|
size_t start = range.location;
size_t end = range.location + range.length;
if (range.length > SIZE_MAX - range.location || end > _s->length)
@throw [OFOutOfRangeException exception];
if (_s->isUTF8) {
start = OFUTF8StringIndexToPosition(_s->cString, start,
start = _OFUTF8StringIndexToPosition(_s->cString, start,
_s->cStringLength);
end = OFUTF8StringIndexToPosition(_s->cString, end,
end = _OFUTF8StringIndexToPosition(_s->cString, end,
_s->cStringLength);
}
return [OFString stringWithUTF8String: _s->cString + start
length: end - start];
}
|
︙ | | |
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
|
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
|
-
+
|
size_t i = 0, j = 0;
const OFUnichar *ret;
while (i < _s->cStringLength) {
OFUnichar c;
ssize_t cLen;
cLen = OFUTF8StringDecode(_s->cString + i,
cLen = _OFUTF8StringDecode(_s->cString + i,
_s->cStringLength - i, &c);
if (cLen <= 0 || c > 0x10FFFF) {
OFFreeMemory(buffer);
@throw [OFInvalidEncodingException exception];
}
|
︙ | | |
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
|
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
|
-
+
|
size_t i = 0, j = 0;
const OFChar32 *ret;
while (i < _s->cStringLength) {
OFChar32 c;
ssize_t cLen;
cLen = OFUTF8StringDecode(_s->cString + i,
cLen = _OFUTF8StringDecode(_s->cString + i,
_s->cStringLength - i, &c);
if (cLen <= 0 || c > 0x10FFFF) {
OFFreeMemory(buffer);
@throw [OFInvalidEncodingException exception];
}
|
︙ | | |
Modified src/OFZIPArchive.h
from [f4b92af793]
to [e571bce84b].
︙ | | |
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
|
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
|
-
-
-
-
+
+
+
+
|
*/
- (void)close;
@end
#ifdef __cplusplus
extern "C" {
#endif
extern uint32_t OFZIPArchiveReadField32(const uint8_t *_Nonnull *_Nonnull,
uint16_t *_Nonnull);
extern uint64_t OFZIPArchiveReadField64(const uint8_t *_Nonnull *_Nonnull,
uint16_t *_Nonnull);
extern uint32_t _OFZIPArchiveReadField32(const uint8_t *_Nonnull *_Nonnull,
uint16_t *_Nonnull) OF_VISIBILITY_HIDDEN;
extern uint64_t _OFZIPArchiveReadField64(const uint8_t *_Nonnull *_Nonnull,
uint16_t *_Nonnull) OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
OF_ASSUME_NONNULL_END
|
Modified src/OFZIPArchive.m
from [7c50e25802]
to [b2947775a7].
︙ | | |
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
|
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
|
-
+
-
+
|
stream: (OFStream *)stream
entry: (OFMutableZIPArchiveEntry *)entry
CRC32Offset: (OFStreamOffset)CRC32Offset
size64Offset: (OFStreamOffset)size64Offset;
@end
uint32_t
OFZIPArchiveReadField32(const uint8_t **data, uint16_t *size)
_OFZIPArchiveReadField32(const uint8_t **data, uint16_t *size)
{
uint32_t field = 0;
if (*size < 4)
@throw [OFInvalidFormatException exception];
for (uint8_t i = 0; i < 4; i++)
field |= (uint32_t)(*data)[i] << (i * 8);
*data += 4;
*size -= 4;
return field;
}
uint64_t
OFZIPArchiveReadField64(const uint8_t **data, uint16_t *size)
_OFZIPArchiveReadField64(const uint8_t **data, uint16_t *size)
{
uint64_t field = 0;
if (*size < 8)
@throw [OFInvalidFormatException exception];
for (uint8_t i = 0; i < 8; i++)
|
︙ | | |
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
-
+
|
+ (instancetype)archiveWithIRI: (OFIRI *)IRI mode: (OFString *)mode
{
return [[[self alloc] initWithIRI: IRI mode: mode] autorelease];
}
+ (OFIRI *)IRIForFilePath: (OFString *)path inArchiveWithIRI: (OFIRI *)IRI
{
return OFArchiveIRIHandlerIRIForFileInArchive(@"zip", path, IRI);
return _OFArchiveIRIHandlerIRIForFileInArchive(@"zip", path, IRI);
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
|
︙ | | |
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
|
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
|
-
+
-
+
|
if (ZIP64Index != OFNotFound) {
const uint8_t *ZIP64 =
[extraField itemAtIndex: ZIP64Index];
OFRange range =
OFMakeRange(ZIP64Index - 4, ZIP64Size + 4);
if (_uncompressedSize == 0xFFFFFFFF)
_uncompressedSize = OFZIPArchiveReadField64(
_uncompressedSize = _OFZIPArchiveReadField64(
&ZIP64, &ZIP64Size);
if (_compressedSize == 0xFFFFFFFF)
_compressedSize = OFZIPArchiveReadField64(
_compressedSize = _OFZIPArchiveReadField64(
&ZIP64, &ZIP64Size);
if (ZIP64Size > 0)
@throw [OFInvalidFormatException exception];
[extraField removeItemsInRange: range];
}
|
︙ | | |
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
|
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
|
-
+
|
if (length > _toRead)
length = (size_t)_toRead;
ret = [_decompressedStream readIntoBuffer: buffer length: length];
_toRead -= ret;
_CRC32 = OFCRC32(_CRC32, buffer, ret);
_CRC32 = _OFCRC32(_CRC32, buffer, ret);
if (_toRead == 0) {
_atEndOfStream = true;
if (~_CRC32 != _entry.CRC32) {
OFString *actualChecksum = [OFString stringWithFormat:
@"%08" PRIX32, ~_CRC32];
|
︙ | | |
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
|
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
|
-
+
-
+
|
@try {
[_stream writeBuffer: buffer length: length];
} @catch (OFWriteFailedException *e) {
OFEnsure(e.bytesWritten <= length);
_bytesWritten += (unsigned long long)e.bytesWritten;
_CRC32 = OFCRC32(_CRC32, buffer, e.bytesWritten);
_CRC32 = _OFCRC32(_CRC32, buffer, e.bytesWritten);
if (e.errNo == EWOULDBLOCK || e.errNo == EAGAIN)
return e.bytesWritten;
@throw e;
}
_bytesWritten += (unsigned long long)length;
_CRC32 = OFCRC32(_CRC32, buffer, length);
_CRC32 = _OFCRC32(_CRC32, buffer, length);
return length;
}
- (void)close
{
bool seekable;
|
︙ | | |
Modified src/OFZIPArchiveEntry.m
from [ff7db8bf1d]
to [d2d793d4fd].
︙ | | |
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
|
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
|
-
+
-
+
-
+
+
-
+
|
if (ZIP64Index != OFNotFound) {
const uint8_t *ZIP64 =
[extraField itemAtIndex: ZIP64Index];
OFRange range =
OFMakeRange(ZIP64Index - 4, ZIP64Size + 4);
if (_uncompressedSize == 0xFFFFFFFF)
_uncompressedSize = OFZIPArchiveReadField64(
_uncompressedSize = _OFZIPArchiveReadField64(
&ZIP64, &ZIP64Size);
if (_compressedSize == 0xFFFFFFFF)
_compressedSize = OFZIPArchiveReadField64(
_compressedSize = _OFZIPArchiveReadField64(
&ZIP64, &ZIP64Size);
if (_localFileHeaderOffset == 0xFFFFFFFF)
_localFileHeaderOffset =
OFZIPArchiveReadField64(&ZIP64, &ZIP64Size);
_OFZIPArchiveReadField64(&ZIP64,
&ZIP64Size);
if (_startDiskNumber == 0xFFFF)
_startDiskNumber = OFZIPArchiveReadField32(
_startDiskNumber = _OFZIPArchiveReadField32(
&ZIP64, &ZIP64Size);
if (ZIP64Size > 0 || _localFileHeaderOffset < 0)
@throw [OFInvalidFormatException exception];
[extraField removeItemsInRange: range];
}
|
︙ | | |
Modified src/OFZooArchive.m
from [5083c851c9]
to [8aedfeb877].
︙ | | |
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
-
+
|
+ (instancetype)archiveWithIRI: (OFIRI *)IRI mode: (OFString *)mode
{
return [[[self alloc] initWithIRI: IRI mode: mode] autorelease];
}
+ (OFIRI *)IRIForFilePath: (OFString *)path inArchiveWithIRI: (OFIRI *)IRI
{
return OFArchiveIRIHandlerIRIForFileInArchive(@"zoo", path, IRI);
return _OFArchiveIRIHandlerIRIForFileInArchive(@"zoo", path, IRI);
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
|
︙ | | |
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
|
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
|
-
+
|
[_stream readIntoBuffer: buffer exactLength: _lastHeaderLength];
tmp32 = OFToLittleEndian32((uint32_t)offset);
memcpy(buffer + 6, &tmp32, 4);
tmp16 = OFToLittleEndian16(
OFCRC16(0, buffer, _lastHeaderLength));
_OFCRC16(0, buffer, _lastHeaderLength));
memcpy(buffer + 54, &tmp16, 2);
[_stream seekToOffset: _lastHeaderOffset whence: OFSeekSet];
[_stream writeBuffer: buffer length: _lastHeaderLength];
[_stream seekToOffset: offset whence: OFSeekSet];
} @finally {
|
︙ | | |
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
|
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
|
-
+
|
if (length > _toRead)
length = (size_t)_toRead;
ret = [_decompressedStream readIntoBuffer: buffer length: length];
_toRead -= ret;
_CRC16 = OFCRC16(_CRC16, buffer, ret);
_CRC16 = _OFCRC16(_CRC16, buffer, ret);
if (_toRead == 0) {
_atEndOfStream = true;
if (_CRC16 != _entry.CRC16) {
OFString *actualChecksum = [OFString stringWithFormat:
@"%04" @PRIX16, _CRC16];
|
︙ | | |
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
|
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
|
-
+
-
+
|
@try {
[_stream writeBuffer: buffer length: length];
} @catch (OFWriteFailedException *e) {
OFEnsure(e.bytesWritten <= length);
_bytesWritten += (uint32_t)e.bytesWritten;
_CRC16 = OFCRC16(_CRC16, buffer, e.bytesWritten);
_CRC16 = _OFCRC16(_CRC16, buffer, e.bytesWritten);
if (e.errNo == EWOULDBLOCK || e.errNo == EAGAIN)
return e.bytesWritten;
@throw e;
}
_bytesWritten += (uint32_t)length;
_CRC16 = OFCRC16(_CRC16, buffer, length);
_CRC16 = _OFCRC16(_CRC16, buffer, length);
return length;
}
- (bool)lowlevelIsAtEndOfStream
{
if (_stream == nil)
|
︙ | | |
Modified src/bridge/NSArray+OFObject.h
from [7e0f2d7704]
to [38325c709c].
︙ | | |
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
-
+
|
OF_ASSUME_NONNULL_BEGIN
@class OFArray OF_GENERIC(ObjectType);
#ifdef __cplusplus
extern "C" {
#endif
extern int _NSArray_OFObject_reference;
extern int _NSArray_OFObject_reference OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
/**
* @category NSArray (OFObject) \
* NSArray+OFObject.h ObjFWBridge/NSArray+OFObject.h
|
︙ | | |
Modified src/bridge/NSDictionary+OFObject.h
from [cbb576e980]
to [4026e868e8].
︙ | | |
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
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);
#ifdef __cplusplus
extern "C" {
#endif
extern int _NSDictionary_OFObject_reference;
extern int _NSDictionary_OFObject_reference OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
/**
* @category NSDictionary (OFObject) \
* NSDictionary+OFObject.h ObjFWBridge/NSDictionary+OFObject.h
|
︙ | | |
Modified src/bridge/NSEnumerator+OFObject.h
from [ab538c58f1]
to [143ba9176b].
︙ | | |
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
-
+
|
OF_ASSUME_NONNULL_BEGIN
@class OFEnumerator OF_GENERIC(ObjectType);
#ifdef __cplusplus
extern "C" {
#endif
extern int _NSEnumerator_OFObject_reference;
extern int _NSEnumerator_OFObject_reference OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
/**
* @category NSEnumerator (OFObject) \
* NSEnumerator+OFObject.h ObjFWBridge/NSEnumerator+OFObject.h
|
︙ | | |
Modified src/bridge/NSNumber+OFObject.h
from [40720010ad]
to [e239036299].
︙ | | |
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
-
+
|
OF_ASSUME_NONNULL_BEGIN
@class OFNumber;
#ifdef __cplusplus
extern "C" {
#endif
extern int _NSNumber_OFObject_reference;
extern int _NSNumber_OFObject_reference OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
/**
* @category NSNumber (OFObject)
* NSNumber+OFObject.h ObjFWBridge/NSNumber+OFObject.h
|
︙ | | |
Modified src/bridge/NSSet+OFObject.h
from [34c28f8121]
to [5d09584e13].
︙ | | |
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
-
+
|
OF_ASSUME_NONNULL_BEGIN
@class OFSet OF_GENERIC(ObjectType);
#ifdef __cplusplus
extern "C" {
#endif
extern int _NSSet_OFObject_reference;
extern int _NSSet_OFObject_reference OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
/**
* @category NSSet (OFObject)
* NSSet+OFObject.h ObjFWBridge/NSSet+OFObject.h
|
︙ | | |
Modified src/bridge/NSString+OFObject.h
from [80a6874084]
to [b85dde5f1c].
︙ | | |
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
-
+
|
OF_ASSUME_NONNULL_BEGIN
@class OFString;
#ifdef __cplusplus
extern "C" {
#endif
extern int _NSString_OFObject_reference;
extern int _NSString_OFObject_reference OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
/**
* @category NSString (OFObject)
* NSString+OFObject.h ObjFWBridge/NSString+OFObject.h
|
︙ | | |
Modified src/bridge/OFArray+NSObject.h
from [3b8ba1cd06]
to [8452e2cf90].
︙ | | |
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
44
|
-
+
|
#import "OFBridging.h"
OF_ASSUME_NONNULL_BEGIN
#ifdef __cplusplus
extern "C" {
#endif
extern int _OFArray_NSObject_reference;
extern int _OFArray_NSObject_reference OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
/**
* @category OFArray (NSObject) \
* OFArray+NSObject.h ObjFWBridge/OFArray+NSObject.h
|
︙ | | |
Modified src/bridge/OFDictionary+NSObject.h
from [bebeef9986]
to [7d3951e3ba].
︙ | | |
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
44
|
-
+
|
#import "OFBridging.h"
OF_ASSUME_NONNULL_BEGIN
#ifdef __cplusplus
extern "C" {
#endif
extern int _OFDictionary_NSObject_reference;
extern int _OFDictionary_NSObject_reference OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
/**
* @category OFDictionary (NSObject) \
* OFDictionary+NSObject.h ObjFWBridge/OFDictionary+NSObject.h
|
︙ | | |
Modified src/bridge/OFEnumerator+NSObject.h
from [731ca967a3]
to [9aadb90dd5].
︙ | | |
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
44
|
-
+
|
#import "OFBridging.h"
OF_ASSUME_NONNULL_BEGIN
#ifdef __cplusplus
extern "C" {
#endif
extern int _OFEnumerator_NSObject_reference;
extern int _OFEnumerator_NSObject_reference OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
/**
* @category OFEnumerator (NSObject) \
* OFEnumerator+NSObject.h ObjFWBridge/OFEnumerator+NSObject.h
|
︙ | | |
Modified src/bridge/OFNumber+NSObject.h
from [fadb7d7a45]
to [7b4d5234a4].
︙ | | |
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
44
|
-
+
|
#import "OFBridging.h"
OF_ASSUME_NONNULL_BEGIN
#ifdef __cplusplus
extern "C" {
#endif
extern int _OFNumber_NSObject_reference;
extern int _OFNumber_NSObject_reference OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
/**
* @category OFNumber (NSObject) \
* OFNumber+NSObject.h ObjFWBridge/OFNumber+NSObject.h
|
︙ | | |
Modified src/bridge/OFSet+NSObject.h
from [5726564da5]
to [3b2725d99a].
︙ | | |
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
44
|
-
+
|
#import "OFBridging.h"
OF_ASSUME_NONNULL_BEGIN
#ifdef __cplusplus
extern "C" {
#endif
extern int _OFSet_NSObject_reference;
extern int _OFSet_NSObject_reference OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
/**
* @category OFSet (NSObject) \
* OFSet+NSObject.h ObjFWBridge/OFSet+NSObject.h
|
︙ | | |
Modified src/bridge/OFString+NSObject.h
from [cb39a1ef91]
to [287ae0c0ff].
︙ | | |
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
44
|
-
+
|
#import "OFBridging.h"
OF_ASSUME_NONNULL_BEGIN
#ifdef __cplusplus
extern "C" {
#endif
extern int _OFString_NSObject_reference;
extern int _OFString_NSObject_reference OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
/**
* @category OFString (NSObject) \
* OFString+NSObject.h ObjFWBridge/OFString+NSObject.h
|
︙ | | |
Modified src/encodings/codepage-437.m
from [9f118a4c02]
to [0e1d4e03c0].
︙ | | |
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
|
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
|
-
+
-
-
+
+
|
#include "config.h"
#import "OFString.h"
#import "common.h"
const OFChar16 OFCodepage437Table[] = {
const OFChar16 _OFCodepage437Table[] OF_VISIBILITY_HIDDEN = {
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192,
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4,
0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,
0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248,
0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0
};
const size_t OFCodepage437TableOffset =
256 - (sizeof(OFCodepage437Table) / sizeof(*OFCodepage437Table));
const size_t _OFCodepage437TableOffset OF_VISIBILITY_HIDDEN =
256 - (sizeof(_OFCodepage437Table) / sizeof(*_OFCodepage437Table));
static const unsigned char page0[] = {
0xFF, 0xAD, 0x9B, 0x9C, 0x00, 0x9D, 0x00, 0x00,
0x00, 0x00, 0xA6, 0xAE, 0xAA, 0x00, 0x00, 0x00,
0xF8, 0xF1, 0xFD, 0x00, 0x00, 0xE6, 0x00, 0xFA,
0x00, 0x00, 0xA7, 0xAF, 0xAC, 0xAB, 0x00, 0xA8,
0x00, 0x00, 0x00, 0x00, 0x8E, 0x8F, 0x92, 0x80,
|
︙ | | |
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
-
-
+
+
|
0xDB, 0x00, 0x00, 0x00, 0xDD, 0x00, 0x00, 0x00,
0xDE, 0xB0, 0xB1, 0xB2, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xFE
};
static const uint8_t page25Start = 0x00;
bool
OFUnicodeToCodepage437(const OFUnichar *input, unsigned char *output,
bool OF_VISIBILITY_HIDDEN
_OFUnicodeToCodepage437(const OFUnichar *input, unsigned char *output,
size_t length, bool lossy)
{
for (size_t i = 0; i < length; i++) {
OFUnichar c = input[i];
if OF_UNLIKELY (c > 0x7F) {
uint8_t idx;
|
︙ | | |
Modified src/encodings/codepage-850.m
from [1d1a09a45c]
to [116375a4bc].
︙ | | |
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
|
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
|
-
+
-
-
+
+
-
|
#include "config.h"
#import "OFString.h"
#import "common.h"
const OFChar16 OFCodepage850Table[] = {
const OFChar16 _OFCodepage850Table[] OF_VISIBILITY_HIDDEN = {
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192,
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0,
0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510,
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3,
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x0131, 0x00CD, 0x00CE,
0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580,
0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE,
0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4,
0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8,
0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0
};
const size_t OFCodepage850TableOffset =
256 - (sizeof(OFCodepage850Table) / sizeof(*OFCodepage850Table));
const size_t _OFCodepage850TableOffset OF_VISIBILITY_HIDDEN =
256 - (sizeof(_OFCodepage850Table) / sizeof(*_OFCodepage850Table));
static const unsigned char page0[] = {
0xFF, 0xAD, 0xBD, 0x9C, 0xCF, 0xBE, 0xDD, 0xF5,
0xF9, 0xB8, 0xA6, 0xAE, 0xAA, 0xF0, 0xA9, 0xEE,
0xF8, 0xF1, 0xFD, 0xFC, 0xEF, 0xE6, 0xF4, 0xFA,
0xF7, 0xFB, 0xA7, 0xAF, 0xAC, 0xAB, 0xF3, 0xA8,
0xB7, 0xB5, 0xB6, 0xC7, 0x8E, 0x8F, 0x92, 0x80,
|
︙ | | |
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
-
-
+
+
|
0xDB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xB0, 0xB1, 0xB2, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xFE
};
static const uint8_t page25Start = 0x00;
bool
OFUnicodeToCodepage850(const OFUnichar *input, unsigned char *output,
bool OF_VISIBILITY_HIDDEN
_OFUnicodeToCodepage850(const OFUnichar *input, unsigned char *output,
size_t length, bool lossy)
{
for (size_t i = 0; i < length; i++) {
OFUnichar c = input[i];
if OF_UNLIKELY (c > 0x7F) {
uint8_t idx;
|
︙ | | |
Modified src/encodings/codepage-858.m
from [4aa1a82036]
to [0a443ea671].
︙ | | |
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
|
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
|
-
+
-
-
+
+
-
|
#include "config.h"
#import "OFString.h"
#import "common.h"
const OFChar16 OFCodepage858Table[] = {
const OFChar16 _OFCodepage858Table[] OF_VISIBILITY_HIDDEN = {
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192,
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0,
0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510,
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3,
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x20AC, 0x00CD, 0x00CE,
0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580,
0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE,
0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4,
0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8,
0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0
};
const size_t OFCodepage858TableOffset =
256 - (sizeof(OFCodepage858Table) / sizeof(*OFCodepage858Table));
const size_t _OFCodepage858TableOffset OF_VISIBILITY_HIDDEN =
256 - (sizeof(_OFCodepage858Table) / sizeof(*_OFCodepage858Table));
static const unsigned char page0[] = {
0xFF, 0xAD, 0xBD, 0x9C, 0xCF, 0xBE, 0xDD, 0xF5,
0xF9, 0xB8, 0xA6, 0xAE, 0xAA, 0xF0, 0xA9, 0xEE,
0xF8, 0xF1, 0xFD, 0xFC, 0xEF, 0xE6, 0xF4, 0xFA,
0xF7, 0xFB, 0xA7, 0xAF, 0xAC, 0xAB, 0xF3, 0xA8,
0xB7, 0xB5, 0xB6, 0xC7, 0x8E, 0x8F, 0x92, 0x80,
|
︙ | | |
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
-
-
+
+
|
0xDB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xB0, 0xB1, 0xB2, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xFE
};
static const uint8_t page25Start = 0x00;
bool
OFUnicodeToCodepage858(const OFUnichar *input, unsigned char *output,
bool OF_VISIBILITY_HIDDEN
_OFUnicodeToCodepage858(const OFUnichar *input, unsigned char *output,
size_t length, bool lossy)
{
for (size_t i = 0; i < length; i++) {
OFUnichar c = input[i];
if OF_UNLIKELY (c > 0x7F) {
uint8_t idx;
|
︙ | | |
Modified src/encodings/iso-8859-15.m
from [21daaed653]
to [25e41edd49].
︙ | | |
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
|
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
|
-
+
-
-
+
+
|
#include "config.h"
#import "OFString.h"
#import "common.h"
const OFChar16 OFISO8859_15Table[] = {
const OFChar16 _OFISO8859_15Table[] OF_VISIBILITY_HIDDEN = {
0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x20AC, 0x00A5, 0x0160, 0x00A7,
0x0161, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x017D, 0x00B5, 0x00B6, 0x00B7,
0x017E, 0x00B9, 0x00BA, 0x00BB, 0x0152, 0x0153, 0x0178, 0x00BF,
0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7,
0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7,
0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF,
0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7,
0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF
};
const size_t OFISO8859_15TableOffset =
256 - (sizeof(OFISO8859_15Table) / sizeof(*OFISO8859_15Table));
const size_t _OFISO8859_15TableOffset OF_VISIBILITY_HIDDEN =
256 - (sizeof(_OFISO8859_15Table) / sizeof(*_OFISO8859_15Table));
static const unsigned char page0[] = {
0x00, 0xA5, 0x00, 0xA7, 0x00, 0xA9, 0xAA, 0xAB,
0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3,
0x00, 0xB5, 0xB6, 0xB7, 0x00, 0xB9, 0xBA, 0xBB,
0x00, 0x00, 0x00
};
|
︙ | | |
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
-
-
+
+
|
static const uint8_t page1Start = 0x52;
static const unsigned char page20[] = {
0xA4
};
static const uint8_t page20Start = 0xAC;
bool
OFUnicodeToISO8859_15(const OFUnichar *input, unsigned char *output,
bool OF_VISIBILITY_HIDDEN
_OFUnicodeToISO8859_15(const OFUnichar *input, unsigned char *output,
size_t length, bool lossy)
{
for (size_t i = 0; i < length; i++) {
OFUnichar c = input[i];
if OF_UNLIKELY (c > 0x7F) {
uint8_t idx;
|
︙ | | |
Modified src/encodings/iso-8859-2.m
from [8986e3bb39]
to [bd3f7dada7].
︙ | | |
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
|
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
|
-
+
-
-
+
+
|
#include "config.h"
#import "OFString.h"
#import "common.h"
const OFChar16 OFISO8859_2Table[] = {
const OFChar16 _OFISO8859_2Table[] OF_VISIBILITY_HIDDEN = {
0x00A0, 0x0104, 0x02D8, 0x0141, 0x00A4, 0x013D, 0x015A, 0x00A7,
0x00A8, 0x0160, 0x015E, 0x0164, 0x0179, 0x00AD, 0x017D, 0x017B,
0x00B0, 0x0105, 0x02DB, 0x0142, 0x00B4, 0x013E, 0x015B, 0x02C7,
0x00B8, 0x0161, 0x015F, 0x0165, 0x017A, 0x02DD, 0x017E, 0x017C,
0x0154, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0139, 0x0106, 0x00C7,
0x010C, 0x00C9, 0x0118, 0x00CB, 0x011A, 0x00CD, 0x00CE, 0x010E,
0x0110, 0x0143, 0x0147, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x00D7,
0x0158, 0x016E, 0x00DA, 0x0170, 0x00DC, 0x00DD, 0x0162, 0x00DF,
0x0155, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x013A, 0x0107, 0x00E7,
0x010D, 0x00E9, 0x0119, 0x00EB, 0x011B, 0x00ED, 0x00EE, 0x010F,
0x0111, 0x0144, 0x0148, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x00F7,
0x0159, 0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD, 0x0163, 0x02D9
};
const size_t OFISO8859_2TableOffset =
256 - (sizeof(OFISO8859_2Table) / sizeof(*OFISO8859_2Table));
const size_t _OFISO8859_2TableOffset OF_VISIBILITY_HIDDEN =
256 - (sizeof(_OFISO8859_2Table) / sizeof(*_OFISO8859_2Table));
static const unsigned char page0[] = {
0xA0, 0x00, 0x00, 0x00, 0xA4, 0x00, 0x00, 0xA7,
0xA8, 0x00, 0x00, 0x00, 0x00, 0xAD, 0x00, 0x00,
0xB0, 0x00, 0x00, 0x00, 0xB4, 0x00, 0x00, 0x00,
0xB8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xC1, 0xC2, 0x00, 0xC4, 0x00, 0x00, 0xC7,
|
︙ | | |
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
-
-
+
+
|
static const unsigned char page2[] = {
0xB7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xA2, 0xFF, 0x00, 0xB2, 0x00, 0xBD
};
static const uint8_t page2Start = 0xC7;
bool
OFUnicodeToISO8859_2(const OFUnichar *input, unsigned char *output,
bool OF_VISIBILITY_HIDDEN
_OFUnicodeToISO8859_2(const OFUnichar *input, unsigned char *output,
size_t length, bool lossy)
{
for (size_t i = 0; i < length; i++) {
OFUnichar c = input[i];
if OF_UNLIKELY (c > 0x7F) {
uint8_t idx;
|
︙ | | |
Modified src/encodings/iso-8859-3.m
from [2126ec415a]
to [bc9ab876ae].
︙ | | |
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
|
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
|
-
+
-
-
+
+
|
#include "config.h"
#import "OFString.h"
#import "common.h"
const OFChar16 OFISO8859_3Table[] = {
const OFChar16 _OFISO8859_3Table[] OF_VISIBILITY_HIDDEN = {
0x00A0, 0x0126, 0x02D8, 0x00A3, 0x00A4, 0xFFFF, 0x0124, 0x00A7,
0x00A8, 0x0130, 0x015E, 0x011E, 0x0134, 0x00AD, 0xFFFF, 0x017B,
0x00B0, 0x0127, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x0125, 0x00B7,
0x00B8, 0x0131, 0x015F, 0x011F, 0x0135, 0x00BD, 0xFFFF, 0x017C,
0x00C0, 0x00C1, 0x00C2, 0xFFFF, 0x00C4, 0x010A, 0x0108, 0x00C7,
0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
0xFFFF, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x0120, 0x00D6, 0x00D7,
0x011C, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x016C, 0x015C, 0x00DF,
0x00E0, 0x00E1, 0x00E2, 0xFFFF, 0x00E4, 0x010B, 0x0109, 0x00E7,
0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
0xFFFF, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x0121, 0x00F6, 0x00F7,
0x011D, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x016D, 0x015D, 0x02D9
};
const size_t OFISO8859_3TableOffset =
256 - (sizeof(OFISO8859_3Table) / sizeof(*OFISO8859_3Table));
const size_t _OFISO8859_3TableOffset OF_VISIBILITY_HIDDEN =
256 - (sizeof(_OFISO8859_3Table) / sizeof(*_OFISO8859_3Table));
static const unsigned char page0[] = {
0xA0, 0x00, 0x00, 0xA3, 0xA4, 0x00, 0x00, 0xA7,
0xA8, 0x00, 0x00, 0x00, 0x00, 0xAD, 0x00, 0x00,
0xB0, 0x00, 0xB2, 0xB3, 0xB4, 0xB5, 0x00, 0xB7,
0xB8, 0x00, 0x00, 0x00, 0x00, 0xBD, 0x00, 0x00,
0xC0, 0xC1, 0xC2, 0x00, 0xC4, 0x00, 0x00, 0xC7,
|
︙ | | |
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
-
-
+
+
|
static const uint8_t page1Start = 0x08;
static const unsigned char page2[] = {
0xA2, 0xFF
};
static const uint8_t page2Start = 0xD8;
bool
OFUnicodeToISO8859_3(const OFUnichar *input, unsigned char *output,
bool OF_VISIBILITY_HIDDEN
_OFUnicodeToISO8859_3(const OFUnichar *input, unsigned char *output,
size_t length, bool lossy)
{
for (size_t i = 0; i < length; i++) {
OFUnichar c = input[i];
if OF_UNLIKELY (c > 0x7F) {
uint8_t idx;
|
︙ | | |
Modified src/encodings/koi8-r.m
from [2c4f09a0dd]
to [7d684b26ac].
︙ | | |
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
|
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
|
-
+
-
-
+
+
|
#include "config.h"
#import "OFString.h"
#import "common.h"
const OFChar16 OFKOI8RTable[] = {
const OFChar16 _OFKOI8RTable[] OF_VISIBILITY_HIDDEN = {
0x2500, 0x2502, 0x250C, 0x2510, 0x2514, 0x2518, 0x251C, 0x2524,
0x252C, 0x2534, 0x253C, 0x2580, 0x2584, 0x2588, 0x258C, 0x2590,
0x2591, 0x2592, 0x2593, 0x2320, 0x25A0, 0x2219, 0x221A, 0x2248,
0x2264, 0x2265, 0x00A0, 0x2321, 0x00B0, 0x00B2, 0x00B7, 0x00F7,
0x2550, 0x2551, 0x2552, 0x0451, 0x2553, 0x2554, 0x2555, 0x2556,
0x2557, 0x2558, 0x2559, 0x255A, 0x255B, 0x255C, 0x255D, 0x255E,
0x255F, 0x2560, 0x2561, 0x0401, 0x2562, 0x2563, 0x2564, 0x2565,
0x2566, 0x2567, 0x2568, 0x2569, 0x256A, 0x256B, 0x256C, 0x00A9,
0x044E, 0x0430, 0x0431, 0x0446, 0x0434, 0x0435, 0x0444, 0x0433,
0x0445, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E,
0x043F, 0x044F, 0x0440, 0x0441, 0x0442, 0x0443, 0x0436, 0x0432,
0x044C, 0x044B, 0x0437, 0x0448, 0x044D, 0x0449, 0x0447, 0x044A,
0x042E, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413,
0x0425, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E,
0x041F, 0x042F, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412,
0x042C, 0x042B, 0x0417, 0x0428, 0x042D, 0x0429, 0x0427, 0x042A
};
const size_t OFKOI8RTableOffset =
256 - (sizeof(OFKOI8RTable) / sizeof(*OFKOI8RTable));
const size_t _OFKOI8RTableOffset OF_VISIBILITY_HIDDEN =
256 - (sizeof(_OFKOI8RTable) / sizeof(*_OFKOI8RTable));
static const unsigned char page0[] = {
0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xBF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x9C, 0x00, 0x9D, 0x00, 0x00, 0x00, 0x00, 0x9E,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
︙ | | |
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
-
-
+
+
|
0x8D, 0x00, 0x00, 0x00, 0x8E, 0x00, 0x00, 0x00,
0x8F, 0x90, 0x91, 0x92, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x94
};
static const uint8_t page25Start = 0x00;
bool
OFUnicodeToKOI8R(const OFUnichar *input, unsigned char *output, size_t length,
bool OF_VISIBILITY_HIDDEN
_OFUnicodeToKOI8R(const OFUnichar *input, unsigned char *output, size_t length,
bool lossy)
{
for (size_t i = 0; i < length; i++) {
OFUnichar c = input[i];
if OF_UNLIKELY (c > 0x7F) {
uint8_t idx;
|
︙ | | |
Modified src/encodings/koi8-u.m
from [9252bda863]
to [0f9ae48dcf].
︙ | | |
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
|
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
|
-
+
-
-
+
+
|
#include "config.h"
#import "OFString.h"
#import "common.h"
const OFChar16 OFKOI8UTable[] = {
const OFChar16 _OFKOI8UTable[] OF_VISIBILITY_HIDDEN = {
0x2500, 0x2502, 0x250C, 0x2510, 0x2514, 0x2518, 0x251C, 0x2524,
0x252C, 0x2534, 0x253C, 0x2580, 0x2584, 0x2588, 0x258C, 0x2590,
0x2591, 0x2592, 0x2593, 0x2320, 0x25A0, 0x2219, 0x221A, 0x2248,
0x2264, 0x2265, 0x00A0, 0x2321, 0x00B0, 0x00B2, 0x00B7, 0x00F7,
0x2550, 0x2551, 0x2552, 0x0451, 0x0454, 0x2554, 0x0456, 0x0457,
0x2557, 0x2558, 0x2559, 0x255A, 0x255B, 0x0491, 0x255D, 0x255E,
0x255F, 0x2560, 0x2561, 0x0401, 0x0404, 0x2563, 0x0406, 0x0407,
0x2566, 0x2567, 0x2568, 0x2569, 0x256A, 0x0490, 0x256C, 0x00A9,
0x044E, 0x0430, 0x0431, 0x0446, 0x0434, 0x0435, 0x0444, 0x0433,
0x0445, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E,
0x043F, 0x044F, 0x0440, 0x0441, 0x0442, 0x0443, 0x0436, 0x0432,
0x044C, 0x044B, 0x0437, 0x0448, 0x044D, 0x0449, 0x0447, 0x044A,
0x042E, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413,
0x0425, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E,
0x041F, 0x042F, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412,
0x042C, 0x042B, 0x0417, 0x0428, 0x042D, 0x0429, 0x0427, 0x042A
};
const size_t OFKOI8UTableOffset =
256 - (sizeof(OFKOI8UTable) / sizeof(*OFKOI8UTable));
const size_t _OFKOI8UTableOffset OF_VISIBILITY_HIDDEN =
256 - (sizeof(_OFKOI8UTable) / sizeof(*_OFKOI8UTable));
static const unsigned char page0[] = {
0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xBF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x9C, 0x00, 0x9D, 0x00, 0x00, 0x00, 0x00, 0x9E,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
︙ | | |
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
-
-
+
+
|
0x8D, 0x00, 0x00, 0x00, 0x8E, 0x00, 0x00, 0x00,
0x8F, 0x90, 0x91, 0x92, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x94
};
static const uint8_t page25Start = 0x00;
bool
OFUnicodeToKOI8U(const OFUnichar *input, unsigned char *output, size_t length,
bool OF_VISIBILITY_HIDDEN
_OFUnicodeToKOI8U(const OFUnichar *input, unsigned char *output, size_t length,
bool lossy)
{
for (size_t i = 0; i < length; i++) {
OFUnichar c = input[i];
if OF_UNLIKELY (c > 0x7F) {
uint8_t idx;
|
︙ | | |
Modified src/encodings/mac-roman.m
from [d6ebb30db7]
to [48622afc6e].
︙ | | |
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
|
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
|
-
+
-
-
+
+
|
#include "config.h"
#import "OFString.h"
#import "common.h"
const OFChar16 OFMacRomanTable[] = {
const OFChar16 _OFMacRomanTable[] OF_VISIBILITY_HIDDEN = {
0x00C4, 0x00C5, 0x00C7, 0x00C9, 0x00D1, 0x00D6, 0x00DC, 0x00E1,
0x00E0, 0x00E2, 0x00E4, 0x00E3, 0x00E5, 0x00E7, 0x00E9, 0x00E8,
0x00EA, 0x00EB, 0x00ED, 0x00EC, 0x00EE, 0x00EF, 0x00F1, 0x00F3,
0x00F2, 0x00F4, 0x00F6, 0x00F5, 0x00FA, 0x00F9, 0x00FB, 0x00FC,
0x2020, 0x00B0, 0x00A2, 0x00A3, 0x00A7, 0x2022, 0x00B6, 0x00DF,
0x00AE, 0x00A9, 0x2122, 0x00B4, 0x00A8, 0x2260, 0x00C6, 0x00D8,
0x221E, 0x00B1, 0x2264, 0x2265, 0x00A5, 0x00B5, 0x2202, 0x2211,
0x220F, 0x03C0, 0x222B, 0x00AA, 0x00BA, 0x03A9, 0x00E6, 0x00F8,
0x00BF, 0x00A1, 0x00AC, 0x221A, 0x0192, 0x2248, 0x2206, 0x00AB,
0x00BB, 0x2026, 0x00A0, 0x00C0, 0x00C3, 0x00D5, 0x0152, 0x0153,
0x2013, 0x2014, 0x201C, 0x201D, 0x2018, 0x2019, 0x00F7, 0x25CA,
0x00FF, 0x0178, 0x2044, 0x20AC, 0x2039, 0x203A, 0xFB01, 0xFB02,
0x2021, 0x00B7, 0x201A, 0x201E, 0x2030, 0x00C2, 0x00CA, 0x00C1,
0x00CB, 0x00C8, 0x00CD, 0x00CE, 0x00CF, 0x00CC, 0x00D3, 0x00D4,
0xF8FF, 0x00D2, 0x00DA, 0x00DB, 0x00D9, 0x0131, 0x02C6, 0x02DC,
0x00AF, 0x02D8, 0x02D9, 0x02DA, 0x00B8, 0x02DD, 0x02DB, 0x02C7
};
const size_t OFMacRomanTableOffset =
256 - (sizeof(OFMacRomanTable) / sizeof(*OFMacRomanTable));
const size_t _OFMacRomanTableOffset OF_VISIBILITY_HIDDEN =
256 - (sizeof(_OFMacRomanTable) / sizeof(*_OFMacRomanTable));
static const unsigned char page0[] = {
0xCA, 0xC1, 0xA2, 0xA3, 0x00, 0xB4, 0x00, 0xA4,
0xAC, 0xA9, 0xBB, 0xC7, 0xC2, 0x00, 0xA8, 0xF8,
0xA1, 0xB1, 0x00, 0x00, 0xAB, 0xB5, 0xA6, 0xE1,
0xFC, 0x00, 0xBC, 0xC8, 0x00, 0x00, 0x00, 0xC0,
0xCB, 0xE7, 0xE5, 0xCC, 0x80, 0x81, 0xAE, 0x82,
|
︙ | | |
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
-
-
+
+
|
static const uint8_t pageF8Start = 0xFF;
static const unsigned char pageFB[] = {
0xDE, 0xDF
};
static const uint8_t pageFBStart = 0x01;
bool
OFUnicodeToMacRoman(const OFUnichar *input, unsigned char *output,
bool OF_VISIBILITY_HIDDEN
_OFUnicodeToMacRoman(const OFUnichar *input, unsigned char *output,
size_t length, bool lossy)
{
for (size_t i = 0; i < length; i++) {
OFUnichar c = input[i];
if OF_UNLIKELY (c > 0x7F) {
uint8_t idx;
|
︙ | | |
Modified src/encodings/windows-1251.m
from [902244b996]
to [fb08e37f56].
︙ | | |
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
|
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
|
-
+
-
-
+
+
|
#include "config.h"
#import "OFString.h"
#import "common.h"
const OFChar16 OFWindows1251Table[] = {
const OFChar16 _OFWindows1251Table[] OF_VISIBILITY_HIDDEN = {
0x0402, 0x0403, 0x201A, 0x0453, 0x201E, 0x2026, 0x2020, 0x2021,
0x20AC, 0x2030, 0x0409, 0x2039, 0x040A, 0x040C, 0x040B, 0x040F,
0x0452, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
0xFFFF, 0x2122, 0x0459, 0x203A, 0x045A, 0x045C, 0x045B, 0x045F,
0x00A0, 0x040E, 0x045E, 0x0408, 0x00A4, 0x0490, 0x00A6, 0x00A7,
0x0401, 0x00A9, 0x0404, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x0407,
0x00B0, 0x00B1, 0x0406, 0x0456, 0x0491, 0x00B5, 0x00B6, 0x00B7,
0x0451, 0x2116, 0x0454, 0x00BB, 0x0458, 0x0405, 0x0455, 0x0457,
0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F,
0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F,
0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F,
0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F
};
const size_t OFWindows1251TableOffset =
256 - (sizeof(OFWindows1251Table) / sizeof(*OFWindows1251Table));
const size_t _OFWindows1251TableOffset OF_VISIBILITY_HIDDEN =
256 - (sizeof(_OFWindows1251Table) / sizeof(*_OFWindows1251Table));
static const unsigned char page0[] = {
0xA0, 0x00, 0x00, 0x00, 0xA4, 0x00, 0xA6, 0xA7,
0x00, 0xA9, 0x00, 0xAB, 0xAC, 0xAD, 0xAE, 0x00,
0xB0, 0xB1, 0x00, 0x00, 0x00, 0xB5, 0xB6, 0xB7,
0x00, 0x00, 0x00, 0xBB
};
|
︙ | | |
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
-
-
+
+
|
static const unsigned char page21[] = {
0xB9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x99
};
static const uint8_t page21Start = 0x16;
bool
OFUnicodeToWindows1251(const OFUnichar *input, unsigned char *output,
bool OF_VISIBILITY_HIDDEN
_OFUnicodeToWindows1251(const OFUnichar *input, unsigned char *output,
size_t length, bool lossy)
{
for (size_t i = 0; i < length; i++) {
OFUnichar c = input[i];
if OF_UNLIKELY (c > 0x7F) {
uint8_t idx;
|
︙ | | |
Modified src/encodings/windows-1252.m
from [3f257f7d9d]
to [1577a4fe9c].
︙ | | |
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
|
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
|
-
+
-
-
+
+
|
#include "config.h"
#import "OFString.h"
#import "common.h"
const OFChar16 OFWindows1252Table[] = {
const OFChar16 _OFWindows1252Table[] OF_VISIBILITY_HIDDEN = {
0x20AC, 0xFFFF, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0xFFFF, 0x017D, 0xFFFF,
0xFFFF, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
0x02DC, 0x2122, 0x0161, 0x203A, 0x0153, 0xFFFF, 0x017E, 0x0178,
0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7,
0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7,
0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF,
0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7,
0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF
};
const size_t OFWindows1252TableOffset =
256 - (sizeof(OFWindows1252Table) / sizeof(*OFWindows1252Table));
const size_t _OFWindows1252TableOffset OF_VISIBILITY_HIDDEN =
256 - (sizeof(_OFWindows1252Table) / sizeof(*_OFWindows1252Table));
static const unsigned char page0[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
|
︙ | | |
97
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
112
|
-
-
+
+
|
static const uint8_t page20Start = 0x13;
static const unsigned char page21[] = {
0x99
};
static const uint8_t page21Start = 0x22;
bool
OFUnicodeToWindows1252(const OFUnichar *input, unsigned char *output,
bool OF_VISIBILITY_HIDDEN
_OFUnicodeToWindows1252(const OFUnichar *input, unsigned char *output,
size_t length, bool lossy)
{
for (size_t i = 0; i < length; i++) {
OFUnichar c = input[i];
if OF_UNLIKELY (c > 0x7F) {
uint8_t idx;
|
︙ | | |
Modified src/exceptions/OFCreateWindowsRegistryKeyFailedException.m
from [6808748419]
to [cecd763f91].
︙ | | |
80
81
82
83
84
85
86
87
88
89
|
80
81
82
83
84
85
86
87
88
89
|
-
+
|
[super dealloc];
}
- (OFString *)description
{
return [OFString stringWithFormat:
@"Failed to create subkey at path %@: %@",
_path, OFWindowsStatusToString(_status)];
_path, _OFWindowsStatusToString(_status)];
}
@end
|
Modified src/exceptions/OFDNSQueryFailedException.h
from [ba6bf4fd32]
to [9442dc2216].
︙ | | |
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
-
-
+
+
|
- (instancetype)init OF_UNAVAILABLE;
@end
#ifdef __cplusplus
extern "C" {
#endif
extern OFString *OFDNSResolverErrorCodeDescription(
OFDNSResolverErrorCode errorCode);
extern OFString *_OFDNSResolverErrorCodeDescription(
OFDNSResolverErrorCode errorCode) OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
OF_ASSUME_NONNULL_END
|
Modified src/exceptions/OFDNSQueryFailedException.m
from [cbd992d3b3]
to [328c695472].
︙ | | |
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
-
+
|
#include "config.h"
#import "OFDNSQueryFailedException.h"
#import "OFString.h"
OFString *
OFDNSResolverErrorCodeDescription(OFDNSResolverErrorCode errorCode)
_OFDNSResolverErrorCodeDescription(OFDNSResolverErrorCode errorCode)
{
switch (errorCode) {
case OFDNSResolverErrorCodeTimeout:
return @"The query timed out.";
case OFDNSResolverErrorCodeCanceled:
return @"The query was canceled.";
case OFDNSResolverErrorCodeNoResult:
|
︙ | | |
96
97
98
99
100
101
102
103
104
105
|
96
97
98
99
100
101
102
103
104
105
|
-
+
|
[super dealloc];
}
- (OFString *)description
{
return [OFString stringWithFormat:
@"DNS query %@ could not be performed: %@",
_query, OFDNSResolverErrorCodeDescription(_errorCode)];
_query, _OFDNSResolverErrorCodeDescription(_errorCode)];
}
@end
|
Modified src/exceptions/OFDeleteWindowsRegistryKeyFailedException.m
from [334a748840]
to [fac0a7d3cf].
︙ | | |
67
68
69
70
71
72
73
74
75
76
|
67
68
69
70
71
72
73
74
75
76
|
-
+
|
[super dealloc];
}
- (OFString *)description
{
return [OFString stringWithFormat:
@"Failed to delete subkey at path %@: %@",
_subkeyPath, OFWindowsStatusToString(_status)];
_subkeyPath, _OFWindowsStatusToString(_status)];
}
@end
|
Modified src/exceptions/OFDeleteWindowsRegistryValueFailedException.m
from [0e23fc3fee]
to [af698f2bca].
︙ | | |
67
68
69
70
71
72
73
74
75
76
|
67
68
69
70
71
72
73
74
75
76
|
-
+
|
[super dealloc];
}
- (OFString *)description
{
return [OFString stringWithFormat:
@"Failed to delete value named %@: %@",
_valueName, OFWindowsStatusToString(_status)];
_valueName, _OFWindowsStatusToString(_status)];
}
@end
|
Modified src/exceptions/OFException.h
from [b676d6c459]
to [5970277a67].
︙ | | |
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
+
+
|
#import "OFObject.h"
#ifdef OF_WINDOWS
# include <windows.h>
#endif
OF_ASSUME_NONNULL_BEGIN
/** @file */
@class OFArray OF_GENERIC(ObjectType);
@class OFString;
@class OFValue;
#define OFStackTraceSize 16
|
︙ | | |
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
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
|
+
+
+
+
+
+
+
+
+
+
+
+
-
+
|
*/
- (nullable OFArray OF_GENERIC(OFString *) *)stackTraceSymbols;
@end
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Converts the specified error number (from `<errno.h>`) to a string.
*
* Unlike the system function `strerror`, this function is always thread-safe.
*
* As an addition, on Windows, it is also able to convert socket error numbers
* to string.
*
* @param errNo The error number to convert to a string
* @return A string describing the error
*/
extern OFString *OFStrError(int errNo);
#ifdef OF_WINDOWS
extern OFString *OFWindowsStatusToString(LSTATUS status);
extern OFString *_OFWindowsStatusToString(LSTATUS status) OF_VISIBILITY_HIDDEN;
#endif
#ifdef __cplusplus
}
#endif
OF_ASSUME_NONNULL_END
|
Modified src/exceptions/OFException.m
from [816a02d4da]
to [33a4f03ee1].
︙ | | |
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
|
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
|
-
+
|
#endif
return ret;
}
#ifdef OF_WINDOWS
OFString *
OFWindowsStatusToString(LSTATUS status)
_OFWindowsStatusToString(LSTATUS status)
{
OFString *string = nil;
void *buffer;
if ([OFSystemInfo isWindowsNT]) {
if (FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
︙ | | |
Modified src/exceptions/OFGetWindowsRegistryValueFailedException.m
from [fb4c183eca]
to [089a3beae1].
︙ | | |
70
71
72
73
74
75
76
77
78
79
|
70
71
72
73
74
75
76
77
78
79
|
-
+
|
[super dealloc];
}
- (OFString *)description
{
return [OFString stringWithFormat:
@"Failed to get value named %@: %@",
_valueName, OFWindowsStatusToString(_status)];
_valueName, _OFWindowsStatusToString(_status)];
}
@end
|
Modified src/exceptions/OFOpenWindowsRegistryKeyFailedException.m
from [3030425341]
to [335390b890].
︙ | | |
78
79
80
81
82
83
84
85
86
87
|
78
79
80
81
82
83
84
85
86
87
|
-
+
|
[super dealloc];
}
- (OFString *)description
{
return [OFString stringWithFormat:
@"Failed to open subkey at path %@: %@",
_path, OFWindowsStatusToString(_status)];
_path, _OFWindowsStatusToString(_status)];
}
@end
|
Modified src/exceptions/OFResolveHostFailedException.m
from [fe448762f6]
to [0aa6b04b40].
︙ | | |
71
72
73
74
75
76
77
78
79
80
|
71
72
73
74
75
76
77
78
79
80
|
-
+
|
[super dealloc];
}
- (OFString *)description
{
return [OFString stringWithFormat:
@"The host %@ could not be resolved: %@",
_host, OFDNSResolverErrorCodeDescription(_errorCode)];
_host, _OFDNSResolverErrorCodeDescription(_errorCode)];
}
@end
|
Modified src/exceptions/OFSetWindowsRegistryValueFailedException.m
from [f10d7b695a]
to [9d878c3278].
︙ | | |
76
77
78
79
80
81
82
83
84
85
|
76
77
78
79
80
81
82
83
84
85
|
-
+
|
[super dealloc];
}
- (OFString *)description
{
return [OFString stringWithFormat:
@"Failed to set value named %@ of type %u: %@",
_valueName, _type, OFWindowsStatusToString(_status)];
_valueName, _type, _OFWindowsStatusToString(_status)];
}
@end
|
Modified src/exceptions/OFTLSHandshakeFailedException.h
from [6262e58801]
to [6986a24c14].
︙ | | |
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
-
+
|
#import "OFTLSStream.h"
OF_ASSUME_NONNULL_BEGIN
#ifdef __cplusplus
extern "C" {
#endif
extern int _OFTLSHandshakeFailedException_reference;
extern int _OFTLSHandshakeFailedException_reference OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
/**
* @class OFTLSHandshakeFailedException \
* OFTLSHandshakeFailedException.h ObjFW/OFTLSHandshakeFailedException.h
|
︙ | | |
Modified src/forwarding/forwarding-arm-elf.S
from [6672c7d1bd]
to [f6b2ed20ca].
︙ | | |
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
+
+
+
+
+
|
mov r1, r4
bl objc_msg_lookup(PLT)
mov r12, r0
ldr r0, [sp, #0]
mov r1, r4
ldr r2, [sp, #4]
#ifdef HAVE_BLX
blx r12
#else
mov lr, pc
bx r12
#endif
cmp r0, #0
beq 0f
ldr r1, [sp, #0]
cmp r0, r1
beq 0f
|
︙ | | |
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
+
+
+
+
+
|
mov r1, r4
bl objc_msg_lookup(PLT)
mov r12, r0
ldr r0, [sp, #4]
mov r1, r4
ldr r2, [sp, #8]
#ifdef HAVE_BLX
blx r12
#else
mov lr, pc
bx r12
#endif
cmp r0, #0
beq 0f
ldr r1, [sp, #4]
cmp r0, r1
beq 0f
|
︙ | | |
Modified src/macros.h
from [7e3d0a019b]
to [e71e68e9ff].
︙ | | |
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
+
+
|
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
/** @file */
#include "platform.h"
#ifdef OF_OBJFW_RUNTIME
# ifdef OF_COMPILING_OBJFW
# include "ObjFWRT.h"
# else
|
︙ | | |
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
+
+
|
#ifdef __GNUC__
# define OF_INLINE inline __attribute__((__always_inline__))
# define OF_LIKELY(cond) (__builtin_expect(!!(cond), 1))
# define OF_UNLIKELY(cond) (__builtin_expect(!!(cond), 0))
# define OF_CONST_FUNC __attribute__((__const__))
# define OF_NO_RETURN_FUNC __attribute__((__noreturn__))
# define OF_WEAK_REF(sym) __attribute__((__weakref__(sym)))
# define OF_VISIBILITY_HIDDEN __attribute__((__visibility__("hidden")))
#else
# define OF_INLINE inline
# define OF_LIKELY(cond) (cond)
# define OF_UNLIKELY(cond) (cond)
# define OF_CONST_FUNC
# define OF_NO_RETURN_FUNC
# define OF_WEAK_REF(sym)
# define OF_VISIBILITY_HIDDEN
#endif
#if __STDC_VERSION__ >= 201112L
# define OF_ALIGN(size) _Alignas(size)
# define OF_ALIGNOF(type) _Alignof(type)
# define OF_ALIGNAS(type) _Alignas(type)
#else
|
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
|
static void __attribute__((__constructor__(prio))) \
OF_PREPROCESSOR_CONCAT(constructor, __LINE__)(void)
#define OF_DESTRUCTOR(prio) \
static void __attribute__((__destructor__(prio))) \
OF_PREPROCESSOR_CONCAT(destructor, __LINE__)(void)
static OF_INLINE uint16_t OF_CONST_FUNC
OFByteSwap16Const(uint16_t i)
_OFByteSwap16Const(uint16_t i)
{
return (i & UINT16_C(0xFF00)) >> 8 | (i & UINT16_C(0x00FF)) << 8;
}
static OF_INLINE uint32_t OF_CONST_FUNC
OFByteSwap32Const(uint32_t i)
_OFByteSwap32Const(uint32_t i)
{
return (i & UINT32_C(0xFF000000)) >> 24 |
(i & UINT32_C(0x00FF0000)) >> 8 |
(i & UINT32_C(0x0000FF00)) << 8 |
(i & UINT32_C(0x000000FF)) << 24;
}
static OF_INLINE uint64_t OF_CONST_FUNC
OFByteSwap64Const(uint64_t i)
_OFByteSwap64Const(uint64_t i)
{
return (i & UINT64_C(0xFF00000000000000)) >> 56 |
(i & UINT64_C(0x00FF000000000000)) >> 40 |
(i & UINT64_C(0x0000FF0000000000)) >> 24 |
(i & UINT64_C(0x000000FF00000000)) >> 8 |
(i & UINT64_C(0x00000000FF000000)) << 8 |
(i & UINT64_C(0x0000000000FF0000)) << 24 |
(i & UINT64_C(0x000000000000FF00)) << 40 |
(i & UINT64_C(0x00000000000000FF)) << 56;
}
static OF_INLINE uint16_t OF_CONST_FUNC
OFByteSwap16NonConst(uint16_t i)
_OFByteSwap16NonConst(uint16_t i)
{
#if defined(OF_HAVE_BUILTIN_BSWAP16)
return __builtin_bswap16(i);
#elif (defined(OF_AMD64) || defined(OF_X86)) && defined(__GNUC__)
__asm__ (
"xchg{b} { %h0, %b0 | %b0, %h0 }"
: "=Q" (i)
|
︙ | | |
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
|
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
|
-
+
|
i = (i & UINT16_C(0xFF00)) >> 8 |
(i & UINT16_C(0x00FF)) << 8;
#endif
return i;
}
static OF_INLINE uint32_t OF_CONST_FUNC
OFByteSwap32NonConst(uint32_t i)
_OFByteSwap32NonConst(uint32_t i)
{
#if defined(OF_HAVE_BUILTIN_BSWAP32)
return __builtin_bswap32(i);
#elif (defined(OF_AMD64) || defined(OF_X86)) && defined(__GNUC__)
__asm__ (
"bswap %0"
: "=q" (i)
|
︙ | | |
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
|
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
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
|
-
+
-
+
-
+
-
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
-
+
-
-
-
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
(i & UINT32_C(0x0000FF00)) << 8 |
(i & UINT32_C(0x000000FF)) << 24;
#endif
return i;
}
static OF_INLINE uint64_t OF_CONST_FUNC
OFByteSwap64NonConst(uint64_t i)
_OFByteSwap64NonConst(uint64_t i)
{
#if defined(OF_HAVE_BUILTIN_BSWAP64)
return __builtin_bswap64(i);
#elif defined(OF_AMD64) && defined(__GNUC__)
__asm__ (
"bswap %0"
: "=r" (i)
: "0" (i)
);
#elif defined(OF_X86) && defined(__GNUC__)
__asm__ (
"bswap {%%}eax\n\t"
"bswap {%%}edx\n\t"
"xchg{l} { %%eax, %%edx | edx, eax }"
: "=A" (i)
: "0" (i)
);
#else
i = (uint64_t)OFByteSwap32NonConst(
i = (uint64_t)_OFByteSwap32NonConst(
(uint32_t)(i & UINT32_C(0xFFFFFFFF))) << 32 |
OFByteSwap32NonConst((uint32_t)(i >> 32));
_OFByteSwap32NonConst((uint32_t)(i >> 32));
#endif
return i;
}
#ifdef __GNUC__
#if defined(__GNUC__) || defined(DOXYGEN)
/**
* @brief Byte swaps the specified 16 bit integer.
*
* @param i The integer to byte swap
* @return The byte swapped integer
*/
# define OFByteSwap16(i) \
(__builtin_constant_p(i) ? OFByteSwap16Const(i) : OFByteSwap16NonConst(i))
(__builtin_constant_p(i) ? _OFByteSwap16Const(i) : _OFByteSwap16NonConst(i))
/**
* @brief Byte swaps the specified 32 bit integer.
*
* @param i The integer to byte swap
* @return The byte swapped integer
*/
# define OFByteSwap32(i) \
(__builtin_constant_p(i) ? OFByteSwap32Const(i) : OFByteSwap32NonConst(i))
(__builtin_constant_p(i) ? _OFByteSwap32Const(i) : _OFByteSwap32NonConst(i))
/**
* @brief Byte swaps the specified 64 bit integer.
*
* @param i The integer to byte swap
* @return The byte swapped integer
*/
# define OFByteSwap64(i) \
(__builtin_constant_p(i) ? OFByteSwap64Const(i) : OFByteSwap64NonConst(i))
(__builtin_constant_p(i) ? _OFByteSwap64Const(i) : _OFByteSwap64NonConst(i))
#else
# define OFByteSwap16(i) OFByteSwap16Const(i)
# define OFByteSwap32(i) OFByteSwap32Const(i)
# define OFByteSwap64(i) OFByteSwap64Const(i)
# define OFByteSwap16(i) _OFByteSwap16Const(i)
# define OFByteSwap32(i) _OFByteSwap32Const(i)
# define OFByteSwap64(i) _OFByteSwap64Const(i)
#endif
/**
* @brief Bit-converts the specified float to a uint32_t.
*
* @param f The float to bit-convert
* @return The float bit-converted to a uint32_t
*/
static OF_INLINE uint32_t
OFFloatToRawUInt32(float f)
static OF_INLINE uint32_t OF_CONST_FUNC
OFBitConvertFloatToUInt32(float f)
{
uint32_t ret;
memcpy(&ret, &f, 4);
return ret;
}
/**
* @brief Bit-converts the specified uint32_t to a float.
*
* @param uInt32 The uint32_t to bit-convert
* @return The uint32_t bit-converted to a float
*/
static OF_INLINE float
OFRawUInt32ToFloat(uint32_t uInt32)
static OF_INLINE float OF_CONST_FUNC
OFBitConvertUInt32ToFloat(uint32_t uInt32)
{
float ret;
memcpy(&ret, &uInt32, 4);
return ret;
}
/**
* @brief Bit-converts the specified double to a uint64_t.
*
* @param d The double to bit-convert
* @return The double bit-converted to a uint64_t
*/
static OF_INLINE uint64_t
OFDoubleToRawUInt64(double d)
static OF_INLINE uint64_t OF_CONST_FUNC
OFBitConvertDoubleToUInt64(double d)
{
uint64_t ret;
memcpy(&ret, &d, 8);
return ret;
}
/**
* @brief Bit-converts the specified uint64_t to a double.
*
* @param uInt64 The uint64_t to bit-convert
* @return The uint64_t bit-converted to a double
*/
static OF_INLINE double
OFRawUInt64ToDouble(uint64_t uInt64)
static OF_INLINE double OF_CONST_FUNC
OFBitConvertUInt64ToDouble(uint64_t uInt64)
{
double ret;
memcpy(&ret, &uInt64, 8);
return ret;
}
/**
* @brief Byte swaps the specified float.
*
* @param f The float to byte swap
* @return The byte swapped float
*/
static OF_INLINE float OF_CONST_FUNC
OFByteSwapFloat(float f)
{
return OFRawUInt32ToFloat(OFByteSwap32(OFFloatToRawUInt32(f)));
return OFBitConvertUInt32ToFloat(OFByteSwap32(
OFBitConvertFloatToUInt32(f)));
}
/**
* @brief Byte swaps the specified double.
*
* @param d The double to byte swap
* @return The byte swapped double
*/
static OF_INLINE double OF_CONST_FUNC
OFByteSwapDouble(double d)
{
return OFRawUInt64ToDouble(OFByteSwap64(OFDoubleToRawUInt64(d)));
return OFBitConvertUInt64ToDouble(OFByteSwap64(
OFBitConvertDoubleToUInt64(d)));
}
#ifdef OF_BIG_ENDIAN
#if defined(OF_BIG_ENDIAN) || defined(DOXYGEN)
/**
* @brief Converts the specified 16 bit integer from big endian to native
* endian.
*
* @param i The 16 bit integer to convert
* @return The 16 bit integer converted to native endian
*/
# define OFFromBigEndian16(i) (i)
/**
* @brief Converts the specified 32 bit integer from big endian to native
* endian.
*
* @param i The 32 bit integer to convert
* @return The 32 bit integer converted to native endian
*/
# define OFFromBigEndian32(i) (i)
/**
* @brief Converts the specified 64 bit integer from big endian to native
* endian.
*
* @param i The 64 bit integer to convert
* @return The 64 bit integer converted to native endian
*/
# define OFFromBigEndian64(i) (i)
/**
* @brief Converts the specified 16 bit integer from little endian to native
* endian.
*
* @param i The 16 bit integer to convert
* @return The 16 bit integer converted to native endian
*/
# define OFFromLittleEndian16(i) OFByteSwap16(i)
/**
* @brief Converts the specified 32 bit integer from little endian to native
* endian.
*
* @param i The 32 bit integer to convert
* @return The 32 bit integer converted to native endian
*/
# define OFFromLittleEndian32(i) OFByteSwap32(i)
/**
* @brief Converts the specified 64 bit integer from little endian to native
* endian.
*
* @param i The 64 bit integer to convert
* @return The 64 bit integer converted to native endian
*/
# define OFFromLittleEndian64(i) OFByteSwap64(i)
/**
* @brief Converts the specified 16 bit integer from native endian to big
* endian.
*
* @param i The 16 bit integer to convert
* @return The 16 bit integer converted to big endian
*/
# define OFToBigEndian16(i) (i)
/**
* @brief Converts the specified 32 bit integer from native endian to big
* endian.
*
* @param i The 32 bit integer to convert
* @return The 32 bit integer converted to big endian
*/
# define OFToBigEndian32(i) (i)
/**
* @brief Converts the specified 64 bit integer from native endian to big
* endian.
*
* @param i The 64 bit integer to convert
* @return The 64 bit integer converted to big endian
*/
# define OFToBigEndian64(i) (i)
/**
* @brief Converts the specified 16 bit integer from native endian to little
* endian.
*
* @param i The 16 bit integer to convert
* @return The 16 bit integer converted to little endian
*/
# define OFToLittleEndian16(i) OFByteSwap16(i)
/**
* @brief Converts the specified 32 bit integer from native endian to little
* endian.
*
* @param i The 32 bit integer to convert
* @return The 32 bit integer converted to little endian
*/
# define OFToLittleEndian32(i) OFByteSwap32(i)
/**
* @brief Converts the specified 64 bit integer from native endian to little
* endian.
*
* @param i The 64 bit integer to convert
* @return The 64 bit integer converted to little endian
*/
# define OFToLittleEndian64(i) OFByteSwap64(i)
#else
# define OFFromBigEndian16(i) OFByteSwap16(i)
# define OFFromBigEndian32(i) OFByteSwap32(i)
# define OFFromBigEndian64(i) OFByteSwap64(i)
# define OFFromLittleEndian16(i) (i)
# define OFFromLittleEndian32(i) (i)
# define OFFromLittleEndian64(i) (i)
# define OFToBigEndian16(i) OFByteSwap16(i)
# define OFToBigEndian32(i) OFByteSwap32(i)
# define OFToBigEndian64(i) OFByteSwap64(i)
# define OFToLittleEndian16(i) (i)
# define OFToLittleEndian32(i) (i)
# define OFToLittleEndian64(i) (i)
#endif
#ifdef OF_FLOAT_BIG_ENDIAN
#if defined(OF_FLOAT_BIG_ENDIAN) || defined(DOXYGEN)
/**
* @brief Converts the specified float from big endian to native endian.
*
* @param f The float to convert
* @return The float converted to native endian
*/
# define OFFromBigEndianFloat(f) (f)
/**
* @brief Converts the specified double from big endian to native endian.
*
* @param d The double to convert
* @return The double converted to native endian
*/
# define OFFromBigEndianDouble(d) (d)
/**
* @brief Converts the specified float from little endian to native endian.
*
* @param f The float to convert
* @return The float converted to native endian
*/
# define OFFromLittleEndianFloat(f) OFByteSwapFloat(f)
/**
* @brief Converts the specified double from little endian to native endian.
*
* @param d The double to convert
* @return The double converted to native endian
*/
# define OFFromLittleEndianDouble(d) OFByteSwapDouble(d)
/**
* @brief Converts the specified float from native endian to big endian.
*
* @param f The float to convert
* @return The float converted to big endian
*/
# define OFToBigEndianFloat(f) (f)
/**
* @brief Converts the specified double from native endian to big endian.
*
* @param d The double to convert
* @return The double converted to big endian
*/
# define OFToBigEndianDouble(d) (d)
/**
* @brief Converts the specified float from native endian to little endian.
*
* @param f The float to convert
* @return The float converted to little endian
*/
# define OFToLittleEndianFloat(f) OFByteSwapFloat(f)
/**
* @brief Converts the specified double from native endian to little endian.
*
* @param d The double to convert
* @return The double converted to little endian
*/
# define OFToLittleEndianDouble(d) OFByteSwapDouble(d)
#else
# define OFFromBigEndianFloat(f) OFByteSwapFloat(f)
# define OFFromBigEndianDouble(d) OFByteSwapDouble(d)
# define OFFromLittleEndianFloat(f) (f)
# define OFFromLittleEndianDouble(d) (d)
# define OFToBigEndianFloat(f) OFByteSwapFloat(f)
# define OFToBigEndianDouble(d) OFByteSwapDouble(d)
# define OFToLittleEndianFloat(f) (f)
# define OFToLittleEndianDouble(d) (d)
#endif
/**
* @brief Rotates the specified value left by the specified amount of bits.
*
* @param value The value to rotate
* @param bits The number of bits to rotate left the value by
* @return The value rotated left by the specified amount of bits
*/
#define OFRotateLeft(value, bits) \
(((bits) % (sizeof(value) * 8)) > 0 \
? ((value) << ((bits) % (sizeof(value) * 8))) | \
((value) >> (sizeof(value) * 8 - ((bits) % (sizeof(value) * 8)))) \
: (value))
/**
* @brief Rotates the specified value right by the specified amount of bits.
*
* @param value The value to rotate
* @param bits The number of bits to rotate right the value by
* @return The value rotated right by the specified amount of bits
*/
#define OFRotateRight(value, bits) \
(((bits) % (sizeof(value) * 8)) > 0 \
? ((value) >> ((bits) % (sizeof(value) * 8))) | \
((value) << (sizeof(value) * 8 - ((bits) % (sizeof(value) * 8)))) \
: (value))
/**
* @brief Rounds up the specified value to the specified power of two.
*
* @param pow2 The power of 2 to round up to
* @param value The value to round up to the specified power of two
* @return The specified value rounded up to the specified power of two
*/
#define OFRoundUpToPowerOf2(pow2, value) \
(((value) + (pow2) - 1) & ~((pow2) - 1))
static OF_INLINE bool
OFBitsetIsSet(unsigned char *_Nonnull storage, size_t idx)
{
return storage[idx / CHAR_BIT] & (1u << (idx % CHAR_BIT));
|
︙ | | |
Modified src/platform.h
from [b44c54e58f]
to [a058ae787f].
︙ | | |
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
-
+
|
# define OF_BIG_ENDIAN
# define OF_FLOAT_BIG_ENDIAN
# elif !__LITTLE_ENDIAN__
# error OF_UNIVERSAL defined, but neither __BIG_ENDIAN__ nor __LITTLE_ENDIAN__!
# endif
#endif
#if defined(__x86_64__) || defined(__amd64__)
#if (defined(__x86_64__) || defined(__amd64__)) && defined(__LP64__)
# define OF_AMD64
#elif defined(__i386__)
# define OF_X86
#elif defined(__powerpc64__) || defined(__ppc64__) || defined(__PPC64__)
# define OF_POWERPC64
#elif defined(__powerpc__) || defined(__ppc__) || defined(__PPC__)
# define OF_POWERPC
|
︙ | | |
Modified src/platform/AmigaOS/OFPlainCondition.m
from [c2df0315e9]
to [264925273e].
︙ | | |
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
-
+
|
return OFPlainConditionWaitOrExecSignal(condition, mutex, &signalMask);
}
int
OFPlainConditionWaitOrExecSignal(OFPlainCondition *condition,
OFPlainMutex *mutex, ULONG *signalMask)
{
struct OFPlainConditionWaitingTask waitingTask = {
struct _OFPlainConditionWaitingTask waitingTask = {
.task = FindTask(NULL),
.sigBit = AllocSignal(-1)
};
int error = 0;
ULONG mask;
if (waitingTask.sigBit == -1)
|
︙ | | |
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
-
+
|
&signalMask);
}
int
OFPlainConditionTimedWaitOrExecSignal(OFPlainCondition *condition,
OFPlainMutex *mutex, OFTimeInterval timeout, ULONG *signalMask)
{
struct OFPlainConditionWaitingTask waitingTask = {
struct _OFPlainConditionWaitingTask waitingTask = {
.task = FindTask(NULL),
.sigBit = AllocSignal(-1)
};
struct MsgPort port = {
.mp_Node = {
.ln_Type = NT_MSGPORT
},
|
︙ | | |
Modified src/platform/POSIX/OFSystemInfo+NetworkInterfaces.m
from [d2c08c8ec3]
to [0e4f3315ec].
︙ | | |
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
|
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
|
-
+
|
# endif
}
# endif
[addresses addItem: &address];
next:
# ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
# if defined(HAVE_STRUCT_SOCKADDR_SA_LEN) && !defined(OF_NETBSD)
if (current->ifr_addr.sa_len > sizeof(struct sockaddr))
buffer += sizeof(struct ifreq) -
sizeof(struct sockaddr) +
current->ifr_addr.sa_len;
else
# endif
buffer += sizeof(struct ifreq);
|
︙ | | |
Modified src/platform/Windows/OFWin32ConsoleStdIOStream.m
from [ab386bcc83]
to [e39c45536f].
︙ | | |
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
-
+
|
if (UTF16Len > 0 && _incompleteUTF16Surrogate != 0) {
OFUnichar c =
(((_incompleteUTF16Surrogate & 0x3FF) << 10) |
(UTF16[0] & 0x3FF)) + 0x10000;
char UTF8[4];
size_t UTF8Len;
if ((UTF8Len = OFUTF8StringEncode(c, UTF8)) == 0)
if ((UTF8Len = _OFUTF8StringEncode(c, UTF8)) == 0)
@throw [OFInvalidEncodingException exception];
if (UTF8Len <= length) {
memcpy(buffer, UTF8, UTF8Len);
j += UTF8Len;
} else {
if (rest == nil)
|
︙ | | |
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
|
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
|
-
+
|
c = (((c & 0x3FF) << 10) | (next & 0x3FF)) +
0x10000;
i++;
}
if ((UTF8Len = OFUTF8StringEncode(c, UTF8)) == 0)
if ((UTF8Len = _OFUTF8StringEncode(c, UTF8)) == 0)
@throw [OFInvalidEncodingException exception];
if (j + UTF8Len <= length) {
memcpy(buffer + j, UTF8, UTF8Len);
j += UTF8Len;
} else {
if (rest == nil)
|
︙ | | |
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
|
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
|
-
+
-
+
|
if (_incompleteUTF8SurrogateLen > 0) {
OFUnichar c;
OFChar16 UTF16[2];
ssize_t UTF8Len;
size_t toCopy;
DWORD UTF16Len, bytesWritten;
UTF8Len = -OFUTF8StringDecode(
UTF8Len = -_OFUTF8StringDecode(
_incompleteUTF8Surrogate, _incompleteUTF8SurrogateLen, &c);
OFEnsure(UTF8Len > 0);
toCopy = UTF8Len - _incompleteUTF8SurrogateLen;
if (toCopy > length)
toCopy = length;
memcpy(_incompleteUTF8Surrogate + _incompleteUTF8SurrogateLen,
buffer, toCopy);
_incompleteUTF8SurrogateLen += toCopy;
if (_incompleteUTF8SurrogateLen < (size_t)UTF8Len)
return 0;
UTF8Len = OFUTF8StringDecode(
UTF8Len = _OFUTF8StringDecode(
_incompleteUTF8Surrogate, _incompleteUTF8SurrogateLen, &c);
if (UTF8Len <= 0 || c > 0x10FFFF) {
OFAssert(UTF8Len == 0 || UTF8Len < -4);
UTF16[0] = 0xFFFD;
UTF16Len = 1;
|
︙ | | |
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
|
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
|
-
+
|
@try {
DWORD bytesWritten;
while (i < length) {
OFUnichar c;
ssize_t UTF8Len;
UTF8Len = OFUTF8StringDecode(buffer + i, length - i,
UTF8Len = _OFUTF8StringDecode(buffer + i, length - i,
&c);
if (UTF8Len < 0 && UTF8Len >= -4) {
OFEnsure(length - i < 4);
memcpy(_incompleteUTF8Surrogate, buffer + i,
length - i);
|
︙ | | |
Modified src/runtime/ObjFWRT.h
from [94db01f911]
to [d9451d26e7].
︙ | | |
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
-
|
/** @brief Associate the object like a copied property. */
OBJC_ASSOCIATION_COPY = OBJC_ASSOCIATION_COPY_NONATOMIC | 0x300
} objc_associationPolicy;
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Registers a selector with the specified name with the runtime.
*
* @param name The name for the selector to register
* @return The registered selector
*/
extern SEL _Nonnull sel_registerName(const char *_Nonnull name);
|
︙ | | |
Modified src/test/OTAssert.h
from [8bd6d8696c]
to [41f0812f71].
︙ | | |
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
-
+
|
* @brief Asserts that the specified condition condition holds.
*
* @param condition The condition to check
* @param ... An optional format string to print if the assertion failed,
* followed by optional arguments
*/
#define OTAssert(condition, ...) \
OTAssertImpl(self, _cmd, condition, @#condition, \
_OTAssertImpl(self, _cmd, condition, @#condition, \
@__FILE__, __LINE__, ## __VA_ARGS__, nil)
/**
* @brief Asserts that the specified condition is true.
*
* @param condition The condition to check
* @param ... An optional format string to print if the assertion failed,
|
︙ | | |
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
-
+
-
-
-
+
+
+
+
|
/**
* @brief Skips the current test, making it neither fail nor succeeed.
*
* @param ... An optional format string to print why the test was skipped,
* followed by optional arguments
*/
#define OTSkip(...) \
OTSkipImpl(self, _cmd, @__FILE__, __LINE__, ## __VA_ARGS__, nil)
_OTSkipImpl(self, _cmd, @__FILE__, __LINE__, ## __VA_ARGS__, nil)
#ifdef __cplusplus
extern "C" {
#endif
extern void OTAssertImpl(id testCase, SEL test, bool condition, OFString *check,
OFString *file, size_t line, ...);
extern void OTSkipImpl(id testCase, SEL test, OFString *file, size_t line, ...);
extern void _OTAssertImpl(id testCase, SEL test, bool condition,
OFString *check, OFString *file, size_t line, ...);
extern void _OTSkipImpl(id testCase, SEL test, OFString *file, size_t line,
...);
#ifdef __cplusplus
}
#endif
|
Modified src/test/OTAssert.m
from [fa56e52ecc]
to [8cdaeecf00].
︙ | | |
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
|
-
+
|
#import "OFString.h"
#import "OTAssertionFailedException.h"
#import "OTTestSkippedException.h"
void
OTAssertImpl(id testCase, SEL test, bool condition, OFString *check,
_OTAssertImpl(id testCase, SEL test, bool condition, OFString *check,
OFString *file, size_t line, ...)
{
va_list arguments;
OFConstantString *format;
OFString *message = nil;
if (condition)
|
︙ | | |
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
-
+
|
va_end(arguments);
@throw [OTAssertionFailedException exceptionWithCondition: check
message: message];
}
void
OTSkipImpl(id testCase, SEL test, OFString *file, size_t line, ...)
_OTSkipImpl(id testCase, SEL test, OFString *file, size_t line, ...)
{
va_list arguments;
OFConstantString *format;
OFString *message = nil;
va_start(arguments, line);
format = va_arg(arguments, OFConstantString *);
|
︙ | | |
Modified src/unicode.h
from [1b0487bb05]
to [f81c1f2dbe].
︙ | | |
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
|
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
|
-
-
-
-
+
+
+
+
-
+
-
+
-
+
-
+
+
|
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* <https://www.gnu.org/licenses/>.
*/
#import "OFString.h"
#define OFUnicodeUppercaseTableSize 0x1EA
#define OFUnicodeLowercaseTableSize 0x1EA
#define OFUnicodeTitlecaseTableSize 0x1EA
#define OFUnicodeCaseFoldingTableSize 0x1EA
#define _OFUnicodeUppercaseTableSize 0x1EA
#define _OFUnicodeLowercaseTableSize 0x1EA
#define _OFUnicodeTitlecaseTableSize 0x1EA
#define _OFUnicodeCaseFoldingTableSize 0x1EA
#ifdef __cplusplus
extern "C" {
#endif
extern const OFUnichar *const _Nonnull
OFUnicodeUppercaseTable[OFUnicodeUppercaseTableSize];
_OFUnicodeUppercaseTable[_OFUnicodeUppercaseTableSize] OF_VISIBILITY_HIDDEN;
extern const OFUnichar *const _Nonnull
OFUnicodeLowercaseTable[OFUnicodeLowercaseTableSize];
_OFUnicodeLowercaseTable[_OFUnicodeLowercaseTableSize] OF_VISIBILITY_HIDDEN;
extern const OFUnichar *const _Nonnull
OFUnicodeTitlecaseTable[OFUnicodeTitlecaseTableSize];
_OFUnicodeTitlecaseTable[_OFUnicodeTitlecaseTableSize] OF_VISIBILITY_HIDDEN;
extern const OFUnichar *const _Nonnull
OFUnicodeCaseFoldingTable[OFUnicodeCaseFoldingTableSize];
_OFUnicodeCaseFoldingTable[_OFUnicodeCaseFoldingTableSize]
OF_VISIBILITY_HIDDEN;
#ifdef __cplusplus
}
#endif
|
Modified src/unicode.m
from [f5c16fee83]
to [31ef22e205].
︙ | | |
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
-
+
|
* You should have received a copy of the GNU Lesser General Public License
* version 3.0 along with this program. If not, see
* <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#import "OFString.h"
#import "unicode.h"
static const OFUnichar emptyPage[0x100] = { 0 };
static const OFUnichar uppercasePage0[0x100] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
|
︙ | | |
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
|
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
|
-
+
|
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
const OFUnichar *const OFUnicodeUppercaseTable[0x1EA] = {
const OFUnichar *const _OFUnicodeUppercaseTable[0x1EA] = {
uppercasePage0, uppercasePage1, uppercasePage2, uppercasePage3,
uppercasePage4, uppercasePage5, emptyPage, emptyPage,
emptyPage, emptyPage, emptyPage, emptyPage,
emptyPage, emptyPage, emptyPage, emptyPage,
uppercasePage16, emptyPage, emptyPage, uppercasePage19,
emptyPage, emptyPage, emptyPage, emptyPage,
emptyPage, emptyPage, emptyPage, emptyPage,
|
︙ | | |
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
|
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
|
-
+
|
emptyPage, emptyPage, emptyPage, emptyPage,
emptyPage, emptyPage, emptyPage, emptyPage,
emptyPage, emptyPage, emptyPage, emptyPage,
emptyPage, emptyPage, emptyPage, emptyPage,
emptyPage, uppercasePage489
};
const OFUnichar *const OFUnicodeLowercaseTable[0x1EA] = {
const OFUnichar *const _OFUnicodeLowercaseTable[0x1EA] = {
lowercasePage0, lowercasePage1, lowercasePage2, lowercasePage3,
lowercasePage4, lowercasePage5, emptyPage, emptyPage,
emptyPage, emptyPage, emptyPage, emptyPage,
emptyPage, emptyPage, emptyPage, emptyPage,
lowercasePage16, emptyPage, emptyPage, lowercasePage19,
emptyPage, emptyPage, emptyPage, emptyPage,
emptyPage, emptyPage, emptyPage, emptyPage,
|
︙ | | |
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
|
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
|
-
+
|
emptyPage, emptyPage, emptyPage, emptyPage,
emptyPage, emptyPage, emptyPage, emptyPage,
emptyPage, emptyPage, emptyPage, emptyPage,
emptyPage, emptyPage, emptyPage, emptyPage,
emptyPage, lowercasePage489
};
const OFUnichar *const OFUnicodeTitlecaseTable[0x1EA] = {
const OFUnichar *const _OFUnicodeTitlecaseTable[0x1EA] = {
uppercasePage0, titlecasePage1, uppercasePage2, uppercasePage3,
uppercasePage4, uppercasePage5, emptyPage, emptyPage,
emptyPage, emptyPage, emptyPage, emptyPage,
emptyPage, emptyPage, emptyPage, emptyPage,
titlecasePage16, emptyPage, emptyPage, uppercasePage19,
emptyPage, emptyPage, emptyPage, emptyPage,
emptyPage, emptyPage, emptyPage, emptyPage,
|
︙ | | |
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
|
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
|
-
+
|
emptyPage, emptyPage, emptyPage, emptyPage,
emptyPage, emptyPage, emptyPage, emptyPage,
emptyPage, emptyPage, emptyPage, emptyPage,
emptyPage, emptyPage, emptyPage, emptyPage,
emptyPage, uppercasePage489
};
const OFUnichar *const OFUnicodeCaseFoldingTable[0x1EA] = {
const OFUnichar *const _OFUnicodeCaseFoldingTable[0x1EA] = {
caseFoldingPage0, caseFoldingPage1, lowercasePage2,
caseFoldingPage3, lowercasePage4, lowercasePage5,
emptyPage, emptyPage, emptyPage,
emptyPage, emptyPage, emptyPage,
emptyPage, emptyPage, emptyPage,
emptyPage, lowercasePage16, emptyPage,
emptyPage, caseFoldingPage19, emptyPage,
|
︙ | | |
Modified tests/OFDateTests.m
from [1b655b92f3]
to [4495b273a8].
︙ | | |
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
-
-
+
+
|
- (void)testStrPTime
{
struct tm tm;
int16_t timeZone;
const char *dateString = "Wed, 09 Jun 2021 +0200x";
OTAssertEqual(OFStrPTime(dateString, "%a, %d %b %Y %z", &tm, &timeZone),
dateString + 22);
OTAssertEqual(_OFStrPTime(dateString, "%a, %d %b %Y %z", &tm,
&timeZone), dateString + 22);
OTAssertEqual(tm.tm_wday, 3);
OTAssertEqual(tm.tm_mday, 9);
OTAssertEqual(tm.tm_mon, 5);
OTAssertEqual(tm.tm_year, 2021 - 1900);
OTAssertEqual(timeZone, 2 * 60);
}
|
︙ | | |
Modified tests/OFFileManagerTests.m
from [ff06e4c90e]
to [08e4ea3058].
︙ | | |
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
|
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
|
+
+
-
-
+
+
+
+
+
|
IRIByAppendingPathComponent: @"source"];
OFIRI *destinationIRI = [_testsDirectoryIRI
IRIByAppendingPathComponent: @"destination"];
OFFileAttributes attributes;
[@"test" writeToIRI: sourceIRI];
@try {
[_fileManager
[_fileManager linkItemAtPath: sourceIRI.fileSystemRepresentation
toPath: destinationIRI.fileSystemRepresentation];
linkItemAtPath: sourceIRI.fileSystemRepresentation
toPath: destinationIRI.fileSystemRepresentation];
} @catch (OFNotImplementedException *e) {
OTSkip(@"Links not supported");
}
attributes = [_fileManager attributesOfItemAtIRI: destinationIRI];
OTAssertEqual(attributes.fileType, OFFileTypeRegular);
OTAssertEqual(attributes.fileSize, 4);
OTAssertEqualObjects([OFString stringWithContentsOfIRI: destinationIRI],
@"test");
}
|
︙ | | |
346
347
348
349
350
351
352
353
354
355
356
357
358
359
|
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
|
+
+
|
} @catch (OFCreateSymbolicLinkFailedException *e) {
if (e.errNo != EPERM)
@throw e;
OTSkip(@"No permission to create symlink.\n"
@"On Windows, only the administrator can create symbolic "
@"links.");
} @catch (OFNotImplementedException *e) {
OTSkip(@"Symlinks not supported");
}
attributes = [_fileManager attributesOfItemAtIRI: destinationIRI];
OTAssertEqual(attributes.fileType, OFFileTypeSymbolicLink);
OTAssertEqualObjects([OFString stringWithContentsOfIRI: destinationIRI],
@"test");
}
|
︙ | | |
Modified tests/OFScryptTests.m
from [a6d12637a8]
to [1df5c01194].
︙ | | |
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
|
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
|
-
+
-
+
-
+
|
@implementation OFScryptTests
- (void)testSalsa20_8Core
{
uint32_t salsa20Buffer[16];
memcpy(salsa20Buffer, salsa20Input, 64);
OFSalsa20_8Core(salsa20Buffer);
_OFSalsa20_8Core(salsa20Buffer);
OTAssertEqual(memcmp(salsa20Buffer, salsa20Output, 64), 0);
}
- (void)testBlockMix
{
uint32_t blockMixBuffer[32];
OFScryptBlockMix(blockMixBuffer, blockMixInput.u32, 1);
_OFScryptBlockMix(blockMixBuffer, blockMixInput.u32, 1);
OTAssertEqual(memcmp(blockMixBuffer, blockMixOutput, 128), 0);
}
- (void)testROMix
{
uint32_t ROMixBuffer[32], ROMixTmp[17 * 32];
memcpy(ROMixBuffer, ROMixInput, 128);
OFScryptROMix(ROMixBuffer, 1, 16, ROMixTmp);
_OFScryptROMix(ROMixBuffer, 1, 16, ROMixTmp);
OTAssertEqual(memcmp(ROMixBuffer, ROMixOutput, 128), 0);
}
- (void)testRFC7941TestVector1
{
unsigned char output[64];
|
︙ | | |
Modified tests/subprocess/Subprocess.m
from [75e4dad33e]
to [f5dfed46e5].
︙ | | |
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
|
OFString *line;
if (![[OFApplication arguments] isEqual:
[OFArray arrayWithObjects: @"tést", @"123", nil]])
[OFApplication terminateWithStatus: 1];
if (![[[OFApplication environment] objectForKey: @"tëst"]
isEqual: @"yés"])
isEqual: @"yés"]) {
[OFApplication terminateWithStatus: 2];
while ((line = [OFStdIn readLine]) != nil)
[OFStdOut writeLine: line.uppercaseString];
}
#ifdef OF_WINDOWS
/* On Windows 9x, closing the pipe doesn't seem to cause EOF. */
if (![OFSystemInfo isWindowsNT]) {
if ((line = [OFStdIn readLine]) != nil)
[OFStdOut writeLine: line.uppercaseString];
} else
#endif
while ((line = [OFStdIn readLine]) != nil)
[OFStdOut writeLine: line.uppercaseString];
[OFApplication terminate];
}
@end
|
Modified utils/ofarc/OFArc.m
from [f2ee58a5d5]
to [f0ee4f03f2].
︙ | | |
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
|
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
|
+
-
-
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
|
archive = [self openArchiveWithIRI: IRI
type: type
mode: mode
encoding: encoding];
#ifdef OF_MACOS
if ([IRI.scheme isEqual: @"file"]) {
@try {
OFString *attributeName = @"com.apple.quarantine";
@try {
OFString *attributeName =
@"com.apple.quarantine";
_quarantine = [[[OFFileManager defaultManager]
extendedAttributeDataForName: attributeName
ofItemAtIRI: IRI] retain];
} @catch (OFGetItemAttributesFailedException *e) {
if (e.errNo != /*ENOATTR*/ 93)
@throw e;
_quarantine = [[[OFFileManager defaultManager]
extendedAttributeDataForName: attributeName
ofItemAtIRI: IRI] retain];
} @catch (OFGetItemAttributesFailedException *e) {
if (e.errNo != /*ENOATTR*/ 93)
@throw e;
}
}
#endif
if (outputDir != nil) {
OFFileManager *fileManager =
[OFFileManager defaultManager];
|
︙ | | |