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
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
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
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: .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`:
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, 2022
+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
@@ -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.1dev, js@nil.im)
+AC_INIT(ObjFW, 1.1dev, js@nil.im, objfw, https://objfw.nil.im/)
AC_CONFIG_SRCDIR(src)
AC_CONFIG_AUX_DIR(build-aux)
AC_CONFIG_MACRO_DIR(build-aux/m4)
AC_DEFINE(OBJFW_VERSION_MAJOR, 1, [The major version of ObjFW])
@@ -101,11 +101,11 @@
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-*)
@@ -146,10 +146,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}
@@ -169,11 +177,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]))
@@ -418,11 +425,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([
@@ -594,11 +603,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")
])
@@ -1056,11 +1065,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
@@ -1332,11 +1359,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([
@@ -1418,21 +1445,44 @@
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 net/if.h])
+ AC_CHECK_HEADERS([arpa/inet.h netdb.h])
+ AC_CHECK_HEADERS([net/if.h net/if_arp.h net/if_dl.h net/if_types.h])
AC_CHECK_FUNCS([if_indextoname if_nametoindex])
+ AC_CHECK_TYPES([struct sockaddr_dl], [], [], [
+ #ifdef HAVAE_SYS_TYPES_H
+ # include
+ #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_MEMBER([struct sockaddr_in6.sin6_addr], [
AC_EGREP_CPP(egrep_cpp_yes, [
@@ -1495,10 +1545,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
@@ -1516,21 +1581,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
@@ -1547,10 +1631,14 @@
])
], [
#ifdef _WIN32
typedef int BOOL;
#endif
+
+ #ifdef HAVE_SYS_TYPES_H
+ # include
+ #endif
#ifdef OF_HAVE_NETIPX_IPX_H
# include
#endif
@@ -1564,11 +1652,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
@@ -1730,27 +1819,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,
@@ -1762,14 +1851,12 @@
LIBS="$old_LIBS"
])
])
AS_IF([test x"$with_tls" = x"gnutls" \
- -o \( x"$with_tls" = x"yes" -a x"$tls_support" = x"no" \)], [
+ -o \( x"$with_tls" = x"yes" -a x"$tls_support" = x"no" \)], [
PKG_CHECK_MODULES(gnutls, [gnutls >= 3.5.0], [
- AC_DEFINE(HAVE_GNUTLS, 1, [Whether we have GnuTLS])
-
tls_support="GnuTLS"
TLS_CPPFLAGS="$gnutls_CFLAGS $TLS_CPPFLAGS"
TLS_LIBS="$gnutls_LIBS $TLS_LIBS"
AC_SUBST(OF_GNUTLS_TLS_STREAM_M, "OFGnuTLSTLSStream.m")
@@ -1779,11 +1866,11 @@
:
])
])
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"
;;
@@ -1793,13 +1880,10 @@
;;
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")
@@ -1817,11 +1901,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")
])
@@ -1881,14 +1965,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"
])
;;
@@ -1896,21 +1976,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" \
@@ -1920,19 +2001,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()])
])
@@ -1941,11 +2021,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")
])
@@ -2219,10 +2299,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([
@@ -2249,14 +2343,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.
@@ -2266,21 +2357,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
@@ -30,11 +30,10 @@
ENCODINGS_LIB_A = @ENCODINGS_LIB_A@
ENCODINGS_SRCS = @ENCODINGS_SRCS@
EXCEPTIONS_A = @EXCEPTIONS_A@
EXCEPTIONS_AMIGALIB_A = @EXCEPTIONS_AMIGALIB_A@
EXCEPTIONS_LIB_A = @EXCEPTIONS_LIB_A@
-FISH_COMPLETIONS = @FISH_COMPLETIONS@
FORWARDING_A = @FORWARDING_A@
FORWARDING_AMIGALIB_A = @FORWARDING_AMIGALIB_A@
FORWARDING_LIB_A = @FORWARDING_LIB_A@
LIBBASES_M = @LIBBASES_M@
LIBOBJFWRT_DEP = @LIBOBJFWRT_DEP@
Index: generators/library/FuncArrayGenerator.h
==================================================================
--- generators/library/FuncArrayGenerator.h
+++ generators/library/FuncArrayGenerator.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/library/FuncArrayGenerator.m
==================================================================
--- generators/library/FuncArrayGenerator.m
+++ generators/library/FuncArrayGenerator.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: generators/library/GlueGenerator.h
==================================================================
--- generators/library/GlueGenerator.h
+++ generators/library/GlueGenerator.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/library/GlueGenerator.m
==================================================================
--- generators/library/GlueGenerator.m
+++ generators/library/GlueGenerator.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: generators/library/LibraryGenerator.m
==================================================================
--- generators/library/LibraryGenerator.m
+++ generators/library/LibraryGenerator.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,11 +16,11 @@
#include "config.h"
#import "OFApplication.h"
#import "OFFile.h"
#import "OFFileManager.h"
-#import "OFURI.h"
+#import "OFIRI.h"
#import "OFXMLElement.h"
#import "FuncArrayGenerator.h"
#import "GlueGenerator.h"
#import "LinkLibGenerator.h"
@@ -31,35 +31,35 @@
OF_APPLICATION_DELEGATE(LibraryGenerator)
@implementation LibraryGenerator
- (void)generateInDirectory: (OFString *)directory
{
- OFURI *sourcesURI = [[OFFileManager defaultManager].currentDirectoryURI
- URIByAppendingPathComponent: directory];
- OFURI *libraryURI = [sourcesURI
- URIByAppendingPathComponent: @"amiga-library.xml"];
- OFURI *linkLibURI = [sourcesURI
- URIByAppendingPathComponent: @"linklib/linklib.m"];
- OFURI *glueHeaderURI = [sourcesURI
- URIByAppendingPathComponent: @"amiga-glue.h"];
- OFURI *glueURI = [sourcesURI
- URIByAppendingPathComponent: @"amiga-glue.m"];
- OFURI *funcArrayURI = [sourcesURI
- URIByAppendingPathComponent: @"amiga-funcarray.inc"];
+ OFIRI *sourcesIRI = [[OFFileManager defaultManager].currentDirectoryIRI
+ IRIByAppendingPathComponent: directory];
+ OFIRI *libraryIRI = [sourcesIRI
+ IRIByAppendingPathComponent: @"amiga-library.xml"];
+ OFIRI *linkLibIRI = [sourcesIRI
+ IRIByAppendingPathComponent: @"linklib/linklib.m"];
+ OFIRI *glueHeaderIRI = [sourcesIRI
+ IRIByAppendingPathComponent: @"amiga-glue.h"];
+ OFIRI *glueIRI = [sourcesIRI
+ IRIByAppendingPathComponent: @"amiga-glue.m"];
+ OFIRI *funcArrayIRI = [sourcesIRI
+ IRIByAppendingPathComponent: @"amiga-funcarray.inc"];
OFXMLElement *library = [OFXMLElement elementWithStream:
- [OFFile fileWithPath: libraryURI.fileSystemRepresentation
+ [OFFile fileWithPath: libraryIRI.fileSystemRepresentation
mode: @"r"]];
OFFile *linkLib =
- [OFFile fileWithPath: linkLibURI.fileSystemRepresentation
+ [OFFile fileWithPath: linkLibIRI.fileSystemRepresentation
mode: @"w"];
OFFile *glueHeader =
- [OFFile fileWithPath: glueHeaderURI.fileSystemRepresentation
+ [OFFile fileWithPath: glueHeaderIRI.fileSystemRepresentation
mode: @"w"];
OFFile *glue =
- [OFFile fileWithPath: glueURI.fileSystemRepresentation mode: @"w"];
+ [OFFile fileWithPath: glueIRI.fileSystemRepresentation mode: @"w"];
OFFile *funcArray =
- [OFFile fileWithPath: funcArrayURI.fileSystemRepresentation
+ [OFFile fileWithPath: funcArrayIRI.fileSystemRepresentation
mode: @"w"];
LinkLibGenerator *linkLibGenerator = [[[LinkLibGenerator alloc]
initWithLibrary: library
implementation: linkLib] autorelease];
GlueGenerator *glueGenerator = [[[GlueGenerator alloc]
Index: generators/library/LinkLibGenerator.h
==================================================================
--- generators/library/LinkLibGenerator.h
+++ generators/library/LinkLibGenerator.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/library/LinkLibGenerator.m
==================================================================
--- generators/library/LinkLibGenerator.m
+++ generators/library/LinkLibGenerator.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: generators/library/copyright.h
==================================================================
--- generators/library/copyright.h
+++ generators/library/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: 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
@@ -66,12 +66,12 @@
{
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
@@ -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
@@ -28,47 +28,48 @@
OFData.m \
OFData+CryptographicHashing.m \
OFData+MessagePackParsing.m \
OFDate.m \
OFDictionary.m \
- OFEmbeddedURIHandler.m \
OFEnumerator.m \
OFFileManager.m \
OFGZIPStream.m \
OFHMAC.m \
OFINICategory.m \
OFINIFile.m \
+ OFIRI.m \
+ OFIRIHandler.m \
OFInflate64Stream.m \
OFInflateStream.m \
OFInvocation.m \
OFLHAArchive.m \
OFLHAArchiveEntry.m \
OFList.m \
OFLocale.m \
OFMD5Hash.m \
OFMapTable.m \
+ OFMatrix4x4.m \
OFMemoryStream.m \
OFMessagePackExtension.m \
OFMethodSignature.m \
OFMutableArray.m \
OFMutableData.m \
OFMutableDictionary.m \
+ OFMutableIRI.m \
OFMutableLHAArchiveEntry.m \
OFMutablePair.m \
OFMutableSet.m \
OFMutableString.m \
OFMutableTarArchiveEntry.m \
OFMutableTriple.m \
- OFMutableURI.m \
OFMutableZIPArchiveEntry.m \
OFNotification.m \
OFNotificationCenter.m \
OFNull.m \
OFNumber.m \
OFObject.m \
OFObject+KeyValueCoding.m \
- OFObject+Serialization.m \
OFOnce.m \
OFOptionsParser.m \
OFPBKDF2.m \
OFPair.m \
OFRIPEMD160Hash.m \
@@ -81,11 +82,10 @@
OFSHA384Or512Hash.m \
OFSHA512Hash.m \
OFScrypt.m \
OFSecureData.m \
OFSeekableStream.m \
- OFSerialization.m \
OFSet.m \
OFSettings.m \
OFSortedList.m \
OFStdIOStream.m \
OFStream.m \
@@ -92,30 +92,26 @@
OFString.m \
OFString+CryptographicHashing.m \
OFString+JSONParsing.m \
OFString+PercentEncoding.m \
OFString+PropertyListParsing.m \
- OFString+Serialization.m \
OFString+XMLEscaping.m \
OFString+XMLUnescaping.m \
${OF_SUBPROCESS_M} \
OFSystemInfo.m \
OFTarArchive.m \
OFTarArchiveEntry.m \
OFThread.m \
OFTimer.m \
OFTriple.m \
- OFURI.m \
- OFURIHandler.m \
OFUUID.m \
OFValue.m \
OFXMLAttribute.m \
OFXMLCDATA.m \
OFXMLCharacters.m \
OFXMLComment.m \
OFXMLElement.m \
- OFXMLElement+Serialization.m \
OFXMLElementBuilder.m \
OFXMLNode.m \
OFXMLParser.m \
OFXMLProcessingInstruction.m \
OFZIPArchive.m \
@@ -140,10 +136,11 @@
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} \
@@ -186,17 +183,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 \
+ OFEmbeddedIRIHandler.m \
OFHuffmanTree.m \
OFINIFileSettings.m \
OFInvertedCharacterSet.m \
OFLHADecompressingStream.m \
OFMapTableDictionary.m \
@@ -218,15 +216,15 @@
OFUTF8String.m \
${LIBBASES_M} \
${RUNTIME_AUTORELEASE_M} \
${RUNTIME_INSTANCE_M} \
${UNICODE_M}
-SRCS_FILES += OFFileURIHandler.m
+SRCS_FILES += OFFileIRIHandler.m
SRCS_SOCKETS += OFAsyncIPSocketConnector.m \
OFDNSResolverSettings.m \
${OF_EPOLL_KERNEL_EVENT_OBSERVER_M} \
- OFHTTPURIHandler.m \
+ OFHTTPIRIHandler.m \
OFHostAddressResolver.m \
OFKernelEventObserver.m \
${OF_KQUEUE_KERNEL_EVENT_OBSERVER_M} \
${OF_POLL_KERNEL_EVENT_OBSERVER_M} \
${OF_SELECT_KERNEL_EVENT_OBSERVER_M} \
@@ -264,5 +262,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
{
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
@@ -163,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
@@ -53,12 +53,14 @@
#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
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
@@ -23,11 +23,10 @@
#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"
@@ -85,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;
}
@@ -212,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
{
@@ -546,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];
}
@@ -723,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
{
Index: src/OFAsyncIPSocketConnector.h
==================================================================
--- src/OFAsyncIPSocketConnector.h
+++ src/OFAsyncIPSocketConnector.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/OFAsyncIPSocketConnector.m
==================================================================
--- src/OFAsyncIPSocketConnector.m
+++ src/OFAsyncIPSocketConnector.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/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
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
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
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
Index: src/OFDDPSocket.h
==================================================================
--- src/OFDDPSocket.h
+++ src/OFDDPSocket.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
@@ -16,10 +16,11 @@
#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.
@@ -41,11 +42,11 @@
* socket number).
*
* @note On some systems, packets received with the wrong protocol type just
* get filtered by the kernel, however, on other systems, the packet is
* queued up and will raise an @ref OFReadFailedException with the
- * @ref errNo set to `ENOMSG` when being received.
+ * @ref OFReadFailedException#errNo set to `ENOMSG` when being received.
*
* @warning Even though the OFCopying protocol is implemented, it does *not*
* return an independent copy of the socket, but instead retains it.
* This is so that the socket can be used as a key for a dictionary,
* so context can be associated with a socket. Using a socket in more
@@ -79,14 +80,14 @@
* @param protocolType The DDP protocol type to use. Must not be 0. If you want
* to use DDP directly and not a protocol built on top of
* it, use 11 for compatibility with Open Transport.
* @return The address on which this socket can be reached
* @throw OFBindDDPSockeFailedException Binding failed
- * @throw OFAlreadyConnectedException The socket is already bound
+ * @throw OFAlreadyOpenException The socket is already bound
*/
- (OFSocketAddress)bindToNetwork: (uint16_t)network
node: (uint8_t)node
port: (uint8_t)port
protocolType: (uint8_t)protocolType;
@end
OF_ASSUME_NONNULL_END
Index: src/OFDDPSocket.m
==================================================================
--- src/OFDDPSocket.m
+++ src/OFDDPSocket.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,19 +20,32 @@
#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 "OFAlreadyConnectedException.h"
+#import "OFAlreadyOpenException.h"
#import "OFBindDDPSocketFailedException.h"
+#import "OFGetOptionFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFNotOpenException.h"
+#import "OFOutOfRangeException.h"
#import "OFReadFailedException.h"
+#import "OFSetOptionFailedException.h"
#import "OFWriteFailedException.h"
+
+#ifdef HAVE_NET_IF_H
+# include
+#endif
+#ifdef HAVE_SYS_IOCTL_H
+# include
+#endif
#ifdef OF_HAVE_NETAT_APPLETALK_H
# include
# include
@@ -65,11 +78,11 @@
if (protocolType == 0)
@throw [OFInvalidArgumentException exception];
if (_socket != OFInvalidSocketHandle)
- @throw [OFAlreadyConnectedException exceptionWithSocket: self];
+ @throw [OFAlreadyOpenException exceptionWithObject: self];
address = OFSocketAddressMakeAppleTalk(network, node, port);
#if defined(OF_MACOS)
if ((_socket = socket(address.sockaddr.at.sat_family,
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];
@@ -946,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
@@ -288,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];
}
@@ -341,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
@@ -445,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];
}
@@ -491,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];
}
@@ -600,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.
*/
@@ -620,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]
@@ -209,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;
@@ -332,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
{
@@ -585,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
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
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
@@ -22,22 +22,19 @@
#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
@@ -53,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];
}
@@ -111,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;
}
@@ -135,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
{
@@ -328,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
{
@@ -635,54 +556,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];
}
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,44 +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
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-/**
- * @brief Register a file for the `embedded:` URI 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
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 {
- OFString *path;
- 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(OFString *path, 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].path = path;
- embeddedFiles[numEmbeddedFiles].bytes = bytes;
- embeddedFiles[numEmbeddedFiles].size = size;
- numEmbeddedFiles++;
-
-#ifdef OF_HAVE_THREADS
- OFEnsure(OFPlainMutexUnlock(&mutex) == 0);
-#endif
-}
-
-@implementation OFEmbeddedURIHandler
-- (OFStream *)openItemAtURI: (OFURI *)URI mode: (OFString *)mode
-{
- OFString *path;
-
- if (![URI.scheme isEqual: @"embedded"] || URI.host.length > 0 ||
- URI.port != nil || URI.user != nil || URI.password != nil ||
- URI.query != nil || URI.fragment != nil)
- @throw [OFInvalidArgumentException exception];
-
- if (![mode isEqual: @"r"])
- @throw [OFOpenItemFailedException exceptionWithURI: URI
- mode: mode
- errNo: EROFS];
-
- if ((path = URI.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 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
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
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,11 +13,13 @@
* file.
*/
#include "config.h"
-#define _LARGEFILE64_SOURCE
+#ifndef _LARGEFILE64_SOURCE
+# define _LARGEFILE64_SOURCE
+#endif
#include
#ifdef HAVE_FCNTL_H
# include
@@ -30,11 +32,10 @@
#import "OFFile.h"
#import "OFLocale.h"
#import "OFString.h"
#import "OFSystemInfo.h"
-#import "OFURI.h"
#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFNotOpenException.h"
#import "OFOpenItemFailedException.h"
@@ -47,12 +48,14 @@
#ifdef OF_WINDOWS
# include
#endif
#ifdef OF_AMIGAOS
+# define Class IntuitionClass
# include
# include
+# undef Class
#endif
#ifdef OF_WII
# include
#endif
ADDED src/OFFileIRIHandler.h
Index: src/OFFileIRIHandler.h
==================================================================
--- src/OFFileIRIHandler.h
+++ src/OFFileIRIHandler.h
@@ -0,0 +1,24 @@
+/*
+ * 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 OFFileIRIHandler: OFIRIHandler
++ (bool)of_directoryExistsAtPath: (OFString *)path OF_DIRECT;
+@end
+
+OF_ASSUME_NONNULL_END
ADDED src/OFFileIRIHandler.m
Index: src/OFFileIRIHandler.m
==================================================================
--- src/OFFileIRIHandler.m
+++ src/OFFileIRIHandler.m
@@ -0,0 +1,1679 @@
+/*
+ * 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"
+
+#ifndef _LARGEFILE64_SOURCE
+# define _LARGEFILE64_SOURCE
+#endif
+
+#include
+#include
+
+#ifdef HAVE_DIRENT_H
+# include
+#endif
+#include "unistd_wrapper.h"
+
+#include "platform.h"
+#ifdef HAVE_SYS_STAT_H
+# include
+#endif
+#include
+#if defined(OF_LINUX) || defined(OF_MACOS)
+# include
+#endif
+#ifdef OF_WINDOWS
+# include
+#endif
+#ifdef OF_DJGPP
+# include
+#endif
+
+#ifdef HAVE_FCNTL_H
+# include
+#endif
+#ifdef HAVE_PWD_H
+# include
+#endif
+#ifdef HAVE_GRP_H
+# include
+#endif
+
+#import "OFFileIRIHandler.h"
+#import "OFArray.h"
+#import "OFData.h"
+#import "OFDate.h"
+#import "OFFile.h"
+#import "OFFileManager.h"
+#import "OFIRI.h"
+#import "OFLocale.h"
+#import "OFNumber.h"
+#import "OFSystemInfo.h"
+
+#ifdef OF_HAVE_THREADS
+# import "OFMutex.h"
+#endif
+
+#import "OFCreateDirectoryFailedException.h"
+#import "OFCreateSymbolicLinkFailedException.h"
+#import "OFGetItemAttributesFailedException.h"
+#import "OFInitializationFailedException.h"
+#import "OFInvalidArgumentException.h"
+#import "OFLinkItemFailedException.h"
+#import "OFMoveItemFailedException.h"
+#import "OFNotImplementedException.h"
+#import "OFOpenItemFailedException.h"
+#import "OFOutOfRangeException.h"
+#import "OFReadFailedException.h"
+#import "OFRemoveItemFailedException.h"
+#import "OFSetItemAttributesFailedException.h"
+
+#ifdef OF_WINDOWS
+# include
+# include
+# include
+# include
+#endif
+
+#ifdef OF_AMIGAOS
+# define Class IntuitionClass
+# include
+# include