Comment: | Merge branch 'master' into 1.0 |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | 1.0 |
Files: | files | file ages | folders |
SHA3-256: |
11e303eb3be475958577f5eaa0f4d72b |
User & Date: | js on 2019-12-15 15:37:07 |
Other Links: | branch diff | manifest | tags |
2019-12-15
| ||
15:37 | Remove OFThreadPool check-in: 38cf0b9cef user: js tags: 1.0 | |
15:37 | Merge branch 'master' into 1.0 check-in: 11e303eb3b user: js tags: 1.0 | |
14:42 | Make +[OFSecureData isSecure] per instance check-in: 60caadeb5d user: js tags: trunk | |
2019-09-29
| ||
19:57 | Merge branch 'master' into 1.0 check-in: 76245b4665 user: js tags: 1.0 | |
Modified .travis.yml from [2b9da8daec] to [a4ba9a887a].
︙ | ︙ | |||
25 26 27 28 29 30 31 32 33 34 35 36 37 38 | sudo: required - os: linux compiler: clang dist: trusty sudo: required # macOS - os: osx osx_image: xcode10.2 language: objective-c env: - no32bit=1 - os: osx osx_image: xcode10.1 | > > > > > > > > > > > > > > > > > > > > > > > | 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 | sudo: required - os: linux compiler: clang dist: trusty sudo: required # macOS - os: osx osx_image: xcode11.2 language: objective-c env: - no32bit=1 - noruntime=1 # Broken compiler in this version of Xcode - os: osx osx_image: xcode11.1 language: objective-c env: - no32bit=1 - noruntime=1 # Broken compiler in this version of Xcode - os: osx osx_image: xcode11 language: objective-c env: - no32bit=1 - noruntime=1 # Broken compiler in this version of Xcode - os: osx osx_image: xcode10.3 language: objective-c env: - no32bit=1 - os: osx osx_image: xcode10.2 language: objective-c env: - no32bit=1 - os: osx osx_image: xcode10.1 |
︙ | ︙ | |||
62 63 64 65 66 67 68 69 70 71 72 73 74 75 | osx_image: xcode8 language: objective-c - os: osx osx_image: xcode7.3 language: objective-c # iOS - os: osx osx_image: xcode9.4 language: objective-c env: - config=ios - os: osx osx_image: xcode9.3 | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | osx_image: xcode8 language: objective-c - os: osx osx_image: xcode7.3 language: objective-c # iOS - os: osx osx_image: xcode11.2 language: objective-c env: - config=ios - os: osx osx_image: xcode11.1 language: objective-c env: - config=ios - os: osx osx_image: xcode11 language: objective-c env: - config=ios - os: osx osx_image: xcode10.3 language: objective-c env: - config=ios - os: osx osx_image: xcode10.2 language: objective-c env: - config=ios - os: osx osx_image: xcode10.1 language: objective-c env: - config=ios - os: osx osx_image: xcode10 language: objective-c env: - config=ios - os: osx osx_image: xcode9.4 language: objective-c env: - config=ios - os: osx osx_image: xcode9.3 |
︙ | ︙ | |||
104 105 106 107 108 109 110 | - os: osx osx_image: xcode7.3 language: objective-c env: - config=ios # AmigaOS | | | | | < | | | | | 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 | - os: osx osx_image: xcode7.3 language: objective-c env: - config=ios # AmigaOS - os: linux dist: trusty env: - config=amigaos # Nintendo 3DS - os: linux dist: trusty env: - config=nintendo_3ds # Nintendo DS - os: linux dist: trusty env: - config=nintendo_ds # Nintendo Wii - os: linux dist: trusty env: - config=wii before_install: - if [ "$TRAVIS_OS_NAME" = "linux" -a -z "$config" ]; then if ! sudo apt-get -qq update >/tmp/apt_log 2>&1; then cat /tmp/apt_log; exit 1; fi; |
︙ | ︙ | |||
234 235 236 237 238 239 240 | build_mac_32_64 --disable-threads --disable-sockets; build_mac_32_64 --disable-threads --disable-files; build_mac_32_64 --disable-threads --disable-sockets --disable-files; build_mac_32_64 --disable-sockets; build_mac_32_64 --disable-sockets --disable-files; build_mac_32_64 --disable-files; build_mac_32_64 --disable-shared; | > | | | | | | > | | | | > | | | > > | | | 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 | build_mac_32_64 --disable-threads --disable-sockets; build_mac_32_64 --disable-threads --disable-files; build_mac_32_64 --disable-threads --disable-sockets --disable-files; build_mac_32_64 --disable-sockets; build_mac_32_64 --disable-sockets --disable-files; build_mac_32_64 --disable-files; build_mac_32_64 --disable-shared; if [ -z "$noruntime" ]; then build_mac_32_64 --enable-runtime; build_mac_32_64 --enable-runtime --enable-seluid24; build_mac_32_64 --enable-runtime --disable-threads; build_mac_32_64 --enable-runtime --disable-threads --disable-sockets; build_mac_32_64 --enable-runtime --disable-threads --disable-files; build_mac_32_64 --enable-runtime --disable-threads --disable-sockets --disable-files; build_mac_32_64 --enable-runtime --disable-sockets; build_mac_32_64 --enable-runtime --disable-sockets --disable-files; build_mac_32_64 --enable-runtime --disable-files; build_mac_32_64 --enable-runtime --disable-shared; build_mac_32_64 --enable-runtime --disable-shared --enable-seluid24; fi; fi - if [ "$config" = "ios" ]; then if xcodebuild -version | grep 'Xcode 6' >/dev/null; then export CPPFLAGS="-D_Nullable=__nullable -D_Nonnull=__nonnull -D_Null_unspecified=__null_unspecified"; fi; export IPHONEOS_DEPLOYMENT_TARGET="9.0"; clang="clang -isysroot $(xcrun --sdk iphoneos --show-sdk-path)"; export OBJC="$clang -arch armv7 -arch arm64"; export OBJCPP="$clang -arch armv7 -E"; build --host=arm-apple-darwin --enable-static; sysroot="$(xcrun --sdk iphonesimulator --show-sdk-path)"; clang="clang -isysroot $sysroot"; export OBJC="$clang -arch i386 -arch x86_64"; export OBJCPP="$clang -arch i386 -E"; build WRAPPER=true --host=i386-apple-darwin --enable-static; fi - if [ "$config" = "amigaos" ]; then export PATH="/opt/amiga/bin:$PATH"; |
︙ | ︙ |
Modified README.md from [a3fc1bdda7] to [0c9a55fe73].
︙ | ︙ | |||
49 50 51 52 53 54 55 | ### Building as a framework When building for macOS or iOS, everything is built as a `.framework` by default if `--disable-shared` has not been specified to `configure`. To build for iOS, use something like this: | | | | | | 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 | ### Building as a framework When building for macOS or iOS, everything is built as a `.framework` by default if `--disable-shared` has not been specified to `configure`. To build for iOS, use something like this: $ clang="clang -isysroot $(xcrun --sdk iphoneos --show-sdk-path)" $ export OBJC="$clang -arch armv7 -arch arm64" $ export OBJCPP="$clang -arch armv7 -E" $ export IPHONEOS_DEPLOYMENT_TARGET="9.0" $ ./configure --prefix=/usr/local/ios --host=arm-apple-darwin To build for the iOS simulator, use something like this: $ clang="clang -isysroot $(xcrun --sdk iphonesimulator --show-sdk-path)" $ export OBJC="$clang -arch i386 -arch x86_64" $ export OBJCPP="$clang -arch i386 -E" $ export IPHONEOS_DEPLOYMENT_TARGET="9.0" $ ./configure --prefix=/usr/local/iossim --host=i386-apple-darwin ### Using the macOS or iOS framework in Xcode To use the macOS framework in Xcode, you need to add the `.framework`s to your project and add the following flags to `Other C Flags`: |
︙ | ︙ |
Modified configure.ac from [d5db25efd9] to [112940991b].
1 2 3 4 5 6 7 | AC_INIT(ObjFW, 1.0, js@heap.zone) 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, 0, [The minor version of ObjFW]) | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | AC_INIT(ObjFW, 1.0, js@heap.zone) 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, 0, [The minor version of ObjFW]) AC_SUBST(BUNDLE_VERSION, 1.0.0) AC_SUBST(BUNDLE_SHORT_VERSION, 1.0) 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!]) ]) |
︙ | ︙ | |||
1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 | msdosdjgpp*) dnl DJGPP has the type, but it's not really usable. ;; *) AC_CHECK_TYPE(off64_t, [ AC_DEFINE(OF_HAVE_OFF64_T, 1, [Whether we have off64_t]) ]) ;; esac AC_CHECK_HEADERS([pwd.h grp.h]) AC_CHECK_FUNC(chmod, [ AC_DEFINE(OF_HAVE_CHMOD, 1, [Whether we have chmod()]) | > | 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 | msdosdjgpp*) dnl DJGPP has the type, but it's not really usable. ;; *) AC_CHECK_TYPE(off64_t, [ AC_DEFINE(OF_HAVE_OFF64_T, 1, [Whether we have off64_t]) AC_CHECK_FUNCS([lseek64 lstat64 open64 stat64]) ]) ;; esac AC_CHECK_HEADERS([pwd.h grp.h]) AC_CHECK_FUNC(chmod, [ AC_DEFINE(OF_HAVE_CHMOD, 1, [Whether we have chmod()]) |
︙ | ︙ |
Modified extra.mk.in from [c2430594e6] to [6a46caddbb].
1 2 3 4 5 6 7 8 9 10 11 12 | OBJFW_SHARED_LIB = @OBJFW_SHARED_LIB@ OBJFW_STATIC_LIB = @OBJFW_STATIC_LIB@ OBJFW_FRAMEWORK = @OBJFW_FRAMEWORK@ # When changing: Be sure to also change these in the Xcode project! OBJFW_LIB_MAJOR = 9 OBJFW_LIB_MINOR = 0 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_AMIGA_LIB = @OBJFWRT_AMIGA_LIB@ | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | OBJFW_SHARED_LIB = @OBJFW_SHARED_LIB@ OBJFW_STATIC_LIB = @OBJFW_STATIC_LIB@ OBJFW_FRAMEWORK = @OBJFW_FRAMEWORK@ # When changing: Be sure to also change these in the Xcode project! OBJFW_LIB_MAJOR = 9 OBJFW_LIB_MINOR = 0 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_AMIGA_LIB = @OBJFWRT_AMIGA_LIB@ OBJFWRT_LIB_MAJOR = 1 OBJFWRT_LIB_MINOR = 0 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@ |
︙ | ︙ |
Modified src/Makefile from [04a46c14e4] to [32504c7040].
︙ | ︙ | |||
24 25 26 27 28 29 30 | OFDictionary.m \ OFEnumerator.m \ OFFileManager.m \ OFGZIPStream.m \ OFHMAC.m \ OFInflate64Stream.m \ OFInflateStream.m \ | < | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | OFDictionary.m \ OFEnumerator.m \ OFFileManager.m \ OFGZIPStream.m \ OFHMAC.m \ OFInflate64Stream.m \ OFInflateStream.m \ OFInvocation.m \ OFLHAArchive.m \ OFLHAArchiveEntry.m \ OFList.m \ OFLocale.m \ OFMapTable.m \ OFMD5Hash.m \ |
︙ | ︙ | |||
119 120 121 122 123 124 125 | ${USE_SRCS_WINDOWS} SRCS_FILES = OFFile.m \ OFINICategory.m \ OFINIFile.m \ OFSettings.m \ OFString+PathAdditions.m SRCS_PLUGINS = OFPlugin.m | | > > | 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | ${USE_SRCS_WINDOWS} SRCS_FILES = OFFile.m \ OFINICategory.m \ OFINIFile.m \ OFSettings.m \ OFString+PathAdditions.m SRCS_PLUGINS = OFPlugin.m SRCS_SOCKETS = OFDNSQuery.m \ OFDNSResolver.m \ OFDNSResourceRecord.m \ OFDNSResponse.m \ OFHTTPClient.m \ OFHTTPCookie.m \ OFHTTPCookieManager.m \ OFHTTPRequest.m \ OFHTTPResponse.m \ OFHTTPServer.m \ OFStreamSocket.m \ |
︙ | ︙ | |||
195 196 197 198 199 200 201 | OFSubarray.m \ OFUTF8String.m \ ${AUTORELEASE_M} \ ${INSTANCE_M} \ ${LIBBASES_M} SRCS_FILES += OFFileURLHandler.m \ OFINIFileSettings.m | > | > | 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | OFSubarray.m \ OFUTF8String.m \ ${AUTORELEASE_M} \ ${INSTANCE_M} \ ${LIBBASES_M} SRCS_FILES += OFFileURLHandler.m \ OFINIFileSettings.m SRCS_SOCKETS += OFDNSResolverSettings.m \ OFHTTPURLHandler.m \ OFHostAddressResolver.m \ OFKernelEventObserver.m \ ${OFEPOLLKERNELEVENTOBSERVER_M} \ ${OFKQUEUEKERNELEVENTOBSERVER_M} \ ${OFPOLLKERNELEVENTOBSERVER_M} \ ${OFSELECTKERNELEVENTOBSERVER_M} OBJS_EXTRA = ${RUNTIME_RUNTIME_A} \ |
︙ | ︙ |
Modified src/OFAdjacentArray.h from [cebe5ad233] to [6f24e09a18].
︙ | ︙ | |||
17 18 19 20 21 22 23 | #import "OFArray.h" OF_ASSUME_NONNULL_BEGIN @class OFMutableData; | < | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #import "OFArray.h" OF_ASSUME_NONNULL_BEGIN @class OFMutableData; @interface OFAdjacentArray: OFArray { OFMutableData *_array; } @end OF_ASSUME_NONNULL_END |
Modified src/OFAdjacentSubarray.h from [bd17bec51a] to [089d0764c2].
︙ | ︙ | |||
15 16 17 18 19 20 21 | * file. */ #import "OFSubarray.h" OF_ASSUME_NONNULL_BEGIN | < | 15 16 17 18 19 20 21 22 23 24 25 | * file. */ #import "OFSubarray.h" OF_ASSUME_NONNULL_BEGIN @interface OFAdjacentSubarray: OFSubarray @end OF_ASSUME_NONNULL_END |
Modified src/OFApplication.h from [93b516bfa0] to [1ecf36756b].
︙ | ︙ | |||
126 127 128 129 130 131 132 | @interface OFApplication: OFObject { OFString *_programName; OFArray OF_GENERIC(OFString *) *_arguments; OFMutableDictionary OF_GENERIC(OFString *, OFString *) *_environment; int *_argc; char ***_argv; | < < < | 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | @interface OFApplication: OFObject { OFString *_programName; OFArray OF_GENERIC(OFString *) *_arguments; OFMutableDictionary OF_GENERIC(OFString *, OFString *) *_environment; int *_argc; char ***_argv; id <OFApplicationDelegate> _Nullable _delegate; void (*_Nullable _SIGINTHandler)(id, SEL); #ifndef OF_WINDOWS void (*_Nullable _SIGHUPHandler)(id, SEL); void (*_Nullable _SIGUSR1Handler)(id, SEL); void (*_Nullable _SIGUSR2Handler)(id, SEL); #endif |
︙ | ︙ |
Modified src/OFApplication.m from [c0cd7cc60a] to [641d94e4fd].
︙ | ︙ | |||
13 14 15 16 17 18 19 | * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" | < < | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <signal.h> |
︙ | ︙ | |||
97 98 99 100 101 102 103 | [delegate release]; #if defined(OF_HAVE_THREADS) && defined(OF_HAVE_SOCKETS) && defined(OF_AMIGAOS) of_socket_deinit(); #endif } | < < < < < < < < < < < < < < < < < < < | 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | [delegate release]; #if defined(OF_HAVE_THREADS) && defined(OF_HAVE_SOCKETS) && defined(OF_AMIGAOS) of_socket_deinit(); #endif } int of_application_main(int *argc, char **argv[], id <OFApplicationDelegate> delegate) { #ifdef OF_WINDOWS wchar_t **wargv, **wenvp; int wargc, si = 0; |
︙ | ︙ | |||
154 155 156 157 158 159 160 161 162 163 164 165 166 167 | @implementation OFApplication @synthesize programName = _programName, arguments = _arguments; @synthesize environment = _environment; #ifdef OF_HAVE_SANDBOX @synthesize activeSandbox = _activeSandbox; @synthesize activeSandboxForChildProcesses = _activeSandboxForChildProcesses; #endif + (OFApplication *)sharedApplication { return app; } + (OFString *)programName | > > > > > > > > > > > > > > > > > > > | 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 | @implementation OFApplication @synthesize programName = _programName, arguments = _arguments; @synthesize environment = _environment; #ifdef OF_HAVE_SANDBOX @synthesize activeSandbox = _activeSandbox; @synthesize activeSandboxForChildProcesses = _activeSandboxForChildProcesses; #endif #define SIGNAL_HANDLER(signal) \ static void \ handle##signal(int sig) \ { \ app->_##signal##Handler(app->_delegate, \ @selector(applicationDidReceive##signal)); \ } SIGNAL_HANDLER(SIGINT) #ifdef SIGHUP SIGNAL_HANDLER(SIGHUP) #endif #ifdef SIGUSR1 SIGNAL_HANDLER(SIGUSR1) #endif #ifdef SIGUSR2 SIGNAL_HANDLER(SIGUSR2) #endif #undef SIGNAL_HANDLER + (OFApplication *)sharedApplication { return app; } + (OFString *)programName |
︙ | ︙ |
Added src/OFArray+Private.h version [a806faad1b].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | /* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, * 2018, 2019 * Jonathan Schleifer <js@heap.zone> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFArray.h" OF_ASSUME_NONNULL_BEGIN @interface OFArrayEnumerator: OFEnumerator { OFArray *_array; size_t _count; unsigned long _mutations; unsigned long *_Nullable _mutationsPtr; size_t _position; } - (instancetype)initWithArray: (OFArray *)data mutationsPtr: (nullable unsigned long *)mutationsPtr; @end OF_ASSUME_NONNULL_END |
Modified src/OFArray.h from [72663abff1] to [3219a87afc].
︙ | ︙ | |||
88 89 90 91 92 93 94 | * @brief An abstract class for storing objects in an array. * * @note Subclasses must implement @ref count and @ref objectAtIndex:. */ @interface OFArray OF_GENERIC(ObjectType): OFObject <OFCopying, OFMutableCopying, OFCollection, OFSerialization, OFJSONRepresentation, OFMessagePackRepresentation> | < < < < | 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | * @brief An abstract class for storing objects in an array. * * @note Subclasses must implement @ref count and @ref objectAtIndex:. */ @interface OFArray OF_GENERIC(ObjectType): OFObject <OFCopying, OFMutableCopying, OFCollection, OFSerialization, OFJSONRepresentation, OFMessagePackRepresentation> #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) # define ObjectType id #endif /*! * @brief The objects of the array as a C array. * * The result is valid until the autorelease pool is released. If you want to |
︙ | ︙ | |||
492 493 494 495 496 497 498 | - (nullable id)foldUsingBlock: (of_array_fold_block_t)block; #endif #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) # undef ObjectType #endif @end | < < < < < < < < < < < < < | 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 | - (nullable id)foldUsingBlock: (of_array_fold_block_t)block; #endif #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) # undef ObjectType #endif @end OF_ASSUME_NONNULL_END #import "OFMutableArray.h" #if !defined(NSINTEGER_DEFINED) && !__has_feature(modules) /* Required for array literals to work */ @compatibility_alias NSArray OFArray; #endif |
Modified src/OFArray.m from [b12c539371] to [9bb6a6b4d8].
︙ | ︙ | |||
19 20 21 22 23 24 25 26 27 28 29 30 31 32 | #include <stdarg.h> #include <stdlib.h> #include <assert.h> #import "OFArray.h" #import "OFAdjacentArray.h" #import "OFData.h" #import "OFNull.h" #import "OFString.h" #import "OFSubarray.h" #import "OFXMLElement.h" | > | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #include <stdarg.h> #include <stdlib.h> #include <assert.h> #import "OFArray.h" #import "OFArray+Private.h" #import "OFAdjacentArray.h" #import "OFData.h" #import "OFNull.h" #import "OFString.h" #import "OFSubarray.h" #import "OFXMLElement.h" |
︙ | ︙ |
Modified src/OFBitSetCharacterSet.h from [0f5e448e50] to [354358342b].
︙ | ︙ | |||
15 16 17 18 19 20 21 | * file. */ #import "OFCharacterSet.h" OF_ASSUME_NONNULL_BEGIN | < | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | * file. */ #import "OFCharacterSet.h" OF_ASSUME_NONNULL_BEGIN @interface OFBitSetCharacterSet: OFCharacterSet { unsigned char *_bitset; size_t _size; } @end OF_ASSUME_NONNULL_END |
Modified src/OFBlock.m from [acebb38475] to [b86036ff7d].
︙ | ︙ | |||
67 68 69 70 71 72 73 | @protocol RetainRelease - (instancetype)retain; - (void)release; @end #ifdef OF_OBJFW_RUNTIME /* Begin of ObjC module */ | | < | > | | | > | | | | | | > | | | | | | > | | | | 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 | @protocol RetainRelease - (instancetype)retain; - (void)release; @end #ifdef OF_OBJFW_RUNTIME /* Begin of ObjC module */ static struct objc_class _NSConcreteStackBlock_metaclass = { Nil, Nil, "OFStackBlock", 8, OBJC_CLASS_INFO_METACLASS, sizeof(_NSConcreteStackBlock_metaclass), NULL, NULL }; struct objc_class _NSConcreteStackBlock = { &_NSConcreteStackBlock_metaclass, (Class)(void *)"OFBlock", "OFStackBlock", 8, OBJC_CLASS_INFO_CLASS, sizeof(of_block_literal_t), NULL, NULL }; static struct objc_class _NSConcreteGlobalBlock_metaclass = { Nil, Nil, "OFGlobalBlock", 8, OBJC_CLASS_INFO_METACLASS, sizeof(_NSConcreteGlobalBlock_metaclass), NULL, NULL }; struct objc_class _NSConcreteGlobalBlock = { &_NSConcreteGlobalBlock_metaclass, (Class)(void *)"OFBlock", "OFGlobalBlock", 8, OBJC_CLASS_INFO_CLASS, sizeof(of_block_literal_t), NULL, NULL }; static struct objc_class _NSConcreteMallocBlock_metaclass = { Nil, Nil, "OFMallocBlock", 8, OBJC_CLASS_INFO_METACLASS, sizeof(_NSConcreteMallocBlock_metaclass), NULL, NULL }; struct objc_class _NSConcreteMallocBlock = { &_NSConcreteMallocBlock_metaclass, (Class)(void *)"OFBlock", "OFMallocBlock", 8, OBJC_CLASS_INFO_CLASS, sizeof(of_block_literal_t), NULL, NULL }; static struct { unsigned long unknown; struct objc_selector *selectorRefs; uint16_t classDefsCount, categoryDefsCount; void *defs[4]; } symtab = { 0, NULL, 3, 0, { &_NSConcreteStackBlock, &_NSConcreteGlobalBlock, &_NSConcreteMallocBlock, NULL } }; static struct objc_module module = { 8, sizeof(module), NULL, (struct objc_symtab *)&symtab }; OF_CONSTRUCTOR() { __objc_exec_class(&module); } /* End of ObjC module */ |
︙ | ︙ |
Modified src/OFBytesValue.h from [12d8c96477] to [064f02062a].
︙ | ︙ | |||
15 16 17 18 19 20 21 | * file. */ #import "OFValue.h" OF_ASSUME_NONNULL_BEGIN | < | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | * file. */ #import "OFValue.h" OF_ASSUME_NONNULL_BEGIN @interface OFBytesValue: OFValue { size_t _size; void *_bytes; const char *_objCType; } @end OF_ASSUME_NONNULL_END |
Modified src/OFColor.m from [1d58b7ab36] to [9416cbb4f4].
︙ | ︙ | |||
58 59 60 61 62 63 64 65 66 67 68 69 70 71 | return self; } - (bool)isEqual: (id)object { OFColor *other; if (![object isKindOfClass: [OFColor class]]) return false; other = object; if (other->_red != _red) | > > > | 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | return self; } - (bool)isEqual: (id)object { OFColor *other; if (object == self) return true; if (![object isKindOfClass: [OFColor class]]) return false; other = object; if (other->_red != _red) |
︙ | ︙ |
Modified src/OFCountedMapTableSet.h from [54cdfe273c] to [425da1187b].
︙ | ︙ | |||
17 18 19 20 21 22 23 | #import "OFCountedSet.h" OF_ASSUME_NONNULL_BEGIN @class OFMapTable; | < | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #import "OFCountedSet.h" OF_ASSUME_NONNULL_BEGIN @class OFMapTable; @interface OFCountedMapTableSet: OFCountedSet { OFMapTable *_mapTable; } @end OF_ASSUME_NONNULL_END |
Modified src/OFCountedSet.h from [2ecebf0177] to [4abf7110e4].
︙ | ︙ | |||
44 45 46 47 48 49 50 | * of @ref OFSet and @ref OFMutableSet that need to be implemented. */ @interface OFCountedSet OF_GENERIC(ObjectType): OFMutableSet OF_GENERIC(ObjectType) #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) # define ObjectType id #endif | < < < < | 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | * of @ref OFSet and @ref OFMutableSet that need to be implemented. */ @interface OFCountedSet OF_GENERIC(ObjectType): OFMutableSet OF_GENERIC(ObjectType) #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) # define ObjectType id #endif /*! * @brief Returns how often the object is in the set. * * @return How often the object is in the set */ - (size_t)countForObject: (ObjectType)object; |
︙ | ︙ |
Added src/OFDNSQuery.h version [823e60afdb].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | /* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, * 2018, 2019 * Jonathan Schleifer <js@heap.zone> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFObject.h" #import "OFDNSResourceRecord.h" OF_ASSUME_NONNULL_BEGIN @class OFString; /*! * @class OFDNSQuery OFDNSQuery.h ObjFW/OFDNSQuery.h * * @brief A class representing a DNS query. */ @interface OFDNSQuery: OFObject <OFCopying> { OFString *_domainName; of_dns_class_t _DNSClass; of_dns_record_type_t _recordType; OF_RESERVE_IVARS(4) } /*! * @brief The domain name of the query. */ @property (readonly, nonatomic) OFString *domainName; /*! * @brief The DNS class of the query. */ @property (readonly, nonatomic) of_dns_class_t DNSClass; /*! * @brief The record type of the query. */ @property (readonly, nonatomic) of_dns_record_type_t recordType; /*! * @brief Creates a new, autoreleased OFDNSQuery. * * @param domainName The domain name to query * @param DNSClass The DNS class of the query * @param recordType The record type of the query * @return A new, autoreleased OFDNSQuery */ + (instancetype)queryWithDomainName: (OFString *)domainName DNSClass: (of_dns_class_t)DNSClass recordType: (of_dns_record_type_t)recordType; /*! * @brief Initializes an already allocated OFDNSQuery. * * @param domainName The domain name to query * @param DNSClass The DNS class of the query * @param recordType The record type of the query * @return An initialized OFDNSQuery */ - (instancetype)initWithDomainName: (OFString *)domainName DNSClass: (of_dns_class_t)DNSClass recordType: (of_dns_record_type_t)recordType OF_DESIGNATED_INITIALIZER; - (instancetype)init OF_UNAVAILABLE; @end OF_ASSUME_NONNULL_END |
Added src/OFDNSQuery.m version [e62571f4f4].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | /* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, * 2018, 2019 * Jonathan Schleifer <js@heap.zone> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #import "OFDNSQuery.h" #import "OFString.h" @implementation OFDNSQuery @synthesize domainName = _domainName, DNSClass = _DNSClass; @synthesize recordType = _recordType; + (instancetype)queryWithDomainName: (OFString *)domainName DNSClass: (of_dns_class_t)DNSClass recordType: (of_dns_record_type_t)recordType { return [[[self alloc] initWithDomainName: domainName DNSClass: DNSClass recordType: recordType] autorelease]; } - (instancetype)initWithDomainName: (OFString *)domainName DNSClass: (of_dns_class_t)DNSClass recordType: (of_dns_record_type_t)recordType { self = [super init]; @try { void *pool = objc_autoreleasePoolPush(); if (![domainName hasSuffix: @"."]) domainName = [domainName stringByAppendingString: @"."]; _domainName = [domainName copy]; _DNSClass = DNSClass; _recordType = recordType; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; } return self; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (void)dealloc { [_domainName release]; [super dealloc]; } - (bool)isEqual: (id)object { OFDNSQuery *query; if (object == self) return true; if (![object isKindOfClass: [OFDNSQuery class]]) return false; query = object; if (query->_domainName != _domainName && ![query->_domainName isEqual: _domainName]) return false; if (query->_DNSClass != _DNSClass) return false; if (query->_recordType != _recordType) return false; return true; } - (uint32_t)hash { uint32_t hash; OF_HASH_INIT(hash); OF_HASH_ADD_HASH(hash, _domainName.hash); OF_HASH_ADD(hash, _DNSClass); OF_HASH_ADD(hash, _recordType); OF_HASH_FINALIZE(hash); return hash; } - (id)copy { return [self retain]; } - (OFString *)description { return [OFString stringWithFormat: @"<%@ %@ %@ %@>", self.className, _domainName, of_dns_class_to_string(_DNSClass), of_dns_record_type_to_string(_recordType)]; } @end |
Modified src/OFDNSResolver.h from [7a80eed2c3] to [e885685095].
︙ | ︙ | |||
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFObject.h" #import "OFDNSResourceRecord.h" #import "OFRunLoop.h" #import "OFString.h" OF_ASSUME_NONNULL_BEGIN #define OF_DNS_RESOLVER_BUFFER_LENGTH 512 @class OFArray OF_GENERIC(ObjectType); @class OFDNSResolver; | > > | > | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFObject.h" #import "OFDNSQuery.h" #import "OFDNSResourceRecord.h" #import "OFDNSResponse.h" #import "OFRunLoop.h" #import "OFString.h" OF_ASSUME_NONNULL_BEGIN #define OF_DNS_RESOLVER_BUFFER_LENGTH 512 @class OFArray OF_GENERIC(ObjectType); @class OFDNSResolver; @class OFDNSResolverContext; @class OFDNSResolverSettings; @class OFDate; @class OFDictionary OF_GENERIC(KeyType, ObjectType); @class OFMutableDictionary OF_GENERIC(KeyType, ObjectType); @class OFNumber; @class OFUDPSocket; /*! |
︙ | ︙ | |||
60 61 62 63 64 65 66 | OF_DNS_RESOLVER_ERROR_SERVER_NAME_ERROR, /*! The server does not have support for the requested query */ OF_DNS_RESOLVER_ERROR_SERVER_NOT_IMPLEMENTED, /*! The server refused the query */ OF_DNS_RESOLVER_ERROR_SERVER_REFUSED } of_dns_resolver_error_t; | < < < | | | < | | | < < < < < | | | < < | > > > > > > > | | | | | | | | < | < < < < < < < < | | 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 | OF_DNS_RESOLVER_ERROR_SERVER_NAME_ERROR, /*! The server does not have support for the requested query */ OF_DNS_RESOLVER_ERROR_SERVER_NOT_IMPLEMENTED, /*! The server refused the query */ OF_DNS_RESOLVER_ERROR_SERVER_REFUSED } of_dns_resolver_error_t; /*! * @protocol OFDNSResolverQueryDelegate OFDNSResolver.h ObjFW/OFDNSResolver.h * * @brief A delegate for performed DNS queries. */ @protocol OFDNSResolverQueryDelegate <OFObject> /*! * @brief This method is called when a DNS resolver performed a query. * * @param resolver The acting resolver * @param query The query performed by the resolver * @param response The response from the DNS server, or nil on error * @param exception An exception that happened during resolving, or nil on * success */ - (void)resolver: (OFDNSResolver *)resolver didPerformQuery: (OFDNSQuery *)query response: (nullable OFDNSResponse *)response exception: (nullable id)exception; @end /*! * @protocol OFDNSResolverQueryDelegate OFDNSResolver.h ObjFW/OFDNSResolver.h * * @brief A delegate for resolved hosts. */ @protocol OFDNSResolverHostDelegate <OFObject> /*! * @brief This method is called when a DNS resolver resolved a host to * addresses. * * @param resolver The acting resolver * @param host The host the resolver resolved * @param addresses OFData containing several of_socket_address_t * @param exception The exception that occurred during resolving, or nil on * success */ - (void)resolver: (OFDNSResolver *)resolver didResolveHost: (OFString *)host addresses: (nullable OFData *)addresses exception: (nullable id)exception; @end /*! * @class OFDNSResolver OFDNSResolver.h ObjFW/OFDNSResolver.h * * @brief A class for resolving DNS names. * * @note If you change any of the properties, make sure to set * @ref configReloadInterval to 0, as otherwise your changes will be * reverted back to the system configuration on the next periodic config * reload. */ OF_SUBCLASSING_RESTRICTED @interface OFDNSResolver: OFObject { OFDNSResolverSettings *_settings; OFUDPSocket *_IPv4Socket; #ifdef OF_HAVE_IPV6 OFUDPSocket *_IPv6Socket; #endif char _buffer[OF_DNS_RESOLVER_BUFFER_LENGTH]; OFMutableDictionary OF_GENERIC(OFNumber *, OFDNSResolverContext *) *_queries; } /*! * @brief A dictionary of static hosts. * * This dictionary is checked before actually looking up a host. |
︙ | ︙ | |||
205 206 207 208 209 210 211 | /*! * @brief Initializes an already allocated OFDNSResolver. */ - (instancetype)init; /*! | | | | | | < < < < < < < < < | < < < < < < | < < | | | | < | | < | < | | < | | < | | < | | 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | /*! * @brief Initializes an already allocated OFDNSResolver. */ - (instancetype)init; /*! * @brief Asynchronously performs the specified query. * * @param query The query to perform * @param delegate The delegate to use for callbacks */ - (void)asyncPerformQuery: (OFDNSQuery *)query delegate: (id <OFDNSResolverQueryDelegate>)delegate; /*! * @brief Asynchronously performs the specified query. * * @param query The query to perform * @param runLoopMode The run loop mode in which to resolve * @param delegate The delegate to use for callbacks */ - (void)asyncPerformQuery: (OFDNSQuery *)query runLoopMode: (of_run_loop_mode_t)runLoopMode delegate: (id <OFDNSResolverQueryDelegate>)delegate; /*! * @brief Asynchronously resolves the specified host to socket addresses. * * @param host The host to resolve * @param delegate The delegate to use for callbacks */ - (void)asyncResolveAddressesForHost: (OFString *)host delegate: (id <OFDNSResolverHostDelegate>)delegate; /*! * @brief Asynchronously resolves the specified host to socket addresses. * * @param host The host to resolve * @param addressFamily The desired socket address family * @param delegate The delegate to use for callbacks */ - (void)asyncResolveAddressesForHost: (OFString *)host addressFamily: (of_socket_address_family_t)addressFamily delegate: (id <OFDNSResolverHostDelegate>)delegate; /*! * @brief Asynchronously resolves the specified host to socket addresses. * * @param host The host to resolve * @param addressFamily The desired socket address family * @param runLoopMode The run loop mode in which to resolve * @param delegate The delegate to use for callbacks */ - (void)asyncResolveAddressesForHost: (OFString *)host addressFamily: (of_socket_address_family_t)addressFamily runLoopMode: (of_run_loop_mode_t)runLoopMode delegate: (id <OFDNSResolverHostDelegate>)delegate; /*! * @brief Synchronously resolves the specified host to socket addresses. * * @param host The host to resolve * @param addressFamily The desired socket address family * @return OFData containing several of_socket_address_t */ - (OFData *)resolveAddressesForHost: (OFString *)host addressFamily: (of_socket_address_family_t)addressFamily; /*! * @brief Closes all sockets and cancels all ongoing queries. */ - (void)close; @end OF_ASSUME_NONNULL_END |
Modified src/OFDNSResolver.m from [77dfb36f29] to [dfbdc81c03].
︙ | ︙ | |||
13 14 15 16 17 18 19 | * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" | < < | > > | < < < < > < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < | < < < < < < | | < < | | < < | < < < | | < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #include <string.h> #import "OFDNSResolver.h" #import "OFArray.h" #import "OFDNSQuery.h" #import "OFDNSResolverSettings.h" #import "OFDNSResponse.h" #import "OFData.h" #import "OFDate.h" #import "OFDictionary.h" #import "OFHostAddressResolver.h" #import "OFNumber.h" #import "OFPair.h" #import "OFString.h" #import "OFTimer.h" #import "OFUDPSocket.h" #import "OFUDPSocket+Private.h" #import "OFDNSQueryFailedException.h" #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFInvalidServerReplyException.h" #import "OFOutOfRangeException.h" #import "OFTruncatedDataException.h" #ifndef SOCK_DNS # define SOCK_DNS 0 #endif #define BUFFER_LENGTH OF_DNS_RESOLVER_BUFFER_LENGTH /* * RFC 1035 doesn't specify if pointers to pointers are allowed, and if so how * many. Since it's unspecified, we have to assume that it might happen, but we * also want to limit it to avoid DoS. Limiting it to 16 levels of pointers and * immediately rejecting pointers to itself seems like a fair balance. */ #define MAX_ALLOWED_POINTERS 16 #define CNAME_RECURSION 3 /* * TODO: * * - Fallback to TCP */ @interface OFDNSResolver () <OFUDPSocketDelegate> - (void)of_contextTimedOut: (OFDNSResolverContext *)context; @end @interface OFDNSResolverContext: OFObject { @public OFDNSQuery *_query; OFNumber *_ID; OFDNSResolverSettings *_settings; size_t _nameServersIndex; unsigned int _attempt; id <OFDNSResolverQueryDelegate> _delegate; OFData *_queryData; of_socket_address_t _usedNameServer; OFTimer *_cancelTimer; } - (instancetype)initWithQuery: (OFDNSQuery *)query ID: (OFNumber *)ID settings: (OFDNSResolverSettings *)settings delegate: (id <OFDNSResolverQueryDelegate>)delegate; @end static OFString * parseString(const unsigned char *buffer, size_t length, size_t *i) { uint8_t stringLength; OFString *string; |
︙ | ︙ | |||
370 371 372 373 374 375 376 | [components addObject: component]; } while (componentLength > 0); return [components componentsJoinedByString: @"."]; } static OF_KINDOF(OFDNSResourceRecord *) | | | | | < | | | | | | 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 | [components addObject: component]; } while (componentLength > 0); return [components componentsJoinedByString: @"."]; } static OF_KINDOF(OFDNSResourceRecord *) parseResourceRecord(OFString *name, of_dns_class_t DNSClass, of_dns_record_type_t recordType, uint32_t TTL, const unsigned char *buffer, size_t length, size_t i, uint16_t dataLength) { if (recordType == OF_DNS_RECORD_TYPE_A && DNSClass == OF_DNS_CLASS_IN) { of_socket_address_t address; if (dataLength != 4) @throw [OFInvalidServerReplyException exception]; memset(&address, 0, sizeof(address)); address.family = OF_SOCKET_ADDRESS_FAMILY_IPV4; address.length = sizeof(address.sockaddr.in); address.sockaddr.in.sin_family = AF_INET; memcpy(&address.sockaddr.in.sin_addr.s_addr, buffer + i, 4); return [[[OFADNSResourceRecord alloc] initWithName: name address: &address TTL: TTL] autorelease]; } else if (recordType == OF_DNS_RECORD_TYPE_NS) { size_t j = i; OFString *authoritativeHost = parseName(buffer, length, &j, MAX_ALLOWED_POINTERS); if (j != i + dataLength) @throw [OFInvalidServerReplyException exception]; return [[[OFNSDNSResourceRecord alloc] initWithName: name DNSClass: DNSClass authoritativeHost: authoritativeHost TTL: TTL] autorelease]; } else if (recordType == OF_DNS_RECORD_TYPE_CNAME) { size_t j = i; OFString *alias = parseName(buffer, length, &j, MAX_ALLOWED_POINTERS); if (j != i + dataLength) @throw [OFInvalidServerReplyException exception]; return [[[OFCNAMEDNSResourceRecord alloc] initWithName: name DNSClass: DNSClass alias: alias TTL: TTL] autorelease]; } else if (recordType == OF_DNS_RECORD_TYPE_SOA) { size_t j = i; OFString *primaryNameServer = parseName(buffer, length, &j, MAX_ALLOWED_POINTERS); OFString *responsiblePerson; uint32_t serialNumber, refreshInterval, retryInterval; uint32_t expirationInterval, minTTL; |
︙ | ︙ | |||
450 451 452 453 454 455 456 | (buffer[j + 13] << 16) | (buffer[j + 14] << 8) | buffer[j + 15]; minTTL = (buffer[j + 16] << 24) | (buffer[j + 17] << 16) | (buffer[j + 18] << 8) | buffer[j + 19]; return [[[OFSOADNSResourceRecord alloc] initWithName: name | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 | (buffer[j + 13] << 16) | (buffer[j + 14] << 8) | buffer[j + 15]; minTTL = (buffer[j + 16] << 24) | (buffer[j + 17] << 16) | (buffer[j + 18] << 8) | buffer[j + 19]; return [[[OFSOADNSResourceRecord alloc] initWithName: name DNSClass: DNSClass primaryNameServer: primaryNameServer responsiblePerson: responsiblePerson serialNumber: serialNumber refreshInterval: refreshInterval retryInterval: retryInterval expirationInterval: expirationInterval minTTL: minTTL TTL: TTL] autorelease]; } else if (recordType == OF_DNS_RECORD_TYPE_PTR) { size_t j = i; OFString *domainName = parseName(buffer, length, &j, MAX_ALLOWED_POINTERS); if (j != i + dataLength) @throw [OFInvalidServerReplyException exception]; return [[[OFPTRDNSResourceRecord alloc] initWithName: name DNSClass: DNSClass domainName: domainName TTL: TTL] autorelease]; } else if (recordType == OF_DNS_RECORD_TYPE_HINFO) { size_t j = i; OFString *CPU = parseString(buffer, length, &j); OFString *OS; if (j > i + dataLength) @throw [OFInvalidServerReplyException exception]; OS = parseString(buffer, length, &j); if (j != i + dataLength) @throw [OFInvalidServerReplyException exception]; return [[[OFHINFODNSResourceRecord alloc] initWithName: name DNSClass: DNSClass CPU: CPU OS: OS TTL: TTL] autorelease]; } else if (recordType == OF_DNS_RECORD_TYPE_MX) { uint16_t preference; size_t j; OFString *mailExchange; if (dataLength < 2) @throw [OFInvalidServerReplyException exception]; preference = (buffer[i] << 8) | buffer[i + 1]; j = i + 2; mailExchange = parseName(buffer, length, &j, MAX_ALLOWED_POINTERS); if (j != i + dataLength) @throw [OFInvalidServerReplyException exception]; return [[[OFMXDNSResourceRecord alloc] initWithName: name DNSClass: DNSClass preference: preference mailExchange: mailExchange TTL: TTL] autorelease]; } else if (recordType == OF_DNS_RECORD_TYPE_TXT) { OFData *textData = [OFData dataWithItems: &buffer[i] count: dataLength]; return [[[OFTXTDNSResourceRecord alloc] initWithName: name DNSClass: DNSClass textData: textData TTL: TTL] autorelease]; } else if (recordType == OF_DNS_RECORD_TYPE_RP) { size_t j = i; OFString *mailbox = parseName(buffer, length, &j, MAX_ALLOWED_POINTERS); OFString *TXTDomainName; if (j > i + dataLength) @throw [OFInvalidServerReplyException exception]; TXTDomainName = parseName(buffer, length, &j, MAX_ALLOWED_POINTERS); if (j != i + dataLength) @throw [OFInvalidServerReplyException exception]; return [[[OFRPDNSResourceRecord alloc] initWithName: name DNSClass: DNSClass mailbox: mailbox TXTDomainName: TXTDomainName TTL: TTL] autorelease]; } else if (recordType == OF_DNS_RECORD_TYPE_AAAA && DNSClass == OF_DNS_CLASS_IN) { of_socket_address_t address; if (dataLength != 16) @throw [OFInvalidServerReplyException exception]; memset(&address, 0, sizeof(address)); address.family = OF_SOCKET_ADDRESS_FAMILY_IPV6; address.length = sizeof(address.sockaddr.in6); #ifdef AF_INET6 address.sockaddr.in6.sin6_family = AF_INET6; #else address.sockaddr.in6.sin6_family = AF_UNSPEC; #endif memcpy(address.sockaddr.in6.sin6_addr.s6_addr, buffer + i, 16); return [[[OFAAAADNSResourceRecord alloc] initWithName: name address: &address TTL: TTL] autorelease]; } else if (recordType == OF_DNS_RECORD_TYPE_SRV && DNSClass == OF_DNS_CLASS_IN) { uint16_t priority, weight, port; size_t j; OFString *target; if (dataLength < 6) @throw [OFInvalidServerReplyException exception]; priority = (buffer[i] << 8) | buffer[i + 1]; weight = (buffer[i + 2] << 8) | buffer[i + 3]; port = (buffer[i + 4] << 8) | buffer[i + 5]; j = i + 6; target = parseName(buffer, length, &j, MAX_ALLOWED_POINTERS); if (j != i + dataLength) @throw [OFInvalidServerReplyException exception]; return [[[OFSRVDNSResourceRecord alloc] initWithName: name priority: priority weight: weight target: target port: port TTL: TTL] autorelease]; } else return [[[OFDNSResourceRecord alloc] initWithName: name DNSClass: DNSClass recordType: recordType TTL: TTL] autorelease]; } static OFDictionary * parseSection(const unsigned char *buffer, size_t length, size_t *i, uint_fast16_t count) { OFMutableDictionary *ret = [OFMutableDictionary dictionary]; OFEnumerator OF_GENERIC(OFMutableArray *) *objectEnumerator; OFMutableArray *array; for (uint_fast16_t j = 0; j < count; j++) { OFString *name = parseName(buffer, length, i, MAX_ALLOWED_POINTERS); of_dns_class_t DNSClass; of_dns_record_type_t recordType; uint32_t TTL; uint16_t dataLength; OFDNSResourceRecord *record; if (*i + 10 > length) @throw [OFTruncatedDataException exception]; recordType = (buffer[*i] << 16) | buffer[*i + 1]; DNSClass = (buffer[*i + 2] << 16) | buffer[*i + 3]; TTL = (buffer[*i + 4] << 24) | (buffer[*i + 5] << 16) | (buffer[*i + 6] << 8) | buffer[*i + 7]; dataLength = (buffer[*i + 8] << 16) | buffer[*i + 9]; *i += 10; if (*i + dataLength > length) @throw [OFTruncatedDataException exception]; record = parseResourceRecord(name, DNSClass, recordType, TTL, buffer, length, *i, dataLength); *i += dataLength; array = [ret objectForKey: name]; if (array == nil) { array = [OFMutableArray array]; |
︙ | ︙ | |||
655 656 657 658 659 660 661 | [array makeImmutable]; [ret makeImmutable]; return ret; } | < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < | | < < | < < | < < < | < < | < < | | | | | | < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 | [array makeImmutable]; [ret makeImmutable]; return ret; } @implementation OFDNSResolverContext - (instancetype)initWithQuery: (OFDNSQuery *)query ID: (OFNumber *)ID settings: (OFDNSResolverSettings *)settings delegate: (id <OFDNSResolverQueryDelegate>)delegate { self = [super init]; @try { void *pool = objc_autoreleasePoolPush(); OFMutableData *queryData; uint16_t tmp; _query = [query copy]; _ID = [ID retain]; _settings = [settings copy]; _delegate = [delegate retain]; queryData = [OFMutableData dataWithCapacity: 512]; /* Header */ tmp = OF_BSWAP16_IF_LE(_ID.uInt16Value); [queryData addItems: &tmp count: 2]; /* RD */ tmp = OF_BSWAP16_IF_LE(1u << 8); [queryData addItems: &tmp count: 2]; /* QDCOUNT */ tmp = OF_BSWAP16_IF_LE(1); [queryData addItems: &tmp count: 2]; /* ANCOUNT, NSCOUNT and ARCOUNT */ [queryData increaseCountBy: 6]; /* Question */ /* QNAME */ for (OFString *component in [_query.domainName componentsSeparatedByString: @"."]) { size_t length = component.UTF8StringLength; uint8_t length8; if (length > 63 || queryData.count + length > 512) @throw [OFOutOfRangeException exception]; length8 = (uint8_t)length; [queryData addItem: &length8]; [queryData addItems: component.UTF8String count: length]; } /* QTYPE */ tmp = OF_BSWAP16_IF_LE(_query.recordType); [queryData addItems: &tmp count: 2]; /* QCLASS */ tmp = OF_BSWAP16_IF_LE(_query.DNSClass); [queryData addItems: &tmp count: 2]; [queryData makeImmutable]; _queryData = [queryData copy]; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_query release]; [_ID release]; [_settings release]; [_delegate release]; [_queryData release]; [_cancelTimer release]; [super dealloc]; } @end @implementation OFDNSResolver #ifdef OF_AMIGAOS + (void)initialize { if (self != [OFDNSResolver class]) return; if (!of_socket_init()) |
︙ | ︙ | |||
1137 1138 1139 1140 1141 1142 1143 1144 1145 | } - (instancetype)init { self = [super init]; @try { _queries = [[OFMutableDictionary alloc] init]; | > < > < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < | < < < < | < < < < < | | < | < < < < < | < < < | < < < < < < < < < < < < < < | | < < < < | < < < < < < < < < < < | < < | < < < < < < < < < < < < < < < < < < < < | | < < | < < < < < | < < < | < < < | < < < < | < < < < < < < < < | < < < < < | < | < < < < < < < | < < | < | < < < < | < < < < < | < < < < < | < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < | < < | < | < < < < | < < < < | < < < < < < < < < < < < | < < | < < < | < < < < < < | < < < < < < < < | | < < < < | < < | < < < < < | < < < < < < < < | < < | | < < < < < < < < | < < | < < < < | < < < | < < < < < < < < < < < < | < < | < < | < < | < < < | < < | < < | < < < < < < < < < < < < < < < | < | < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < | < < | < < | < < < < < < < < < < < < < < < < < | < < < < < | < < < < < < < < < | < < < < < < < < < < | < < < < < < < < < < < < < | | < < < < < < < < < < < < < < | < < < < < < < < < < | < | < | | | | | | | | | | | | | | | < < < < | | > > > > | < > > > | | < > > > | > > > | > > > | | | < < > | > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | | | | | | | < < | > | > > > | > | | | | | | | | > > < | | | | 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 | } - (instancetype)init { self = [super init]; @try { _settings = [[OFDNSResolverSettings alloc] init]; _queries = [[OFMutableDictionary alloc] init]; [_settings reload]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [self close]; [_settings release]; [_IPv4Socket cancelAsyncRequests]; [_IPv4Socket release]; #ifdef OF_HAVE_IPV6 [_IPv6Socket cancelAsyncRequests]; [_IPv6Socket release]; #endif [_queries release]; [super dealloc]; } - (OFDictionary *)staticHosts { return _settings->_staticHosts; } - (void)setStaticHosts: (OFDictionary *)staticHosts { OFDictionary *old = _settings->_staticHosts; _settings->_staticHosts = [staticHosts copy]; [old release]; } - (OFArray *)nameServers { return _settings->_nameServers; } - (void)setNameServers: (OFArray *)nameServers { OFArray *old = _settings->_nameServers; _settings->_nameServers = [nameServers copy]; [old release]; } - (OFString *)localDomain { return _settings->_localDomain; } - (OFArray *)searchDomains { return _settings->_searchDomains; } - (void)setSearchDomains: (OFArray *)searchDomains { OFArray *old = _settings->_searchDomains; _settings->_searchDomains = [searchDomains copy]; [old release]; } - (of_time_interval_t)timeout { return _settings->_timeout; } - (void)setTimeout: (of_time_interval_t)timeout { _settings->_timeout = timeout; } - (unsigned int)maxAttempts { return _settings->_maxAttempts; } - (void)setMaxAttempts: (unsigned int)maxAttempts { _settings->_maxAttempts = maxAttempts; } - (unsigned int)minNumberOfDotsInAbsoluteName { return _settings->_minNumberOfDotsInAbsoluteName; } - (void)setMinNumberOfDotsInAbsoluteName: (unsigned int)minNumberOfDotsInAbsoluteName { _settings->_minNumberOfDotsInAbsoluteName = minNumberOfDotsInAbsoluteName; } - (bool)usesTCP { return _settings->_usesTCP; } - (void)setUsesTCP: (bool)usesTCP { _settings->_usesTCP = usesTCP; } - (of_time_interval_t)configReloadInterval { return _settings->_configReloadInterval; } - (void)setConfigReloadInterval: (of_time_interval_t)configReloadInterval { _settings->_configReloadInterval = configReloadInterval; } - (void)of_sendQueryForContext: (OFDNSResolverContext *)context runLoopMode: (of_run_loop_mode_t)runLoopMode { OFUDPSocket *sock; OFString *nameServer; [context->_cancelTimer invalidate]; [context->_cancelTimer release]; context->_cancelTimer = nil; context->_cancelTimer = [[OFTimer alloc] initWithFireDate: [OFDate dateWithTimeIntervalSinceNow: context->_settings->_timeout] interval: context->_settings->_timeout target: self selector: @selector(of_contextTimedOut:) object: context repeats: false]; [[OFRunLoop currentRunLoop] addTimer: context->_cancelTimer forMode: runLoopMode]; nameServer = [context->_settings->_nameServers objectAtIndex: context->_nameServersIndex]; context->_usedNameServer = of_socket_address_parse_ip(nameServer, 53); switch (context->_usedNameServer.family) { #ifdef OF_HAVE_IPV6 case OF_SOCKET_ADDRESS_FAMILY_IPV6: if (_IPv6Socket == nil) { of_socket_address_t address = of_socket_address_parse_ip(@"::", 0); _IPv6Socket = [[OFUDPSocket alloc] init]; [_IPv6Socket of_bindToAddress: &address extraType: SOCK_DNS]; _IPv6Socket.blocking = false; _IPv6Socket.delegate = self; } sock = _IPv6Socket; break; #endif case OF_SOCKET_ADDRESS_FAMILY_IPV4: if (_IPv4Socket == nil) { of_socket_address_t address = of_socket_address_parse_ip(@"0.0.0.0", 0); _IPv4Socket = [[OFUDPSocket alloc] init]; [_IPv4Socket of_bindToAddress: &address extraType: SOCK_DNS]; _IPv4Socket.blocking = false; _IPv4Socket.delegate = self; } sock = _IPv4Socket; break; default: @throw [OFInvalidArgumentException exception]; } [sock asyncSendData: context->_queryData receiver: &context->_usedNameServer runLoopMode: runLoopMode]; [sock asyncReceiveIntoBuffer: _buffer length: BUFFER_LENGTH runLoopMode: runLoopMode]; } - (void)asyncPerformQuery: (OFDNSQuery *)query delegate: (id <OFDNSResolverQueryDelegate>)delegate { [self asyncPerformQuery: query runLoopMode: of_run_loop_mode_default delegate: delegate]; } - (void)asyncPerformQuery: (OFDNSQuery *)query runLoopMode: (of_run_loop_mode_t)runLoopMode delegate: (id <OFDNSResolverQueryDelegate>)delegate { void *pool = objc_autoreleasePoolPush(); OFNumber *ID; OFDNSResolverContext *context; /* Random, unused ID */ do { ID = [OFNumber numberWithUInt16: (uint16_t)of_random()]; } while ([_queries objectForKey: ID] != nil); if (query.domainName.UTF8StringLength > 253) @throw [OFOutOfRangeException exception]; context = [[[OFDNSResolverContext alloc] initWithQuery: query ID: ID settings: _settings delegate: delegate] autorelease]; [_queries setObject: context forKey: ID]; [self of_sendQueryForContext: context runLoopMode: runLoopMode]; objc_autoreleasePoolPop(pool); } - (void)of_contextTimedOut: (OFDNSResolverContext *)context { of_run_loop_mode_t runLoopMode = [OFRunLoop currentRunLoop].currentMode; OFDNSQueryFailedException *exception; if (context->_nameServersIndex + 1 < context->_settings->_nameServers.count) { context->_nameServersIndex++; [self of_sendQueryForContext: context runLoopMode: runLoopMode]; return; } if (context->_attempt < context->_settings->_maxAttempts) { context->_attempt++; context->_nameServersIndex = 0; [self of_sendQueryForContext: context runLoopMode: runLoopMode]; return; } context = [[context retain] autorelease]; [_queries removeObjectForKey: context->_ID]; /* * Cancel any pending queries, to avoid a send being still pending and * trying to access the query once it no longer exists. */ [_IPv4Socket cancelAsyncRequests]; [_IPv4Socket asyncReceiveIntoBuffer: _buffer length: BUFFER_LENGTH]; #ifdef OF_HAVE_IPV6 [_IPv6Socket cancelAsyncRequests]; [_IPv6Socket asyncReceiveIntoBuffer: _buffer length: BUFFER_LENGTH]; #endif exception = [OFDNSQueryFailedException exceptionWithQuery: context->_query error: OF_DNS_RESOLVER_ERROR_TIMEOUT]; if ([context->_delegate respondsToSelector: @selector(resolver:didPerformQuery:response:exception:)]) [context->_delegate resolver: self didPerformQuery: context->_query response: nil exception: exception]; } - (bool)socket: (OFUDPSocket *)sock didReceiveIntoBuffer: (void *)buffer_ length: (size_t)length sender: (const of_socket_address_t *)sender exception: (id)exception { unsigned char *buffer = buffer_; OFDictionary *answerRecords = nil, *authorityRecords = nil; OFDictionary *additionalRecords = nil; OFDNSResponse *response = nil; OFNumber *ID; OFDNSResolverContext *context; if (exception != nil) return true; if (length < 2) /* We can't get the ID to get the context. Ignore packet. */ return true; ID = [OFNumber numberWithUInt16: (buffer[0] << 8) | buffer[1]]; context = [[[_queries objectForKey: ID] retain] autorelease]; if (context == nil) return true; if (!of_socket_address_equal(sender, &context->_usedNameServer)) return true; [context->_cancelTimer invalidate]; [context->_cancelTimer release]; context->_cancelTimer = nil; [_queries removeObjectForKey: ID]; @try { of_dns_resolver_error_t error = 0; bool tryNextNameServer = false; const unsigned char *queryDataBuffer; size_t i; uint16_t numQuestions, numAnswers, numAuthorityRecords; uint16_t numAdditionalRecords; if (length < 12) @throw [OFTruncatedDataException exception]; if (context->_queryData.itemSize != 1 || context->_queryData.count < 12) @throw [OFInvalidArgumentException exception]; queryDataBuffer = context->_queryData.items; /* QR */ if ((buffer[2] & 0x80) == 0) @throw [OFInvalidServerReplyException exception]; /* Opcode */ if ((buffer[2] & 0x78) != (queryDataBuffer[2] & 0x78)) |
︙ | ︙ | |||
1932 1933 1934 1935 1936 1937 1938 1939 1940 | case 0: break; case 1: error = OF_DNS_RESOLVER_ERROR_SERVER_INVALID_FORMAT; break; case 2: error = OF_DNS_RESOLVER_ERROR_SERVER_FAILURE; break; case 3: | > < < < < < < < < < < < < < < < < < < < < < > > > > > > > > > > > > > > > > > | | < < | | 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 | case 0: break; case 1: error = OF_DNS_RESOLVER_ERROR_SERVER_INVALID_FORMAT; break; case 2: error = OF_DNS_RESOLVER_ERROR_SERVER_FAILURE; tryNextNameServer = true; break; case 3: error = OF_DNS_RESOLVER_ERROR_SERVER_NAME_ERROR; break; case 4: error = OF_DNS_RESOLVER_ERROR_SERVER_NOT_IMPLEMENTED; tryNextNameServer = true; break; case 5: error = OF_DNS_RESOLVER_ERROR_SERVER_REFUSED; tryNextNameServer = true; break; default: error = OF_DNS_RESOLVER_ERROR_UNKNOWN; tryNextNameServer = true; break; } if (tryNextNameServer) { if (context->_nameServersIndex + 1 < context->_settings->_nameServers.count) { of_run_loop_mode_t runLoopMode = [OFRunLoop currentRunLoop].currentMode; context->_nameServersIndex++; [self of_sendQueryForContext: context runLoopMode: runLoopMode]; return false; } } if (buffer[3] & 0x0F) @throw [OFDNSQueryFailedException exceptionWithQuery: context->_query error: error]; numQuestions = (buffer[4] << 8) | buffer[5]; numAnswers = (buffer[6] << 8) | buffer[7]; numAuthorityRecords = (buffer[8] << 8) | buffer[9]; numAdditionalRecords = (buffer[10] << 8) | buffer[11]; i = 12; |
︙ | ︙ | |||
1998 1999 2000 2001 2002 2003 2004 2005 | } answerRecords = parseSection(buffer, length, &i, numAnswers); authorityRecords = parseSection(buffer, length, &i, numAuthorityRecords); additionalRecords = parseSection(buffer, length, &i, numAdditionalRecords); } @catch (id e) { | > > > > > < < | > > | < > > > | > > | | | | | | | | | < | | | | | | | < | | < | < | < < < < < | < | < < < < < < < < < < < < < < < | < < < | < | < | < < < < < < < < < < < < < < < < | | < < < < < | < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | < < > | | | < < < | < < < < < < < < < < < < < < < < | < < < < < | < < < | | | < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | | | | | | | < < | > | > | > | | 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 | } answerRecords = parseSection(buffer, length, &i, numAnswers); authorityRecords = parseSection(buffer, length, &i, numAuthorityRecords); additionalRecords = parseSection(buffer, length, &i, numAdditionalRecords); response = [OFDNSResponse responseWithDomainName: context->_query.domainName answerRecords: answerRecords authorityRecords: authorityRecords additionalRecords: additionalRecords]; } @catch (id e) { exception = e; } if (exception != nil) response = nil; if ([context->_delegate respondsToSelector: @selector(resolver:didPerformQuery:response:exception:)]) [context->_delegate resolver: self didPerformQuery: context->_query response: response exception: exception]; return false; } - (void)asyncResolveAddressesForHost: (OFString *)host delegate: (id <OFDNSResolverHostDelegate>)delegate { [self asyncResolveAddressesForHost: host addressFamily: OF_SOCKET_ADDRESS_FAMILY_ANY runLoopMode: of_run_loop_mode_default delegate: delegate]; } - (void)asyncResolveAddressesForHost: (OFString *)host addressFamily: (of_socket_address_family_t)addressFamily delegate: (id <OFDNSResolverHostDelegate>)delegate { [self asyncResolveAddressesForHost: host addressFamily: addressFamily runLoopMode: of_run_loop_mode_default delegate: delegate]; } - (void)asyncResolveAddressesForHost: (OFString *)host addressFamily: (of_socket_address_family_t)addressFamily runLoopMode: (of_run_loop_mode_t)runLoopMode delegate: (id <OFDNSResolverHostDelegate>)delegate { void *pool = objc_autoreleasePoolPush(); OFHostAddressResolver *resolver = [[[OFHostAddressResolver alloc] initWithHost: host addressFamily: addressFamily resolver: self settings: _settings runLoopMode: runLoopMode delegate: delegate] autorelease]; [resolver asyncResolve]; objc_autoreleasePoolPop(pool); } - (OFData *)resolveAddressesForHost: (OFString *)host addressFamily: (of_socket_address_family_t)addressFamily { void *pool = objc_autoreleasePoolPush(); OFHostAddressResolver *resolver = [[[OFHostAddressResolver alloc] initWithHost: host addressFamily: addressFamily resolver: self settings: _settings runLoopMode: nil delegate: nil] autorelease]; OFData *addresses = [resolver resolve]; [addresses retain]; objc_autoreleasePoolPop(pool); return [addresses autorelease]; } - (void)close { void *pool = objc_autoreleasePoolPush(); OFEnumerator OF_GENERIC(OFDNSResolverContext *) *enumerator; OFDNSResolverContext *context; [_IPv4Socket cancelAsyncRequests]; [_IPv4Socket release]; _IPv4Socket = nil; #ifdef OF_HAVE_IPV6 [_IPv6Socket cancelAsyncRequests]; [_IPv6Socket release]; _IPv6Socket = nil; #endif enumerator = [_queries objectEnumerator]; while ((context = [enumerator nextObject]) != nil) { OFDNSQueryFailedException *exception; exception = [OFDNSQueryFailedException exceptionWithQuery: context->_query error: OF_DNS_RESOLVER_ERROR_CANCELED]; if ([context->_delegate respondsToSelector: @selector(resolver:didPerformQuery:response:exception:)]) [context->_delegate resolver: self didPerformQuery: context->_query response: nil exception: exception]; } [_queries removeAllObjects]; objc_autoreleasePoolPop(pool); } @end |
Added src/OFDNSResolverSettings.h version [8cc10c01ba].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | /* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, * 2018, 2019 * Jonathan Schleifer <js@heap.zone> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFObject.h" OF_ASSUME_NONNULL_BEGIN @class OFArray OF_GENERIC(ObjectType); @class OFDate; @class OFDictionary OF_GENERIC(KeyType, ObjectType); @interface OFDNSResolverSettings: OFObject <OFCopying> { @public OFDictionary OF_GENERIC(OFString *, OFArray OF_GENERIC(OFString *) *) *_staticHosts; OFArray OF_GENERIC(OFString *) *_nameServers; OFString *_Nullable _localDomain; OFArray OF_GENERIC(OFString *) *_searchDomains; of_time_interval_t _timeout; unsigned int _maxAttempts, _minNumberOfDotsInAbsoluteName; bool _usesTCP; of_time_interval_t _configReloadInterval; @protected OFDate *_lastConfigReload; } - (void)reload; @end OF_ASSUME_NONNULL_END |
Added src/OFDNSResolverSettings.m version [2a510449d0].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 | /* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, * 2018, 2019 * Jonathan Schleifer <js@heap.zone> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #include "unistd_wrapper.h" #import "OFDNSResolverSettings.h" #import "OFArray.h" #import "OFCharacterSet.h" #import "OFDate.h" #import "OFDictionary.h" #import "OFFile.h" #import "OFLocale.h" #import "OFString.h" #ifdef OF_WINDOWS # import "OFWindowsRegistryKey.h" #endif #import "OFInvalidFormatException.h" #import "OFOpenItemFailedException.h" #import "OFOutOfMemoryException.h" #ifdef OF_WINDOWS # define interface struct # include <iphlpapi.h> # undef interface #endif #ifdef OF_NINTENDO_3DS # include <3ds.h> #endif #import "socket_helpers.h" #if defined(OF_HAIKU) # define HOSTS_PATH @"/system/settings/network/hosts" # define RESOLV_CONF_PATH @"/system/settings/network/resolv.conf" #elif defined(OF_MORPHOS) # define HOSTS_PATH @"ENV:sys/net/hosts" # define RESOLV_CONF_PATH @"ENV:sys/net/resolv.conf" #elif defined(OF_AMIGAOS4) # define HOSTS_PATH @"DEVS:Internet/hosts" #elif defined(OF_AMIGAOS) # define HOSTS_PATH @"AmiTCP:db/hosts" # define RESOLV_CONF_PATH @"AmiTCP:db/resolv.conf" #else # define HOSTS_PATH @"/etc/hosts" # define RESOLV_CONF_PATH @"/etc/resolv.conf" #endif #ifndef OF_WII static OFString * domainFromHostname(void) { char hostname[256]; OFString *domain; if (gethostname(hostname, 256) != 0) return nil; domain = [OFString stringWithCString: hostname encoding: [OFLocale encoding]]; @try { of_socket_address_parse_ip(domain, 0); /* * If we are still here, the host name is a valid IP address. * We can't use that as local domain. */ return nil; } @catch (OFInvalidFormatException *e) { /* Not an IP address -> we can use it if it contains a dot. */ size_t pos = [domain rangeOfString: @"."].location; if (pos == OF_NOT_FOUND) return nil; return [domain substringWithRange: of_range(pos + 1, domain.length - pos - 1)]; } } #endif @implementation OFDNSResolverSettings - (void)dealloc { [_staticHosts release]; [_nameServers release]; [_localDomain release]; [_searchDomains release]; [_lastConfigReload release]; [super dealloc]; } - (id)copy { OFDNSResolverSettings *copy = [[OFDNSResolverSettings alloc] init]; @try { copy->_staticHosts = [_staticHosts copy]; copy->_nameServers = [_nameServers copy]; copy->_localDomain = [_localDomain copy]; copy->_searchDomains = [_searchDomains copy]; copy->_timeout = _timeout; copy->_maxAttempts = _maxAttempts; copy->_minNumberOfDotsInAbsoluteName = _minNumberOfDotsInAbsoluteName; copy->_usesTCP = _usesTCP; copy->_configReloadInterval = _configReloadInterval; copy->_lastConfigReload = [_lastConfigReload copy]; } @catch (id e) { [copy release]; @throw e; } return copy; } - (void)setDefaults { [_staticHosts release]; _staticHosts = nil; [_nameServers release]; _nameServers = nil; [_localDomain release]; _localDomain = nil; [_searchDomains release]; _searchDomains = nil; _timeout = 2; _maxAttempts = 3; _minNumberOfDotsInAbsoluteName = 1; _usesTCP = false; #ifndef OF_NINTENDO_3DS _configReloadInterval = 2; #else _configReloadInterval = 0; #endif } #if defined(OF_HAVE_FILES) && !defined(OF_NINTENDO_3DS) - (void)parseHosts: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFCharacterSet *whitespaceCharacterSet = [OFCharacterSet whitespaceCharacterSet]; OFMutableDictionary *staticHosts; OFFile *file; OFString *line; OFEnumerator *enumerator; OFMutableArray *addresses; @try { file = [OFFile fileWithPath: path mode: @"r"]; } @catch (OFOpenItemFailedException *e) { objc_autoreleasePoolPop(pool); return; } staticHosts = [OFMutableDictionary dictionary]; while ((line = [file readLine]) != nil) { void *pool2 = objc_autoreleasePoolPush(); OFArray *components, *hosts; size_t pos; OFString *address; pos = [line rangeOfString: @"#"].location; if (pos != OF_NOT_FOUND) line = [line substringWithRange: of_range(0, pos)]; components = [line componentsSeparatedByCharactersInSet: whitespaceCharacterSet options: OF_STRING_SKIP_EMPTY]; if (components.count < 2) { objc_autoreleasePoolPop(pool2); continue; } address = components.firstObject; hosts = [components objectsInRange: of_range(1, components.count - 1)]; for (OFString *host in hosts) { addresses = [staticHosts objectForKey: host]; if (addresses == nil) { addresses = [OFMutableArray array]; [staticHosts setObject: addresses forKey: host]; } [addresses addObject: address]; } objc_autoreleasePoolPop(pool2); } enumerator = [staticHosts objectEnumerator]; while ((addresses = [enumerator nextObject]) != nil) [addresses makeImmutable]; [staticHosts makeImmutable]; [_staticHosts release]; _staticHosts = [staticHosts copy]; objc_autoreleasePoolPop(pool); } # if !defined(OF_WINDOWS) && !defined(OF_AMIGAOS4) - (void)parseResolvConfOption: (OFString *)option { @try { if ([option hasPrefix: @"ndots:"]) { option = [option substringWithRange: of_range(6, option.length - 6)]; _minNumberOfDotsInAbsoluteName = (unsigned int)option.decimalValue; } else if ([option hasPrefix: @"timeout:"]) { option = [option substringWithRange: of_range(8, option.length - 8)]; _timeout = option.decimalValue; } else if ([option hasPrefix: @"attempts:"]) { option = [option substringWithRange: of_range(9, option.length - 9)]; _maxAttempts = (unsigned int)option.decimalValue; } else if ([option hasPrefix: @"reload-period:"]) { option = [option substringWithRange: of_range(14, option.length - 14)]; _configReloadInterval = option.decimalValue; } else if ([option isEqual: @"tcp"]) _usesTCP = true; } @catch (OFInvalidFormatException *e) { } } - (void)parseResolvConf: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFCharacterSet *whitespaceCharacterSet = [OFCharacterSet whitespaceCharacterSet]; OFCharacterSet *commentCharacters = [OFCharacterSet characterSetWithCharactersInString: @"#;"]; OFMutableArray *nameServers = [[_nameServers mutableCopy] autorelease]; OFFile *file; OFString *line; @try { file = [OFFile fileWithPath: path mode: @"r"]; } @catch (OFOpenItemFailedException *e) { objc_autoreleasePoolPop(pool); return; } if (nameServers == nil) nameServers = [OFMutableArray array]; while ((line = [file readLine]) != nil) { void *pool2 = objc_autoreleasePoolPush(); size_t pos; OFArray *components, *arguments; OFString *option; pos = [line indexOfCharacterFromSet: commentCharacters]; if (pos != OF_NOT_FOUND) line = [line substringWithRange: of_range(0, pos)]; components = [line componentsSeparatedByCharactersInSet: whitespaceCharacterSet options: OF_STRING_SKIP_EMPTY]; if (components.count < 2) { objc_autoreleasePoolPop(pool2); continue; } option = components.firstObject; arguments = [components objectsInRange: of_range(1, components.count - 1)]; if ([option isEqual: @"nameserver"]) { if (arguments.count != 1) { objc_autoreleasePoolPop(pool2); continue; } [nameServers addObject: [arguments firstObject]]; } else if ([option isEqual: @"domain"]) { if (arguments.count != 1) { objc_autoreleasePoolPop(pool2); continue; } [_localDomain release]; _localDomain = [arguments.firstObject copy]; } else if ([option isEqual: @"search"]) { [_searchDomains release]; _searchDomains = [arguments copy]; } else if ([option isEqual: @"options"]) for (OFString *argument in arguments) [self parseResolvConfOption: argument]; objc_autoreleasePoolPop(pool2); } [nameServers makeImmutable]; [_nameServers release]; _nameServers = [nameServers copy]; objc_autoreleasePoolPop(pool); } # endif #endif #ifdef OF_WINDOWS - (void)obtainWindowsSystemConfig { of_string_encoding_t encoding = [OFLocale encoding]; OFMutableArray *nameServers; /* * We need more space than FIXED_INFO in case we have more than one * name server, but we also want it to be properly aligned, meaning we * can't just get a buffer of bytes. Thus, we just get space for 8. */ FIXED_INFO fixedInfo[8]; ULONG length = sizeof(fixedInfo); PIP_ADDR_STRING iter; if (GetNetworkParams(fixedInfo, &length) != ERROR_SUCCESS) return; nameServers = [OFMutableArray array]; for (iter = &fixedInfo->DnsServerList; iter != NULL; iter = iter->Next) [nameServers addObject: [OFString stringWithCString: iter->IpAddress.String encoding: encoding]]; if (nameServers.count > 0) { [nameServers makeImmutable]; _nameServers = [nameServers copy]; } if (fixedInfo->DomainName[0] != '\0') _localDomain = [[OFString alloc] initWithCString: fixedInfo->DomainName encoding: encoding]; } #endif #ifdef OF_AMIGAOS4 - (void)obtainAmigaOS4SystemConfig { OFMutableArray *nameServers = [OFMutableArray array]; of_string_encoding_t encoding = [OFLocale encoding]; struct List *nameServerList = ObtainDomainNameServerList(); char buffer[MAXHOSTNAMELEN]; if (nameServerList == NULL) @throw [OFOutOfMemoryException exception]; @try { struct DomainNameServerNode *iter = (struct DomainNameServerNode *)&nameServerList->lh_Head; while (iter->dnsn_MinNode.mln_Succ != NULL) { if (iter->dnsn_UseCount != 0 && iter->dnsn_Address != NULL) { OFString *address = [OFString stringWithCString: iter->dnsn_Address encoding: encoding]; [nameServers addObject: address]; } iter = (struct DomainNameServerNode *) iter->dnsn_MinNode.mln_Succ; } } @finally { ReleaseDomainNameServerList(nameServerList); } if (nameServers.count > 0) { [nameServers makeImmutable]; _nameServers = [nameServers copy]; } if (GetDefaultDomainName(buffer, sizeof(buffer))) _localDomain = [[OFString alloc] initWithCString: buffer encoding: encoding]; } #endif #ifdef OF_NINTENDO_3DS - (void)obtainNintendo3DSSytemConfig { OFMutableArray *nameServers = [OFMutableArray array]; union { /* * For some unknown reason, this needs a 336 bytes buffer and * always returns 336 bytes. */ char bytes[336]; SOCU_DNSTableEntry entries[2]; } buffer; socklen_t optLen = sizeof(buffer); if (SOCU_GetNetworkOpt(SOL_CONFIG, NETOPT_DNS_TABLE, &buffer, &optLen) != 0) return; /* * We're fine if this gets smaller in a future release (unlikely), as * long as two entries still fit. */ if (optLen < sizeof(buffer.entries)) return; for (uint_fast8_t i = 0; i < 2; i++) { uint32_t ip = OF_BSWAP32_IF_LE(buffer.entries[i].ip.s_addr); if (ip == 0) continue; [nameServers addObject: [OFString stringWithFormat: @"%u.%u.%u.%u", (ip >> 24) & 0xFF, (ip >> 16) & 0xFF, (ip >> 8) & 0xFF, ip & 0xFF]]; } if (nameServers.count > 0) { [nameServers makeImmutable]; _nameServers = [nameServers copy]; } } #endif - (void)reload { void *pool; #ifdef OF_WINDOWS OFString *path; #endif /* * TODO: Rather than reparsing every time, check what actually changed * (mtime) and only reset those. */ if (_lastConfigReload != nil && _configReloadInterval > 0 && _lastConfigReload.timeIntervalSinceNow < _configReloadInterval) return; pool = objc_autoreleasePoolPush(); [self setDefaults]; #if defined(OF_WINDOWS) # ifdef OF_HAVE_FILES path = [[OFWindowsRegistryKey localMachineKey] stringForValue: @"DataBasePath" subkeyPath: @"SYSTEM\\CurrentControlSet\\Services\\" @"Tcpip\\Parameters"]; path = [path stringByAppendingPathComponent: @"hosts"]; if (path != nil) [self parseHosts: path]; # endif [self obtainWindowsSystemConfig]; #elif defined(OF_AMIGAOS4) [self parseHosts: HOSTS_PATH]; [self obtainAmigaOS4SystemConfig]; #elif defined(OF_NINTENDO_3DS) [self obtainNintendo3DSSytemConfig]; #elif defined(OF_HAVE_FILES) [self parseHosts: HOSTS_PATH]; [self parseResolvConf: RESOLV_CONF_PATH]; #endif if (_staticHosts == nil) { OFArray *localhost = #ifdef OF_HAVE_IPV6 [OFArray arrayWithObjects: @"::1", @"127.0.0.1", nil]; #else [OFArray arrayWithObject: @"127.0.0.1"]; #endif _staticHosts = [[OFDictionary alloc] initWithObject: localhost forKey: @"localhost"]; } if (_nameServers == nil) #ifdef OF_HAVE_IPV6 _nameServers = [[OFArray alloc] initWithObjects: @"127.0.0.1", @"::1", nil]; #else _nameServers = [[OFArray alloc] initWithObject: @"127.0.0.1"]; #endif #ifndef OF_WII if (_localDomain == nil) _localDomain = [domainFromHostname() copy]; #endif if (_searchDomains == nil) { if (_localDomain != nil) _searchDomains = [[OFArray alloc] initWithObject: _localDomain]; else _searchDomains = [[OFArray alloc] init]; } objc_autoreleasePoolPop(pool); } @end |
Modified src/OFDNSResourceRecord.h from [2ea810b61f] to [b9392a37ff].
︙ | ︙ | |||
23 24 25 26 27 28 29 | OF_ASSUME_NONNULL_BEGIN /*! @file */ @class OFData; /*! | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | OF_ASSUME_NONNULL_BEGIN /*! @file */ @class OFData; /*! * @brief The DNS class. */ typedef enum { /*! IN */ OF_DNS_CLASS_IN = 1, /*! Any class. Only for queries. */ OF_DNS_CLASS_ANY = 255, } of_dns_class_t; /*! * @brief The type of a DNS resource record. */ typedef enum { /*! A */ OF_DNS_RECORD_TYPE_A = 1, /*! NS */ OF_DNS_RECORD_TYPE_NS = 2, /*! CNAME */ OF_DNS_RECORD_TYPE_CNAME = 5, /*! SOA */ OF_DNS_RECORD_TYPE_SOA = 6, /*! PTR */ OF_DNS_RECORD_TYPE_PTR = 12, /*! HINFO */ OF_DNS_RECORD_TYPE_HINFO = 13, /*! MX */ OF_DNS_RECORD_TYPE_MX = 15, /*! TXT */ OF_DNS_RECORD_TYPE_TXT = 16, /*! RP */ OF_DNS_RECORD_TYPE_RP = 17, /*! AAAA */ OF_DNS_RECORD_TYPE_AAAA = 28, /*! SRV */ OF_DNS_RECORD_TYPE_SRV = 33, /*! All types. Only for queries. */ OF_DNS_RECORD_TYPE_ALL = 255, } of_dns_record_type_t; /*! * @class OFDNSResourceRecord OFDNSResourceRecord.h ObjFW/OFDNSResourceRecord.h * * @brief A class representing a DNS resource record. */ @interface OFDNSResourceRecord: OFObject <OFCopying> { OFString *_name; of_dns_class_t _DNSClass; of_dns_record_type_t _recordType; uint32_t _TTL; OF_RESERVE_IVARS(4) } /** * @brief The domain name to which the resource record belongs. */ @property (readonly, nonatomic) OFString *name; /*! * @brief The DNS class. */ @property (readonly, nonatomic) of_dns_class_t DNSClass; /*! * @brief The resource record type code. */ @property (readonly, nonatomic) of_dns_record_type_t recordType; /*! * @brief The number of seconds after which the resource record should be * discarded from the cache. */ @property (readonly, nonatomic) uint32_t TTL; /*! * @brief Initializes an already allocated OFDNSResourceRecord with the * specified name, class, type, data and time to live. * * @param name The name for the resource record * @param DNSClass The class code for the resource record * @param recordType The type code for the resource record * @param TTL The time to live for the resource record * @return An initialized OFDNSResourceRecord */ - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass recordType: (of_dns_record_type_t)recordType TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER; @end /*! * @class OFADNSResourceRecord OFDNSResourceRecord.h ObjFW/OFDNSResourceRecord.h * * @brief A class representing an A DNS resource record. */ OF_SUBCLASSING_RESTRICTED @interface OFADNSResourceRecord: OFDNSResourceRecord { of_socket_address_t _address; } /*! * @brief The IPv4 address of the resource record. */ @property (readonly, nonatomic) const of_socket_address_t *address; - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass recordType: (of_dns_record_type_t)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /*! * @brief Initializes an already allocated OFADNSResourceRecord with the * specified name, class, address and time to live. * * @param name The name for the resource record |
︙ | ︙ | |||
166 167 168 169 170 171 172 | /*! * @brief The IPv6 address of the resource record. */ @property (readonly, nonatomic) const of_socket_address_t *address; - (instancetype)initWithName: (OFString *)name | | | | 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | /*! * @brief The IPv6 address of the resource record. */ @property (readonly, nonatomic) const of_socket_address_t *address; - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass recordType: (of_dns_record_type_t)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /*! * @brief Initializes an already allocated OFAAAADNSResourceRecord with the * specified name, class, address and time to live. * * @param name The name for the resource record |
︙ | ︙ | |||
202 203 204 205 206 207 208 | /*! * @brief The alias of the resource record. */ @property (readonly, nonatomic) OFString *alias; - (instancetype)initWithName: (OFString *)name | | | | | | 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 | /*! * @brief The alias of the resource record. */ @property (readonly, nonatomic) OFString *alias; - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass recordType: (of_dns_record_type_t)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /*! * @brief Initializes an already allocated OFCNAMEDNSResourceRecord with the * specified name, class, alias and time to live. * * @param name The name for the resource record * @param DNSClass The class code for the resource record * @param alias The alias for the resource record * @param TTL The time to live for the resource record * @return An initialized OFCNAMEDNSResourceRecord */ - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass alias: (OFString *)alias TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER; @end /*! * @class OFHINFODNSResourceRecord \ * OFDNSResourceRecord.h ObjFW/OFDNSResourceRecord.h |
︙ | ︙ | |||
245 246 247 248 249 250 251 | /*! * @brief The OS of the host info of the resource record. */ @property (readonly, nonatomic) OFString *OS; - (instancetype)initWithName: (OFString *)name | | | | | | 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 | /*! * @brief The OS of the host info of the resource record. */ @property (readonly, nonatomic) OFString *OS; - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass recordType: (of_dns_record_type_t)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /*! * @brief Initializes an already allocated OFHINFODNSResourceRecord with the * specified name, class, domain name and time to live. * * @param name The name for the resource record * @param DNSClass The class code for the resource record * @param CPU The CPU of the host info for the resource record * @param OS The OS of the host info for the resource record * @param TTL The time to live for the resource record * @return An initialized OFHINFODNSResourceRecord */ - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass CPU: (OFString *)CPU OS: (OFString *)OS TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER; @end /*! * @class OFMXDNSResourceRecord \ |
︙ | ︙ | |||
291 292 293 294 295 296 297 | /*! * @brief The mail exchange of the resource record. */ @property (readonly, nonatomic) OFString *mailExchange; - (instancetype)initWithName: (OFString *)name | | | | | | 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | /*! * @brief The mail exchange of the resource record. */ @property (readonly, nonatomic) OFString *mailExchange; - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass recordType: (of_dns_record_type_t)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /*! * @brief Initializes an already allocated OFMXDNSResourceRecord with the * specified name, class, preference, mail exchange and time to live. * * @param name The name for the resource record * @param DNSClass The class code for the resource record * @param preference The preference for the resource record * @param mailExchange The mail exchange for the resource record * @param TTL The time to live for the resource record * @return An initialized OFMXDNSResourceRecord */ - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass preference: (uint16_t)preference mailExchange: (OFString *)mailExchange TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER; @end /*! * @class OFNSDNSResourceRecord \ |
︙ | ︙ | |||
331 332 333 334 335 336 337 | /*! * @brief The authoritative host of the resource record. */ @property (readonly, nonatomic) OFString *authoritativeHost; - (instancetype)initWithName: (OFString *)name | | | | | | 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 | /*! * @brief The authoritative host of the resource record. */ @property (readonly, nonatomic) OFString *authoritativeHost; - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass recordType: (of_dns_record_type_t)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /*! * @brief Initializes an already allocated OFNSDNSResourceRecord with the * specified name, class, authoritative host and time to live. * * @param name The name for the resource record * @param DNSClass The class code for the resource record * @param authoritativeHost The authoritative host for the resource record * @param TTL The time to live for the resource record * @return An initialized OFNSDNSResourceRecord */ - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass authoritativeHost: (OFString *)authoritativeHost TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER; @end /*! * @class OFPTRDNSResourceRecord \ * OFDNSResourceRecord.h ObjFW/OFDNSResourceRecord.h |
︙ | ︙ | |||
369 370 371 372 373 374 375 | /*! * @brief The domain name of the resource record. */ @property (readonly, nonatomic) OFString *domainName; - (instancetype)initWithName: (OFString *)name | | | | | | 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 | /*! * @brief The domain name of the resource record. */ @property (readonly, nonatomic) OFString *domainName; - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass recordType: (of_dns_record_type_t)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /*! * @brief Initializes an already allocated OFPTRDNSResourceRecord with the * specified name, class, domain name and time to live. * * @param name The name for the resource record * @param DNSClass The class code for the resource record * @param domainName The domain name for the resource record * @param TTL The time to live for the resource record * @return An initialized OFPTRDNSResourceRecord */ - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass domainName: (OFString *)domainName TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER; @end /*! * @class OFRPNSResourceRecord \ * OFDNSResourceRecord.h ObjFW/OFDNSResourceRecord.h |
︙ | ︙ | |||
413 414 415 416 417 418 419 | /*! * @brief A domain name that contains a TXT resource record for the responsible * person of the resource record. */ @property (readonly, nonatomic) OFString *TXTDomainName; - (instancetype)initWithName: (OFString *)name | | | | | | 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 | /*! * @brief A domain name that contains a TXT resource record for the responsible * person of the resource record. */ @property (readonly, nonatomic) OFString *TXTDomainName; - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass recordType: (of_dns_record_type_t)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /*! * @brief Initializes an already allocated OFRPDNSResourceRecord with the * specified name, class, alias and time to live. * * @param name The name for the resource record * @param DNSClass The class code for the resource record * @param mailbox The mailbox of the responsible person of the resource record * @param TXTDomainName A domain name that contains a TXT resource record for * the responsible person of the resource record * @param TTL The time to live for the resource record * @return An initialized OFRPDNSResourceRecord */ - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass mailbox: (OFString *)mailbox TXTDomainName: (OFString *)TXTDomainName TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER; @end /*! * @class OFSOADNSResourceRecord \ |
︙ | ︙ | |||
486 487 488 489 490 491 492 | /*! * @brief The minimum TTL of the zone. */ @property (readonly, nonatomic) uint32_t minTTL; - (instancetype)initWithName: (OFString *)name | | | | | | 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 | /*! * @brief The minimum TTL of the zone. */ @property (readonly, nonatomic) uint32_t minTTL; - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass recordType: (of_dns_record_type_t)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /*! * @brief Initializes an already allocated OFSOADNSResourceRecord with the * specified name, class, text data and time to live. * * @param name The name for the resource record * @param DNSClass The class code for the resource record * @param primaryNameServer The the primary name server for the zone * @param responsiblePerson The mailbox of the person responsible for the zone * @param serialNumber The serial number of the original copy of the zone * @param refreshInterval The refresh interval of the zone * @param retryInterval The retry interval of the zone * @param expirationInterval The expiration interval of the zone * @param minTTL The minimum TTL of the zone * @param TTL The time to live for the resource record * @return An initialized OFSOADNSResourceRecord */ - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass primaryNameServer: (OFString *)primaryNameServer responsiblePerson: (OFString *)responsiblePerson serialNumber: (uint32_t)serialNumber refreshInterval: (uint32_t)refreshInterval retryInterval: (uint32_t)retryInterval expirationInterval: (uint32_t)expirationInterval minTTL: (uint32_t)minTTL |
︙ | ︙ | |||
553 554 555 556 557 558 559 | /*! * @brief The port on the target of the resource record. */ @property (readonly, nonatomic) uint16_t port; - (instancetype)initWithName: (OFString *)name | | | | 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 | /*! * @brief The port on the target of the resource record. */ @property (readonly, nonatomic) uint16_t port; - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass recordType: (of_dns_record_type_t)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /*! * @brief Initializes an already allocated OFSRVDNSResourceRecord with the * specified name, class, preference, mail exchange and time to live. * * @param name The name for the resource record |
︙ | ︙ | |||
595 596 597 598 599 600 601 | /*! * @brief The text of the resource record. */ @property (readonly, nonatomic) OFData *textData; - (instancetype)initWithName: (OFString *)name | | | | | | < | | < | < | | 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 | /*! * @brief The text of the resource record. */ @property (readonly, nonatomic) OFData *textData; - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass recordType: (of_dns_record_type_t)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /*! * @brief Initializes an already allocated OFTXTDNSResourceRecord with the * specified name, class, text data and time to live. * * @param name The name for the resource record * @param DNSClass The class code for the resource record * @param textData The data for the resource record * @param TTL The time to live for the resource record * @return An initialized OFTXTDNSResourceRecord */ - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass textData: (OFData *)textData TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER; @end #ifdef __cplusplus extern "C" { #endif extern OFString *_Nonnull of_dns_class_to_string(of_dns_class_t DNSClass); extern OFString *_Nonnull of_dns_record_type_to_string( of_dns_record_type_t recordType); extern of_dns_class_t of_dns_class_parse(OFString *_Nonnull string); extern of_dns_record_type_t of_dns_record_type_parse(OFString *_Nonnull string); #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END |
Modified src/OFDNSResourceRecord.m from [b77a7c0c09] to [38d9eb9459].
︙ | ︙ | |||
20 21 22 23 24 25 26 | #import "OFDNSResourceRecord.h" #import "OFData.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" OFString * | | < | | | | | | | | | | | | | | | | | < | | | | > > > | > > | < | | | | | | | | | | | | | | > > > > | > > | | | | | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | #import "OFDNSResourceRecord.h" #import "OFData.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" OFString * of_dns_class_to_string(of_dns_class_t DNSClass) { switch (DNSClass) { case OF_DNS_CLASS_IN: return @"IN"; case OF_DNS_CLASS_ANY: return @"any"; default: return [OFString stringWithFormat: @"%u", DNSClass]; } } OFString * of_dns_record_type_to_string(of_dns_record_type_t recordType) { switch (recordType) { case OF_DNS_RECORD_TYPE_A: return @"A"; case OF_DNS_RECORD_TYPE_NS: return @"NS"; case OF_DNS_RECORD_TYPE_CNAME: return @"CNAME"; case OF_DNS_RECORD_TYPE_SOA: return @"SOA"; case OF_DNS_RECORD_TYPE_PTR: return @"PTR"; case OF_DNS_RECORD_TYPE_HINFO: return @"HINFO"; case OF_DNS_RECORD_TYPE_MX: return @"MX"; case OF_DNS_RECORD_TYPE_TXT: return @"TXT"; case OF_DNS_RECORD_TYPE_RP: return @"RP"; case OF_DNS_RECORD_TYPE_AAAA: return @"AAAA"; case OF_DNS_RECORD_TYPE_SRV: return @"SRV"; case OF_DNS_RECORD_TYPE_ALL: return @"all"; default: return [OFString stringWithFormat: @"%u", recordType]; } } of_dns_class_t of_dns_class_parse(OFString *string) { void *pool = objc_autoreleasePoolPush(); of_dns_class_t DNSClass; string = string.uppercaseString; if ([string isEqual: @"IN"]) DNSClass = OF_DNS_CLASS_IN; else { @try { DNSClass = (of_dns_class_t)[string decimalValue]; } @catch (OFInvalidFormatException *e) { @throw [OFInvalidArgumentException exception]; } } objc_autoreleasePoolPop(pool); return DNSClass; } of_dns_record_type_t of_dns_record_type_parse(OFString *string) { void *pool = objc_autoreleasePoolPush(); of_dns_record_type_t recordType; string = string.uppercaseString; if ([string isEqual: @"A"]) recordType = OF_DNS_RECORD_TYPE_A; else if ([string isEqual: @"NS"]) recordType = OF_DNS_RECORD_TYPE_NS; else if ([string isEqual: @"CNAME"]) recordType = OF_DNS_RECORD_TYPE_CNAME; else if ([string isEqual: @"SOA"]) recordType = OF_DNS_RECORD_TYPE_SOA; else if ([string isEqual: @"PTR"]) recordType = OF_DNS_RECORD_TYPE_PTR; else if ([string isEqual: @"HINFO"]) recordType = OF_DNS_RECORD_TYPE_HINFO; else if ([string isEqual: @"MX"]) recordType = OF_DNS_RECORD_TYPE_MX; else if ([string isEqual: @"TXT"]) recordType = OF_DNS_RECORD_TYPE_TXT; else if ([string isEqual: @"RP"]) recordType = OF_DNS_RECORD_TYPE_RP; else if ([string isEqual: @"AAAA"]) recordType = OF_DNS_RECORD_TYPE_AAAA; else if ([string isEqual: @"SRV"]) recordType = OF_DNS_RECORD_TYPE_SRV; else { @try { recordType = (of_dns_record_type_t)[string decimalValue]; } @catch (OFInvalidFormatException *e) { @throw [OFInvalidArgumentException exception]; } } objc_autoreleasePoolPop(pool); return recordType; } @implementation OFDNSResourceRecord @synthesize name = _name, DNSClass = _DNSClass, recordType = _recordType; @synthesize TTL = _TTL; - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass recordType: (of_dns_record_type_t)recordType TTL: (uint32_t)TTL { self = [super init]; @try { _name = [name copy]; _DNSClass = DNSClass; _recordType = recordType; _TTL = TTL; } @catch (id e) { [self release]; @throw e; } |
︙ | ︙ | |||
167 168 169 170 171 172 173 | return [OFString stringWithFormat: @"<%@:\n" @"\tName = %@\n" @"\tClass = %@\n" @"\tType = %@\n" @"\tTTL = %" PRIu32 "\n" @">", | | < | | | | | | | > > > | | | | | | | | | 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | return [OFString stringWithFormat: @"<%@:\n" @"\tName = %@\n" @"\tClass = %@\n" @"\tType = %@\n" @"\tTTL = %" PRIu32 "\n" @">", self.className, _name, of_dns_class_to_string(_DNSClass), of_dns_record_type_to_string(_recordType), _TTL]; } @end @implementation OFADNSResourceRecord - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass recordType: (of_dns_record_type_t)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } - (instancetype)initWithName: (OFString *)name address: (const of_socket_address_t *)address TTL: (uint32_t)TTL { self = [super initWithName: name DNSClass: OF_DNS_CLASS_IN recordType: OF_DNS_RECORD_TYPE_A TTL: TTL]; _address = *address; return self; } - (const of_socket_address_t *)address { return &_address; } - (bool)isEqual: (id)object { OFADNSResourceRecord *record; if (object == self) return true; if (![object isKindOfClass: [OFADNSResourceRecord class]]) return false; record = object; if (record->_name != _name && ![record->_name isEqual: _name]) return false; if (record->_DNSClass != _DNSClass) return false; if (record->_recordType != _recordType) return false; if (!of_socket_address_equal(&record->_address, &_address)) return false; return true; } - (uint32_t)hash { uint32_t hash; OF_HASH_INIT(hash); OF_HASH_ADD_HASH(hash, _name.hash); OF_HASH_ADD(hash, _DNSClass >> 8); OF_HASH_ADD(hash, _DNSClass); OF_HASH_ADD(hash, _recordType >> 8); OF_HASH_ADD(hash, _recordType); OF_HASH_ADD_HASH(hash, of_socket_address_hash(&_address)); OF_HASH_FINALIZE(hash); return hash; |
︙ | ︙ | |||
258 259 260 261 262 263 264 | self.className, _name, of_socket_address_ip_string(&_address, NULL), _TTL]; } @end @implementation OFAAAADNSResourceRecord - (instancetype)initWithName: (OFString *)name | | | | | | | > > > | | | | | | | | | 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | self.className, _name, of_socket_address_ip_string(&_address, NULL), _TTL]; } @end @implementation OFAAAADNSResourceRecord - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass recordType: (of_dns_record_type_t)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } - (instancetype)initWithName: (OFString *)name address: (const of_socket_address_t *)address TTL: (uint32_t)TTL { self = [super initWithName: name DNSClass: OF_DNS_CLASS_IN recordType: OF_DNS_RECORD_TYPE_AAAA TTL: TTL]; _address = *address; return self; } - (const of_socket_address_t *)address { return &_address; } - (bool)isEqual: (id)object { OFAAAADNSResourceRecord *record; if (object == self) return true; if (![object isKindOfClass: [OFAAAADNSResourceRecord class]]) return false; record = object; if (record->_name != _name && ![record->_name isEqual: _name]) return false; if (record->_DNSClass != _DNSClass) return false; if (record->_recordType != _recordType) return false; if (!of_socket_address_equal(&record->_address, &_address)) return false; return true; } - (uint32_t)hash { uint32_t hash; OF_HASH_INIT(hash); OF_HASH_ADD_HASH(hash, _name.hash); OF_HASH_ADD(hash, _DNSClass >> 8); OF_HASH_ADD(hash, _DNSClass); OF_HASH_ADD(hash, _recordType >> 8); OF_HASH_ADD(hash, _recordType); OF_HASH_ADD_HASH(hash, of_socket_address_hash(&_address)); OF_HASH_FINALIZE(hash); return hash; |
︙ | ︙ | |||
343 344 345 346 347 348 349 | } @end @implementation OFCNAMEDNSResourceRecord @synthesize alias = _alias; - (instancetype)initWithName: (OFString *)name | | | | | | | | > > > | | | | | < | | | | | | | | | | | 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 | } @end @implementation OFCNAMEDNSResourceRecord @synthesize alias = _alias; - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass recordType: (of_dns_record_type_t)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass alias: (OFString *)alias TTL: (uint32_t)TTL { self = [super initWithName: name DNSClass: DNSClass recordType: OF_DNS_RECORD_TYPE_CNAME TTL: TTL]; @try { _alias = [alias copy]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_alias release]; [super dealloc]; } - (bool)isEqual: (id)object { OFCNAMEDNSResourceRecord *record; if (object == self) return true; if (![object isKindOfClass: [OFCNAMEDNSResourceRecord class]]) return false; record = object; if (record->_name != _name && ![record->_name isEqual: _name]) return false; if (record->_DNSClass != _DNSClass) return false; if (record->_recordType != _recordType) return false; if (record->_alias != _alias && ![record->_alias isEqual: _alias]) return false; return true; } - (uint32_t)hash { uint32_t hash; OF_HASH_INIT(hash); OF_HASH_ADD_HASH(hash, _name.hash); OF_HASH_ADD(hash, _DNSClass >> 8); OF_HASH_ADD(hash, _DNSClass); OF_HASH_ADD(hash, _recordType >> 8); OF_HASH_ADD(hash, _recordType); OF_HASH_ADD_HASH(hash, _alias.hash); OF_HASH_FINALIZE(hash); return hash; } - (OFString *)description { return [OFString stringWithFormat: @"<%@:\n" @"\tName = %@\n" @"\tClass = %@\n" @"\tAlias = %@\n" @"\tTTL = %" PRIu32 "\n" @">", self.className, _name, of_dns_class_to_string(_DNSClass), _alias, _TTL]; } @end @implementation OFHINFODNSResourceRecord @synthesize CPU = _CPU, OS = _OS; - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass recordType: (of_dns_record_type_t)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass CPU: (OFString *)CPU OS: (OFString *)OS TTL: (uint32_t)TTL { self = [super initWithName: name DNSClass: DNSClass recordType: OF_DNS_RECORD_TYPE_HINFO TTL: TTL]; @try { _CPU = [CPU copy]; _OS = [OS copy]; } @catch (id e) { [self release]; |
︙ | ︙ | |||
475 476 477 478 479 480 481 | { [_CPU release]; [_OS release]; [super dealloc]; } | | | > > > | | | | | | | | | | < | | | | | | | > > > | | | | | | | | | | | 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 | { [_CPU release]; [_OS release]; [super dealloc]; } - (bool)isEqual: (id)object { OFHINFODNSResourceRecord *record; if (object == self) return true; if (![object isKindOfClass: [OFHINFODNSResourceRecord class]]) return false; record = object; if (record->_name != _name && ![record->_name isEqual: _name]) return false; if (record->_DNSClass != _DNSClass) return false; if (record->_recordType != _recordType) return false; if (record->_CPU != _CPU && ![record->_CPU isEqual: _CPU]) return false; if (record->_OS != _OS && ![record->_OS isEqual: _OS]) return false; return true; } - (uint32_t)hash { uint32_t hash; OF_HASH_INIT(hash); OF_HASH_ADD_HASH(hash, _name.hash); OF_HASH_ADD(hash, _DNSClass >> 8); OF_HASH_ADD(hash, _DNSClass); OF_HASH_ADD(hash, _recordType >> 8); OF_HASH_ADD(hash, _recordType); OF_HASH_ADD_HASH(hash, _CPU.hash); OF_HASH_ADD_HASH(hash, _OS.hash); OF_HASH_FINALIZE(hash); return hash; } - (OFString *)description { return [OFString stringWithFormat: @"<%@:\n" @"\tName = %@\n" @"\tClass = %@\n" @"\tCPU = %@\n" @"\tOS = %@\n" @"\tTTL = %" PRIu32 "\n" @">", self.className, _name, of_dns_class_to_string(_DNSClass), _CPU, _OS, _TTL]; } @end @implementation OFMXDNSResourceRecord @synthesize preference = _preference, mailExchange = _mailExchange; - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass recordType: (of_dns_record_type_t)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass preference: (uint16_t)preference mailExchange: (OFString *)mailExchange TTL: (uint32_t)TTL { self = [super initWithName: name DNSClass: DNSClass recordType: OF_DNS_RECORD_TYPE_MX TTL: TTL]; @try { _preference = preference; _mailExchange = [mailExchange copy]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_mailExchange release]; [super dealloc]; } - (bool)isEqual: (id)object { OFMXDNSResourceRecord *record; if (object == self) return true; if (![object isKindOfClass: [OFMXDNSResourceRecord class]]) return false; record = object; if (record->_name != _name && ![record->_name isEqual: _name]) return false; if (record->_DNSClass != _DNSClass) return false; if (record->_recordType != _recordType) return false; if (record->_preference != _preference) return false; if (record->_mailExchange != _mailExchange && ![record->_mailExchange isEqual: _mailExchange]) return false; return true; } - (uint32_t)hash { uint32_t hash; OF_HASH_INIT(hash); OF_HASH_ADD_HASH(hash, _name.hash); OF_HASH_ADD(hash, _DNSClass >> 8); OF_HASH_ADD(hash, _DNSClass); OF_HASH_ADD(hash, _recordType >> 8); OF_HASH_ADD(hash, _recordType); OF_HASH_ADD(hash, _preference >> 8); OF_HASH_ADD(hash, _preference); OF_HASH_ADD_HASH(hash, _mailExchange.hash); OF_HASH_FINALIZE(hash); |
︙ | ︙ | |||
635 636 637 638 639 640 641 | @"<%@:\n" @"\tName = %@\n" @"\tClass = %@\n" @"\tPreference = %" PRIu16 "\n" @"\tMail Exchange = %@\n" @"\tTTL = %" PRIu32 "\n" @">", | | < | | | | | | | | > > > | | | | | | | | | | < | | | | | | | > > > | | | | | | | | | | < | | | | | | | 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 | @"<%@:\n" @"\tName = %@\n" @"\tClass = %@\n" @"\tPreference = %" PRIu16 "\n" @"\tMail Exchange = %@\n" @"\tTTL = %" PRIu32 "\n" @">", self.className, _name, of_dns_class_to_string(_DNSClass), _preference, _mailExchange, _TTL]; } @end @implementation OFNSDNSResourceRecord @synthesize authoritativeHost = _authoritativeHost; - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass recordType: (of_dns_record_type_t)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass authoritativeHost: (OFString *)authoritativeHost TTL: (uint32_t)TTL { self = [super initWithName: name DNSClass: DNSClass recordType: OF_DNS_RECORD_TYPE_NS TTL: TTL]; @try { _authoritativeHost = [authoritativeHost copy]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_authoritativeHost release]; [super dealloc]; } - (bool)isEqual: (id)object { OFNSDNSResourceRecord *record; if (object == self) return true; if (![object isKindOfClass: [OFNSDNSResourceRecord class]]) return false; record = object; if (record->_name != _name && ![record->_name isEqual: _name]) return false; if (record->_DNSClass != _DNSClass) return false; if (record->_recordType != _recordType) return false; if (record->_authoritativeHost != _authoritativeHost && ![record->_authoritativeHost isEqual: _authoritativeHost]) return false; return true; } - (uint32_t)hash { uint32_t hash; OF_HASH_INIT(hash); OF_HASH_ADD_HASH(hash, _name.hash); OF_HASH_ADD(hash, _DNSClass >> 8); OF_HASH_ADD(hash, _DNSClass); OF_HASH_ADD(hash, _recordType >> 8); OF_HASH_ADD(hash, _recordType); OF_HASH_ADD_HASH(hash, _authoritativeHost.hash); OF_HASH_FINALIZE(hash); return hash; } - (OFString *)description { return [OFString stringWithFormat: @"<%@:\n" @"\tName = %@\n" @"\tClass = %@\n" @"\tAuthoritative Host = %@\n" @"\tTTL = %" PRIu32 "\n" @">", self.className, _name, of_dns_class_to_string(_DNSClass), _authoritativeHost, _TTL]; } @end @implementation OFPTRDNSResourceRecord @synthesize domainName = _domainName; - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass recordType: (of_dns_record_type_t)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass domainName: (OFString *)domainName TTL: (uint32_t)TTL { self = [super initWithName: name DNSClass: DNSClass recordType: OF_DNS_RECORD_TYPE_PTR TTL: TTL]; @try { _domainName = [domainName copy]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_domainName release]; [super dealloc]; } - (bool)isEqual: (id)object { OFPTRDNSResourceRecord *record; if (object == self) return true; if (![object isKindOfClass: [OFPTRDNSResourceRecord class]]) return false; record = object; if (record->_name != _name && ![record->_name isEqual: _name]) return false; if (record->_DNSClass != _DNSClass) return false; if (record->_recordType != _recordType) return false; if (record->_domainName != _domainName && ![record->_domainName isEqual: _domainName]) return false; return true; } - (uint32_t)hash { uint32_t hash; OF_HASH_INIT(hash); OF_HASH_ADD_HASH(hash, _name.hash); OF_HASH_ADD(hash, _DNSClass >> 8); OF_HASH_ADD(hash, _DNSClass); OF_HASH_ADD(hash, _recordType >> 8); OF_HASH_ADD(hash, _recordType); OF_HASH_ADD_HASH(hash, _domainName.hash); OF_HASH_FINALIZE(hash); return hash; } - (OFString *)description { return [OFString stringWithFormat: @"<%@:\n" @"\tName = %@\n" @"\tClass = %@\n" @"\tDomain Name = %@\n" @"\tTTL = %" PRIu32 "\n" @">", self.className, _name, of_dns_class_to_string(_DNSClass), _domainName, _TTL]; } @end @implementation OFRPDNSResourceRecord @synthesize mailbox = _mailbox, TXTDomainName = _TXTDomainName; - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass recordType: (of_dns_record_type_t)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass mailbox: (OFString *)mailbox TXTDomainName: (OFString *)TXTDomainName TTL: (uint32_t)TTL { self = [super initWithName: name DNSClass: DNSClass recordType: OF_DNS_RECORD_TYPE_RP TTL: TTL]; @try { _mailbox = [mailbox copy]; _TXTDomainName = [TXTDomainName copy]; } @catch (id e) { [self release]; |
︙ | ︙ | |||
874 875 876 877 878 879 880 | { [_mailbox release]; [_TXTDomainName release]; [super dealloc]; } | | | > > > | | | | | | | | | | | | < | | | | | | 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 | { [_mailbox release]; [_TXTDomainName release]; [super dealloc]; } - (bool)isEqual: (id)object { OFRPDNSResourceRecord *record; if (object == self) return true; if (![object isKindOfClass: [OFRPDNSResourceRecord class]]) return false; record = object; if (record->_name != _name && ![record->_name isEqual: _name]) return false; if (record->_DNSClass != _DNSClass) return false; if (record->_recordType != _recordType) return false; if (record->_mailbox != _mailbox && ![record->_mailbox isEqual: _mailbox]) return false; if (record->_TXTDomainName != _TXTDomainName && ![record->_TXTDomainName isEqual: _TXTDomainName]) return false; return true; } - (uint32_t)hash { uint32_t hash; OF_HASH_INIT(hash); OF_HASH_ADD_HASH(hash, _name.hash); OF_HASH_ADD(hash, _DNSClass >> 8); OF_HASH_ADD(hash, _DNSClass); OF_HASH_ADD(hash, _recordType >> 8); OF_HASH_ADD(hash, _recordType); OF_HASH_ADD_HASH(hash, _mailbox.hash); OF_HASH_ADD_HASH(hash, _TXTDomainName.hash); OF_HASH_FINALIZE(hash); return hash; } - (OFString *)description { return [OFString stringWithFormat: @"<%@:\n" @"\tName = %@\n" @"\tClass = %@\n" @"\tMailbox = %@\n" @"\tTXT Domain Name = %@\n" @"\tTTL = %" PRIu32 "\n" @">", self.className, _name, of_dns_class_to_string(_DNSClass), _mailbox, _TXTDomainName, _TTL]; } @end @implementation OFSOADNSResourceRecord @synthesize primaryNameServer = _primaryNameServer; @synthesize responsiblePerson = _responsiblePerson; @synthesize serialNumber = _serialNumber, refreshInterval = _refreshInterval; @synthesize retryInterval = _retryInterval; @synthesize expirationInterval = _expirationInterval, minTTL = _minTTL; - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass recordType: (of_dns_record_type_t)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass primaryNameServer: (OFString *)primaryNameServer responsiblePerson: (OFString *)responsiblePerson serialNumber: (uint32_t)serialNumber refreshInterval: (uint32_t)refreshInterval retryInterval: (uint32_t)retryInterval expirationInterval: (uint32_t)expirationInterval minTTL: (uint32_t)minTTL TTL: (uint32_t)TTL { self = [super initWithName: name DNSClass: DNSClass recordType: OF_DNS_RECORD_TYPE_SOA TTL: TTL]; @try { _primaryNameServer = [primaryNameServer copy]; _responsiblePerson = [responsiblePerson copy]; _serialNumber = serialNumber; _refreshInterval = refreshInterval; |
︙ | ︙ | |||
993 994 995 996 997 998 999 | { [_primaryNameServer release]; [_responsiblePerson release]; [super dealloc]; } | | | > > > | | | | | | | | | | | | | | | | | 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 | { [_primaryNameServer release]; [_responsiblePerson release]; [super dealloc]; } - (bool)isEqual: (id)object { OFSOADNSResourceRecord *record; if (object == self) return true; if (![object isKindOfClass: [OFSOADNSResourceRecord class]]) return false; record = object; if (record->_name != _name && ![record->_name isEqual: _name]) return false; if (record->_DNSClass != _DNSClass) return false; if (record->_recordType != _recordType) return false; if (record->_primaryNameServer != _primaryNameServer && ![record->_primaryNameServer isEqual: _primaryNameServer]) return false; if (record->_responsiblePerson != _responsiblePerson && ![record->_responsiblePerson isEqual: _responsiblePerson]) return false; if (record->_serialNumber != _serialNumber) return false; if (record->_refreshInterval != _refreshInterval) return false; if (record->_retryInterval != _retryInterval) return false; if (record->_expirationInterval != _expirationInterval) return false; if (record->_minTTL != _minTTL) return false; return true; } - (uint32_t)hash { uint32_t hash; OF_HASH_INIT(hash); OF_HASH_ADD_HASH(hash, _name.hash); OF_HASH_ADD(hash, _DNSClass >> 8); OF_HASH_ADD(hash, _DNSClass); OF_HASH_ADD(hash, _recordType >> 8); OF_HASH_ADD(hash, _recordType); OF_HASH_ADD_HASH(hash, _primaryNameServer.hash); OF_HASH_ADD_HASH(hash, _responsiblePerson.hash); OF_HASH_ADD(hash, _serialNumber >> 24); OF_HASH_ADD(hash, _serialNumber >> 16); OF_HASH_ADD(hash, _serialNumber >> 8); |
︙ | ︙ | |||
1091 1092 1093 1094 1095 1096 1097 | @"\tSerial Number = %" PRIu32 "\n" @"\tRefresh Interval = %" PRIu32 "\n" @"\tRetry Interval = %" PRIu32 "\n" @"\tExpiration Interval = %" PRIu32 "\n" @"\tMinimum TTL = %" PRIu32 "\n" @"\tTTL = %" PRIu32 "\n" @">", | | < | | | | | 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 | @"\tSerial Number = %" PRIu32 "\n" @"\tRefresh Interval = %" PRIu32 "\n" @"\tRetry Interval = %" PRIu32 "\n" @"\tExpiration Interval = %" PRIu32 "\n" @"\tMinimum TTL = %" PRIu32 "\n" @"\tTTL = %" PRIu32 "\n" @">", self.className, _name, of_dns_class_to_string(_DNSClass), _primaryNameServer, _responsiblePerson, _serialNumber, _refreshInterval, _retryInterval, _expirationInterval, _minTTL, _TTL]; } @end @implementation OFSRVDNSResourceRecord @synthesize priority = _priority, weight = _weight, target = _target; @synthesize port = _port; - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass recordType: (of_dns_record_type_t)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } - (instancetype)initWithName: (OFString *)name priority: (uint16_t)priority weight: (uint16_t)weight target: (OFString *)target port: (uint16_t)port TTL: (uint32_t)TTL { self = [super initWithName: name DNSClass: OF_DNS_CLASS_IN recordType: OF_DNS_RECORD_TYPE_SRV TTL: TTL]; @try { _priority = priority; _weight = weight; _target = [target copy]; _port = port; |
︙ | ︙ | |||
1143 1144 1145 1146 1147 1148 1149 | - (void)dealloc { [_target release]; [super dealloc]; } | | | > > > | | | | | | | | < | | | | 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 | - (void)dealloc { [_target release]; [super dealloc]; } - (bool)isEqual: (id)object { OFSRVDNSResourceRecord *record; if (object == self) return true; if (![object isKindOfClass: [OFSRVDNSResourceRecord class]]) return false; record = object; if (record->_name != _name && ![record->_name isEqual: _name]) return false; if (record->_DNSClass != _DNSClass) return false; if (record->_recordType != _recordType) return false; if (record->_priority != _priority) return false; if (record->_weight != _weight) return false; if (record->_target != _target && ![record->_target isEqual: _target]) return false; if (record->_port != _port) return false; return true; } - (uint32_t)hash { uint32_t hash; OF_HASH_INIT(hash); OF_HASH_ADD_HASH(hash, _name.hash); OF_HASH_ADD(hash, _DNSClass >> 8); OF_HASH_ADD(hash, _DNSClass); OF_HASH_ADD(hash, _recordType >> 8); OF_HASH_ADD(hash, _recordType); OF_HASH_ADD(hash, _priority >> 8); OF_HASH_ADD(hash, _priority); OF_HASH_ADD(hash, _weight >> 8); OF_HASH_ADD(hash, _weight); OF_HASH_ADD_HASH(hash, _target.hash); |
︙ | ︙ | |||
1220 1221 1222 1223 1224 1225 1226 | } @end @implementation OFTXTDNSResourceRecord @synthesize textData = _textData; - (instancetype)initWithName: (OFString *)name | | | | | | | | > > > | | | | | | | | | | < | 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 | } @end @implementation OFTXTDNSResourceRecord @synthesize textData = _textData; - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass recordType: (of_dns_record_type_t)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } - (instancetype)initWithName: (OFString *)name DNSClass: (of_dns_class_t)DNSClass textData: (OFData *)textData TTL: (uint32_t)TTL { self = [super initWithName: name DNSClass: DNSClass recordType: OF_DNS_RECORD_TYPE_TXT TTL: TTL]; @try { _textData = [textData copy]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_textData release]; [super dealloc]; } - (bool)isEqual: (id)object { OFTXTDNSResourceRecord *record; if (object == self) return true; if (![object isKindOfClass: [OFTXTDNSResourceRecord class]]) return false; record = object; if (record->_name != _name && ![record->_name isEqual: _name]) return false; if (record->_DNSClass != _DNSClass) return false; if (record->_recordType != _recordType) return false; if (record->_textData != _textData && ![record->_textData isEqual: _textData]) return false; return true; } - (uint32_t)hash { uint32_t hash; OF_HASH_INIT(hash); OF_HASH_ADD_HASH(hash, _name.hash); OF_HASH_ADD(hash, _DNSClass >> 8); OF_HASH_ADD(hash, _DNSClass); OF_HASH_ADD(hash, _recordType >> 8); OF_HASH_ADD(hash, _recordType); OF_HASH_ADD_HASH(hash, _textData.hash); OF_HASH_FINALIZE(hash); return hash; } - (OFString *)description { return [OFString stringWithFormat: @"<%@:\n" @"\tName = %@\n" @"\tClass = %@\n" @"\tText Data = %@\n" @"\tTTL = %" PRIu32 "\n" @">", self.className, _name, of_dns_class_to_string(_DNSClass), _textData, _TTL]; } @end |
Added src/OFDNSResponse.h version [83177f4956].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | /* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, * 2018, 2019 * Jonathan Schleifer <js@heap.zone> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFObject.h" #import "OFDNSResourceRecord.h" OF_ASSUME_NONNULL_BEGIN @class OFArray OF_GENERIC(ObjectType); @class OFDictionary OF_GENERIC(KeyType, ObjectType); typedef OFDictionary OF_GENERIC(OFString *, OFArray OF_GENERIC( OF_KINDOF(OFDNSResourceRecord *)) *) *of_dns_response_records_t; /*! * @class OFDNSResponse OFDNSResponse.h ObjFW/OFDNSResponse.h * * @brief A class storing a response from @ref OFDNSResolver. */ @interface OFDNSResponse: OFObject { OFString *_domainName; of_dns_response_records_t _answerRecords; of_dns_response_records_t _authorityRecords; of_dns_response_records_t _additionalRecords; OF_RESERVE_IVARS(4) } /*! * @brief The domain name of the response. */ @property (readonly, nonatomic) OFString *domainName; /*! * @brief The answer records of the response. * * This is a dictionary with the key being the domain name and the value being * an array of @ref OFDNSResourceRecord. */ @property (readonly, nonatomic) of_dns_response_records_t answerRecords; /*! * @brief The authority records of the response. * * This is a dictionary with the key being the domain name and the value being * an array of @ref OFDNSResourceRecord. */ @property (readonly, nonatomic) of_dns_response_records_t authorityRecords; /*! * @brief The additional records of the response. * * This is a dictionary with the key being the domain name and the value being * an array of @ref OFDNSResourceRecord. */ @property (readonly, nonatomic) of_dns_response_records_t additionalRecords; /*! * @brief Creates a new, autoreleased OFDNSResponse. * * @param answerRecords The answer records of the response * @param authorityRecords The authority records of the response * @param additionalRecords The additional records of the response * @return A new, autoreleased OFDNSResponse */ + (instancetype) responseWithDomainName: (OFString *)domainName answerRecords: (of_dns_response_records_t)answerRecords authorityRecords: (of_dns_response_records_t)authorityRecords additionalRecords: (of_dns_response_records_t)additionalRecords; /*! * @brief Initializes an already allocated OFDNSResponse. * * @param answerRecords The answer records of the response * @param authorityRecords The authority records of the response * @param additionalRecords The additional records of the response * @return An initialized OFDNSResponse */ - (instancetype) initWithDomainName: (OFString *)domainName answerRecords: (of_dns_response_records_t)answerRecords authorityRecords: (of_dns_response_records_t)authorityRecords additionalRecords: (of_dns_response_records_t)additionalRecords OF_DESIGNATED_INITIALIZER; - (instancetype)init OF_UNAVAILABLE; @end OF_ASSUME_NONNULL_END |
Added src/OFDNSResponse.m version [4c41009453].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | /* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, * 2018, 2019 * Jonathan Schleifer <js@heap.zone> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #import "OFDNSResponse.h" #import "OFDictionary.h" #import "OFString.h" @implementation OFDNSResponse @synthesize domainName = _domainName, answerRecords = _answerRecords; @synthesize authorityRecords = _authorityRecords; @synthesize additionalRecords = _additionalRecords; + (instancetype) responseWithDomainName: (OFString *)domainName answerRecords: (of_dns_response_records_t)answerRecords authorityRecords: (of_dns_response_records_t)authorityRecords additionalRecords: (of_dns_response_records_t)additionalRecords { return [[[self alloc] initWithDomainName: domainName answerRecords: answerRecords authorityRecords: authorityRecords additionalRecords: additionalRecords] autorelease]; } - (instancetype)initWithDomainName: (OFString *)domainName answerRecords: (of_dns_response_records_t)answerRecords authorityRecords: (of_dns_response_records_t)authorityRecords additionalRecords: (of_dns_response_records_t)additionalRecords { self = [super init]; @try { _domainName = [domainName copy]; _answerRecords = [answerRecords copy]; _authorityRecords = [authorityRecords copy]; _additionalRecords = [additionalRecords copy]; } @catch (id e) { [self release]; @throw e; } return self; } - (instancetype)init OF_UNAVAILABLE { OF_INVALID_INIT_METHOD } - (void)dealloc { [_domainName release]; [_answerRecords release]; [_authorityRecords release]; [_additionalRecords release]; [super dealloc]; } - (bool)isEqual: (id)object { OFDNSResponse *response; if (object == self) return true; if (![object isKindOfClass: [OFDNSResponse class]]) return false; response = object; if (response->_domainName != _domainName && ![response->_domainName isEqual: _domainName]) return false; if (response->_answerRecords != _answerRecords && ![response->_answerRecords isEqual: _answerRecords]) return false; if (response->_authorityRecords != _authorityRecords && ![response->_authorityRecords isEqual: _authorityRecords]) return false; if (response->_additionalRecords != _additionalRecords && ![response->_additionalRecords isEqual: _additionalRecords]) return false; return true; } - (uint32_t)hash { uint32_t hash; OF_HASH_INIT(hash); OF_HASH_ADD_HASH(hash, _domainName.hash); OF_HASH_ADD_HASH(hash, [_answerRecords hash]); OF_HASH_ADD_HASH(hash, [_authorityRecords hash]); OF_HASH_ADD_HASH(hash, [_additionalRecords hash]); OF_HASH_FINALIZE(hash); return hash; } - (OFString *)description { OFString *answerRecords = [_answerRecords.description stringByReplacingOccurrencesOfString: @"\n" withString: @"\n\t"]; OFString *authorityRecords = [_authorityRecords.description stringByReplacingOccurrencesOfString: @"\n" withString: @"\n\t"]; OFString *additionalRecords = [_additionalRecords.description stringByReplacingOccurrencesOfString: @"\n" withString: @"\n\t"]; return [OFString stringWithFormat: @"<%@:\n" @"\tDomain name = %@\n" @"\tAnswer records = %@\n" @"\tAuthority records = %@\n" @"\tAdditional records = %@\n" @">", self.className, _domainName, answerRecords, authorityRecords, additionalRecords]; } @end |
Modified src/OFData.h from [db711ac9ba] to [5ddc0ad015].
︙ | ︙ | |||
38 39 40 41 42 43 44 45 46 47 48 49 50 51 | */ @interface OFData: OFObject <OFCopying, OFMutableCopying, OFComparing, OFSerialization, OFMessagePackRepresentation> { unsigned char *_items; size_t _count, _itemSize; bool _freeWhenDone; OFData *_parentData; OF_RESERVE_IVARS(4) } /*! * @brief The size of a single item in the OFData in bytes. */ | > | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | */ @interface OFData: OFObject <OFCopying, OFMutableCopying, OFComparing, OFSerialization, OFMessagePackRepresentation> { unsigned char *_items; size_t _count, _itemSize; bool _freeWhenDone; @private OFData *_parentData; OF_RESERVE_IVARS(4) } /*! * @brief The size of a single item in the OFData in bytes. */ |
︙ | ︙ |
Modified src/OFDictionary.h from [0bdd64401a] to [2fc9d82347].
︙ | ︙ | |||
58 59 60 61 62 63 64 | @interface OFDictionary OF_GENERIC(KeyType, ObjectType): OFObject <OFCopying, OFMutableCopying, OFCollection, OFSerialization, OFJSONRepresentation, OFMessagePackRepresentation> #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) # define KeyType id # define ObjectType id #endif | < < < < | 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | @interface OFDictionary OF_GENERIC(KeyType, ObjectType): OFObject <OFCopying, OFMutableCopying, OFCollection, OFSerialization, OFJSONRepresentation, OFMessagePackRepresentation> #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) # define KeyType id # define ObjectType id #endif /*! * @brief An array of all keys. */ @property (readonly, nonatomic) OFArray OF_GENERIC(KeyType) *allKeys; /*! * @brief An array of all objects. |
︙ | ︙ |
Modified src/OFDimensionValue.h from [4f99589b0d] to [506e11e7af].
︙ | ︙ | |||
15 16 17 18 19 20 21 | * file. */ #import "OFValue.h" OF_ASSUME_NONNULL_BEGIN | < | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | * file. */ #import "OFValue.h" OF_ASSUME_NONNULL_BEGIN @interface OFDimensionValue: OFValue { of_dimension_t _dimension; } @end OF_ASSUME_NONNULL_END |
Modified src/OFEpollKernelEventObserver.h from [82f0a9bae6] to [a52cc0d821].
︙ | ︙ | |||
17 18 19 20 21 22 23 | #import "OFKernelEventObserver.h" OF_ASSUME_NONNULL_BEGIN @class OFMapTable; | < | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #import "OFKernelEventObserver.h" OF_ASSUME_NONNULL_BEGIN @class OFMapTable; @interface OFEpollKernelEventObserver: OFKernelEventObserver { int _epfd; OFMapTable *_FDToEvents; } @end OF_ASSUME_NONNULL_END |
Modified src/OFFile.m from [e53f8eae67] to [7066f87c86].
︙ | ︙ | |||
219 220 221 222 223 224 225 | @throw [OFInvalidArgumentException exception]; flags |= O_BINARY | O_CLOEXEC; # if defined(OF_WINDOWS) if ((handle = _wopen(path.UTF16String, flags, _S_IREAD | _S_IWRITE)) == -1) | | | 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | @throw [OFInvalidArgumentException exception]; flags |= O_BINARY | O_CLOEXEC; # if defined(OF_WINDOWS) if ((handle = _wopen(path.UTF16String, flags, _S_IREAD | _S_IWRITE)) == -1) # elif defined(HAVE_OPEN64) if ((handle = open64([path cStringWithEncoding: [OFLocale encoding]], flags, 0666)) == -1) # else if ((handle = open([path cStringWithEncoding: [OFLocale encoding]], flags, 0666)) == -1) # endif @throw [OFOpenItemFailedException |
︙ | ︙ | |||
462 463 464 465 466 467 468 | if (_handle == OF_INVALID_FILE_HANDLE) @throw [OFNotOpenException exceptionWithObject: self]; #ifndef OF_AMIGAOS # if defined(OF_WINDOWS) ret = _lseeki64(_handle, offset, whence); | | | 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 | if (_handle == OF_INVALID_FILE_HANDLE) @throw [OFNotOpenException exceptionWithObject: self]; #ifndef OF_AMIGAOS # if defined(OF_WINDOWS) ret = _lseeki64(_handle, offset, whence); # elif defined(HAVE_LSEEK64) ret = lseek64(_handle, offset, whence); # else ret = lseek(_handle, offset, whence); # endif if (ret == -1) @throw [OFSeekFailedException exceptionWithStream: self |
︙ | ︙ |
Modified src/OFFileURLHandler.h from [fd0c855548] to [4c8d0c729e].
︙ | ︙ | |||
15 16 17 18 19 20 21 | * file. */ #import "OFURLHandler.h" OF_ASSUME_NONNULL_BEGIN | < | 15 16 17 18 19 20 21 22 23 24 25 26 | * file. */ #import "OFURLHandler.h" OF_ASSUME_NONNULL_BEGIN @interface OFFileURLHandler: OFURLHandler + (bool)of_directoryExistsAtPath: (OFString *)path; @end OF_ASSUME_NONNULL_END |
Modified src/OFFileURLHandler.m from [4a5233a57f] to [ad06f1fab8].
︙ | ︙ | |||
85 86 87 88 89 90 91 | of_time_interval_t st_atime, st_mtime, st_ctime; # ifdef OF_WINDOWS # define HAVE_STRUCT_STAT_ST_BIRTHTIME of_time_interval_t st_birthtime; DWORD fileAttributes; # endif } of_stat_t; | | | 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | of_time_interval_t st_atime, st_mtime, st_ctime; # ifdef OF_WINDOWS # define HAVE_STRUCT_STAT_ST_BIRTHTIME of_time_interval_t st_birthtime; DWORD fileAttributes; # endif } of_stat_t; #elif defined(HAVE_STAT64) typedef struct stat64 of_stat_t; #else typedef struct stat of_stat_t; #endif #ifdef OF_WINDOWS # define S_IFLNK 0x10000 |
︙ | ︙ | |||
270 271 272 273 274 275 276 | buffer->st_atime = buffer->st_mtime = buffer->st_ctime = timeInterval; # ifdef OF_AMIGAOS4 FreeDosObject(DOS_EXAMINEDATA, ed); # endif return 0; | | | | 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 | buffer->st_atime = buffer->st_mtime = buffer->st_ctime = timeInterval; # ifdef OF_AMIGAOS4 FreeDosObject(DOS_EXAMINEDATA, ed); # endif return 0; #elif defined(HAVE_STAT64) return stat64([path cStringWithEncoding: [OFLocale encoding]], buffer); #else return stat([path cStringWithEncoding: [OFLocale encoding]], buffer); #endif } static int of_lstat(OFString *path, of_stat_t *buffer) { #if defined(HAVE_LSTAT) && !defined(OF_WINDOWS) && !defined(OF_AMIGAOS) && \ !defined(OF_NINTENDO_3DS) && !defined(OF_WII) # ifdef HAVE_LSTAT64 return lstat64([path cStringWithEncoding: [OFLocale encoding]], buffer); # else return lstat([path cStringWithEncoding: [OFLocale encoding]], buffer); # endif #else return of_stat(path, buffer); #endif |
︙ | ︙ |
Modified src/OFHTTPURLHandler.h from [8c0000bba5] to [9220399ab4].
︙ | ︙ | |||
15 16 17 18 19 20 21 | * file. */ #import "OFURLHandler.h" OF_ASSUME_NONNULL_BEGIN | < | 15 16 17 18 19 20 21 22 23 24 25 | * file. */ #import "OFURLHandler.h" OF_ASSUME_NONNULL_BEGIN @interface OFHTTPURLHandler: OFURLHandler @end OF_ASSUME_NONNULL_END |
Added src/OFHostAddressResolver.h version [1990f9e1b6].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | /* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, * 2018, 2019 * Jonathan Schleifer <js@heap.zone> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFObject.h" #import "OFDNSResolver.h" #import "OFRunLoop.h" #import "socket.h" OF_ASSUME_NONNULL_BEGIN @class OFDNSResolverSettings; @class OFDNSResourceRecord; @class OFMutableArray OF_GENERIC(ObjectType); @class OFMutableData; @class OFString; @interface OFHostAddressResolver: OFObject <OFDNSResolverQueryDelegate> { OFString *_host; of_socket_address_family_t _addressFamily; OFDNSResolver *_resolver; OFDNSResolverSettings *_settings; of_run_loop_mode_t _Nullable _runLoopMode; id <OFDNSResolverHostDelegate> _Nullable _delegate; bool _isFQDN; size_t _searchDomainIndex; unsigned int _numExpectedResponses; OFMutableData *_addresses; } - (instancetype)initWithHost: (OFString *)host addressFamily: (of_socket_address_family_t)addressFamily resolver: (OFDNSResolver *)resolver settings: (OFDNSResolverSettings *)settings runLoopMode: (nullable of_run_loop_mode_t)runLoopMode delegate: (nullable id <OFDNSResolverHostDelegate>)delegate; - (void)asyncResolve; - (OFData *)resolve; @end OF_ASSUME_NONNULL_END |
Added src/OFHostAddressResolver.m version [90c9bb13be].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | /* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, * 2018, 2019 * Jonathan Schleifer <js@heap.zone> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #import "OFHostAddressResolver.h" #import "OFArray.h" #import "OFDNSResolver.h" #import "OFDNSResolverSettings.h" #import "OFData.h" #import "OFDate.h" #import "OFDictionary.h" #import "OFRunLoop.h" #import "OFString.h" #import "OFTimer.h" #import "OFDNSQueryFailedException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFResolveHostFailedException.h" @interface OFHostAddressResolverDelegate: OFObject <OFDNSResolverHostDelegate> { @public bool _done; OFData *_addresses; id _exception; } @end static const of_run_loop_mode_t resolveRunLoopMode = @"of_host_address_resolver_resolve_mode"; static bool isFQDN(OFString *host, unsigned int minNumberOfDotsInAbsoluteName) { const char *UTF8String; size_t length; unsigned int dots; if ([host hasSuffix: @"."]) return true; UTF8String = host.UTF8String; length = host.UTF8StringLength; dots = 0; for (size_t i = 0; i < length; i++) if (UTF8String[i] == '.') dots++; return (dots >= minNumberOfDotsInAbsoluteName); } static bool addressForRecord(OF_KINDOF(OFDNSResourceRecord *) record, const of_socket_address_t **address, of_socket_address_family_t addressFamily) { switch ([record recordType]) { #ifdef OF_HAVE_IPV6 case OF_DNS_RECORD_TYPE_AAAA: if (addressFamily != OF_SOCKET_ADDRESS_FAMILY_IPV6 && addressFamily != OF_SOCKET_ADDRESS_FAMILY_ANY) return false; break; #endif case OF_DNS_RECORD_TYPE_A: if (addressFamily != OF_SOCKET_ADDRESS_FAMILY_IPV4 && addressFamily != OF_SOCKET_ADDRESS_FAMILY_ANY) return false; break; default: return false; } *address = [record address]; return true; } static void callDelegateInMode(of_run_loop_mode_t runLoopMode, id <OFDNSResolverHostDelegate> delegate, OFDNSResolver *resolver, OFString *host, OFData *addresses, id exception) { SEL selector = @selector(resolver:didResolveHost:addresses:exception:); if ([delegate respondsToSelector: selector]) { OFTimer *timer = [OFTimer timerWithTimeInterval: 0 target: delegate selector: selector object: resolver object: host object: addresses object: exception repeats: false]; [[OFRunLoop currentRunLoop] addTimer: timer forMode: runLoopMode]; } } @implementation OFHostAddressResolver: OFObject - (instancetype)initWithHost: (OFString *)host addressFamily: (of_socket_address_family_t)addressFamily resolver: (OFDNSResolver *)resolver settings: (OFDNSResolverSettings *)settings runLoopMode: (of_run_loop_mode_t)runLoopMode delegate: (id <OFDNSResolverHostDelegate>)delegate { self = [super init]; @try { _host = [host copy]; _addressFamily = addressFamily; _resolver = [resolver retain]; _settings = [settings copy]; _runLoopMode = [runLoopMode copy]; _delegate = [delegate retain]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_host release]; [_resolver release]; [_settings release]; [_runLoopMode release]; [_delegate release]; [_addresses release]; [super dealloc]; } - (void)sendQueries { OFString *domainName; if (!_isFQDN) { OFString *searchDomain = [_settings->_searchDomains objectAtIndex: _searchDomainIndex]; domainName = [OFString stringWithFormat: @"%@.%@", _host, searchDomain]; } else domainName = _host; #ifdef OF_HAVE_IPV6 if (_addressFamily == OF_SOCKET_ADDRESS_FAMILY_IPV6 || _addressFamily == OF_SOCKET_ADDRESS_FAMILY_ANY) { OFDNSQuery *query = [OFDNSQuery queryWithDomainName: domainName DNSClass: OF_DNS_CLASS_IN recordType: OF_DNS_RECORD_TYPE_AAAA]; _numExpectedResponses++; [_resolver asyncPerformQuery: query runLoopMode: _runLoopMode delegate: self]; } #endif if (_addressFamily == OF_SOCKET_ADDRESS_FAMILY_IPV4 || _addressFamily == OF_SOCKET_ADDRESS_FAMILY_ANY) { OFDNSQuery *query = [OFDNSQuery queryWithDomainName: domainName DNSClass: OF_DNS_CLASS_IN recordType: OF_DNS_RECORD_TYPE_A]; _numExpectedResponses++; [_resolver asyncPerformQuery: query runLoopMode: _runLoopMode delegate: self]; } } - (void)resolver: (OFDNSResolver *)resolver didPerformQuery: (OFDNSQuery *)query response: (OFDNSResponse *)response exception: (id)exception { _numExpectedResponses--; if ([exception isKindOfClass: [OFDNSQueryFailedException class]] && [exception error] == OF_DNS_RESOLVER_ERROR_SERVER_NAME_ERROR && !_isFQDN && _numExpectedResponses == 0 && _addresses.count == 0 && _searchDomainIndex + 1 < _settings->_searchDomains.count) { _searchDomainIndex++; [self sendQueries]; return; } for (OF_KINDOF(OFDNSResourceRecord *) record in [response.answerRecords objectForKey: query.domainName]) { const of_socket_address_t *address; OFDNSQuery *CNAMEQuery; if ([record DNSClass] != OF_DNS_CLASS_IN) continue; if (addressForRecord(record, &address, _addressFamily)) { [_addresses addItem: address]; continue; } if ([record recordType] != OF_DNS_RECORD_TYPE_CNAME) continue; /* FIXME: Check if it's already in answers */ CNAMEQuery = [OFDNSQuery queryWithDomainName: [record alias] DNSClass: OF_DNS_CLASS_IN recordType: query.recordType]; _numExpectedResponses++; [_resolver asyncPerformQuery: CNAMEQuery runLoopMode: _runLoopMode delegate: self]; } if (_numExpectedResponses > 0) return; [_addresses makeImmutable]; if ([_delegate respondsToSelector: @selector(resolver:didResolveHost:addresses:exception:)]) [_delegate resolver: _resolver didResolveHost: _host addresses: (_addresses.count > 0 ? _addresses : nil) exception: (_addresses.count == 0 ? exception : nil)]; } - (void)asyncResolve { void *pool = objc_autoreleasePoolPush(); OFArray OF_GENERIC(OFString *) *aliases; @try { of_socket_address_t address = of_socket_address_parse_ip(_host, 0); OFData *addresses = nil; id exception = nil; if (_addressFamily == address.family || _addressFamily == OF_SOCKET_ADDRESS_FAMILY_ANY) addresses = [OFData dataWithItems: &address itemSize: sizeof(address) count: 1]; else exception = [OFInvalidArgumentException exception]; callDelegateInMode(_runLoopMode, _delegate, _resolver, _host, addresses, exception); objc_autoreleasePoolPop(pool); return; } @catch (OFInvalidFormatException *e) { } if ((aliases = [_settings->_staticHosts objectForKey: _host]) != nil) { OFMutableData *addresses = [OFMutableData dataWithItemSize: sizeof(of_socket_address_t)]; id exception = nil; for (OFString *alias in aliases) { of_socket_address_t address; @try { address = of_socket_address_parse_ip(alias, 0); } @catch (OFInvalidFormatException *e) { continue; } if (_addressFamily != address.family && _addressFamily != OF_SOCKET_ADDRESS_FAMILY_ANY) continue; [addresses addItem: &address]; } [addresses makeImmutable]; if (addresses.count == 0) { addresses = nil; exception = [OFResolveHostFailedException exceptionWithHost: _host addressFamily: _addressFamily error: OF_DNS_RESOLVER_ERROR_NO_RESULT]; } callDelegateInMode(_runLoopMode, _delegate, _resolver, _host, addresses, exception); objc_autoreleasePoolPop(pool); return; } _isFQDN = isFQDN(_host, _settings->_minNumberOfDotsInAbsoluteName); _addresses = [[OFMutableData alloc] initWithItemSize: sizeof(of_socket_address_t)]; [self sendQueries]; objc_autoreleasePoolPop(pool); } - (OFData *)resolve { void *pool = objc_autoreleasePoolPush(); OFRunLoop *runLoop = [OFRunLoop currentRunLoop]; OFHostAddressResolverDelegate *delegate; OFData *ret; delegate = [[[OFHostAddressResolverDelegate alloc] init] autorelease]; _runLoopMode = [resolveRunLoopMode copy]; _delegate = [delegate retain]; [self asyncResolve]; while (!delegate->_done) [runLoop runMode: resolveRunLoopMode beforeDate: nil]; /* Cleanup */ [runLoop runMode: resolveRunLoopMode beforeDate: [OFDate date]]; if (delegate->_exception != nil) @throw delegate->_exception; ret = [delegate->_addresses copy]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } @end @implementation OFHostAddressResolverDelegate - (void)dealloc { [_addresses release]; [_exception release]; [super dealloc]; } - (void)resolver: (OFDNSResolver *)resolver didResolveHost: (OFString *)host addresses: (OFData *)addresses exception: (id)exception { _addresses = [addresses copy]; _exception = [exception retain]; _done = true; } @end |
Modified src/OFINIFileSettings.h from [bae8a4f75c] to [0f40811c1f].
︙ | ︙ | |||
18 19 20 21 22 23 24 | #import "OFSettings.h" OF_ASSUME_NONNULL_BEGIN @class OFString; @class OFINIFile; | < | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | #import "OFSettings.h" OF_ASSUME_NONNULL_BEGIN @class OFString; @class OFINIFile; @interface OFINIFileSettings: OFSettings { OFString *_filePath; OFINIFile *_INIFile; } @end OF_ASSUME_NONNULL_END |
Modified src/OFInflate64Stream.h from [7497e2c385] to [1e8b3531bf].
︙ | ︙ | |||
30 31 32 33 34 35 36 | * * @brief A class that handles Deflate decompression transparently for an * underlying stream. */ OF_SUBCLASSING_RESTRICTED @interface OFInflate64Stream: OFStream <OFReadyForReadingObserving> { | < < < | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | * * @brief A class that handles Deflate decompression transparently for an * underlying stream. */ OF_SUBCLASSING_RESTRICTED @interface OFInflate64Stream: OFStream <OFReadyForReadingObserving> { OFStream *_stream; unsigned char _buffer[OF_INFLATE64_STREAM_BUFFER_SIZE]; uint16_t _bufferIndex, _bufferLength; uint8_t _byte; uint8_t _bitIndex, _savedBitsLength; uint16_t _savedBits; unsigned char *_Nullable _slidingWindow; |
︙ | ︙ |
Modified src/OFInflateStream.h from [a451ce0366] to [56ded0c782].
︙ | ︙ | |||
30 31 32 33 34 35 36 | * * @brief A class that handles Deflate decompression transparently for an * underlying stream. */ OF_SUBCLASSING_RESTRICTED @interface OFInflateStream: OFStream <OFReadyForReadingObserving> { | < < < | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | * * @brief A class that handles Deflate decompression transparently for an * underlying stream. */ OF_SUBCLASSING_RESTRICTED @interface OFInflateStream: OFStream <OFReadyForReadingObserving> { OFStream *_stream; unsigned char _buffer[OF_INFLATE_STREAM_BUFFER_SIZE]; uint16_t _bufferIndex, _bufferLength; uint8_t _byte; uint8_t _bitIndex, _savedBitsLength; uint16_t _savedBits; unsigned char *_Nullable _slidingWindow; |
︙ | ︙ |
Modified src/OFInflateStream.m from [5b9953e18a] to [2d02df5db2].
︙ | ︙ | |||
11 12 13 14 15 16 17 | * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ | < < | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #include <stdlib.h> #include <string.h> #include <assert.h> |
︙ | ︙ | |||
102 103 104 105 106 107 108 109 110 111 112 113 114 115 | }; #endif static const uint8_t codeLengthsOrder[19] = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 }; static struct of_huffman_tree *fixedLitLenTree, *fixedDistTree; static OF_INLINE bool tryReadBits(OFInflateStream *stream, uint16_t *bits, uint8_t count) { uint16_t ret = stream->_savedBits; assert(stream->_savedBitsLength < count); | > | 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | }; #endif static const uint8_t codeLengthsOrder[19] = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 }; static struct of_huffman_tree *fixedLitLenTree, *fixedDistTree; @implementation OFInflateStream static OF_INLINE bool tryReadBits(OFInflateStream *stream, uint16_t *bits, uint8_t count) { uint16_t ret = stream->_savedBits; assert(stream->_savedBitsLength < count); |
︙ | ︙ | |||
144 145 146 147 148 149 150 | stream->_savedBits = 0; stream->_savedBitsLength = 0; *bits = ret; return true; } | < | 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | stream->_savedBits = 0; stream->_savedBitsLength = 0; *bits = ret; return true; } + (void)initialize { uint8_t lengths[288]; if (self != [OFInflateStream class]) return; |
︙ | ︙ |
Deleted src/OFIntrospection.h version [f4fdf94694].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/OFIntrospection.m version [79c1692f33].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Modified src/OFInvertedCharacterSet.h from [1f748d556a] to [e78ee993d6].
︙ | ︙ | |||
15 16 17 18 19 20 21 | * file. */ #import "OFCharacterSet.h" OF_ASSUME_NONNULL_BEGIN | < | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | * file. */ #import "OFCharacterSet.h" OF_ASSUME_NONNULL_BEGIN @interface OFInvertedCharacterSet: OFCharacterSet { OFCharacterSet *_characterSet; bool (*_characterIsMember)(id, SEL, of_unichar_t); } - (instancetype)of_initWithCharacterSet: (OFCharacterSet *)characterSet OF_METHOD_FAMILY(init); @end OF_ASSUME_NONNULL_END |
Modified src/OFKernelEventObserver.h from [b2d4e300e7] to [1f89c2433c].
︙ | ︙ | |||
129 130 131 132 133 134 135 | #elif defined(OF_AMIGAOS) struct Task *_waitingTask; ULONG _cancelSignal; #else of_socket_t _cancelFD[2]; struct sockaddr_in _cancelAddr; #endif | | | > | | | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | #elif defined(OF_AMIGAOS) struct Task *_waitingTask; ULONG _cancelSignal; #else of_socket_t _cancelFD[2]; struct sockaddr_in _cancelAddr; #endif #ifdef OF_AMIGAOS ULONG _execSignalMask; #endif @private OFMutableData *_queueActions; OFMutableArray *_queueObjects; #ifdef OF_HAVE_THREADS OFMutex *_mutex; #endif OF_RESERVE_IVARS(4) } /*! * @brief The delegate for the OFKernelEventObserver. */ |
︙ | ︙ |
Modified src/OFKqueueKernelEventObserver.h from [04d72570f9] to [93173a129b].
︙ | ︙ | |||
17 18 19 20 21 22 23 | #import "OFKernelEventObserver.h" OF_ASSUME_NONNULL_BEGIN @class OFMutableArray OF_GENERIC(ObjectType); | < | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #import "OFKernelEventObserver.h" OF_ASSUME_NONNULL_BEGIN @class OFMutableArray OF_GENERIC(ObjectType); @interface OFKqueueKernelEventObserver: OFKernelEventObserver { int _kernelQueue; } @end OF_ASSUME_NONNULL_END |
Modified src/OFLHAArchive.m from [e91adc15fc] to [e8d8679991].
︙ | ︙ | |||
385 386 387 388 389 390 391 | if ([_decompressedStream isKindOfClass: [OFLHADecompressingStream class]]) { OFLHADecompressingStream *decompressingStream = (OFLHADecompressingStream *)_decompressedStream; [decompressingStream close]; toRead = | | | 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 | if ([_decompressedStream isKindOfClass: [OFLHADecompressingStream class]]) { OFLHADecompressingStream *decompressingStream = (OFLHADecompressingStream *)_decompressedStream; [decompressingStream close]; toRead = _entry.compressedSize - decompressingStream.bytesConsumed; stream = _stream; } if ([stream isKindOfClass: [OFSeekableStream class]] && (sizeof(of_offset_t) > 4 || toRead < INT32_MAX)) [(OFSeekableStream *)stream seekToOffset: (of_offset_t)toRead |
︙ | ︙ |
Modified src/OFLHAArchiveEntry.h from [a2fc14bd84] to [c6a8d0afe4].
︙ | ︙ | |||
29 30 31 32 33 34 35 | /*! * @class OFLHAArchiveEntry OFLHAArchiveEntry.h ObjFW/OFLHAArchiveEntry.h * * @brief A class which represents an entry in an LHA archive. */ @interface OFLHAArchiveEntry: OFObject <OFCopying, OFMutableCopying> { | < < < | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | /*! * @class OFLHAArchiveEntry OFLHAArchiveEntry.h ObjFW/OFLHAArchiveEntry.h * * @brief A class which represents an entry in an LHA archive. */ @interface OFLHAArchiveEntry: OFObject <OFCopying, OFMutableCopying> { OFString *_fileName, *_Nullable _directoryName, *_compressionMethod; uint32_t _compressedSize, _uncompressedSize; OFDate *_date; uint8_t _headerLevel; uint16_t _CRC16; uint8_t _operatingSystemIdentifier; OFString *_Nullable _fileComment; |
︙ | ︙ |
Modified src/OFLHAArchiveEntry.m from [436ef99699] to [f7b5894775].
︙ | ︙ | |||
13 14 15 16 17 18 19 | * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" | < < > | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #include <string.h> #import "OFLHAArchiveEntry.h" #import "OFLHAArchiveEntry+Private.h" #import "OFArray.h" #import "OFData.h" #import "OFDate.h" #import "OFNumber.h" #import "OFStream.h" #import "OFString.h" #import "crc16.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFOutOfRangeException.h" #import "OFUnsupportedVersionException.h" @implementation OFLHAArchiveEntry static OFDate * parseMSDOSDate(uint32_t MSDOSDate) { uint16_t year = ((MSDOSDate & 0xFE000000) >> 25) + 1980; uint8_t month = (MSDOSDate & 0x1E00000) >> 21; uint8_t day = (MSDOSDate & 0x1F); uint8_t hour = (MSDOSDate & 0xF800) >> 11; |
︙ | ︙ | |||
304 305 306 307 308 309 310 | *fileName = cString + pos; *fileNameLength = length - pos; *directoryName = cString; *directoryNameLength = pos; } | < | 303 304 305 306 307 308 309 310 311 312 313 314 315 316 | *fileName = cString + pos; *fileNameLength = length - pos; *directoryName = cString; *directoryNameLength = pos; } + (instancetype)entryWithFileName: (OFString *)fileName { return [[[self alloc] initWithFileName: fileName] autorelease]; } - (instancetype)init { |
︙ | ︙ |
Modified src/OFLHADecompressingStream.h from [e5a15c8e0b] to [e29da2420d].
︙ | ︙ | |||
17 18 19 20 21 22 23 | #import "OFStream.h" OF_ASSUME_NONNULL_BEGIN #define OF_LHA_DECOMPRESSING_STREAM_BUFFER_SIZE 4096 | < < > > | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | #import "OFStream.h" OF_ASSUME_NONNULL_BEGIN #define OF_LHA_DECOMPRESSING_STREAM_BUFFER_SIZE 4096 @interface OFLHADecompressingStream: OFStream { OFStream *_stream; uint8_t _distanceBits, _dictionaryBits; unsigned char _buffer[OF_LHA_DECOMPRESSING_STREAM_BUFFER_SIZE]; uint32_t _bytesConsumed; uint16_t _bufferIndex, _bufferLength; uint8_t _byte; uint8_t _bitIndex, _savedBitsLength; uint16_t _savedBits; unsigned char *_slidingWindow; uint32_t _slidingWindowIndex, _slidingWindowMask; int _state; uint16_t _symbolsLeft; struct of_huffman_tree *_Nullable _codeLenTree, *_Nullable _litLenTree; struct of_huffman_tree *_Nullable _distTree, *_Nullable _treeIter; uint16_t _codesCount, _codesReceived; bool _currentIsExtendedLength, _skip; uint8_t *_Nullable _codesLengths; uint16_t _length; uint32_t _distance; } @property (readonly, nonatomic) uint32_t bytesConsumed; - (instancetype)of_initWithStream: (OFStream *)stream distanceBits: (uint8_t)distanceBits dictionaryBits: (uint8_t)dictionaryBits; @end OF_ASSUME_NONNULL_END |
Modified src/OFLHADecompressingStream.m from [3f3861d786] to [4bb7cbcba0].
︙ | ︙ | |||
40 41 42 43 44 45 46 47 48 49 50 51 52 53 | STATE_DIST_TREE_SINGLE, STATE_BLOCK_LITLEN, STATE_BLOCK_DIST_LENGTH, STATE_BLOCK_DIST_LENGTH_EXTRA, STATE_BLOCK_LEN_DIST_PAIR }; static OF_INLINE bool tryReadBits(OFLHADecompressingStream *stream, uint16_t *bits, uint8_t count) { uint16_t ret = stream->_savedBits; assert(stream->_savedBitsLength < count); | > > > | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | STATE_DIST_TREE_SINGLE, STATE_BLOCK_LITLEN, STATE_BLOCK_DIST_LENGTH, STATE_BLOCK_DIST_LENGTH_EXTRA, STATE_BLOCK_LEN_DIST_PAIR }; @implementation OFLHADecompressingStream @synthesize bytesConsumed = _bytesConsumed; static OF_INLINE bool tryReadBits(OFLHADecompressingStream *stream, uint16_t *bits, uint8_t count) { uint16_t ret = stream->_savedBits; assert(stream->_savedBitsLength < count); |
︙ | ︙ | |||
87 88 89 90 91 92 93 | stream->_savedBits = 0; stream->_savedBitsLength = 0; *bits = ret; return true; } | < | 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | stream->_savedBits = 0; stream->_savedBitsLength = 0; *bits = ret; return true; } - (instancetype)of_initWithStream: (OFStream *)stream distanceBits: (uint8_t)distanceBits dictionaryBits: (uint8_t)dictionaryBits { self = [super init]; @try { |
︙ | ︙ |
Modified src/OFList.h from [c1be030244] to [4ff6f82ebc].
︙ | ︙ | |||
169 170 171 172 173 174 175 | */ - (void)removeAllObjects; #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) # undef ObjectType #endif @end | < < < < < < < < < < < < | 169 170 171 172 173 174 175 176 | */ - (void)removeAllObjects; #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) # undef ObjectType #endif @end OF_ASSUME_NONNULL_END |
Modified src/OFList.m from [146f486f61] to [60f4af0c33].
︙ | ︙ | |||
23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #import "OFList.h" #import "OFString.h" #import "OFXMLElement.h" #import "OFArray.h" #import "OFEnumerationMutationException.h" #import "OFInvalidArgumentException.h" @implementation OFList @synthesize firstListObject = _firstListObject; @synthesize lastListObject = _lastListObject; + (instancetype)list { | > > > > > > > > > > > > | 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 | #import "OFList.h" #import "OFString.h" #import "OFXMLElement.h" #import "OFArray.h" #import "OFEnumerationMutationException.h" #import "OFInvalidArgumentException.h" @interface OFListEnumerator: OFEnumerator { OFList *_list; of_list_object_t *_Nullable _current; unsigned long _mutations; unsigned long *_Nullable _mutationsPtr; } - (instancetype)initWithList: (OFList *)list mutationsPointer: (unsigned long *)mutationsPtr; @end @implementation OFList @synthesize firstListObject = _firstListObject; @synthesize lastListObject = _lastListObject; + (instancetype)list { |
︙ | ︙ |
Modified src/OFMapTableDictionary.h from [e4b08c07d4] to [c6f471998e].
︙ | ︙ | |||
18 19 20 21 22 23 24 | #import "OFDictionary.h" OF_ASSUME_NONNULL_BEGIN @class OFMapTable; @class OFMapTableEnumerator; | < | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #import "OFDictionary.h" OF_ASSUME_NONNULL_BEGIN @class OFMapTable; @class OFMapTableEnumerator; @interface OFMapTableDictionary: OFDictionary { OFMapTable *_mapTable; } - (instancetype)initWithCapacity: (size_t)capacity; @end OF_ASSUME_NONNULL_END |
Modified src/OFMapTableSet.h from [87db5f22c7] to [955e132003].
︙ | ︙ | |||
17 18 19 20 21 22 23 | #import "OFSet.h" OF_ASSUME_NONNULL_BEGIN @class OFMapTable; | < | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | #import "OFSet.h" OF_ASSUME_NONNULL_BEGIN @class OFMapTable; @interface OFMapTableSet: OFSet { OFMapTable *_mapTable; } - (instancetype)initWithCapacity: (size_t)capacity; @end OF_ASSUME_NONNULL_END |
Modified src/OFMutableAdjacentArray.h from [51288ab7a0] to [ba9ae1bdf2].
︙ | ︙ | |||
17 18 19 20 21 22 23 | #import "OFArray.h" OF_ASSUME_NONNULL_BEGIN @class OFMutableData; | < | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #import "OFArray.h" OF_ASSUME_NONNULL_BEGIN @class OFMutableData; @interface OFMutableAdjacentArray: OFMutableArray { OFMutableData *_array; unsigned long _mutations; } @end OF_ASSUME_NONNULL_END |
Modified src/OFMutableAdjacentArray.m from [41904cfc7c] to [5f88adbbe0].
︙ | ︙ | |||
17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #include "config.h" #include <string.h> #import "OFMutableAdjacentArray.h" #import "OFAdjacentArray.h" #import "OFData.h" #import "OFEnumerationMutationException.h" #import "OFInvalidArgumentException.h" #import "OFOutOfRangeException.h" @implementation OFMutableAdjacentArray | > | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #include "config.h" #include <string.h> #import "OFMutableAdjacentArray.h" #import "OFAdjacentArray.h" #import "OFArray+Private.h" #import "OFData.h" #import "OFEnumerationMutationException.h" #import "OFInvalidArgumentException.h" #import "OFOutOfRangeException.h" @implementation OFMutableAdjacentArray |
︙ | ︙ |
Modified src/OFMutableArray.h from [34a09a316e] to [97f317cd8c].
︙ | ︙ | |||
42 43 44 45 46 47 48 | * @ref replaceObjectAtIndex:withObject:, @ref removeObjectAtIndex: as * well as all methods of @ref OFArray that need to be implemented. */ @interface OFMutableArray OF_GENERIC(ObjectType): OFArray OF_GENERIC(ObjectType) #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) # define ObjectType id #endif | < < < < | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | * @ref replaceObjectAtIndex:withObject:, @ref removeObjectAtIndex: as * well as all methods of @ref OFArray that need to be implemented. */ @interface OFMutableArray OF_GENERIC(ObjectType): OFArray OF_GENERIC(ObjectType) #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) # define ObjectType id #endif /*! * @brief Creates a new OFMutableArray with enough memory to hold the specified * number of objects. * * @param capacity The initial capacity for the OFMutableArray * @return A new autoreleased OFMutableArray */ |
︙ | ︙ |
Modified src/OFMutableDictionary.h from [e6550bad92] to [43070c71d1].
︙ | ︙ | |||
43 44 45 46 47 48 49 | */ @interface OFMutableDictionary OF_GENERIC(KeyType, ObjectType): OFDictionary OF_GENERIC(KeyType, ObjectType) #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) # define KeyType id # define ObjectType id #endif | < < < < | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | */ @interface OFMutableDictionary OF_GENERIC(KeyType, ObjectType): OFDictionary OF_GENERIC(KeyType, ObjectType) #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) # define KeyType id # define ObjectType id #endif /*! * @brief Creates a new OFMutableDictionary with enough memory to hold the * specified number of objects. * * @param capacity The initial capacity for the OFMutableDictionary * @return A new autoreleased OFMutableDictionary */ |
︙ | ︙ |
Modified src/OFMutableMapTableDictionary.h from [4d2fb14c64] to [dec5e52f1e].
︙ | ︙ | |||
17 18 19 20 21 22 23 | #import "OFDictionary.h" OF_ASSUME_NONNULL_BEGIN @class OFMapTable; | < | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #import "OFDictionary.h" OF_ASSUME_NONNULL_BEGIN @class OFMapTable; @interface OFMutableMapTableDictionary: OFMutableDictionary { OFMapTable *_mapTable; } @end OF_ASSUME_NONNULL_END |
Modified src/OFMutableMapTableSet.h from [184041bad3] to [59911fabdb].
︙ | ︙ | |||
17 18 19 20 21 22 23 | #import "OFMutableSet.h" OF_ASSUME_NONNULL_BEGIN @class OFMapTable; | < | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #import "OFMutableSet.h" OF_ASSUME_NONNULL_BEGIN @class OFMapTable; @interface OFMutableMapTableSet: OFMutableSet { OFMapTable *_mapTable; } @end OF_ASSUME_NONNULL_END |
Modified src/OFMutableSet.h from [ec355518ec] to [9b1889a14f].
︙ | ︙ | |||
27 28 29 30 31 32 33 | * @note Subclasses must implement @ref addObject:, @ref removeObject: as well * as all methods of @ref OFSet that need to be implemented. */ @interface OFMutableSet OF_GENERIC(ObjectType): OFSet OF_GENERIC(ObjectType) #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) # define ObjectType id #endif | < < < < | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | * @note Subclasses must implement @ref addObject:, @ref removeObject: as well * as all methods of @ref OFSet that need to be implemented. */ @interface OFMutableSet OF_GENERIC(ObjectType): OFSet OF_GENERIC(ObjectType) #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) # define ObjectType id #endif /*! * @brief Creates a new OFMutableSet with enough memory to hold the specified * number of objects. * * @param capacity The initial capacity for the OFMutableSet * @return A new autoreleased OFMutableSet */ |
︙ | ︙ |
Modified src/OFMutableString.h from [721df996ad] to [b9fb78b26e].
︙ | ︙ | |||
21 22 23 24 25 26 27 | /*! * @class OFMutableString OFString.h ObjFW/OFString.h * * @brief A class for storing and modifying strings. */ @interface OFMutableString: OFString | < < < < | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | /*! * @class OFMutableString OFString.h ObjFW/OFString.h * * @brief A class for storing and modifying strings. */ @interface OFMutableString: OFString /*! * @brief Sets the character at the specified index. * * @param character The character to set * @param index The index where to set the character */ - (void)setCharacter: (of_unichar_t)character |
︙ | ︙ |
Modified src/OFMutableUTF8String.h from [bde0a714b5] to [2bea88fa1e].
︙ | ︙ | |||
16 17 18 19 20 21 22 | */ #import "OFMutableString.h" #import "OFUTF8String.h" OF_ASSUME_NONNULL_BEGIN | < < | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | */ #import "OFMutableString.h" #import "OFUTF8String.h" OF_ASSUME_NONNULL_BEGIN @interface OFMutableUTF8String: OFMutableString { struct of_string_utf8_ivars *restrict _s; struct of_string_utf8_ivars _storage; } @end OF_ASSUME_NONNULL_END |
Modified src/OFMutableUTF8String.m from [e22aad1130] to [3bd226f623].
︙ | ︙ | |||
372 373 374 375 376 377 378 | _s->cStringLength += UTF8StringLength; _s->length += string.length; _s->cString[_s->cStringLength] = 0; if ([string isKindOfClass: [OFUTF8String class]] || [string isKindOfClass: [OFMutableUTF8String class]]) { | | | 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | _s->cStringLength += UTF8StringLength; _s->length += string.length; _s->cString[_s->cStringLength] = 0; if ([string isKindOfClass: [OFUTF8String class]] || [string isKindOfClass: [OFMutableUTF8String class]]) { if (((OFMutableUTF8String *)string)->_s->isUTF8) _s->isUTF8 = true; } else _s->isUTF8 = true; } - (void)appendCharacters: (const of_unichar_t *)characters length: (size_t)length |
︙ | ︙ | |||
547 548 549 550 551 552 553 | _s->cString[newCStringLength] = '\0'; _s->cStringLength = newCStringLength; _s->length += string.length; if ([string isKindOfClass: [OFUTF8String class]] || [string isKindOfClass: [OFMutableUTF8String class]]) { | | | 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 | _s->cString[newCStringLength] = '\0'; _s->cStringLength = newCStringLength; _s->length += string.length; if ([string isKindOfClass: [OFUTF8String class]] || [string isKindOfClass: [OFMutableUTF8String class]]) { if (((OFMutableUTF8String *)string)->_s->isUTF8) _s->isUTF8 = true; } else _s->isUTF8 = true; } - (void)deleteCharactersInRange: (of_range_t)range { |
︙ | ︙ | |||
640 641 642 643 644 645 646 | size: newCStringLength + 1]; _s->cStringLength = newCStringLength; _s->length = newLength; if ([replacement isKindOfClass: [OFUTF8String class]] || [replacement isKindOfClass: [OFMutableUTF8String class]]) { | | | 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 | size: newCStringLength + 1]; _s->cStringLength = newCStringLength; _s->length = newLength; if ([replacement isKindOfClass: [OFUTF8String class]] || [replacement isKindOfClass: [OFMutableUTF8String class]]) { if (((OFMutableUTF8String *)replacement)->_s->isUTF8) _s->isUTF8 = true; } else _s->isUTF8 = true; } - (void)replaceOccurrencesOfString: (OFString *)string withString: (OFString *)replacement |
︙ | ︙ | |||
727 728 729 730 731 732 733 | _s->hashed = false; _s->cString = newCString; _s->cStringLength = newCStringLength; _s->length = newLength; if ([replacement isKindOfClass: [OFUTF8String class]] || [replacement isKindOfClass: [OFMutableUTF8String class]]) { | | | 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 | _s->hashed = false; _s->cString = newCString; _s->cStringLength = newCStringLength; _s->length = newLength; if ([replacement isKindOfClass: [OFUTF8String class]] || [replacement isKindOfClass: [OFMutableUTF8String class]]) { if (((OFMutableUTF8String *)replacement)->_s->isUTF8) _s->isUTF8 = true; } else _s->isUTF8 = true; } - (void)deleteLeadingWhitespaces { |
︙ | ︙ |
Modified src/OFNonretainedObjectValue.h from [36f80cbb4e] to [c355b53946].
︙ | ︙ | |||
15 16 17 18 19 20 21 | * file. */ #import "OFValue.h" OF_ASSUME_NONNULL_BEGIN | < | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | * file. */ #import "OFValue.h" OF_ASSUME_NONNULL_BEGIN @interface OFNonretainedObjectValue: OFValue { id _object; } @end OF_ASSUME_NONNULL_END |
Modified src/OFNumber.h from [1367656c87] to [04b36e645f].
︙ | ︙ | |||
294 295 296 297 298 299 300 301 302 303 304 305 306 307 | @property (readonly, nonatomic) float floatValue; /*! * @brief The OFNumber as a `double`. */ @property (readonly, nonatomic) double doubleValue; #ifdef OF_HAVE_UNAVAILABLE + (instancetype)valueWithBytes: (const void *)bytes objCType: (const char *)objCType OF_UNAVAILABLE; + (instancetype)valueWithPointer: (const void *)pointer OF_UNAVAILABLE; + (instancetype)valueWithNonretainedObject: (id)object OF_UNAVAILABLE; + (instancetype)valueWithRange: (of_range_t)range OF_UNAVAILABLE; + (instancetype)valueWithPoint: (of_point_t)point OF_UNAVAILABLE; | > > > > > | 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | @property (readonly, nonatomic) float floatValue; /*! * @brief The OFNumber as a `double`. */ @property (readonly, nonatomic) double doubleValue; /*! * @brief The OFNumber as a string. */ @property (readonly, nonatomic) OFString *stringValue; #ifdef OF_HAVE_UNAVAILABLE + (instancetype)valueWithBytes: (const void *)bytes objCType: (const char *)objCType OF_UNAVAILABLE; + (instancetype)valueWithPointer: (const void *)pointer OF_UNAVAILABLE; + (instancetype)valueWithNonretainedObject: (id)object OF_UNAVAILABLE; + (instancetype)valueWithRange: (of_range_t)range OF_UNAVAILABLE; + (instancetype)valueWithPoint: (of_point_t)point OF_UNAVAILABLE; |
︙ | ︙ |
Modified src/OFNumber.m from [402455fc05] to [f90d5af790].
︙ | ︙ | |||
1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 | - (id)copy { return [self retain]; } - (OFString *)description { OFMutableString *ret; switch (_type) { case OF_NUMBER_TYPE_BOOL: return (_value.bool_ ? @"true" : @"false"); case OF_NUMBER_TYPE_UCHAR: | > > > > > | 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 | - (id)copy { return [self retain]; } - (OFString *)description { return [self stringValue]; } - (OFString *)stringValue { OFMutableString *ret; switch (_type) { case OF_NUMBER_TYPE_BOOL: return (_value.bool_ ? @"true" : @"false"); case OF_NUMBER_TYPE_UCHAR: |
︙ | ︙ |
Modified src/OFObject.m from [c440638f52] to [507689f6ed].
︙ | ︙ | |||
101 102 103 104 105 106 107 | } allocFailedException; uint32_t of_hash_seed; static const char * typeEncodingForSelector(Class class, SEL selector) { | < < < | | | < | 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | } allocFailedException; uint32_t of_hash_seed; static const char * typeEncodingForSelector(Class class, SEL selector) { Method method; if ((method = class_getInstanceMethod(class, selector)) == NULL) return NULL; return method_getTypeEncoding(method); } #if !defined(OF_APPLE_RUNTIME) || defined(__OBJC2__) static void uncaughtExceptionHandler(id exception) { OFString *description = [exception description]; |
︙ | ︙ | |||
360 361 362 363 364 365 366 367 368 369 370 | return class_replaceMethod(self, selector, method, typeEncodingForSelector(class, selector)); } + (void)inheritMethodsFromClass: (Class)class { Class superclass = [self superclass]; if ([self isSubclassOfClass: class]) return; | > > < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 | return class_replaceMethod(self, selector, method, typeEncodingForSelector(class, selector)); } + (void)inheritMethodsFromClass: (Class)class { Class superclass = [self superclass]; Method *methodList; unsigned int count; if ([self isSubclassOfClass: class]) return; methodList = class_copyMethodList(object_getClass(class), &count); @try { for (unsigned int i = 0; i < count; i++) { SEL selector = method_getName(methodList[i]); /* * Don't replace methods implemented in the receiving |
︙ | ︙ | |||
444 445 446 447 448 449 450 | [self replaceInstanceMethod: selector withMethodFromClass: class]; } } @finally { free(methodList); } | < | 401 402 403 404 405 406 407 408 409 410 411 412 413 414 | [self replaceInstanceMethod: selector withMethodFromClass: class]; } } @finally { free(methodList); } [self inheritMethodsFromClass: superclass]; } + (bool)resolveClassMethod: (SEL)selector { return NO; |
︙ | ︙ |
Modified src/OFPlugin.h from [cb3a1304f8] to [ce507fec65].
︙ | ︙ | |||
36 37 38 39 40 41 42 | /*! * @class OFPlugin OFPlugin.h ObjFW/OFPlugin.h * * @brief Provides a system for loading plugins at runtime. */ @interface OFPlugin: OFObject { | | | 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | /*! * @class OFPlugin OFPlugin.h ObjFW/OFPlugin.h * * @brief Provides a system for loading plugins at runtime. */ @interface OFPlugin: OFObject { of_plugin_handle_t _pluginHandle; OF_RESERVE_IVARS(4) } /*! * @brief Loads a plugin from a file. * * @param path Path to the plugin file. The suffix is appended automatically. |
︙ | ︙ |
Modified src/OFPlugin.m from [503261dce9] to [e6fd971342].
︙ | ︙ | |||
105 106 107 108 109 110 111 | initPlugin = (init_plugin_t)(uintptr_t)of_dlsym(handle, "init_plugin"); if (initPlugin == (init_plugin_t)0 || (plugin = initPlugin()) == nil) { of_dlclose(handle); @throw [OFInitializationFailedException exceptionWithClass: self]; } | | | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | initPlugin = (init_plugin_t)(uintptr_t)of_dlsym(handle, "init_plugin"); if (initPlugin == (init_plugin_t)0 || (plugin = initPlugin()) == nil) { of_dlclose(handle); @throw [OFInitializationFailedException exceptionWithClass: self]; } plugin->_pluginHandle = handle; return plugin; } - (instancetype)init { if ([self isMemberOfClass: [OFPlugin class]]) { @try { |
︙ | ︙ | |||
127 128 129 130 131 132 133 | } return [super init]; } - (void)dealloc { | | | 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | } return [super init]; } - (void)dealloc { of_plugin_handle_t h = _pluginHandle; [super dealloc]; of_dlclose(h); } @end |
Modified src/OFPointValue.h from [88e07dfeed] to [ee56f0af65].
︙ | ︙ | |||
15 16 17 18 19 20 21 | * file. */ #import "OFValue.h" OF_ASSUME_NONNULL_BEGIN | < | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | * file. */ #import "OFValue.h" OF_ASSUME_NONNULL_BEGIN @interface OFPointValue: OFValue { of_point_t _point; } @end OF_ASSUME_NONNULL_END |
Modified src/OFPointerValue.h from [bc4ae528fd] to [c394de6a61].
︙ | ︙ | |||
15 16 17 18 19 20 21 | * file. */ #import "OFValue.h" OF_ASSUME_NONNULL_BEGIN | < | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | * file. */ #import "OFValue.h" OF_ASSUME_NONNULL_BEGIN @interface OFPointerValue: OFValue { void *_pointer; } @end OF_ASSUME_NONNULL_END |
Modified src/OFPollKernelEventObserver.h from [2770775881] to [aa8c14235f].
︙ | ︙ | |||
17 18 19 20 21 22 23 | #import "OFKernelEventObserver.h" OF_ASSUME_NONNULL_BEGIN @class OFMutableData; | < | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | #import "OFKernelEventObserver.h" OF_ASSUME_NONNULL_BEGIN @class OFMutableData; @interface OFPollKernelEventObserver: OFKernelEventObserver { OFMutableData *_FDs; int _maxFD; id __unsafe_unretained *_FDToObject; } @end OF_ASSUME_NONNULL_END |
Modified src/OFRangeCharacterSet.h from [a2771ad1c7] to [d6286761a3].
︙ | ︙ | |||
15 16 17 18 19 20 21 | * file. */ #import "OFCharacterSet.h" OF_ASSUME_NONNULL_BEGIN | < | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | * file. */ #import "OFCharacterSet.h" OF_ASSUME_NONNULL_BEGIN @interface OFRangeCharacterSet: OFCharacterSet { of_range_t _range; } @end OF_ASSUME_NONNULL_END |
Modified src/OFRangeValue.h from [a8ef163be5] to [485fced595].
︙ | ︙ | |||
15 16 17 18 19 20 21 | * file. */ #import "OFValue.h" OF_ASSUME_NONNULL_BEGIN | < | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | * file. */ #import "OFValue.h" OF_ASSUME_NONNULL_BEGIN @interface OFRangeValue: OFValue { of_range_t _range; } @end OF_ASSUME_NONNULL_END |
Modified src/OFRectangleValue.h from [7066e1a221] to [e6635df87d].
︙ | ︙ | |||
15 16 17 18 19 20 21 | * file. */ #import "OFValue.h" OF_ASSUME_NONNULL_BEGIN | < | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | * file. */ #import "OFValue.h" OF_ASSUME_NONNULL_BEGIN @interface OFRectangleValue: OFValue { of_rectangle_t _rectangle; } @end OF_ASSUME_NONNULL_END |
Modified src/OFSHA224Or256Hash.h from [6b1a277f58] to [e39de03a34].
︙ | ︙ | |||
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | /*! * @class OFSHA224Or256Hash OFSHA224Or256Hash.h ObjFW/OFSHA224Or256Hash.h * * @brief A base class for SHA-224 and SHA-256. */ @interface OFSHA224Or256Hash: OFObject <OFCryptoHash> { OFSecureData *_iVarsData; struct of_sha224_or_256_hash_ivars { uint32_t state[8]; uint64_t bits; union of_sha224_or_256_hash_buffer { uint8_t bytes[64]; uint32_t words[64]; } buffer; size_t bufferLength; } *_iVars; bool _calculated; OF_RESERVE_IVARS(4) } @end OF_ASSUME_NONNULL_END | > > > | 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 | /*! * @class OFSHA224Or256Hash OFSHA224Or256Hash.h ObjFW/OFSHA224Or256Hash.h * * @brief A base class for SHA-224 and SHA-256. */ @interface OFSHA224Or256Hash: OFObject <OFCryptoHash> { @private OFSecureData *_iVarsData; @protected struct of_sha224_or_256_hash_ivars { uint32_t state[8]; uint64_t bits; union of_sha224_or_256_hash_buffer { uint8_t bytes[64]; uint32_t words[64]; } buffer; size_t bufferLength; } *_iVars; @private bool _calculated; OF_RESERVE_IVARS(4) } @end OF_ASSUME_NONNULL_END |
Modified src/OFSHA384Or512Hash.h from [835b1d3d02] to [10ea7023d1].
︙ | ︙ | |||
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | /*! * @class OFSHA384Or512Hash OFSHA384Or512Hash.h ObjFW/OFSHA384Or512Hash.h * * @brief A base class for SHA-384 and SHA-512. */ @interface OFSHA384Or512Hash: OFObject <OFCryptoHash> { OFSecureData *_iVarsData; struct of_sha384_or_512_hash_ivars { uint64_t state[8]; uint64_t bits[2]; union of_sha384_or_512_hash_buffer { uint8_t bytes[128]; uint64_t words[80]; } buffer; size_t bufferLength; } *_iVars; bool _calculated; OF_RESERVE_IVARS(4) } @end OF_ASSUME_NONNULL_END | > > > | 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 | /*! * @class OFSHA384Or512Hash OFSHA384Or512Hash.h ObjFW/OFSHA384Or512Hash.h * * @brief A base class for SHA-384 and SHA-512. */ @interface OFSHA384Or512Hash: OFObject <OFCryptoHash> { @private OFSecureData *_iVarsData; @protected struct of_sha384_or_512_hash_ivars { uint64_t state[8]; uint64_t bits[2]; union of_sha384_or_512_hash_buffer { uint8_t bytes[128]; uint64_t words[80]; } buffer; size_t bufferLength; } *_iVars; @private bool _calculated; OF_RESERVE_IVARS(4) } @end OF_ASSUME_NONNULL_END |
Modified src/OFSecureData.h from [4b4455fb4b] to [95d6612ecd].
︙ | ︙ | |||
18 19 20 21 22 23 24 | #import "OFData.h" OF_ASSUME_NONNULL_BEGIN /*! * @class OFSecureData OFSecureData.h ObjFW/OFSecureData.h * | | | | | > > > < > > > | < < < < < < < | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | #import "OFData.h" OF_ASSUME_NONNULL_BEGIN /*! * @class OFSecureData OFSecureData.h ObjFW/OFSecureData.h * * @brief A class for storing arbitrary data in secure (non-swappable) memory, * securely wiping it when it gets deallocated. * * @warning Non-swappable memory might be unavailable, in which case this falls * back to swappable memory, but still wipes the data when it gets * deallocated. Check the @ref swappable property to see whether a * particular OFSecureData was allocated in swappable memory. */ OF_SUBCLASSING_RESTRICTED @interface OFSecureData: OFData { struct page *_page; bool _swappable; } /*! * @brief Whether the OFSecureData is in swappable memory. */ @property (readonly, nonatomic, getter=isSwappable) bool swappable; /*! * @brief All items of the OFSecureData as a C array. * * Modifying the returned array directly is allowed and will change the contents * of the data. */ @property (readonly, nonatomic) void *mutableItems OF_RETURNS_INNER_POINTER; /*! * @brief Preallocates the specified number of bytes. * * This is useful to allocate secure memory before enabling a sandbox that does * not allow it anymore. * * @note This may only be called once per thread! |
︙ | ︙ |
Modified src/OFSecureData.m from [fa28a56f57] to [0b2ff22574].
︙ | ︙ | |||
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 | #endif #define CHUNK_SIZE 16 struct page { struct page *next, *previous; void *map; unsigned char *page; }; #if defined(OF_HAVE_COMPILER_TLS) static thread_local struct page *firstPage = NULL; static thread_local struct page *lastPage = NULL; static thread_local struct page **preallocatedPages = NULL; static thread_local size_t numPreallocatedPages = 0; #elif defined(OF_HAVE_THREADS) static of_tlskey_t firstPageKey, lastPageKey; static of_tlskey_t preallocatedPagesKey, numPreallocatedPagesKey; #else static struct page *firstPage = NULL; static struct page *lastPage = NULL; static struct page **preallocatedPages = NULL; static size_t numPreallocatedPages = 0; #endif static void * | > | | < < > > | > | | 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 | #endif #define CHUNK_SIZE 16 struct page { struct page *next, *previous; void *map; bool swappable; unsigned char *page; }; #if defined(OF_HAVE_COMPILER_TLS) static thread_local struct page *firstPage = NULL; static thread_local struct page *lastPage = NULL; static thread_local struct page **preallocatedPages = NULL; static thread_local size_t numPreallocatedPages = 0; #elif defined(OF_HAVE_THREADS) static of_tlskey_t firstPageKey, lastPageKey; static of_tlskey_t preallocatedPagesKey, numPreallocatedPagesKey; #else static struct page *firstPage = NULL; static struct page *lastPage = NULL; static struct page **preallocatedPages = NULL; static size_t numPreallocatedPages = 0; #endif static void * mapPages(size_t numPages, bool *swappable) { size_t pageSize = [OFSystemInfo pageSize]; void *pointer; if (numPages > SIZE_MAX / pageSize) @throw [OFOutOfRangeException exception]; #if defined(HAVE_MMAP) && defined(HAVE_MLOCK) && defined(MAP_ANON) if ((pointer = mmap(NULL, numPages * pageSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0)) == MAP_FAILED) @throw [OFOutOfMemoryException exceptionWithRequestedSize: pageSize]; *swappable = (mlock(pointer, numPages * pageSize) != 0); #else if ((pointer = malloc(numPages * pageSize)) == NULL) @throw [OFOutOfMemoryException exceptionWithRequestedSize: pageSize]; *swappable = true; #endif return pointer; } static void unmapPages(void *pointer, size_t numPages, bool swappable) { size_t pageSize = [OFSystemInfo pageSize]; if (numPages > SIZE_MAX / pageSize) @throw [OFOutOfRangeException exception]; #if defined(HAVE_MMAP) && defined(HAVE_MLOCK) && defined(MAP_ANON) if (!swappable) munlock(pointer, numPages * pageSize); munmap(pointer, numPages * pageSize); #else free(pointer); #endif } static struct page * |
︙ | ︙ | |||
150 151 152 153 154 155 156 | @throw [OFOutOfMemoryException exceptionWithRequestedSize: sizeof(*page)]; if ((page->map = calloc(1, mapSize)) == NULL) @throw [OFOutOfMemoryException exceptionWithRequestedSize: mapSize]; | | | 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | @throw [OFOutOfMemoryException exceptionWithRequestedSize: sizeof(*page)]; if ((page->map = calloc(1, mapSize)) == NULL) @throw [OFOutOfMemoryException exceptionWithRequestedSize: mapSize]; page->page = mapPages(1, &page->swappable); of_explicit_memset(page->page, 0, pageSize); #if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) lastPage = of_tlskey_get(lastPageKey); #endif page->previous = lastPage; |
︙ | ︙ | |||
189 190 191 192 193 194 195 | size_t pageSize = [OFSystemInfo pageSize]; size_t mapSize = OF_ROUND_UP_POW2(8, pageSize / CHUNK_SIZE) / 8; for (size_t i = 0; i < mapSize; i++) if (map[i] != 0) return; | | | 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | size_t pageSize = [OFSystemInfo pageSize]; size_t mapSize = OF_ROUND_UP_POW2(8, pageSize / CHUNK_SIZE) / 8; for (size_t i = 0; i < mapSize; i++) if (map[i] != 0) return; unmapPages(page->page, 1, page->swappable); free(page->map); if (page->previous != NULL) page->previous->next = page->next; if (page->next != NULL) page->next->previous = page->previous; |
︙ | ︙ | |||
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | of_explicit_memset(pointer, 0, bytes); for (size_t i = 0; i < chunks; i++) of_bitset_clear(page->map, chunkIndex + i); } @implementation OFSecureData #if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) + (void)initialize { if (self != [OFSecureData class]) return; if (!of_tlskey_new(&firstPageKey) || !of_tlskey_new(&lastPageKey) || !of_tlskey_new(&preallocatedPagesKey) || !of_tlskey_new(&numPreallocatedPagesKey)) @throw [OFInitializationFailedException exceptionWithClass: self]; } #endif | > > < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 | of_explicit_memset(pointer, 0, bytes); for (size_t i = 0; i < chunks; i++) of_bitset_clear(page->map, chunkIndex + i); } @implementation OFSecureData @synthesize swappable = _swappable; #if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) + (void)initialize { if (self != [OFSecureData class]) return; if (!of_tlskey_new(&firstPageKey) || !of_tlskey_new(&lastPageKey) || !of_tlskey_new(&preallocatedPagesKey) || !of_tlskey_new(&numPreallocatedPagesKey)) @throw [OFInitializationFailedException exceptionWithClass: self]; } #endif + (void)preallocateMemoryWithSize: (size_t)size { size_t pageSize = [OFSystemInfo pageSize]; size_t numPages = OF_ROUND_UP_POW2(pageSize, size) / pageSize; #if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) struct page **preallocatedPages = of_tlskey_get(preallocatedPagesKey); size_t numPreallocatedPages; |
︙ | ︙ | |||
394 395 396 397 398 399 400 | size_t pageSize = [OFSystemInfo pageSize]; if (count > SIZE_MAX / itemSize) @throw [OFOutOfRangeException exception]; if (count * itemSize >= pageSize) _items = mapPages(OF_ROUND_UP_POW2(pageSize, | | | 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 | size_t pageSize = [OFSystemInfo pageSize]; if (count > SIZE_MAX / itemSize) @throw [OFOutOfRangeException exception]; if (count * itemSize >= pageSize) _items = mapPages(OF_ROUND_UP_POW2(pageSize, count * itemSize) / pageSize, &_swappable); else { #if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) struct page *lastPage = of_tlskey_get(lastPageKey); #endif for (struct page *page = lastPage; page != NULL; page = page->previous) { |
︙ | ︙ | |||
420 421 422 423 424 425 426 427 428 429 430 431 432 433 | count * itemSize); if (_items == NULL) @throw [OFOutOfMemoryException exceptionWithRequestedSize: count * itemSize]; } } _itemSize = itemSize; _count = count; } @catch (id e) { [self release]; @throw e; | > > | 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 | count * itemSize); if (_items == NULL) @throw [OFOutOfMemoryException exceptionWithRequestedSize: count * itemSize]; } _swappable = _page->swappable; } _itemSize = itemSize; _count = count; } @catch (id e) { [self release]; @throw e; |
︙ | ︙ | |||
494 495 496 497 498 499 500 | - (void)dealloc { size_t pageSize = [OFSystemInfo pageSize]; if (_count * _itemSize > pageSize) unmapPages(_items, | | > | 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 | - (void)dealloc { size_t pageSize = [OFSystemInfo pageSize]; if (_count * _itemSize > pageSize) unmapPages(_items, OF_ROUND_UP_POW2(pageSize, _count * _itemSize) / pageSize, _swappable); else if (_page != NULL) { if (_items != NULL) freeMemory(_page, _items, _count * _itemSize); removePageIfEmpty(_page); } |
︙ | ︙ | |||
541 542 543 544 545 546 547 548 549 550 551 552 553 554 | count: _count]; } - (bool)isEqual: (id)object { OFData *otherData; unsigned char diff; if (![object isKindOfClass: [OFData class]]) return false; otherData = object; if (otherData->_count != _count || otherData->_itemSize != _itemSize) | > > > | 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 | count: _count]; } - (bool)isEqual: (id)object { OFData *otherData; unsigned char diff; if (object == self) return true; if (![object isKindOfClass: [OFData class]]) return false; otherData = object; if (otherData->_count != _count || otherData->_itemSize != _itemSize) |
︙ | ︙ |
Modified src/OFSelectKernelEventObserver.h from [e8ee327775] to [4637ad2ef9].
︙ | ︙ | |||
28 29 30 31 32 33 34 | # include <sys/select.h> #endif #import "OFKernelEventObserver.h" OF_ASSUME_NONNULL_BEGIN | < | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | # include <sys/select.h> #endif #import "OFKernelEventObserver.h" OF_ASSUME_NONNULL_BEGIN @interface OFSelectKernelEventObserver: OFKernelEventObserver { fd_set _readFDs, _writeFDs; int _maxFD; } @end OF_ASSUME_NONNULL_END |
Modified src/OFSet.h from [f80d14d494] to [9f71c62224].
︙ | ︙ | |||
65 66 67 68 69 70 71 | * @ref objectEnumerator. */ @interface OFSet OF_GENERIC(ObjectType): OFObject <OFCollection, OFCopying, OFMutableCopying, OFSerialization> #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) # define ObjectType id #endif | < < < < | 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | * @ref objectEnumerator. */ @interface OFSet OF_GENERIC(ObjectType): OFObject <OFCollection, OFCopying, OFMutableCopying, OFSerialization> #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) # define ObjectType id #endif /*! * @brief An array of all objects in the set. */ @property (readonly, nonatomic) OFArray OF_GENERIC(ObjectType) *allObjects; /*! * @brief An arbitrary object in the set. |
︙ | ︙ |
Modified src/OFStream.h from [b92e531fc2] to [0663f8f188].
︙ | ︙ | |||
192 193 194 195 196 197 198 199 200 201 202 203 204 205 | * the methods that do the actual work. OFStream uses those for all other * methods and does all the caching and other stuff for you. If you * override these methods without the `lowlevel` prefix, you *will* break * caching and get broken results! */ @interface OFStream: OFObject <OFCopying> { #if !defined(OF_SEEKABLE_STREAM_M) && !defined(OF_TCP_SOCKET_M) @private #endif char *_Nullable _readBuffer, *_Nullable _readBufferMemory; char *_Nullable _writeBuffer; size_t _readBufferLength, _writeBufferLength; bool _writeBuffered, _waitingForDelimiter; | > > < < < | 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | * the methods that do the actual work. OFStream uses those for all other * methods and does all the caching and other stuff for you. If you * override these methods without the `lowlevel` prefix, you *will* break * caching and get broken results! */ @interface OFStream: OFObject <OFCopying> { bool _blocking; id _Nullable _delegate; #if !defined(OF_SEEKABLE_STREAM_M) && !defined(OF_TCP_SOCKET_M) @private #endif char *_Nullable _readBuffer, *_Nullable _readBufferMemory; char *_Nullable _writeBuffer; size_t _readBufferLength, _writeBufferLength; bool _writeBuffered, _waitingForDelimiter; OF_RESERVE_IVARS(4) } /*! * @brief Whether the end of the stream has been reached. */ @property (readonly, nonatomic, getter=isAtEndOfStream) bool atEndOfStream; |
︙ | ︙ |
Modified src/OFString.h from [6ace318746] to [122f8a653b].
︙ | ︙ | |||
117 118 119 120 121 122 123 | /*! * @class OFString OFString.h ObjFW/OFString.h * * @brief A class for handling strings. */ @interface OFString: OFObject <OFCopying, OFMutableCopying, OFComparing, OFSerialization, OFJSONRepresentation, OFMessagePackRepresentation> | < < < < | 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | /*! * @class OFString OFString.h ObjFW/OFString.h * * @brief A class for handling strings. */ @interface OFString: OFObject <OFCopying, OFMutableCopying, OFComparing, OFSerialization, OFJSONRepresentation, OFMessagePackRepresentation> /*! * @brief The length of the string in Unicode codepoints. */ @property (readonly, nonatomic) size_t length; /*! * @brief The OFString as a UTF-8 encoded C string. |
︙ | ︙ |
Modified src/OFTCPSocket.m from [f42e23d703] to [5389356633].
︙ | ︙ | |||
63 64 65 66 67 68 69 | Class of_tls_socket_class = Nil; static OFString *defaultSOCKS5Host = nil; static uint16_t defaultSOCKS5Port = 1080; @interface OFTCPSocketAsyncConnectDelegate: OFObject <OFTCPSocketDelegate, | | | 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | Class of_tls_socket_class = Nil; static OFString *defaultSOCKS5Host = nil; static uint16_t defaultSOCKS5Port = 1080; @interface OFTCPSocketAsyncConnectDelegate: OFObject <OFTCPSocketDelegate, OFTCPSocketDelegate_Private, OFDNSResolverHostDelegate> { OFTCPSocket *_socket; OFString *_host; uint16_t _port; OFString *_SOCKS5Host; uint16_t _SOCKS5Port; id <OFTCPSocketDelegate> _delegate; |
︙ | ︙ | |||
317 318 319 320 321 322 323 | #if defined(OF_NINTENDO_3DS) || defined(OF_WII) _socket.blocking = false; #endif [self didConnect]; } | | | | | | | 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 | #if defined(OF_NINTENDO_3DS) || defined(OF_WII) _socket.blocking = false; #endif [self didConnect]; } - (void)resolver: (OFDNSResolver *)resolver didResolveHost: (OFString *)host addresses: (OFData *)addresses exception: (id)exception { if (exception != nil) { _exception = [exception retain]; [self didConnect]; return; } _socketAddresses = [addresses copy]; [self tryNextAddressWithRunLoopMode: [OFRunLoop currentRunLoop].currentMode]; } - (void)startWithRunLoopMode: (of_run_loop_mode_t)runLoopMode { |
︙ | ︙ | |||
365 366 367 368 369 370 371 | [self tryNextAddressWithRunLoopMode: runLoopMode]; return; } @catch (OFInvalidFormatException *e) { } [[OFThread DNSResolver] | | | | | | 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | [self tryNextAddressWithRunLoopMode: runLoopMode]; return; } @catch (OFInvalidFormatException *e) { } [[OFThread DNSResolver] asyncResolveAddressesForHost: host addressFamily: OF_SOCKET_ADDRESS_FAMILY_ANY runLoopMode: runLoopMode delegate: self]; } - (void)sendSOCKS5Request { OFData *data = [OFData dataWithItems: "\x05\x01\x00" count: 3]; |
︙ | ︙ | |||
808 809 810 811 812 813 814 | @throw [OFAlreadyConnectedException exceptionWithSocket: self]; if (_SOCKS5Host != nil) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; socketAddresses = [[OFThread DNSResolver] | | | | 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 | @throw [OFAlreadyConnectedException exceptionWithSocket: self]; if (_SOCKS5Host != nil) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; socketAddresses = [[OFThread DNSResolver] resolveAddressesForHost: host addressFamily: OF_SOCKET_ADDRESS_FAMILY_ANY]; address = *(of_socket_address_t *)[socketAddresses itemAtIndex: 0]; of_socket_address_set_port(&address, port); if ((_socket = socket(address.sockaddr.sockaddr.sa_family, SOCK_STREAM | SOCK_CLOEXEC, 0)) == INVALID_SOCKET) @throw [OFBindFailedException |
︙ | ︙ |
Modified src/OFThread.h from [156e47b532] to [c31c7a3537].
︙ | ︙ | |||
61 62 63 64 65 66 67 | * This is so that the thread can be used as a key for a dictionary, * so context can be associated with a thread. */ @interface OFThread: OFObject #ifdef OF_HAVE_THREADS <OFCopying> { | < | < < < | 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 | * This is so that the thread can be used as a key for a dictionary, * so context can be associated with a thread. */ @interface OFThread: OFObject #ifdef OF_HAVE_THREADS <OFCopying> { @private of_thread_t _thread; of_thread_attr_t _attr; enum of_thread_running { OF_THREAD_NOT_RUNNING, OF_THREAD_RUNNING, OF_THREAD_WAITING_FOR_JOIN } _running; void *_pool; # ifdef OF_HAVE_BLOCKS of_thread_block_t _Nullable _threadBlock; # endif jmp_buf _exitEnv; id _returnValue; bool _supportsSockets; OFRunLoop *_Nullable _runLoop; OFMutableDictionary *_threadDictionary; OFString *_Nullable _name; # ifdef OF_HAVE_SOCKETS OFDNSResolver *_DNSResolver; # endif OF_RESERVE_IVARS(4) } #endif |
︙ | ︙ |
Modified src/OFThread.m from [3758706d1f] to [6151851d64].
︙ | ︙ | |||
11 12 13 14 15 16 17 | * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ | > | < < | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #define _POSIX_TIMERS #define __NO_EXT_QNX #include <errno.h> #include <stdlib.h> #include <math.h> #include <time.h> #ifdef OF_HAVE_SCHED_YIELD |
︙ | ︙ | |||
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | # import "tlskey.h" # if defined(OF_AMIGAOS) && defined(OF_HAVE_SOCKETS) # import "socket.h" # endif static of_tlskey_t threadSelfKey; static OFThread *mainThread; static void callMain(id object) { OFThread *thread = (OFThread *)object; OFString *name; if (!of_tlskey_set(threadSelfKey, thread)) | > > > > > | 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | # import "tlskey.h" # if defined(OF_AMIGAOS) && defined(OF_HAVE_SOCKETS) # import "socket.h" # endif static of_tlskey_t threadSelfKey; static OFThread *mainThread; #elif defined(OF_HAVE_SOCKETS) static OFDNSResolver *DNSResolver; #endif @implementation OFThread #ifdef OF_HAVE_THREADS static void callMain(id object) { OFThread *thread = (OFThread *)object; OFString *name; if (!of_tlskey_set(threadSelfKey, thread)) |
︙ | ︙ | |||
141 142 143 144 145 146 147 | of_socket_deinit(); #endif thread->_running = OF_THREAD_WAITING_FOR_JOIN; [thread release]; } | < < < < < | 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | of_socket_deinit(); #endif thread->_running = OF_THREAD_WAITING_FOR_JOIN; [thread release]; } @synthesize name = _name; # ifdef OF_HAVE_BLOCKS @synthesize threadBlock = _threadBlock; # endif + (void)initialize { |
︙ | ︙ |
Modified src/OFUDPSocket.m from [e6c74d7c76] to [de0f80ba6e].
︙ | ︙ | |||
262 263 264 265 266 267 268 | OFData *socketAddresses; of_socket_address_t address; if (_socket != INVALID_SOCKET) @throw [OFAlreadyConnectedException exceptionWithSocket: self]; socketAddresses = [[OFThread DNSResolver] | | | | 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | OFData *socketAddresses; of_socket_address_t address; if (_socket != INVALID_SOCKET) @throw [OFAlreadyConnectedException exceptionWithSocket: self]; socketAddresses = [[OFThread DNSResolver] resolveAddressesForHost: host addressFamily: OF_SOCKET_ADDRESS_FAMILY_ANY]; address = *(of_socket_address_t *)[socketAddresses itemAtIndex: 0]; of_socket_address_set_port(&address, port); port = [self of_bindToAddress: &address extraType: 0]; |
︙ | ︙ |
Modified src/OFUTF8String.h from [27bd544b4e] to [50f5bbbd9a].
︙ | ︙ | |||
17 18 19 20 21 22 23 | #import "OFString.h" OF_ASSUME_NONNULL_BEGIN @interface OFUTF8String: OFString { | < | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #import "OFString.h" OF_ASSUME_NONNULL_BEGIN @interface OFUTF8String: OFString { /* * A pointer to the actual data. * * Since constant strings don't have `_storage`, they have to allocate * it on the first access. Strings created at runtime just set the * pointer to `&_storage`. */ |
︙ | ︙ |
Modified src/OFValue.m from [50d6956f54] to [2619bc1d62].
︙ | ︙ | |||
164 165 166 167 168 169 170 171 172 173 174 175 176 177 | } - (bool)isEqual: (id)object { const char *objCType; size_t size; void *value, *otherValue; if (![object isKindOfClass: [OFValue class]]) return false; objCType = self.objCType; if (strcmp([object objCType], objCType) != 0) | > > > | 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | } - (bool)isEqual: (id)object { const char *objCType; size_t size; void *value, *otherValue; if (object == self) return true; if (![object isKindOfClass: [OFValue class]]) return false; objCType = self.objCType; if (strcmp([object objCType], objCType) != 0) |
︙ | ︙ |
Modified src/OFWin32ConsoleStdIOStream.h from [4f43803fd9] to [f6d4919bb8].
︙ | ︙ | |||
17 18 19 20 21 22 23 | #define OF_STDIO_STREAM_WIN32CONSOLE_H #import "OFStdIOStream.h" OF_ASSUME_NONNULL_BEGIN | < | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #define OF_STDIO_STREAM_WIN32CONSOLE_H #import "OFStdIOStream.h" OF_ASSUME_NONNULL_BEGIN @interface OFWin32ConsoleStdIOStream: OFStdIOStream { HANDLE _handle; of_char16_t _incompleteUTF16Surrogate; char _incompleteUTF8Surrogate[4]; size_t _incompleteUTF8SurrogateLen; } @end OF_ASSUME_NONNULL_END |
Modified src/OFXMLElementBuilder.h from [a5bfbc9534] to [9c972fb717].
︙ | ︙ | |||
100 101 102 103 104 105 106 | * @brief A class implementing the OFXMLParserDelegate protocol that can build * OFXMLElements from the document parsed by the OFXMLParser. * * It can also be used to build OFXMLElements from parts of the document by * first parsing stuff using the OFXMLParser with another delegate and then * setting the OFXMLElementBuilder as delegate for the parser. */ | < > | 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | * @brief A class implementing the OFXMLParserDelegate protocol that can build * OFXMLElements from the document parsed by the OFXMLParser. * * It can also be used to build OFXMLElements from parts of the document by * first parsing stuff using the OFXMLParser with another delegate and then * setting the OFXMLElementBuilder as delegate for the parser. */ @interface OFXMLElementBuilder: OFObject <OFXMLParserDelegate> { OFMutableArray OF_GENERIC(OFXMLElement *) *_stack; id <OFXMLElementBuilderDelegate> _Nullable _delegate; OF_RESERVE_IVARS(4) } /*! * @brief The delegate for the OFXMLElementBuilder. */ @property OF_NULLABLE_PROPERTY (assign, nonatomic) id <OFXMLElementBuilderDelegate> delegate; |
︙ | ︙ |
Modified src/OFXMLProcessingInstructions.m from [b4f91e54e3] to [a1aa347f59].
︙ | ︙ | |||
83 84 85 86 87 88 89 | return true; if (![object isKindOfClass: [OFXMLProcessingInstructions class]]) return false; processingInstructions = object; | | | | 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | return true; if (![object isKindOfClass: [OFXMLProcessingInstructions class]]) return false; processingInstructions = object; return [processingInstructions->_processingInstructions isEqual: _processingInstructions]; } - (uint32_t)hash { return _processingInstructions.hash; } |
︙ | ︙ |
Modified src/ObjFW.h from [faf921101f] to [fb83a9c085].
︙ | ︙ | |||
40 41 42 43 44 45 46 | #import "OFEnumerator.h" #import "OFNull.h" #import "OFMethodSignature.h" #import "OFInvocation.h" | < | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | #import "OFEnumerator.h" #import "OFNull.h" #import "OFMethodSignature.h" #import "OFInvocation.h" #import "OFNumber.h" #import "OFDate.h" #import "OFURL.h" #import "OFURLHandler.h" #import "OFColor.h" |
︙ | ︙ | |||
71 72 73 74 75 76 77 | #endif #ifdef OF_HAVE_SOCKETS # import "OFStreamSocket.h" # import "OFTCPSocket.h" # import "OFUDPSocket.h" # import "OFTLSSocket.h" # import "OFKernelEventObserver.h" | | > > | 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | #endif #ifdef OF_HAVE_SOCKETS # import "OFStreamSocket.h" # import "OFTCPSocket.h" # import "OFUDPSocket.h" # import "OFTLSSocket.h" # import "OFKernelEventObserver.h" # import "OFDNSQuery.h" # import "OFDNSResourceRecord.h" # import "OFDNSResponse.h" # import "OFDNSResolver.h" #endif #ifdef OF_HAVE_SOCKETS # ifdef OF_HAVE_THREADS # import "OFHTTPClient.h" # endif # import "OFHTTPCookie.h" # import "OFHTTPCookieManager.h" |
︙ | ︙ | |||
130 131 132 133 134 135 136 | #import "OFAllocFailedException.h" #import "OFException.h" #ifdef OF_HAVE_SOCKETS # import "OFAcceptFailedException.h" # import "OFAlreadyConnectedException.h" # import "OFBindFailedException.h" | < > > > > > | 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 | #import "OFAllocFailedException.h" #import "OFException.h" #ifdef OF_HAVE_SOCKETS # import "OFAcceptFailedException.h" # import "OFAlreadyConnectedException.h" # import "OFBindFailedException.h" #endif #import "OFChangeCurrentDirectoryPathFailedException.h" #import "OFChecksumMismatchException.h" #ifdef OF_HAVE_THREADS # import "OFConditionBroadcastFailedException.h" # import "OFConditionSignalFailedException.h" # import "OFConditionStillWaitingException.h" # import "OFConditionWaitFailedException.h" #endif #ifdef OF_HAVE_SOCKETS # import "OFConnectionFailedException.h" #endif #import "OFCopyItemFailedException.h" #import "OFCreateDirectoryFailedException.h" #import "OFCreateSymbolicLinkFailedException.h" #ifdef OF_WINDOWS # import "OFCreateWindowsRegistryKeyFailedException.h" #endif #ifdef OF_HAVE_SOCKETS # import "OFDNSQueryFailedException.h" #endif #ifdef OF_WINDOWS # import "OFDeleteWindowsRegistryKeyFailedException.h" # import "OFDeleteWindowsRegistryValueFailedException.h" #endif #import "OFEnumerationMutationException.h" #ifdef OF_HAVE_FILES # import "OFGetCurrentDirectoryPathFailedException.h" #endif |
︙ | ︙ | |||
194 195 196 197 198 199 200 201 202 203 204 205 206 207 | # import "OFOpenWindowsRegistryKeyFailedException.h" #endif #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFReadOrWriteFailedException.h" #import "OFRemoveItemFailedException.h" #import "OFRetrieveItemAttributesFailedException.h" #import "OFSandboxActivationFailedException.h" #import "OFSeekFailedException.h" #import "OFSetItemAttributesFailedException.h" #import "OFSetOptionFailedException.h" #ifdef OF_WINDOWS # import "OFSetWindowsRegistryValueFailedException.h" | > > > | 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | # import "OFOpenWindowsRegistryKeyFailedException.h" #endif #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFReadOrWriteFailedException.h" #import "OFRemoveItemFailedException.h" #ifdef OF_HAVE_SOCKETS # import "OFResolveHostFailedException.h" #endif #import "OFRetrieveItemAttributesFailedException.h" #import "OFSandboxActivationFailedException.h" #import "OFSeekFailedException.h" #import "OFSetItemAttributesFailedException.h" #import "OFSetOptionFailedException.h" #ifdef OF_WINDOWS # import "OFSetWindowsRegistryValueFailedException.h" |
︙ | ︙ |
Modified src/block.h from [e2b05adf4f] to [e8b856e116].
︙ | ︙ | |||
46 47 48 49 50 51 52 | # if defined(OF_WINDOWS) && \ (defined(OF_NO_SHARED) || defined(OF_COMPILING_OBJFW)) /* * Clang has implicit declarations for these, but they are dllimport. When * compiling ObjFW itself or using it as a static library, these need to be * dllexport. Interestingly, this still works when using it as a shared library. */ | | | | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | # if defined(OF_WINDOWS) && \ (defined(OF_NO_SHARED) || defined(OF_COMPILING_OBJFW)) /* * Clang has implicit declarations for these, but they are dllimport. When * compiling ObjFW itself or using it as a static library, these need to be * dllexport. Interestingly, this still works when using it as a shared library. */ extern __declspec(dllexport) struct objc_class _NSConcreteStackBlock; extern __declspec(dllexport) struct objc_class _NSConcreteGlobalBlock; extern __declspec(dllexport) void _Block_object_assign(void *, const void *, const int); extern __declspec(dllexport) void _Block_object_dispose(const void *, const int); # endif #ifdef __cplusplus } |
︙ | ︙ |
Modified src/exceptions/Makefile from [78ae506a77] to [103a175ba6].
︙ | ︙ | |||
54 55 56 57 58 59 60 61 62 63 64 65 66 67 | ${USE_SRCS_WINDOWS} SRCS_FILES = OFGetCurrentDirectoryPathFailedException.m SRCS_PLUGINS = OFLoadPluginFailedException.m SRCS_SOCKETS = OFAcceptFailedException.m \ OFAlreadyConnectedException.m \ OFBindFailedException.m \ OFConnectionFailedException.m \ OFHTTPRequestFailedException.m \ OFListenFailedException.m \ OFObserveFailedException.m \ OFResolveHostFailedException.m SRCS_THREADS = OFConditionBroadcastFailedException.m \ OFConditionSignalFailedException.m \ OFConditionStillWaitingException.m \ | > | 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | ${USE_SRCS_WINDOWS} SRCS_FILES = OFGetCurrentDirectoryPathFailedException.m SRCS_PLUGINS = OFLoadPluginFailedException.m SRCS_SOCKETS = OFAcceptFailedException.m \ OFAlreadyConnectedException.m \ OFBindFailedException.m \ OFConnectionFailedException.m \ OFDNSQueryFailedException.m \ OFHTTPRequestFailedException.m \ OFListenFailedException.m \ OFObserveFailedException.m \ OFResolveHostFailedException.m SRCS_THREADS = OFConditionBroadcastFailedException.m \ OFConditionSignalFailedException.m \ OFConditionStillWaitingException.m \ |
︙ | ︙ |
Added src/exceptions/OFDNSQueryFailedException.h version [2a3821e5d9].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | /* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, * 2018, 2019 * Jonathan Schleifer <js@heap.zone> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFException.h" #import "OFDNSQuery.h" #import "OFDNSResolver.h" #import "OFDNSResourceRecord.h" OF_ASSUME_NONNULL_BEGIN /*! * @class OFDNSQueryFailedException \ * OFDNSQueryFailedException.h ObjFW/OFDNSQueryFailedException.h * * @brief An exception indicating that a DNS query failed. */ @interface OFDNSQueryFailedException: OFException { OFDNSQuery *_query; of_dns_resolver_error_t _error; } /*! * @brief The query which could not be performed. */ @property (readonly, nonatomic) OFDNSQuery *query; /*! * @brief The error from the resolver. */ @property (readonly, nonatomic) of_dns_resolver_error_t error; /*! * @brief Creates a new, autoreleased DNS query failed exception. * * @param query The query which could not be performed * @param error The error from the resolver * @return A new, autoreleased address translation failed exception */ + (instancetype)exceptionWithQuery: (OFDNSQuery *)query error: (of_dns_resolver_error_t)error; /*! * @brief Initializes an already allocated DNS query failed exception. * * @param query The query which could not be performed * @param error The error from the resolver * @return An initialized address translation failed exception */ - (instancetype)initWithQuery: (OFDNSQuery *)query error: (of_dns_resolver_error_t)error; @end #ifdef __cplusplus extern "C" { #endif extern OFString *of_dns_resolver_error_to_string(of_dns_resolver_error_t error); #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END |
Added src/exceptions/OFDNSQueryFailedException.m version [04f5be8a60].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | /* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, * 2018, 2019 * Jonathan Schleifer <js@heap.zone> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #import "OFDNSQueryFailedException.h" #import "OFString.h" OFString * of_dns_resolver_error_to_string(of_dns_resolver_error_t error) { switch (error) { case OF_DNS_RESOLVER_ERROR_TIMEOUT: return @"The query timed out."; case OF_DNS_RESOLVER_ERROR_CANCELED: return @"The query was canceled."; case OF_DNS_RESOLVER_ERROR_NO_RESULT: return @"No result for the specified host with the specified " @"type and class."; case OF_DNS_RESOLVER_ERROR_SERVER_INVALID_FORMAT: return @"The server considered the query to be malformed."; case OF_DNS_RESOLVER_ERROR_SERVER_FAILURE: return @"The server was unable to process due to an internal " @"error."; case OF_DNS_RESOLVER_ERROR_SERVER_NAME_ERROR: return @"The server returned an error that the domain does not " @"exist."; case OF_DNS_RESOLVER_ERROR_SERVER_NOT_IMPLEMENTED: return @"The server does not have support for the requested " @"query."; case OF_DNS_RESOLVER_ERROR_SERVER_REFUSED: return @"The server refused the query."; default: return @"Unknown error."; } } @implementation OFDNSQueryFailedException @synthesize query = _query, error = _error; + (instancetype)exceptionWithQuery: (OFDNSQuery *)query error: (of_dns_resolver_error_t)error { return [[[self alloc] initWithQuery: query error: error] autorelease]; } - (instancetype)initWithQuery: (OFDNSQuery *)query error: (of_dns_resolver_error_t)error { self = [super init]; @try { _query = [query copy]; _error = error; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_query release]; [super dealloc]; } - (OFString *)description { return [OFString stringWithFormat: @"DNS query %@ could not be performed: %@", _query, of_dns_resolver_error_to_string(_error)]; } @end |
Modified src/exceptions/OFResolveHostFailedException.h from [cec0b8274f] to [9c568bc023].
︙ | ︙ | |||
13 14 15 16 17 18 19 | * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFException.h" #import "OFDNSResolver.h" | < | | < < < < | < < | | | | < | | | | | < | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFException.h" #import "OFDNSResolver.h" OF_ASSUME_NONNULL_BEGIN /*! * @class OFResolveHostFailedException \ * OFResolveHostFailedException.h ObjFW/OFResolveHostFailedException.h * * @brief An exception indicating that resolving a host failed. */ @interface OFResolveHostFailedException: OFException { OFString *_host; of_socket_address_family_t _addressFamily; of_dns_resolver_error_t _error; } /*! * @brief The host which could not be resolved. */ @property (readonly, nonatomic) OFString *host; /*! * @brief The address family for which the host could not be resolved. */ @property (readonly, nonatomic) of_socket_address_family_t addressFamily; /*! * @brief The error from the resolver. */ @property (readonly, nonatomic) of_dns_resolver_error_t error; /*! * @brief Creates a new, autoreleased resolve host failed exception. * * @param host The host which could not be resolved * @param addressFamily The address family for which the host could not be * resolved * @param error The error from the resolver * @return A new, autoreleased address translation failed exception */ + (instancetype)exceptionWithHost: (OFString *)host addressFamily: (of_socket_address_family_t)addressFamily error: (of_dns_resolver_error_t)error; /*! * @brief Initializes an already allocated resolve host failed exception. * * @param host The host which could not be resolved * @param addressFamily The address family for which the host could not be * resolved * @param error The error from the resolver * @return An initialized address translation failed exception */ - (instancetype)initWithHost: (OFString *)host addressFamily: (of_socket_address_family_t)addressFamily error: (of_dns_resolver_error_t)error; @end OF_ASSUME_NONNULL_END |
Modified src/exceptions/OFResolveHostFailedException.m from [5ebb9198c3] to [3a43359e82].
︙ | ︙ | |||
14 15 16 17 18 19 20 21 22 23 | * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #import "OFResolveHostFailedException.h" #import "OFString.h" @implementation OFResolveHostFailedException | > | < | < | < | < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | > | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #import "OFResolveHostFailedException.h" #import "OFDNSQueryFailedException.h" #import "OFString.h" @implementation OFResolveHostFailedException @synthesize host = _host, addressFamily = _addressFamily, error = _error; + (instancetype)exceptionWithHost: (OFString *)host addressFamily: (of_socket_address_family_t)addressFamily error: (of_dns_resolver_error_t)error { return [[[self alloc] initWithHost: host addressFamily: addressFamily error: error] autorelease]; } - (instancetype)initWithHost: (OFString *)host addressFamily: (of_socket_address_family_t)addressFamily error: (of_dns_resolver_error_t)error { self = [super init]; @try { _host = [host copy]; _addressFamily = addressFamily; _error = error; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_host release]; [super dealloc]; } - (OFString *)description { return [OFString stringWithFormat: @"The host %@ could not be resolved: %@", _host, of_dns_resolver_error_to_string(_error)]; } @end |
Modified src/forwarding/apple-forwarding-arm.S from [54eb048dac] to [6201d871d1].
︙ | ︙ | |||
32 33 34 35 36 37 38 | .long 0, 0 .section __TEXT, __text, regular, pure_instructions .arm .align 2 _of_forward: stmfd sp!, {r0-r4, lr} | | | 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | .long 0, 0 .section __TEXT, __text, regular, pure_instructions .arm .align 2 _of_forward: stmfd sp!, {r0-r4, lr} vstmdb sp!, {d0-d7} ldr r4, sel_forwardingTargetForSelector_$indirect_L0 L0: ldr r4, [pc, r4] blx _object_getClass |
︙ | ︙ | |||
57 58 59 60 61 62 63 | cmp r0, #0 beq 0f ldr r1, [sp, #64] cmp r0, r1 beq 0f | | | | | 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 | cmp r0, #0 beq 0f ldr r1, [sp, #64] cmp r0, r1 beq 0f vldmia sp!, {d0-d7} add sp, sp, #4 @ throw away r0 ldmfd sp!, {r1-r4, lr} b _objc_msgSend 0: vldmia sp!, {d0-d7} ldmfd sp!, {r0-r4, lr} b _of_method_not_found .data_region sel_forwardingTargetForSelector_$indirect_L0: .long sel_forwardingTargetForSelector_-(L0+8) .end_data_region .align 2 _of_forward_stret: stmfd sp!, {r0-r4, lr} vstmdb sp!, {d0-d7} ldr r4, sel_forwardingTargetForSelector_$indirect_L1 L1: ldr r4, [pc, r4] mov r0, r1 blx _object_getClass |
︙ | ︙ | |||
104 105 106 107 108 109 110 | beq 0f ldr r1, [sp, #68] cmp r0, r1 beq 0f mov r1, r0 | | | | 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | beq 0f ldr r1, [sp, #68] cmp r0, r1 beq 0f mov r1, r0 vldmia sp!, {d0-d7} ldmfd sp!, {r0} add sp, sp, #4 @ throw away r1 ldmfd sp!, {r2-r4, lr} b _objc_msgSend_stret 0: vldmia sp!, {d0-d7} ldmfd sp!, {r0-r4, lr} b _of_method_not_found_stret .data_region sel_forwardingTargetForSelector_$indirect_L1: .long sel_forwardingTargetForSelector_-(L1+8) .end_data_region |
Modified src/forwarding/forwarding-arm-elf.S from [461b1eeec9] to [33bad73f5d].
︙ | ︙ | |||
25 26 27 28 29 30 31 | .globl of_forward .globl of_forward_stret .section .text of_forward: #ifdef HAVE_VFP2 | | | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | .globl of_forward .globl of_forward_stret .section .text of_forward: #ifdef HAVE_VFP2 vstmdb sp!, {d0-d7} #endif stmfd sp!, {r0-r4, lr} ldr r4, sel_forwardingTargetForSelector_$indirect_.L0 .L0: add r4, pc |
︙ | ︙ | |||
64 65 66 67 68 69 70 | str r0, [sp, #0] ldr r1, [sp, #4] bl objc_msg_lookup(PLT) mov r12, r0 ldmfd sp!, {r0-r4, lr} #ifdef HAVE_VFP2 | | | | | 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 | str r0, [sp, #0] ldr r1, [sp, #4] bl objc_msg_lookup(PLT) mov r12, r0 ldmfd sp!, {r0-r4, lr} #ifdef HAVE_VFP2 vldmia sp!, {d0-d7} #endif bx r12 0: ldmfd sp!, {r0-r4, lr} #ifdef HAVE_VFP2 vldmia sp!, {d0-d7} #endif b of_method_not_found(PLT) .type of_forward, %function .size of_forward, .-of_forward of_forward_stret: #ifdef HAVE_VFP2 vstmdb sp!, {d0-d7} #endif stmfd sp!, {r0-r4, lr} ldr r4, sel_forwardingTargetForSelector_$indirect_.L1 .L1: add r4, pc |
︙ | ︙ | |||
120 121 122 123 124 125 126 | str r0, [sp, #4] ldr r1, [sp, #8] bl objc_msg_lookup_stret(PLT) mov r12, r0 ldmfd sp!, {r0-r4, lr} #ifdef HAVE_VFP2 | | | | 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | str r0, [sp, #4] ldr r1, [sp, #8] bl objc_msg_lookup_stret(PLT) mov r12, r0 ldmfd sp!, {r0-r4, lr} #ifdef HAVE_VFP2 vldmia sp!, {d0-d7} #endif bx r12 0: ldmfd sp!, {r0-r4, lr} #ifdef HAVE_VFP2 vldmia sp!, {d0-d7} #endif b of_method_not_found_stret(PLT) .type of_forward_stret, %function .size of_forward_stret, .-of_forward_stret init: ldr r0, module$indirect_.L2 |
︙ | ︙ |
Modified src/runtime/Makefile from [a2eae9738b] to [461ba255ad].
︙ | ︙ | |||
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | SRCS = arc.m \ category.m \ class.m \ dtable.m \ exception.m \ hashtable.m \ init.m \ lookup.m \ misc.m \ property.m \ protocol.m \ selector.m \ sparsearray.m \ static-instances.m \ synchronized.m \ | > > | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | SRCS = arc.m \ category.m \ class.m \ dtable.m \ exception.m \ hashtable.m \ init.m \ ivar.m \ lookup.m \ method.m \ misc.m \ property.m \ protocol.m \ selector.m \ sparsearray.m \ static-instances.m \ synchronized.m \ |
︙ | ︙ |
Modified src/runtime/ObjFWRT.h from [0d652d980c] to [b950544256].
︙ | ︙ | |||
57 58 59 60 61 62 63 64 65 66 67 68 69 70 | #define nil (id _Null_unspecified)0 #define YES true #define NO false typedef struct objc_class *Class; typedef struct objc_object *id; typedef const struct objc_selector *SEL; #if !defined(__wii__) && !defined(__amigaos__) typedef bool BOOL; #endif typedef id _Nullable (*IMP)(id _Nonnull, SEL _Nonnull, ...); typedef void (*objc_uncaught_exception_handler_t)(id _Nullable); typedef void (*objc_enumeration_mutation_handler_t)(id _Nonnull); | > > > > > > > > < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 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 | #define nil (id _Null_unspecified)0 #define YES true #define NO false typedef struct objc_class *Class; typedef struct objc_object *id; typedef const struct objc_selector *SEL; typedef const struct objc_method *Method; #ifdef __OBJC__ @class Protocol; #else typedef const struct objc_protocol *Protocol; #endif typedef const struct objc_ivar *Ivar; typedef const struct objc_property *objc_property_t; #if !defined(__wii__) && !defined(__amigaos__) typedef bool BOOL; #endif typedef id _Nullable (*IMP)(id _Nonnull, SEL _Nonnull, ...); typedef void (*objc_uncaught_exception_handler_t)(id _Nullable); typedef void (*objc_enumeration_mutation_handler_t)(id _Nonnull); struct objc_super { id __unsafe_unretained _Nullable self; #ifdef __cplusplus Class _Nonnull class_; #else Class _Nonnull class; #endif }; #ifdef __cplusplus extern "C" { #endif extern SEL _Nonnull sel_registerName(const char *_Nonnull name); extern const char *_Nonnull sel_getName(SEL _Nonnull selector); extern bool sel_isEqual(SEL _Nonnull selector1, SEL _Nonnull selector2); extern Class _Nonnull objc_allocateClassPair(Class _Nullable superclass, |
︙ | ︙ | |||
240 241 242 243 244 245 246 | SEL _Nonnull selector); extern bool class_conformsToProtocol(Class _Nullable class_, Protocol *_Nonnull protocol); extern IMP _Nullable class_getMethodImplementation(Class _Nullable class_, SEL _Nonnull selector); extern IMP _Nullable class_getMethodImplementation_stret(Class _Nullable class_, SEL _Nonnull selector); | | > > > > > > > > > > > > > > > | | 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 | SEL _Nonnull selector); extern bool class_conformsToProtocol(Class _Nullable class_, Protocol *_Nonnull protocol); extern IMP _Nullable class_getMethodImplementation(Class _Nullable class_, SEL _Nonnull selector); extern IMP _Nullable class_getMethodImplementation_stret(Class _Nullable class_, SEL _Nonnull selector); extern Method _Nullable class_getInstanceMethod(Class _Nullable class_, SEL _Nonnull selector); extern bool class_addMethod(Class _Nonnull class_, SEL _Nonnull selector, IMP _Nonnull implementation, const char *_Nullable typeEncoding); extern IMP _Nullable class_replaceMethod(Class _Nonnull class_, SEL _Nonnull selector, IMP _Nonnull implementation, const char *_Nullable typeEncoding); extern Class _Nullable object_getClass(id _Nullable object); extern Class _Nullable object_setClass(id _Nullable object, Class _Nonnull class_); extern const char *_Nullable object_getClassName(id _Nullable object); extern const char *_Nonnull protocol_getName(Protocol *_Nonnull protocol); extern bool protocol_isEqual(Protocol *_Nonnull protocol1, Protocol *_Nonnull protocol2); extern bool protocol_conformsToProtocol(Protocol *_Nonnull protocol1, Protocol *_Nonnull protocol2); extern Method _Nullable *_Nullable class_copyMethodList(Class _Nullable class_, unsigned int *_Nullable outCount); extern SEL _Nonnull method_getName(Method _Nonnull method); extern const char *_Nullable method_getTypeEncoding(Method _Nonnull method); extern Ivar _Nullable *_Nullable class_copyIvarList(Class _Nullable class_, unsigned int *_Nullable outCount); extern const char *_Nonnull ivar_getName(Ivar _Nonnull ivar); extern const char *_Nonnull ivar_getTypeEncoding(Ivar _Nonnull ivar); extern ptrdiff_t ivar_getOffset(Ivar _Nonnull ivar); extern objc_property_t _Nullable *_Nullable class_copyPropertyList( Class _Nullable class_, unsigned int *_Nullable outCount); extern const char *_Nonnull property_getName(objc_property_t _Nonnull property); extern char *_Nullable property_copyAttributeValue( objc_property_t _Nonnull property, const char *_Nonnull name); extern void objc_exit(void); extern _Nullable objc_uncaught_exception_handler_t objc_setUncaughtExceptionHandler( objc_uncaught_exception_handler_t _Nullable handler); extern void objc_setForwardHandler(IMP _Nullable forward, IMP _Nullable stretForward); extern void objc_setEnumerationMutationHandler( objc_enumeration_mutation_handler_t _Nullable handler); extern void objc_zero_weak_references(id _Nonnull value); /* * Used by the compiler, but can also be called manually. * * These declarations are also required to prevent Clang's implicit * declarations which include __declspec(dllimport) on Windows. */ struct objc_module; extern void __objc_exec_class(struct objc_module *_Nonnull module); extern IMP _Nonnull objc_msg_lookup(id _Nullable object, SEL _Nonnull selector); extern IMP _Nonnull objc_msg_lookup_stret(id _Nullable object, SEL _Nonnull selector); extern IMP _Nonnull objc_msg_lookup_super(struct objc_super *_Nonnull super, SEL _Nonnull selector); extern IMP _Nonnull objc_msg_lookup_super_stret( struct objc_super *_Nonnull super, SEL _Nonnull selector); |
︙ | ︙ |
Modified src/runtime/amiga-glue.m from [f152603cb3] to [066d6109b5].
︙ | ︙ | |||
51 52 53 54 55 56 57 | M68K_ARG(FILE *, stdout_, a1) M68K_ARG(FILE *, stderr_, a2) return objc_init(version, libc, stdout_, stderr_); } void __saveds | | | | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | M68K_ARG(FILE *, stdout_, a1) M68K_ARG(FILE *, stderr_, a2) return objc_init(version, libc, stdout_, stderr_); } void __saveds glue___objc_exec_class PPC_PARAMS(struct objc_module *module) { M68K_ARG(struct objc_module *, module, a0) __objc_exec_class(module); } IMP __saveds glue_objc_msg_lookup PPC_PARAMS(id object, SEL selector) { |
︙ | ︙ | |||
503 504 505 506 507 508 509 | { M68K_ARG(Class, class, a0) M68K_ARG(SEL, selector, a1) return class_getMethodImplementation_stret(class, selector); } | | | | | 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 | { M68K_ARG(Class, class, a0) M68K_ARG(SEL, selector, a1) return class_getMethodImplementation_stret(class, selector); } Method __saveds glue_class_getInstanceMethod PPC_PARAMS(Class class, SEL selector) { M68K_ARG(Class, class, a0) M68K_ARG(SEL, selector, a1) return class_getInstanceMethod(class, selector); } bool __saveds glue_class_addMethod PPC_PARAMS(Class class, SEL selector, IMP implementation, const char *typeEncoding) { M68K_ARG(Class, class, a0) |
︙ | ︙ | |||
629 630 631 632 633 634 635 | } void __saveds glue_objc_exit(void) { objc_exit(); } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | } void __saveds glue_objc_exit(void) { objc_exit(); } Ivar *__saveds glue_class_copyIvarList PPC_PARAMS(Class class, unsigned int *outCount) { M68K_ARG(Class, class, a0) M68K_ARG(unsigned int *, outCount, a1) return class_copyIvarList(class, outCount); } const char *__saveds glue_ivar_getName PPC_PARAMS(Ivar ivar) { M68K_ARG(Ivar, ivar, a0) return ivar_getName(ivar); } const char *__saveds glue_ivar_getTypeEncoding PPC_PARAMS(Ivar ivar) { M68K_ARG(Ivar, ivar, a0) return ivar_getTypeEncoding(ivar); } ptrdiff_t __saveds glue_ivar_getOffset PPC_PARAMS(Ivar ivar) { M68K_ARG(Ivar, ivar, a0) return ivar_getOffset(ivar); } Method *__saveds glue_class_copyMethodList PPC_PARAMS(Class class, unsigned int *outCount) { M68K_ARG(Class, class, a0) M68K_ARG(unsigned int *, outCount, a1) return class_copyMethodList(class, outCount); } SEL __saveds glue_method_getName PPC_PARAMS(Method method) { M68K_ARG(Method, method, a0) return method_getName(method); } const char *__saveds glue_method_getTypeEncoding PPC_PARAMS(Method method) { M68K_ARG(Method, method, a0) return method_getTypeEncoding(method); } objc_property_t *__saveds glue_class_copyPropertyList PPC_PARAMS(Class class, unsigned int *outCount) { M68K_ARG(Class, class, a0) M68K_ARG(unsigned int *, outCount, a1) return class_copyPropertyList(class, outCount); } const char *__saveds glue_property_getName PPC_PARAMS(objc_property_t property) { M68K_ARG(objc_property_t, property, a0) return property_getName(property); } char *__saveds glue_property_copyAttributeValue PPC_PARAMS(objc_property_t property, const char *name) { M68K_ARG(objc_property_t, property, a0) M68K_ARG(const char *, name, a1) return property_copyAttributeValue(property, name); } |
Modified src/runtime/amiga-library.m from [f3f4183dca] to [947d91885b].
︙ | ︙ | |||
60 61 62 63 64 65 66 | extern uintptr_t __CTOR_LIST__[]; extern const void *_EH_FRAME_BEGINS__; extern void *_EH_FRAME_OBJECTS__; #endif extern bool glue_objc_init(void); extern void glue___objc_exec_class(void); | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > > > > > > | 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | extern uintptr_t __CTOR_LIST__[]; extern const void *_EH_FRAME_BEGINS__; extern void *_EH_FRAME_OBJECTS__; #endif extern bool glue_objc_init(void); extern void glue___objc_exec_class(void); extern IMP glue_objc_msg_lookup(void); extern IMP glue_objc_msg_lookup_stret(void); extern IMP glue_objc_msg_lookup_super(void); extern IMP glue_objc_msg_lookup_super_stret(void); extern Class glue_objc_lookUpClass(void); extern Class glue_objc_getClass(void); extern Class glue_objc_getRequiredClass(void); extern Class glue_objc_lookup_class(void); extern Class glue_objc_get_class(void); extern void glue_objc_exception_throw(void); extern int glue_objc_sync_enter(void); extern int glue_objc_sync_exit(void); extern id glue_objc_getProperty(void); extern void glue_objc_setProperty(void); extern void glue_objc_getPropertyStruct(void); extern void glue_objc_setPropertyStruct(void); extern void glue_objc_enumerationMutation(void); extern int glue___gnu_objc_personality(void); extern id glue_objc_retain(void); extern id glue_objc_retainBlock(void); extern id glue_objc_retainAutorelease(void); extern void glue_objc_release(void); extern id glue_objc_autorelease(void); extern id glue_objc_autoreleaseReturnValue(void); extern id glue_objc_retainAutoreleaseReturnValue(void); extern id glue_objc_retainAutoreleasedReturnValue(void); extern id glue_objc_storeStrong(void); extern id glue_objc_storeWeak(void); extern id glue_objc_loadWeakRetained(void); extern id glue_objc_initWeak(void); extern void glue_objc_destroyWeak(void); extern id glue_objc_loadWeak(void); extern void glue_objc_copyWeak(void); extern void glue_objc_moveWeak(void); extern SEL glue_sel_registerName(void); extern const char *glue_sel_getName(void); extern bool glue_sel_isEqual(void); extern Class glue_objc_allocateClassPair(void); extern void glue_objc_registerClassPair(void); extern unsigned int glue_objc_getClassList(void); extern Class *glue_objc_copyClassList(void); extern bool glue_class_isMetaClass(void); extern const char *glue_class_getName(void); extern Class glue_class_getSuperclass(void); extern unsigned long glue_class_getInstanceSize(void); extern bool glue_class_respondsToSelector(void); extern bool glue_class_conformsToProtocol(void); extern IMP glue_class_getMethodImplementation(void); extern IMP glue_class_getMethodImplementation_stret(void); extern Method glue_class_getInstanceMethod(void); extern bool glue_class_addMethod(void); extern IMP glue_class_replaceMethod(void); extern Class glue_object_getClass(void); extern Class glue_object_setClass(void); extern const char *glue_object_getClassName(void); extern const char *glue_protocol_getName(void); extern bool glue_protocol_isEqual(void); extern bool glue_protocol_conformsToProtocol(void); extern objc_uncaught_exception_handler_t glue_objc_setUncaughtExceptionHandler(void); extern void glue_objc_setForwardHandler(void); extern void glue_objc_setEnumerationMutationHandler(void); extern void glue_objc_zero_weak_references(void); extern void glue_objc_exit(void); extern Ivar *glue_class_copyIvarList(void); extern const char *glue_ivar_getName(void); extern const char *glue_ivar_getTypeEncoding(void); extern ptrdiff_t glue_ivar_getOffset(void); extern Method *glue_class_copyMethodList(void); extern SEL glue_method_getName(void); extern const char *glue_method_getTypeEncoding(void); extern objc_property_t *glue_class_copyPropertyList(void); extern const char *glue_property_getName(void); extern char *glue_property_copyAttributeValue(void); #ifdef OF_MORPHOS const ULONG __abox__ = 1; #endif struct ExecBase *SysBase; struct objc_libc libc; FILE *stdout; |
︙ | ︙ | |||
617 618 619 620 621 622 623 | (CONST_APTR)glue_class_getName, (CONST_APTR)glue_class_getSuperclass, (CONST_APTR)glue_class_getInstanceSize, (CONST_APTR)glue_class_respondsToSelector, (CONST_APTR)glue_class_conformsToProtocol, (CONST_APTR)glue_class_getMethodImplementation, (CONST_APTR)glue_class_getMethodImplementation_stret, | | > > > > > > > > > > | 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 | (CONST_APTR)glue_class_getName, (CONST_APTR)glue_class_getSuperclass, (CONST_APTR)glue_class_getInstanceSize, (CONST_APTR)glue_class_respondsToSelector, (CONST_APTR)glue_class_conformsToProtocol, (CONST_APTR)glue_class_getMethodImplementation, (CONST_APTR)glue_class_getMethodImplementation_stret, (CONST_APTR)glue_class_getInstanceMethod, (CONST_APTR)glue_class_addMethod, (CONST_APTR)glue_class_replaceMethod, (CONST_APTR)glue_object_getClass, (CONST_APTR)glue_object_setClass, (CONST_APTR)glue_object_getClassName, (CONST_APTR)glue_protocol_getName, (CONST_APTR)glue_protocol_isEqual, (CONST_APTR)glue_protocol_conformsToProtocol, (CONST_APTR)glue_objc_setUncaughtExceptionHandler, (CONST_APTR)glue_objc_setForwardHandler, (CONST_APTR)glue_objc_setEnumerationMutationHandler, (CONST_APTR)glue_objc_zero_weak_references, (CONST_APTR)glue_objc_exit, (CONST_APTR)glue_class_copyIvarList, (CONST_APTR)glue_ivar_getName, (CONST_APTR)glue_ivar_getTypeEncoding, (CONST_APTR)glue_ivar_getOffset, (CONST_APTR)glue_class_copyMethodList, (CONST_APTR)glue_method_getName, (CONST_APTR)glue_method_getTypeEncoding, (CONST_APTR)glue_class_copyPropertyList, (CONST_APTR)glue_property_getName, (CONST_APTR)glue_property_copyAttributeValue, (CONST_APTR)-1, #ifdef OF_MORPHOS (CONST_APTR)FUNCARRAY_END #endif }; #pragma GCC diagnostic pop |
︙ | ︙ |
Modified src/runtime/amigaos3.sfd from [de4ad75da8] to [49f4c1e562].
1 2 3 4 5 6 7 8 9 | ==base _ObjFWRTBase ==basetype struct Library * ==libname objfwrt68k.library ==bias 30 ==public * Functions that are only for the linklib. bool glue_objc_init(unsigned int version, struct objc_libc *libc, FILE *stdout, FILE *stderr)(d0,a0,a1,a2) * These have a built-in declaration in the compiler that does not use the * registers and thus always need glue. | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ==base _ObjFWRTBase ==basetype struct Library * ==libname objfwrt68k.library ==bias 30 ==public * Functions that are only for the linklib. bool glue_objc_init(unsigned int version, struct objc_libc *libc, FILE *stdout, FILE *stderr)(d0,a0,a1,a2) * These have a built-in declaration in the compiler that does not use the * registers and thus always need glue. void glue___objc_exec_class(struct objc_module *_Nonnull module)(a0) IMP _Nonnull glue_objc_msg_lookup(id _Nullable object, SEL _Nonnull selector)(a0,a1) IMP _Nonnull glue_objc_msg_lookup_stret(id _Nullable object, SEL _Nonnull selector)(a0,a1) IMP _Nonnull glue_objc_msg_lookup_super(struct objc_super *_Nonnull super, SEL _Nonnull selector)(a0,a1) IMP _Nonnull glue_objc_msg_lookup_super_stret(struct objc_super *_Nonnull super, SEL _Nonnull selector)(a0,a1) Class _Nullable glue_objc_lookUpClass(const char *_Nonnull name)(a0) Class _Nullable glue_objc_getClass(const char *_Nonnull name)(a0) Class _Nonnull glue_objc_getRequiredClass(const char *_Nonnull name)(a0) |
︙ | ︙ | |||
53 54 55 56 57 58 59 | const char *_Nullable glue_class_getName(Class _Nullable class_)(a0) Class _Nullable glue_class_getSuperclass(Class _Nullable class_)(a0) unsigned long glue_class_getInstanceSize(Class _Nullable class_)(a0) bool glue_class_respondsToSelector(Class _Nullable class_, SEL _Nonnull selector)(a0,a1) bool glue_class_conformsToProtocol(Class _Nullable class_, Protocol *_Nonnull p)(a0,a1) IMP _Nullable glue_class_getMethodImplementation(Class _Nullable class_, SEL _Nonnull selector)(a0,a1) IMP _Nullable glue_class_getMethodImplementation_stret(Class _Nullable class_, SEL _Nonnull selector)(a0,a1) | | > > > > > > > > > > | 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 | const char *_Nullable glue_class_getName(Class _Nullable class_)(a0) Class _Nullable glue_class_getSuperclass(Class _Nullable class_)(a0) unsigned long glue_class_getInstanceSize(Class _Nullable class_)(a0) bool glue_class_respondsToSelector(Class _Nullable class_, SEL _Nonnull selector)(a0,a1) bool glue_class_conformsToProtocol(Class _Nullable class_, Protocol *_Nonnull p)(a0,a1) IMP _Nullable glue_class_getMethodImplementation(Class _Nullable class_, SEL _Nonnull selector)(a0,a1) IMP _Nullable glue_class_getMethodImplementation_stret(Class _Nullable class_, SEL _Nonnull selector)(a0,a1) Method _Nullable glue_class_getInstanceMethod(Class _Nullable class_, SEL _Nonnull selector)(a0,a1) bool glue_class_addMethod(Class _Nonnull class_, SEL _Nonnull selector, IMP _Nonnull implementation, const char *_Nullable typeEncoding)(a0,a1,a2,a3) IMP _Nullable glue_class_replaceMethod(Class _Nonnull class_, SEL _Nonnull selector, IMP _Nonnull implementation, const char *_Nullable typeEncoding)(a0,a1,a2,a3) Class _Nullable glue_object_getClass(id _Nullable object)(a0) Class _Nullable glue_object_setClass(id _Nullable object, Class _Nonnull class_)(a0,a1) const char *_Nullable glue_object_getClassName(id _Nullable object)(a0) const char *_Nonnull glue_protocol_getName(Protocol *_Nonnull protocol)(a0) bool glue_protocol_isEqual(Protocol *_Nonnull protocol1, Protocol *_Nonnull protocol2)(a0,a1) bool glue_protocol_conformsToProtocol(Protocol *_Nonnull protocol1, Protocol *_Nonnull protocol2)(a0,a1) _Nullable objc_uncaught_exception_handler_t glue_objc_setUncaughtExceptionHandler(objc_uncaught_exception_handler_t _Nullable handler)(a0) void glue_objc_setForwardHandler(IMP _Nullable forward, IMP _Nullable stretForward)(a0,a1) void glue_objc_setEnumerationMutationHandler(objc_enumeration_mutation_handler_t _Nullable handler)(a0) void glue_objc_zero_weak_references(id _Nonnull value)(a0) void glue_objc_exit(void)() Ivar _Nullable *_Nullable glue_class_copyIvarList(Class _Nullable class_, unsigned int *_Nullable outCount)(a0,a1) const char *_Nonnull glue_ivar_getName(Ivar _Nonnull ivar)(a0) const char *_Nonnull glue_ivar_getTypeEncoding(Ivar _Nonnull ivar)(a0) ptrdiff_t glue_ivar_getOffset(Ivar _Nonnull ivar)(a0) Method _Nullable *_Nullable glue_class_copyMethodList(Class _Nullable class_, unsigned int *_Nullable outCount)(a0,a1) SEL _Nonnull glue_method_getName(Method _Nonnull method)(a0) const char *_Nullable glue_method_getTypeEncoding(Method _Nonnull method)(a0) objc_property_t _Nullable *_Nullable glue_class_copyPropertyList(Class _Nullable class_, unsigned int *_Nullable outCount)(a0,a1) const char *_Nonnull glue_property_getName(objc_property_t _Nonnull property)(a0) char *_Nullable glue_property_copyAttributeValue(objc_property_t _Nonnull property, const char *_Nonnull name)(a0,a1) ==end |
Modified src/runtime/category.m from [5c4513a7b1] to [3c4cc24bfa].
︙ | ︙ | |||
23 24 25 26 27 28 29 | #import "ObjFWRT.h" #import "private.h" static struct objc_hashtable *categoriesMap = NULL; static void | | | > > | < | | < | < | | < | | | | | | < | | | | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | #import "ObjFWRT.h" #import "private.h" static struct objc_hashtable *categoriesMap = NULL; static void registerSelectors(struct objc_category *category) { struct objc_method_list *iter; unsigned int i; for (iter = category->instanceMethods; iter != NULL; iter = iter->next) for (i = 0; i < iter->count; i++) objc_register_selector(&iter->methods[i].selector); for (iter = category->classMethods; iter != NULL; iter = iter->next) for (i = 0; i < iter->count; i++) objc_register_selector(&iter->methods[i].selector); } static void registerCategory(struct objc_category *category) { struct objc_category **categories; Class class = objc_classname_to_class(category->className, false); if (categoriesMap == NULL) categoriesMap = objc_hashtable_new( objc_hash_string, objc_equal_string, 2); categories = (struct objc_category **)objc_hashtable_get( categoriesMap, category->className); if (categories != NULL) { struct objc_category **newCategories; size_t i; for (i = 0; categories[i] != NULL; i++); if ((newCategories = realloc(categories, (i + 2) * sizeof(*categories))) == NULL) OBJC_ERROR("Not enough memory for category %s of " "class %s!", category->categoryName, category->className); newCategories[i] = category; newCategories[i + 1] = NULL; objc_hashtable_set(categoriesMap, category->className, newCategories); if (class != Nil && class->info & OBJC_CLASS_INFO_SETUP) { objc_update_dtable(class); objc_update_dtable(class->isa); } return; } if ((categories = malloc(2 * sizeof(*categories))) == NULL) OBJC_ERROR("Not enough memory for category %s of class %s!\n", category->categoryName, category->className); categories[0] = category; categories[1] = NULL; objc_hashtable_set(categoriesMap, category->className, categories); if (class != Nil && class->info & OBJC_CLASS_INFO_SETUP) { objc_update_dtable(class); objc_update_dtable(class->isa); } } void objc_register_all_categories(struct objc_symtab *symtab) { struct objc_category **categories = (struct objc_category **)symtab->defs + symtab->classDefsCount; for (size_t i = 0; i < symtab->categoryDefsCount; i++) { registerSelectors(categories[i]); registerCategory(categories[i]); } } |
︙ | ︙ |
Modified src/runtime/class.m from [132bb904b5] to [415251c564].
︙ | ︙ | |||
30 31 32 33 34 35 36 | static Class *loadQueue = NULL; static size_t loadQueueCount = 0; static struct objc_dtable *emptyDTable = NULL; static unsigned lookupsUntilFastPath = 128; static struct objc_sparsearray *fastPath = NULL; static void | | | | | | | 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 | static Class *loadQueue = NULL; static size_t loadQueueCount = 0; static struct objc_dtable *emptyDTable = NULL; static unsigned lookupsUntilFastPath = 128; static struct objc_sparsearray *fastPath = NULL; static void registerClass(Class class) { if (classes == NULL) classes = objc_hashtable_new( objc_hash_string, objc_equal_string, 2); objc_hashtable_set(classes, class->name, class); if (emptyDTable == NULL) emptyDTable = objc_dtable_new(); class->DTable = emptyDTable; class->isa->DTable = emptyDTable; if (strcmp(class->name, "Protocol") != 0) classesCount++; } bool class_registerAlias_np(Class class, const char *name) { objc_global_mutex_lock(); |
︙ | ︙ | |||
67 68 69 70 71 72 73 | objc_global_mutex_unlock(); return YES; } static void | | | > | < | | < | 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | objc_global_mutex_unlock(); return YES; } static void registerSelectors(Class class) { struct objc_method_list *iter; unsigned int i; for (iter = class->methodList; iter != NULL; iter = iter->next) for (i = 0; i < iter->count; i++) objc_register_selector(&iter->methods[i].selector); } Class objc_classname_to_class(const char *name, bool cache) { Class class; |
︙ | ︙ | |||
253 254 255 256 257 258 259 | OBJC_ERROR("Not enough memory for subclass list of class %s\n", class->superclass->name); class->superclass->subclassList[i] = class; class->superclass->subclassList[i + 1] = Nil; } | < | | | | | | | | | > > > > > > > > > > | > | > | | 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | OBJC_ERROR("Not enough memory for subclass list of class %s\n", class->superclass->name); class->superclass->subclassList[i] = class; class->superclass->subclassList[i + 1] = Nil; } static void updateIvarOffsets(Class class) { if (!(class->info & OBJC_CLASS_INFO_NEW_ABI)) return; if (class->instanceSize > 0) return; class->instanceSize = -class->instanceSize; if (class->superclass != Nil) { class->instanceSize += class->superclass->instanceSize; if (class->ivars != NULL) { for (unsigned int i = 0; i < class->ivars->count; i++) { class->ivars->ivars[i].offset += class->superclass->instanceSize; *class->ivarOffsets[i] = class->ivars->ivars[i].offset; } } } else for (unsigned int i = 0; i < class->ivars->count; i++) *class->ivarOffsets[i] = class->ivars->ivars[i].offset; } static void setupClass(Class class) { const char *superclassName; if (class->info & OBJC_CLASS_INFO_SETUP) return; superclassName = (const char *)class->superclass; if (superclassName != NULL) { Class super = objc_classname_to_class(superclassName, false); Class rootClass; if (super == Nil) return; setupClass(super); if (!(super->info & OBJC_CLASS_INFO_SETUP)) return; /* * GCC sets class->isa->isa to the name of the root class, * while Clang just sets it to Nil. Therefore always calculate * it. */ for (Class iter = super; iter != NULL; iter = iter->superclass) rootClass = iter; class->superclass = super; class->isa->isa = rootClass->isa; class->isa->superclass = super->isa; addSubclass(class); addSubclass(class->isa); } else { class->isa->isa = class->isa; class->isa->superclass = class; } updateIvarOffsets(class); class->info |= OBJC_CLASS_INFO_SETUP; class->isa->info |= OBJC_CLASS_INFO_SETUP; } static void initializeClass(Class class) |
︙ | ︙ | |||
414 415 416 417 418 419 420 | if (loadQueue == NULL) OBJC_ERROR("Not enough memory for load queue!"); } } } void | | < | | | | | 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 | if (loadQueue == NULL) OBJC_ERROR("Not enough memory for load queue!"); } } } void objc_register_all_classes(struct objc_symtab *symtab) { for (uint16_t i = 0; i < symtab->classDefsCount; i++) { Class class = (Class)symtab->defs[i]; registerClass(class); registerSelectors(class); registerSelectors(class->isa); } for (uint16_t i = 0; i < symtab->classDefsCount; i++) { Class class = (Class)symtab->defs[i]; if (hasLoad(class)) { setupClass(class); |
︙ | ︙ | |||
489 490 491 492 493 494 495 | } void objc_registerClassPair(Class class) { objc_global_mutex_lock(); | | | 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 | } void objc_registerClassPair(Class class) { objc_global_mutex_lock(); registerClass(class); if (class->superclass != Nil) { addSubclass(class); addSubclass(class->isa); } class->info |= OBJC_CLASS_INFO_SETUP; |
︙ | ︙ | |||
757 758 759 760 761 762 763 | methodList->methods[0].implementation = implementation; class->methodList = methodList; objc_update_dtable(class); } | | | | > < | > > | | | 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 | methodList->methods[0].implementation = implementation; class->methodList = methodList; objc_update_dtable(class); } Method class_getInstanceMethod(Class class, SEL selector) { Method method; Class superclass; if (class == Nil) return NULL; objc_global_mutex_lock(); if ((method = getMethod(class, selector)) != NULL) { objc_global_mutex_unlock(); return method; } superclass = class->superclass; objc_global_mutex_unlock(); if (superclass != Nil) return class_getInstanceMethod(superclass, selector); return NULL; } bool class_addMethod(Class class, SEL selector, IMP implementation, const char *typeEncoding) |
︙ | ︙ | |||
862 863 864 865 866 867 868 | { return class_getName(object_getClass(object)); } static void unregisterClass(Class class) { | < < | 873 874 875 876 877 878 879 880 881 882 883 884 885 886 | { return class_getName(object_getClass(object)); } static void unregisterClass(Class class) { if ((class->info & OBJC_CLASS_INFO_SETUP) && class->superclass != Nil && class->superclass->subclassList != NULL) { size_t i = SIZE_MAX, count = 0; Class *tmp; for (tmp = class->superclass->subclassList; *tmp != Nil; tmp++) { |
︙ | ︙ | |||
899 900 901 902 903 904 905 | if (class->DTable != NULL && class->DTable != emptyDTable) objc_dtable_free(class->DTable); class->DTable = NULL; if ((class->info & OBJC_CLASS_INFO_SETUP) && class->superclass != Nil) | | | 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 | if (class->DTable != NULL && class->DTable != emptyDTable) objc_dtable_free(class->DTable); class->DTable = NULL; if ((class->info & OBJC_CLASS_INFO_SETUP) && class->superclass != Nil) class->superclass = (Class)class->superclass->name; class->info &= ~OBJC_CLASS_INFO_SETUP; } void objc_unregister_class(Class class) { |
︙ | ︙ |
Modified src/runtime/init.m from [8f157610ad] to [b72034f7da].
︙ | ︙ | |||
17 18 19 20 21 22 23 | #include "config.h" #import "ObjFWRT.h" #import "private.h" void | | < < | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | #include "config.h" #import "ObjFWRT.h" #import "private.h" void __objc_exec_class(struct objc_module *module) { objc_global_mutex_lock(); objc_register_all_selectors(module->symtab); objc_register_all_classes(module->symtab); objc_register_all_categories(module->symtab); objc_init_static_instances(module->symtab); |
︙ | ︙ |
Added src/runtime/ivar.m version [b1aba62100].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | /* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, * 2018, 2019 * Jonathan Schleifer <js@heap.zone> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #import "ObjFWRT.h" #import "private.h" Ivar * class_copyIvarList(Class class, unsigned int *outCount) { unsigned int count; Ivar *ivars; if (class == Nil) { if (outCount != NULL) *outCount = 0; return NULL; } objc_global_mutex_lock(); count = (class->ivars != NULL ? class->ivars->count : 0); if (count == 0) { if (outCount != NULL) *outCount = 0; objc_global_mutex_unlock(); return NULL; } if ((ivars = malloc((count + 1) * sizeof(Ivar))) == NULL) OBJC_ERROR("Not enough memory to copy ivars"); for (unsigned int i = 0; i < count; i++) ivars[i] = &class->ivars->ivars[i]; ivars[count] = NULL; if (outCount != NULL) *outCount = count; objc_global_mutex_unlock(); return ivars; } const char * ivar_getName(Ivar ivar) { return ivar->name; } const char * ivar_getTypeEncoding(Ivar ivar) { return ivar->typeEncoding; } ptrdiff_t ivar_getOffset(Ivar ivar) { return ivar->offset; } |
Modified src/runtime/linklib/linklib.m from [9569bc8b44] to [df8b8ee743].
︙ | ︙ | |||
136 137 138 139 140 141 142 | DESTRUCTOR_P(ObjFWRT, 4000) { dtor(); } #endif void | | | 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | DESTRUCTOR_P(ObjFWRT, 4000) { dtor(); } #endif void __objc_exec_class(struct objc_module *module) { /* * The compiler generates constructors that call into this, so it is * possible that we are not set up yet when we get called. */ ctor(); |
︙ | ︙ | |||
500 501 502 503 504 505 506 | IMP class_getMethodImplementation_stret(Class class, SEL selector) { return glue_class_getMethodImplementation_stret(class, selector); } | | | | | 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 | IMP class_getMethodImplementation_stret(Class class, SEL selector) { return glue_class_getMethodImplementation_stret(class, selector); } Method class_getInstanceMethod(Class class, SEL selector) { return glue_class_getInstanceMethod(class, selector); } bool class_addMethod(Class class, SEL selector, IMP implementation, const char *typeEncoding) { return glue_class_addMethod(class, selector, implementation, |
︙ | ︙ | |||
587 588 589 590 591 592 593 | } void objc_exit(void) { glue_objc_exit(); } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | } void objc_exit(void) { glue_objc_exit(); } Ivar * class_copyIvarList(Class class, unsigned int *outCount) { return glue_class_copyIvarList(class, outCount); } const char * ivar_getName(Ivar ivar) { return glue_ivar_getName(ivar); } const char * ivar_getTypeEncoding(Ivar ivar) { return glue_ivar_getTypeEncoding(ivar); } ptrdiff_t ivar_getOffset(Ivar ivar) { return glue_ivar_getOffset(ivar); } Method * class_copyMethodList(Class class, unsigned int *outCount) { return glue_class_copyMethodList(class, outCount); } SEL method_getName(Method method) { return glue_method_getName(method); } const char * method_getTypeEncoding(Method method) { return glue_method_getTypeEncoding(method); } objc_property_t * class_copyPropertyList(Class class, unsigned int *outCount) { return glue_class_copyPropertyList(class, outCount); } const char * property_getName(objc_property_t property) { return glue_property_getName(property); } char * property_copyAttributeValue(objc_property_t property, const char *name) { return glue_property_copyAttributeValue(property, name); } |
Added src/runtime/method.m version [49dc632b0c].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | /* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, * 2018, 2019 * Jonathan Schleifer <js@heap.zone> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #import "ObjFWRT.h" #import "private.h" Method * class_copyMethodList(Class class, unsigned int *outCount) { unsigned int i, count; struct objc_method_list *iter; Method *methods; if (class == Nil) { if (outCount != NULL) *outCount = 0; return NULL; } objc_global_mutex_lock(); count = 0; for (iter = class->methodList; iter != NULL; iter = iter->next) count += iter->count; if (count == 0) { if (outCount != NULL) *outCount = 0; objc_global_mutex_unlock(); return NULL; } if ((methods = malloc((count + 1) * sizeof(Method))) == NULL) OBJC_ERROR("Not enough memory to copy methods"); i = 0; for (iter = class->methodList; iter != NULL; iter = iter->next) for (unsigned int j = 0; j < iter->count; j++) methods[i++] = &iter->methods[j]; OF_ENSURE(i == count); methods[count] = NULL; if (outCount != NULL) *outCount = count; objc_global_mutex_unlock(); return methods; } SEL method_getName(Method method) { return (SEL)&method->selector; } const char * method_getTypeEncoding(Method method) { return method->selector.typeEncoding; } |
Modified src/runtime/morphos-clib.h from [4a0280b314] to [ad80976596].
1 2 3 | /* Functions that are only for the linklib. */ bool glue_objc_init(unsigned int, struct objc_libc *, FILE *, FILE *); /* All other functions. */ | | | 1 2 3 4 5 6 7 8 9 10 11 | /* Functions that are only for the linklib. */ bool glue_objc_init(unsigned int, struct objc_libc *, FILE *, FILE *); /* All other functions. */ void glue___objc_exec_class(struct objc_module *); IMP glue_objc_msg_lookup(id, SEL); IMP glue_objc_msg_lookup_stret(id, SEL); IMP glue_objc_msg_lookup_super(struct objc_super *, SEL); IMP glue_objc_msg_lookup_super_stret(struct objc_super *, SEL); Class glue_objc_lookUpClass(const char *); Class glue_objc_getClass(const char *); Class glue_objc_getRequiredClass(const char *); |
︙ | ︙ | |||
47 48 49 50 51 52 53 | const char *glue_class_getName(Class); Class glue_class_getSuperclass(Class); unsigned long glue_class_getInstanceSize(Class); bool glue_class_respondsToSelector(Class, SEL); bool glue_class_conformsToProtocol(Class, Protocol *); IMP glue_class_getMethodImplementation(Class, SEL); IMP glue_class_getMethodImplementation_stret(Class, SEL); | | > > > > > > > > > > | 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 | const char *glue_class_getName(Class); Class glue_class_getSuperclass(Class); unsigned long glue_class_getInstanceSize(Class); bool glue_class_respondsToSelector(Class, SEL); bool glue_class_conformsToProtocol(Class, Protocol *); IMP glue_class_getMethodImplementation(Class, SEL); IMP glue_class_getMethodImplementation_stret(Class, SEL); Method glue_class_getInstanceMethod(Class, SEL); bool glue_class_addMethod(Class class_, SEL selector, IMP, const char *); IMP glue_class_replaceMethod(Class, SEL, IMP, const char *); Class glue_object_getClass(id); Class glue_object_setClass(id, Class); const char *glue_object_getClassName(id); const char *glue_protocol_getName(Protocol *); bool glue_protocol_isEqual(Protocol *, Protocol *); bool glue_protocol_conformsToProtocol(Protocol *, Protocol *); objc_uncaught_exception_handler_t glue_objc_setUncaughtExceptionHandler(objc_uncaught_exception_handler_t); void glue_objc_setForwardHandler(IMP, IMP); void glue_objc_setEnumerationMutationHandler(objc_enumeration_mutation_handler_t); void glue_objc_zero_weak_references(id); void glue_objc_exit(void); Ivar *glue_class_copyIvarList(Class class_, unsigned int *outCount); const char *glue_ivar_getName(Ivar ivar); const char *glue_ivar_getTypeEncoding(Ivar ivar); ptrdiff_t glue_ivar_getOffset(Ivar ivar); Method *glue_class_copyMethodList(Class class_, unsigned int *outCount); SEL glue_method_getName(Method method); const char *glue_method_getTypeEncoding(Method method); objc_property_t *glue_class_copyPropertyList(Class class_, unsigned int *outCount); const char *glue_property_getName(objc_property_t property); char *glue_property_copyAttributeValue(objc_property_t property, const char *name); |
Modified src/runtime/morphos.fd from [28b3a4e6a7] to [826761c847].
︙ | ︙ | |||
49 50 51 52 53 54 55 | glue_class_getName(class_)(sysv,r12base) glue_class_getSuperclass(class_)(sysv,r12base) glue_class_getInstanceSize(class_)(sysv,r12base) glue_class_respondsToSelector(class_,selector)(sysv,r12base) glue_class_conformsToProtocol(class_,p)(sysv,r12base) glue_class_getMethodImplementation(class_,selector)(sysv,r12base) glue_class_getMethodImplementation_stret(class_,selector)(sysv,r12base) | | > > > > > > > > > > | 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 | glue_class_getName(class_)(sysv,r12base) glue_class_getSuperclass(class_)(sysv,r12base) glue_class_getInstanceSize(class_)(sysv,r12base) glue_class_respondsToSelector(class_,selector)(sysv,r12base) glue_class_conformsToProtocol(class_,p)(sysv,r12base) glue_class_getMethodImplementation(class_,selector)(sysv,r12base) glue_class_getMethodImplementation_stret(class_,selector)(sysv,r12base) glue_class_getInstanceMethod(class_,selector)(sysv,r12base) glue_class_addMethod(class_,selector,implementation,typeEncoding)(sysv,r12base) glue_class_replaceMethod(class_,selector,implementation,typeEncoding)(sysv,r12base) glue_object_getClass(object)(sysv,r12base) glue_object_setClass(object,class_)(sysv,r12base) glue_object_getClassName(object)(sysv,r12base) glue_protocol_getName(protocol)(sysv,r12base) glue_protocol_isEqual(protocol1,protocol2)(sysv,r12base) glue_protocol_conformsToProtocol(protocol1,protocol2)(sysv,r12base) glue_objc_setUncaughtExceptionHandler(handler)(sysv,r12base) glue_objc_setForwardHandler(forward,stretForward)(sysv,r12base) glue_objc_setEnumerationMutationHandler(handler)(sysv,r12base) glue_objc_zero_weak_references(value)(sysv,r12base) glue_objc_exit()(sysv,r12base) glue_class_copyIvarList(class_,outCount)(sysv,r12base) glue_ivar_getName(ivar)(sysv,r12base) glue_ivar_getTypeEncoding(ivar)(sysv,r12base) glue_ivar_getOffset(ivar)(sysv,r12base) glue_class_copyMethodList(class_,outCount)(sysv,r12base) glue_method_getName(method)(sysv,r12base) glue_method_getTypeEncoding(method)(sysv,r12base) glue_class_copyPropertyList(class_,outCount)(sysv,r12base) glue_property_getName(property)(sysv,r12base) glue_property_copyAttributeValue(property,name)(sysv,r12base) ##end |
Modified src/runtime/private.h from [62b52db4cc] to [4747c0153c].
︙ | ︙ | |||
25 26 27 28 29 30 31 | # define _Nonnull # endif # ifndef _Nullable # define _Nullable # endif #endif | | | | | | | | | | | | > > > > > > > > > > | | > > > > | | | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | # define _Nonnull # endif # ifndef _Nullable # define _Nullable # endif #endif struct objc_class { Class _Nonnull isa; Class _Nullable superclass; const char *_Nonnull name; unsigned long version; unsigned long info; long instanceSize; struct objc_ivar_list *_Nullable ivars; struct objc_method_list *_Nullable methodList; struct objc_dtable *_Nonnull DTable; Class _Nullable *_Nullable subclassList; void *_Nullable siblingClass; struct objc_protocol_list *_Nullable protocols; void *_Nullable GCObjectType; unsigned long ABIVersion; int32_t *_Nonnull *_Nullable ivarOffsets; struct objc_property_list *_Nullable propertyList; }; enum objc_class_info { OBJC_CLASS_INFO_CLASS = 0x001, OBJC_CLASS_INFO_METACLASS = 0x002, OBJC_CLASS_INFO_NEW_ABI = 0x010, OBJC_CLASS_INFO_SETUP = 0x100, OBJC_CLASS_INFO_LOADED = 0x200, OBJC_CLASS_INFO_DTABLE = 0x400, OBJC_CLASS_INFO_INITIALIZED = 0x800 }; struct objc_object { Class _Nonnull isa; }; struct objc_selector { uintptr_t UID; const char *_Nullable typeEncoding; }; struct objc_method { struct objc_selector selector; IMP _Nonnull implementation; }; struct objc_method_list { struct objc_method_list *_Nullable next; unsigned int count; struct objc_method methods[1]; }; struct objc_category { const char *_Nonnull categoryName; const char *_Nonnull className; struct objc_method_list *_Nullable instanceMethods; struct objc_method_list *_Nullable classMethods; struct objc_protocol_list *_Nullable protocols; }; struct objc_ivar { const char *_Nonnull name; const char *_Nonnull typeEncoding; unsigned int offset; }; struct objc_ivar_list { unsigned int count; struct objc_ivar ivars[1]; }; struct objc_method_description { const char *_Nonnull name; const char *_Nonnull typeEncoding; }; struct objc_method_description_list { int count; struct objc_method_description list[1]; }; struct objc_protocol_list { struct objc_protocol_list *_Nullable next; long count; Protocol *__unsafe_unretained _Nonnull list[1]; }; #if __has_attribute(__objc_root_class__) __attribute__((__objc_root_class__)) #endif @interface Protocol { @public Class _Nonnull isa; const char *_Nonnull name; struct objc_protocol_list *_Nullable protocolList; struct objc_method_description_list *_Nullable instanceMethods; struct objc_method_description_list *_Nullable classMethods; } @end enum objc_property_attributes { OBJC_PROPERTY_READONLY = 0x01, OBJC_PROPERTY_GETTER = 0x02, OBJC_PROPERTY_ASSIGN = 0x04, OBJC_PROPERTY_READWRITE = 0x08, OBJC_PROPERTY_RETAIN = 0x10, OBJC_PROPERTY_COPY = 0x20, OBJC_PROPERTY_NONATOMIC = 0x40, OBJC_PROPERTY_SETTER = 0x80 }; enum objc_property_extended_attributes { OBJC_PROPERTY_SYNTHESIZED = 0x1, OBJC_PROPERTY_DYNAMIC = 0x2, OBJC_PROPERTY_PROTOCOL = 0x3, OBJC_PROPERTY_ATOMIC = 0x4, OBJC_PROPERTY_WEAK = 0x8, OBJC_PROPERTY_STRONG = 0x10, OBJC_PROPERTY_UNSAFE_UNRETAINED = 0x20 }; struct objc_property { const char *_Nonnull name; unsigned char attributes, extendedAttributes; struct { const char *_Nullable name; const char *_Nullable typeEncoding; } getter, setter; }; struct objc_property_list { unsigned int count; struct objc_property_list *_Nullable next; struct objc_property properties[1]; }; struct objc_static_instances { const char *_Nonnull className; id _Nullable instances[1]; }; struct objc_symtab { unsigned long unknown; struct objc_selector *_Nullable selectorRefs; uint16_t classDefsCount; uint16_t categoryDefsCount; void *_Nonnull defs[1]; }; struct objc_module { unsigned long version; /* 9 = non-fragile */ unsigned long size; const char *_Nullable name; struct objc_symtab *_Nonnull symtab; }; struct objc_hashtable_bucket { const void *_Nonnull key, *_Nonnull object; uint32_t hash; }; |
︙ | ︙ | |||
170 171 172 173 174 175 176 | type name = reg_##name; # endif # undef stdout # undef stderr extern FILE *stdout, *stderr; #endif | | | | | | | 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 | type name = reg_##name; # endif # undef stdout # undef stderr extern FILE *stdout, *stderr; #endif extern void objc_register_all_categories(struct objc_symtab *_Nonnull); extern struct objc_category *_Nullable *_Nullable objc_categories_for_class(Class _Nonnull); extern void objc_unregister_all_categories(void); extern void objc_initialize_class(Class _Nonnull); extern void objc_update_dtable(Class _Nonnull); extern void objc_register_all_classes(struct objc_symtab *_Nonnull); extern Class _Nullable objc_classname_to_class(const char *_Nonnull, bool); extern void objc_unregister_class(Class _Nonnull); extern void objc_unregister_all_classes(void); extern uint32_t objc_hash_string(const void *_Nonnull); extern bool objc_equal_string(const void *_Nonnull, const void *_Nonnull); extern struct objc_hashtable *_Nonnull objc_hashtable_new( uint32_t (*_Nonnull)(const void *_Nonnull), bool (*_Nonnull)(const void *_Nonnull, const void *_Nonnull), uint32_t); extern struct objc_hashtable_bucket objc_deleted_bucket; extern void objc_hashtable_set(struct objc_hashtable *_Nonnull, const void *_Nonnull, const void *_Nonnull); extern void *_Nullable objc_hashtable_get(struct objc_hashtable *_Nonnull, const void *_Nonnull); extern void objc_hashtable_delete(struct objc_hashtable *_Nonnull, const void *_Nonnull); extern void objc_hashtable_free(struct objc_hashtable *_Nonnull); extern void objc_register_selector(struct objc_selector *_Nonnull); extern void objc_register_all_selectors(struct objc_symtab *_Nonnull); extern void objc_unregister_all_selectors(void); extern struct objc_sparsearray *_Nonnull objc_sparsearray_new(uint8_t); extern void *_Nullable objc_sparsearray_get(struct objc_sparsearray *_Nonnull, uintptr_t); extern void objc_sparsearray_set(struct objc_sparsearray *_Nonnull, uintptr_t, void *_Nullable); extern void objc_sparsearray_free(struct objc_sparsearray *_Nonnull); extern struct objc_dtable *_Nonnull objc_dtable_new(void); extern void objc_dtable_copy(struct objc_dtable *_Nonnull, struct objc_dtable *_Nonnull); extern void objc_dtable_set(struct objc_dtable *_Nonnull, uint32_t, IMP _Nullable); extern void objc_dtable_free(struct objc_dtable *_Nonnull); extern void objc_dtable_cleanup(void); extern void objc_init_static_instances(struct objc_symtab *_Nonnull); extern void objc_forget_pending_static_instances(void); #ifdef OF_HAVE_THREADS extern void objc_global_mutex_lock(void); extern void objc_global_mutex_unlock(void); extern void objc_global_mutex_free(void); #else # define objc_global_mutex_lock() |
︙ | ︙ |
Modified src/runtime/property.m from [af06feb764] to [b52cba63b9].
︙ | ︙ | |||
152 153 154 155 156 157 158 | #endif return; } memcpy(dest, src, size); } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | #endif return; } memcpy(dest, src, size); } objc_property_t * class_copyPropertyList(Class class, unsigned int *outCount) { unsigned int i, count; struct objc_property_list *iter; objc_property_t *properties; if (class == Nil) { if (outCount != NULL) *outCount = 0; return NULL; } objc_global_mutex_lock(); count = 0; if (class->info & OBJC_CLASS_INFO_NEW_ABI) for (iter = class->propertyList; iter != NULL; iter = iter->next) count += iter->count; if (count == 0) { if (outCount != NULL) *outCount = 0; objc_global_mutex_unlock(); return NULL; } properties = malloc((count + 1) * sizeof(objc_property_t)); if (properties == NULL) OBJC_ERROR("Not enough memory to copy properties"); i = 0; for (iter = class->propertyList; iter != NULL; iter = iter->next) for (unsigned int j = 0; j < iter->count; j++) properties[i++] = &iter->properties[j]; OF_ENSURE(i == count); properties[count] = NULL; if (outCount != NULL) *outCount = count; objc_global_mutex_unlock(); return properties; } const char * property_getName(objc_property_t property) { return property->name; } char * property_copyAttributeValue(objc_property_t property, const char *name) { char *ret = NULL; bool nullIsError = false; if (strlen(name) != 1) return NULL; switch (*name) { case 'T': ret = of_strdup(property->getter.typeEncoding); nullIsError = true; break; case 'G': if (property->attributes & OBJC_PROPERTY_GETTER) { ret = of_strdup(property->getter.name); nullIsError = true; } break; case 'S': if (property->attributes & OBJC_PROPERTY_SETTER) { ret = of_strdup(property->setter.name); nullIsError = true; } break; #define BOOL_CASE(name, field, flag) \ case name: \ if (property->field & flag) { \ ret = calloc(1, 1); \ nullIsError = true; \ } \ break; BOOL_CASE('R', attributes, OBJC_PROPERTY_READONLY) BOOL_CASE('C', attributes, OBJC_PROPERTY_COPY) BOOL_CASE('&', attributes, OBJC_PROPERTY_RETAIN) BOOL_CASE('N', attributes, OBJC_PROPERTY_NONATOMIC) BOOL_CASE('D', extendedAttributes, OBJC_PROPERTY_DYNAMIC) BOOL_CASE('W', extendedAttributes, OBJC_PROPERTY_WEAK) #undef BOOL_CASE } if (nullIsError && ret == NULL) OBJC_ERROR("Not enough memory to copy property attribute " "value"); return ret; } |
Modified src/runtime/selector.m from [99b2d0f965] to [b2795ffb4b].
︙ | ︙ | |||
37 38 39 40 41 42 43 | static struct objc_hashtable *selectors = NULL; static uint32_t selectorsCount = 0; static struct objc_sparsearray *selectorNames = NULL; static void **freeList = NULL; static size_t freeListCount = 0; void | | | | | | | < | | | | | | | | | | | | | < | | 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 | static struct objc_hashtable *selectors = NULL; static uint32_t selectorsCount = 0; static struct objc_sparsearray *selectorNames = NULL; static void **freeList = NULL; static size_t freeListCount = 0; void objc_register_selector(struct objc_selector *selector) { SEL existingSelector; const char *name; if (selectorsCount > SEL_MAX) OBJC_ERROR("Out of selector slots!"); if (selectors == NULL) selectors = objc_hashtable_new( objc_hash_string, objc_equal_string, 2); else if ((existingSelector = objc_hashtable_get(selectors, (const char *)selector->UID)) != NULL) { selector->UID = existingSelector->UID; return; } if (selectorNames == NULL) selectorNames = objc_sparsearray_new(SEL_SIZE); name = (const char *)selector->UID; selector->UID = selectorsCount++; objc_hashtable_set(selectors, name, selector); objc_sparsearray_set(selectorNames, (uint32_t)selector->UID, (void *)name); } SEL sel_registerName(const char *name) { struct objc_selector *selector; objc_global_mutex_lock(); if (selectors != NULL && (selector = objc_hashtable_get(selectors, name)) != NULL) { objc_global_mutex_unlock(); return (SEL)selector; } if ((selector = malloc(sizeof(*selector))) == NULL) OBJC_ERROR("Not enough memory to allocate selector!"); if ((selector->UID = (uintptr_t)of_strdup(name)) == 0) OBJC_ERROR("Not enough memory to allocate selector!"); selector->typeEncoding = NULL; if ((freeList = realloc(freeList, sizeof(void *) * (freeListCount + 2))) == NULL) OBJC_ERROR("Not enough memory to allocate selector!"); freeList[freeListCount++] = selector; freeList[freeListCount++] = (char *)selector->UID; objc_register_selector(selector); objc_global_mutex_unlock(); return (SEL)selector; } void objc_register_all_selectors(struct objc_symtab *symtab) { struct objc_selector *selector; if (symtab->selectorRefs == NULL) return; for (selector = symtab->selectorRefs; selector->UID != 0; selector++) objc_register_selector(selector); } const char * sel_getName(SEL selector) { const char *ret; |
︙ | ︙ |
Modified src/runtime/static-instances.m from [8c2bdd3f07] to [331920028d].
︙ | ︙ | |||
19 20 21 22 23 24 25 | #include <stdio.h> #include <stdlib.h> #import "ObjFWRT.h" #import "private.h" | | | | | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #include <stdio.h> #include <stdlib.h> #import "ObjFWRT.h" #import "private.h" static struct objc_static_instances **staticInstancesList = NULL; static size_t staticInstancesCount = 0; void objc_init_static_instances(struct objc_symtab *symtab) { struct objc_static_instances **staticInstances; /* Check if the class for a static instance became available */ for (size_t i = 0; i < staticInstancesCount; i++) { Class class = objc_lookUpClass( staticInstancesList[i]->className); if (class != Nil) { |
︙ | ︙ | |||
49 50 51 52 53 54 55 | break; } staticInstancesList[i] = staticInstancesList[staticInstancesCount]; staticInstancesList = realloc(staticInstancesList, | | | | | 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 | break; } staticInstancesList[i] = staticInstancesList[staticInstancesCount]; staticInstancesList = realloc(staticInstancesList, sizeof(*staticInstancesList) * staticInstancesCount); if (staticInstancesList == NULL) OBJC_ERROR("Not enough memory for list of " "static instances!"); /* * We moved the last entry to the current index, * therefore we need to run again for the current index. */ i--; } } staticInstances = (struct objc_static_instances **) symtab->defs[symtab->classDefsCount + symtab->categoryDefsCount]; if (staticInstances == NULL) return; for (; *staticInstances != NULL; staticInstances++) { Class class = objc_lookUpClass((*staticInstances)->className); if (class != Nil) { for (id *instances = (*staticInstances)->instances; *instances != nil; instances++) object_setClass(*instances, class); } else { staticInstancesList = realloc(staticInstancesList, sizeof(*staticInstancesList) * (staticInstancesCount + 1)); if (staticInstancesList == NULL) OBJC_ERROR("Not enough memory for list of " "static instances!"); staticInstancesList[staticInstancesCount++] = |
︙ | ︙ |
Modified src/socket.m from [b18a1905f9] to [8c4ab8f800].
︙ | ︙ | |||
466 467 468 469 470 471 472 | addrIn6->sin6_addr.s6_addr[i++] = number; } i = 16; for (OFString *component in rightComponents.reversedArray) { uint16_t number = parseIPv6Component(component); | | | | 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 | addrIn6->sin6_addr.s6_addr[i++] = number; } i = 16; for (OFString *component in rightComponents.reversedArray) { uint16_t number = parseIPv6Component(component); addrIn6->sin6_addr.s6_addr[--i] = number; addrIn6->sin6_addr.s6_addr[--i] = number >> 8; } } else { OFArray OF_GENERIC(OFString *) *components = [IPv6 componentsSeparatedByString: @":"]; size_t i; if (components.count != 8) |
︙ | ︙ |
Modified tests/OFBlockTests.m from [6e73d74cf4] to [62a88e7629].
︙ | ︙ | |||
17 18 19 20 21 22 23 | #include "config.h" #import "TestsAppDelegate.h" static OFString *module = @"OFBlock"; | > | | | > > > > > | | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | #include "config.h" #import "TestsAppDelegate.h" static OFString *module = @"OFBlock"; #if defined(OF_OBJFW_RUNTIME) extern struct objc_class _NSConcreteStackBlock; extern struct objc_class _NSConcreteGlobalBlock; extern struct objc_class _NSConcreteMallocBlock; #elif defined(OF_APPLE_RUNTIME) extern void *_NSConcreteStackBlock; extern void *_NSConcreteGlobalBlock; extern void *_NSConcreteMallocBlock; #endif static void (^g)(void) = ^ {}; static int (^returnStackBlock(void))(void) { __block int i = 42; return [Block_copy(^ int { return ++i; }) autorelease]; } static double forwardTest(void) { __block double d; void (^b)(void) = Block_copy(^ { |
︙ | ︙ |
Modified tests/OFInvocationTests.m from [a893e98c20] to [7acb8f9710].
︙ | ︙ | |||
38 39 40 41 42 43 44 45 46 47 48 49 50 51 | : (unsigned int)i : (struct test_struct *)ptr : (struct test_struct)st { return st; } - (void)invocationTestMethod2: (id)obj { assert(obj == self); } - (int)invocationTestMethod3: (int)i1 : (int)i2 | > | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | : (unsigned int)i : (struct test_struct *)ptr : (struct test_struct)st { return st; } #ifdef OF_INVOCATION_CAN_INVOKE - (void)invocationTestMethod2: (id)obj { assert(obj == self); } - (int)invocationTestMethod3: (int)i1 : (int)i2 |
︙ | ︙ | |||
127 128 129 130 131 132 133 | : (long double)d15 : (long double)d16 { return (d1 + d2 + d3 + d4 + d5 + d6 + d7 + d8 + d9 + d10 + d11 + d12 + d13 + d14 + d15 + d16) / 16; } | | | 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | : (long double)d15 : (long double)d16 { return (d1 + d2 + d3 + d4 + d5 + d6 + d7 + d8 + d9 + d10 + d11 + d12 + d13 + d14 + d15 + d16) / 16; } # if defined(HAVE_COMPLEX_H) && !defined(__STDC_NO_COMPLEX__) - (complex double)invocationTestMethod7: (complex float)c1 : (complex double)c2 : (complex float)c3 : (complex double)c4 : (complex float)c5 : (complex double)c6 : (complex float)c7 |
︙ | ︙ | |||
203 204 205 206 207 208 209 | OF_ENSURE(creal(c14) == 14.0 && cimag(c14) == 7.0); OF_ENSURE(creal(c15) == 15.0 && cimag(c15) == 7.5); OF_ENSURE(creal(c16) == 16.0 && cimag(c16) == 8.0); return (c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8 + c9 + c10 + c11 + c12 + c13 + c14 + c15 + c16) / 16; } | | | | 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | OF_ENSURE(creal(c14) == 14.0 && cimag(c14) == 7.0); OF_ENSURE(creal(c15) == 15.0 && cimag(c15) == 7.5); OF_ENSURE(creal(c16) == 16.0 && cimag(c16) == 8.0); return (c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8 + c9 + c10 + c11 + c12 + c13 + c14 + c15 + c16) / 16; } # endif # ifdef __SIZEOF_INT128__ __extension__ - (__int128)invocationTestMethod9: (int)i1 : (__int128)i2 : (__int128)i3 : (__int128)i4 : (int)i5 : (__int128)i6 |
︙ | ︙ | |||
247 248 249 250 251 252 253 254 255 256 257 258 259 260 | OF_ENSURE(i15 == mask + 15); OF_ENSURE(i16 == mask + 16); return ((i1 + (int)i2 + (int)i3 + (int)i4 + i5 + (int)i6 + (int)i7 + (int)i8 + (int)i9 + (int)i10 + (int)i11 + (int)i12 + (int)i13 + (int)i14 + (int)i15 + (int)i16) / 16) + mask; } #endif - (void)invocationTests { void *pool = objc_autoreleasePoolPush(); SEL selector = @selector(invocationTestMethod1::::); OFMethodSignature *sig = [self methodSignatureForSelector: selector]; | > | 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | OF_ENSURE(i15 == mask + 15); OF_ENSURE(i16 == mask + 16); return ((i1 + (int)i2 + (int)i3 + (int)i4 + i5 + (int)i6 + (int)i7 + (int)i8 + (int)i9 + (int)i10 + (int)i11 + (int)i12 + (int)i13 + (int)i14 + (int)i15 + (int)i16) / 16) + mask; } # endif #endif - (void)invocationTests { void *pool = objc_autoreleasePoolPush(); SEL selector = @selector(invocationTestMethod1::::); OFMethodSignature *sig = [self methodSignatureForSelector: selector]; |
︙ | ︙ |
Modified utils/ofdns/OFDNS.m from [ac49749d23] to [9954b1c29a].
︙ | ︙ | |||
19 20 21 22 23 24 25 | #import "OFApplication.h" #import "OFArray.h" #import "OFDNSResolver.h" #import "OFSandbox.h" #import "OFStdIOStream.h" | | | | | < < | | < < < < < < | | | | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | #import "OFApplication.h" #import "OFArray.h" #import "OFDNSResolver.h" #import "OFSandbox.h" #import "OFStdIOStream.h" @interface OFDNS: OFObject <OFApplicationDelegate, OFDNSResolverQueryDelegate> @end OF_APPLICATION_DELEGATE(OFDNS) @implementation OFDNS - (void)resolver: (OFDNSResolver *)resolver didPerformQuery: (OFDNSQuery *)query response: (OFDNSResponse *)response exception: (id)exception { if (exception != nil) { [of_stderr writeFormat: @"Failed to resolve: %@\n", exception]; [OFApplication terminateWithStatus: 1]; } [of_stdout writeFormat: @"%@\n", response]; [OFApplication terminate]; } - (void)applicationDidFinishLaunching { OFArray OF_GENERIC(OFString *) *arguments = [OFApplication arguments]; of_dns_class_t DNSClass = OF_DNS_CLASS_ANY; of_dns_record_type_t recordType = OF_DNS_RECORD_TYPE_ALL; OFDNSQuery *query; OFDNSResolver *resolver; #ifdef OF_HAVE_SANDBOX OFSandbox *sandbox = [[OFSandbox alloc] init]; @try { sandbox.allowsStdIO = true; sandbox.allowsDNS = true; |
︙ | ︙ | |||
78 79 80 81 82 83 84 | [OFApplication programName]]; [OFApplication terminateWithStatus: 1]; } resolver = [OFDNSResolver resolver]; if (arguments.count >= 2) | | < | | | | > | | 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 | [OFApplication programName]]; [OFApplication terminateWithStatus: 1]; } resolver = [OFDNSResolver resolver]; if (arguments.count >= 2) recordType = of_dns_record_type_parse( [arguments objectAtIndex: 1]); if (arguments.count >= 3) DNSClass = of_dns_class_parse([arguments objectAtIndex: 2]); if (arguments.count >= 4) { resolver.configReloadInterval = 0; resolver.nameServers = [arguments objectsInRange: of_range(3, 1)]; } query = [OFDNSQuery queryWithDomainName: [arguments objectAtIndex: 0] DNSClass: DNSClass recordType: recordType]; [resolver asyncPerformQuery: query delegate: self]; } @end |
Modified utils/ofhttp/OFHTTP.m from [03652a6d82] to [749d02c708].
︙ | ︙ | |||
613 614 615 616 617 618 619 | request: (OFHTTPRequest *)request { if ([e isKindOfClass: [OFResolveHostFailedException class]]) { if (!_quiet) [of_stdout writeString: @"\n"]; [of_stderr writeLine: | | | 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 | request: (OFHTTPRequest *)request { if ([e isKindOfClass: [OFResolveHostFailedException class]]) { if (!_quiet) [of_stdout writeString: @"\n"]; [of_stderr writeLine: OF_LOCALIZED(@"download_resolve_host_failed", @"%[prog]: Failed to download <%[url]>!\n" @" Failed to resolve host: %[exception]", @"prog", [OFApplication programName], @"url", request.URL.string, @"exception", e)]; } else if ([e isKindOfClass: [OFConnectionFailedException class]]) { if (!_quiet) |
︙ | ︙ |
Modified utils/ofhttp/lang/de.json from [7ef06d4aaf] to [9e4f95f1d1].
︙ | ︙ | |||
34 35 36 37 38 39 40 | "%[prog]: -o / --output und -O / --detect-filename schließen sich ", "gegenseitig aus!" ], "output_only_with_one_url": [ "%[prog]: -o / --output kann nicht mit mehr als einer URL benutzt ", "werden!" ], | | | | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | "%[prog]: -o / --output und -O / --detect-filename schließen sich ", "gegenseitig aus!" ], "output_only_with_one_url": [ "%[prog]: -o / --output kann nicht mit mehr als einer URL benutzt ", "werden!" ], "download_resolve_host_failed": [ "%[prog]: Fehler beim Download von <%[url]>!\n", " Host auflösen fehlgeschlagen: %[exception]" ], "download_failed_connection_failed": [ "%[prog]: Fehler beim Download von <%[url]>!\n", " Verbindung fehlgeschlagen: %[exception]" ], "download_failed_invalid_server_reply": [ "%[prog]: Fehler beim Download von <%[url]>!\n", |
︙ | ︙ |