Index: .fossil-settings/clean-glob
==================================================================
--- .fossil-settings/clean-glob
+++ .fossil-settings/clean-glob
@@ -37,11 +37,10 @@
tests/EBOOT.PBP
tests/Info.plist
tests/PARAM.SFO
tests/objc_sync/objc_sync
tests/plugin/Info.plist
-tests/serialization_xml.m
tests/terminal/terminal_tests
tests/testfile_bin.m
tests/testfile_ini.m
tests/tests
tests/tests.3dsx
Index: .fossil-settings/ignore-glob
==================================================================
--- .fossil-settings/ignore-glob
+++ .fossil-settings/ignore-glob
@@ -42,11 +42,10 @@
tests/iOS.xcodeproj/*.pbxuser
tests/iOS.xcodeproj/project.xcworkspace
tests/iOS.xcodeproj/xcuserdata
tests/objc_sync/objc_sync
tests/plugin/Info.plist
-tests/serialization_xml.m
tests/terminal/terminal_tests
tests/testfile_bin.m
tests/testfile_ini.m
tests/tests
tests/tests.3dsx
Index: .github/workflows/amiga-gcc.yml
==================================================================
--- .github/workflows/amiga-gcc.yml
+++ .github/workflows/amiga-gcc.yml
@@ -1,37 +1,16 @@
name: amiga-gcc
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
- strategy:
- matrix:
- configure_flags:
- -
- - --disable-amiga-lib
+ container: amigadev/crosstools:m68k-amigaos
steps:
- - name: Install dependencies
- run: docker pull amigadev/crosstools:m68k-amigaos
- uses: actions/checkout@v2
- name: autogen.sh
run: ./autogen.sh
- name: configure
- run: |
- docker run \
- -e PATH="/opt/m68k-amigaos/bin:$PATH" \
- -v "$PWD:/objfw" \
- amigadev/crosstools:m68k-amigaos \
- sh -c 'cd /objfw && ./configure --host=m68k-amigaos ${{ matrix.configure_flags }}'
+ run: ./configure --host=m68k-amigaos
- name: make
- run: |
- docker run \
- -e PATH="/opt/m68k-amigaos/bin:$PATH" \
- -v "$PWD:/objfw" \
- amigadev/crosstools:m68k-amigaos \
- sh -c "cd /objfw && make -j$(nproc)"
+ run: make -j$(nproc)
- name: make install
- run: |
- docker run \
- -e PATH="/opt/m68k-amigaos/bin:$PATH" \
- -v "$PWD:/objfw" \
- amigadev/crosstools:m68k-amigaos \
- sh -c "cd /objfw && make -j$(nproc)"
+ run: make install
ADDED .github/workflows/dragonflybsd.yml
Index: .github/workflows/dragonflybsd.yml
==================================================================
--- .github/workflows/dragonflybsd.yml
+++ .github/workflows/dragonflybsd.yml
@@ -0,0 +1,25 @@
+name: dragonflybsd
+on: [push, pull_request]
+jobs:
+ tests:
+ runs-on: macos-12
+ strategy:
+ matrix:
+ configure_flags:
+ -
+ - --disable-shared
+ - --with-tls=gnutls
+ steps:
+ - uses: actions/checkout@v3
+ - uses: vmactions/dragonflybsd-vm@v0
+ with:
+ usesh: true
+ copyback: false
+ prepare: |
+ pkg install -y autoconf automake gnutls llvm pkgconf
+ run: |
+ ./autogen.sh
+ ./configure OBJC=clang ${{ matrix.configure_flags }}
+ make -j4
+ make check
+ make install
ADDED .github/workflows/freebsd.yml
Index: .github/workflows/freebsd.yml
==================================================================
--- .github/workflows/freebsd.yml
+++ .github/workflows/freebsd.yml
@@ -0,0 +1,25 @@
+name: freebsd
+on: [push, pull_request]
+jobs:
+ tests:
+ runs-on: macos-12
+ strategy:
+ matrix:
+ configure_flags:
+ -
+ - --disable-shared
+ - --with-tls=gnutls
+ steps:
+ - uses: actions/checkout@v3
+ - uses: vmactions/freebsd-vm@v0
+ with:
+ usesh: true
+ copyback: false
+ prepare: |
+ pkg install -y autoconf automake gnutls pkgconf
+ run: |
+ ./autogen.sh
+ ./configure OBJC=clang ${{ matrix.configure_flags }}
+ make -j4
+ make check
+ make install
Index: .github/workflows/morphos.yml
==================================================================
--- .github/workflows/morphos.yml
+++ .github/workflows/morphos.yml
@@ -1,37 +1,16 @@
name: morphos
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
- strategy:
- matrix:
- configure_flags:
- -
- - --disable-amiga-lib
+ container: amigadev/crosstools:ppc-morphos
steps:
- - name: Install dependencies
- run: docker pull amigadev/crosstools:ppc-morphos
- uses: actions/checkout@v2
- name: autogen.sh
run: ./autogen.sh
- name: configure
- run: |
- docker run \
- -e PATH="/opt/ppc-morphos/bin:$PATH" \
- -v "$PWD:/objfw" \
- amigadev/crosstools:ppc-morphos \
- sh -c 'cd /objfw && ./configure --host=ppc-morphos ${{ matrix.configure_flags }}'
+ run: ./configure --host=ppc-morphos
- name: make
- run: |
- docker run \
- -e PATH="/opt/ppc-morphos/bin:$PATH" \
- -v "$PWD:/objfw" \
- amigadev/crosstools:ppc-morphos \
- sh -c "cd /objfw && make -j$(nproc)"
+ run: make -j$(nproc)
- name: make install
- run: |
- docker run \
- -e PATH="/opt/ppc-morphos/bin:$PATH" \
- -v "$PWD:/objfw" \
- amigadev/crosstools:ppc-morphos \
- sh -c "cd /objfw && make -j$(nproc)"
+ run: make install
ADDED .github/workflows/netbsd-gcc.yml
Index: .github/workflows/netbsd-gcc.yml
==================================================================
--- .github/workflows/netbsd-gcc.yml
+++ .github/workflows/netbsd-gcc.yml
@@ -0,0 +1,25 @@
+name: netbsd-gcc
+on: [push, pull_request]
+jobs:
+ tests:
+ runs-on: macos-12
+ strategy:
+ matrix:
+ configure_flags:
+ -
+ - --disable-shared
+ - --with-tls=gnutls
+ steps:
+ - uses: actions/checkout@v3
+ - uses: vmactions/netbsd-vm@v0
+ with:
+ usesh: true
+ copyback: false
+ prepare: |
+ pkg_add autoconf automake gnutls pkgconf
+ run: |
+ ./autogen.sh
+ ./configure OBJC=gcc ${{ matrix.configure_flags }}
+ make -j4
+ make check
+ make install
ADDED .github/workflows/netbsd.yml
Index: .github/workflows/netbsd.yml
==================================================================
--- .github/workflows/netbsd.yml
+++ .github/workflows/netbsd.yml
@@ -0,0 +1,25 @@
+name: netbsd
+on: [push, pull_request]
+jobs:
+ tests:
+ runs-on: macos-12
+ strategy:
+ matrix:
+ configure_flags:
+ -
+ - --disable-shared
+ - --with-tls=gnutls
+ steps:
+ - uses: actions/checkout@v3
+ - uses: vmactions/netbsd-vm@v0
+ with:
+ usesh: true
+ copyback: false
+ prepare: |
+ pkg_add autoconf automake clang gnutls pkgconf
+ run: |
+ ./autogen.sh
+ ./configure OBJC=clang ${{ matrix.configure_flags }}
+ make -j4
+ make check
+ make install
Index: .github/workflows/nintendo-3ds.yml
==================================================================
--- .github/workflows/nintendo-3ds.yml
+++ .github/workflows/nintendo-3ds.yml
@@ -30,6 +30,6 @@
docker run \
-e DEVKITPRO=/opt/devkitpro \
-e PATH="/opt/devkitpro/devkitARM/bin:$PATH" \
-v "$PWD:/objfw" \
devkitpro/devkitarm \
- sh -c "cd /objfw && make -j$(nproc)"
+ sh -c "cd /objfw && make install"
Index: .github/workflows/nintendo-ds.yml
==================================================================
--- .github/workflows/nintendo-ds.yml
+++ .github/workflows/nintendo-ds.yml
@@ -30,6 +30,6 @@
docker run \
-e DEVKITPRO=/opt/devkitpro \
-e PATH="/opt/devkitpro/devkitARM/bin:$PATH" \
-v "$PWD:/objfw" \
devkitpro/devkitarm \
- sh -c "cd /objfw && make -j$(nproc)"
+ sh -c "cd /objfw && make install"
Index: .github/workflows/nintendo-switch.yml
==================================================================
--- .github/workflows/nintendo-switch.yml
+++ .github/workflows/nintendo-switch.yml
@@ -30,6 +30,6 @@
docker run \
-e DEVKITPRO=/opt/devkitpro \
-e PATH="/opt/devkitpro/devkitA64/bin:$PATH" \
-v "$PWD:/objfw" \
devkitpro/devkita64 \
- sh -c "cd /objfw && make -j$(nproc)"
+ sh -c "cd /objfw && make install"
ADDED .github/workflows/openbsd.yml
Index: .github/workflows/openbsd.yml
==================================================================
--- .github/workflows/openbsd.yml
+++ .github/workflows/openbsd.yml
@@ -0,0 +1,25 @@
+name: openbsd
+on: [push, pull_request]
+jobs:
+ tests:
+ runs-on: macos-12
+ strategy:
+ matrix:
+ configure_flags:
+ -
+ - --disable-shared
+ - --with-tls=gnutls
+ steps:
+ - uses: actions/checkout@v3
+ - uses: vmactions/openbsd-vm@v0
+ with:
+ usesh: true
+ copyback: false
+ prepare: |
+ pkg_add autoconf-2.71 automake-1.16.5 gnutls pkgconf
+ run: |
+ ./autogen.sh
+ ./configure OBJC=clang ${{ matrix.configure_flags }}
+ make -j4
+ make check
+ make install
Index: .github/workflows/wii-u.yml
==================================================================
--- .github/workflows/wii-u.yml
+++ .github/workflows/wii-u.yml
@@ -30,6 +30,6 @@
docker run \
-e DEVKITPRO=/opt/devkitpro \
-e PATH="/opt/devkitpro/devkitPPC/bin:$PATH" \
-v "$PWD:/objfw" \
devkitpro/devkitppc \
- sh -c "cd /objfw && make -j$(nproc)"
+ sh -c "cd /objfw && make install"
Index: .github/workflows/wii.yml
==================================================================
--- .github/workflows/wii.yml
+++ .github/workflows/wii.yml
@@ -30,6 +30,6 @@
docker run \
-e DEVKITPRO=/opt/devkitpro \
-e PATH="/opt/devkitpro/devkitPPC/bin:$PATH" \
-v "$PWD:/objfw" \
devkitpro/devkitppc \
- sh -c "cd /objfw && make -j$(nproc)"
+ sh -c "cd /objfw && make install"
Index: .gitignore
==================================================================
--- .gitignore
+++ .gitignore
@@ -42,11 +42,10 @@
tests/iOS.xcodeproj/*.pbxuser
tests/iOS.xcodeproj/project.xcworkspace
tests/iOS.xcodeproj/xcuserdata
tests/objc_sync/objc_sync
tests/plugin/Info.plist
-tests/serialization_xml.m
tests/terminal/terminal_tests
tests/testfile_bin.m
tests/testfile_ini.m
tests/tests
tests/tests.3dsx
Index: Doxyfile
==================================================================
--- Doxyfile
+++ Doxyfile
@@ -6,37 +6,45 @@
HAVE_DOT = NO
GENERATE_LATEX = NO
HIDE_UNDOC_CLASSES = YES
HIDE_UNDOC_MEMBERS = YES
TYPEDEF_HIDES_STRUCT = YES
-PREDEFINED = __OBJC__ \
- _Nonnull= \
- _Nullable= \
- DOXYGEN \
- OF_BOXABLE= \
- OF_CONSUMED= \
- OF_DESIGNATED_INITIALIZER= \
- OF_GENERIC(...)= \
- OF_HAVE_BLOCKS \
- OF_HAVE_FILES \
- OF_HAVE_SANDBOX \
- OF_HAVE_SOCKETS \
- OF_HAVE_THREADS \
- OF_KINDOF(...)= \
- OF_NO_RETURN= \
- OF_NO_RETURN_FUNC= \
- OF_NULLABLE_PROPERTY(...)= \
- OF_NULL_RESETTABLE_PROPERTY(...)= \
- OF_REQUIRES_SUPER= \
- OF_RETURNS_INNER_POINTER= \
- OF_RETURNS_NOT_RETAINED= \
- OF_RETURNS_RETAINED= \
- OF_ROOT_CLASS= \
- OF_SENTINEL= \
- OF_WARN_UNUSED_RESULT= \
- OF_WEAK_UNAVAILABLE= \
- SIGHUP \
- SIGUSR1 \
+PREDEFINED = __OBJC__ \
+ _Nonnull= \
+ _Nullable= \
+ DOXYGEN \
+ OF_BOXABLE= \
+ OF_CONSUMED= \
+ OF_DESIGNATED_INITIALIZER= \
+ OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES \
+ OF_FILE_MANAGER_SUPPORTS_LINKS \
+ OF_FILE_MANAGER_SUPPORTS_OWNER \
+ OF_FILE_MANAGER_SUPPORTS_PERMISSIONS \
+ OF_FILE_MANAGER_SUPPORTS_SYMLINKS \
+ OF_GENERIC(...)= \
+ OF_HAVE_APPLETALK \
+ OF_HAVE_BLOCKS \
+ OF_HAVE_FILES \
+ OF_HAVE_IPV6 \
+ OF_HAVE_IPX \
+ OF_HAVE_SANDBOX \
+ OF_HAVE_SOCKETS \
+ OF_HAVE_THREADS \
+ OF_KINDOF(...)= \
+ OF_NO_RETURN= \
+ OF_NO_RETURN_FUNC= \
+ OF_NULLABLE_PROPERTY(...)= \
+ OF_NULL_RESETTABLE_PROPERTY(...)= \
+ OF_REQUIRES_SUPER= \
+ OF_RETURNS_INNER_POINTER= \
+ OF_RETURNS_NOT_RETAINED= \
+ OF_RETURNS_RETAINED= \
+ OF_ROOT_CLASS= \
+ OF_SENTINEL= \
+ OF_WARN_UNUSED_RESULT= \
+ OF_WEAK_UNAVAILABLE= \
+ SIGHUP \
+ SIGUSR1 \
SIGUSR2
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = YES
IGNORE_PREFIX = OF of_
Index: Makefile
==================================================================
--- Makefile
+++ Makefile
@@ -10,11 +10,11 @@
config.status \
extra.mk
include buildsys.mk
-.PHONY: docs release
+.PHONY: check docs release
utils tests: src
check: tests
cd tests && ${MAKE} -s run
Index: PLATFORMS.md
==================================================================
--- PLATFORMS.md
+++ PLATFORMS.md
@@ -43,23 +43,34 @@
DragonFlyBSD
------------
* OS Versions: 3.0, 3.3-DEVELOPMENT
- * Architectures: x86, x86_64
+ * Architectures: AMD64, x86
* Compilers: GCC 4.4.7
* Runtimes: ObjFW
FreeBSD
-------
* OS Versions: 9.1-rc3, 10.0
- * Architectures: x86_64
+ * Architectures: AMD64
* Compilers: Clang 3.1, Clang 3.3
* Runtimes: ObjFW
+
+GNU/Hurd
+--------
+
+ * OS Versions: 0.9
+ * Architectures: i686
+ * Compilers: Clang 14.0.6
+ * Runtimes: ObjFW
+ * Limitations: No support for UNIX sockets (`AF_UNIX` with `SOCK_DGRAM` is
+ currently broken in Hurd)
+
Haiku
-----
* OS version: r1-alpha4
@@ -88,22 +99,22 @@
Linux
-----
- * Architectures: Alpha, ARMv6, ARMv7, ARM64, Itanium, m68k, MIPS (O32),
- MIPS64 (N64), RISC-V 64, PowerPC, S390x, SuperH-4, x86,
- x86_64
+ * Architectures: Alpha, AMD64, ARMv6, ARMv7, ARM64, Itanium, m68k, MIPS (O32),
+ MIPS64 (N64), RISC-V 64, PowerPC, S390x, SuperH-4, x86
* Compilers: Clang 3.0-10.0, GCC 4.6-10.0
+ * C libraries: glibc, musl
* Runtimes: ObjFW
macOS
-----
* OS Versions: 10.5, 10.7-10.15, Darling
- * Architectures: PowerPC, PowerPC64, x86, x86_64
+ * Architectures: AMD64, PowerPC, PowerPC64, x86
* Compilers: Clang 3.1-10.0, Apple GCC 4.0.1 & 4.2.1
* Runtimes: Apple, ObjFW
MiNT
@@ -127,12 +138,12 @@
NetBSD
------
* OS Versions: 5.1-9.0
- * Architectures: ARM, ARM (big endian, BE8 mode), MIPS (O32), PowerPC, SPARC,
- SPARC64, x86, x86_64
+ * Architectures: AMD64, ARM, ARM (big endian, BE8 mode), MIPS (O32), PowerPC,
+ SPARC, SPARC64, x86
* Compilers: Clang 3.0-3.2, GCC 4.1.3 & 4.5.3 & 7.4.0
* Runtimes: ObjFW
Nintendo 3DS
@@ -167,11 +178,11 @@
OpenBSD
-------
* OS Versions: 5.2-6.7
- * Architectures: MIPS64, PA-RISC, PowerPC, SPARC64, x86_64
+ * Architectures: AMD64, MIPS64, PA-RISC, PowerPC, SPARC64
* Compilers: GCC 6.3.0, Clang 4.0
* Runtimes: ObjFW
PlayStation Portable
@@ -194,13 +205,13 @@
Solaris
-------
- * OS Versions: OpenIndiana 2015.03
- * Architectures: x86, x86_64
- * Compilers: Clang 3.4.2, GCC 4.8.3
+ * OS Versions: OpenIndiana 2015.03, OpenIndiana 2023.04, Oracle Solaris 11.4
+ * Architectures: AMD64, x86
+ * Compilers: Clang 3.4.2, Clang 11.0.0, Clang 13.0.1, GCC 4.8.3, GCC 10.4.0
* Runtimes: ObjFW
Wii
---
@@ -226,14 +237,14 @@
Windows
-------
* OS Versions: 98 SE, NT 4.0, XP (x86), 7 (x64), 8 (x64), 8.1 (x64), 10, 11,
Wine (x86 & x64)
- * Architectures: x86, x86_64, AArch64
- * Compilers: GCC 5.3.0 & 6.2.0 from msys2 (x86 & x64),
+ * Architectures: AArch64, AMD64, x86
+ * Compilers: GCC 5.3.0 & 6.2.0 from msys2 (AMD64 & x86),
Clang 3.9.0 from msys2 (x86),
- Clang 10.0 from msys2 (x86 & x86_64),
+ Clang 10.0 from msys2 (AMD64 & x86),
Clang 14.0.4 from msys2 (AArch64)
* Runtimes: ObjFW
Others
@@ -254,16 +265,16 @@
As forwarding needs hand-written assembly for each combination of CPU
architecture, executable format and calling convention, it is only available
for the following platforms (except resolveClassMethod: and
resolveInstanceMethod:, which are always available):
+ * AMD64 (SysV/ELF, Apple/Mach-O, Mach-O, Win64/PE)
* ARM (EABI/ELF, Apple/Mach-O)
* ARM64 (ARM64/ELF, Apple/Mach-O)
* MIPS (O32/ELF, EABI/ELF)
* PowerPC (SysV/ELF, EABI/ELF, Apple/Mach-O)
* SPARC (SysV/ELF)
* SPARC64 (SysV/ELF)
* x86 (SysV/ELF, Apple/Mach-O, Win32/PE)
- * x86_64 (SysV/ELF, Apple/Mach-O, Mach-O, Win64/PE)
Apple/Mach-O means both, the Apple ABI and runtime, while Mach-O means the
ObjFW runtime on Mach-O.
Index: README.md
==================================================================
--- README.md
+++ README.md
@@ -167,24 +167,23 @@
regular instructions above.
To build for iOS, follow the regular instructions, but instead of
`./configure` do something like this:
- $ clang="clang -isysroot $(xcrun --sdk iphoneos --show-sdk-path)"
- $ export OBJC="$clang -arch armv7 -arch arm64"
- $ export OBJCPP="$clang -arch armv7 -E"
- $ export IPHONEOS_DEPLOYMENT_TARGET="9.0"
+ $ clang="xcrun --sdk iphoneos clang"
+ $ export OBJC="$clang -arch arm64e -arch arm64"
+ $ export OBJCPP="$clang -arch arm64e -E"
+ $ export IPHONEOS_DEPLOYMENT_TARGET="10.0"
$ ./configure --prefix=/usr/local/ios --host=arm64-apple-darwin
To build for the iOS simulator, follow the regular instructions, but instead
of `./configure` use something like this:
- $ clang="clang -isysroot $(xcrun --sdk iphonesimulator --show-sdk-path)"
- $ export OBJC="$clang -arch arm64 -arch x86_64"
- $ export OBJCPP="$clang -arch arm64 -E"
- $ export IPHONEOS_DEPLOYMENT_TARGET="9.0"
- $ ./configure --prefix=/usr/local/iossim --host=arm64-apple-darwin
+ $ clang="xcrun --sdk iphonesimulator clang"
+ $ export OBJC="$clang -arch $(uname -m)"
+ $ export IPHONEOS_DEPLOYMENT_TARGET="10.0"
+ $ ./configure --prefix=/usr/local/iossim --host=$(uname -m)-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`:
@@ -321,11 +320,11 @@
To create your first, empty application, you can use `objfw-new`:
$ objfw-new --app MyFirstApp
- This creates a file `MyFirstApp.m`. The `-[applicationDidFinishLaunching]`
+ This creates a file `MyFirstApp.m`. The `-[applicationDidFinishLaunching:]`
method is called as soon as ObjFW finished all initialization. Use this as
the entry point to your own code. For example, you could add the following
line there to create a "Hello World":
[OFStdOut writeLine: @"Hello World!"];
Index: autogen.sh
==================================================================
--- autogen.sh
+++ autogen.sh
@@ -1,11 +1,13 @@
#!/bin/sh
set -e
# Set a version for OpenBSD
-: ${AUTOCONF_VERSION:=2.69}
-: ${AUTOMAKE_VERSION:=1.16}
-export AUTOCONF_VERSION AUTOMAKE_VERSION
+if test x"$(uname -s)" = x"OpenBSD"; then
+ : ${AUTOCONF_VERSION:=2.71}
+ : ${AUTOMAKE_VERSION:=1.16}
+ export AUTOCONF_VERSION AUTOMAKE_VERSION
+fi
aclocal -I build-aux/m4
autoconf
autoheader
Index: build-aux/m4/buildsys.m4
==================================================================
--- build-aux/m4/buildsys.m4
+++ build-aux/m4/buildsys.m4
@@ -1,8 +1,8 @@
dnl
dnl Copyright (c) 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2016, 2017,
-dnl 2018, 2020, 2021
+dnl 2018, 2020, 2021, 2022, 2023
dnl Jonathan Schleifer
dnl
dnl https://fossil.nil.im/buildsys
dnl
dnl Permission to use, copy, modify, and/or distribute this software for any
@@ -146,10 +146,11 @@
host_is_ios="yes"
], [
host_is_ios="no"
])
AC_MSG_RESULT($host_is_ios)
+ AC_CHECK_TOOL(CODESIGN, codesign)
;;
esac
])
AC_DEFUN([BUILDSYS_PROG_IMPLIB], [
@@ -173,11 +174,11 @@
])
AC_DEFUN([BUILDSYS_SHARED_LIB], [
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([BUILDSYS_CHECK_IOS])
- AC_MSG_CHECKING(for shared library system)
+ AC_MSG_CHECKING(for shared library type)
case "$host" in
*-*-darwin*)
AC_MSG_RESULT(Darwin)
LIB_CFLAGS='-fPIC -DPIC'
@@ -186,22 +187,12 @@
LIB_PREFIX='lib'
LIB_SUFFIX='.dylib'
AS_IF([test x"$enable_rpath" != x"no"], [
LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
])
- PLUGIN_CFLAGS='-fPIC -DPIC'
- PLUGIN_LDFLAGS='-bundle ${PLUGIN_LDFLAGS_BUNDLE_LOADER}'
- PLUGIN_SUFFIX='.bundle'
- AS_IF([test x"$host_is_ios" = x"yes"], [
- LINK_PLUGIN='rm -fr $$out && ${MKDIR_P} $$out && if test -f Info.plist; then ${INSTALL} -m 644 Info.plist $$out/Info.plist; fi && ${LD} -o $$out/$${out%${PLUGIN_SUFFIX}} ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS} && ${CODESIGN} -fs ${CODESIGN_IDENTITY} --timestamp=none $$out'
- ], [
- LINK_PLUGIN='rm -fr $$out && ${MKDIR_P} $$out/Contents/MacOS && if test -f Info.plist; then ${INSTALL} -m 644 Info.plist $$out/Contents/Info.plist; fi && ${LD} -o $$out/Contents/MacOS/$${out%${PLUGIN_SUFFIX}} ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS} && ${CODESIGN} -fs ${CODESIGN_IDENTITY} --timestamp=none $$out'
- ])
INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib && ${LN_S} -f $${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.dylib && ${LN_S} -f $${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib ${DESTDIR}${libdir}/$$i'
UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.dylib ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib'
- INSTALL_PLUGIN='&& rm -fr ${DESTDIR}${plugindir}/$$i && cp -R $$i ${DESTDIR}${plugindir}/'
- UNINSTALL_PLUGIN='&& rm -fr ${DESTDIR}${plugindir}/$$i'
CLEAN_LIB=''
;;
*-*-mingw* | *-*-cygwin*)
AC_MSG_RESULT(MinGW / Cygwin)
LIB_CFLAGS=''
@@ -208,18 +199,12 @@
LIB_LDFLAGS='-shared -Wl,--export-all-symbols'
LIB_LDFLAGS_INSTALL_NAME=''
LIB_PREFIX=''
LIB_SUFFIX='${LIB_MAJOR}.dll'
LINK_LIB='&& rm -f lib$${out%${LIB_SUFFIX}}.dll.a && ${LN_S} $$out lib$${out%${LIB_SUFFIX}}.dll.a'
- PLUGIN_CFLAGS=''
- PLUGIN_LDFLAGS='-shared -Wl,--export-all-symbols'
- PLUGIN_SUFFIX='.dll'
- LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
INSTALL_LIB='&& ${MKDIR_P} ${DESTDIR}${bindir} && ${INSTALL} -m 755 $$i ${DESTDIR}${bindir}/$$i && ${INSTALL} -m 755 lib$${i%${LIB_SUFFIX}}.dll.a ${DESTDIR}${libdir}/lib$${i%${LIB_SUFFIX}}.dll.a'
UNINSTALL_LIB='&& rm -f ${DESTDIR}${bindir}/$$i ${DESTDIR}${libdir}/lib$${i%${LIB_SUFFIX}}.dll.a'
- INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i'
- UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i'
CLEAN_LIB='${SHARED_LIB}.a ${SHARED_LIB_NOINST}.a'
;;
*-*-openbsd* | *-*-mirbsd*)
AC_MSG_RESULT(OpenBSD)
LIB_CFLAGS='-fPIC -DPIC'
@@ -228,18 +213,12 @@
LIB_PREFIX='lib'
LIB_SUFFIX='.so.${LIB_MAJOR}.${LIB_MINOR}'
AS_IF([test x"$enable_rpath" != x"no"], [
LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
])
- PLUGIN_CFLAGS='-fPIC -DPIC'
- PLUGIN_LDFLAGS='-shared'
- PLUGIN_SUFFIX='.so'
- LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i'
UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i'
- INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i'
- UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i'
CLEAN_LIB=''
;;
*-*-solaris*)
AC_MSG_RESULT(Solaris)
LIB_CFLAGS='-fPIC -DPIC'
@@ -248,35 +227,23 @@
LIB_PREFIX='lib'
LIB_SUFFIX='.so'
AS_IF([test x"$enable_rpath" != x"no"], [
LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
])
- PLUGIN_CFLAGS='-fPIC -DPIC'
- PLUGIN_LDFLAGS='-shared'
- PLUGIN_SUFFIX='.so'
- LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR} && rm -f ${DESTDIR}${libdir}/$$i && ${LN_S} $$i.${LIB_MAJOR}.${LIB_MINOR} ${DESTDIR}${libdir}/$$i'
UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}'
- INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i'
- UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i'
CLEAN_LIB=''
;;
*-*-android*)
AC_MSG_RESULT(Android)
LIB_CFLAGS='-fPIC -DPIC'
LIB_LDFLAGS='-shared -Wl,-soname=$$out.${LIB_MAJOR}'
LIB_LDFLAGS_INSTALL_NAME=''
LIB_PREFIX='lib'
LIB_SUFFIX='.so'
- PLUGIN_CFLAGS='-fPIC -DPIC'
- PLUGIN_LDFLAGS='-shared'
- PLUGIN_SUFFIX='.so'
- LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.0 && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.0 ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.0 ${DESTDIR}${libdir}/$$i'
UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.0'
- INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i'
- UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i'
CLEAN_LIB=''
;;
hppa*-*-hpux*)
AC_MSG_RESULT([HP-UX (PA-RISC)])
LIB_CFLAGS='-fPIC -DPIC'
@@ -286,18 +253,12 @@
LIB_SUFFIX='.${LIB_MAJOR}'
LINK_LIB='&& rm -f $${out%%.*}.sl && ${LN_S} $$out $${out%%.*}.sl'
AS_IF([test x"$enable_rpath" != x"no"], [
LDFLAGS_RPATH='-Wl,+b,${libdir}'
])
- PLUGIN_CFLAGS='-fPIC -DPIC'
- PLUGIN_LDFLAGS='-shared'
- PLUGIN_SUFFIX='.sl'
- LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i && ${LN_S} -f $$i ${DESTDIR}${libdir}/$${i%%.*}.sl'
UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$${i%%.*}.sl'
- INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i'
- UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i'
CLEAN_LIB=''
;;
ia64*-*-hpux*)
AC_MSG_RESULT([HP-UX (Itanium)])
LIB_CFLAGS='-fPIC -DPIC'
@@ -307,18 +268,12 @@
LIB_SUFFIX='.${LIB_MAJOR}'
LINK_LIB='&& rm -f $${out%%.*}.so && ${LN_S} $$out $${out%%.*}.so'
AS_IF([test x"$enable_rpath" != x"no"], [
LDFLAGS_RPATH='-Wl,+b,${libdir}'
])
- PLUGIN_CFLAGS='-fPIC -DPIC'
- PLUGIN_LDFLAGS='-shared'
- PLUGIN_SUFFIX='.so'
- LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i && ${LN_S} -f $$i ${DESTDIR}${libdir}/$${i%%.*}.so'
UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$${i%%.*}.so'
- INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i'
- UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i'
CLEAN_LIB=''
;;
*)
AC_MSG_RESULT(ELF)
LIB_CFLAGS='-fPIC -DPIC'
@@ -327,18 +282,12 @@
LIB_PREFIX='lib'
LIB_SUFFIX='.so'
AS_IF([test x"$enable_rpath" != x"no"], [
LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
])
- PLUGIN_CFLAGS='-fPIC -DPIC'
- PLUGIN_LDFLAGS='-shared'
- PLUGIN_SUFFIX='.so'
- LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.0 && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.0 ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.0 ${DESTDIR}${libdir}/$$i'
UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.0'
- INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i'
- UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i'
CLEAN_LIB=''
;;
esac
AC_SUBST(LIB_CFLAGS)
@@ -346,28 +295,20 @@
AC_SUBST(LIB_LDFLAGS_INSTALL_NAME)
AC_SUBST(LIB_PREFIX)
AC_SUBST(LIB_SUFFIX)
AC_SUBST(LINK_LIB)
AC_SUBST(LDFLAGS_RPATH)
- AC_SUBST(PLUGIN_CFLAGS)
- AC_SUBST(PLUGIN_LDFLAGS)
- AC_SUBST(PLUGIN_SUFFIX)
- AC_SUBST(LINK_PLUGIN)
AC_SUBST(INSTALL_LIB)
AC_SUBST(UNINSTALL_LIB)
- AC_SUBST(INSTALL_PLUGIN)
- AC_SUBST(UNINSTALL_PLUGIN)
AC_SUBST(CLEAN_LIB)
])
AC_DEFUN([BUILDSYS_FRAMEWORK], [
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([BUILDSYS_CHECK_IOS])
AC_REQUIRE([BUILDSYS_SHARED_LIB])
- AC_CHECK_TOOL(CODESIGN, codesign)
-
case "$host_os" in
darwin*)
AS_IF([test x"$host_is_ios" = x"yes"], [
FRAMEWORK_LDFLAGS='-dynamiclib -current_version ${LIB_MAJOR}.${LIB_MINOR} -compatibility_version ${LIB_MAJOR}'
FRAMEWORK_LDFLAGS_INSTALL_NAME='-Wl,-install_name,@executable_path/Frameworks/$$out/$${out%.framework}'
@@ -382,5 +323,61 @@
$1
;;
esac
])
+
+AC_DEFUN([BUILDSYS_PLUGIN], [
+ AC_REQUIRE([AC_CANONICAL_HOST])
+ AC_REQUIRE([BUILDSYS_CHECK_IOS])
+ AC_MSG_CHECKING(for plugin type)
+
+ case "$host" in
+ *-*-darwin*)
+ AC_MSG_RESULT(Darwin)
+ PLUGIN_CFLAGS='-fPIC -DPIC'
+ PLUGIN_LDFLAGS='-bundle ${PLUGIN_LDFLAGS_BUNDLE_LOADER}'
+ PLUGIN_SUFFIX='.bundle'
+ AS_IF([test x"$host_is_ios" = x"yes"], [
+ LINK_PLUGIN='rm -fr $$out && ${MKDIR_P} $$out && if test -f Info.plist; then ${INSTALL} -m 644 Info.plist $$out/Info.plist; fi && ${LD} -o $$out/$${out%${PLUGIN_SUFFIX}} ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS} && ${CODESIGN} -fs ${CODESIGN_IDENTITY} --timestamp=none $$out'
+ ], [
+ LINK_PLUGIN='rm -fr $$out && ${MKDIR_P} $$out/Contents/MacOS && if test -f Info.plist; then ${INSTALL} -m 644 Info.plist $$out/Contents/Info.plist; fi && ${LD} -o $$out/Contents/MacOS/$${out%${PLUGIN_SUFFIX}} ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS} && ${CODESIGN} -fs ${CODESIGN_IDENTITY} --timestamp=none $$out'
+ ])
+ INSTALL_PLUGIN='&& rm -fr ${DESTDIR}${plugindir}/$$i && cp -R $$i ${DESTDIR}${plugindir}/'
+ UNINSTALL_PLUGIN='&& rm -fr ${DESTDIR}${plugindir}/$$i'
+ ;;
+ *-*-mingw* | *-*-cygwin*)
+ AC_MSG_RESULT(MinGW / Cygwin)
+ PLUGIN_CFLAGS=''
+ PLUGIN_LDFLAGS='-shared -Wl,--export-all-symbols'
+ PLUGIN_SUFFIX='.dll'
+ LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
+ INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i'
+ UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i'
+ ;;
+ hppa*-*-hpux*)
+ AC_MSG_RESULT([HP-UX (PA-RISC)])
+ PLUGIN_CFLAGS='-fPIC -DPIC'
+ PLUGIN_LDFLAGS='-shared'
+ PLUGIN_SUFFIX='.sl'
+ LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
+ INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i'
+ UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i'
+ ;;
+ *)
+ AC_MSG_RESULT(ELF)
+ PLUGIN_CFLAGS='-fPIC -DPIC'
+ PLUGIN_LDFLAGS='-shared'
+ PLUGIN_SUFFIX='.so'
+ LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}'
+ INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i'
+ UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i'
+ ;;
+ esac
+
+ AC_SUBST(PLUGIN_CFLAGS)
+ AC_SUBST(PLUGIN_LDFLAGS)
+ AC_SUBST(PLUGIN_SUFFIX)
+ AC_SUBST(LINK_PLUGIN)
+ AC_SUBST(INSTALL_PLUGIN)
+ AC_SUBST(UNINSTALL_PLUGIN)
+])
Index: buildsys.mk.in
==================================================================
--- buildsys.mk.in
+++ buildsys.mk.in
@@ -1,8 +1,8 @@
#
# Copyright (c) 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016,
-# 2017, 2018, 2020, 2021
+# 2017, 2018, 2020, 2021, 2022, 2023
# Jonathan Schleifer
#
# https://fossil.nil.im/buildsys
#
# Permission to use, copy, modify, and/or distribute this software for any
@@ -761,11 +761,11 @@
fi \
done
install-extra:
-uninstall: uninstall-extra
+uninstall:
for i in "" ${SUBDIRS} ${SUBDIRS_AFTER}; do \
test x"$$i" = x"" && continue; \
${DIR_ENTER}; \
${MAKE} -s uninstall || exit $$?; \
${DIR_LEAVE}; \
@@ -873,10 +873,12 @@
else \
${DELETE_FAILED}; \
fi \
fi \
done
+
+ ${MAKE} -s uninstall-extra
uninstall-extra:
clean:
for i in "" ${SUBDIRS} ${SUBDIRS_AFTER}; do \
Index: configure.ac
==================================================================
--- configure.ac
+++ configure.ac
@@ -1,6 +1,6 @@
-AC_INIT(ObjFW, 1.0dev, js@nil.im)
+AC_INIT(ObjFW, 1.0dev, js@nil.im, objfw, https://objfw.nil.im/)
AC_CONFIG_SRCDIR(src)
AC_CONFIG_AUX_DIR(build-aux)
AC_CONFIG_MACRO_DIR(build-aux/m4)
AC_DEFINE(OBJFW_VERSION_MAJOR, 1, [The major version of ObjFW])
@@ -44,22 +44,10 @@
LIBS="$LIBS -ldebug"
enable_files="yes" # Required for reading ENV:
enable_shared="no"
with_tls="no"
- supports_amiga_lib="yes"
-
- AS_IF([test x"$enable_amiga_lib" != x"no"], [
- AC_SUBST(OBJFWRT_AMIGA_LIB,
- ['objfwrt${OBJFWRT_LIB_MAJOR}.library'])
- dnl For 68000, GCC emits calls to helper functions that
- dnl do not work properly in a library.
- t="-mcpu=68020 -fbaserel -noixemul -ffreestanding"
- AC_SUBST(AMIGA_LIB_CFLAGS, $t)
- t="$t -resident -nostartfiles -nodefaultlibs -ldebug -lc"
- AC_SUBST(AMIGA_LIB_LDFLAGS, $t)
- ])
AC_SUBST(LIBBASES_M, libbases.m)
;;
powerpc-*-amigaos*)
CPPFLAGS="$CPPFLAGS -D__USE_INLINE__"
@@ -77,30 +65,20 @@
LDFLAGS="$LDFLAGS -noixemul"
LIBS="$LIBS -ldebug"
enable_files="yes" # Required for reading ENV:
enable_shared="no"
- supports_amiga_lib="yes"
-
- AS_IF([test x"$enable_amiga_lib" != x"no"], [
- AC_SUBST(OBJFWRT_AMIGA_LIB,
- ['objfwrt${OBJFW_LIB_MAJOR}ppc.library'])
- t="-mresident32 -ffreestanding -noixemul"
- AC_SUBST(AMIGA_LIB_CFLAGS, $t)
- t="-mresident32 -nostartfiles -nodefaultlibs -noixemul -ldebug"
- AC_SUBST(AMIGA_LIB_LDFLAGS, "$t -lc")
- ])
AC_SUBST(LIBBASES_M, libbases.m)
;;
*-msdosdjgpp*)
enable_shared="no"
enable_threads="no"
enable_sockets="no"
;;
*-*-mingw*)
- LDFLAGS="$LDFLAGS -Wl,--allow-multiple-definition -static-libgcc"
+ LDFLAGS="$LDFLAGS -Wl,--allow-multiple-definition"
LIBS="$LIBS -lversion"
AC_SUBST(USE_SRCS_WINDOWS, '${SRCS_WINDOWS}')
;;
*-psp-*)
@@ -141,10 +119,18 @@
*-*-mint*)
enable_shared="no"
enable_threads="no" # TODO
with_tls="no"
;;
+*-apple-macos*)
+ enable_shared="no"
+ enable_threads="no" # TODO
+ enable_sockets="no" # TODO
+
+ AC_DEFINE(OF_CLASSIC_MACOS, 1,
+ [Whether we are compiling for classic macOS])
+ ;;
esac
AS_IF([test x"$host_os" = x"msdosdjgpp" -a x"$build_os" = x"msdosdjgpp"], [
dnl Hack to make configure find these on DOS.
: ${AR:=ar.exe}
@@ -164,11 +150,10 @@
;;
esac
AC_PROG_OBJC($potential_compilers)
AC_PROG_OBJCPP
AC_PROG_LN_S
-AC_PROG_EGREP
BUILDSYS_CHECK_IOS
AC_ARG_WITH(wii,
AS_HELP_STRING([--with-wii], [build for Wii]))
@@ -409,11 +394,13 @@
AC_ARG_ENABLE(shared,
AS_HELP_STRING([--disable-shared], [do not build shared library]))
AS_IF([test x"$enable_shared" != x"no"], [
BUILDSYS_SHARED_LIB
- AC_SUBST(OBJFW_SHARED_LIB, "${LIB_PREFIX}objfw${LIB_SUFFIX}")
+ BUILDSYS_PLUGIN
+
+ AC_SUBST(OBJFW_SHARED_LIB, '${LIB_PREFIX}objfw${LIB_SUFFIX}')
AC_SUBST(EXCEPTIONS_LIB_A, "exceptions.lib.a")
AC_SUBST(FORWARDING_LIB_A, "forwarding.lib.a")
AC_SUBST(LOOKUP_ASM_LIB_A, "lookup-asm.lib.a")
BUILDSYS_FRAMEWORK([
@@ -433,22 +420,12 @@
TESTS_LIBS="\${RUNTIME_LIBS} $TESTS_LIBS"
TESTS_LIBS="-L../src/runtime -L../src/runtime/linklib $TESTS_LIBS"
TESTS_LIBS="-L../src -lobjfw $TESTS_LIBS"
])
-AC_ARG_ENABLE(amiga-lib,
- AS_HELP_STRING([--disable-amiga-lib], [do not build Amiga library]))
-AS_IF([test x"$supports_amiga_lib" != x"yes"], [enable_amiga_lib="no"])
-AS_IF([test x"$enable_amiga_lib" != x"no"], [
- AC_SUBST(OBJFW_STATIC_LIB, "libobjfw.a")
- AC_SUBST(EXCEPTIONS_A, "exceptions.a")
- AC_SUBST(FORWARDING_A, "forwarding.a")
- AC_SUBST(LOOKUP_ASM_AMIGALIB_A, "lookup-asm.amigalib.a")
-])
-
AC_ARG_ENABLE(static, AS_HELP_STRING([--enable-static], [build static library]))
-AS_IF([test x"$enable_shared" = x"no" -a x"$enable_amiga_lib" = x"no"], [
+AS_IF([test x"$enable_shared" = x"no"], [
enable_static="yes"
])
AS_IF([test x"$enable_static" = x"yes"], [
AC_SUBST(OBJFW_STATIC_LIB, "libobjfw.a")
AC_SUBST(EXCEPTIONS_A, "exceptions.a")
@@ -570,11 +547,11 @@
AC_SUBST(RUNTIME, "runtime")
AC_CONFIG_FILES(src/runtime/Info.plist)
AS_IF([test x"$enable_shared" != x"no"], [
AC_SUBST(OBJFWRT_SHARED_LIB,
- "${LIB_PREFIX}objfwrt${LIB_SUFFIX}")
+ '${LIB_PREFIX}objfwrt${LIB_SUFFIX}')
])
AS_IF([test x"$enable_static" = x"yes"], [
AC_SUBST(OBJFWRT_STATIC_LIB, "libobjfwrt.a")
])
@@ -582,22 +559,13 @@
AS_IF([test x"$build_framework" = x"yes"], [
AC_SUBST(OBJFWRT_FRAMEWORK, "ObjFWRT.framework")
AC_SUBST(RUNTIME_FRAMEWORK_LIBS, "-framework ObjFWRT")
])
- AS_IF([test x"$enable_amiga_lib" != x"no"], [
- AC_SUBST(RUNTIME_LIBS, "-lobjfwrt.library")
- AC_SUBST(LINKLIB, linklib)
- tmp="../src/runtime/linklib/libobjfwrt.library.a"
- AC_SUBST(LIBOBJFWRT_DEP, "$tmp")
- AC_SUBST(LIBOBJFWRT_DEP_LVL2, "../$tmp")
- ], [
- AC_SUBST(RUNTIME_LIBS, "-lobjfwrt")
- ])
-
- AS_IF([test x"$enable_shared" = x"no" \
- -a x"$enable_amiga_lib" = x"no"], [
+ AC_SUBST(RUNTIME_LIBS, "-lobjfwrt")
+
+ AS_IF([test x"$enable_shared" = x"no"], [
AC_SUBST(LIBOBJFWRT_DEP, "../src/runtime/libobjfwrt.a")
AC_SUBST(LIBOBJFWRT_DEP_LVL2, "../../src/runtime/libobjfwrt.a")
])
AS_IF([test x"$enable_seluid24" = x"yes"], [
@@ -1027,11 +995,29 @@
AC_DEFINE(OF_HAVE_SCHED_YIELD, 1,
[Whether we have sched_yield()])
])
AC_CHECK_FUNCS(pthread_attr_getschedpolicy)
- AC_CHECK_FUNCS(pthread_attr_setinheritsched)
+
+ old_OBJCFLAGS="$OBJCFLAGS"
+ OBJCFLAGS="$OBJCFLAGS -Werror"
+ AC_MSG_CHECKING(for pthread_attr_setinheritsched)
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+ #include
+ ], [
+ pthread_attr_setinheritsched(
+ (pthread_attr_t *)-1, 0);
+ ])
+ ], [
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_PTHREAD_ATTR_SETINHERITSCHED, 1,
+ [Whether we have pthread_attr_setinheritsched])
+ ], [
+ AC_MSG_RESULT(no)
+ ])
+ OBJCFLAGS="$old_OBJCFLAGS"
AC_CHECK_HEADERS(pthread_np.h, [], [], [#include ])
AC_CHECK_FUNCS(pthread_set_name_np pthread_setname_np, break)
;;
esac
@@ -1303,11 +1289,11 @@
AC_CHECK_FUNCS([fcntl nanosleep])
;;
esac
AC_CHECK_HEADERS(xlocale.h)
-AC_CHECK_FUNCS([strtod_l strtof_l asprintf_l])
+AC_CHECK_FUNCS([strtod_l strtof_l asprintf_l uselocale])
AS_IF([test x"$gnu_source" != x"yes" -a \( \
x"$ac_cv_func_strtod_l" = x"yes" -o x"$ac_cv_func_strtof_l" = x"yes" -o \
x"$ac_cv_func_asprintf_l" = x"yes" \)], [
AC_MSG_CHECKING(whether *_l functions need _GNU_SOURCE)
AC_COMPILE_IFELSE([
@@ -1389,27 +1375,47 @@
AC_CHECK_HEADER(sys/socket.h, [
AC_DEFINE(OF_HAVE_SYS_SOCKET_H, 1,
[Whether we have sys/socket.h])
])
+ AC_CHECK_TYPE([struct sockaddr_storage], [
+ AC_DEFINE(OF_HAVE_SOCKADDR_STORAGE, 1,
+ [Whether we have struct sockaddr_storage])
+ ], [], [
+ #ifdef OF_HAVE_SYS_TYPES_H
+ # include
+ #endif
+ #ifdef OF_HAVE_SYS_SOCKET_H
+ # include
+ #endif
+ #ifdef _WIN32
+ # include
+ #endif
+ ])
+
AC_CHECK_HEADER(netinet/in.h, [
AC_DEFINE(OF_HAVE_NETINET_IN_H, 1,
[Whether we have netinet/in.h])
])
AC_CHECK_HEADER(netinet/tcp.h, [
AC_DEFINE(OF_HAVE_NETINET_TCP_H, 1,
[Whether we have netinet/tcp.h])
])
AC_CHECK_HEADERS([arpa/inet.h netdb.h])
+ AC_CHECK_HEADERS([net/if.h net/if_arp.h net/if_dl.h net/if_types.h])
+ AC_CHECK_FUNCS([if_indextoname if_nametoindex])
+ AC_CHECK_TYPES([struct sockaddr_dl], [], [], [
+ #ifdef HAVAE_SYS_TYPES_H
+ # include
+ #endif
+ #ifdef HAVE_NET_IF_DL_H
+ # include
+ #endif
+ ])
AC_CHECK_HEADER(sys/un.h, [
AC_DEFINE(OF_HAVE_SYS_UN_H, 1, [Whether we have sys/un.h])
])
- AC_CHECK_HEADER(netipx/ipx.h, [
- AC_DEFINE(OF_HAVE_NETIPX_IPX_H, 1,
- [Whether we have netipx/ipx.h])
- ])
-
AC_CHECK_MEMBER([struct sockaddr_in6.sin6_addr], [
AC_EGREP_CPP(egrep_cpp_yes, [
#ifdef _WIN32
typedef int BOOL;
#endif
@@ -1469,10 +1475,25 @@
])
AC_CHECK_MEMBER(struct sockaddr_un.sun_path, [
AC_DEFINE(OF_HAVE_UNIX_SOCKETS, 1,
[Whether we have UNIX sockets])
AC_SUBST(USE_SRCS_UNIX_SOCKETS, '${SRCS_UNIX_SOCKETS}')
+
+ AC_CHECK_MEMBERS(struct sockaddr_un.sun_len, [], [], [
+ #ifdef OF_HAVE_SYS_TYPES_H
+ # include
+ #endif
+ #ifdef OF_HAVE_SYS_UN_H
+ # include
+ #endif
+ #ifdef _WIN32
+ # include
+ #endif
+ #ifdef HAVE_AFUNIX_H
+ # include
+ #endif
+ ])
], [], [
#ifdef OF_HAVE_SYS_TYPES_H
# include
#endif
#ifdef OF_HAVE_SYS_UN_H
@@ -1490,17 +1511,40 @@
#endif
#ifdef __MINT__
# error Gives invalid argument at runtime
#endif
+
+ #ifdef __gnu_hurd__
+ # error Empty sun_path in the source given by recvfrom()
+ #endif
])
+ AC_CHECK_HEADER(netipx/ipx.h, [
+ AC_DEFINE(OF_HAVE_NETIPX_IPX_H, 1,
+ [Whether we have netipx/ipx.h])
+ ])
AC_CHECK_MEMBER(struct sockaddr_ipx.sipx_network, [], [
- AC_CHECK_MEMBER(struct sockaddr_ipx.sa_netnum, [], [], [
+ AC_CHECK_MEMBER(struct sockaddr_ipx.sa_netnum, [], [
+ AC_CHECK_MEMBER(struct sockaddr_ipx.sipx_addr.x_port, [
+ ], [], [
+ #ifdef HAVE_SYS_TYPES_H
+ # include
+ #endif
+
+ #ifdef OF_HAVE_NETIPX_IPX_H
+ # include
+ #endif
+ ])
+ ], [
#ifdef _WIN32
typedef int BOOL;
#endif
+
+ #ifdef HAVE_SYS_TYPES_H
+ # include
+ #endif
#ifdef OF_HAVE_NETIPX_IPX_H
# include
#endif
@@ -1517,10 +1561,14 @@
])
], [
#ifdef _WIN32
typedef int BOOL;
#endif
+
+ #ifdef HAVE_SYS_TYPES_H
+ # include
+ #endif
#ifdef OF_HAVE_NETIPX_IPX_H
# include
#endif
@@ -1534,11 +1582,12 @@
# include
# include
#endif
])
AS_IF([test x"$ac_cv_member_struct_sockaddr_ipx_sipx_network" = x"yes" \
- -o x"$ac_cv_member_struct_sockaddr_ipx_sa_netnum" = x"yes"], [
+ -o x"$ac_cv_member_struct_sockaddr_ipx_sa_netnum" = x"yes" -o \
+ x"$ac_cv_member_struct_sockaddr_ipx_sipx_addr_x_port" = x"yes"], [
AC_EGREP_CPP(egrep_cpp_yes, [
#ifdef _WIN32
typedef int BOOL;
#endif
@@ -1563,10 +1612,101 @@
], [
AC_DEFINE(OF_HAVE_IPX, 1, [Whether we have IPX/SPX])
AC_SUBST(USE_SRCS_IPX, '${SRCS_IPX}')
])
])
+
+ AC_CHECK_HEADER(netat/appletalk.h, [
+ AC_DEFINE(OF_HAVE_NETAT_APPLETALK_H, 1,
+ [Whether we have netat/appletalk.h])
+ ])
+ AC_CHECK_HEADER(netatalk/at.h, [
+ AC_DEFINE(OF_HAVE_NETATALK_AT_H, 1,
+ [Whether we have netatalk/at.h])
+ ])
+ AC_CHECK_MEMBER(struct sockaddr_at.sat_addr, [], [
+ AC_CHECK_MEMBER(struct sockaddr_at.sat_net, [], [], [
+ #ifdef _WIN32
+ typedef int BOOL;
+ #endif
+
+ #ifdef OF_HAVE_SYS_TYPES_H
+ # include
+ #endif
+ #if defined(OF_HAVE_NETAT_APPLETALK_H)
+ # include
+ #elif defined(OF_HAVE_NETATALK_AT_H)
+ # include
+ #endif
+
+ #ifdef _WIN32
+ # ifdef __MINGW32__
+ # include <_mingw.h>
+ # ifdef __MINGW64_VERSION_MAJOR
+ # include
+ # endif
+ # endif
+ # include
+ # include
+ #endif
+ ])
+ ], [
+ #ifdef _WIN32
+ typedef int BOOL;
+ #endif
+
+ #ifdef OF_HAVE_SYS_TYPES_H
+ # include
+ #endif
+ #if defined(OF_HAVE_NETAT_APPLETALK_H)
+ # include
+ #elif defined(OF_HAVE_NETATALK_AT_H)
+ # include
+ #endif
+
+ #ifdef _WIN32
+ # ifdef __MINGW32__
+ # include <_mingw.h>
+ # ifdef __MINGW64_VERSION_MAJOR
+ # include
+ # endif
+ # endif
+ # include
+ # include
+ #endif
+ ])
+ AS_IF([test x"$ac_cv_member_struct_sockaddr_at_sat_addr" = x"yes" \
+ -o x"$ac_cv_member_struct_sockaddr_at_sat_net" = x"yes"], [
+ AC_EGREP_CPP(egrep_cpp_yes, [
+ #ifdef _WIN32
+ typedef int BOOL;
+ #endif
+
+ #ifdef OF_HAVE_SYS_SOCKET_H
+ # include
+ #endif
+
+ #ifdef _WIN32
+ # ifdef __MINGW32__
+ # include <_mingw.h>
+ # ifdef __MINGW64_VERSION_MAJOR
+ # include
+ # endif
+ # endif
+ # include
+ # include
+ #endif
+
+ #ifdef AF_APPLETALK
+ egrep_cpp_yes
+ #endif
+ ], [
+ AC_DEFINE(OF_HAVE_APPLETALK, 1,
+ [Whether we have AppleTalk])
+ AC_SUBST(USE_SRCS_APPLETALK, '${SRCS_APPLETALK}')
+ ])
+ ])
AC_CHECK_FUNCS(paccept accept4, break)
AC_CHECK_FUNCS(kqueue1 kqueue, [
AC_DEFINE(HAVE_KQUEUE, 1, [Whether we have kqueue])
@@ -1609,27 +1749,27 @@
"OFSelectKernelEventObserver.m")
])
;;
esac
+ AC_CHECK_HEADERS(net/if.h)
+ AC_CHECK_FUNCS(if_nameindex)
+
AC_ARG_WITH(tls,
AS_HELP_STRING([--with-tls], [
enable TLS support using the specified library
(yes, openssl, gnutls, securetransport or no)]))
AS_IF([test x"$with_tls" = x""], [with_tls="yes"])
tls_support="no"
AS_IF([test x"$with_tls" = x"securetransport" \
- -o x"$with_tls" = x"yes"], [
+ -o x"$with_tls" = x"yes"], [
AC_CHECK_HEADERS(Security/SecureTransport.h, [
old_LIBS="$LIBS"
LIBS="-framework Security -framework Foundation $LIBS"
AC_CHECK_FUNC(SSLHandshake, [
- AC_DEFINE(HAVE_SECURE_TRANSPORT, 1,
- [Whether we have Secure Transport])
-
tls_support="Secure Transport"
TLS_LIBS="-framework Foundation $TLS_LIBS"
TLS_LIBS="-framework Security $TLS_LIBS"
AC_SUBST(OF_SECURE_TRANSPORT_TLS_STREAM_M,
@@ -1639,13 +1779,28 @@
], [])
LIBS="$old_LIBS"
])
])
+
+ AS_IF([test x"$with_tls" = x"gnutls" \
+ -o \( x"$with_tls" = x"yes" -a x"$tls_support" = x"no" \)], [
+ PKG_CHECK_MODULES(gnutls, [gnutls >= 3.5.0], [
+ tls_support="GnuTLS"
+ TLS_CPPFLAGS="$gnutls_CFLAGS $TLS_CPPFLAGS"
+ TLS_LIBS="$gnutls_LIBS $TLS_LIBS"
+
+ AC_SUBST(OF_GNUTLS_TLS_STREAM_M, "OFGnuTLSTLSStream.m")
+ ], [
+ dnl Disable default action-if-not-found, which exits
+ dnl configure with an error.
+ :
+ ])
+ ])
AS_IF([test x"$with_tls" = x"openssl" \
- -o \( x"$with_tls" = x"yes" -a x"$tls_support" = x"no" \)], [
+ -o \( x"$with_tls" = x"yes" -a x"$tls_support" = x"no" \)], [
case "$host_os" in
morphos*)
ssl="ssl_shared"
crypto="crypto_shared"
;;
@@ -1655,39 +1810,19 @@
;;
esac
AC_CHECK_LIB($ssl, SSL_set1_host, [
AC_CHECK_HEADER(openssl/ssl.h, [
- AC_DEFINE(HAVE_OPENSSL, 1,
- [Whether we have OpenSSL])
-
tls_support="OpenSSL"
TLS_LIBS="-l$ssl -l$crypto $TLS_LIBS"
AC_SUBST(OF_OPENSSL_TLS_STREAM_M,
"OFOpenSSLTLSStream.m")
])
], [], [-l$crypto])
])
- AS_IF([test x"$with_tls" = x"gnutls" \
- -o \( x"$with_tls" = x"yes" -a x"$tls_support" = x"no" \)], [
- PKG_CHECK_MODULES(gnutls, [gnutls >= 3.5.0], [
- AC_DEFINE(HAVE_GNUTLS, 1, [Whether we have GnuTLS])
-
- tls_support="GnuTLS"
- TLS_CPPFLAGS="$gnutls_CFLAGS $TLS_CPPFLAGS"
- TLS_LIBS="$gnutls_LIBS $TLS_LIBS"
-
- AC_SUBST(OF_GNUTLS_TLS_STREAM_M, "OFGnuTLSTLSStream.m")
- ], [
- dnl Disable default action-if-not-found, which exits
- dnl configure with an error.
- :
- ])
- ])
-
AS_IF([test x"$tls_support" != x"no"], [
AC_SUBST(TLS, "tls")
AC_SUBST(TLS_CPPFLAGS)
AC_SUBST(TLS_LIBS)
AC_DEFINE(HAVE_TLS_SUPPORT, 1,
@@ -1696,11 +1831,11 @@
OFHTTP_LIBS="-lobjfwtls $TLS_LIBS $OFHTTP_LIBS"
AS_IF([test x"$enable_shared" != x"no"], [
AC_SUBST(OBJFWTLS_SHARED_LIB,
- "${LIB_PREFIX}objfwtls${LIB_SUFFIX}")
+ '${LIB_PREFIX}objfwtls${LIB_SUFFIX}')
])
AS_IF([test x"$enable_static" = x"yes" \
-o x"$enable_shared" = x"no"], [
AC_SUBST(OBJFWTLS_STATIC_LIB, "libobjfwtls.a")
])
@@ -1760,14 +1895,10 @@
(!defined(TARGET_OS_SIMULATOR) || !TARGET_OS_SIMULATOR)
egrep_cpp_yes
#endif
], [
AC_MSG_RESULT(yes)
- have_subprocesses="yes"
-
- AC_CHECK_FUNCS(posix_spawnp)
- AC_CHECK_HEADERS(spawn.h)
], [
AC_MSG_RESULT(no)
have_subprocesses="no"
])
;;
@@ -1775,21 +1906,22 @@
have_subprocesses="yes"
;;
msdosdjgpp*)
have_subprocesses="no"
;;
-*)
+esac
+AS_IF([test x"$have_subprocesses" = x""], [
AC_HEADER_SYS_WAIT
AC_CHECK_FUNCS(kill)
AC_CHECK_FUNCS(posix_spawnp, [
AS_IF([test x"$ac_cv_func_kill" = x"yes"], [
- have_subprocesses="yes"
-
- AC_CHECK_HEADERS(spawn.h)
+ AC_CHECK_HEADERS(spawn.h, [have_subprocesses="yes"])
])
- ], [
+ ])
+
+ AS_IF([test x"$have_subprocesses" = x""], [
AC_CHECK_FUNCS([vfork dup2 execvp _exit], [
AS_IF([test x"$ac_cv_func_vfork" = x"yes" \
-a x"$ac_cv_func_pipe" = x"yes" \
-a x"$ac_cv_func_dup2" = x"yes" \
-a x"$ac_cv_func_execvp" = x"yes" \
@@ -1799,19 +1931,18 @@
])
], [
break
])
])
- ;;
-esac
+])
AS_IF([test x"$have_subprocesses" = x"yes"], [
AC_SUBST(OF_SUBPROCESS_M, "OFSubprocess.m")
AC_DEFINE(OF_HAVE_SUBPROCESSES, 1, [Whether we have subprocesses])
])
AC_CHECK_HEADERS_ONCE([complex.h sys/ioctl.h sys/ttycom.h])
-AC_CHECK_FUNCS(isatty)
+AC_CHECK_FUNCS(ioctl isatty)
AC_CHECK_FUNC(pledge, [
AC_DEFINE(OF_HAVE_PLEDGE, 1, [Whether we have pledge()])
])
@@ -1820,11 +1951,11 @@
AC_SUBST(BRIDGE, "bridge")
AC_CONFIG_FILES(src/bridge/Info.plist)
AS_IF([test x"$enable_shared" != x"no"], [
AC_SUBST(OBJFWBRIDGE_SHARED_LIB,
- "${LIB_PREFIX}objfwbridge${LIB_SUFFIX}")
+ '${LIB_PREFIX}objfwbridge${LIB_SUFFIX}')
])
AS_IF([test x"$enable_static" = x"yes" \
-o x"$enable_shared" = x"no"], [
AC_SUBST(OBJFWBRIDGE_STATIC_LIB, "libobjfwbridge.a")
])
@@ -1854,11 +1985,17 @@
AC_MSG_RESULT(no)
OBJCFLAGS="$old_OBJCFLAGS"
])
AS_IF([test x"$GOBJC" = x"yes"], [
- OBJCFLAGS="$OBJCFLAGS -Wwrite-strings -Wpointer-arith -Werror"
+ OBJCFLAGS="$OBJCFLAGS -Wwrite-strings -Wpointer-arith"
+
+ AC_ARG_ENABLE(werror,
+ AS_HELP_STRING([--disable-werror], [do not build with -Werror]))
+ AS_IF([test x"$enable_werror" != x"no"], [
+ OBJCFLAGS="$OBJCFLAGS -Werror"
+ ])
AC_MSG_CHECKING(whether we need -Wno-strict-aliasing due to GCC bugs)
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
#ifdef __has_attribute
@@ -1999,11 +2136,12 @@
# define OF_DEALLOC_UNSUPPORTED \
[self doesNotRecognizeSelector: _cmd]; \
\
abort(); \
\
- _Pragma("clang diagnostic push ignore \
+ _Pragma("clang diagnostic push"); \
+ _Pragma("clang diagnostic ignored \
\"-Wunreachable-code\""); \
[super dealloc]; \
_Pragma("clang diagnostic pop");
#else
# define OF_DEALLOC_UNSUPPORTED \
@@ -2097,10 +2235,24 @@
], [
AC_MSG_RESULT(yes)
OBJCFLAGS="$old_OBJCFLAGS"
])
])
+
+ AC_MSG_CHECKING(whether we need -Wno-strict-prototypes)
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+ #include
+ ], [
+ signal(SIGINT, SIG_DFL);
+ ])
+ ], [
+ AC_MSG_RESULT(no)
+ ], [
+ AC_MSG_RESULT(yes)
+ OBJCFLAGS="$OBJCFLAGS -Wno-strict-prototypes"
+ ])
AS_IF([test x"$ac_cv_header_complex_h" = x"yes"], [
AC_MSG_CHECKING(whether we need -Wno-gnu-imaginary-constant)
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
@@ -2127,14 +2279,11 @@
;;
x86_64-*-mingw*)
AC_CHECK_PROG(WINE, wine64, wine64)
;;
esac
-
- AS_IF([test x"$WINE" != x""], [
- AC_SUBST(WRAPPER, "$WINE")
- ])
+ AS_IF([test x"$WINE" != x""], [AC_SUBST(WRAPPER, "$WINE")])
AS_IF([test x"$with_wii" = x"yes"], [
dnl Keep this lowercase, as WIILOAD is a variable used by
dnl wiiload and thus likely already set by the user to something
dnl that is not the path of the wiiload binary.
@@ -2144,21 +2293,10 @@
AC_SUBST(WRAPPER, "$wiiload")
])
])
])
-AC_ARG_WITH(fish_completions,
- AS_HELP_STRING([--with-fish-completions],
- [install completions for the fish shell]))
-AS_IF([test x"$with_fish_completions" = x""], [
- AC_CHECK_PROG(FISH, fish, fish)
- AS_IF([test x"$FISH" != x""], [with_fish_completions="yes"])
-])
-AS_IF([test x"$with_fish_completions" = x"yes"], [
- AC_SUBST(FISH_COMPLETIONS, fish)
-])
-
dnl We don't call AC_PROG_CPP, but only AC_PROG_OBJCPP and set CPP to OBJCPP
dnl and add OBJCPPFLAGS to CPPFLAGS, thus we need to AC_SUBST these ourself.
AC_SUBST(CPP)
AC_SUBST(CPPFLAGS)
dnl We use the ObjC compiler as our assembler
Index: extra.mk.in
==================================================================
--- extra.mk.in
+++ extra.mk.in
@@ -6,11 +6,10 @@
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 = 0
OBJFWRT_LIB_MINOR = 0
OBJFWRT_LIB_MAJOR_MINOR = ${OBJFWRT_LIB_MAJOR}.${OBJFWRT_LIB_MINOR}
OBJFWBRIDGE_SHARED_LIB = @OBJFWBRIDGE_SHARED_LIB@
@@ -27,21 +26,18 @@
ENCODINGS_A = @ENCODINGS_A@
ENCODINGS_LIB_A = @ENCODINGS_LIB_A@
ENCODINGS_SRCS = @ENCODINGS_SRCS@
EXCEPTIONS_A = @EXCEPTIONS_A@
EXCEPTIONS_LIB_A = @EXCEPTIONS_LIB_A@
-FISH_COMPLETIONS = @FISH_COMPLETIONS@
FORWARDING_A = @FORWARDING_A@
FORWARDING_LIB_A = @FORWARDING_LIB_A@
LIBBASES_M = @LIBBASES_M@
LIBOBJFWRT_DEP = @LIBOBJFWRT_DEP@
LIBOBJFWRT_DEP_LVL2 = @LIBOBJFWRT_DEP_LVL2@
LIBOBJFW_DEP = @LIBOBJFW_DEP@
LIBOBJFW_DEP_LVL2 = @LIBOBJFW_DEP_LVL2@
-LINKLIB = @LINKLIB@
LOOKUP_ASM_A = @LOOKUP_ASM_A@
-LOOKUP_ASM_AMIGALIB_A = @LOOKUP_ASM_AMIGALIB_A@
LOOKUP_ASM_LIB_A = @LOOKUP_ASM_LIB_A@
MAP_LDFLAGS = @MAP_LDFLAGS@
OBJC_SYNC = @OBJC_SYNC@
OBJFW_NEW = @OBJFW_NEW@
OFARC = @OFARC@
@@ -77,13 +73,14 @@
TLS = @TLS@
TLS_CPPFLAGS = @TLS_CPPFLAGS@
TLS_LIBS = @TLS_LIBS@
UNICODE_M = @UNICODE_M@
USE_INCLUDES_ATOMIC = @USE_INCLUDES_ATOMIC@
+USE_SRCS_APPLETALK = @USE_SRCS_APPLETALK@
USE_SRCS_FILES = @USE_SRCS_FILES@
USE_SRCS_IPX = @USE_SRCS_IPX@
USE_SRCS_PLUGINS = @USE_SRCS_PLUGINS@
USE_SRCS_SOCKETS = @USE_SRCS_SOCKETS@
USE_SRCS_THREADS = @USE_SRCS_THREADS@
USE_SRCS_UNIX_SOCKETS = @USE_SRCS_UNIX_SOCKETS@
USE_SRCS_WINDOWS = @USE_SRCS_WINDOWS@
WRAPPER = @WRAPPER@
DELETED generators/library/FuncArrayGenerator.h
Index: generators/library/FuncArrayGenerator.h
==================================================================
--- generators/library/FuncArrayGenerator.h
+++ generators/library/FuncArrayGenerator.h
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
- *
- * 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 "OFStream.h"
-#import "OFXMLElement.h"
-
-@interface FuncArrayGenerator: OFObject
-{
- OFXMLElement *_library;
- OFStream *_include;
-}
-
-- (instancetype)initWithLibrary: (OFXMLElement *)library
- include: (OFStream *)include;
-- (void)generate;
-@end
DELETED generators/library/FuncArrayGenerator.m
Index: generators/library/FuncArrayGenerator.m
==================================================================
--- generators/library/FuncArrayGenerator.m
+++ generators/library/FuncArrayGenerator.m
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
- *
- * 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 "OFArray.h"
-#import "OFXMLAttribute.h"
-
-#import "FuncArrayGenerator.h"
-
-#import "OFInvalidFormatException.h"
-#import "OFUnsupportedVersionException.h"
-
-#import "copyright.h"
-
-@implementation FuncArrayGenerator
-- (instancetype)initWithLibrary: (OFXMLElement *)library
- include: (OFStream *)include
-{
- self = [super init];
-
- @try {
- OFXMLAttribute *version;
-
- if (![library.name isEqual: @"amiga-library"] ||
- library.namespace != nil)
- @throw [OFInvalidFormatException exception];
-
- if ((version = [library attributeForName: @"version"]) == nil)
- @throw [OFInvalidFormatException exception];
-
- if (![version.stringValue isEqual: @"1.0"])
- @throw [OFUnsupportedVersionException
- exceptionWithVersion: version.stringValue];
-
- _library = [library retain];
- _include = [include retain];
- } @catch (id e) {
- [self release];
- @throw e;
- }
-
- return self;
-}
-
-- (void)dealloc
-{
- [_library release];
- [_include release];
-
- [super dealloc];
-}
-
-- (void)generate
-{
- [_include writeString: COPYRIGHT];
- [_include writeString:
- @"/* This file is automatically generated from amiga-library.xml */"
- @"\n\n"];
-
- for (OFXMLElement *function in [_library elementsForName: @"function"])
- [_include writeFormat:
- @"(CONST_APTR)glue_%@,\n",
- [function attributeForName: @"name"].stringValue];
-}
-@end
DELETED generators/library/GlueGenerator.h
Index: generators/library/GlueGenerator.h
==================================================================
--- generators/library/GlueGenerator.h
+++ generators/library/GlueGenerator.h
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
- *
- * 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 "OFStream.h"
-#import "OFXMLElement.h"
-
-@interface GlueGenerator: OFObject
-{
- OFXMLElement *_library;
- OFStream *_header, *_impl;
-}
-
-- (instancetype)initWithLibrary: (OFXMLElement *)library
- header: (OFStream *)header
- implementation: (OFStream *)implementation;
-- (void)generate;
-@end
DELETED generators/library/GlueGenerator.m
Index: generators/library/GlueGenerator.m
==================================================================
--- generators/library/GlueGenerator.m
+++ generators/library/GlueGenerator.m
@@ -1,207 +0,0 @@
-/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
- *
- * 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 "OFArray.h"
-#import "OFXMLAttribute.h"
-
-#import "GlueGenerator.h"
-
-#import "OFInvalidFormatException.h"
-#import "OFUnsupportedVersionException.h"
-
-#import "copyright.h"
-
-@implementation GlueGenerator
-- (instancetype)initWithLibrary: (OFXMLElement *)library
- header: (OFStream *)header
- implementation: (OFStream *)impl
-{
- self = [super init];
-
- @try {
- OFXMLAttribute *version;
-
- if (![library.name isEqual: @"amiga-library"] ||
- library.namespace != nil)
- @throw [OFInvalidFormatException exception];
-
- if ((version = [library attributeForName: @"version"]) == nil)
- @throw [OFInvalidFormatException exception];
-
- if (![version.stringValue isEqual: @"1.0"])
- @throw [OFUnsupportedVersionException
- exceptionWithVersion: version.stringValue];
-
- _library = [library retain];
- _header = [header retain];
- _impl = [impl retain];
- } @catch (id e) {
- [self release];
- @throw e;
- }
-
- return self;
-}
-
-- (void)dealloc
-{
- [_library release];
- [_header release];
- [_impl release];
-
- [super dealloc];
-}
-
-- (void)generate
-{
- [_header writeString: COPYRIGHT];
- [_impl writeString: COPYRIGHT];
-
- [_header writeString:
- @"/* This file is automatically generated from amiga-library.xml */"
- @"\n\n"];
-
- [_impl writeString:
- @"/* This file is automatically generated from amiga-library.xml */"
- @"\n\n"
- @"#include \"config.h\"\n"
- @"\n"
- @"#import \"amiga-glue.h\"\n"
- @"\n"];
-
- for (OFXMLElement *include in [_library elementsForName: @"include"])
- [_header writeFormat: @"#import \"%@\"\n", include.stringValue];
-
- [_header writeString:
- @"\n"
- @"#ifdef OF_AMIGAOS_M68K\n"
- @"# define PPC_PARAMS(...) (void)\n"
- @"# define M68K_ARG(type, name, reg)\t\t\\\n"
- @"\tregister type reg##name __asm__(#reg);\t\\\n"
- @"\ttype name = reg##name;\n"
- @"#else\n"
- @"# define PPC_PARAMS(...) (__VA_ARGS__)\n"
- @"# define M68K_ARG(...)\n"
- @"#endif\n"
- @"\n"];
- [_impl writeString:
- @"#ifdef OF_MORPHOS\n"
- @"/* All __saveds functions in this file need to use the SysV "
- @"ABI */\n"
- @"__asm__ (\n"
- @" \".section .text\\n\"\n"
- @" \".align 2\\n\"\n"
- @" \"__restore_r13:\\n\"\n"
- @" \"\tlwz\t%r13, 44(%r12)\\n\"\n"
- @" \"\tblr\\n\"\n"
- @");\n"
- @"#endif\n"];
-
- for (OFXMLElement *function in
- [_library elementsForName: @"function"]) {
- OFString *name =
- [function attributeForName: @"name"].stringValue;
- OFString *returnType =
- [function attributeForName: @"return-type"].stringValue;
- OFArray OF_GENERIC(OFXMLElement *) *arguments =
- [function elementsForName: @"argument"];
- size_t argumentIndex;
-
- if (returnType == nil)
- returnType = @"void";
-
- [_header writeFormat:
- @"extern %@%@glue_%@",
- returnType,
- (![returnType hasSuffix: @"*"] ? @" " : @""),
- name];
-
- [_impl writeFormat: @"\n"
- @"%@ __saveds\n"
- @"glue_%@",
- returnType, name];
-
- if (arguments.count > 0) {
- [_header writeString: @" PPC_PARAMS("];
- [_impl writeString: @" PPC_PARAMS("];
- } else {
- [_header writeString: @"(void"];
- [_impl writeString: @"(void"];
- }
-
- argumentIndex = 0;
- for (OFXMLElement *argument in arguments) {
- OFString *argName =
- [argument attributeForName: @"name"].stringValue;
- OFString *argType =
- [argument attributeForName: @"type"].stringValue;
-
- if (argumentIndex++ > 0) {
- [_header writeString: @", "];
- [_impl writeString: @", "];
- }
-
- [_header writeString: argType];
- [_impl writeString: argType];
- if (![argType hasSuffix: @"*"]) {
- [_header writeString: @" "];
- [_impl writeString: @" "];
- }
- [_header writeString: argName];
- [_impl writeString: argName];
- }
-
- [_header writeString: @");\n"];
-
- [_impl writeString: @")\n{\n"];
- for (OFXMLElement *argument in arguments) {
- OFString *argName =
- [argument attributeForName: @"name"].stringValue;
- OFString *argType =
- [argument attributeForName: @"type"].stringValue;
- OFString *m68kReg = [argument
- attributeForName: @"m68k-reg"].stringValue;
-
- [_impl writeFormat: @"\tM68K_ARG(%@, %@, %@)\n",
- argType, argName, m68kReg];
- }
-
- if (arguments.count > 0)
- [_impl writeString: @"\n"];
-
- if (![returnType isEqual: @"void"])
- [_impl writeString: @"\treturn "];
- else
- [_impl writeString: @"\t"];
-
- [_impl writeFormat: @"%@(", name];
-
- argumentIndex = 0;
- for (OFXMLElement *argument in arguments) {
- OFString *argName =
- [argument attributeForName: @"name"].stringValue;
-
- if (argumentIndex++ > 0)
- [_impl writeString: @", "];
-
- [_impl writeString: argName];
- }
-
- [_impl writeString: @");\n}\n"];
- }
-}
-@end
DELETED generators/library/LibraryGenerator.m
Index: generators/library/LibraryGenerator.m
==================================================================
--- generators/library/LibraryGenerator.m
+++ generators/library/LibraryGenerator.m
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#include "config.h"
-
-#import "OFApplication.h"
-#import "OFFile.h"
-#import "OFFileManager.h"
-#import "OFURI.h"
-#import "OFXMLElement.h"
-
-#import "FuncArrayGenerator.h"
-#import "GlueGenerator.h"
-#import "LinkLibGenerator.h"
-
-@interface LibraryGenerator: OFObject
-@end
-
-OF_APPLICATION_DELEGATE(LibraryGenerator)
-
-@implementation LibraryGenerator
-- (void)applicationDidFinishLaunching
-{
- OFURI *sourcesURI = [[OFFileManager defaultManager].currentDirectoryURI
- URIByAppendingPathComponent: @"../../src"];
- OFURI *runtimeLibraryURI = [sourcesURI
- URIByAppendingPathComponent: @"runtime/amiga-library.xml"];
- OFURI *runtimeLinkLibURI = [sourcesURI
- URIByAppendingPathComponent: @"runtime/linklib/linklib.m"];
- OFURI *runtimeGlueHeaderURI = [sourcesURI
- URIByAppendingPathComponent: @"runtime/amiga-glue.h"];
- OFURI *runtimeGlueURI = [sourcesURI
- URIByAppendingPathComponent: @"runtime/amiga-glue.m"];
- OFURI *runtimeFuncArrayURI = [sourcesURI
- URIByAppendingPathComponent: @"runtime/amiga-funcarray.inc"];
- OFXMLElement *runtimeLibrary = [OFXMLElement elementWithStream:
- [OFFile fileWithPath: runtimeLibraryURI.fileSystemRepresentation
- mode: @"r"]];
- OFFile *runtimeLinkLib =
- [OFFile fileWithPath: runtimeLinkLibURI.fileSystemRepresentation
- mode: @"w"];
- OFFile *runtimeGlueHeader =
- [OFFile fileWithPath: runtimeGlueHeaderURI.fileSystemRepresentation
- mode: @"w"];
- OFFile *runtimeGlue =
- [OFFile fileWithPath: runtimeGlueURI.fileSystemRepresentation
- mode: @"w"];
- OFFile *runtimeFuncArray =
- [OFFile fileWithPath: runtimeFuncArrayURI.fileSystemRepresentation
- mode: @"w"];
- LinkLibGenerator *runtimeLinkLibGenerator = [[[LinkLibGenerator alloc]
- initWithLibrary: runtimeLibrary
- implementation: runtimeLinkLib] autorelease];
- GlueGenerator *runtimeGlueGenerator = [[[GlueGenerator alloc]
- initWithLibrary: runtimeLibrary
- header: runtimeGlueHeader
- implementation: runtimeGlue] autorelease];
- FuncArrayGenerator *runtimeFuncArrayGenerator;
- runtimeFuncArrayGenerator = [[[FuncArrayGenerator alloc]
- initWithLibrary: runtimeLibrary
- include: runtimeFuncArray] autorelease];
-
- [runtimeLinkLibGenerator generate];
- [runtimeGlueGenerator generate];
- [runtimeFuncArrayGenerator generate];
-
- [OFApplication terminate];
-}
-@end
DELETED generators/library/LinkLibGenerator.h
Index: generators/library/LinkLibGenerator.h
==================================================================
--- generators/library/LinkLibGenerator.h
+++ generators/library/LinkLibGenerator.h
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
- *
- * 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 "OFStream.h"
-#import "OFXMLElement.h"
-
-@interface LinkLibGenerator: OFObject
-{
- OFXMLElement *_library;
- OFStream *_impl;
-}
-
-- (instancetype)initWithLibrary: (OFXMLElement *)library
- implementation: (OFStream *)impl;
-- (void)generate;
-@end
DELETED generators/library/LinkLibGenerator.m
Index: generators/library/LinkLibGenerator.m
==================================================================
--- generators/library/LinkLibGenerator.m
+++ generators/library/LinkLibGenerator.m
@@ -1,226 +0,0 @@
-/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
- *
- * 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 "OFArray.h"
-#import "OFXMLAttribute.h"
-
-#import "LinkLibGenerator.h"
-
-#import "OFInvalidFormatException.h"
-#import "OFUnsupportedVersionException.h"
-
-#import "copyright.h"
-
-@implementation LinkLibGenerator
-- (instancetype)initWithLibrary: (OFXMLElement *)library
- implementation: (OFStream *)impl
-{
- self = [super init];
-
- @try {
- OFXMLAttribute *version;
-
- if (![library.name isEqual: @"amiga-library"] ||
- library.namespace != nil)
- @throw [OFInvalidFormatException exception];
-
- if ((version = [library attributeForName: @"version"]) == nil)
- @throw [OFInvalidFormatException exception];
-
- if (![version.stringValue isEqual: @"1.0"])
- @throw [OFUnsupportedVersionException
- exceptionWithVersion: version.stringValue];
-
- _library = [library retain];
- _impl = [impl retain];
- } @catch (id e) {
- [self release];
- @throw e;
- }
-
- return self;
-}
-
-- (void)dealloc
-{
- [_library release];
- [_impl release];
-
- [super dealloc];
-}
-
-- (void)generate
-{
- OFString *libBase = [_library attributeForName: @"base"].stringValue;
- OFArray OF_GENERIC(OFXMLElement *) *functions;
- size_t funcIndex = 0;
-
- [_impl writeString: COPYRIGHT];
- [_impl writeString:
- @"/* This file is automatically generated from amiga-library.xml */"
- @"\n\n"
- @"#include \"config.h\"\n"
- @"\n"];
-
- for (OFXMLElement *include in [_library elementsForName: @"include"])
- [_impl writeFormat: @"#import \"%@\"\n",
- include.stringValue];
-
- [_impl writeFormat: @"\n"
- @"extern struct Library *%@;\n"
- @"\n",
- libBase];
-
- functions = [_library elementsForName: @"function"];
- for (OFXMLElement *function in functions) {
- OFString *name =
- [function attributeForName: @"name"].stringValue;
- OFString *returnType =
- [function attributeForName: @"return-type"].stringValue;
- OFArray OF_GENERIC(OFXMLElement *) *arguments =
- [function elementsForName: @"argument"];
- size_t argumentIndex;
-
- if (returnType == nil)
- returnType = @"void";
-
- [_impl writeFormat: @"%@\n%@(", returnType, name];
-
- argumentIndex = 0;
- for (OFXMLElement *argument in
- [function elementsForName: @"argument"]) {
- OFString *argName =
- [argument attributeForName: @"name"].stringValue;
- OFString *argType =
- [argument attributeForName: @"type"].stringValue;
-
- if (argumentIndex++ > 0)
- [_impl writeString: @", "];
-
- [_impl writeString: argType];
- if (![argType hasSuffix: @"*"])
- [_impl writeString: @" "];
- [_impl writeString: argName];
- }
-
- [_impl writeFormat:
- @")\n"
- @"{\n"
- @"#if defined(OF_AMIGAOS_M68K)\n"
- @"\tregister struct Library *a6 __asm__(\"a6\") = %@;\n"
- @"\t(void)a6;\n"
- @"\t", libBase];
-
- if (![returnType isEqual: @"void"])
- [_impl writeString: @"return "];
-
- [_impl writeString: @"(("];
- [_impl writeString: returnType];
- if (![returnType hasSuffix: @"*"])
- [_impl writeString: @" "];
- [_impl writeString: @"(*)("];
-
- argumentIndex = 0;
- for (OFXMLElement *argument in arguments) {
- OFString *argType =
- [argument attributeForName: @"type"].stringValue;
- OFString *m68kReg = [argument
- attributeForName: @"m68k-reg"].stringValue;
-
- if (argumentIndex++ > 0)
- [_impl writeString: @", "];
-
- [_impl writeString: argType];
- if (![argType hasSuffix: @"*"])
- [_impl writeString: @" "];
- [_impl writeFormat: @"__asm__(\"%@\")",
- m68kReg];
- }
-
- [_impl writeFormat: @"))(((uintptr_t)%@) - %zu))(",
- libBase, 30 + funcIndex * 6];
-
- argumentIndex = 0;
- for (OFXMLElement *argument in
- [function elementsForName: @"argument"]) {
- OFString *argName =
- [argument attributeForName: @"name"].stringValue;
-
- if (argumentIndex++ > 0)
- [_impl writeString: @", "];
-
- [_impl writeString: argName];
- }
-
- [_impl writeFormat: @");\n"
- @"#elif defined(OF_MORPHOS)\n"
- @"\t__asm__ __volatile__ (\n"
- @"\t \"mr\t\t%%%%r12, %%0\"\n"
- @"\t :: \"r\"(%@) : \"r12\"\n"
- @"\t);\n"
- @"\n"
- @"\t",
- libBase, libBase];
-
- if (![returnType isEqual: @"void"])
- [_impl writeString: @"return "];
-
- [_impl writeString: @"__extension__ (("];
- [_impl writeString: returnType];
- if (![returnType hasSuffix: @"*"])
- [_impl writeString: @" "];
- [_impl writeString: @"(*)("];
-
- argumentIndex = 0;
- for (OFXMLElement *argument in arguments) {
- OFString *argType =
- [argument attributeForName: @"type"].stringValue;
-
- if (argumentIndex++ > 0)
- [_impl writeString: @", "];
-
- [_impl writeString: argType];
- }
-
- [_impl writeFormat: @"))*(void **)(((uintptr_t)%@) - %zu))(",
- libBase, 28 + funcIndex * 6];
-
- argumentIndex = 0;
- for (OFXMLElement *argument in
- [function elementsForName: @"argument"]) {
- OFString *argName =
- [argument attributeForName: @"name"].stringValue;
-
- if (argumentIndex++ > 0)
- [_impl writeString: @", "];
-
- [_impl writeString: argName];
- }
-
- [_impl writeString: @");\n"
- @"#endif\n"];
-
- if ([function attributeForName: @"noreturn"] != nil)
- [_impl writeString: @"\n\tOF_UNREACHABLE\n"];
-
- [_impl writeString: @"}\n"];
-
- if (++funcIndex < functions.count)
- [_impl writeString: @"\n"];
- }
-}
-@end
DELETED generators/library/Makefile
Index: generators/library/Makefile
==================================================================
--- generators/library/Makefile
+++ generators/library/Makefile
@@ -1,75 +0,0 @@
-include ../../extra.mk
-
-PROG_NOINST = gen_libraries${PROG_SUFFIX}
-SRCS = FuncArrayGenerator.m \
- GlueGenerator.m \
- LibraryGenerator.m \
- LinkLibGenerator.m
-
-include ../../buildsys.mk
-
-.PHONY: run
-run: all
- rm -f libobjfw.so.${OBJFW_LIB_MAJOR}
- rm -f libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}
- rm -f objfw${OBJFW_LIB_MAJOR}.dll libobjfw.${OBJFW_LIB_MAJOR}.dylib
- rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR}
- rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}
- rm -f objfwrt${OBJFWRT_LIB_MAJOR}.dll
- rm -f libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib
- rm -f ${OBJFWRT_AMIGA_LIB}
- if test -f ../../src/libobjfw.so; then \
- ${LN_S} ../../src/libobjfw.so libobjfw.so.${OBJFW_LIB_MAJOR}; \
- ${LN_S} ../../src/libobjfw.so \
- libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \
- elif test -f ../../src/libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; then \
- ${LN_S} ../../src/libobjfw.so.${OBJFW_LIB_MAJOR_MINOR} \
- libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \
- fi
- if test -f ../../src/objfw${OBJFW_LIB_MAJOR}.dll; then \
- ${LN_S} ../../src/objfw${OBJFW_LIB_MAJOR}.dll \
- objfw${OBJFW_LIB_MAJOR}.dll; \
- fi
- if test -f ../../src/libobjfw.dylib; then \
- ${LN_S} ../../src/libobjfw.dylib \
- libobjfw.${OBJFW_LIB_MAJOR}.dylib; \
- fi
- if test -f ../../src/runtime/libobjfwrt.so; then \
- ${LN_S} ../../src/runtime/libobjfwrt.so \
- libobjfwrt.so.${OBJFWRT_LIB_MAJOR}; \
- ${LN_S} ../../src/runtime/libobjfwrt.so \
- libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}; \
- elif test -f ../../src/runtime/libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}; then \
- ${LN_S} ../../src/runtime/libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR} libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}; \
- fi
- if test -f ../../src/runtime/objfwrt${OBJFWRT_LIB_MAJOR}.dll; then \
- ${LN_S} ../../src/runtime/objfwrt${OBJFWRT_LIB_MAJOR}.dll \
- objfwrt${OBJFWRT_LIB_MAJOR}.dll; \
- fi
- if test -f ../../src/runtime/libobjfwrt.dylib; then \
- ${LN_S} ../../src/runtime/libobjfwrt.dylib \
- libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib; \
- fi
- if test -f ../../src/runtime/${OBJFWRT_AMIGA_LIB}; then \
- ${LN_S} ../../src/runtime/${OBJFWRT_AMIGA_LIB} \
- ${OBJFWRT_AMIGA_LIB}; \
- fi
- LD_LIBRARY_PATH=.$${LD_LIBRARY_PATH+:}$$LD_LIBRARY_PATH \
- DYLD_FRAMEWORK_PATH=../../src:../../src/runtime$${DYLD_FRAMEWORK_PATH+:}$$DYLD_FRAMEWORK_PATH \
- DYLD_LIBRARY_PATH=.$${DYLD_LIBRARY_PATH+:}$$DYLD_LIBRARY_PATH \
- LIBRARY_PATH=.$${LIBRARY_PATH+:}$$LIBRARY_PATH \
- ASAN_OPTIONS=allocator_may_return_null=1 \
- ${WRAPPER} ./${PROG_NOINST}; EXIT=$$?; \
- rm -f libobjfw.so.${OBJFW_LIB_MAJOR}; \
- rm -f libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \
- rm -f objfw${OBJFW_LIB_MAJOR}.dll; \
- rm -f libobjfw.${OBJFW_LIB_MAJOR}.dylib; \
- rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR}; \
- rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}; \
- rm -f objfwrt${OBJFWRT_LIB_MAJOR}.dll; \
- rm -f libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib; \
- exit $$EXIT
-
-CPPFLAGS += -I../../src -I../../src/exceptions -I../../src/runtime -I../..
-LIBS := -L../../src -lobjfw -L../../src/runtime ${RUNTIME_LIBS} ${LIBS}
-LD = ${OBJC}
DELETED generators/library/copyright.h
Index: generators/library/copyright.h
==================================================================
--- generators/library/copyright.h
+++ generators/library/copyright.h
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#import "OFString.h"
-
-#define COPYRIGHT \
- @"/*\n" \
- @" * Copyright (c) 2008-2022 Jonathan Schleifer \n" \
- @" *\n" \
- @" * All rights reserved.\n" \
- @" *\n" \
- @" * This file is part of ObjFW. It may be distributed under the terms " \
- @"of the\n" \
- @" * Q Public License 1.0, which can be found in the file LICENSE.QPL " \
- @"included in\n" \
- @" * the packaging of this file.\n" \
- @" *\n" \
- @" * Alternatively, it may be distributed under the terms of the GNU " \
- @"General\n" \
- @" * Public License, either version 2 or 3, which can be found in the " \
- @"file\n" \
- @" * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the " \
- @"packaging of this\n" \
- @" * file.\n" \
- @" */\n" \
- @"\n"
Index: generators/unicode/Makefile
==================================================================
--- generators/unicode/Makefile
+++ generators/unicode/Makefile
@@ -12,11 +12,10 @@
rm -f objfw${OBJFW_LIB_MAJOR}.dll libobjfw.${OBJFW_LIB_MAJOR}.dylib
rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR}
rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}
rm -f objfwrt${OBJFWRT_LIB_MAJOR}.dll
rm -f libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib
- rm -f ${OBJFWRT_AMIGA_LIB}
if test -f ../../src/libobjfw.so; then \
${LN_S} ../../src/libobjfw.so libobjfw.so.${OBJFW_LIB_MAJOR}; \
${LN_S} ../../src/libobjfw.so \
libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \
elif test -f ../../src/libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; then \
@@ -45,14 +44,10 @@
fi
if test -f ../../src/runtime/libobjfwrt.dylib; then \
${LN_S} ../../src/runtime/libobjfwrt.dylib \
libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib; \
fi
- if test -f ../../src/runtime/${OBJFWRT_AMIGA_LIB}; then \
- ${LN_S} ../../src/runtime/${OBJFWRT_AMIGA_LIB} \
- ${OBJFWRT_AMIGA_LIB}; \
- fi
LD_LIBRARY_PATH=.$${LD_LIBRARY_PATH+:}$$LD_LIBRARY_PATH \
DYLD_FRAMEWORK_PATH=../../src:../../src/runtime$${DYLD_FRAMEWORK_PATH+:}$$DYLD_FRAMEWORK_PATH \
DYLD_LIBRARY_PATH=.$${DYLD_LIBRARY_PATH+:}$$DYLD_LIBRARY_PATH \
LIBRARY_PATH=.$${LIBRARY_PATH+:}$$LIBRARY_PATH \
ASAN_OPTIONS=allocator_may_return_null=1 \
Index: generators/unicode/TableGenerator.h
==================================================================
--- generators/unicode/TableGenerator.h
+++ generators/unicode/TableGenerator.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
Index: generators/unicode/TableGenerator.m
==================================================================
--- generators/unicode/TableGenerator.m
+++ generators/unicode/TableGenerator.m
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
@@ -15,28 +15,28 @@
#include "config.h"
#include
-#import "OFString.h"
+#import "OFApplication.h"
#import "OFArray.h"
-#import "OFApplication.h"
-#import "OFURI.h"
+#import "OFFile.h"
+#import "OFHTTPClient.h"
#import "OFHTTPRequest.h"
#import "OFHTTPResponse.h"
-#import "OFHTTPClient.h"
-#import "OFFile.h"
+#import "OFIRI.h"
#import "OFStdIOStream.h"
+#import "OFString.h"
#import "OFOutOfRangeException.h"
#import "TableGenerator.h"
#import "copyright.h"
-static OFString *const unicodeDataURI =
+static OFString *const unicodeDataIRI =
@"http://www.unicode.org/Public/UNIDATA/UnicodeData.txt";
-static OFString *const caseFoldingURI =
+static OFString *const caseFoldingIRI =
@"http://www.unicode.org/Public/UNIDATA/CaseFolding.txt";
OF_APPLICATION_DELEGATE(TableGenerator)
@implementation TableGenerator
@@ -60,18 +60,18 @@
}
return self;
}
-- (void)applicationDidFinishLaunching
+- (void)applicationDidFinishLaunching: (OFNotification *)notification
{
OFHTTPRequest *request;
[OFStdOut writeString: @"Downloading UnicodeData.txt…"];
_state = stateUnicodeData;
- request = [OFHTTPRequest requestWithURI:
- [OFURI URIWithString: unicodeDataURI]];
+ request = [OFHTTPRequest requestWithIRI:
+ [OFIRI IRIWithString: unicodeDataIRI]];
[_HTTPClient asyncPerformRequest: request];
}
- (void)client: (OFHTTPClient *)client
didPerformRequest: (OFHTTPRequest *)request
@@ -166,12 +166,12 @@
[OFStdOut writeLine: @" done"];
[OFStdOut writeString: @"Downloading CaseFolding.txt…"];
_state = stateCaseFolding;
- request = [OFHTTPRequest requestWithURI:
- [OFURI URIWithString: caseFoldingURI]];
+ request = [OFHTTPRequest requestWithIRI:
+ [OFIRI IRIWithString: caseFoldingIRI]];
[_HTTPClient asyncPerformRequest: request];
}
- (void)parseCaseFolding: (OFHTTPResponse *)response
{
@@ -268,19 +268,19 @@
} while (!done);
}
- (void)writeFiles
{
- OFURI *URI;
+ OFIRI *IRI;
[OFStdOut writeString: @"Writing files…"];
- URI = [OFURI fileURIWithPath: @"../../src/unicode.m"];
- [self writeTablesToFile: URI.fileSystemRepresentation];
+ IRI = [OFIRI fileIRIWithPath: @"../../src/unicode.m"];
+ [self writeTablesToFile: IRI.fileSystemRepresentation];
- URI = [OFURI fileURIWithPath: @"../../src/unicode.h"];
- [self writeHeaderToFile: URI.fileSystemRepresentation];
+ IRI = [OFIRI fileIRIWithPath: @"../../src/unicode.h"];
+ [self writeHeaderToFile: IRI.fileSystemRepresentation];
[OFStdOut writeLine: @" done"];
[OFApplication terminate];
}
Index: generators/unicode/copyright.h
==================================================================
--- generators/unicode/copyright.h
+++ generators/unicode/copyright.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
@@ -15,11 +15,11 @@
#import "OFString.h"
#define COPYRIGHT \
@"/*\n" \
- @" * Copyright (c) 2008-2022 Jonathan Schleifer \n" \
+ @" * Copyright (c) 2008-2023 Jonathan Schleifer \n" \
@" *\n" \
@" * All rights reserved.\n" \
@" *\n" \
@" * This file is part of ObjFW. It may be distributed under the terms " \
@"of the\n" \
Index: objfw.spec
==================================================================
--- objfw.spec
+++ objfw.spec
@@ -30,11 +30,11 @@
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: clang
BuildRequires: make
-BuildRequires: pkgconfig(openssl)
+BuildRequires: pkgconfig(gnutls)
Requires: %{libobjfw_pkgname}%{_isa} = %{version}-%{release}
Requires: %{libobjfw_pkgname}-devel = %{version}-%{release}
Requires: %{libobjfwrt_pkgname}%{_isa} = %{version}-%{release}
Requires: %{libobjfwrt_pkgname}-devel = %{version}-%{release}
Requires: ofarc%{_isa} = %{version}-%{release}
@@ -87,11 +87,11 @@
The %{libobjfwrt_pkgname}-devel package contains header files and libraries for
ObjFW's Objective-C runtime library.
%package -n %{libobjfwtls_pkgname}
Summary: TLS support for ObjFW
-Requires: openssl%{_isa} >= 1.1.1
+Requires: gnutls%{_isa} >= 3.0.5
%description -n %{libobjfwtls_pkgname}
The %{libobjfwtls_pkgname} package contains TLS support for ObjFW
%package -n %{libobjfwtls_pkgname}-devel
@@ -136,14 +136,14 @@
Requires: %{libobjfw_pkgname}%{_isa} = %{version}-%{release}
Requires: %{libobjfwrt_pkgname}%{_isa} = %{version}-%{release}
Requires: %{libobjfwtls_pkgname}%{_isa} = %{version}-%{release}
%description -n ofhttp
-ofhttp is a command line downloader for HTTP and HTTPS (via ObjOpenSSL) using
-ObjFW's OFHTTPClient class. It supports all features one would expect from a
-modern command line downloader such as resuming of downloads, using a SOCKS5
-proxy, a modern terminal-based UI, etc.
+ofhttp is a command line downloader for HTTP and HTTPS using ObjFW's
+OFHTTPClient class. It supports all features one would expect from a modern
+command line downloader such as resuming of downloads, using a SOCKS5 proxy, a
+modern terminal-based UI, etc.
%prep
%autosetup
./autogen.sh
@@ -163,86 +163,82 @@
%post -n %{libobjfwrt_pkgname} -p /sbin/ldconfig
%postun -n %{libobjfwrt_pkgname} -p /sbin/ldconfig
%endif
%files
-%license LICENSE.QPL
+%license LICENSE.GPLv2
%license LICENSE.GPLv3
-%license LICENSE.GPLv2
+%license LICENSE.QPL
%files -n %{libobjfw_pkgname}
+%license LICENSE.GPLv2
+%license LICENSE.GPLv3
+%license LICENSE.QPL
%{_libdir}/libobjfw.so.%{libobjfw_major}
%{_libdir}/libobjfw.so.%{libobjfw_major}.%{libobjfw_minor}.0
-%license LICENSE.QPL
-%license LICENSE.GPLv3
-%license LICENSE.GPLv2
%files -n %{libobjfw_pkgname}-devel
-%{_libdir}/libobjfw.so
-%dir %{_includedir}/ObjFW
-%{_includedir}/ObjFW
+%license LICENSE.GPLv2
+%license LICENSE.GPLv3
+%license LICENSE.QPL
%{_bindir}/objfw-compile
%{_bindir}/objfw-config
+%{_bindir}/objfw-embed
%{_bindir}/objfw-new
-%license LICENSE.QPL
-%license LICENSE.GPLv3
-%license LICENSE.GPLv2
+%{_includedir}/ObjFW
+%{_libdir}/libobjfw.so
%files -n %{libobjfwrt_pkgname}
+%license LICENSE.GPLv2
+%license LICENSE.GPLv3
+%license LICENSE.QPL
%{_libdir}/libobjfwrt.so.%{libobjfwrt_major}
%{_libdir}/libobjfwrt.so.%{libobjfwrt_major}.%{libobjfwrt_minor}.0
-%license LICENSE.QPL
-%license LICENSE.GPLv3
-%license LICENSE.GPLv2
%files -n %{libobjfwrt_pkgname}-devel
-%{_libdir}/libobjfwrt.so
-%{_includedir}/ObjFWRT/ObjFWRT.h
+%license LICENSE.GPLv2
+%license LICENSE.GPLv3
%license LICENSE.QPL
-%license LICENSE.GPLv3
-%license LICENSE.GPLv2
+%{_includedir}/ObjFWRT
+%{_libdir}/libobjfwrt.so
%files -n %{libobjfwtls_pkgname}
+%license LICENSE.GPLv2
+%license LICENSE.GPLv3
+%license LICENSE.QPL
%{_libdir}/libobjfwtls.so.%{libobjfwtls_major}
%{_libdir}/libobjfwtls.so.%{libobjfwtls_major}.%{libobjfwtls_minor}.0
-%license LICENSE.QPL
-%license LICENSE.GPLv3
-%license LICENSE.GPLv2
%files -n %{libobjfwtls_pkgname}-devel
-%{_libdir}/libobjfwtls.so
-%{_includedir}/ObjFWTLS/ObjFWTLS.h
+%license LICENSE.GPLv2
+%license LICENSE.GPLv3
%license LICENSE.QPL
-%license LICENSE.GPLv3
-%license LICENSE.GPLv2
+%{_includedir}/ObjFWTLS
+%{_libdir}/libobjfwtls.so
%files -n ofarc
-%{_bindir}/ofarc
-%{_datadir}/ofarc/lang/de.json
-%{_datadir}/ofarc/lang/languages.json
+%license LICENSE.GPLv2
+%license LICENSE.GPLv3
%license LICENSE.QPL
-%license LICENSE.GPLv3
-%license LICENSE.GPLv2
+%{_bindir}/ofarc
+%{_datadir}/ofarc
%files -n ofdns
-%{_bindir}/ofdns
-%{_datadir}/ofdns/lang/de.json
-%{_datadir}/ofdns/lang/languages.json
+%license LICENSE.GPLv2
+%license LICENSE.GPLv3
%license LICENSE.QPL
-%license LICENSE.GPLv3
-%license LICENSE.GPLv2
+%{_bindir}/ofdns
+%{_datadir}/ofdns
%files -n ofhash
-%{_bindir}/ofhash
-%{_datadir}/ofhash/lang/de.json
-%{_datadir}/ofhash/lang/languages.json
+%license LICENSE.GPLv2
+%license LICENSE.GPLv3
%license LICENSE.QPL
-%license LICENSE.GPLv3
-%license LICENSE.GPLv2
+%{_bindir}/ofhash
+%{_datadir}/ofhash
%files -n ofhttp
-%{_bindir}/ofhttp
-%{_datadir}/ofhttp/lang/de.json
-%{_datadir}/ofhttp/lang/languages.json
+%license LICENSE.GPLv2
+%license LICENSE.GPLv3
%license LICENSE.QPL
-%license LICENSE.GPLv3
-%license LICENSE.GPLv2
+%{_bindir}/ofhttp
+%{_datadir}/ofhttp
Index: src/Makefile
==================================================================
--- src/Makefile
+++ src/Makefile
@@ -26,40 +26,42 @@
OFFileManager.m \
OFGZIPStream.m \
OFHMAC.m \
OFINICategory.m \
OFINIFile.m \
+ OFIRI.m \
+ OFIRIHandler.m \
OFInflate64Stream.m \
OFInflateStream.m \
OFInvocation.m \
OFLHAArchive.m \
OFLHAArchiveEntry.m \
OFList.m \
OFLocale.m \
OFMD5Hash.m \
OFMapTable.m \
+ OFMatrix4x4.m \
OFMemoryStream.m \
OFMessagePackExtension.m \
OFMethodSignature.m \
OFMutableArray.m \
OFMutableData.m \
OFMutableDictionary.m \
+ OFMutableIRI.m \
OFMutableLHAArchiveEntry.m \
OFMutablePair.m \
OFMutableSet.m \
OFMutableString.m \
OFMutableTarArchiveEntry.m \
OFMutableTriple.m \
- OFMutableURI.m \
OFMutableZIPArchiveEntry.m \
OFNotification.m \
OFNotificationCenter.m \
OFNull.m \
OFNumber.m \
OFObject.m \
OFObject+KeyValueCoding.m \
- OFObject+Serialization.m \
OFOnce.m \
OFOptionsParser.m \
OFPBKDF2.m \
OFPair.m \
OFRIPEMD160Hash.m \
@@ -72,41 +74,36 @@
OFSHA384Or512Hash.m \
OFSHA512Hash.m \
OFScrypt.m \
OFSecureData.m \
OFSeekableStream.m \
- OFSerialization.m \
OFSet.m \
+ OFSettings.m \
OFSortedList.m \
OFStdIOStream.m \
OFStream.m \
OFString.m \
OFString+CryptographicHashing.m \
OFString+JSONParsing.m \
OFString+PercentEncoding.m \
OFString+PropertyListParsing.m \
- OFString+Serialization.m \
OFString+XMLEscaping.m \
OFString+XMLUnescaping.m \
${OF_SUBPROCESS_M} \
- OFSettings.m \
OFSystemInfo.m \
OFTarArchive.m \
OFTarArchiveEntry.m \
OFThread.m \
OFTimer.m \
OFTriple.m \
- OFURI.m \
- OFURIHandler.m \
OFUUID.m \
OFValue.m \
OFXMLAttribute.m \
OFXMLCDATA.m \
OFXMLCharacters.m \
OFXMLComment.m \
OFXMLElement.m \
- OFXMLElement+Serialization.m \
OFXMLElementBuilder.m \
OFXMLNode.m \
OFXMLParser.m \
OFXMLProcessingInstruction.m \
OFZIPArchive.m \
@@ -131,15 +128,18 @@
OFHTTPResponse.m \
OFHTTPServer.m \
OFSequencedPacketSocket.m \
OFSocket.m \
OFStreamSocket.m \
+ OFSystemInfo+NetworkInterfaces.m \
OFTCPSocket.m \
OFTLSStream.m \
OFUDPSocket.m \
+ ${USE_SRCS_APPLETALK} \
${USE_SRCS_IPX} \
${USE_SRCS_UNIX_SOCKETS}
+SRCS_APPLETALK = OFDDPSocket.m
SRCS_IPX = OFIPXSocket.m \
OFSPXSocket.m \
OFSPXStreamSocket.m
SRCS_UNIX_SOCKETS = OFUNIXDatagramSocket.m \
OFUNIXStreamSocket.m
@@ -175,18 +175,18 @@
${USE_INCLUDES_ATOMIC}
SRCS += OFASPrintF.m \
OFAdjacentArray.m \
OFAdjacentSubarray.m \
- OFArchiveURIHandler.m \
+ OFArchiveIRIHandler.m \
OFBase64.m \
OFBitSetCharacterSet.m \
OFBytesValue.m \
OFCRC16.m \
OFCRC32.m \
OFCountedMapTableSet.m \
- OFEmbeddedURIHandler.m \
+ OFEmbeddedIRIHandler.m \
OFHuffmanTree.m \
OFINIFileSettings.m \
OFInvertedCharacterSet.m \
OFLHADecompressingStream.m \
OFMapTableDictionary.m \
@@ -208,16 +208,16 @@
OFUTF8String.m \
${LIBBASES_M} \
${RUNTIME_AUTORELEASE_M} \
${RUNTIME_INSTANCE_M} \
${UNICODE_M}
-SRCS_FILES += OFFileURIHandler.m
-SRCS_SOCKETS += OFDNSResolverSettings.m \
+SRCS_FILES += OFFileIRIHandler.m
+SRCS_SOCKETS += OFAsyncIPSocketConnector.m \
+ OFDNSResolverSettings.m \
${OF_EPOLL_KERNEL_EVENT_OBSERVER_M} \
- OFHTTPURIHandler.m \
+ OFHTTPIRIHandler.m \
OFHostAddressResolver.m \
- OFIPSocketAsyncConnector.m \
OFKernelEventObserver.m \
${OF_KQUEUE_KERNEL_EVENT_OBSERVER_M} \
${OF_POLL_KERNEL_EVENT_OBSERVER_M} \
${OF_SELECT_KERNEL_EVENT_OBSERVER_M} \
OFTCPSocketSOCKS5Connector.m
@@ -243,5 +243,13 @@
RCFLAGS = --use-temp-file \
-DOBJFW_LIB_MAJOR=${OBJFW_LIB_MAJOR} \
-DOBJFW_LIB_MINOR=${OBJFW_LIB_MINOR} \
-DOBJFW_LIB_VERSION=\"${OBJFW_LIB_MAJOR}.${OBJFW_LIB_MINOR}\" \
-DOBJFW_SHARED_LIB=\"${OBJFW_SHARED_LIB}\"
+
+uninstall-extra:
+ for i in platform/GCC4 platform/GCC4.7 platform/PowerPC platform/macOS \
+ platform/x86 platform ""; do \
+ if test -d ${DESTDIR}${includedir}/${includesubdir}/$$i; then \
+ rmdir ${DESTDIR}${includedir}/${includesubdir}/$$i; \
+ fi; \
+ done
Index: src/OFASPrintF.h
==================================================================
--- src/OFASPrintF.h
+++ src/OFASPrintF.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
Index: src/OFASPrintF.m
==================================================================
--- src/OFASPrintF.m
+++ src/OFASPrintF.m
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
@@ -23,11 +23,11 @@
#ifdef HAVE_WCHAR_H
# include
#endif
-#ifdef HAVE_ASPRINTF_L
+#if defined(HAVE_ASPRINTF_L) || defined(HAVE_USELOCALE)
# include
#endif
#ifdef HAVE_XLOCALE_H
# include
#endif
@@ -81,11 +81,11 @@
lengthModifierCapitalL
} lengthModifier;
bool useLocale;
};
-#ifdef HAVE_ASPRINTF_L
+#if defined(HAVE_ASPRINTF_L) || defined(HAVE_USELOCALE)
static locale_t cLocale;
OF_CONSTRUCTOR()
{
if ((cLocale = newlocale(LC_ALL_MASK, "C", NULL)) == NULL)
@@ -375,11 +375,11 @@
static bool
formatConversionSpecifierState(struct Context *ctx)
{
char *tmp = NULL;
int tmpLen = 0;
-#ifndef HAVE_ASPRINTF_L
+#if !defined(HAVE_ASPRINTF_L) && !defined(HAVE_USELOCALE)
OFString *point;
#endif
if (!appendSubformat(ctx, ctx->format + ctx->i, 1))
return false;
@@ -546,43 +546,57 @@
case 'a':
case 'A':
switch (ctx->lengthModifier) {
case lengthModifierNone:
case lengthModifierL:
-#ifdef HAVE_ASPRINTF_L
+#if defined(HAVE_ASPRINTF_L)
if (!ctx->useLocale)
tmpLen = asprintf_l(&tmp, cLocale,
ctx->subformat,
va_arg(ctx->arguments, double));
else
+#elif defined(HAVE_USELOCALE)
+ if (!ctx->useLocale) {
+ locale_t previousLocale = uselocale(cLocale);
+ tmpLen = asprintf(&tmp, ctx->subformat,
+ va_arg(ctx->arguments, double));
+ uselocale(previousLocale);
+ } else
#endif
tmpLen = asprintf(&tmp, ctx->subformat,
va_arg(ctx->arguments, double));
break;
case lengthModifierCapitalL:
-#ifdef HAVE_ASPRINTF_L
+#if defined(HAVE_ASPRINTF_L)
if (!ctx->useLocale)
tmpLen = asprintf_l(&tmp, cLocale,
ctx->subformat,
va_arg(ctx->arguments, long double));
else
+#elif defined(HAVE_USELOCALE)
+ if (!ctx->useLocale) {
+ locale_t previousLocale = uselocale(cLocale);
+ tmpLen = asprintf(&tmp, ctx->subformat,
+ va_arg(ctx->arguments, long double));
+ uselocale(previousLocale);
+ } else
#endif
tmpLen = asprintf(&tmp, ctx->subformat,
va_arg(ctx->arguments, long double));
break;
default:
return false;
}
-#ifndef HAVE_ASPRINTF_L
+#if !defined(HAVE_ASPRINTF_L) && !defined(HAVE_USELOCALE)
if (tmpLen == -1)
return false;
/*
- * If there's no asprintf_l, we have no other choice than to
- * use this ugly hack to replace the locale's decimal point
- * back to ".".
+ * If there's no asprintf_l and no uselocale, we have no other
+ * choice than to use this ugly hack to replace the locale's
+ * decimal point back to ".".
*/
point = [OFLocale decimalSeparator];
if (!ctx->useLocale && point != nil && ![point isEqual: @"."]) {
void *pool = objc_autoreleasePoolPush();
Index: src/OFAdjacentArray.h
==================================================================
--- src/OFAdjacentArray.h
+++ src/OFAdjacentArray.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
Index: src/OFAdjacentArray.m
==================================================================
--- src/OFAdjacentArray.m
+++ src/OFAdjacentArray.m
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
@@ -20,11 +20,10 @@
#import "OFAdjacentArray.h"
#import "OFAdjacentSubarray.h"
#import "OFData.h"
#import "OFMutableAdjacentArray.h"
#import "OFString.h"
-#import "OFXMLElement.h"
#import "OFEnumerationMutationException.h"
#import "OFInvalidArgumentException.h"
#import "OFOutOfRangeException.h"
@@ -148,43 +147,10 @@
[self release];
@throw e;
}
- return self;
-}
-
-- (instancetype)initWithSerialization: (OFXMLElement *)element
-{
- self = [self init];
-
- @try {
- void *pool = objc_autoreleasePoolPush();
-
- if ((![element.name isEqual: @"OFArray"] &&
- ![element.name isEqual: @"OFMutableArray"]) ||
- ![element.namespace isEqual: OFSerializationNS])
- @throw [OFInvalidArgumentException exception];
-
- for (OFXMLElement *child in
- [element elementsForNamespace: OFSerializationNS]) {
- void *pool2 = objc_autoreleasePoolPush();
- id object;
-
- object = child.objectByDeserializing;
- [_array addItem: &object];
- [object retain];
-
- objc_autoreleasePoolPop(pool2);
- }
-
- objc_autoreleasePoolPop(pool);
- } @catch (id e) {
- [self release];
- @throw e;
- }
-
return self;
}
- (size_t)count
{
@@ -318,10 +284,11 @@
- (int)countByEnumeratingWithState: (OFFastEnumerationState *)state
objects: (id *)objects
count: (int)count_
{
+ static unsigned long dummyMutations;
size_t count = _array.count;
if (count > INT_MAX)
/*
* Use the implementation from OFArray, which is slower, but can
@@ -334,11 +301,11 @@
if (state->state >= count)
return 0;
state->state = (unsigned long)count;
state->itemsPtr = (id *)_array.items;
- state->mutationsPtr = (unsigned long *)self;
+ state->mutationsPtr = &dummyMutations;
return (int)count;
}
#ifdef OF_HAVE_BLOCKS
Index: src/OFAdjacentSubarray.h
==================================================================
--- src/OFAdjacentSubarray.h
+++ src/OFAdjacentSubarray.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
Index: src/OFAdjacentSubarray.m
==================================================================
--- src/OFAdjacentSubarray.m
+++ src/OFAdjacentSubarray.m
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
Index: src/OFApplication.h
==================================================================
--- src/OFApplication.h
+++ src/OFApplication.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
@@ -27,10 +27,16 @@
@class OFMutableArray OF_GENERIC(ObjectType);
@class OFMutableDictionary OF_GENERIC(KeyType, ObjectType);
@class OFSandbox;
@class OFString;
+/**
+ * @brief A notification that will be sent when the application did finish
+ * launching.
+ */
+extern const OFNotificationName OFApplicationDidFinishLaunchingNotification;
+
/**
* @brief A notification that will be sent when the application will terminate.
*/
extern const OFNotificationName OFApplicationWillTerminateNotification;
@@ -49,11 +55,11 @@
*
* // In MyAppDelegate.m:
* OF_APPLICATION_DELEGATE(MyAppDelegate)
*
* @implementation MyAppDelegate
- * - (void)applicationDidFinishLaunching
+ * - (void)applicationDidFinishLaunching: (OFNotification *)notification
* {
* [OFApplication terminate];
* }
* @end
* @endcode
@@ -79,18 +85,24 @@
*/
@protocol OFApplicationDelegate
/**
* @brief A method which is called when the application was initialized and is
* running now.
+ *
+ * @param notification A notification with name
+ * OFApplicationDidFinishLaunchingNotification
*/
-- (void)applicationDidFinishLaunching;
+- (void)applicationDidFinishLaunching: (OFNotification *)notification;
@optional
/**
* @brief A method which is called when the application will terminate.
+ *
+ * @param notification A notification with name
+ * OFApplicationWillTerminateNotification
*/
-- (void)applicationWillTerminate;
+- (void)applicationWillTerminate: (OFNotification *)notification;
/**
* @brief A method which is called when the application received a SIGINT.
*
* @warning You are not allowed to send any messages inside this method, as
@@ -151,11 +163,11 @@
* In order to create a new OFApplication, you should create a class conforming
* to the optional @ref OFApplicationDelegate protocol and put
* `OF_APPLICATION_DELEGATE(NameOfYourClass)` in the .m file of that class.
*
* When the application is about to be terminated,
- * @ref OFApplicationDelegate#applicationWillTerminate will be called on the
+ * @ref OFApplicationDelegate#applicationWillTerminate: will be called on the
* delegate and an @ref OFApplicationWillTerminateNotification will be sent.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFApplication: OFObject
{
Index: src/OFApplication.m
==================================================================
--- src/OFApplication.m
+++ src/OFApplication.m
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
@@ -35,29 +35,32 @@
#import "OFNotificationCenter.h"
#import "OFPair.h"
#import "OFRunLoop+Private.h"
#import "OFRunLoop.h"
#import "OFSandbox.h"
+#import "OFStdIOStream.h"
#import "OFString.h"
#import "OFSystemInfo.h"
#import "OFThread+Private.h"
#import "OFThread.h"
+#import "OFActivateSandboxFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFOutOfMemoryException.h"
#import "OFOutOfRangeException.h"
-#import "OFSandboxActivationFailedException.h"
#if defined(OF_MACOS)
# include
#elif defined(OF_WINDOWS)
# include
extern int _CRT_glob;
extern void __wgetmainargs(int *, wchar_t ***, wchar_t ***, int, int *);
#elif defined(OF_AMIGAOS)
+# define Class IntuitionClass
# include
# include
+# undef Class
#elif !defined(OF_IOS)
extern char **environ;
#endif
#ifdef OF_PSP
@@ -82,27 +85,30 @@
andWideArgumentValues: (wchar_t *[])wargv;
#endif
- (void)of_run;
@end
+const OFNotificationName OFApplicationDidFinishLaunchingNotification =
+ @"OFApplicationDidFinishLaunchingNotification";
const OFNotificationName OFApplicationWillTerminateNotification =
@"OFApplicationWillTerminateNotification";
static OFApplication *app = nil;
static void
atexitHandler(void)
{
id delegate = app.delegate;
-
- [[OFNotificationCenter defaultCenter]
- postNotificationName: OFApplicationWillTerminateNotification
+ OFNotification *notification = [OFNotification
+ notificationWithName: OFApplicationWillTerminateNotification
object: app];
- if ([delegate respondsToSelector: @selector(applicationWillTerminate)])
- [delegate applicationWillTerminate];
+ if ([delegate respondsToSelector: @selector(applicationWillTerminate:)])
+ [delegate applicationWillTerminate: notification];
[delegate release];
+
+ [[OFNotificationCenter defaultCenter] postNotification: notification];
#if defined(OF_HAVE_THREADS) && defined(OF_HAVE_SOCKETS) && \
defined(OF_AMIGAOS) && !defined(OF_MORPHOS)
OFSocketDeinit();
#endif
@@ -258,13 +264,12 @@
continue;
}
pos = [tmp rangeOfString: @"="].location;
if (pos == OFNotFound) {
- fprintf(stderr,
- "Warning: Invalid environment "
- "variable: %s\n", tmp.UTF8String);
+ OFLog(@"Warning: Invalid environment "
+ "variable: %@", tmp);
continue;
}
key = [tmp substringToIndex: pos];
value = [tmp substringFromIndex: pos + 1];
@@ -300,13 +305,12 @@
continue;
}
pos = [tmp rangeOfString: @"="].location;
if (pos == OFNotFound) {
- fprintf(stderr,
- "Warning: Invalid environment "
- "variable: %s\n", tmp.UTF8String);
+ OFLog(@"Warning: Invalid environment "
+ "variable: %@", tmp);
continue;
}
key = [tmp substringToIndex: pos];
value = [tmp substringFromIndex: pos + 1];
@@ -394,12 +398,12 @@
void *pool = objc_autoreleasePoolPush();
OFString *key, *value;
char *sep;
if ((sep = strchr(*env, '=')) == NULL) {
- fprintf(stderr, "Warning: Invalid "
- "environment variable: %s\n", *env);
+ OFLog(@"Warning: Invalid environment "
+ "variable: %s", *env);
continue;
}
key = [OFString
stringWithCString: *env
@@ -578,10 +582,11 @@
- (void)of_run
{
void *pool = objc_autoreleasePoolPush();
OFRunLoop *runLoop;
+ OFNotification *notification;
#ifdef OF_HAVE_THREADS
[OFThread of_createMainThread];
runLoop = [OFRunLoop currentRunLoop];
#else
@@ -597,11 +602,19 @@
* of_setMainRunLoop: retained it. However, we only have a weak
* reference to it now, whereas we had a strong reference before.
*/
pool = objc_autoreleasePoolPush();
- [_delegate applicationDidFinishLaunching];
+
+ notification = [OFNotification
+ notificationWithName: OFApplicationDidFinishLaunchingNotification
+ object: app];
+
+ [[OFNotificationCenter defaultCenter] postNotification: notification];
+
+ [_delegate applicationDidFinishLaunching: notification];
+
objc_autoreleasePoolPop(pool);
[runLoop run];
}
@@ -652,11 +665,11 @@
sandbox->_unveiledPathsIndex = unveiledPathsCount;
promises = [sandbox.pledgeString cStringWithEncoding: encoding];
if (pledge(promises, NULL) != 0)
- @throw [OFSandboxActivationFailedException
+ @throw [OFActivateSandboxFailedException
exceptionWithSandbox: sandbox
errNo: errno];
objc_autoreleasePoolPop(pool);
@@ -680,11 +693,11 @@
promises = [sandbox.pledgeString
cStringWithEncoding: [OFLocale encoding]];
if (pledge(NULL, promises) != 0)
- @throw [OFSandboxActivationFailedException
+ @throw [OFActivateSandboxFailedException
exceptionWithSandbox: sandbox
errNo: errno];
objc_autoreleasePoolPop(pool);
Index: src/OFArchiveEntry.h
==================================================================
--- src/OFArchiveEntry.h
+++ src/OFArchiveEntry.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
ADDED src/OFArchiveIRIHandler.h
Index: src/OFArchiveIRIHandler.h
==================================================================
--- src/OFArchiveIRIHandler.h
+++ src/OFArchiveIRIHandler.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2008-2023 Jonathan Schleifer
+ *
+ * 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 "OFIRIHandler.h"
+
+OF_ASSUME_NONNULL_BEGIN
+
+@interface OFArchiveIRIHandler: OFIRIHandler
+@end
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern OFIRI *OFArchiveIRIHandlerIRIForFileInArchive(OFString *, OFString *,
+ OFIRI *);
+#ifdef __cplusplus
+}
+#endif
+
+OF_ASSUME_NONNULL_END
ADDED src/OFArchiveIRIHandler.m
Index: src/OFArchiveIRIHandler.m
==================================================================
--- src/OFArchiveIRIHandler.m
+++ src/OFArchiveIRIHandler.m
@@ -0,0 +1,200 @@
+/*
+ * Copyright (c) 2008-2023 Jonathan Schleifer
+ *
+ * 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
+
+#import "OFArchiveIRIHandler.h"
+#import "OFCharacterSet.h"
+#import "OFGZIPStream.h"
+#import "OFIRI.h"
+#import "OFLHAArchive.h"
+#import "OFStream.h"
+#import "OFTarArchive.h"
+#import "OFZIPArchive.h"
+
+#import "OFInvalidArgumentException.h"
+#import "OFOpenItemFailedException.h"
+
+@interface OFArchiveIRIHandlerPathAllowedCharacterSet: OFCharacterSet
+{
+ OFCharacterSet *_characterSet;
+ bool (*_characterIsMember)(id, SEL, OFUnichar);
+}
+@end
+
+static OFCharacterSet *pathAllowedCharacters;
+
+static void
+initPathAllowedCharacters(void)
+{
+ pathAllowedCharacters =
+ [[OFArchiveIRIHandlerPathAllowedCharacterSet alloc] init];
+}
+
+@implementation OFArchiveIRIHandler
+- (OFStream *)openItemAtIRI: (OFIRI *)IRI mode: (OFString *)mode
+{
+ void *pool = objc_autoreleasePoolPush();
+ OFString *scheme = IRI.scheme;
+ OFString *percentEncodedPath, *path;
+ size_t pos;
+ OFIRI *archiveIRI;
+ OFStream *stream;
+
+ if (IRI.host != nil || IRI.port != nil || IRI.user != nil ||
+ IRI.password != nil || IRI.query != nil || IRI.fragment != nil)
+ @throw [OFInvalidArgumentException exception];
+
+ if (![mode isEqual: @"r"])
+ /*
+ * Writing has some implications that are not decided yet: Will
+ * it always append to an archive? What happens if the file
+ * already exists?
+ */
+ @throw [OFInvalidArgumentException exception];
+
+ /*
+ * GZIP only compresses one file and thus has no path inside an
+ * archive.
+ */
+ if ([scheme isEqual: @"gzip"]) {
+ stream = [OFIRIHandler openItemAtIRI: [OFIRI IRIWithString:
+ IRI.path]
+ mode: @"r"];
+ stream = [OFGZIPStream streamWithStream: stream mode: @"r"];
+ goto end;
+ }
+
+ percentEncodedPath = IRI.percentEncodedPath;
+ pos = [percentEncodedPath rangeOfString: @"!"].location;
+
+ if (pos == OFNotFound)
+ @throw [OFInvalidArgumentException exception];
+
+ archiveIRI = [OFIRI IRIWithString:
+ [percentEncodedPath substringWithRange: OFMakeRange(0, pos)]
+ .stringByRemovingPercentEncoding];
+ path = [percentEncodedPath substringWithRange:
+ OFMakeRange(pos + 1, percentEncodedPath.length - pos - 1)]
+ .stringByRemovingPercentEncoding;
+
+ if ([scheme isEqual: @"lha"]) {
+ OFLHAArchive *archive = [OFLHAArchive archiveWithIRI: archiveIRI
+ mode: @"r"];
+ OFLHAArchiveEntry *entry;
+
+ while ((entry = [archive nextEntry]) != nil) {
+ if ([entry.fileName isEqual: path]) {
+ stream = [archive streamForReadingCurrentEntry];
+ goto end;
+ }
+ }
+
+ @throw [OFOpenItemFailedException exceptionWithIRI: IRI
+ mode: mode
+ errNo: ENOENT];
+ } else if ([scheme isEqual: @"tar"]) {
+ OFTarArchive *archive = [OFTarArchive archiveWithIRI: archiveIRI
+ mode: @"r"];
+ OFTarArchiveEntry *entry;
+
+ while ((entry = [archive nextEntry]) != nil) {
+ if ([entry.fileName isEqual: path]) {
+ stream = [archive streamForReadingCurrentEntry];
+ goto end;
+ }
+ }
+
+ @throw [OFOpenItemFailedException exceptionWithIRI: IRI
+ mode: mode
+ errNo: ENOENT];
+ } else if ([scheme isEqual: @"zip"]) {
+ OFZIPArchive *archive = [OFZIPArchive archiveWithIRI: archiveIRI
+ mode: @"r"];
+
+ stream = [archive streamForReadingFile: path];
+ } else
+ @throw [OFInvalidArgumentException exception];
+
+end:
+ stream = [stream retain];
+
+ objc_autoreleasePoolPop(pool);
+
+ return [stream autorelease];
+}
+@end
+
+@implementation OFArchiveIRIHandlerPathAllowedCharacterSet
+- (instancetype)init
+{
+ self = [super init];
+
+ @try {
+ _characterSet =
+ [[OFCharacterSet IRIPathAllowedCharacterSet] retain];
+ _characterIsMember = (bool (*)(id, SEL, OFUnichar))
+ [_characterSet methodForSelector:
+ @selector(characterIsMember:)];
+ } @catch (id e) {
+ [self release];
+ @throw e;
+ }
+
+ return self;
+}
+
+- (void)dealloc
+{
+ [_characterSet release];
+
+ [super dealloc];
+}
+
+- (bool)characterIsMember: (OFUnichar)character
+{
+ return (character != '!' && _characterIsMember(_characterSet,
+ @selector(characterIsMember:), character));
+}
+@end
+
+OFIRI *
+OFArchiveIRIHandlerIRIForFileInArchive(OFString *scheme,
+ OFString *pathInArchive, OFIRI *archiveIRI)
+{
+ static OFOnceControl onceControl = OFOnceControlInitValue;
+ OFMutableIRI *ret = [OFMutableIRI IRIWithScheme: scheme];
+ void *pool = objc_autoreleasePoolPush();
+ OFString *archiveIRIString;
+
+ OFOnce(&onceControl, initPathAllowedCharacters);
+
+ pathInArchive = [pathInArchive
+ stringByAddingPercentEncodingWithAllowedCharacters:
+ pathAllowedCharacters];
+ archiveIRIString = [archiveIRI.string
+ stringByAddingPercentEncodingWithAllowedCharacters:
+ pathAllowedCharacters];
+
+ ret.percentEncodedPath = [OFString
+ stringWithFormat: @"%@!%@", archiveIRIString, pathInArchive];
+ [ret makeImmutable];
+
+ objc_autoreleasePoolPop(pool);
+
+ return ret;
+}
DELETED src/OFArchiveURIHandler.h
Index: src/OFArchiveURIHandler.h
==================================================================
--- src/OFArchiveURIHandler.h
+++ src/OFArchiveURIHandler.h
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#import "OFURIHandler.h"
-
-OF_ASSUME_NONNULL_BEGIN
-
-@interface OFArchiveURIHandler: OFURIHandler
-@end
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-extern OFURI *OFArchiveURIHandlerURIForFileInArchive(OFString *, OFString *,
- OFURI *);
-#ifdef __cplusplus
-}
-#endif
-
-OF_ASSUME_NONNULL_END
DELETED src/OFArchiveURIHandler.m
Index: src/OFArchiveURIHandler.m
==================================================================
--- src/OFArchiveURIHandler.m
+++ src/OFArchiveURIHandler.m
@@ -1,200 +0,0 @@
-/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
- *
- * 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
-
-#import "OFArchiveURIHandler.h"
-#import "OFCharacterSet.h"
-#import "OFGZIPStream.h"
-#import "OFLHAArchive.h"
-#import "OFStream.h"
-#import "OFTarArchive.h"
-#import "OFURI.h"
-#import "OFZIPArchive.h"
-
-#import "OFInvalidArgumentException.h"
-#import "OFOpenItemFailedException.h"
-
-@interface OFArchiveURIHandlerPathAllowedCharacterSet: OFCharacterSet
-{
- OFCharacterSet *_characterSet;
- bool (*_characterIsMember)(id, SEL, OFUnichar);
-}
-@end
-
-static OFCharacterSet *pathAllowedCharacters;
-
-static void
-initPathAllowedCharacters(void)
-{
- pathAllowedCharacters =
- [[OFArchiveURIHandlerPathAllowedCharacterSet alloc] init];
-}
-
-@implementation OFArchiveURIHandler
-- (OFStream *)openItemAtURI: (OFURI *)URI mode: (OFString *)mode
-{
- void *pool = objc_autoreleasePoolPush();
- OFString *scheme = URI.scheme;
- OFString *percentEncodedPath, *path;
- size_t pos;
- OFURI *archiveURI;
- OFStream *stream;
-
- if (URI.host != nil || URI.port != nil || URI.user != nil ||
- URI.password != nil || URI.query != nil || URI.fragment != nil)
- @throw [OFInvalidArgumentException exception];
-
- if (![mode isEqual: @"r"])
- /*
- * Writing has some implications that are not decided yet: Will
- * it always append to an archive? What happens if the file
- * already exists?
- */
- @throw [OFInvalidArgumentException exception];
-
- /*
- * GZIP only compresses one file and thus has no path inside an
- * archive.
- */
- if ([scheme isEqual: @"gzip"]) {
- stream = [OFURIHandler openItemAtURI: [OFURI URIWithString:
- URI.path]
- mode: @"r"];
- stream = [OFGZIPStream streamWithStream: stream mode: @"r"];
- goto end;
- }
-
- percentEncodedPath = URI.percentEncodedPath;
- pos = [percentEncodedPath rangeOfString: @"!"].location;
-
- if (pos == OFNotFound)
- @throw [OFInvalidArgumentException exception];
-
- archiveURI = [OFURI URIWithString:
- [percentEncodedPath substringWithRange: OFMakeRange(0, pos)]
- .stringByRemovingPercentEncoding];
- path = [percentEncodedPath substringWithRange:
- OFMakeRange(pos + 1, percentEncodedPath.length - pos - 1)]
- .stringByRemovingPercentEncoding;
-
- if ([scheme isEqual: @"lha"]) {
- OFLHAArchive *archive = [OFLHAArchive archiveWithURI: archiveURI
- mode: @"r"];
- OFLHAArchiveEntry *entry;
-
- while ((entry = [archive nextEntry]) != nil) {
- if ([entry.fileName isEqual: path]) {
- stream = [archive streamForReadingCurrentEntry];
- goto end;
- }
- }
-
- @throw [OFOpenItemFailedException exceptionWithURI: URI
- mode: mode
- errNo: ENOENT];
- } else if ([scheme isEqual: @"tar"]) {
- OFTarArchive *archive = [OFTarArchive archiveWithURI: archiveURI
- mode: @"r"];
- OFTarArchiveEntry *entry;
-
- while ((entry = [archive nextEntry]) != nil) {
- if ([entry.fileName isEqual: path]) {
- stream = [archive streamForReadingCurrentEntry];
- goto end;
- }
- }
-
- @throw [OFOpenItemFailedException exceptionWithURI: URI
- mode: mode
- errNo: ENOENT];
- } else if ([scheme isEqual: @"zip"]) {
- OFZIPArchive *archive = [OFZIPArchive archiveWithURI: archiveURI
- mode: @"r"];
-
- stream = [archive streamForReadingFile: path];
- } else
- @throw [OFInvalidArgumentException exception];
-
-end:
- stream = [stream retain];
-
- objc_autoreleasePoolPop(pool);
-
- return [stream autorelease];
-}
-@end
-
-@implementation OFArchiveURIHandlerPathAllowedCharacterSet
-- (instancetype)init
-{
- self = [super init];
-
- @try {
- _characterSet =
- [[OFCharacterSet URIPathAllowedCharacterSet] retain];
- _characterIsMember = (bool (*)(id, SEL, OFUnichar))
- [_characterSet methodForSelector:
- @selector(characterIsMember:)];
- } @catch (id e) {
- [self release];
- @throw e;
- }
-
- return self;
-}
-
-- (void)dealloc
-{
- [_characterSet release];
-
- [super dealloc];
-}
-
-- (bool)characterIsMember: (OFUnichar)character
-{
- return (character != '!' && _characterIsMember(_characterSet,
- @selector(characterIsMember:), character));
-}
-@end
-
-OFURI *
-OFArchiveURIHandlerURIForFileInArchive(OFString *scheme,
- OFString *pathInArchive, OFURI *archiveURI)
-{
- static OFOnceControl onceControl = OFOnceControlInitValue;
- OFMutableURI *ret = [OFMutableURI URIWithScheme: scheme];
- void *pool = objc_autoreleasePoolPush();
- OFString *archiveURIString;
-
- OFOnce(&onceControl, initPathAllowedCharacters);
-
- pathInArchive = [pathInArchive
- stringByAddingPercentEncodingWithAllowedCharacters:
- pathAllowedCharacters];
- archiveURIString = [archiveURI.string
- stringByAddingPercentEncodingWithAllowedCharacters:
- pathAllowedCharacters];
-
- ret.percentEncodedPath = [OFString
- stringWithFormat: @"%@!%@", archiveURIString, pathInArchive];
- [ret makeImmutable];
-
- objc_autoreleasePoolPop(pool);
-
- return ret;
-}
Index: src/OFArray+Private.h
==================================================================
--- src/OFArray+Private.h
+++ src/OFArray+Private.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
Index: src/OFArray.h
==================================================================
--- src/OFArray.h
+++ src/OFArray.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
@@ -23,11 +23,10 @@
#include
#import "OFObject.h"
#import "OFCollection.h"
#import "OFEnumerator.h"
-#import "OFSerialization.h"
#import "OFJSONRepresentation.h"
#import "OFMessagePackRepresentation.h"
OF_ASSUME_NONNULL_BEGIN
@@ -100,11 +99,11 @@
* @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
#if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN)
# define ObjectType id
#endif
/**
@@ -403,10 +402,24 @@
*/
- (OFArray OF_GENERIC(ObjectType) *)
sortedArrayUsingSelector: (SEL)selector
options: (OFArraySortOptions)options;
+/**
+ * @brief Returns a copy of the array sorted using the specified function and
+ * options.
+ *
+ * @param compare The function to use to sort the array
+ * @param context Context passed to the function to compare
+ * @param options The options to use when sorting the array
+ * @return A sorted copy of the array
+ */
+- (OFArray OF_GENERIC(ObjectType) *)
+ sortedArrayUsingFunction: (OFCompareFunction)compare
+ context: (nullable void *)context
+ options: (OFArraySortOptions)options;
+
#ifdef OF_HAVE_BLOCKS
/**
* @brief Returns a copy of the array sorted using the specified selector and
* options.
*
Index: src/OFArray.m
==================================================================
--- src/OFArray.m
+++ src/OFArray.m
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
@@ -16,20 +16,17 @@
#include "config.h"
#include
#include
-#include
-
#import "OFArray.h"
#import "OFArray+Private.h"
#import "OFAdjacentArray.h"
#import "OFData.h"
#import "OFNull.h"
#import "OFString.h"
#import "OFSubarray.h"
-#import "OFXMLElement.h"
#import "OFEnumerationMutationException.h"
#import "OFInvalidArgumentException.h"
#import "OFOutOfRangeException.h"
@@ -87,15 +84,10 @@
{
return (id)[[OFAdjacentArray alloc] initWithObjects: objects
count: count];
}
-- (instancetype)initWithSerialization: (OFXMLElement *)element
-{
- return (id)[[OFAdjacentArray alloc] initWithSerialization: element];
-}
-
- (instancetype)retain
{
return self;
}
@@ -214,15 +206,10 @@
}
- (instancetype)initWithObjects: (id const *)objects
count: (size_t)count
{
- OF_INVALID_INIT_METHOD
-}
-
-- (instancetype)initWithSerialization: (OFXMLElement *)element
-{
OF_INVALID_INIT_METHOD
}
- (size_t)count
{
@@ -548,37 +535,10 @@
[ret makeImmutable];
return [ret autorelease];
}
-- (OFXMLElement *)XMLElementBySerializing
-{
- void *pool = objc_autoreleasePoolPush();
- OFXMLElement *element;
-
- if ([self isKindOfClass: [OFMutableArray class]])
- element = [OFXMLElement elementWithName: @"OFMutableArray"
- namespace: OFSerializationNS];
- else
- element = [OFXMLElement elementWithName: @"OFArray"
- namespace: OFSerializationNS];
-
- for (id object in self) {
- void *pool2 = objc_autoreleasePoolPush();
-
- [element addChild: object.XMLElementBySerializing];
-
- objc_autoreleasePoolPop(pool2);
- }
-
- [element retain];
-
- objc_autoreleasePoolPop(pool);
-
- return [element autorelease];
-}
-
- (OFString *)JSONRepresentation
{
return [self of_JSONRepresentationWithOptions: 0 depth: 0];
}
@@ -687,11 +647,11 @@
[data addItems: child.items count: child.count];
objc_autoreleasePoolPop(pool2);
}
- assert(i == count);
+ OFAssert(i == count);
[data makeImmutable];
objc_autoreleasePoolPop(pool);
@@ -725,10 +685,20 @@
OFMutableArray *new = [[self mutableCopy] autorelease];
[new sortUsingSelector: selector options: options];
[new makeImmutable];
return new;
}
+
+- (OFArray *)sortedArrayUsingFunction: (OFCompareFunction)compare
+ context: (void *)context
+ options: (OFArraySortOptions)options
+{
+ OFMutableArray *new = [[self mutableCopy] autorelease];
+ [new sortUsingFunction: compare context: context options: options];
+ [new makeImmutable];
+ return new;
+}
#ifdef OF_HAVE_BLOCKS
- (OFArray *)sortedArrayUsingComparator: (OFComparator)comparator
options: (OFArraySortOptions)options
{
@@ -749,10 +719,11 @@
- (int)countByEnumeratingWithState: (OFFastEnumerationState *)state
objects: (id *)objects
count: (int)count
{
+ static unsigned long dummyMutations;
OFRange range = OFMakeRange(state->state, count);
if (range.length > SIZE_MAX - range.location)
@throw [OFOutOfRangeException exception];
@@ -764,11 +735,11 @@
if (range.location + range.length > ULONG_MAX)
@throw [OFOutOfRangeException exception];
state->state = (unsigned long)(range.location + range.length);
state->itemsPtr = objects;
- state->mutationsPtr = (unsigned long *)self;
+ state->mutationsPtr = &dummyMutations;
return (int)range.length;
}
- (OFEnumerator *)objectEnumerator
ADDED src/OFAsyncIPSocketConnector.h
Index: src/OFAsyncIPSocketConnector.h
==================================================================
--- src/OFAsyncIPSocketConnector.h
+++ src/OFAsyncIPSocketConnector.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2008-2023 Jonathan Schleifer
+ *
+ * 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 "OFDNSResolver.h"
+#import "OFRunLoop.h"
+#import "OFRunLoop+Private.h"
+
+OF_ASSUME_NONNULL_BEGIN
+
+@protocol OFAsyncIPSocketConnecting
+- (bool)of_createSocketForAddress: (const OFSocketAddress *)address
+ errNo: (int *)errNo;
+- (bool)of_connectSocketToAddress: (const OFSocketAddress *)address
+ errNo: (int *)errNo;
+- (void)of_closeSocket;
+@end
+
+@interface OFAsyncIPSocketConnector: OFObject
+{
+ id _socket;
+ OFString *_host;
+ uint16_t _port;
+ id _Nullable _delegate;
+ id _Nullable _block;
+ id _Nullable _exception;
+ OFData *_Nullable _socketAddresses;
+ size_t _socketAddressesIndex;
+}
+
+- (instancetype)initWithSocket: (id)sock
+ host: (OFString *)host
+ port: (uint16_t)port
+ delegate: (nullable id)delegate
+ block: (nullable id)block;
+- (void)didConnect;
+- (void)tryNextAddressWithRunLoopMode: (OFRunLoopMode)runLoopMode;
+- (void)startWithRunLoopMode: (OFRunLoopMode)runLoopMode;
+@end
+
+OF_ASSUME_NONNULL_END
ADDED src/OFAsyncIPSocketConnector.m
Index: src/OFAsyncIPSocketConnector.m
==================================================================
--- src/OFAsyncIPSocketConnector.m
+++ src/OFAsyncIPSocketConnector.m
@@ -0,0 +1,251 @@
+/*
+ * Copyright (c) 2008-2023 Jonathan Schleifer
+ *
+ * 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
+
+#import "OFAsyncIPSocketConnector.h"
+#import "OFData.h"
+#import "OFTCPSocket.h"
+#import "OFThread.h"
+#import "OFTimer.h"
+
+#import "OFConnectIPSocketFailedException.h"
+#import "OFInvalidFormatException.h"
+
+@implementation OFAsyncIPSocketConnector
+- (instancetype)initWithSocket: (id)sock
+ host: (OFString *)host
+ port: (uint16_t)port
+ delegate: (id)delegate
+ block: (id)block
+{
+ self = [super init];
+
+ @try {
+ _socket = [sock retain];
+ _host = [host copy];
+ _port = port;
+ _delegate = [delegate retain];
+ _block = [block copy];
+ } @catch (id e) {
+ [self release];
+ @throw e;
+ }
+
+ return self;
+}
+
+- (void)dealloc
+{
+ [_socket release];
+ [_host release];
+ [_delegate release];
+ [_block release];
+ [_exception release];
+ [_socketAddresses release];
+
+ [super dealloc];
+}
+
+- (void)didConnect
+{
+ if (_exception == nil)
+ [_socket setCanBlock: true];
+
+#ifdef OF_HAVE_BLOCKS
+ if (_block != NULL) {
+ if ([_socket isKindOfClass: [OFTCPSocket class]])
+ ((OFTCPSocketAsyncConnectBlock)_block)(_exception);
+ else
+ OFEnsure(0);
+ } else {
+#endif
+ if ([_delegate respondsToSelector:
+ @selector(socket:didConnectToHost:port:exception:)])
+ [_delegate socket: _socket
+ didConnectToHost: _host
+ port: _port
+ exception: _exception];
+#ifdef OF_HAVE_BLOCKS
+ }
+#endif
+}
+
+- (void)of_socketDidConnect: (id)sock exception: (id)exception
+{
+ if (exception != nil) {
+ /*
+ * self might be retained only by the pending async requests,
+ * which we're about to cancel.
+ */
+ [[self retain] autorelease];
+
+ [sock cancelAsyncRequests];
+ [sock of_closeSocket];
+
+ if (_socketAddressesIndex >= _socketAddresses.count) {
+ _exception = [exception retain];
+ [self didConnect];
+ } else {
+ /*
+ * We must not call it before returning, as otherwise
+ * the new socket would be removed from the queue upon
+ * return.
+ */
+ OFRunLoop *runLoop = [OFRunLoop currentRunLoop];
+ SEL selector =
+ @selector(tryNextAddressWithRunLoopMode:);
+ OFTimer *timer = [OFTimer
+ timerWithTimeInterval: 0
+ target: self
+ selector: selector
+ object: runLoop.currentMode
+ repeats: false];
+ [runLoop addTimer: timer forMode: runLoop.currentMode];
+ }
+
+ return;
+ }
+
+ [self didConnect];
+}
+
+- (id)of_connectionFailedExceptionForErrNo: (int)errNo
+{
+ return [OFConnectIPSocketFailedException exceptionWithHost: _host
+ port: _port
+ socket: _socket
+ errNo: errNo];
+}
+
+- (void)tryNextAddressWithRunLoopMode: (OFRunLoopMode)runLoopMode
+{
+ OFSocketAddress address = *(const OFSocketAddress *)
+ [_socketAddresses itemAtIndex: _socketAddressesIndex++];
+ int errNo;
+
+ OFSocketAddressSetIPPort(&address, _port);
+
+ if (![_socket of_createSocketForAddress: &address errNo: &errNo]) {
+ if (_socketAddressesIndex >= _socketAddresses.count) {
+ _exception = [[OFConnectIPSocketFailedException alloc]
+ initWithHost: _host
+ port: _port
+ socket: _socket
+ errNo: errNo];
+ [self didConnect];
+ return;
+ }
+
+ [self tryNextAddressWithRunLoopMode: runLoopMode];
+ return;
+ }
+
+#if defined(OF_NINTENDO_3DS) || defined(OF_WII)
+ /*
+ * On Wii and 3DS, connect() fails if non-blocking is enabled.
+ *
+ * Additionally, on Wii, there is no getsockopt(), so it would not be
+ * possible to get the error (or success) after connecting anyway.
+ *
+ * So for now, connecting is blocking on Wii and 3DS.
+ *
+ * FIXME: Use a different thread as a work around.
+ */
+ [_socket setCanBlock: true];
+#else
+ [_socket setCanBlock: false];
+#endif
+
+ if (![_socket of_connectSocketToAddress: &address errNo: &errNo]) {
+#if !defined(OF_NINTENDO_3DS) && !defined(OF_WII)
+# ifdef OF_WINDOWS
+ if (errNo == EINPROGRESS || errNo == EWOULDBLOCK) {
+# else
+ if (errNo == EINPROGRESS) {
+# endif
+ [OFRunLoop of_addAsyncConnectForSocket: _socket
+ mode: runLoopMode
+ delegate: self];
+ return;
+ } else {
+#endif
+ [_socket of_closeSocket];
+
+ if (_socketAddressesIndex >= _socketAddresses.count) {
+ _exception = [[OFConnectIPSocketFailedException
+ alloc] initWithHost: _host
+ port: _port
+ socket: _socket
+ errNo: errNo];
+ [self didConnect];
+ return;
+ }
+
+ [self tryNextAddressWithRunLoopMode: runLoopMode];
+ return;
+#if !defined(OF_NINTENDO_3DS) && !defined(OF_WII)
+ }
+#endif
+ }
+
+#if defined(OF_NINTENDO_3DS) || defined(OF_WII)
+ [_socket setCanBlock: 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: (OFRunLoopMode)runLoopMode
+{
+ @try {
+ OFSocketAddress address = OFSocketAddressParseIP(_host, _port);
+
+ _socketAddresses = [[OFData alloc]
+ initWithItems: &address
+ count: 1
+ itemSize: sizeof(address)];
+
+ [self tryNextAddressWithRunLoopMode: runLoopMode];
+ return;
+ } @catch (OFInvalidFormatException *e) {
+ }
+
+ [[OFThread DNSResolver]
+ asyncResolveAddressesForHost: _host
+ addressFamily: OFSocketAddressFamilyAny
+ runLoopMode: runLoopMode
+ delegate: self];
+}
+@end
Index: src/OFAtomic.h
==================================================================
--- src/OFAtomic.h
+++ src/OFAtomic.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
@@ -167,11 +167,11 @@
static OF_INLINE void
OFReleaseMemoryBarrier(void)
{
/* nop */
}
-#elif (defined(OF_X86_64) || defined(OF_X86)) && defined(__GNUC__)
+#elif (defined(OF_AMD64) || defined(OF_X86)) && defined(__GNUC__)
# import "platform/x86/OFAtomic.h"
#elif defined(OF_POWERPC) && defined(__GNUC__) && !defined(__APPLE_CC__) && \
!defined(OF_AIX)
# import "platform/PowerPC/OFAtomic.h"
#elif defined(OF_HAVE_ATOMIC_BUILTINS)
Index: src/OFBase64.h
==================================================================
--- src/OFBase64.h
+++ src/OFBase64.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
Index: src/OFBase64.m
==================================================================
--- src/OFBase64.m
+++ src/OFBase64.m
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
Index: src/OFBitSetCharacterSet.h
==================================================================
--- src/OFBitSetCharacterSet.h
+++ src/OFBitSetCharacterSet.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
Index: src/OFBitSetCharacterSet.m
==================================================================
--- src/OFBitSetCharacterSet.m
+++ src/OFBitSetCharacterSet.m
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
Index: src/OFBlock.h
==================================================================
--- src/OFBlock.h
+++ src/OFBlock.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
Index: src/OFBlock.m
==================================================================
--- src/OFBlock.m
+++ src/OFBlock.m
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
@@ -24,10 +24,11 @@
# import "OFAtomic.h"
#endif
#ifdef OF_HAVE_THREADS
# import "OFPlainMutex.h"
#endif
+#import "OFString.h"
#import "OFAllocFailedException.h"
#import "OFInitializationFailedException.h"
#if defined(OF_OBJFW_RUNTIME)
Index: src/OFBytesValue.h
==================================================================
--- src/OFBytesValue.h
+++ src/OFBytesValue.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
Index: src/OFBytesValue.m
==================================================================
--- src/OFBytesValue.m
+++ src/OFBytesValue.m
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
Index: src/OFCRC16.h
==================================================================
--- src/OFCRC16.h
+++ src/OFCRC16.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
Index: src/OFCRC16.m
==================================================================
--- src/OFCRC16.m
+++ src/OFCRC16.m
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
Index: src/OFCRC32.h
==================================================================
--- src/OFCRC32.h
+++ src/OFCRC32.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
Index: src/OFCRC32.m
==================================================================
--- src/OFCRC32.m
+++ src/OFCRC32.m
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
Index: src/OFCharacterSet.h
==================================================================
--- src/OFCharacterSet.h
+++ src/OFCharacterSet.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
Index: src/OFCharacterSet.m
==================================================================
--- src/OFCharacterSet.m
+++ src/OFCharacterSet.m
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
Index: src/OFCollection.h
==================================================================
--- src/OFCollection.h
+++ src/OFCollection.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
Index: src/OFColor.h
==================================================================
--- src/OFColor.h
+++ src/OFColor.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
Index: src/OFColor.m
==================================================================
--- src/OFColor.m
+++ src/OFColor.m
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
@@ -12,27 +12,151 @@
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
+
+#include
#import "OFColor.h"
#import "OFOnce.h"
+#import "OFString.h"
#import "OFInvalidArgumentException.h"
+
+@interface OFColor ()
++ (instancetype)of_alloc;
+@end
+
+@interface OFColorSingleton: OFColor
+@end
+
+@interface OFColorPlaceholder: OFColorSingleton
+@end
+
+#ifdef OF_OBJFW_RUNTIME
+@interface OFTaggedPointerColor: OFColorSingleton
+@end
+
+static const float allowedImprecision = 0.0000001;
+#endif
+
+static struct {
+ Class isa;
+} placeholder;
+
+#ifdef OF_OBJFW_RUNTIME
+static int colorTag;
+#endif
+
+@implementation OFColorSingleton
+- (instancetype)autorelease
+{
+ return self;
+}
+
+- (instancetype)retain
+{
+ return self;
+}
+
+- (void)release
+{
+}
+
+- (unsigned int)retainCount
+{
+ return OFMaxRetainCount;
+}
+@end
+
+@implementation OFColorPlaceholder
+- (instancetype)initWithRed: (float)red
+ green: (float)green
+ blue: (float)blue
+ alpha: (float)alpha
+{
+#ifdef OF_OBJFW_RUNTIME
+ uint8_t redInt = nearbyintf(red * 255);
+ uint8_t greenInt = nearbyintf(green * 255);
+ uint8_t blueInt = nearbyintf(blue * 255);
+
+ if (fabsf(red * 255 - redInt) < allowedImprecision &&
+ fabsf(green * 255 - greenInt) < allowedImprecision &&
+ fabsf(blue * 255 - blueInt) < allowedImprecision && alpha == 1) {
+ id ret = objc_createTaggedPointer(colorTag,
+ (uintptr_t)redInt << 16 | (uintptr_t)greenInt << 8 |
+ (uintptr_t)blueInt);
+
+ if (ret != nil)
+ return ret;
+ }
+#endif
+
+ return (id)[[OFColor of_alloc] initWithRed: red
+ green: green
+ blue: blue
+ alpha: alpha];
+}
+@end
+
+#ifdef OF_OBJFW_RUNTIME
+@implementation OFTaggedPointerColor
+- (void)getRed: (float *)red
+ green: (float *)green
+ blue: (float *)blue
+ alpha: (float *)alpha
+{
+ uintptr_t value = object_getTaggedPointerValue(self);
+
+ *red = (float)(value >> 16) / 255;
+ *green = (float)((value >> 8) & 0xFF) / 255;
+ *blue = (float)(value & 0xFF) / 255;
+
+ if (alpha != NULL)
+ *alpha = 1;
+}
+@end
+#endif
@implementation OFColor
++ (void)initialize
+{
+ if (self != [OFColor class])
+ return;
+
+ placeholder.isa = [OFColorPlaceholder class];
+#ifdef OF_OBJFW_RUNTIME
+ colorTag =
+ objc_registerTaggedPointerClass([OFTaggedPointerColor class]);
+#endif
+}
+
++ (instancetype)of_alloc
+{
+ return [super alloc];
+}
+
++ (instancetype)alloc
+{
+ if (self == [OFColor class])
+ return (id)&placeholder;
+
+ return [super alloc];
+}
+
#define PREDEFINED_COLOR(name, redValue, greenValue, blueValue) \
static OFColor *name##Color = nil; \
\
static void \
initPredefinedColor_##name(void) \
{ \
- name##Color = [[OFColor alloc] initWithRed: redValue \
- green: greenValue \
- blue: blueValue \
- alpha: 1]; \
+ name##Color = [[OFColorSingleton alloc] \
+ initWithRed: redValue \
+ green: greenValue \
+ blue: blueValue \
+ alpha: 1]; \
} \
\
+ (OFColor *)name \
{ \
static OFOnceControl onceControl = OFOnceControlInitValue; \
@@ -157,6 +281,17 @@
*blue = _blue;
if (alpha != NULL)
*alpha = _alpha;
}
+
+- (OFString *)description
+{
+ float red, green, blue, alpha;
+
+ [self getRed: &red green: &green blue: &blue alpha: &alpha];
+
+ return [OFString stringWithFormat:
+ @"<%@ red=%f green=%f blue=%f alpha=%f>",
+ self.class, red, green, blue, alpha];
+}
@end
Index: src/OFCondition.h
==================================================================
--- src/OFCondition.h
+++ src/OFCondition.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
@@ -44,11 +44,11 @@
* @ref broadcast.
*
* @note Waiting might have been interrupted by a signal. It is thus recommended
* to check the condition again after @ref wait returned!
*
- * @throw OFConditionWaitFailedException Waiting for the condition failed
+ * @throw OFWaitForConditionFailedException Waiting for the condition failed
*/
- (void)wait;
#ifdef OF_AMIGAOS
/**
@@ -57,11 +57,11 @@
*
* @note This is only available on AmigaOS!
*
* @param signalMask A pointer to a signal mask of Exec Signals to receive.
* This is modified and set to the mask of signals received.
- * @throw OFConditionWaitFailedException Waiting for the condition failed
+ * @throw OFWaitForConditionFailedException Waiting for the condition failed
*/
- (void)waitForConditionOrExecSignal: (ULONG *)signalMask;
#endif
/**
@@ -71,11 +71,11 @@
* @note Waiting might have been interrupted by a signal. It is thus recommended
* to check the condition again after @ref waitForTimeInterval: returned!
*
* @param timeInterval The time interval until the timeout is reached
* @return Whether the condition has been signaled
- * @throw OFConditionWaitFailedException Waiting for the condition failed
+ * @throw OFWaitForConditionFailedException Waiting for the condition failed
*/
- (bool)waitForTimeInterval: (OFTimeInterval)timeInterval;
#ifdef OF_AMIGAOS
/**
@@ -86,11 +86,11 @@
*
* @param timeInterval The time interval until the timeout is reached
* @param signalMask A pointer to a signal mask of Exec Signals to receive.
* This is modified and set to the mask of signals received.
* @return Whether the condition has been signaled or a signal received
- * @throw OFConditionWaitFailedException Waiting for the condition failed
+ * @throw OFWaitForConditionFailedException Waiting for the condition failed
*/
- (bool)waitForTimeInterval: (OFTimeInterval)timeInterval
orExecSignal: (ULONG *)signalMask;
#endif
@@ -101,11 +101,11 @@
* @note Waiting might have been interrupted by a signal. It is thus recommended
* to check the condition again after @ref waitUntilDate: returned!
*
* @param date The date at which the timeout is reached
* @return Whether the condition has been signaled
- * @throw OFConditionWaitFailedException Waiting for the condition failed
+ * @throw OFWaitForConditionFailedException Waiting for the condition failed
*/
- (bool)waitUntilDate: (OFDate *)date;
#ifdef OF_AMIGAOS
/**
@@ -116,26 +116,26 @@
*
* @param date The date at which the timeout is reached
* @param signalMask A pointer to a signal mask of Exec Signals to receive.
* This is modified and set to the mask of signals received.
* @return Whether the condition has been signaled or a signal received
- * @throw OFConditionWaitFailedException Waiting for the condition failed
+ * @throw OFWaitForConditionFailedException Waiting for the condition failed
*/
- (bool)waitUntilDate: (OFDate *)date orExecSignal: (ULONG *)signalMask;
#endif
/**
* @brief Signals the next waiting thread to continue.
*
- * @throw OFConditionSignalFailedException Signaling the condition failed
+ * @throw OFSignalConditionFailedException Signaling the condition failed
*/
- (void)signal;
/**
* @brief Signals all threads to continue.
*
- * @throw OFConditionBroadcastFailedException Broadcasting the condition failed
+ * @throw OFBroadcastConditionFailedException Broadcasting the condition failed
*/
- (void)broadcast;
@end
OF_ASSUME_NONNULL_END
Index: src/OFCondition.m
==================================================================
--- src/OFCondition.m
+++ src/OFCondition.m
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
@@ -17,16 +17,17 @@
#include
#import "OFCondition.h"
#import "OFDate.h"
+#import "OFString.h"
-#import "OFConditionBroadcastFailedException.h"
-#import "OFConditionSignalFailedException.h"
+#import "OFBroadcastConditionFailedException.h"
#import "OFConditionStillWaitingException.h"
-#import "OFConditionWaitFailedException.h"
#import "OFInitializationFailedException.h"
+#import "OFSignalConditionFailedException.h"
+#import "OFWaitForConditionFailedException.h"
@implementation OFCondition
+ (instancetype)condition
{
return [[[self alloc] init] autorelease];
@@ -66,11 +67,11 @@
- (void)wait
{
int error = OFPlainConditionWait(&_condition, &_mutex);
if (error != 0)
- @throw [OFConditionWaitFailedException
+ @throw [OFWaitForConditionFailedException
exceptionWithCondition: self
errNo: error];
}
#ifdef OF_AMIGAOS
@@ -78,11 +79,11 @@
{
int error = OFPlainConditionWaitOrExecSignal(&_condition, &_mutex,
signalMask);
if (error != 0)
- @throw [OFConditionWaitFailedException
+ @throw [OFWaitForConditionFailedException
exceptionWithCondition: self
errNo: error];
}
#endif
@@ -93,11 +94,11 @@
if (error == ETIMEDOUT)
return false;
if (error != 0)
- @throw [OFConditionWaitFailedException
+ @throw [OFWaitForConditionFailedException
exceptionWithCondition: self
errNo: error];
return true;
}
@@ -111,11 +112,11 @@
if (error == ETIMEDOUT)
return false;
if (error != 0)
- @throw [OFConditionWaitFailedException
+ @throw [OFWaitForConditionFailedException
exceptionWithCondition: self
errNo: error];
return true;
}
@@ -137,20 +138,20 @@
- (void)signal
{
int error = OFPlainConditionSignal(&_condition);
if (error != 0)
- @throw [OFConditionSignalFailedException
+ @throw [OFSignalConditionFailedException
exceptionWithCondition: self
errNo: error];
}
- (void)broadcast
{
int error = OFPlainConditionBroadcast(&_condition);
if (error != 0)
- @throw [OFConditionBroadcastFailedException
+ @throw [OFBroadcastConditionFailedException
exceptionWithCondition: self
errNo: error];
}
@end
Index: src/OFConstantString.h
==================================================================
--- src/OFConstantString.h
+++ src/OFConstantString.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
Index: src/OFConstantString.m
==================================================================
--- src/OFConstantString.m
+++ src/OFConstantString.m
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
@@ -583,20 +583,20 @@
[self finishInitialization];
[self writeToFile: path encoding: encoding];
}
#endif
-- (void)writeToURI: (OFURI *)URI
+- (void)writeToIRI: (OFIRI *)IRI
{
[self finishInitialization];
- [self writeToURI: URI];
+ [self writeToIRI: IRI];
}
-- (void)writeToURI: (OFURI *)URI encoding: (OFStringEncoding)encoding
+- (void)writeToIRI: (OFIRI *)IRI encoding: (OFStringEncoding)encoding
{
[self finishInitialization];
- [self writeToURI: URI encoding: encoding];
+ [self writeToIRI: IRI encoding: encoding];
}
#ifdef OF_HAVE_BLOCKS
- (void)enumerateLinesUsingBlock: (OFStringLineEnumerationBlock)block
{
Index: src/OFCountedMapTableSet.h
==================================================================
--- src/OFCountedMapTableSet.h
+++ src/OFCountedMapTableSet.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
Index: src/OFCountedMapTableSet.m
==================================================================
--- src/OFCountedMapTableSet.m
+++ src/OFCountedMapTableSet.m
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
@@ -19,11 +19,10 @@
#import "OFArray.h"
#import "OFMapTable.h"
#import "OFMutableMapTableSet.h"
#import "OFString.h"
#import "OFXMLAttribute.h"
-#import "OFXMLElement.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFEnumerationMutationException.h"
#import "OFOutOfRangeException.h"
@@ -112,56 +111,10 @@
} @catch (id e) {
[self release];
@throw e;
}
- return self;
-}
-
-- (instancetype)initWithSerialization: (OFXMLElement *)element
-{
- self = [self init];
-
- @try {
- void *pool = objc_autoreleasePoolPush();
-
- if (![element.name isEqual: @"OFCountedSet"] ||
- ![element.namespace isEqual: OFSerializationNS])
- @throw [OFInvalidArgumentException exception];
-
- for (OFXMLElement *objectElement in
- [element elementsForName: @"object"
- namespace: OFSerializationNS]) {
- void *pool2 = objc_autoreleasePoolPush();
- OFXMLElement *object;
- OFXMLAttribute *countAttribute;
- unsigned long long count;
-
- object = [objectElement elementsForNamespace:
- OFSerializationNS].firstObject;
- countAttribute =
- [objectElement attributeForName: @"count"];
-
- if (object == nil || countAttribute == nil)
- @throw [OFInvalidFormatException exception];
-
- count = countAttribute.unsignedLongLongValue;
- if (count > SIZE_MAX || count > UINTPTR_MAX)
- @throw [OFOutOfRangeException exception];
-
- [_mapTable setObject: (void *)(uintptr_t)count
- forKey: object.objectByDeserializing];
-
- objc_autoreleasePoolPop(pool2);
- }
-
- objc_autoreleasePoolPop(pool);
- } @catch (id e) {
- [self release];
- @throw e;
- }
-
return self;
}
- (size_t)countForObject: (id)object
{
Index: src/OFCountedSet.h
==================================================================
--- src/OFCountedSet.h
+++ src/OFCountedSet.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
Index: src/OFCountedSet.m
==================================================================
--- src/OFCountedSet.m
+++ src/OFCountedSet.m
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
@@ -19,11 +19,10 @@
#import "OFCountedSet.h"
#import "OFCountedMapTableSet.h"
#import "OFNumber.h"
#import "OFString.h"
-#import "OFXMLElement.h"
static struct {
Class isa;
} placeholder;
@@ -69,16 +68,10 @@
{
return (id)[[OFCountedMapTableSet alloc] initWithObject: firstObject
arguments: arguments];
}
-- (instancetype)initWithSerialization: (OFXMLElement *)element
-{
- return (id)[[OFCountedMapTableSet alloc]
- initWithSerialization: element];
-}
-
- (instancetype)retain
{
return self;
}
@@ -175,46 +168,10 @@
- (id)mutableCopy
{
return [[OFCountedSet alloc] initWithSet: self];
}
-- (OFXMLElement *)XMLElementBySerializing
-{
- void *pool = objc_autoreleasePoolPush();
- OFXMLElement *element;
-
- element = [OFXMLElement elementWithName: @"OFCountedSet"
- namespace: OFSerializationNS];
-
- for (id object in self) {
- void *pool2 = objc_autoreleasePoolPush();
-
- OFXMLElement *objectElement;
- OFString *count;
-
- count =
- [OFString stringWithFormat: @"%zu",
- [self countForObject: object]];
-
- objectElement = [OFXMLElement
- elementWithName: @"object"
- namespace: OFSerializationNS];
- [objectElement addAttributeWithName: @"count"
- stringValue: count];
- [objectElement addChild: object.XMLElementBySerializing];
- [element addChild: objectElement];
-
- objc_autoreleasePoolPop(pool2);
- }
-
- [element retain];
-
- objc_autoreleasePoolPop(pool);
-
- return [element autorelease];
-}
-
#ifdef OF_HAVE_BLOCKS
- (void)enumerateObjectsAndCountUsingBlock: (OFCountedSetEnumerationBlock)block
{
[self enumerateObjectsUsingBlock: ^ (id object, bool *stop) {
block(object, [self countForObject: object], stop);
Index: src/OFCryptographicHash.h
==================================================================
--- src/OFCryptographicHash.h
+++ src/OFCryptographicHash.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
ADDED src/OFDDPSocket.h
Index: src/OFDDPSocket.h
==================================================================
--- src/OFDDPSocket.h
+++ src/OFDDPSocket.h
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2008-2023 Jonathan Schleifer
+ *
+ * All rights reserved.
+ *
+ * This file is part of ObjFW. It may be distributed under the terms of the
+ * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
+ * the packaging of this file.
+ *
+ * Alternatively, it may be distributed under the terms of the GNU General
+ * Public License, either version 2 or 3, which can be found in the file
+ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
+ * file.
+ */
+
+#import "OFDatagramSocket.h"
+
+OF_ASSUME_NONNULL_BEGIN
+
+@class OFString;
+@class OFDictionary OF_GENERIC(KeyType, ObjectType);
+
+/**
+ * @protocol OFDDPSocketDelegate OFDDPSocket.h ObjFW/OFDDPSocket.h
+ *
+ * @brief A delegate for OFDDPSocket.
+ */
+@protocol OFDDPSocketDelegate
+@end
+
+/**
+ * @class OFDDPSocket OFDDPSocket.h ObjFW/OFDDPSocket.h
+ *
+ * @brief A class which provides methods to create and use AppleTalk DDP
+ * sockets.
+ *
+ * Addresses are of type @ref OFSocketAddress. You can use
+ * @ref OFSocketAddressMakeAppleTalk to create an address or
+ * @ref OFSocketAddressAppleTalkNetwork to get the AppleTalk network,
+ * @ref OFSocketAddressAppleTalkNode to get the AppleTalk node and
+ * @ref OFSocketAddressAppleTalkPort to get the port (sometimes also called
+ * socket number).
+ *
+ * @note On some systems, packets received with the wrong protocol type just
+ * get filtered by the kernel, however, on other systems, the packet is
+ * queued up and will raise an @ref OFReadFailedException with the
+ * @ref OFReadFailedException#errNo set to `ENOMSG` when being received.
+ *
+ * @warning Even though the OFCopying protocol is implemented, it does *not*
+ * return an independent copy of the socket, but instead retains it.
+ * This is so that the socket can be used as a key for a dictionary,
+ * so context can be associated with a socket. Using a socket in more
+ * than one thread at the same time is not thread-safe, even if copy
+ * was called to create one "instance" for every thread!
+ */
+@interface OFDDPSocket: OFDatagramSocket
+{
+#if !defined(OF_MACOS) && !defined(OF_WINDOWS)
+ uint8_t _protocolType;
+#endif
+ OF_RESERVE_IVARS(OFDDPSocket, 4)
+}
+
+/**
+ * @brief The delegate for asynchronous operations on the socket.
+ *
+ * @note The delegate is retained for as long as asynchronous operations are
+ * still ongoing.
+ */
+@property OF_NULLABLE_PROPERTY (assign, nonatomic)
+ id delegate;
+
+/**
+ * @brief Bind the socket to the specified network, node and port.
+ *
+ * @param network The network to bind to. 0 means any.
+ * @param node The node to bind to. 0 means "this node".
+ * @param port The port to bind to. 0 means to pick one and return it via the
+ * returned socket address.
+ * @param protocolType The DDP protocol type to use. Must not be 0. If you want
+ * to use DDP directly and not a protocol built on top of
+ * it, use 11 for compatibility with Open Transport.
+ * @return The address on which this socket can be reached
+ * @throw OFBindDDPSockeFailedException Binding failed
+ * @throw OFAlreadyOpenException The socket is already bound
+ */
+- (OFSocketAddress)bindToNetwork: (uint16_t)network
+ node: (uint8_t)node
+ port: (uint8_t)port
+ protocolType: (uint8_t)protocolType;
+@end
+
+OF_ASSUME_NONNULL_END
ADDED src/OFDDPSocket.m
Index: src/OFDDPSocket.m
==================================================================
--- src/OFDDPSocket.m
+++ src/OFDDPSocket.m
@@ -0,0 +1,280 @@
+/*
+ * Copyright (c) 2008-2023 Jonathan Schleifer
+ *
+ * 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
+
+#ifdef HAVE_FCNTL_H
+# include
+#endif
+
+#import "OFDDPSocket.h"
+#import "OFDictionary.h"
+#import "OFNumber.h"
+#import "OFPair.h"
+#import "OFSocket.h"
+#import "OFSocket+Private.h"
+
+#import "OFAlreadyOpenException.h"
+#import "OFBindDDPSocketFailedException.h"
+#import "OFGetOptionFailedException.h"
+#import "OFInvalidArgumentException.h"
+#import "OFNotOpenException.h"
+#import "OFOutOfRangeException.h"
+#import "OFReadFailedException.h"
+#import "OFSetOptionFailedException.h"
+#import "OFWriteFailedException.h"
+
+#ifdef HAVE_NET_IF_H
+# include
+#endif
+#ifdef HAVE_SYS_IOCTL_H
+# include
+#endif
+
+#ifdef OF_HAVE_NETAT_APPLETALK_H
+# include
+# include
+
+/* Unfortulately, there is no struct for the following in userland headers */
+struct ATInterfaceConfig {
+ char interfaceName[16];
+ unsigned int flags;
+ struct at_addr address, router;
+ unsigned short netStart, netEnd;
+ at_nvestr_t zoneName;
+};
+#endif
+
+@implementation OFDDPSocket
+@dynamic delegate;
+
+- (OFSocketAddress)bindToNetwork: (uint16_t)network
+ node: (uint8_t)node
+ port: (uint8_t)port
+ protocolType: (uint8_t)protocolType
+{
+#ifdef OF_MACOS
+ const int one = 1;
+ struct ATInterfaceConfig config = { { 0 } };
+#endif
+ OFSocketAddress address;
+#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC)
+ int flags;
+#endif
+
+ if (protocolType == 0)
+ @throw [OFInvalidArgumentException exception];
+
+ if (_socket != OFInvalidSocketHandle)
+ @throw [OFAlreadyOpenException exceptionWithObject: self];
+
+ address = OFSocketAddressMakeAppleTalk(network, node, port);
+
+#if defined(OF_MACOS)
+ if ((_socket = socket(address.sockaddr.at.sat_family,
+ SOCK_RAW | SOCK_CLOEXEC, protocolType)) == OFInvalidSocketHandle)
+#elif defined(OF_WINDOWS)
+ if ((_socket = socket(address.sockaddr.at.sat_family,
+ SOCK_DGRAM | SOCK_CLOEXEC, ATPROTO_BASE + protocolType)) ==
+ OFInvalidSocketHandle)
+#else
+ if ((_socket = socket(address.sockaddr.at.sat_family,
+ SOCK_DGRAM | SOCK_CLOEXEC, 0)) == OFInvalidSocketHandle)
+#endif
+ @throw [OFBindDDPSocketFailedException
+ exceptionWithNetwork: network
+ node: node
+ port: port
+ protocolType: protocolType
+ socket: self
+ errNo: OFSocketErrNo()];
+
+ _canBlock = true;
+
+#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC)
+ if ((flags = fcntl(_socket, F_GETFD, 0)) != -1)
+ fcntl(_socket, F_SETFD, flags | FD_CLOEXEC);
+#endif
+
+ if (bind(_socket, (struct sockaddr *)&address.sockaddr,
+ address.length) != 0) {
+ int errNo = OFSocketErrNo();
+
+ closesocket(_socket);
+ _socket = OFInvalidSocketHandle;
+
+ @throw [OFBindDDPSocketFailedException
+ exceptionWithNetwork: network
+ node: node
+ port: port
+ protocolType: protocolType
+ socket: self
+ errNo: errNo];
+ }
+
+ memset(&address, 0, sizeof(address));
+ address.family = OFSocketAddressFamilyAppleTalk;
+ address.length = (socklen_t)sizeof(address.sockaddr);
+
+ if (OFGetSockName(_socket, (struct sockaddr *)&address.sockaddr,
+ &address.length) != 0) {
+ int errNo = OFSocketErrNo();
+
+ closesocket(_socket);
+ _socket = OFInvalidSocketHandle;
+
+ @throw [OFBindDDPSocketFailedException
+ exceptionWithNetwork: network
+ node: node
+ port: port
+ protocolType: protocolType
+ socket: self
+ errNo: errNo];
+ }
+
+ if (address.sockaddr.at.sat_family != AF_APPLETALK) {
+ closesocket(_socket);
+ _socket = OFInvalidSocketHandle;
+
+ @throw [OFBindDDPSocketFailedException
+ exceptionWithNetwork: network
+ node: node
+ port: port
+ protocolType: protocolType
+ socket: self
+ errNo: EAFNOSUPPORT];
+ }
+
+#ifdef OF_MACOS
+ if (setsockopt(_socket, ATPROTO_NONE, DDP_STRIPHDR, &one,
+ sizeof(one)) != 0 || ioctl(_socket, _IOWR('a', 2,
+ struct ATInterfaceConfig), &config) != 0)
+ @throw [OFBindDDPSocketFailedException
+ exceptionWithNetwork: network
+ node: node
+ port: port
+ protocolType: protocolType
+ socket: self
+ errNo: OFSocketErrNo()];
+
+ OFSocketAddressSetAppleTalkNetwork(&address, config.address.s_net);
+ OFSocketAddressSetAppleTalkNode(&address, config.address.s_node);
+#endif
+
+#if !defined(OF_MACOS) && !defined(OF_WINDOWS)
+ _protocolType = protocolType;
+#endif
+
+ return address;
+}
+
+/*
+ * Everybody but macOS and Windows is probably using a netatalk-compatible
+ * implementation, which includes the protocol type as the first byte of the
+ * data instead of considering it part of the header.
+ *
+ * The following overrides prepend the protocol type when sending and compare
+ * and strip it when receiving.
+ *
+ * Unfortunately, the downside of this is that the only way to handle receiving
+ * a packet with the wrong protocol type is to throw an exception with errNo
+ * ENOMSG, while macOS and Windows just filter those out in the kernel.
+ * Returning 0 would mean this is indistinguishable from an empty packet, so it
+ * has to be an exception.
+ */
+#if !defined(OF_MACOS) && !defined(OF_WINDOWS)
+- (size_t)receiveIntoBuffer: (void *)buffer
+ length: (size_t)length
+ sender: (OFSocketAddress *)sender
+{
+ ssize_t ret;
+ uint8_t protocolType;
+ struct iovec iov[2] = {
+ { &protocolType, 1 },
+ { buffer, length }
+ };
+ struct msghdr msg = {
+ .msg_name = (sender != NULL
+ ? (struct sockaddr *)&sender->sockaddr : NULL),
+ .msg_namelen = (sender != NULL
+ ? (socklen_t)sizeof(sender->sockaddr) : 0),
+ .msg_iov = iov,
+ .msg_iovlen = 2
+ };
+
+ if (_socket == OFInvalidSocketHandle)
+ @throw [OFNotOpenException exceptionWithObject: self];
+
+ if ((ret = recvmsg(_socket, &msg, 0)) < 0)
+ @throw [OFReadFailedException
+ exceptionWithObject: self
+ requestedLength: length
+ errNo: OFSocketErrNo()];
+
+ if (ret < 1 || protocolType != _protocolType)
+ @throw [OFReadFailedException exceptionWithObject: self
+ requestedLength: length
+ errNo: ENOMSG];
+
+ if (sender != NULL) {
+ sender->length = msg.msg_namelen;
+ sender->family = OFSocketAddressFamilyAppleTalk;
+ }
+
+ return ret - 1;
+}
+
+- (void)sendBuffer: (const void *)buffer
+ length: (size_t)length
+ receiver: (const OFSocketAddress *)receiver
+{
+ struct iovec iov[2] = {
+ { &_protocolType, 1 },
+ { (void *)buffer, length }
+ };
+ struct msghdr msg = {
+ .msg_name = (struct sockaddr *)&receiver->sockaddr,
+ .msg_namelen = receiver->length,
+ .msg_iov = iov,
+ .msg_iovlen = 2
+ };
+ ssize_t bytesWritten;
+
+ if (_socket == OFInvalidSocketHandle)
+ @throw [OFNotOpenException exceptionWithObject: self];
+
+ if ((bytesWritten = sendmsg(_socket, &msg, 0)) < 0)
+ @throw [OFWriteFailedException
+ exceptionWithObject: self
+ requestedLength: length
+ bytesWritten: 0
+ errNo: OFSocketErrNo()];
+
+ if ((size_t)bytesWritten != length + 1) {
+ bytesWritten--;
+
+ if (bytesWritten < 0)
+ bytesWritten = 0;
+
+ @throw [OFWriteFailedException exceptionWithObject: self
+ requestedLength: length
+ bytesWritten: bytesWritten
+ errNo: 0];
+ }
+}
+#endif
+@end
Index: src/OFDNSQuery.h
==================================================================
--- src/OFDNSQuery.h
+++ src/OFDNSQuery.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
Index: src/OFDNSQuery.m
==================================================================
--- src/OFDNSQuery.m
+++ src/OFDNSQuery.m
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
@@ -41,11 +41,11 @@
void *pool = objc_autoreleasePoolPush();
if (![domainName hasSuffix: @"."])
domainName = [domainName stringByAppendingString: @"."];
- _domainName = [domainName copy];
+ _domainName = [domainName.lowercaseString copy];
_DNSClass = DNSClass;
_recordType = recordType;
objc_autoreleasePoolPop(pool);
} @catch (id e) {
Index: src/OFDNSResolver.h
==================================================================
--- src/OFDNSResolver.h
+++ src/OFDNSResolver.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
@@ -178,13 +178,13 @@
* @brief The minimum number of dots for a name to be considered absolute.
*/
@property (nonatomic) unsigned int minNumberOfDotsInAbsoluteName;
/**
- * @brief Whether the resolver uses TCP to talk to a name server.
+ * @brief Whether the resolver forces TCP to talk to a name server.
*/
-@property (nonatomic) bool usesTCP;
+@property (nonatomic) bool forcesTCP;
/**
* @brief The interval in seconds in which the config should be reloaded.
*
* Setting this to 0 disables config reloading.
Index: src/OFDNSResolver.m
==================================================================
--- src/OFDNSResolver.m
+++ src/OFDNSResolver.m
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
@@ -421,11 +421,11 @@
OFEnumerator OF_GENERIC(OFMutableArray *) *objectEnumerator;
OFMutableArray *array;
for (uint_fast16_t j = 0; j < count; j++) {
OFString *name = parseName(buffer, length, i,
- maxAllowedPointers);
+ maxAllowedPointers).lowercaseString;
OFDNSClass DNSClass;
OFDNSRecordType recordType;
uint32_t TTL;
uint16_t dataLength;
OFDNSResourceRecord *record;
@@ -676,18 +676,18 @@
{
_settings->_minNumberOfDotsInAbsoluteName =
minNumberOfDotsInAbsoluteName;
}
-- (bool)usesTCP
+- (bool)forcesTCP
{
- return _settings->_usesTCP;
+ return _settings->_forcesTCP;
}
-- (void)setUsesTCP: (bool)usesTCP
+- (void)setForcesTCP: (bool)forcesTCP
{
- _settings->_usesTCP = usesTCP;
+ _settings->_forcesTCP = forcesTCP;
}
- (OFTimeInterval)configReloadInterval
{
return _settings->_configReloadInterval;
@@ -721,11 +721,11 @@
forMode: runLoopMode];
nameServer = [context->_settings->_nameServers
objectAtIndex: context->_nameServersIndex];
- if (context->_settings->_usesTCP) {
+ if (context->_settings->_forcesTCP) {
OFEnsure(context->_TCPSocket == nil);
context->_TCPSocket = [[OFTCPSocket alloc] init];
[_TCPQueries setObject: context forKey: context->_TCPSocket];
@@ -908,11 +908,12 @@
return true;
if (context->_TCPSocket != nil) {
if ([_TCPQueries objectForKey: context->_TCPSocket] != context)
return true;
- } else if (!OFSocketAddressEqual(sender, &context->_usedNameServer))
+ } else if (sender == NULL ||
+ !OFSocketAddressEqual(sender, &context->_usedNameServer))
return true;
[context->_cancelTimer invalidate];
[context->_cancelTimer release];
context->_cancelTimer = nil;
@@ -945,14 +946,14 @@
/* TC */
if (buffer[2] & 0x02) {
OFRunLoopMode runLoopMode;
- if (context->_settings->_usesTCP)
+ if (context->_settings->_forcesTCP)
@throw [OFTruncatedDataException exception];
- context->_settings->_usesTCP = true;
+ context->_settings->_forcesTCP = true;
runLoopMode = [OFRunLoop currentRunLoop].currentMode;
[self of_sendQueryForContext: context
runLoopMode: runLoopMode];
return false;
}
Index: src/OFDNSResolverSettings.h
==================================================================
--- src/OFDNSResolverSettings.h
+++ src/OFDNSResolverSettings.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
@@ -29,15 +29,15 @@
OFArray OF_GENERIC(OFString *) *_nameServers;
OFString *_Nullable _localDomain;
OFArray OF_GENERIC(OFString *) *_searchDomains;
OFTimeInterval _timeout;
unsigned int _maxAttempts, _minNumberOfDotsInAbsoluteName;
- bool _usesTCP;
+ bool _forcesTCP;
OFTimeInterval _configReloadInterval;
@protected
OFDate *_lastConfigReload;
}
- (void)reload;
@end
OF_ASSUME_NONNULL_END
Index: src/OFDNSResolverSettings.m
==================================================================
--- src/OFDNSResolverSettings.m
+++ src/OFDNSResolverSettings.m
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
@@ -30,12 +30,16 @@
# import "OFWindowsRegistryKey.h"
#endif
#import "OFInvalidFormatException.h"
#import "OFOpenItemFailedException.h"
+#ifdef OF_WINDOWS
+# import "OFOpenWindowsRegistryKeyFailedException.h"
+#endif
#import "OFOutOfMemoryException.h"
#import "OFOutOfRangeException.h"
+#import "OFUndefinedKeyException.h"
#ifdef OF_WINDOWS
# define interface struct
# include
# undef interface
@@ -211,11 +215,11 @@
copy->_searchDomains = [_searchDomains copy];
copy->_timeout = _timeout;
copy->_maxAttempts = _maxAttempts;
copy->_minNumberOfDotsInAbsoluteName =
_minNumberOfDotsInAbsoluteName;
- copy->_usesTCP = _usesTCP;
+ copy->_forcesTCP = _forcesTCP;
copy->_configReloadInterval = _configReloadInterval;
copy->_lastConfigReload = [_lastConfigReload copy];
} @catch (id e) {
[copy release];
@throw e;
@@ -239,11 +243,11 @@
_searchDomains = nil;
_timeout = 2;
_maxAttempts = 3;
_minNumberOfDotsInAbsoluteName = 1;
- _usesTCP = false;
+ _forcesTCP = false;
#ifndef OF_NINTENDO_3DS
_configReloadInterval = 2;
#else
_configReloadInterval = 0;
#endif
@@ -266,11 +270,12 @@
return;
}
staticHosts = [OFMutableDictionary dictionary];
- while ((line = [file readLine]) != nil) {
+ while ((line =
+ [file readLineWithEncoding: [OFLocale encoding]]) != nil) {
OFArray *components, *hosts;
size_t pos;
OFString *address;
pos = [line rangeOfString: @"#"].location;
@@ -287,12 +292,14 @@
address = components.firstObject;
hosts = [components objectsInRange:
OFMakeRange(1, components.count - 1)];
for (OFString *host in hosts) {
- OFMutableArray *addresses =
- [staticHosts objectForKey: host];
+ OFMutableArray *addresses;
+
+ host = host.lowercaseString;
+ addresses = [staticHosts objectForKey: host];
if (addresses == nil) {
addresses = [OFMutableArray array];
[staticHosts setObject: addresses forKey: host];
}
@@ -340,11 +347,11 @@
} else if ([option hasPrefix: @"reload-period:"]) {
option = [option substringFromIndex: 14];
_configReloadInterval = option.unsignedLongLongValue;
} else if ([option isEqual: @"tcp"])
- _usesTCP = true;
+ _forcesTCP = true;
} @catch (OFInvalidFormatException *e) {
}
}
- (void)parseResolvConf: (OFString *)path
@@ -366,11 +373,12 @@
}
if (nameServers == nil)
nameServers = [OFMutableArray array];
- while ((line = [file readLine]) != nil) {
+ while ((line =
+ [file readLineWithEncoding: [OFLocale encoding]]) != nil) {
void *pool2 = objc_autoreleasePoolPush();
size_t pos;
OFArray *components, *arguments;
OFString *option;
@@ -443,14 +451,19 @@
if (GetNetworkParams(fixedInfo, &length) != ERROR_SUCCESS)
return;
nameServers = [OFMutableArray array];
- for (iter = &fixedInfo->DnsServerList; iter != NULL; iter = iter->Next)
- [nameServers addObject:
+ for (iter = &fixedInfo->DnsServerList; iter != NULL;
+ iter = iter->Next) {
+ OFString *nameServer =
[OFString stringWithCString: iter->IpAddress.String
- encoding: encoding]];
+ encoding: encoding];
+
+ if (nameServer.length > 0)
+ [nameServers addObject: nameServer];
+ }
if (nameServers.count > 0) {
[nameServers makeImmutable];
_nameServers = [nameServers copy];
}
@@ -489,12 +502,14 @@
address = components.firstObject;
hosts = [components objectsInRange:
OFMakeRange(1, components.count - 1)];
for (OFString *host in hosts) {
- OFMutableArray *addresses =
- [staticHosts objectForKey: host];
+ OFMutableArray *addresses;
+
+ host = host.lowercaseString;
+ addresses = [staticHosts objectForKey: host];
if (addresses == nil) {
addresses = [OFMutableArray array];
[staticHosts setObject: addresses forKey: host];
}
@@ -598,14 +613,14 @@
}
#endif
- (void)reload
{
- void *pool;
#ifdef OF_WINDOWS
- OFString *path;
+ OFString *path = nil;
#endif
+ void *pool;
/*
* TODO: Rather than reparsing every time, check what actually changed
* (mtime) and only reset those.
*/
@@ -618,18 +633,26 @@
[self setDefaults];
#if defined(OF_WINDOWS)
# ifdef OF_HAVE_FILES
- OFWindowsRegistryKey *key = [[OFWindowsRegistryKey localMachineKey]
- openSubkeyAtPath: @"SYSTEM\\CurrentControlSet\\Services\\"
- @"Tcpip\\Parameters"
- accessRights: KEY_QUERY_VALUE
- options: 0];
- path = [[[key stringForValueNamed: @"DataBasePath"]
- stringByAppendingPathComponent: @"hosts"]
- stringByExpandingWindowsEnvironmentStrings];
+ @try {
+ OFWindowsRegistryKey *key;
+
+ key = [[OFWindowsRegistryKey localMachineKey]
+ openSubkeyAtPath: @"SYSTEM\\CurrentControlSet\\Services\\"
+ @"Tcpip\\Parameters"
+ accessRights: KEY_QUERY_VALUE
+ options: 0];
+ path = [[[key stringForValueNamed: @"DataBasePath"]
+ stringByAppendingPathComponent: @"hosts"]
+ stringByExpandingWindowsEnvironmentStrings];
+ } @catch (OFOpenWindowsRegistryKeyFailedException *e) {
+ /* Ignore */
+ } @catch (OFUndefinedKeyException *e) {
+ /* Ignore */
+ }
if (path != nil)
[self parseHosts: path];
# endif
Index: src/OFDNSResourceRecord.h
==================================================================
--- src/OFDNSResourceRecord.h
+++ src/OFDNSResourceRecord.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
Index: src/OFDNSResourceRecord.m
==================================================================
--- src/OFDNSResourceRecord.m
+++ src/OFDNSResourceRecord.m
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
Index: src/OFDNSResponse.h
==================================================================
--- src/OFDNSResponse.h
+++ src/OFDNSResponse.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
Index: src/OFDNSResponse.m
==================================================================
--- src/OFDNSResponse.m
+++ src/OFDNSResponse.m
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
Index: src/OFData+CryptographicHashing.h
==================================================================
--- src/OFData+CryptographicHashing.h
+++ src/OFData+CryptographicHashing.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
Index: src/OFData+CryptographicHashing.m
==================================================================
--- src/OFData+CryptographicHashing.m
+++ src/OFData+CryptographicHashing.m
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
Index: src/OFData+MessagePackParsing.h
==================================================================
--- src/OFData+MessagePackParsing.h
+++ src/OFData+MessagePackParsing.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
Index: src/OFData+MessagePackParsing.m
==================================================================
--- src/OFData+MessagePackParsing.m
+++ src/OFData+MessagePackParsing.m
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
Index: src/OFData.h
==================================================================
--- src/OFData.h
+++ src/OFData.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
@@ -12,19 +12,18 @@
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFObject.h"
-#import "OFSerialization.h"
#import "OFMessagePackRepresentation.h"
/*! @file */
OF_ASSUME_NONNULL_BEGIN
+@class OFIRI;
@class OFString;
-@class OFURI;
/**
* @brief Options for searching in data.
*
* This is a bit mask.
@@ -36,16 +35,13 @@
/**
* @class OFData OFData.h ObjFW/OFData.h
*
* @brief A class for storing arbitrary data in an array.
- *
- * For security reasons, serialization and deserialization is only implemented
- * for OFData with item size 1.
*/
@interface OFData: OFObject
+ OFMessagePackRepresentation>
{
unsigned char *_Nullable _items;
size_t _count, _itemSize;
bool _freeWhenDone;
@private
@@ -165,16 +161,16 @@
+ (instancetype)dataWithContentsOfFile: (OFString *)path;
#endif
/**
* @brief Creates a new OFData with an item size of 1, containing the data of
- * the specified URI.
+ * the specified IRI.
*
- * @param URI The URI to the contents for the OFData
+ * @param IRI The IRI to the contents for the OFData
* @return A new autoreleased OFData
*/
-+ (instancetype)dataWithContentsOfURI: (OFURI *)URI;
++ (instancetype)dataWithContentsOfIRI: (OFIRI *)IRI;
/**
* @brief Creates a new OFData with an item size of 1, containing the data of
* the hex string representation.
*
@@ -268,16 +264,16 @@
- (instancetype)initWithContentsOfFile: (OFString *)path;
#endif
/**
* @brief Initializes an already allocated OFData with an item size of 1,
- * containing the data of the specified URI.
+ * containing the data of the specified IRI.
*
- * @param URI The URI to the contents for the OFData
+ * @param IRI The IRI to the contents for the OFData
* @return A new autoreleased OFData
*/
-- (instancetype)initWithContentsOfURI: (OFURI *)URI;
+- (instancetype)initWithContentsOfIRI: (OFIRI *)IRI;
/**
* @brief Initializes an already allocated OFData with an item size of 1,
* containing the data of the hex string representation.
*
@@ -344,17 +340,17 @@
*/
- (void)writeToFile: (OFString *)path;
#endif
/**
- * @brief Writes the OFData to the specified URI.
+ * @brief Writes the OFData to the specified IRI.
*
- * @param URI The URI to write to
+ * @param IRI The IRI to write to
*/
-- (void)writeToURI: (OFURI *)URI;
+- (void)writeToIRI: (OFIRI *)IRI;
@end
OF_ASSUME_NONNULL_END
#import "OFMutableData.h"
#import "OFData+CryptographicHashing.h"
#import "OFData+MessagePackParsing.h"
Index: src/OFData.m
==================================================================
--- src/OFData.m
+++ src/OFData.m
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
@@ -24,16 +24,15 @@
#import "OFDictionary.h"
#ifdef OF_HAVE_FILES
# import "OFFile.h"
# import "OFFileManager.h"
#endif
+#import "OFIRI.h"
+#import "OFIRIHandler.h"
#import "OFStream.h"
#import "OFString.h"
#import "OFSystemInfo.h"
-#import "OFURI.h"
-#import "OFURIHandler.h"
-#import "OFXMLElement.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFNotImplementedException.h"
#import "OFOutOfMemoryException.h"
@@ -91,13 +90,13 @@
{
return [[[self alloc] initWithContentsOfFile: path] autorelease];
}
#endif
-+ (instancetype)dataWithContentsOfURI: (OFURI *)URI
++ (instancetype)dataWithContentsOfIRI: (OFIRI *)IRI
{
- return [[[self alloc] initWithContentsOfURI: URI] autorelease];
+ return [[[self alloc] initWithContentsOfIRI: IRI] autorelease];
}
+ (instancetype)dataWithStringRepresentation: (OFString *)string
{
return [[[self alloc]
@@ -173,40 +172,36 @@
#ifdef OF_HAVE_FILES
- (instancetype)initWithContentsOfFile: (OFString *)path
{
char *buffer = NULL;
- unsigned long long size;
-
- @try {
- OFFile *file;
-
- size = [[OFFileManager defaultManager]
- attributesOfItemAtPath: path].fileSize;
-
-# if ULLONG_MAX > SIZE_MAX
- if (size > SIZE_MAX)
- @throw [OFOutOfRangeException exception];
-# endif
-
- buffer = OFAllocMemory((size_t)size, 1);
- file = [[OFFile alloc] initWithPath: path mode: @"r"];
- @try {
- [file readIntoBuffer: buffer exactLength: (size_t)size];
- } @finally {
- [file release];
- }
+ OFStreamOffset fileSize;
+
+ @try {
+ void *pool = objc_autoreleasePoolPush();
+ OFFile *file = [OFFile fileWithPath: path mode: @"r"];
+ fileSize = [file seekToOffset: 0 whence: OFSeekEnd];
+
+ if (fileSize < 0 || (unsigned long long)fileSize > SIZE_MAX)
+ @throw [OFOutOfRangeException exception];
+
+ [file seekToOffset: 0 whence: OFSeekSet];
+
+ buffer = OFAllocMemory((size_t)fileSize, 1);
+ [file readIntoBuffer: buffer exactLength: (size_t)fileSize];
+
+ objc_autoreleasePoolPop(pool);
} @catch (id e) {
OFFreeMemory(buffer);
[self release];
@throw e;
}
@try {
self = [self initWithItemsNoCopy: buffer
- count: (size_t)size
+ count: (size_t)fileSize
freeWhenDone: true];
} @catch (id e) {
OFFreeMemory(buffer);
@throw e;
}
@@ -213,17 +208,17 @@
return self;
}
#endif
-- (instancetype)initWithContentsOfURI: (OFURI *)URI
+- (instancetype)initWithContentsOfIRI: (OFIRI *)IRI
{
self = [super init];
@try {
void *pool = objc_autoreleasePoolPush();
- OFStream *stream = [OFURIHandler openItemAtURI: URI mode: @"r"];
+ OFStream *stream = [OFIRIHandler openItemAtIRI: IRI mode: @"r"];
size_t pageSize;
unsigned char *buffer;
_count = 0;
_itemSize = 1;
@@ -336,33 +331,10 @@
}
if (!mutable)
[(OFMutableData *)self makeImmutable];
- return self;
-}
-
-- (instancetype)initWithSerialization: (OFXMLElement *)element
-{
- void *pool = objc_autoreleasePoolPush();
- OFString *stringValue;
-
- @try {
- if (![element.name isEqual: self.className] ||
- ![element.namespace isEqual: OFSerializationNS])
- @throw [OFInvalidArgumentException exception];
-
- stringValue = element.stringValue;
- } @catch (id e) {
- [self release];
- @throw e;
- }
-
- self = [self initWithBase64EncodedString: stringValue];
-
- objc_autoreleasePoolPop(pool);
-
return self;
}
- (void)dealloc
{
@@ -589,39 +561,17 @@
[file release];
}
}
#endif
-- (void)writeToURI: (OFURI *)URI
+- (void)writeToIRI: (OFIRI *)IRI
{
void *pool = objc_autoreleasePoolPush();
- [[OFURIHandler openItemAtURI: URI mode: @"w"] writeData: self];
-
- objc_autoreleasePoolPop(pool);
-}
-
-- (OFXMLElement *)XMLElementBySerializing
-{
- void *pool;
- OFXMLElement *element;
-
- if (_itemSize != 1)
- @throw [OFNotImplementedException exceptionWithSelector: _cmd
- object: self];
-
- pool = objc_autoreleasePoolPush();
- element = [OFXMLElement
- elementWithName: self.className
- namespace: OFSerializationNS
- stringValue: OFBase64Encode(_items, _count * _itemSize)];
-
- [element retain];
-
- objc_autoreleasePoolPop(pool);
-
- return [element autorelease];
+ [[OFIRIHandler openItemAtIRI: IRI mode: @"w"] writeData: self];
+
+ objc_autoreleasePoolPop(pool);
}
- (OFData *)messagePackRepresentation
{
OFMutableData *data;
Index: src/OFDatagramSocket.h
==================================================================
--- src/OFDatagramSocket.h
+++ src/OFDatagramSocket.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
@@ -158,11 +158,11 @@
* @throw OFReadFailedException Receiving failed
* @throw OFNotOpenException The socket is not open
*/
- (size_t)receiveIntoBuffer: (void *)buffer
length: (size_t)length
- sender: (OFSocketAddress *)sender;
+ sender: (nullable OFSocketAddress *)sender;
/**
* @brief Asynchronously receives a datagram and stores it into the specified
* buffer.
*
Index: src/OFDatagramSocket.m
==================================================================
--- src/OFDatagramSocket.m
+++ src/OFDatagramSocket.m
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
@@ -171,53 +171,68 @@
ssize_t ret;
if (_socket == OFInvalidSocketHandle)
@throw [OFNotOpenException exceptionWithObject: self];
- sender->length = (socklen_t)sizeof(sender->sockaddr);
+ if (sender != NULL)
+ sender->length = (socklen_t)sizeof(sender->sockaddr);
#ifndef OF_WINDOWS
if ((ret = recvfrom(_socket, buffer, length, 0,
- (struct sockaddr *)&sender->sockaddr, &sender->length)) < 0)
+ (sender != NULL ? (struct sockaddr *)&sender->sockaddr : NULL),
+ (sender != NULL ? &sender->length : NULL))) < 0)
@throw [OFReadFailedException
exceptionWithObject: self
requestedLength: length
errNo: OFSocketErrNo()];
#else
if (length > INT_MAX)
@throw [OFOutOfRangeException exception];
if ((ret = recvfrom(_socket, buffer, (int)length, 0,
- (struct sockaddr *)&sender->sockaddr, &sender->length)) < 0)
+ (sender != NULL ? (struct sockaddr *)&sender->sockaddr : NULL),
+ (sender != NULL ? &sender->length : NULL))) < 0)
@throw [OFReadFailedException
exceptionWithObject: self
requestedLength: length
errNo: OFSocketErrNo()];
#endif
- switch (((struct sockaddr *)&sender->sockaddr)->sa_family) {
- case AF_INET:
- sender->family = OFSocketAddressFamilyIPv4;
- break;
+ if (sender != NULL) {
+ struct sockaddr *sa = (struct sockaddr *)&sender->sockaddr;
+
+ if (sender->length >= (socklen_t)sizeof(sa->sa_family)) {
+ switch (sa->sa_family) {
+ case AF_INET:
+ sender->family = OFSocketAddressFamilyIPv4;
+ break;
#ifdef OF_HAVE_IPV6
- case AF_INET6:
- sender->family = OFSocketAddressFamilyIPv6;
- break;
+ case AF_INET6:
+ sender->family = OFSocketAddressFamilyIPv6;
+ break;
#endif
#ifdef OF_HAVE_UNIX_SOCKETS
- case AF_UNIX:
- sender->family = OFSocketAddressFamilyUNIX;
- break;
+ case AF_UNIX:
+ sender->family = OFSocketAddressFamilyUNIX;
+ break;
#endif
#ifdef OF_HAVE_IPX
- case AF_IPX:
- sender->family = OFSocketAddressFamilyIPX;
- break;
+ case AF_IPX:
+ sender->family = OFSocketAddressFamilyIPX;
+ break;
+#endif
+#ifdef OF_HAVE_APPLETALK
+ case AF_APPLETALK:
+ sender->family = OFSocketAddressFamilyAppleTalk;
+ break;
#endif
- default:
- sender->family = OFSocketAddressFamilyUnknown;
- break;
+ default:
+ sender->family = OFSocketAddressFamilyUnknown;
+ break;
+ }
+ } else
+ sender->family = OFSocketAddressFamilyUnknown;
}
return ret;
}
Index: src/OFDate.h
==================================================================
--- src/OFDate.h
+++ src/OFDate.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
@@ -13,11 +13,10 @@
* file.
*/
#import "OFObject.h"
#import "OFMessagePackRepresentation.h"
-#import "OFSerialization.h"
OF_ASSUME_NONNULL_BEGIN
@class OFString;
@class OFConstantString;
@@ -28,11 +27,11 @@
* @brief A class for storing, accessing and comparing dates.
*/
#ifndef OF_DATE_M
OF_SUBCLASSING_RESTRICTED
#endif
-@interface OFDate: OFObject
{
OFTimeInterval _seconds;
}
Index: src/OFDate.m
==================================================================
--- src/OFDate.m
+++ src/OFDate.m
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
@@ -32,11 +32,10 @@
#endif
#import "OFStrPTime.h"
#import "OFString.h"
#import "OFSystemInfo.h"
#import "OFXMLAttribute.h"
-#import "OFXMLElement.h"
#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFOutOfMemoryException.h"
@@ -494,43 +493,10 @@
objc_autoreleasePoolPop(pool);
return [self initWithTimeIntervalSince1970: seconds];
}
-- (instancetype)initWithSerialization: (OFXMLElement *)element
-{
- OFTimeInterval seconds;
-
- @try {
- void *pool = objc_autoreleasePoolPush();
- unsigned long long value;
-
- if (![element.name isEqual: @"OFDate"] ||
- ![element.namespace isEqual: OFSerializationNS])
- @throw [OFInvalidArgumentException exception];
-
- if (![[element attributeForName: @"encoding"].stringValue
- isEqual: @"hex"])
- @throw [OFInvalidFormatException exception];
-
- value = [element unsignedLongLongValueWithBase: 16];
-
- if (value > UINT64_MAX)
- @throw [OFOutOfRangeException exception];
-
- seconds = OFFromBigEndianDouble(OFRawUInt64ToDouble(
- OFToBigEndian64(value)));
-
- objc_autoreleasePoolPop(pool);
- } @catch (id e) {
- [self release];
- @throw e;
- }
-
- return [self initWithTimeIntervalSince1970: seconds];
-}
-
- (bool)isEqual: (id)object
{
OFDate *otherDate;
if (object == self)
@@ -585,30 +551,10 @@
- (OFString *)description
{
return [self dateStringWithFormat: @"%Y-%m-%dT%H:%M:%SZ"];
}
-- (OFXMLElement *)XMLElementBySerializing
-{
- void *pool = objc_autoreleasePoolPush();
- OFXMLElement *element;
-
- element = [OFXMLElement elementWithName: @"OFDate"
- namespace: OFSerializationNS];
-
- [element addAttributeWithName: @"encoding" stringValue: @"hex"];
- element.stringValue = [OFString stringWithFormat: @"%016" PRIx64,
- OFFromBigEndian64(OFDoubleToRawUInt64(OFToBigEndianDouble(
- self.timeIntervalSince1970)))];
-
- [element retain];
-
- objc_autoreleasePoolPop(pool);
-
- return [element autorelease];
-}
-
- (OFData *)messagePackRepresentation
{
void *pool = objc_autoreleasePoolPush();
OFTimeInterval timeInterval = self.timeIntervalSince1970;
int64_t seconds = (int64_t)timeInterval;
Index: src/OFDictionary.h
==================================================================
--- src/OFDictionary.h
+++ src/OFDictionary.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
@@ -23,11 +23,10 @@
#include
#import "OFObject.h"
#import "OFCollection.h"
#import "OFEnumerator.h"
-#import "OFSerialization.h"
#import "OFJSONRepresentation.h"
#import "OFMessagePackRepresentation.h"
OF_ASSUME_NONNULL_BEGIN
@@ -75,11 +74,11 @@
*
* @note Subclasses must implement @ref objectForKey:, @ref count and
* @ref keyEnumerator.
*/
@interface OFDictionary OF_GENERIC(KeyType, ObjectType): OFObject
#if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN)
# define KeyType id
# define ObjectType id
#endif
Index: src/OFDictionary.m
==================================================================
--- src/OFDictionary.m
+++ src/OFDictionary.m
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
@@ -15,31 +15,26 @@
#include "config.h"
#include
-#include
-
#import "OFDictionary.h"
#import "OFArray.h"
#import "OFCharacterSet.h"
#import "OFData.h"
#import "OFEnumerator.h"
#import "OFMapTableDictionary.h"
#import "OFString.h"
-#import "OFXMLElement.h"
#import "OFInvalidArgumentException.h"
#import "OFOutOfRangeException.h"
#import "OFUndefinedKeyException.h"
static struct {
Class isa;
} placeholder;
-static OFCharacterSet *URIQueryPartAllowedCharacterSet = nil;
-
@interface OFDictionary ()
- (OFString *)
of_JSONRepresentationWithOptions: (OFJSONRepresentationOptions)options
depth: (size_t)depth;
@end
@@ -55,15 +50,10 @@
}
- (instancetype)initWithDictionary: (OFDictionary *)dictionary;
@end
-OF_DIRECT_MEMBERS
-@interface OFURIQueryPartAllowedCharacterSet: OFCharacterSet
-+ (OFCharacterSet *)URIQueryPartAllowedCharacterSet;
-@end
-
@implementation OFDictionaryPlaceholder
- (instancetype)init
{
return (id)[[OFMapTableDictionary alloc] init];
}
@@ -113,16 +103,10 @@
{
return (id)[[OFMapTableDictionary alloc] initWithKey: firstKey
arguments: arguments];
}
-- (instancetype)initWithSerialization: (OFXMLElement *)element
-{
- return (id)[[OFMapTableDictionary alloc]
- initWithSerialization: element];
-}
-
- (instancetype)retain
{
return self;
}
@@ -137,70 +121,10 @@
- (void)dealloc
{
OF_DEALLOC_UNSUPPORTED
}
-@end
-
-@implementation OFURIQueryPartAllowedCharacterSet
-+ (void)initialize
-{
- if (self != [OFURIQueryPartAllowedCharacterSet class])
- return;
-
- URIQueryPartAllowedCharacterSet =
- [[OFURIQueryPartAllowedCharacterSet alloc] init];
-}
-
-+ (OFCharacterSet *)URIQueryPartAllowedCharacterSet
-{
- return URIQueryPartAllowedCharacterSet;
-}
-
-- (instancetype)autorelease
-{
- return self;
-}
-
-- (instancetype)retain
-{
- return self;
-}
-
-- (void)release
-{
-}
-
-- (unsigned int)retainCount
-{
- return OFMaxRetainCount;
-}
-
-- (bool)characterIsMember: (OFUnichar)character
-{
- if (character < CHAR_MAX && OFASCIIIsAlnum(character))
- return true;
-
- switch (character) {
- case '-':
- case '.':
- case '_':
- case '~':
- case '!':
- case '$':
- case '\'':
- case '(':
- case ')':
- case '*':
- case '+':
- case ',':
- case ';':
- return true;
- default:
- return false;
- }
-}
@end
@implementation OFDictionary
+ (void)initialize
{
@@ -330,15 +254,10 @@
return ret;
}
- (instancetype)initWithKey: (id)firstKey arguments: (va_list)arguments
{
- OF_INVALID_INIT_METHOD
-}
-
-- (instancetype)initWithSerialization: (OFXMLElement *)element
-{
OF_INVALID_INIT_METHOD
}
- (id)objectForKey: (id)key
{
@@ -510,10 +429,11 @@
- (int)countByEnumeratingWithState: (OFFastEnumerationState *)state
objects: (id *)objects
count: (int)count
{
+ static unsigned long dummyMutations;
OFEnumerator *enumerator;
int i;
memcpy(&enumerator, state->extra, sizeof(enumerator));
@@ -521,11 +441,11 @@
enumerator = [self keyEnumerator];
memcpy(state->extra, &enumerator, sizeof(enumerator));
}
state->itemsPtr = objects;
- state->mutationsPtr = (unsigned long *)self;
+ state->mutationsPtr = &dummyMutations;
for (i = 0; i < count; i++) {
id object = [enumerator nextObject];
if (object == nil)
@@ -637,54 +557,10 @@
objc_autoreleasePoolPop(pool);
return ret;
}
-- (OFXMLElement *)XMLElementBySerializing
-{
- void *pool = objc_autoreleasePoolPush();
- OFXMLElement *element;
- OFEnumerator *keyEnumerator, *objectEnumerator;
- id key, object;
-
- if ([self isKindOfClass: [OFMutableDictionary class]])
- element = [OFXMLElement elementWithName: @"OFMutableDictionary"
- namespace: OFSerializationNS];
- else
- element = [OFXMLElement elementWithName: @"OFDictionary"
- namespace: OFSerializationNS];
-
- keyEnumerator = [self keyEnumerator];
- objectEnumerator = [self objectEnumerator];
- while ((key = [keyEnumerator nextObject]) != nil &&
- (object = [objectEnumerator nextObject]) != nil) {
- void *pool2 = objc_autoreleasePoolPush();
- OFXMLElement *keyElement, *objectElement;
-
- keyElement = [OFXMLElement
- elementWithName: @"key"
- namespace: OFSerializationNS];
- [keyElement addChild: key.XMLElementBySerializing];
-
- objectElement = [OFXMLElement
- elementWithName: @"object"
- namespace: OFSerializationNS];
- [objectElement addChild: object.XMLElementBySerializing];
-
- [element addChild: keyElement];
- [element addChild: objectElement];
-
- objc_autoreleasePoolPop(pool2);
- }
-
- [element retain];
-
- objc_autoreleasePoolPop(pool);
-
- return [element autorelease];
-}
-
- (OFString *)JSONRepresentation
{
return [self of_JSONRepresentationWithOptions: 0 depth: 0];
}
@@ -824,11 +700,11 @@
[data addItems: child.items count: child.count];
objc_autoreleasePoolPop(pool2);
}
- assert(i == count);
+ OFAssert(i == count);
[data makeImmutable];
objc_autoreleasePoolPop(pool);
ADDED src/OFEmbeddedIRIHandler.h
Index: src/OFEmbeddedIRIHandler.h
==================================================================
--- src/OFEmbeddedIRIHandler.h
+++ src/OFEmbeddedIRIHandler.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2008-2023 Jonathan Schleifer
+ *
+ * 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 "OFIRIHandler.h"
+
+OF_ASSUME_NONNULL_BEGIN
+
+@interface OFEmbeddedIRIHandler: OFIRIHandler
+@end
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+/**
+ * @brief Register a file for the `embedded:` IRI scheme.
+ *
+ * Usually, you should not use the directly, but rather generate a source file
+ * for a file to be embedded using the `objfw-embed` tool.
+ *
+ * @param path The path to the file under the `embedded:` scheme. This is not
+ * retained, so you must either pass a constant string or pass a
+ * string that is already retained!
+ * @param bytes The raw bytes for the file
+ * @param size The size of the file
+ */
+extern void OFRegisterEmbeddedFile(OFString *path, const uint8_t *bytes,
+ size_t size);
+#ifdef __cplusplus
+}
+#endif
+
+OF_ASSUME_NONNULL_END
ADDED src/OFEmbeddedIRIHandler.m
Index: src/OFEmbeddedIRIHandler.m
==================================================================
--- src/OFEmbeddedIRIHandler.m
+++ src/OFEmbeddedIRIHandler.m
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2008-2023 Jonathan Schleifer
+ *
+ * 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
+#include
+#include
+
+#import "OFEmbeddedIRIHandler.h"
+#import "OFIRI.h"
+#import "OFMemoryStream.h"
+
+#import "OFInvalidArgumentException.h"
+#import "OFOpenItemFailedException.h"
+
+#ifdef OF_HAVE_THREADS
+# import "OFOnce.h"
+# import "OFPlainMutex.h"
+#endif
+
+struct EmbeddedFile {
+ OFString *path;
+ const uint8_t *bytes;
+ size_t size;
+} *embeddedFiles = NULL;
+size_t numEmbeddedFiles = 0;
+#ifdef OF_HAVE_THREADS
+static OFPlainMutex mutex;
+static OFOnceControl mutexOnceControl = OFOnceControlInitValue;
+
+static void
+initMutex(void)
+{
+ OFEnsure(OFPlainMutexNew(&mutex) == 0);
+}
+#endif
+
+void
+OFRegisterEmbeddedFile(OFString *path, const uint8_t *bytes, size_t size)
+{
+#ifdef OF_HAVE_THREADS
+ OFOnce(&mutexOnceControl, initMutex);
+
+ OFEnsure(OFPlainMutexLock(&mutex) == 0);
+#endif
+
+ embeddedFiles = realloc(embeddedFiles,
+ sizeof(*embeddedFiles) * (numEmbeddedFiles + 1));
+ OFEnsure(embeddedFiles != NULL);
+
+ embeddedFiles[numEmbeddedFiles].path = path;
+ embeddedFiles[numEmbeddedFiles].bytes = bytes;
+ embeddedFiles[numEmbeddedFiles].size = size;
+ numEmbeddedFiles++;
+
+#ifdef OF_HAVE_THREADS
+ OFEnsure(OFPlainMutexUnlock(&mutex) == 0);
+#endif
+}
+
+@implementation OFEmbeddedIRIHandler
+#ifdef OF_HAVE_THREADS
++ (void)initialize
+{
+ if (self == [OFEmbeddedIRIHandler class])
+ OFOnce(&mutexOnceControl, initMutex);
+}
+#endif
+
+- (OFStream *)openItemAtIRI: (OFIRI *)IRI mode: (OFString *)mode
+{
+ OFString *path;
+
+ if (![IRI.scheme isEqual: @"embedded"] || IRI.host.length > 0 ||
+ IRI.port != nil || IRI.user != nil || IRI.password != nil ||
+ IRI.query != nil || IRI.fragment != nil)
+ @throw [OFInvalidArgumentException exception];
+
+ if (![mode isEqual: @"r"])
+ @throw [OFOpenItemFailedException exceptionWithIRI: IRI
+ mode: mode
+ errNo: EROFS];
+
+ if ((path = IRI.path) == nil) {
+ @throw [OFInvalidArgumentException exception];
+ }
+
+#ifdef OF_HAVE_THREADS
+ OFEnsure(OFPlainMutexLock(&mutex) == 0);
+ @try {
+#endif
+ for (size_t i = 0; i < numEmbeddedFiles; i++) {
+ if (![embeddedFiles[i].path isEqual: path])
+ continue;
+
+ return [OFMemoryStream
+ streamWithMemoryAddress: (void *)
+ embeddedFiles[i].bytes
+ size: embeddedFiles[i].size
+ writable: false];
+ }
+#ifdef OF_HAVE_THREADS
+ } @finally {
+ OFEnsure(OFPlainMutexUnlock(&mutex) == 0);
+ }
+#endif
+
+ @throw [OFOpenItemFailedException exceptionWithIRI: IRI
+ mode: mode
+ errNo: ENOENT];
+}
+@end
DELETED src/OFEmbeddedURIHandler.h
Index: src/OFEmbeddedURIHandler.h
==================================================================
--- src/OFEmbeddedURIHandler.h
+++ src/OFEmbeddedURIHandler.h
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#import "OFURIHandler.h"
-
-OF_ASSUME_NONNULL_BEGIN
-
-@interface OFEmbeddedURIHandler: OFURIHandler
-@end
-
-OF_ASSUME_NONNULL_END
DELETED src/OFEmbeddedURIHandler.m
Index: src/OFEmbeddedURIHandler.m
==================================================================
--- src/OFEmbeddedURIHandler.m
+++ src/OFEmbeddedURIHandler.m
@@ -1,117 +0,0 @@
-/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
- *
- * 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
-#include
-#include
-
-#import "OFEmbeddedURIHandler.h"
-#import "OFMemoryStream.h"
-#import "OFURI.h"
-
-#import "OFInvalidArgumentException.h"
-#import "OFOpenItemFailedException.h"
-
-#ifdef OF_HAVE_THREADS
-# import "OFOnce.h"
-# import "OFPlainMutex.h"
-#endif
-
-struct EmbeddedFile {
- const char *name;
- const uint8_t *bytes;
- size_t size;
-} *embeddedFiles = NULL;
-size_t numEmbeddedFiles = 0;
-#ifdef OF_HAVE_THREADS
-static OFPlainMutex mutex;
-
-static void
-init(void)
-{
- OFEnsure(OFPlainMutexNew(&mutex) == 0);
-}
-#endif
-
-void
-OFRegisterEmbeddedFile(const char *name, const uint8_t *bytes, size_t size)
-{
-#ifdef OF_HAVE_THREADS
- static OFOnceControl onceControl = OFOnceControlInitValue;
- OFOnce(&onceControl, init);
-
- OFEnsure(OFPlainMutexLock(&mutex) == 0);
-#endif
-
- embeddedFiles = realloc(embeddedFiles,
- sizeof(*embeddedFiles) * (numEmbeddedFiles + 1));
- OFEnsure(embeddedFiles != NULL);
-
- embeddedFiles[numEmbeddedFiles].name = name;
- embeddedFiles[numEmbeddedFiles].bytes = bytes;
- embeddedFiles[numEmbeddedFiles].size = size;
- numEmbeddedFiles++;
-
-#ifdef OF_HAVE_THREADS
- OFEnsure(OFPlainMutexUnlock(&mutex) == 0);
-#endif
-}
-
-@implementation OFEmbeddedURIHandler
-- (OFStream *)openItemAtURI: (OFURI *)URI mode: (OFString *)mode
-{
- const char *path;
-
- if (![URI.scheme isEqual: @"embedded"] || URI.host.length > 0 ||
- URI.port != nil || URI.user != nil || URI.password != nil ||
- URI.query != nil || URI.fragment != nil)
- @throw [OFInvalidArgumentException exception];
-
- if (![mode isEqual: @"r"])
- @throw [OFOpenItemFailedException exceptionWithURI: URI
- mode: mode
- errNo: EROFS];
-
- if ((path = URI.path.UTF8String) == NULL) {
- @throw [OFInvalidArgumentException exception];
- }
-
-#ifdef OF_HAVE_THREADS
- OFEnsure(OFPlainMutexLock(&mutex) == 0);
- @try {
-#endif
- for (size_t i = 0; i < numEmbeddedFiles; i++) {
- if (strcmp(embeddedFiles[i].name, path) != 0)
- continue;
-
- return [OFMemoryStream
- streamWithMemoryAddress: (void *)
- embeddedFiles[i].bytes
- size: embeddedFiles[i].size
- writable: false];
- }
-#ifdef OF_HAVE_THREADS
- } @finally {
- OFEnsure(OFPlainMutexUnlock(&mutex) == 0);
- }
-#endif
-
- @throw [OFOpenItemFailedException exceptionWithURI: URI
- mode: mode
- errNo: ENOENT];
-}
-@end
Index: src/OFEnumerator.h
==================================================================
--- src/OFEnumerator.h
+++ src/OFEnumerator.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
Index: src/OFEnumerator.m
==================================================================
--- src/OFEnumerator.m
+++ src/OFEnumerator.m
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
@@ -59,14 +59,15 @@
- (int)countByEnumeratingWithState: (OFFastEnumerationState *)state
objects: (id *)objects
count: (int)count
{
+ static unsigned long dummyMutations;
int i;
state->itemsPtr = objects;
- state->mutationsPtr = (unsigned long *)self;
+ state->mutationsPtr = &dummyMutations;
for (i = 0; i < count; i++) {
id object = [self nextObject];
if (object == nil)
Index: src/OFEpollKernelEventObserver.h
==================================================================
--- src/OFEpollKernelEventObserver.h
+++ src/OFEpollKernelEventObserver.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
Index: src/OFEpollKernelEventObserver.m
==================================================================
--- src/OFEpollKernelEventObserver.m
+++ src/OFEpollKernelEventObserver.m
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
@@ -13,11 +13,10 @@
* file.
*/
#include "config.h"
-#include
#include
#ifdef HAVE_FCNTL_H
# include
#endif
Index: src/OFFile.h
==================================================================
--- src/OFFile.h
+++ src/OFFile.h
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
@@ -25,12 +25,10 @@
static const OFFileHandle OFInvalidFileHandle = NULL;
#endif
OF_ASSUME_NONNULL_BEGIN
-@class OFURI;
-
/**
* @class OFFile OFFile.h ObjFW/OFFile.h
*
* @brief A class which provides methods to read and write files.
*/
Index: src/OFFile.m
==================================================================
--- src/OFFile.m
+++ src/OFFile.m
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008-2022 Jonathan Schleifer
+ * Copyright (c) 2008-2023 Jonathan Schleifer
*
* 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
@@ -13,13 +13,14 @@
* file.
*/
#include "config.h"
-#define _LARGEFILE64_SOURCE
+#ifndef _LARGEFILE64_SOURCE
+# define _LARGEFILE64_SOURCE
+#endif
-#include
#include
#ifdef HAVE_FCNTL_H
# include