Comment: | Merge trunk into branch "sctp" |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | sctp |
Files: | files | file ages | folders |
SHA3-256: |
bd2d723910df5ff3cc62c9d5c1c778b6 |
User & Date: | js on 2024-04-28 18:15:06 |
Other Links: | branch diff | manifest | tags |
2024-04-28
| ||
18:25 | OFSCTPSocket: Return socket address bound to check-in: c34be99f15 user: js tags: sctp | |
18:15 | Merge trunk into branch "sctp" check-in: bd2d723910 user: js tags: sctp | |
12:47 | Skip (sym)link tests if unavailable check-in: 523f721292 user: js tags: trunk | |
2022-11-07
| ||
00:30 | Update copyright check-in: fd43329443 user: js tags: sctp | |
Modified .fossil-settings/clean-glob from [06b87ad48d] to [749762eae0].
︙ | ︙ | |||
28 29 30 31 32 33 34 35 36 37 38 39 40 41 | generators/unicode/gen_tables src/Info.plist src/bridge/Info.plist src/libobjfw.* src/objfw-defs.h src/runtime/Info.plist src/runtime/libobjfwrt.* src/tls/Info.plist tests/DerivedData tests/EBOOT.PBP tests/Info.plist tests/PARAM.SFO tests/objc_sync/objc_sync tests/plugin/Info.plist | > > > | | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | generators/unicode/gen_tables src/Info.plist src/bridge/Info.plist src/libobjfw.* src/objfw-defs.h src/runtime/Info.plist src/runtime/libobjfwrt.* src/test/libobjfwtest.a src/tls/Info.plist src/tls/libobjfwtls.* tests/DerivedData tests/EBOOT.PBP tests/Info.plist tests/PARAM.SFO tests/big_dictionary_msgpack.m tests/objc_sync/objc_sync tests/plugin/Info.plist tests/subprocess/subprocess tests/terminal/terminal_tests tests/testfile_bin.m tests/testfile_ini.m tests/tests tests/tests.3dsx tests/tests.arm9 tests/tests.nds |
︙ | ︙ |
Modified .fossil-settings/ignore-glob from [23cb69850b] to [92d0e0d642].
︙ | ︙ | |||
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | generators/unicode/gen_tables src/Info.plist src/bridge/Info.plist src/libobjfw.* src/objfw-defs.h src/runtime/Info.plist src/runtime/libobjfwrt.* src/tls/Info.plist tests/DerivedData tests/EBOOT.PBP tests/Info.plist tests/PARAM.SFO tests/iOS.xcodeproj/*.pbxuser tests/iOS.xcodeproj/project.xcworkspace tests/iOS.xcodeproj/xcuserdata tests/objc_sync/objc_sync tests/plugin/Info.plist | > > > | | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | generators/unicode/gen_tables src/Info.plist src/bridge/Info.plist src/libobjfw.* src/objfw-defs.h src/runtime/Info.plist src/runtime/libobjfwrt.* src/test/libobjfwtest.a src/tls/Info.plist src/tls/libobjfwtls.* tests/DerivedData tests/EBOOT.PBP tests/Info.plist tests/PARAM.SFO tests/big_dictionary_msgpack.m tests/iOS.xcodeproj/*.pbxuser tests/iOS.xcodeproj/project.xcworkspace tests/iOS.xcodeproj/xcuserdata tests/objc_sync/objc_sync tests/plugin/Info.plist tests/subprocess/subprocess tests/terminal/terminal_tests tests/testfile_bin.m tests/testfile_ini.m tests/tests tests/tests.3dsx tests/tests.arm9 tests/tests.nds |
︙ | ︙ |
Modified .github/workflows/amiga-gcc.yml from [d938c3ac40] to [334c337cae].
1 2 3 4 5 6 | name: amiga-gcc on: [push, pull_request] jobs: build: runs-on: ubuntu-latest container: amigadev/crosstools:m68k-amigaos | < < < < < | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | name: amiga-gcc on: [push, pull_request] jobs: build: runs-on: ubuntu-latest container: amigadev/crosstools:m68k-amigaos steps: - uses: actions/checkout@v4 - name: autogen.sh run: ./autogen.sh - name: configure run: ./configure --host=m68k-amigaos - name: make run: make -j$(nproc) - name: make install run: make install |
Added .github/workflows/dragonflybsd.yml version [6c0eaab5cb].
> > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | name: dragonflybsd on: [push, pull_request] jobs: tests: runs-on: ubuntu-latest strategy: matrix: configure_flags: - - --disable-shared - --with-tls=gnutls steps: - uses: actions/checkout@v4 - uses: vmactions/dragonflybsd-vm@v1 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/fedora-mingw.yml version [9e238dad53].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | name: fedora-mingw on: [push, pull_request] jobs: tests: runs-on: ubuntu-latest strategy: matrix: include: - prefix: mingw32 triple: i686-w64-mingw32 - prefix: mingw64 triple: x86_64-w64-mingw32 - prefix: ucrt64 triple: x86_64-w64-mingw32ucrt container: fedora:41 steps: - name: Install dependencies run: | sudo dnf upgrade --refresh -y sudo dnf install -y ${{matrix.prefix}}-gcc ${{matrix.prefix}}-openssl clang autoconf automake make wine - uses: actions/checkout@v4 - name: autogen.sh run: ./autogen.sh - name: configure run: ./configure --host=${{matrix.triple}} OBJC="clang -target ${{matrix.triple}}" - name: make run: make -j$(nproc) - name: make check run: WINEPATH=/usr/${{matrix.triple}}/sys-root/mingw/bin WINEPREFIX=/tmp/wineprefix make check - name: make install run: sudo make install |
Added .github/workflows/freebsd.yml version [4657fe9002].
> > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | name: freebsd on: [push, pull_request] jobs: tests: runs-on: ubuntu-latest strategy: matrix: configure_flags: - - --disable-shared - --with-tls=gnutls steps: - uses: actions/checkout@v4 - uses: vmactions/freebsd-vm@v1 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 |
Modified .github/workflows/ios.yml from [dd34f22809] to [dbdab2a600].
︙ | ︙ | |||
10 11 12 13 14 15 16 | - x86_64 configure_flags: - - --disable-shared steps: - name: Install dependencies run: brew install autoconf automake | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | - x86_64 configure_flags: - - --disable-shared steps: - name: Install dependencies run: brew install autoconf automake - uses: actions/checkout@v4 - name: autogen.sh run: ./autogen.sh - name: configure run: | export IPHONEOS_DEPLOYMENT_TARGET="9.0" if [ "${{ matrix.arch}}" = "x86_64" ]; then sdk="iphonesimulator" |
︙ | ︙ |
Modified .github/workflows/macos-11.yml from [d79ffc1fb9] to [ade6268255].
︙ | ︙ | |||
14 15 16 17 18 19 20 | - --disable-sockets - --disable-sockets --disable-files - --disable-files - --disable-shared steps: - name: Install dependencies run: brew install autoconf automake | | | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | - --disable-sockets - --disable-sockets --disable-files - --disable-files - --disable-shared steps: - name: Install dependencies run: brew install autoconf automake - uses: actions/checkout@v4 - name: autogen.sh run: ./autogen.sh - name: configure run: ./configure ${{ matrix.configure_flags }} - name: make run: make -j$(sysctl -n hw.logicalcpu) - name: make check |
︙ | ︙ |
Modified .github/workflows/macos-12.yml from [a15421158f] to [ee9ffcacad].
︙ | ︙ | |||
14 15 16 17 18 19 20 | - --disable-sockets - --disable-sockets --disable-files - --disable-files - --disable-shared steps: - name: Install dependencies run: brew install autoconf automake | | | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | - --disable-sockets - --disable-sockets --disable-files - --disable-files - --disable-shared steps: - name: Install dependencies run: brew install autoconf automake - uses: actions/checkout@v4 - name: autogen.sh run: ./autogen.sh - name: configure run: ./configure ${{ matrix.configure_flags }} - name: make run: make -j$(sysctl -n hw.logicalcpu) - name: make check |
︙ | ︙ |
Added .github/workflows/macos-13.yml version [e68bb1a491].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | name: macos-13 on: [push, pull_request] jobs: tests: runs-on: macos-13 strategy: matrix: configure_flags: - - --disable-threads - --disable-threads --disable-sockets - --disable-threads --disable-files - --disable-threads --disable-sockets --disable-files - --disable-sockets - --disable-sockets --disable-files - --disable-files - --disable-shared steps: - name: Install dependencies run: brew install autoconf automake - uses: actions/checkout@v4 - name: autogen.sh run: ./autogen.sh - name: configure run: ./configure ${{ matrix.configure_flags }} - name: make run: make -j$(sysctl -n hw.logicalcpu) - name: make check run: make check - name: make install run: sudo make install |
Added .github/workflows/macos-14.yml version [af1606c56d].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | name: macos-14 on: [push, pull_request] jobs: tests: runs-on: macos-14 strategy: matrix: configure_flags: - - --disable-threads - --disable-threads --disable-sockets - --disable-threads --disable-files - --disable-threads --disable-sockets --disable-files - --disable-sockets - --disable-sockets --disable-files - --disable-files - --disable-shared steps: - name: Install dependencies run: brew install autoconf automake - uses: actions/checkout@v4 - name: autogen.sh run: ./autogen.sh - name: configure run: ./configure ${{ matrix.configure_flags }} - name: make run: make -j$(sysctl -n hw.logicalcpu) - name: make check run: make check - name: make install run: sudo make install |
Modified .github/workflows/morphos.yml from [c3d30801ba] to [f96dbd2310].
1 2 3 4 5 6 | name: morphos on: [push, pull_request] jobs: build: runs-on: ubuntu-latest container: amigadev/crosstools:ppc-morphos | < < < < < | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | name: morphos on: [push, pull_request] jobs: build: runs-on: ubuntu-latest container: amigadev/crosstools:ppc-morphos steps: - uses: actions/checkout@v4 - name: autogen.sh run: ./autogen.sh - name: configure run: ./configure --host=ppc-morphos - name: make run: make -j$(nproc) - name: make install run: make install |
Added .github/workflows/msys2.yml version [f5ad4b3bf9].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | name: msys2 on: [push, pull_request] jobs: tests: runs-on: windows-latest strategy: matrix: sys: # Broken: Exceptions with ARC fail. Works with other mingw-w64 # distributions. #- mingw32 - mingw64 - ucrt64 - clang32 - clang64 steps: - uses: actions/checkout@v4 - uses: msys2/setup-msys2@v2 with: update: true msystem: ${{matrix.sys}} install: autoconf automake make pacboy: clang:p openssl:p - name: autogen.sh shell: msys2 {0} run: ./autogen.sh - name: configure shell: msys2 {0} run: ./configure OBJC=clang - name: make shell: msys2 {0} run: make -j4 - name: make check shell: msys2 {0} run: make check - name: make install shell: msys2 {0} run: make install |
Added .github/workflows/netbsd-gcc.yml version [9108c5901d].
> > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | name: netbsd-gcc on: [push, pull_request] jobs: tests: runs-on: ubuntu-latest strategy: matrix: configure_flags: - - --disable-shared - --with-tls=gnutls steps: - uses: actions/checkout@v4 - uses: vmactions/netbsd-vm@v1 with: usesh: true copyback: false prepare: | /usr/sbin/pkg_add autoconf automake gnutls pkgconf run: | ./autogen.sh ./configure OBJC=gcc ${{ matrix.configure_flags }} make -j4 make check make install |
Added .github/workflows/netbsd.yml version [5d6e9c60e9].
> > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | name: netbsd on: [push, pull_request] jobs: tests: runs-on: ubuntu-latest strategy: matrix: configure_flags: - - --disable-shared - --with-tls=gnutls steps: - uses: actions/checkout@v4 - uses: vmactions/netbsd-vm@v1 with: usesh: true copyback: false prepare: | /usr/sbin/pkg_add autoconf automake clang gnutls pkgconf run: | ./autogen.sh ./configure OBJC=clang ${{ matrix.configure_flags }} make -j4 make check make install |
Modified .github/workflows/nintendo-3ds.yml from [b6f005f187] to [d5f22cd8d0].
1 2 3 4 5 6 7 8 | name: nintendo-3ds on: [push, pull_request] jobs: build: runs-on: ubuntu-latest steps: - name: Install dependencies run: docker pull devkitpro/devkitarm | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | name: nintendo-3ds on: [push, pull_request] jobs: build: runs-on: ubuntu-latest steps: - name: Install dependencies run: docker pull devkitpro/devkitarm - uses: actions/checkout@v4 - name: autogen.sh run: ./autogen.sh - name: configure run: | docker run \ -e DEVKITPRO=/opt/devkitpro \ -e PATH="/opt/devkitpro/devkitARM/bin:$PATH" \ |
︙ | ︙ |
Modified .github/workflows/nintendo-ds.yml from [1d6308a4b1] to [6b553d5781].
1 2 3 4 5 6 7 8 | name: nintendo-ds on: [push, pull_request] jobs: build: runs-on: ubuntu-latest steps: - name: Install dependencies run: docker pull devkitpro/devkitarm | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | name: nintendo-ds on: [push, pull_request] jobs: build: runs-on: ubuntu-latest steps: - name: Install dependencies run: docker pull devkitpro/devkitarm - uses: actions/checkout@v4 - name: autogen.sh run: ./autogen.sh - name: configure run: | docker run \ -e DEVKITPRO=/opt/devkitpro \ -e PATH="/opt/devkitpro/devkitARM/bin:$PATH" \ |
︙ | ︙ |
Modified .github/workflows/nintendo-switch.yml from [9d8878050b] to [dd1432abab].
1 2 3 4 5 6 7 8 | name: nintendo-switch on: [push, pull_request] jobs: build: runs-on: ubuntu-latest steps: - name: Install dependencies run: docker pull devkitpro/devkita64 | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | name: nintendo-switch on: [push, pull_request] jobs: build: runs-on: ubuntu-latest steps: - name: Install dependencies run: docker pull devkitpro/devkita64 - uses: actions/checkout@v4 - name: autogen.sh run: ./autogen.sh - name: configure run: | docker run \ -e DEVKITPRO=/opt/devkitpro \ -e PATH="/opt/devkitpro/devkitA64/bin:$PATH" \ |
︙ | ︙ |
Added .github/workflows/openbsd.yml version [a810b5a14b].
> > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | name: openbsd on: [push, pull_request] jobs: tests: runs-on: ubuntu-latest strategy: matrix: configure_flags: - - --disable-shared - --with-tls=gnutls steps: - uses: actions/checkout@v4 - uses: vmactions/openbsd-vm@v1 with: usesh: true copyback: false prepare: | pkg_add autoconf-2.71 automake-1.16.5 gnutls pkgconf run: | ./autogen.sh ./configure OBJC=clang ${{ matrix.configure_flags }} make -j4 make check make install |
Modified .github/workflows/ubuntu-20.04-32bit.yml from [6af581a780] to [eafc923d25].
︙ | ︙ | |||
20 21 22 23 24 25 26 | - --without-tls --disable-shared --enable-seluid24 - --without-tls --disable-compiler-tls --disable-threads steps: - name: Install dependencies run: | sudo apt-get update sudo apt-get install gcc-multilib | | | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | - --without-tls --disable-shared --enable-seluid24 - --without-tls --disable-compiler-tls --disable-threads steps: - name: Install dependencies run: | sudo apt-get update sudo apt-get install gcc-multilib - uses: actions/checkout@v4 - name: autogen.sh run: ./autogen.sh - name: configure run: ./configure OBJC="clang -m32" ${{ matrix.configure_flags }} - name: make run: make -j$(nproc) - name: make check |
︙ | ︙ |
Modified .github/workflows/ubuntu-20.04-gcc-32bit.yml from [16adbb51e7] to [b216b21e23].
︙ | ︙ | |||
20 21 22 23 24 25 26 | - --without-tls --disable-shared --enable-seluid24 - --without-tls --disable-compiler-tls --disable-threads steps: - name: Install dependencies run: | sudo apt-get update sudo apt-get install gcc-multilib gobjc | | | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | - --without-tls --disable-shared --enable-seluid24 - --without-tls --disable-compiler-tls --disable-threads steps: - name: Install dependencies run: | sudo apt-get update sudo apt-get install gcc-multilib gobjc - uses: actions/checkout@v4 - name: autogen.sh run: ./autogen.sh - name: configure run: ./configure OBJC="gcc -m32" ${{ matrix.configure_flags }} - name: make run: make -j$(nproc) - name: make check |
︙ | ︙ |
Modified .github/workflows/ubuntu-20.04-gcc.yml from [dd262654f6] to [db8cc56ce4].
︙ | ︙ | |||
22 23 24 25 26 27 28 | - --with-tls=gnutls - --with-tls=gnutls --disable-shared steps: - name: Install dependencies run: | sudo apt-get update sudo apt-get install gobjc libssl-dev gnutls-dev | | | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | - --with-tls=gnutls - --with-tls=gnutls --disable-shared steps: - name: Install dependencies run: | sudo apt-get update sudo apt-get install gobjc libssl-dev gnutls-dev - uses: actions/checkout@v4 - name: autogen.sh run: ./autogen.sh - name: configure run: ./configure OBJC="gcc" ${{ matrix.configure_flags }} - name: make run: make -j$(nproc) - name: make check |
︙ | ︙ |
Modified .github/workflows/ubuntu-20.04.yml from [051ed40d72] to [7132512cb3].
︙ | ︙ | |||
22 23 24 25 26 27 28 | - --with-tls=gnutls - --with-tls=gnutls --disable-shared steps: - name: Install dependencies run: | sudo apt-get update sudo apt-get install libssl-dev gnutls-dev | | | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | - --with-tls=gnutls - --with-tls=gnutls --disable-shared steps: - name: Install dependencies run: | sudo apt-get update sudo apt-get install libssl-dev gnutls-dev - uses: actions/checkout@v4 - name: autogen.sh run: ./autogen.sh - name: configure run: ./configure ${{ matrix.configure_flags }} - name: make run: make -j$(nproc) - name: make check |
︙ | ︙ |
Modified .github/workflows/ubuntu-latest-32bit.yml from [3cbf56442c] to [c27d1cf836].
︙ | ︙ | |||
20 21 22 23 24 25 26 | - --without-tls --disable-shared --enable-seluid24 - --without-tls --disable-compiler-tls --disable-threads steps: - name: Install dependencies run: | sudo apt-get update sudo apt-get install gcc-multilib | | | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | - --without-tls --disable-shared --enable-seluid24 - --without-tls --disable-compiler-tls --disable-threads steps: - name: Install dependencies run: | sudo apt-get update sudo apt-get install gcc-multilib - uses: actions/checkout@v4 - name: autogen.sh run: ./autogen.sh - name: configure run: ./configure OBJC="clang -m32" ${{ matrix.configure_flags }} - name: make run: make -j$(nproc) - name: make check |
︙ | ︙ |
Modified .github/workflows/ubuntu-latest-gcc-32bit.yml from [b827a9a41f] to [e9d9b51c60].
︙ | ︙ | |||
20 21 22 23 24 25 26 | - --without-tls --disable-shared --enable-seluid24 - --without-tls --disable-compiler-tls --disable-threads steps: - name: Install dependencies run: | sudo apt-get update sudo apt-get install gcc-multilib gobjc | | | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | - --without-tls --disable-shared --enable-seluid24 - --without-tls --disable-compiler-tls --disable-threads steps: - name: Install dependencies run: | sudo apt-get update sudo apt-get install gcc-multilib gobjc - uses: actions/checkout@v4 - name: autogen.sh run: ./autogen.sh - name: configure run: ./configure OBJC="gcc -m32" ${{ matrix.configure_flags }} - name: make run: make -j$(nproc) - name: make check |
︙ | ︙ |
Modified .github/workflows/ubuntu-latest-gcc.yml from [4509107d9f] to [aebb3c6867].
︙ | ︙ | |||
17 18 19 20 21 22 23 24 25 26 27 | - --disable-sockets --disable-files - --disable-files - --disable-shared - --disable-shared --enable-seluid24 - --disable-compiler-tls --disable-threads - --with-tls=gnutls - --with-tls=gnutls --disable-shared steps: - name: Install dependencies run: | sudo apt-get update | > > | | | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | - --disable-sockets --disable-files - --disable-files - --disable-shared - --disable-shared --enable-seluid24 - --disable-compiler-tls --disable-threads - --with-tls=gnutls - --with-tls=gnutls --disable-shared - --with-tls=mbedtls - --with-tls=mbedtls --disable-shared steps: - name: Install dependencies run: | sudo apt-get update sudo apt-get install gobjc libssl-dev gnutls-dev libmbedtls-dev - uses: actions/checkout@v4 - name: autogen.sh run: ./autogen.sh - name: configure run: ./configure OBJC="gcc" ${{ matrix.configure_flags }} - name: make run: make -j$(nproc) - name: make check |
︙ | ︙ |
Modified .github/workflows/ubuntu-latest.yml from [36a38ec742] to [c0481fd267].
︙ | ︙ | |||
17 18 19 20 21 22 23 24 25 26 27 | - --disable-sockets --disable-files - --disable-files - --disable-shared - --disable-shared --enable-seluid24 - --disable-compiler-tls --disable-threads - --with-tls=gnutls - --with-tls=gnutls --disable-shared steps: - name: Install dependencies run: | sudo apt-get update | > > | | | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | - --disable-sockets --disable-files - --disable-files - --disable-shared - --disable-shared --enable-seluid24 - --disable-compiler-tls --disable-threads - --with-tls=gnutls - --with-tls=gnutls --disable-shared - --with-tls=mbedtls - --with-tls=mbedtls --disable-shared steps: - name: Install dependencies run: | sudo apt-get update sudo apt-get install libssl-dev gnutls-dev libmbedtls-dev - uses: actions/checkout@v4 - name: autogen.sh run: ./autogen.sh - name: configure run: ./configure ${{ matrix.configure_flags }} - name: make run: make -j$(nproc) - name: make check |
︙ | ︙ |
Modified .github/workflows/wii-u.yml from [7d250df7d0] to [e120b2edbe].
1 2 3 4 5 6 7 8 | name: wii-u on: [push, pull_request] jobs: build: runs-on: ubuntu-latest steps: - name: Install dependencies run: docker pull devkitpro/devkitppc | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | name: wii-u on: [push, pull_request] jobs: build: runs-on: ubuntu-latest steps: - name: Install dependencies run: docker pull devkitpro/devkitppc - uses: actions/checkout@v4 - name: autogen.sh run: ./autogen.sh - name: configure run: | docker run \ -e DEVKITPRO=/opt/devkitpro \ -e PATH="/opt/devkitpro/devkitPPC/bin:$PATH" \ |
︙ | ︙ |
Modified .github/workflows/wii.yml from [59cebc18ff] to [191971b95d].
1 2 3 4 5 6 7 8 | name: wii on: [push, pull_request] jobs: build: runs-on: ubuntu-latest steps: - name: Install dependencies run: docker pull devkitpro/devkitppc | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | name: wii on: [push, pull_request] jobs: build: runs-on: ubuntu-latest steps: - name: Install dependencies run: docker pull devkitpro/devkitppc - uses: actions/checkout@v4 - name: autogen.sh run: ./autogen.sh - name: configure run: | docker run \ -e DEVKITPRO=/opt/devkitpro \ -e PATH="/opt/devkitpro/devkitPPC/bin:$PATH" \ |
︙ | ︙ |
Modified .gitignore from [726b780402] to [77b3609eea].
︙ | ︙ | |||
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | generators/unicode/gen_tables src/Info.plist src/bridge/Info.plist src/libobjfw.* src/objfw-defs.h src/runtime/Info.plist src/runtime/libobjfwrt.* src/tls/Info.plist tests/DerivedData tests/EBOOT.PBP tests/Info.plist tests/PARAM.SFO tests/iOS.xcodeproj/*.pbxuser tests/iOS.xcodeproj/project.xcworkspace tests/iOS.xcodeproj/xcuserdata tests/objc_sync/objc_sync tests/plugin/Info.plist | > > > | | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | generators/unicode/gen_tables src/Info.plist src/bridge/Info.plist src/libobjfw.* src/objfw-defs.h src/runtime/Info.plist src/runtime/libobjfwrt.* src/test/libobjfwtest.a src/tls/Info.plist src/tls/libobjfwtls.* tests/DerivedData tests/EBOOT.PBP tests/Info.plist tests/PARAM.SFO tests/big_dictionary_msgpack.m tests/iOS.xcodeproj/*.pbxuser tests/iOS.xcodeproj/project.xcworkspace tests/iOS.xcodeproj/xcuserdata tests/objc_sync/objc_sync tests/plugin/Info.plist tests/subprocess/subprocess tests/terminal/terminal_tests tests/testfile_bin.m tests/testfile_ini.m tests/tests tests/tests.3dsx tests/tests.arm9 tests/tests.nds |
︙ | ︙ |
Renamed and modified LICENSE.GPLv3 [040444d592] to COPYING [edb0016d9f].
1 2 3 | GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 | | | 1 2 3 4 5 6 7 8 9 10 11 | GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. |
︙ | ︙ | |||
641 642 643 644 645 646 647 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License | | | | | 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: <program> Copyright (C) <year> <name of author> This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <https://www.gnu.org/licenses/>. The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <https://www.gnu.org/licenses/why-not-lgpl.html>. |
Added COPYING.LESSER version [20da05ea66].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library. |
Modified ChangeLog from [9da9558760] to [7f06c4f76b].
1 2 3 4 5 6 | Legend: * Changes of existing features or bugfixes + New features This file only contains the most significant changes. | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | Legend: * Changes of existing features or bugfixes + New features This file only contains the most significant changes. ObjFW 1.1.1 -> ObjFW 1.1.2, 2024-04-20 * Fixes configure script on systems using BusyBox for tr. * Fixes compiling for Haiku. * Fixes -[contentsOfDirectoryAtIRI:] corrupting the stack on Solaris. * Fixes compiling for Wii with newer SDK. * Fixes missing endbr / bti. * Minor optimizations to ARM64 assembly. ObjFW 1.1 -> ObjFW 1.1.1, 2024-04-14 * Fixes missing ${DESTDIR} in some Makefiles. ObjFW 1.0.12 -> ObjFW 1.1, 2024-04-14 * ObjFW is now licensed under LGPLv3.0-only. + Adds a new framework for writing tests called ObjFWTest. * All tests were migrated to ObjFWTest. + The runtime now supports associated objects. + OFDNSResolver now caches responses. + OFDNSResolver now supports URI and LOC DNS resource records. + Adds methods to handle path extension to OFIRI. + Adds support for Mbed TLS. + Adds more methods to OFSystemInfo to check for CPU features. * OFSystemInfo now only indicates CPU features as supported if the OS also supports them. + OFLHAArchive now supports extracting and creating files > 4 GB. + OFLHAArchive now supports header level 3. + OFLHAArchive now supports extracting -lhx-, -lz4- and -pm0- files. * OFLHAArchive no longer defaults to ISO 8859-1. + New class OFZooArchive for extracting and creating Zoo files. * The schemes for archive IRI handlers have been renamed. * The schemes for archive IRI handlers now look for the rightmost `!`, which allows for chaining with less quoting. * Fixes -[OFMutableArray replaceObjectIdenticalTo:withObject:] being inconsistent with -[OFMutableArray replaceObject:withObject:]. * Fixes getting non-existent xattrs in OFFileManager. * Objects on Windows, MS-DOS and 32 bit Solaris now get properly aligned so that SIMD can be used on ivars. * Fixes parsing of signed numbers in MessagePack. * Fixes a memory leak in OFTarArchive. + Adds support for typed extended file attributes (only on Haiku). + Adds support for extended file attributes on Haiku, NetBSD and FreeBSD. + OFStdIOStream now supports cursor movement and colors on MS-DOS. * All headers are now compatible with -masm=intel. + OFMatrix4x4 can now transform multiple vectors at once. + OFMatrix4x4 has a 3DNow! implementation for multiplication and vector transformations now. + OFMatrix4x4 has an SSE implementation for vector transformations now. * Updates Unicode support to 15.1. * Fixes compatibility with LibreSSL. * Fixes two linker warnings on macOS. * Fixes compiling on QNX. * OFLocale now supports automatic initialization. + ofarc now supports extracting and creating Zoo archives. + ofarc now has an --iri option to directly work on local and remote IRIs. + ofarc now prints the archive comment with -lv. + ofarc can now add an archive comment with --archive-comment=. + ofarc now propagates the quarantine xattr on macOS when extracting an archive. ObjFW 1.0.11 -> ObjFW 1.0.12, 2024-03-11 * Fixes a regression in OFZIPArchive that was introduced in 1.0.11 that resulted in failing to extract archives and creating broken archives. * Fixes a rare condition where OFInflateStream could end up in an endless loop. * Fixes OFTarArchiveEntry not having a default date, which could result in messaging nil on a FP return, which yielded invalid results on 32-bit x86 with GCC. ObjFW 1.0.10 -> ObjFW 1.0.11, 2024-03-09 * Fixes -[OFHTTPClientResponse isAtEndOfStream] and -[OFGZIPStream isAtEndOfStream]. * Fixes how OFZIPArchive handles disk 0 vs. disk 1. * OFLHAArchive and OFZIPArchive create more compatible archives now. * OFLHAArchive ignores padding in level 2 headers now. * ofarc correctly sets modification dates of directories now by delaying setting those until after all files have been extracted. * Fixes a linker warning on macOS/iOS. * Several minor documentation fixes. * OFFileIRIHandler correctly transforms exceptions now so that they use an IRI and not a path. ObjFW 1.0.9 -> ObjFW 1.0.10, 2024-02-24 * Fixes objc_getClassList() not releasing the global runtime mutex. * Improves OFLHAArchive's compatibility with non-standard archives. + Adds endbr32 / endbr64 / bti instructions for compatibility with Control Flow Integrity. ObjFW 1.0.8 -> ObjFW 1.0.9, 2024-02-18 * Fixes OFGZIPStream reading the size and CRC32 incorrectly when either spans multiple reads. * Fixes a type mismatch in OFMapTable that could cause problems on big endian systems when uint32_t and unsigned long have a different size. * Fixes the default implementation of -[initWithKeys:arguments:] for custom dictionaries. * Improves detection of mutation during enumeration in -[enumerateKeysAndObjectsUsingBlock:]. * Minor documentation fixes. ObjFW 1.0.7 -> ObjFW 1.0.8, 2024-01-21 * Fixes compilation on NetBSD, OpenBSD, OpenIndiana etc. which was broken by 1.0.7. ObjFW 1.0.6 -> ObjFW 1.0.7, 2024-01-21 * Fixes inheriting the environment in OFSubprocess. * Fixes dealloc in OFSubprocess when -[closeForWriting] was called. + Adds tests for OFSubprocess. * Changes the key for +[OFSystemInfo networkInterfaces] to the adapter name on Windows XP and newer to avoid a possible collission on the adapter index. * Fixes compilation with old MinGW versions. * Fixes the documentation for OFSRVDNSResourceRecord. ObjFW 1.0.5 -> ObjFW 1.0.6, 2024-01-15 * Fixes compatibility with autoconf 2.72. * Fixes OFDNSResolver's handling of types, classes and lengths > 255. ObjFW 1.0.4 -> ObjFW 1.0.5, 2023-11-05 * Fixes the calculation of the extra alignment in OFAllocObject() * Fixes +[OFSystemInfo networkInterfaces] on OpenBSD and Windows 98 * Fixes OFSocketAddressString() for AppleTalk addresses * Uses GetModuleHandle() instead of LoadLibrary() where possible on Windows * Disables tests for global blocks on Win64 due to broken compilers * Adds PGP keys to verify tarballs and commits in the code repository ObjFW 1.0.3 -> ObjFW 1.0.4, 2023-10-08 * Fixes OFFile closing fd 0 when initialization fails * Fixes -[stringByAppendingPathComponent:] on empty strings * Fixes +[OFSystemInfo operatingSystemName] and +[OFSystemInfo operatingSystemVersion] returning nil on some systems * Adds a license for localizations ObjFW 1.0.2 -> ObjFW 1.0.3, 2023-09-14 * Fixes -[OFConcreteData initWithItemSize:] not setting freeWhenDone to true, which resulted in a memory leak * Fixes -[OFData initWithContentsOfIRI:] freeing the buffer in @catch instead of @finally, which resulted in a memory leak ObjFW 1.0.1 -> ObjFW 1.0.2, 2023-09-11 * The build system has been updated to fix building .frameworks and to build them differently for macOS and iOS ObjFW 1.0 -> ObjFW 1.0.1, 2023-09-10 * Hanging connections with OFTLSStream have been fixed when using OpenSSL * The same fix as for OpenSSL has been applied to GnuTLS and SecureTransport out of caution, even though there have been no hangs in practice * The build system has been updated to fix building .frameworks among other minor changes * Some headers have been changed to fix compatibility with ObjC++ * Warnings about empty .o files on x86_64 Darwin have been fixed * The OFDate documentation has been improved to list supported formats ObjFW 0.90.2 -> ObjFW 1.0, 2023-08-29 + First stable release with stable API and ABI * Too many changes to list, as it has been almost 6 years since the last release. See commits in the repository for details. ObjFW 0.90.1 -> ObjFW 0.90.2, 2017-10-23 * Fix shadowed variables which caused many bugs (e.g. using the wrong object) * Many, many nullability fixes * OFTCPSocket: Fix exception not being retained for async connect * OFThread: Fix setting the name on the wrong thread * OFMutableSet: Fix missing override for -[copy] * configure: Fix posix_spawnp check * Xcode project: Set the correct version for the bridge * Better check for iOS * tests: Fix testing the wrong OFKernelEventObserver ObjFW 0.90 -> ObjFW 0.90.1, 2017-08-20 * OFData: Fix -[description] * OFFileManager: Set errno to 0 before readdir() * OFDate: Add -[localMinute] * OFTarArchiveEntry: Fix prefix handling for ustar * OFZIPArchive: Fix uncompressed + data descriptor * OFArray: Fix MessagePack encoding * of_asprintf: Don't require set up OFLocalization * OFGZIPStream: Add missing documentation * Fix a linker warning on OpenBSD/SPARC64 * Remove the OFFile b modes from MorphOS (they were already removed for all other OSes) ObjFW 0.8.1 -> ObjFW 0.90, 2017-08-01 + New classes: OFFileManager, OFGZIPStream, OFTarArchive, OFTarArchiveEntry OFHMAC, OFSandbox, OFHTTPCookie, OFHTTPCookieManager, OFLocalization + New platforms: Nintendo 3DS, MorphOS + New lookup assembly for platforms: SPARC64/ELF, ARM64/ELF + New forwarding for: ARM64/ELF + New tools: objfw-new (to create boilerplate code) |
︙ | ︙ | |||
56 57 58 59 60 61 62 | * OFHash was renamed to OFCryptoHash + PBKDF2 + scrypt + Xcode project to build for iOS + String decomposition to NFD * OFFile modes simplified ('b' removed) | | | | 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | * OFHash was renamed to OFCryptoHash + PBKDF2 + scrypt + Xcode project to build for iOS + String decomposition to NFD * OFFile modes simplified ('b' removed) ObjFW 0.8 -> ObjFW 0.8.1, 2015-10-04 * Adjust to __nullable / __nonnull being changed to _Nullable / _Nonnull in Clang 3.7 (this fixes compilation with Clang 3.7) * Blocks: Proper handling when called from a byref handler * Fix compilation on Solaris * Fix compilation for Wii, PSP and Nintendo DS * OFProcess: Send SIGTERM on close instead of SIGKILL * OFZIPArchive: Throw invalid format exception on failed seeks * Make sure of_hash_seed is never initialized to 0 * Special cases for the Wii's weird network stack (fixes the tests) * Better length checks for write / send calls * Don't use -pedantic on platforms where it's broken by the system headers * Documentation fixes ObjFW 0.7.1 -> ObjFW 0.8, 2015-08-14 + An insanely huge amount of new APIs + New classes: OFHTTPServer, OFINICategory, OFINIFile, OFInflate64Stream, OFInflateStream, OFMapTable, OFRIPEMD160Hash, OFSHA224Hash, OFSHA256Hash, OFSHA384Hash, OFSHA512Hash, OFSettings, OFStdIOStream, OFSystemInfo, OFUDPSocket, OFZIPArchive, OFZIPArchiveEntry + New utils: ofzip, ofhash, ofhttp |
︙ | ︙ | |||
119 120 121 122 123 124 125 | * OFProcess improvements for Win32 + epoll support for OFKernelEventObserver * Rewritten OFMD5Hash and OFSHA1Hash * Reworked OFTLSSocket API (easier verification) * Unicode support updated to Unicode 8.0 * OFURL: Proper escaping and unescaping | | | | 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 | * OFProcess improvements for Win32 + epoll support for OFKernelEventObserver * Rewritten OFMD5Hash and OFSHA1Hash * Reworked OFTLSSocket API (easier verification) * Unicode support updated to Unicode 8.0 * OFURL: Proper escaping and unescaping ObjFW 0.7 -> ObjFW 0.7.1, 2012-11-12 + Support for Haiku * Autorelease pools now work properly without __thread * Incorrect framework version in Xcode project fixed * Documentation fixes and improvements * Blocks now only use 16 bits for the reference count in order to avoid problems with newer Clang versions * More use of OF_SENTINEL ObjFW 0.6 -> ObjFW 0.7, 2012-10-27 Again, the differences are more than in any release before, thus listing them all would be too much. The major differences are: + ObjFW now comes with its own runtime, which greatly increases performance compared to the GNU runtime and is even faster than the Apple runtime (using Clang >= 3.2 is recommended, but not necessary) * Support for the GNU runtime has been dropped + New, much faster autorelease pool implementation (now inside the runtime) |
︙ | ︙ | |||
152 153 154 155 156 157 158 | * Strings are allocated faster now + Support for JSON5 * All private methods use the prefix OF_ now instead of _, making it possible to use the _ prefix in applications * Most ObjC compiler feature checks are not part of configure anymore, making it possible to use the same installation with different compilers | | | | | | | | | | | 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 | * Strings are allocated faster now + Support for JSON5 * All private methods use the prefix OF_ now instead of _, making it possible to use the _ prefix in applications * Most ObjC compiler feature checks are not part of configure anymore, making it possible to use the same installation with different compilers ObjFW 0.5.4 -> ObjFW 0.6, 2012-02-27 The differences between 0.5.4 and 0.6 are too big to list them all. However, the major new features are: * OFString, OFArray, OFDictionary, OFSet and OFCountedSet are now class clusters + Serialization and deserialization of objects into/from XML and JSON + New class OFIntrospection for introspecting classes + New class OFProcess for working with and controlling child processes * Lots of OFXMLParser and OFXMLElement improvements + OFHTTPRequests can have a delegate now for status updates and processing data as soon as it arrives + There are several backends for OFStreamObserver now, including kqueue, poll and select + SOCKS5 support for OFTCPSockets (client only) * Several API changes ObjFW 0.5.3 -> ObjFW 0.5.4, 2011-08-30 * The blocks runtime is now working correctly * Documentation fixes * -framework works with objfw-compile now + Support for QNX * Various small fixes ObjFW 0.5.2 -> ObjFW 0.5.3, 2011-07-01 * Lots of bugfixes, see Git log for details ObjFW 0.5.1 -> ObjFW 0.5.2, 2011-04-25 * Fix double-retain in OFList * Don't ignore the timeout in OFStreamObserver when using select() * Do -[OFURL copy] in a try block to prevent a leak when an exception occurs * Fix too big buffer in -[OFMutableString _applyTable:withSize:] * Call madvise() on the correct length variable so it covers the whole string * Fix a warning when sizeof(size_t) < sizeof(long long) * Skip possible BOMs when appending strings ObjFW 0.5 -> ObjFW 0.5.1, 2011-04-21 * Work around a wrong warning produced by Apple GCC 4.0.1 which would cause the build to fail due to -Werror * Call objc_thread_{add,remove} when using the GNU runtime to make sure the runtime knows about our thread * Detach a thread before restarting if it was never joined * Release the old return value when restarting a thread ObjFW 0.4-alpha1 -> 0.5, 2011-04-09 + %@ is now allowed in format strings + Added of_log for easy logging * Exceptions have one header per exception now * Lots of exception improvements * Huge improvements in XML handling * Improvements in socket handling, including improved API * OFStreamObserver is now thread-safe and stops the current observe call when the set of streams to observe is modified + New class OFURL + New class OFHTTPRequest + New class OFCondition * Improvements in objfw-compile + Blocks can be used together with Cocoa now + When linking ObjFW and Cocoa, OFAutoreleasePools are used by both now + Support for Base64 + Use a real Xcode project instead of just calling make + Add Haiku to the list of supported platforms * Lots of small bugfixes and countless small changes. Read the commits! ObjFW 0.3.1 -> 0.4-alpha1, 2011-01-03 * ObjFW is now available under the terms of the QPL, GPLv2 and GPLv3 + Support for blocks was added, including a blocks runtime + Added support for the new GNU runtime, introduced in GCC 4.6 * Objects returned from collections are no longer retained and autoreleased + Added new classes OFXMLParser, OFXMLElement, OFXMLAttribute and OFXMLElementBuilder + Added new class OFStreamObserver to observe streams + Added new class OFDate for storing dates + Many new methods in almost all classes * OFAutoreleasePool was optimized * Handling of ASCII strings was optimized * OFSocket was renamed to OFStreamSocket * OFConstString was renamed to OFConstantString * objfw-compile now has a new syntax + objfw-compile can now compile libraries and plugins * Many small changes and new features that would be too much to list here The diff between 0.3.1 and 0.4-alpha1 has almost 24000 lines! ObjFW 0.3 -> 0.3.1, 2010-06-19 * Fix a typo in OFMutableDictionary that prevented termination in case the last bucket is already used when the dictionary is resized * The mutations pointer is now correctly initialized in enumerators for immutable collections * The objc_sync test was still using the old threads API and was updated to use the new one now * PLATFORMS has been updated to be more specific ObjFW 0.2.1 -> 0.3, 2010-05-09 + Many new methods were added to different classes + A huge amount of methods was added to OFStream, allowing easy binary stream handling and even mixing string-based and binary operations + An optional write buffer was added to OFStream + OFSeekableStream was added for streams that allow seeking, for example OFFiles * OFNumber was completely reworked and got many new features now |
︙ | ︙ | |||
284 285 286 287 288 289 290 | * The instance variable naming convention was changed so that properties work + Properties were added to the interfaces and are used if they are supported by the compiler + The library version is now included in the resulting dylib and libobjc is reexported now. Additionally, objfw-config offers --reexport now to produce libraries that link against ObjFW and reexport it | | | | 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 | * The instance variable naming convention was changed so that properties work + Properties were added to the interfaces and are used if they are supported by the compiler + The library version is now included in the resulting dylib and libobjc is reexported now. Additionally, objfw-config offers --reexport now to produce libraries that link against ObjFW and reexport it ObjFW 0.2 -> 0.2.1, 2010-03-14 * Fix for OFNumbers not doing calculations * Improved -[hash] for OFNumbers with floats and doubles + Tests for OFNumber * Small optimization for OFArray's -[componentsJoinedByString:] * Documentation improvements * Updated copyright ObjFW 0.1.2 -> 0.2, 2010-02-01 + Support for ObjC 2 Fast Enumerations on every platform which has compiler support for fast enumerations + Support for ObjC 2 properties on every platform with compiler support + Fast Enumeration through arrays and dictionaries * OFIterator has been removed + OFEnumerator was added to replace OFIterator, which is more general and works with arrays and dictionaries |
︙ | ︙ | |||
321 322 323 324 325 326 327 | * The interfaces of OFSocket and OFStream were cleaned up and some methods were moved to OFTCPSocket, as they make sense only there * File methods unavailable on Windows don't throw an exception at runtime anymore, but instead are not even in the interface on Windows. This way, it is a compile time error instead of a runtime error | | | | | 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 | * The interfaces of OFSocket and OFStream were cleaned up and some methods were moved to OFTCPSocket, as they make sense only there * File methods unavailable on Windows don't throw an exception at runtime anymore, but instead are not even in the interface on Windows. This way, it is a compile time error instead of a runtime error ObjFW 0.1.1 -> 0.1.2, 2010-01-15 * Fix a bug in OFMutableArray's -[removeObject:] and -[removeObjectIdenticalTo:] that could lead to not removing all occurrences of the object from the array and to out of bounds reads * Change the URL in the framework plist to the homepage ObjFW 0.1 -> 0.1.1, 2010-01-04 * Fix a missing out of range check for -[removeNItems:atIndex:] that allowed the programmer to specify too big ranges so it would crash instead of throwing an exception * Fix missing calls to -[retain] and -[autorelease] when getting objects from an OFArray or OFDictionary * Safer and more fault-tolerant way to remove objects from an OFMutableArray * Calling +[dealloc] throws an exception now. If someone really calls [SomeClass dealloc], this should be punished and not ignored, as this is a serious programmer error * -[readLineWithEncoding:] is more fault-tolerant now and does not lose data when it stumbles upon invalid encoding. Instead, it allows recalling with the correct encoding now ObjFW 0.1, 2009-12-24 + Initial release |
Modified Doxyfile from [6b8aa42255] to [75514e9314].
1 2 | PROJECT_NAME = "ObjFW" OUTPUT_DIRECTORY = docs/ | | | < | | | | | > > > > > > | > | | > > > | | | > | | | | | | | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | PROJECT_NAME = "ObjFW" OUTPUT_DIRECTORY = docs/ INPUT = src src/exceptions src/runtime src/test FILE_PATTERNS = *.h *.m HTML_OUTPUT = . HAVE_DOT = NO GENERATE_LATEX = NO HIDE_UNDOC_CLASSES = YES HIDE_UNDOC_MEMBERS = YES TYPEDEF_HIDES_STRUCT = YES PREDEFINED = _Nonnull= \ _Nullable= \ DOXYGEN \ OF_BOXABLE= \ OF_CONSUMED= \ OF_DESIGNATED_INITIALIZER= \ OF_DEPRECATED(...)= \ 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_PLUGINS \ OF_HAVE_SANDBOX \ OF_HAVE_SOCKETS \ OF_HAVE_THREADS \ OF_HAVE_UNICODE_TABLES \ 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_ OT OT_ |
Deleted LICENSE.GPLv2 version [32fac3e90c].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted LICENSE.QPL version [714e65c9ba].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Modified Makefile from [4341fed160] to [cf98c87f50].
︙ | ︙ | |||
8 9 10 11 12 13 14 | config.h \ config.log \ config.status \ extra.mk include buildsys.mk | | | < < < | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | config.h \ config.log \ config.status \ extra.mk include buildsys.mk .PHONY: check docs release utils tests: src check: tests ${MAKE} -C tests -s run docs: rm -fr docs doxygen >/dev/null release: docs echo "Generating tarball for version ${PACKAGE_VERSION}..." rm -fr objfw-${PACKAGE_VERSION} objfw-${PACKAGE_VERSION}.tar \ objfw-${PACKAGE_VERSION}.tar.gz fossil tarball --name objfw-${PACKAGE_VERSION} current - \ --exclude '.fossil*,.git*' | ofarc -ttgz -xq - cp configure config.h.in objfw-${PACKAGE_VERSION}/ ofarc -cq objfw-${PACKAGE_VERSION}.tar objfw-${PACKAGE_VERSION} rm -fr objfw-${PACKAGE_VERSION} gzip -9 objfw-${PACKAGE_VERSION}.tar rm -f objfw-${PACKAGE_VERSION}.tar gpg -b objfw-${PACKAGE_VERSION}.tar.gz || true rm -fr objfw-docs-${PACKAGE_VERSION} objfw-docs-${PACKAGE_VERSION}.tar \ objfw-docs-${PACKAGE_VERSION}.tar.gz mv docs objfw-docs-${PACKAGE_VERSION} echo "Generating docs tarball for version ${PACKAGE_VERSION}..." ofarc -cq objfw-docs-${PACKAGE_VERSION}.tar \ objfw-docs-${PACKAGE_VERSION} rm -fr objfw-docs-${PACKAGE_VERSION} gzip -9 objfw-docs-${PACKAGE_VERSION}.tar rm -f objfw-docs-${PACKAGE_VERSION}.tar gpg -b objfw-docs-${PACKAGE_VERSION}.tar.gz || true |
Modified PLATFORMS.md from [cb8b9b98c6] to [2210a2624d].
︙ | ︙ | |||
41 42 43 44 45 46 47 | * Runtimes: ObjFW DragonFlyBSD ------------ * OS Versions: 3.0, 3.3-DEVELOPMENT | | | > > > > > > > > > | | | < > | | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | * Runtimes: ObjFW DragonFlyBSD ------------ * OS Versions: 3.0, 3.3-DEVELOPMENT * Architectures: AMD64, x86 * Compilers: GCC 4.4.7 * Runtimes: ObjFW FreeBSD ------- * OS Versions: 9.1-rc3, 10.0 * 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 Haiku ----- * OS version: r1-alpha4 * Architectures: x86 * Compilers: Clang 3.2, GCC 4.6.3 * Runtimes: ObjFW HP-UX ----- * OS versions: 11i v1, 11i v3 * Architectures: Itanium, PA-RISC 2.0 * Compilers: GCC 4.7.2, GCC 7.5.0 * Runtimes: ObjFW * Notes: Exception handling on Itanium in 32 bit mode is broken, you need to use 64 bit mode by passing `OBJC="gcc -mlp64"` to `configure`. iOS --- * Architectures: ARMv7, ARM64 * Compilers: Clang * Runtimes: Apple Linux ----- * 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: AMD64, PowerPC, PowerPC64, x86 * Compilers: Clang 3.1-10.0, Apple GCC 4.0.1 & 4.2.1 * Runtimes: Apple, ObjFW MiNT ---- |
︙ | ︙ | |||
125 126 127 128 129 130 131 | * Runtimes: ObjFW NetBSD ------ * OS Versions: 5.1-9.0 | | | | 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | * Runtimes: ObjFW NetBSD ------ * OS Versions: 5.1-9.0 * Architectures: AMD64, ARM, ARM (big endian, BE8 mode), MIPS (O32), PowerPC, SPARC, SPARC64, x86 * Compilers: Clang 3.0-3.2, GCC 4.1.3 & 4.5.3 & 7.4.0 * Runtimes: ObjFW Nintendo 3DS ------------ |
︙ | ︙ | |||
165 166 167 168 169 170 171 | * Limitations: No sockets, no shared libraries, not tested on real hardware OpenBSD ------- * OS Versions: 5.2-6.7 | | | 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | * Limitations: No sockets, no shared libraries, not tested on real hardware OpenBSD ------- * OS Versions: 5.2-6.7 * Architectures: AMD64, MIPS64, PA-RISC, PowerPC, SPARC64 * Compilers: GCC 6.3.0, Clang 4.0 * Runtimes: ObjFW PlayStation Portable -------------------- |
︙ | ︙ | |||
192 193 194 195 196 197 198 | * Compilers: GCC 4.6.1 * Runtimes: ObjFW Solaris ------- | | | | | 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | * Compilers: GCC 4.6.1 * Runtimes: ObjFW Solaris ------- * OS Versions: OpenIndiana 2015.03, OpenIndiana 2023.04, Oracle Solaris 11.4 * Architectures: AMD64, x86 * Compilers: Clang 3.4.2, Clang 11.0.0, Clang 13.0.1, GCC 4.8.3, GCC 10.4.0 * Runtimes: ObjFW Wii --- * OS Versions: 4.3E / Homebrew Channel 1.1.0 |
︙ | ︙ | |||
222 223 224 225 226 227 228 | * Limitations: No files, no threads, no sockets, no shared libraries, not tested on real hardware Windows ------- | | < | | | | 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | * Limitations: No files, no threads, no sockets, no shared libraries, not tested on real hardware Windows ------- * OS Versions: 98 SE, NT 4.0, XP, 7, 8, 8.1, 10, 11, Wine * 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 (AMD64 & x86), Clang 14.0.4 from msys2 (AArch64) * Runtimes: ObjFW Others ------ |
︙ | ︙ | |||
252 253 254 255 256 257 258 259 260 261 262 263 264 265 | ========== 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): * 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) | > < | 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | ========== 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) Apple/Mach-O means both, the Apple ABI and runtime, while Mach-O means the ObjFW runtime on Mach-O. |
Modified README.md from [711c05e9ce] to [e80110edc6].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | There are three ways you are probably reading this right now: * On [ObjFW](https://objfw.nil.im/)'s homepage, via Fossil's web interface * On [GitHub](https://github.com/ObjFW/ObjFW) * Via an editor or pager, by opening `README.md` from a clone or tarball ObjFW is developed using Fossil, so if you are reading this on GitHub or any other place, you are most likely using a mirror. <h1 id="table-of-contents">Table of Contents</h1> * [What is ObjFW?](#what) * [License](#license) * [Releases](#releases) * [Cloning the repository](#cloning) | > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | There are three ways you are probably reading this right now: * On [ObjFW](https://objfw.nil.im/)'s homepage, via Fossil's web interface * On [GitHub](https://github.com/ObjFW/ObjFW) * Via an editor or pager, by opening `README.md` from a clone or tarball ObjFW is developed using Fossil, so if you are reading this on GitHub or any other place, you are most likely using a mirror. <h1 id="table-of-contents">Table of Contents</h1> * [What is ObjFW?](#what) * [Installation](#installation) * [License](#license) * [Releases](#releases) * [Cloning the repository](#cloning) * [Building from source](#building-from-source) * [macOS and iOS](#macos-and-ios) * [Building as a framework](#building-framework) * [Using the macOS or iOS framework in Xcode](#framework-in-xcode) * [Broken Xcode versions](#broken-xcode-versions) * [Windows](#windows) * [Getting MSYS2](#getting-msys2) * [Setting up MSYS2](#setting-up-msys2) |
︙ | ︙ | |||
50 51 52 53 54 55 56 | ObjFW is intentionally incompatible with Foundation. This has two reasons: * GNUstep already provides a reimplementation of Foundation, which is only compatible to a certain degree. This means that a developer still needs to care about differences between frameworks if they want to be portable. The idea behind ObjFW is that a developer does not need to concern themselves | | | | > < | > > > > > > > > > > > > > > > > | > > | > | | < | | | | | < < < < | | | | | | | | | | | | | | | | | < | | | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | ObjFW is intentionally incompatible with Foundation. This has two reasons: * GNUstep already provides a reimplementation of Foundation, which is only compatible to a certain degree. This means that a developer still needs to care about differences between frameworks if they want to be portable. The idea behind ObjFW is that a developer does not need to concern themselves with portability and making sure their code works with multiple frameworks: Instead, if it works it ObjFW on one platform, they can reasonably expect it to also work with ObjFW on another platform. ObjFW behaving differently on different operating systems (unless inevitable because it is a platform-specific part, like the Windows Registry) is considered a bug and will be fixed. * Foundation predates a lot of modern Objective-C concepts. The most prominent one is exceptions, which are only used in Foundation as a replacement for `abort()`. This results in cumbersome error handling, especially in initializers, which in Foundation only return `nil` on error with no indication of what went wrong. It also means that the return of every `init` call needs to be checked against `nil`. But in the wild, nobody actually checks *each and every* return from `init` against `nil`, leading to bugs. ObjFW fixes this by making exceptions a first class citizen. ObjFW also comes with its own lightweight and extremely fast Objective-C runtime, which in real world use cases was found to be significantly faster than both GNU's and Apple's runtime. <h1 id="installation">Installation</h1> ObjFW packages are available for various operating systems and can be installed as following: Operating System | Command ---------------------------|--------------------------------------------- Alpine Linux | `doas apk add objfw` CRUX | `sudo prt-get depinst objfw` Fedora | `sudo dnf install objfw` FreeBSD | `sudo pkg install objfw` Haiku | `pkgman install objfw` Haiku (gcc2h) | `pkgman install objfw_x86` macOS (Homebrew) | `brew install objfw` macOS (pkgsrc) | `cd $PKGSRCDIR/devel/objfw && make install` NetBSD | `cd /usr/pkgsrc/devel/objfw && make install` OpenBSD | `doas pkg_add objfw` OpenIndiana | `sudo pkg install developer/objfw` Windows (MSYS2/CLANG64) | `pacman -S mingw-w64-clang-x86_64-objfw` Windows (MSYS2/CLANGARM64) | `pacman -S mingw-w64-clang-aarch64-objfw` Windows (MSYS2/UCRT64) | `pacman -S mingw-w64-ucrt-x86_64-objfw` Windows (MSYS2/MINGW32) | `pacman -S mingw-w64-i686-objfw` If your operating system is not listed, you can <a href="#building-from-source">build ObjFW from source</a>. <h1 id="license">License</h1> ObjFW is released under the GNU Lesser General Public License version 3.0. If this license does not work for you, contact me and we can find a solution. <h1 id="releases">Releases</h1> Releases of ObjFW, as well as change logs and the accompanying documentation, can be found [here](https://objfw.nil.im/wiki?name=Releases). <h1 id="cloning">Cloning the repository</h1> ObjFW is developed in a [Fossil](https://fossil-scm.org) repository, with automatic incremental exports to Git. This means you can either clone the Fossil repository or the Git repository - it does not make a huge difference. The main advantage of cloning the Fossil repository over cloning the Git repository is that you also get all the tickets, wiki pages, etc. <h2 id="cloning-fossil">Fossil</h2> Clone the Fossil repository like this: fossil clone https://objfw.nil.im You can then use Fossil's web interface to browse the timeline, tickets, wiki pages, etc.: cd objfw fossil ui In order to verify the signature of the currently checked out checkin, you can use: fossil artifact current | gpg --verify Please note that not all checkins are signed, as the signing key only resides on trusted systems. This means that checkins I perform on e.g. Windows are unsigned. However, usually it should not take long until there is another signed checkin. Alternatively, you can go back until the last signed checkin and review changes from there on. <h2 id="cloning-git">Git</h2> To clone the Git repository, use the following: git clone https://github.com/ObjFW/ObjFW Git commits are not signed, so if you want to check the signature of an individual commit, branch head or tag, please use Fossil. <h1 id="building-from-source">Building from source</h1> To build ObjFW from source and install it, just run the following commands: ./configure make make check sudo make install In case you checked out ObjFW from the Fossil or Git repository, you need to run the following command first: ./autogen.sh <h2 id="macos-and-ios">macOS and iOS</h2> <h3 id="building-framework">Building as a framework</h3> When building for macOS or iOS, everything is built as a `.framework` by default if `--disable-shared` has not been specified to `./configure`. The frameworks will end up in `$PREFIX/Library/Frameworks`. To build for macOS, just follow the <a href="#building-from-source">regular instructions</a> above. To build for iOS, follow the regular instructions, but instead of `./configure` do something like this: 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="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 <h3 id="framework-in-xcode">Using the macOS or iOS framework in Xcode</h3> To use the macOS framework in Xcode, you need to add the `.framework`s to your project and add the following flags to `Other C Flags`: -fconstant-string-class=OFConstantString -fno-constant-cfstrings |
︙ | ︙ | |||
234 235 236 237 238 239 240 | for the one called just "MSYS" are supported, but which packages you need to install depends on the environment(s) you want to use. If you only want to target Windows 10 and newer, the CLANG64 and CLANG32 environments are the recommended ones. For CLANG64, use: | | > > | > > | | > > | > > | > > | | | | | | | | | | | > > > > > < < < < < < < | | | | | | 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 | for the one called just "MSYS" are supported, but which packages you need to install depends on the environment(s) you want to use. If you only want to target Windows 10 and newer, the CLANG64 and CLANG32 environments are the recommended ones. For CLANG64, use: pacman -Syu mingw-w64-clang-x86_64-clang \ mingw-w64-clang-x86_64-fossil \ mingw-w64-clang-x86_64-openssl For CLANG32, use: pacman -Syu mingw-w64-clang-i686-clang \ mingw-w64-clang-i686-fossil \ mingw-w64-clang-i686-openssl For CLANGARM64, use (you need to use Fossil via another environment): pacman -Syu mingw-w64-clang-aarch64-clang mingw-w64-clang-aarch64-openssl For MINGW64, use: pacman -Syu mingw-w64-x86_64-clang \ mingw-w64-x86_64-fossil \ mingw-w64-x86_64-openssl For MINGW32, use: pacman -Syu mingw-w64-i686-clang \ mingw-w64-i686-fossil \ mingw-w64-i686-openssl For UCRT64, use: pacman -Syu mingw-w64-ucrt-x86_64-clang \ mingw-w64-ucrt-x86_64-fossil \ mingw-w64-ucrt-x86_64-openssl When using `pacman` to install the packages, `pacman` might tell you to close the window. If it does so, close the window, restart MSYS2 and execute the `pacman` command again. There is nothing wrong with installing multiple environments, as MSYS2 has created shortcuts for each of them in your start menu. Just make sure to use the correct shortcut for the environment you want to use. Finally, install a few more things that are common between all environments: pacman -S autoconf automake make <h3 id="steps-windows">Getting, building and installing ObjFW</h3> Start the MSYS2 using the shortcut for the environment you want to use and check out ObjFW: fossil clone https://objfw.nil.im You can also download a release tarball if you want. Now `cd` to the newly checked out repository and build and install it: ./autogen.sh && ./configure && make -j16 install If everything was successful, you can now build projects using ObjFW for Windows using the normal `objfw-compile` and friends. <h2 id="nintendo">Nintendo DS, Nintendo 3DS and Wii</h2> Download and install [devkitPro](https://devkitpro.org/wiki/Getting_Started). <h3 id="nintendo-ds">Nintendo DS</h3> Follow the normal process, but instead of `./configure` run: ./configure --host=arm-none-eabi --with-nds <h3 id="nintendo-3ds">Nintendo 3DS</h3> Follow the normal process, but instead of `./configure` run: ./configure --host=arm-none-eabi --with-3ds <h3 id="wii">Wii</h3> Follow the normal process, but instead of `./configure` run: ./configure --host=powerpc-eabi --with-wii <h2 id="amiga">Amiga</h2> Install [amiga-gcc](https://github.com/bebbo/amiga-gcc). Then follow the normal process, but instead of `./configure` run: ./configure --host=m68k-amigaos <h1 id="first-app">Writing your first application with ObjFW</h1> To create your first, empty application, you can use `objfw-new`: objfw-new --app MyFirstApp This creates a file `MyFirstApp.m`. The `-[applicationDidFinishLaunching:]` method is called as soon as ObjFW finished all initialization. Use this as the entry point to your own code. For example, you could add the following line there to create a "Hello World": [OFStdOut writeLine: @"Hello World!"]; You can compile your new app using `objfw-compile`: objfw-compile -o MyFirstApp MyFirstApp.m `objfw-compile` is a tool that allows building applications and libraries using ObjFW without needing a full-blown build system. If you want to use your own build system, you can get the necessary flags from `objfw-config`. <h1 id="documentation">Documentation</h1> You can find the documentation for released versions of ObjFW [here](https://objfw.nil.im/docs/). In order to build the documentation yourself (necessary to have documentation for trunk / master), you need to have [Doxygen](https://www.doxygen.nl) installed. Once installed, you can build the documentation from the root directory of the repository: make docs <h1 id="bugs">Bugs and feature requests</h1> If you find any bugs or have feature requests, please [file a new bug](https://objfw.nil.im/tktnew) in the [bug tracker](https://objfw.nil.im/reportlist). Alternatively, feel free to send a mail to js@nil.im! <h1 id="support">Support and community</h1> If you have any questions about ObjFW or would like to talk to other ObjFW users, the following venues are available: * The [forum](https://objfw.nil.im/forum) * A [Matrix room](https://matrix.to/#/%23objfw:nil.im) * A [Discord room](https://objfw.nil.im/discord), bridged to the Matrix room above * A [Telegram room](https://t.me/objfw), bridged to the Matrix room above * A [Slack room](https://objfw.nil.im/slack), bridged to the Matrix room above * An IRC channel named `#objfw` on `irc.oftc.net` ([Web chat](https://webchat.oftc.net/?channels=%23objfw)), bridged to the Matrix room above Please don't hesitate to join any or all of those! <h1 id="donating">Donating</h1> If you want to donate to ObjFW, you can read about possible ways to do so [here](https://objfw.nil.im/wiki?name=Donating). <h1 id="thanks">Thanks</h1> * Thank you to [Jonathan Neuschäfer](https://github.com/neuschaefer) for reviewing the *entirety* (all 84k LoC at the time) of ObjFW's codebase in 2017! * Thank you to [Hill Ma](https://github.com/mahiuchun) for donating an M1 Mac Mini to the project in 2022! <h1 id="commercial-use">Commercial use</h1> If for whatever reason the terms of GNU Lesser General Public License version 3.0 don't work for you, a proprietary license for ObjFW including support is available upon request. Just write a mail to js@nil.im and we can find a reasonable solution for both parties. |
Modified autogen.sh from [4f8a1648f4] to [fd90c83211].
1 2 3 4 | #!/bin/sh set -e # Set a version for OpenBSD | > | | | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 | #!/bin/sh set -e # Set a version for OpenBSD if test x"$(uname -s)" = x"OpenBSD"; then : ${AUTOCONF_VERSION:=2.71} : ${AUTOMAKE_VERSION:=1.16} export AUTOCONF_VERSION AUTOMAKE_VERSION fi aclocal -I build-aux/m4 autoconf autoheader |
Modified build-aux/config.guess from [a7bb5831a2] to [eff4d47d66].
1 2 | #! /bin/sh # Attempt to guess a canonical system name. | | > > | | | > > > > > > > > | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | #! /bin/sh # Attempt to guess a canonical system name. # Copyright 1992-2023 Free Software Foundation, Inc. # shellcheck disable=SC2006,SC2268 # see below for rationale timestamp='2023-08-22' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see <https://www.gnu.org/licenses/>. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: # https://git.savannah.gnu.org/cgit/config.git/plain/config.guess # # Please send patches to <config-patches@gnu.org>. # The "shellcheck disable" line above the timestamp inhibits complaints # about features and limitations of the classic Bourne shell that were # superseded or lifted in POSIX. However, this script identifies a wide # variety of pre-POSIX systems that do not have POSIX shells at all, and # even some reasonably current systems (Solaris 10 as case-in-point) still # have a pre-POSIX /bin/sh. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system '$me' is run on. Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to <config-patches@gnu.org>." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright 1992-2023 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try '$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) |
︙ | ︙ | |||
79 80 81 82 83 84 85 86 87 88 89 90 91 | esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. | > > > | | > > | | | | < < | > > > > > > > > | > > | > | > | | < | > > > > > > | < | | | | | < < | | | | | | | | | | > > > | > | | | | | | | | | > > > | | | | | | > > > | | | | > > | | 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi # Just in case it came from the environment. GUESS= # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, 'CC_FOR_BUILD' used to be named 'HOST_CC'. We still # use 'HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. tmp= # shellcheck disable=SC2172 trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15 set_cc_for_build() { # prevent multiple calls if $tmp is already set test "$tmp" && return 0 : "${TMPDIR=/tmp}" # shellcheck disable=SC2039,SC3028 { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } dummy=$tmp/dummy case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in ,,) echo "int x;" > "$dummy.c" for driver in cc gcc c89 c99 ; do if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then CC_FOR_BUILD=$driver break fi done if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac } # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if test -f /.attbin/uname ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown case $UNAME_SYSTEM in Linux|GNU|GNU/*) LIBC=unknown set_cc_for_build cat <<-EOF > "$dummy.c" #if defined(__ANDROID__) LIBC=android #else #include <features.h> #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc #elif defined(__GLIBC__) LIBC=gnu #else #include <stdarg.h> /* First heuristic to detect musl libc. */ #ifdef __DEFINED_va_list LIBC=musl #endif #endif #endif EOF cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` eval "$cc_set_libc" # Second heuristic to detect musl libc. if [ "$LIBC" = unknown ] && command -v ldd >/dev/null && ldd --version 2>&1 | grep -q ^musl; then LIBC=musl fi # If the system lacks a compiler, then just pick glibc. # We could probably try harder. if [ "$LIBC" = unknown ]; then LIBC=gnu fi ;; esac # Note: order is significant - the case branches are not exclusive. case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ /sbin/sysctl -n hw.machine_arch 2>/dev/null || \ /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \ echo unknown)` case $UNAME_MACHINE_ARCH in aarch64eb) machine=aarch64_be-unknown ;; armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; earmv*) arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'` endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'` machine=${arch}${endian}-unknown ;; *) machine=$UNAME_MACHINE_ARCH-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently (or will in the future) and ABI. case $UNAME_MACHINE_ARCH in earm*) os=netbsdelf ;; arm*|i386|m68k|ns32k|sh3*|sparc|vax) set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # Determine ABI tags. case $UNAME_MACHINE_ARCH in earm*) expr='s/^earmv[0-9]/-eabi/;s/eb$//' abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"` ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case $UNAME_VERSION in Debian*) release='-gnu' ;; *) release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. GUESS=$machine-${os}${release}${abi-} ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` GUESS=$UNAME_MACHINE_ARCH-unknown-bitrig$UNAME_RELEASE ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` GUESS=$UNAME_MACHINE_ARCH-unknown-openbsd$UNAME_RELEASE ;; *:SecBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/SecBSD.//'` GUESS=$UNAME_MACHINE_ARCH-unknown-secbsd$UNAME_RELEASE ;; *:LibertyBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` GUESS=$UNAME_MACHINE_ARCH-unknown-libertybsd$UNAME_RELEASE ;; *:MidnightBSD:*:*) GUESS=$UNAME_MACHINE-unknown-midnightbsd$UNAME_RELEASE ;; *:ekkoBSD:*:*) GUESS=$UNAME_MACHINE-unknown-ekkobsd$UNAME_RELEASE ;; *:SolidBSD:*:*) GUESS=$UNAME_MACHINE-unknown-solidbsd$UNAME_RELEASE ;; *:OS108:*:*) GUESS=$UNAME_MACHINE-unknown-os108_$UNAME_RELEASE ;; macppc:MirBSD:*:*) GUESS=powerpc-unknown-mirbsd$UNAME_RELEASE ;; *:MirBSD:*:*) GUESS=$UNAME_MACHINE-unknown-mirbsd$UNAME_RELEASE ;; *:Sortix:*:*) GUESS=$UNAME_MACHINE-unknown-sortix ;; *:Twizzler:*:*) GUESS=$UNAME_MACHINE-unknown-twizzler ;; *:Redox:*:*) GUESS=$UNAME_MACHINE-unknown-redox ;; mips:OSF1:*.*) GUESS=mips-dec-osf1 ;; alpha:OSF1:*:*) # Reset EXIT trap before exiting to avoid spurious non-zero exit code. trap '' 0 case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case $ALPHA_CPU_TYPE in "EV4 (21064)") UNAME_MACHINE=alpha ;; "EV4.5 (21064)") UNAME_MACHINE=alpha ;; "LCA4 (21066/21068)") UNAME_MACHINE=alpha ;; "EV5 (21164)") |
︙ | ︙ | |||
327 328 329 330 331 332 333 | UNAME_MACHINE=alphaev79 ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. | | | < < | | | | | | | | | | | | | | | | | | | | | < | < > | | | | | | | > | > | | > | < | < < < < < < < < | < < < | | | | | | > | | > | | | | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 | UNAME_MACHINE=alphaev79 ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. OSF_REL=`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` GUESS=$UNAME_MACHINE-dec-osf$OSF_REL ;; Amiga*:UNIX_System_V:4.0:*) GUESS=m68k-unknown-sysv4 ;; *:[Aa]miga[Oo][Ss]:*:*) GUESS=$UNAME_MACHINE-unknown-amigaos ;; *:[Mm]orph[Oo][Ss]:*:*) GUESS=$UNAME_MACHINE-unknown-morphos ;; *:OS/390:*:*) GUESS=i370-ibm-openedition ;; *:z/VM:*:*) GUESS=s390-ibm-zvmoe ;; *:OS400:*:*) GUESS=powerpc-ibm-os400 ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) GUESS=arm-acorn-riscix$UNAME_RELEASE ;; arm*:riscos:*:*|arm*:RISCOS:*:*) GUESS=arm-unknown-riscos ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) GUESS=hppa1.1-hitachi-hiuxmpp ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. case `(/bin/universe) 2>/dev/null` in att) GUESS=pyramid-pyramid-sysv3 ;; *) GUESS=pyramid-pyramid-bsd ;; esac ;; NILE*:*:*:dcosx) GUESS=pyramid-pyramid-svr4 ;; DRS?6000:unix:4.0:6*) GUESS=sparc-icl-nx6 ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) GUESS=sparc-icl-nx7 ;; esac ;; s390x:SunOS:*:*) SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` GUESS=$UNAME_MACHINE-ibm-solaris2$SUN_REL ;; sun4H:SunOS:5.*:*) SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` GUESS=sparc-hal-solaris2$SUN_REL ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` GUESS=sparc-sun-solaris2$SUN_REL ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) GUESS=i386-pc-auroraux$UNAME_RELEASE ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) set_cc_for_build SUN_ARCH=i386 # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if test "$CC_FOR_BUILD" != no_compiler_found; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -m64 -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH=x86_64 fi fi SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` GUESS=$SUN_ARCH-pc-solaris2$SUN_REL ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` GUESS=sparc-sun-solaris3$SUN_REL ;; sun4*:SunOS:*:*) case `/usr/bin/arch -k` in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like '4.1.3-JL'. SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'` GUESS=sparc-sun-sunos$SUN_REL ;; sun3*:SunOS:*:*) GUESS=m68k-sun-sunos$UNAME_RELEASE ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 case `/bin/arch` in sun3) GUESS=m68k-sun-sunos$UNAME_RELEASE ;; sun4) GUESS=sparc-sun-sunos$UNAME_RELEASE ;; esac ;; aushp:SunOS:*:*) GUESS=sparc-auspex-sunos$UNAME_RELEASE ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) GUESS=m68k-atari-mint$UNAME_RELEASE ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) GUESS=m68k-atari-mint$UNAME_RELEASE ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) GUESS=m68k-atari-mint$UNAME_RELEASE ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) GUESS=m68k-milan-mint$UNAME_RELEASE ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) GUESS=m68k-hades-mint$UNAME_RELEASE ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) GUESS=m68k-unknown-mint$UNAME_RELEASE ;; m68k:machten:*:*) GUESS=m68k-apple-machten$UNAME_RELEASE ;; powerpc:machten:*:*) GUESS=powerpc-apple-machten$UNAME_RELEASE ;; RISC*:Mach:*:*) GUESS=mips-dec-mach_bsd4.3 ;; RISC*:ULTRIX:*:*) GUESS=mips-dec-ultrix$UNAME_RELEASE ;; VAX*:ULTRIX*:*:*) GUESS=vax-dec-ultrix$UNAME_RELEASE ;; 2020:CLIX:*:* | 2430:CLIX:*:*) GUESS=clipper-intergraph-clix$UNAME_RELEASE ;; mips:*:*:UMIPS | mips:*:*:RISCos) set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" #ifdef __cplusplus #include <stdio.h> /* for printf() prototype */ int main (int argc, char *argv[]) { #else |
︙ | ︙ | |||
522 523 524 525 526 527 528 | exit (-1); } EOF $CC_FOR_BUILD -o "$dummy" "$dummy.c" && dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`"$dummy" "$dummyarg"` && { echo "$SYSTEM_NAME"; exit; } | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 | exit (-1); } EOF $CC_FOR_BUILD -o "$dummy" "$dummy.c" && dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`"$dummy" "$dummyarg"` && { echo "$SYSTEM_NAME"; exit; } GUESS=mips-mips-riscos$UNAME_RELEASE ;; Motorola:PowerMAX_OS:*:*) GUESS=powerpc-motorola-powermax ;; Motorola:*:4.3:PL8-*) GUESS=powerpc-harris-powermax ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) GUESS=powerpc-harris-powermax ;; Night_Hawk:Power_UNIX:*:*) GUESS=powerpc-harris-powerunix ;; m88k:CX/UX:7*:*) GUESS=m88k-harris-cxux7 ;; m88k:*:4*:R4*) GUESS=m88k-motorola-sysv4 ;; m88k:*:3*:R3*) GUESS=m88k-motorola-sysv3 ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110 then if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \ test "$TARGET_BINARY_INTERFACE"x = x then GUESS=m88k-dg-dgux$UNAME_RELEASE else GUESS=m88k-dg-dguxbcs$UNAME_RELEASE fi else GUESS=i586-dg-dgux$UNAME_RELEASE fi ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) GUESS=m88k-dolphin-sysv3 ;; M88*:*:R3*:*) # Delta 88k system running SVR3 GUESS=m88k-motorola-sysv3 ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) GUESS=m88k-tektronix-sysv3 ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) GUESS=m68k-tektronix-bsd ;; *:IRIX*:*:*) IRIX_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/g'` GUESS=mips-sgi-irix$IRIX_REL ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. GUESS=romp-ibm-aix # uname -m gives an 8 hex-code CPU id ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) GUESS=i386-ibm-aix ;; ia64:AIX:*:*) if test -x /usr/bin/oslevel ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=$UNAME_VERSION.$UNAME_RELEASE fi GUESS=$UNAME_MACHINE-ibm-aix$IBM_REV ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" #include <sys/systemcfg.h> main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` then GUESS=$SYSTEM_NAME else GUESS=rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then GUESS=rs6000-ibm-aix3.2.4 else GUESS=rs6000-ibm-aix3.2 fi ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if test -x /usr/bin/lslpp ; then IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | \ awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else IBM_REV=$UNAME_VERSION.$UNAME_RELEASE fi GUESS=$IBM_ARCH-ibm-aix$IBM_REV ;; *:AIX:*:*) GUESS=rs6000-ibm-aix ;; ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) GUESS=romp-ibm-bsd4.4 ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and GUESS=romp-ibm-bsd$UNAME_RELEASE # 4.3 with uname added to ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) GUESS=rs6000-bull-bosx ;; DPX/2?00:B.O.S.:*:*) GUESS=m68k-bull-sysv3 ;; 9000/[34]??:4.3bsd:1.*:*) GUESS=m68k-hp-bsd ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) GUESS=m68k-hp-bsd4.4 ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'` case $UNAME_MACHINE in 9000/31?) HP_ARCH=m68000 ;; 9000/[34]??) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if test -x /usr/bin/getconf; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case $sc_cpu_version in 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case $sc_kernel_bits in 32) HP_ARCH=hppa2.0n ;; 64) HP_ARCH=hppa2.0w ;; '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 esac ;; esac fi if test "$HP_ARCH" = ""; then set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" #define _HPUX_SOURCE #include <stdlib.h> #include <unistd.h> |
︙ | ︙ | |||
712 713 714 715 716 717 718 | exit (0); } EOF (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac | | | | | | | | 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 | exit (0); } EOF (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if test "$HP_ARCH" = hppa2.0w then set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH=hppa2.0w else HP_ARCH=hppa64 fi fi GUESS=$HP_ARCH-hp-hpux$HPUX_REV ;; ia64:HP-UX:*:*) HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'` GUESS=ia64-hp-hpux$HPUX_REV ;; 3050*:HI-UX:*:*) set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" #include <unistd.h> int main () { |
︙ | ︙ | |||
768 769 770 771 772 773 774 | puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && { echo "$SYSTEM_NAME"; exit; } | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | | > | | > | | > | | > | | | | | | | | | | | | > | > | | | | > | | | | | | | | | | | > > > | | | | | | | | | | | > | | | > > | | > > | > > > > > > | | > | > > > > > > > > > > > > > > > > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > > | | > > > > > > | | | | > > | | > > > > > > > > > > > > > > > > > > > > > > > > > > < > < > | | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | > > > > > > > > > > > > > > > > > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 | puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && { echo "$SYSTEM_NAME"; exit; } GUESS=unknown-hitachi-hiuxwe2 ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) GUESS=hppa1.1-hp-bsd ;; 9000/8??:4.3bsd:*:*) GUESS=hppa1.0-hp-bsd ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) GUESS=hppa1.0-hp-mpeix ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) GUESS=hppa1.1-hp-osf ;; hp8??:OSF1:*:*) GUESS=hppa1.0-hp-osf ;; i*86:OSF1:*:*) if test -x /usr/sbin/sysversion ; then GUESS=$UNAME_MACHINE-unknown-osf1mk else GUESS=$UNAME_MACHINE-unknown-osf1 fi ;; parisc*:Lites*:*:*) GUESS=hppa1.1-hp-lites ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) GUESS=c1-convex-bsd ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) GUESS=c34-convex-bsd ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) GUESS=c38-convex-bsd ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) GUESS=c4-convex-bsd ;; CRAY*Y-MP:*:*:*) CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` GUESS=ymp-cray-unicos$CRAY_REL ;; CRAY*[A-Z]90:*:*:*) echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` GUESS=t90-cray-unicos$CRAY_REL ;; CRAY*T3E:*:*:*) CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` GUESS=alphaev5-cray-unicosmk$CRAY_REL ;; CRAY*SV1:*:*:*) CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` GUESS=sv1-cray-unicos$CRAY_REL ;; *:UNICOS/mp:*:*) CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` GUESS=craynv-cray-unicosmp$CRAY_REL ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'` GUESS=${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL} ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` GUESS=sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL} ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) GUESS=$UNAME_MACHINE-pc-bsdi$UNAME_RELEASE ;; sparc*:BSD/OS:*:*) GUESS=sparc-unknown-bsdi$UNAME_RELEASE ;; *:BSD/OS:*:*) GUESS=$UNAME_MACHINE-unknown-bsdi$UNAME_RELEASE ;; arm:FreeBSD:*:*) UNAME_PROCESSOR=`uname -p` set_cc_for_build if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabi else FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf fi ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`uname -p` case $UNAME_PROCESSOR in amd64) UNAME_PROCESSOR=x86_64 ;; i386) UNAME_PROCESSOR=i586 ;; esac FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL ;; i*:CYGWIN*:*) GUESS=$UNAME_MACHINE-pc-cygwin ;; *:MINGW64*:*) GUESS=$UNAME_MACHINE-pc-mingw64 ;; *:MINGW*:*) GUESS=$UNAME_MACHINE-pc-mingw32 ;; *:MSYS*:*) GUESS=$UNAME_MACHINE-pc-msys ;; i*:PW*:*) GUESS=$UNAME_MACHINE-pc-pw32 ;; *:SerenityOS:*:*) GUESS=$UNAME_MACHINE-pc-serenity ;; *:Interix*:*) case $UNAME_MACHINE in x86) GUESS=i586-pc-interix$UNAME_RELEASE ;; authenticamd | genuineintel | EM64T) GUESS=x86_64-unknown-interix$UNAME_RELEASE ;; IA64) GUESS=ia64-unknown-interix$UNAME_RELEASE ;; esac ;; i*:UWIN*:*) GUESS=$UNAME_MACHINE-pc-uwin ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) GUESS=x86_64-pc-cygwin ;; prep*:SunOS:5.*:*) SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` GUESS=powerpcle-unknown-solaris2$SUN_REL ;; *:GNU:*:*) # the GNU system GNU_ARCH=`echo "$UNAME_MACHINE" | sed -e 's,[-/].*$,,'` GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's,/.*$,,'` GUESS=$GNU_ARCH-unknown-$LIBC$GNU_REL ;; *:GNU/*:*:*) # other systems with GNU libc and userland GNU_SYS=`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"` GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC ;; x86_64:[Mm]anagarm:*:*|i?86:[Mm]anagarm:*:*) GUESS="$UNAME_MACHINE-pc-managarm-mlibc" ;; *:[Mm]anagarm:*:*) GUESS="$UNAME_MACHINE-unknown-managarm-mlibc" ;; *:Minix:*:*) GUESS=$UNAME_MACHINE-unknown-minix ;; aarch64:Linux:*:*) set_cc_for_build CPU=$UNAME_MACHINE LIBCABI=$LIBC if test "$CC_FOR_BUILD" != no_compiler_found; then ABI=64 sed 's/^ //' << EOF > "$dummy.c" #ifdef __ARM_EABI__ #ifdef __ARM_PCS_VFP ABI=eabihf #else ABI=eabi #endif #endif EOF cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'` eval "$cc_set_abi" case $ABI in eabi | eabihf) CPU=armv8l; LIBCABI=$LIBC$ABI ;; esac fi GUESS=$CPU-unknown-linux-$LIBCABI ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC=gnulibc1 ; fi GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; arc:Linux:*:* | arceb:Linux:*:* | arc32:Linux:*:* | arc64:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; arm*:Linux:*:*) set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then GUESS=$UNAME_MACHINE-unknown-linux-$LIBC else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabi else GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabihf fi fi ;; avr32*:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; cris:Linux:*:*) GUESS=$UNAME_MACHINE-axis-linux-$LIBC ;; crisv32:Linux:*:*) GUESS=$UNAME_MACHINE-axis-linux-$LIBC ;; e2k:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; frv:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; hexagon:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; i*86:Linux:*:*) GUESS=$UNAME_MACHINE-pc-linux-$LIBC ;; ia64:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; k1om:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; kvx:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; kvx:cos:*:*) GUESS=$UNAME_MACHINE-unknown-cos ;; kvx:mbr:*:*) GUESS=$UNAME_MACHINE-unknown-mbr ;; loongarch32:Linux:*:* | loongarch64:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; m32r*:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; m68*:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; mips:Linux:*:* | mips64:Linux:*:*) set_cc_for_build IS_GLIBC=0 test x"${LIBC}" = xgnu && IS_GLIBC=1 sed 's/^ //' << EOF > "$dummy.c" #undef CPU #undef mips #undef mipsel #undef mips64 #undef mips64el #if ${IS_GLIBC} && defined(_ABI64) LIBCABI=gnuabi64 #else #if ${IS_GLIBC} && defined(_ABIN32) LIBCABI=gnuabin32 #else LIBCABI=${LIBC} #endif #endif #if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 CPU=mipsisa64r6 #else #if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 CPU=mipsisa32r6 #else #if defined(__mips64) CPU=mips64 #else CPU=mips #endif #endif #endif #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) MIPS_ENDIAN=el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) MIPS_ENDIAN= #else MIPS_ENDIAN= #endif #endif EOF cc_set_vars=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'` eval "$cc_set_vars" test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; } ;; mips64el:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; openrisc*:Linux:*:*) GUESS=or1k-unknown-linux-$LIBC ;; or32:Linux:*:* | or1k*:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; padre:Linux:*:*) GUESS=sparc-unknown-linux-$LIBC ;; parisc64:Linux:*:* | hppa64:Linux:*:*) GUESS=hppa64-unknown-linux-$LIBC ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) GUESS=hppa1.1-unknown-linux-$LIBC ;; PA8*) GUESS=hppa2.0-unknown-linux-$LIBC ;; *) GUESS=hppa-unknown-linux-$LIBC ;; esac ;; ppc64:Linux:*:*) GUESS=powerpc64-unknown-linux-$LIBC ;; ppc:Linux:*:*) GUESS=powerpc-unknown-linux-$LIBC ;; ppc64le:Linux:*:*) GUESS=powerpc64le-unknown-linux-$LIBC ;; ppcle:Linux:*:*) GUESS=powerpcle-unknown-linux-$LIBC ;; riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; s390:Linux:*:* | s390x:Linux:*:*) GUESS=$UNAME_MACHINE-ibm-linux-$LIBC ;; sh64*:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; sh*:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; sparc:Linux:*:* | sparc64:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; tile*:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; vax:Linux:*:*) GUESS=$UNAME_MACHINE-dec-linux-$LIBC ;; x86_64:Linux:*:*) set_cc_for_build CPU=$UNAME_MACHINE LIBCABI=$LIBC if test "$CC_FOR_BUILD" != no_compiler_found; then ABI=64 sed 's/^ //' << EOF > "$dummy.c" #ifdef __i386__ ABI=x86 #else #ifdef __ILP32__ ABI=x32 #endif #endif EOF cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'` eval "$cc_set_abi" case $ABI in x86) CPU=i686 ;; x32) LIBCABI=${LIBC}x32 ;; esac fi GUESS=$CPU-pc-linux-$LIBCABI ;; xtensa*:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. GUESS=i386-sequent-sysv4 ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION ;; i*86:OS/2:*:*) # If we were able to find 'uname', then EMX Unix compatibility # is probably installed. GUESS=$UNAME_MACHINE-pc-os2-emx ;; i*86:XTS-300:*:STOP) GUESS=$UNAME_MACHINE-unknown-stop ;; i*86:atheos:*:*) GUESS=$UNAME_MACHINE-unknown-atheos ;; i*86:syllable:*:*) GUESS=$UNAME_MACHINE-pc-syllable ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) GUESS=i386-unknown-lynxos$UNAME_RELEASE ;; i*86:*DOS:*:*) GUESS=$UNAME_MACHINE-pc-msdosdjgpp ;; i*86:*:4.*:*) UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then GUESS=$UNAME_MACHINE-univel-sysv$UNAME_REL else GUESS=$UNAME_MACHINE-pc-sysv$UNAME_REL fi ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac GUESS=$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name` GUESS=$UNAME_MACHINE-pc-isc$UNAME_REL elif /bin/uname -X 2>/dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 GUESS=$UNAME_MACHINE-pc-sco$UNAME_REL else GUESS=$UNAME_MACHINE-pc-sysv32 fi ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configure will decide that # this is a cross-build. GUESS=i586-pc-msdosdjgpp ;; Intel:Mach:3*:*) GUESS=i386-pc-mach3 ;; paragon:*:*:*) GUESS=i860-intel-osf1 ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then GUESS=i860-stardent-sysv$UNAME_RELEASE # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. GUESS=i860-unknown-sysv$UNAME_RELEASE # Unknown i860-SVR4 fi ;; mini*:CTIX:SYS*5:*) # "miniframe" GUESS=m68010-convergent-sysv ;; mc68k:UNIX:SYSTEM5:3.51m) GUESS=m68k-convergent-sysv ;; M680?0:D-NIX:5.3:*) GUESS=m68k-diab-dnix ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ |
︙ | ︙ | |||
1201 1202 1203 1204 1205 1206 1207 | /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > | | | | | | | | | | | | | | | | | | | | > > > | < | | > > > > > > > > > < | | | | | | | | | | | | | | | | < | < < < < < | | | | | | | | | | | | | | | | | | | | | | | < | | | | | | | | | | | | | | | | | | | | > | | | | | | | | > | | | > > > | | | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | > > > > > > > > | 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 | /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) GUESS=m68k-unknown-lynxos$UNAME_RELEASE ;; mc68030:UNIX_System_V:4.*:*) GUESS=m68k-atari-sysv4 ;; TSUNAMI:LynxOS:2.*:*) GUESS=sparc-unknown-lynxos$UNAME_RELEASE ;; rs6000:LynxOS:2.*:*) GUESS=rs6000-unknown-lynxos$UNAME_RELEASE ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) GUESS=powerpc-unknown-lynxos$UNAME_RELEASE ;; SM[BE]S:UNIX_SV:*:*) GUESS=mips-dde-sysv$UNAME_RELEASE ;; RM*:ReliantUNIX-*:*:*) GUESS=mips-sni-sysv4 ;; RM*:SINIX-*:*:*) GUESS=mips-sni-sysv4 ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` GUESS=$UNAME_MACHINE-sni-sysv4 else GUESS=ns32k-sni-sysv fi ;; PENTIUM:*:4.0*:*) # Unisys 'ClearPath HMP IX 4000' SVR4/MP effort # says <Richard.M.Bartel@ccMail.Census.GOV> GUESS=i586-unisys-sysv4 ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes <hewes@openmarket.com>. # How about differentiating between stratus architectures? -djm GUESS=hppa1.1-stratus-sysv4 ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. GUESS=i860-stratus-sysv4 ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. GUESS=$UNAME_MACHINE-stratus-vos ;; *:VOS:*:*) # From Paul.Green@stratus.com. GUESS=hppa1.1-stratus-vos ;; mc68*:A/UX:*:*) GUESS=m68k-apple-aux$UNAME_RELEASE ;; news*:NEWS-OS:6*:*) GUESS=mips-sony-newsos6 ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if test -d /usr/nec; then GUESS=mips-nec-sysv$UNAME_RELEASE else GUESS=mips-unknown-sysv$UNAME_RELEASE fi ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. GUESS=powerpc-be-beos ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. GUESS=powerpc-apple-beos ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. GUESS=i586-pc-beos ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. GUESS=i586-pc-haiku ;; ppc:Haiku:*:*) # Haiku running on Apple PowerPC GUESS=powerpc-apple-haiku ;; *:Haiku:*:*) # Haiku modern gcc (not bound by BeOS compat) GUESS=$UNAME_MACHINE-unknown-haiku ;; SX-4:SUPER-UX:*:*) GUESS=sx4-nec-superux$UNAME_RELEASE ;; SX-5:SUPER-UX:*:*) GUESS=sx5-nec-superux$UNAME_RELEASE ;; SX-6:SUPER-UX:*:*) GUESS=sx6-nec-superux$UNAME_RELEASE ;; SX-7:SUPER-UX:*:*) GUESS=sx7-nec-superux$UNAME_RELEASE ;; SX-8:SUPER-UX:*:*) GUESS=sx8-nec-superux$UNAME_RELEASE ;; SX-8R:SUPER-UX:*:*) GUESS=sx8r-nec-superux$UNAME_RELEASE ;; SX-ACE:SUPER-UX:*:*) GUESS=sxace-nec-superux$UNAME_RELEASE ;; Power*:Rhapsody:*:*) GUESS=powerpc-apple-rhapsody$UNAME_RELEASE ;; *:Rhapsody:*:*) GUESS=$UNAME_MACHINE-apple-rhapsody$UNAME_RELEASE ;; arm64:Darwin:*:*) GUESS=aarch64-apple-darwin$UNAME_RELEASE ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` case $UNAME_PROCESSOR in unknown) UNAME_PROCESSOR=powerpc ;; esac if command -v xcode-select > /dev/null 2> /dev/null && \ ! xcode-select --print-path > /dev/null 2> /dev/null ; then # Avoid executing cc if there is no toolchain installed as # cc will be a stub that puts up a graphical alert # prompting the user to install developer tools. CC_FOR_BUILD=no_compiler_found else set_cc_for_build fi if test "$CC_FOR_BUILD" != no_compiler_found; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then case $UNAME_PROCESSOR in i386) UNAME_PROCESSOR=x86_64 ;; powerpc) UNAME_PROCESSOR=powerpc64 ;; esac fi # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_PPC >/dev/null then UNAME_PROCESSOR=powerpc fi elif test "$UNAME_PROCESSOR" = i386 ; then # uname -m returns i386 or x86_64 UNAME_PROCESSOR=$UNAME_MACHINE fi GUESS=$UNAME_PROCESSOR-apple-darwin$UNAME_RELEASE ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = x86; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi GUESS=$UNAME_PROCESSOR-$UNAME_MACHINE-nto-qnx$UNAME_RELEASE ;; *:QNX:*:4*) GUESS=i386-pc-qnx ;; NEO-*:NONSTOP_KERNEL:*:*) GUESS=neo-tandem-nsk$UNAME_RELEASE ;; NSE-*:NONSTOP_KERNEL:*:*) GUESS=nse-tandem-nsk$UNAME_RELEASE ;; NSR-*:NONSTOP_KERNEL:*:*) GUESS=nsr-tandem-nsk$UNAME_RELEASE ;; NSV-*:NONSTOP_KERNEL:*:*) GUESS=nsv-tandem-nsk$UNAME_RELEASE ;; NSX-*:NONSTOP_KERNEL:*:*) GUESS=nsx-tandem-nsk$UNAME_RELEASE ;; *:NonStop-UX:*:*) GUESS=mips-compaq-nonstopux ;; BS2000:POSIX*:*:*) GUESS=bs2000-siemens-sysv ;; DS/*:UNIX_System_V:*:*) GUESS=$UNAME_MACHINE-$UNAME_SYSTEM-$UNAME_RELEASE ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "${cputype-}" = 386; then UNAME_MACHINE=i386 elif test "x${cputype-}" != x; then UNAME_MACHINE=$cputype fi GUESS=$UNAME_MACHINE-unknown-plan9 ;; *:TOPS-10:*:*) GUESS=pdp10-unknown-tops10 ;; *:TENEX:*:*) GUESS=pdp10-unknown-tenex ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) GUESS=pdp10-dec-tops20 ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) GUESS=pdp10-xkl-tops20 ;; *:TOPS-20:*:*) GUESS=pdp10-unknown-tops20 ;; *:ITS:*:*) GUESS=pdp10-unknown-its ;; SEI:*:*:SEIUX) GUESS=mips-sei-seiux$UNAME_RELEASE ;; *:DragonFly:*:*) DRAGONFLY_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` GUESS=$UNAME_MACHINE-unknown-dragonfly$DRAGONFLY_REL ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case $UNAME_MACHINE in A*) GUESS=alpha-dec-vms ;; I*) GUESS=ia64-dec-vms ;; V*) GUESS=vax-dec-vms ;; esac ;; *:XENIX:*:SysV) GUESS=i386-pc-xenix ;; i*86:skyos:*:*) SKYOS_REL=`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'` GUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL ;; i*86:rdos:*:*) GUESS=$UNAME_MACHINE-pc-rdos ;; i*86:Fiwix:*:*) GUESS=$UNAME_MACHINE-pc-fiwix ;; *:AROS:*:*) GUESS=$UNAME_MACHINE-unknown-aros ;; x86_64:VMkernel:*:*) GUESS=$UNAME_MACHINE-unknown-esx ;; amd64:Isilon\ OneFS:*:*) GUESS=x86_64-unknown-onefs ;; *:Unleashed:*:*) GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE ;; esac # Do we have a guess based on uname results? if test "x$GUESS" != x; then echo "$GUESS" exit fi # No uname command or uname output not recognized. set_cc_for_build cat > "$dummy.c" <<EOF #ifdef _SEQUENT_ #include <sys/types.h> #include <sys/utsname.h> #endif #if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) #if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) #include <signal.h> #if defined(_SIZE_T_) || defined(SIGLOST) #include <sys/utsname.h> #endif #endif #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include <sys/param.h> printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) #if !defined (ultrix) #include <sys/param.h> #if defined (BSD) #if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); #else #if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); #else printf ("vax-dec-bsd\n"); exit (0); #endif #endif #else printf ("vax-dec-bsd\n"); exit (0); #endif #else #if defined(_SIZE_T_) || defined(SIGLOST) struct utsname un; uname (&un); printf ("vax-dec-ultrix%s\n", un.release); exit (0); #else printf ("vax-dec-ultrix\n"); exit (0); #endif #endif #endif #if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) #if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) #if defined(_SIZE_T_) || defined(SIGLOST) struct utsname *un; uname (&un); printf ("mips-dec-ultrix%s\n", un.release); exit (0); #else printf ("mips-dec-ultrix\n"); exit (0); #endif #endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`"$dummy"` && { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; } echo "$0: unable to guess system type" >&2 case $UNAME_MACHINE:$UNAME_SYSTEM in mips:Linux | mips64:Linux) # If we got here on MIPS GNU/Linux, output extra information. cat >&2 <<EOF NOTE: MIPS GNU/Linux systems require a C compiler to fully recognize the system type. Please install a C compiler and try again. EOF ;; esac cat >&2 <<EOF This script (version $timestamp), has failed to recognize the operating system you are using. If your script is old, overwrite *all* copies of config.guess and config.sub with the latest versions from: https://git.savannah.gnu.org/cgit/config.git/plain/config.guess and https://git.savannah.gnu.org/cgit/config.git/plain/config.sub EOF our_year=`echo $timestamp | sed 's,-.*,,'` thisyear=`date +%Y` # shellcheck disable=SC2003 script_age=`expr "$thisyear" - "$our_year"` if test "$script_age" -lt 3 ; then cat >&2 <<EOF If $0 has already been updated, send the following data and any information you think might be pertinent to config-patches@gnu.org to provide the necessary information to handle your system. config.guess timestamp = $timestamp |
︙ | ︙ | |||
1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 | /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = "$UNAME_MACHINE" UNAME_RELEASE = "$UNAME_RELEASE" UNAME_SYSTEM = "$UNAME_SYSTEM" UNAME_VERSION = "$UNAME_VERSION" EOF exit 1 # Local variables: # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: | > | 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 | /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = "$UNAME_MACHINE" UNAME_RELEASE = "$UNAME_RELEASE" UNAME_SYSTEM = "$UNAME_SYSTEM" UNAME_VERSION = "$UNAME_VERSION" EOF fi exit 1 # Local variables: # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: |
Modified build-aux/config.sub from [f6ee861ee1] to [85c85f0251].
1 2 | #! /bin/sh # Configuration validation subroutine script. | | > > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #! /bin/sh # Configuration validation subroutine script. # Copyright 1992-2023 Free Software Foundation, Inc. # shellcheck disable=SC2006,SC2268 # see below for rationale timestamp='2023-09-19' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # |
︙ | ︙ | |||
29 30 31 32 33 34 35 | # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: | | > > > > > > > | | | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # https://git.savannah.gnu.org/cgit/config.git/plain/config.sub # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. # The "shellcheck disable" line above the timestamp inhibits complaints # about features and limitations of the classic Bourne shell that were # superseded or lifted in POSIX. However, this script identifies a wide # variety of pre-POSIX systems that do not have POSIX shells at all, and # even some reasonably current systems (Solaris 10 as case-in-point) still # have a pre-POSIX /bin/sh. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS Canonicalize a configuration name. Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to <config-patches@gnu.org>." version="\ GNU config.sub ($timestamp) Copyright 1992-2023 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try '$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) |
︙ | ︙ | |||
108 109 110 111 112 113 114 115 116 117 118 119 120 121 | 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Split fields of configuration type # shellcheck disable=SC2162 IFS="-" read field1 field2 field3 field4 <<EOF $1 EOF # Separate into logical components for further validation case $1 in *-*-*-*-*) | > > | | | < | > | | | | | > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | < < < < | | | < < < < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > | | | | | | | 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 | 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Split fields of configuration type # shellcheck disable=SC2162 saved_IFS=$IFS IFS="-" read field1 field2 field3 field4 <<EOF $1 EOF IFS=$saved_IFS # Separate into logical components for further validation case $1 in *-*-*-*-*) echo "Invalid configuration '$1': more than four components" >&2 exit 1 ;; *-*-*-*) basic_machine=$field1-$field2 basic_os=$field3-$field4 ;; *-*-*) # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two # parts maybe_os=$field2-$field3 case $maybe_os in nto-qnx* | linux-* | uclinux-uclibc* \ | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \ | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \ | storm-chaos* | os2-emx* | rtmk-nova* | managarm-* \ | windows-* ) basic_machine=$field1 basic_os=$maybe_os ;; android-linux) basic_machine=$field1-unknown basic_os=linux-android ;; *) basic_machine=$field1-$field2 basic_os=$field3 ;; esac ;; *-*) # A lone config we happen to match not fitting any pattern case $field1-$field2 in decstation-3100) basic_machine=mips-dec basic_os= ;; *-*) # Second component is usually, but not always the OS case $field2 in # Prevent following clause from handling this valid os sun*os*) basic_machine=$field1 basic_os=$field2 ;; zephyr*) basic_machine=$field1-unknown basic_os=$field2 ;; # Manufacturers dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \ | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \ | unicom* | ibm* | next | hp | isi* | apollo | altos* \ | convergent* | ncr* | news | 32* | 3600* | 3100* \ | hitachi* | c[123]* | convex* | sun | crds | omron* | dg \ | ultra | tti* | harris | dolphin | highlevel | gould \ | cbm | ns | masscomp | apple | axis | knuth | cray \ | microblaze* | sim | cisco \ | oki | wec | wrs | winbond) basic_machine=$field1-$field2 basic_os= ;; *) basic_machine=$field1 basic_os=$field2 ;; esac ;; esac ;; *) # Convert single-component short-hands not valid as part of # multi-component configurations. case $field1 in 386bsd) basic_machine=i386-pc basic_os=bsd ;; a29khif) basic_machine=a29k-amd basic_os=udi ;; adobe68k) basic_machine=m68010-adobe basic_os=scout ;; alliant) basic_machine=fx80-alliant basic_os= ;; altos | altos3068) basic_machine=m68k-altos basic_os= ;; am29k) basic_machine=a29k-none basic_os=bsd ;; amdahl) basic_machine=580-amdahl basic_os=sysv ;; amiga) basic_machine=m68k-unknown basic_os= ;; amigaos | amigados) basic_machine=m68k-unknown basic_os=amigaos ;; amigaunix | amix) basic_machine=m68k-unknown basic_os=sysv4 ;; apollo68) basic_machine=m68k-apollo basic_os=sysv ;; apollo68bsd) basic_machine=m68k-apollo basic_os=bsd ;; aros) basic_machine=i386-pc basic_os=aros ;; aux) basic_machine=m68k-apple basic_os=aux ;; balance) basic_machine=ns32k-sequent basic_os=dynix ;; blackfin) basic_machine=bfin-unknown basic_os=linux ;; cegcc) basic_machine=arm-unknown basic_os=cegcc ;; convex-c1) basic_machine=c1-convex basic_os=bsd ;; convex-c2) basic_machine=c2-convex basic_os=bsd ;; convex-c32) basic_machine=c32-convex basic_os=bsd ;; convex-c34) basic_machine=c34-convex basic_os=bsd ;; convex-c38) basic_machine=c38-convex basic_os=bsd ;; cray) basic_machine=j90-cray basic_os=unicos ;; crds | unos) basic_machine=m68k-crds basic_os= ;; da30) basic_machine=m68k-da30 basic_os= ;; decstation | pmax | pmin | dec3100 | decstatn) basic_machine=mips-dec basic_os= ;; delta88) basic_machine=m88k-motorola basic_os=sysv3 ;; dicos) basic_machine=i686-pc basic_os=dicos ;; djgpp) basic_machine=i586-pc basic_os=msdosdjgpp ;; ebmon29k) basic_machine=a29k-amd basic_os=ebmon ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson basic_os=ose ;; gmicro) basic_machine=tron-gmicro basic_os=sysv ;; go32) basic_machine=i386-pc basic_os=go32 ;; h8300hms) basic_machine=h8300-hitachi basic_os=hms ;; h8300xray) basic_machine=h8300-hitachi basic_os=xray ;; h8500hms) basic_machine=h8500-hitachi basic_os=hms ;; harris) basic_machine=m88k-harris basic_os=sysv3 ;; hp300 | hp300hpux) basic_machine=m68k-hp basic_os=hpux ;; hp300bsd) basic_machine=m68k-hp basic_os=bsd ;; hppaosf) basic_machine=hppa1.1-hp basic_os=osf ;; hppro) basic_machine=hppa1.1-hp basic_os=proelf ;; i386mach) basic_machine=i386-mach basic_os=mach ;; isi68 | isi) basic_machine=m68k-isi basic_os=sysv ;; m68knommu) basic_machine=m68k-unknown basic_os=linux ;; magnum | m3230) basic_machine=mips-mips basic_os=sysv ;; merlin) basic_machine=ns32k-utek basic_os=sysv ;; mingw64) basic_machine=x86_64-pc basic_os=mingw64 ;; mingw32) basic_machine=i686-pc basic_os=mingw32 ;; mingw32ce) basic_machine=arm-unknown basic_os=mingw32ce ;; monitor) basic_machine=m68k-rom68k basic_os=coff ;; morphos) basic_machine=powerpc-unknown basic_os=morphos ;; moxiebox) basic_machine=moxie-unknown basic_os=moxiebox ;; msdos) basic_machine=i386-pc basic_os=msdos ;; msys) basic_machine=i686-pc basic_os=msys ;; mvs) basic_machine=i370-ibm basic_os=mvs ;; nacl) basic_machine=le32-unknown basic_os=nacl ;; ncr3000) basic_machine=i486-ncr basic_os=sysv4 ;; netbsd386) basic_machine=i386-pc basic_os=netbsd ;; netwinder) basic_machine=armv4l-rebel basic_os=linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony basic_os=newsos ;; news1000) basic_machine=m68030-sony basic_os=newsos ;; necv70) basic_machine=v70-nec basic_os=sysv ;; nh3000) basic_machine=m68k-harris basic_os=cxux ;; nh[45]000) basic_machine=m88k-harris basic_os=cxux ;; nindy960) basic_machine=i960-intel basic_os=nindy ;; mon960) basic_machine=i960-intel basic_os=mon960 ;; nonstopux) basic_machine=mips-compaq basic_os=nonstopux ;; os400) basic_machine=powerpc-ibm basic_os=os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson basic_os=ose ;; os68k) basic_machine=m68k-none basic_os=os68k ;; paragon) basic_machine=i860-intel basic_os=osf ;; parisc) basic_machine=hppa-unknown basic_os=linux ;; psp) basic_machine=mipsallegrexel-sony basic_os=psp ;; pw32) basic_machine=i586-unknown basic_os=pw32 ;; rdos | rdos64) basic_machine=x86_64-pc basic_os=rdos ;; rdos32) basic_machine=i386-pc basic_os=rdos ;; rom68k) basic_machine=m68k-rom68k basic_os=coff ;; sa29200) basic_machine=a29k-amd basic_os=udi ;; sei) basic_machine=mips-sei basic_os=seiux ;; sequent) basic_machine=i386-sequent basic_os= ;; sps7) basic_machine=m68k-bull basic_os=sysv2 ;; st2000) basic_machine=m68k-tandem basic_os= ;; stratus) basic_machine=i860-stratus basic_os=sysv4 ;; sun2) basic_machine=m68000-sun basic_os= ;; sun2os3) basic_machine=m68000-sun basic_os=sunos3 ;; sun2os4) basic_machine=m68000-sun basic_os=sunos4 ;; sun3) basic_machine=m68k-sun basic_os= ;; sun3os3) basic_machine=m68k-sun basic_os=sunos3 ;; sun3os4) basic_machine=m68k-sun basic_os=sunos4 ;; sun4) basic_machine=sparc-sun basic_os= ;; sun4os3) basic_machine=sparc-sun basic_os=sunos3 ;; sun4os4) basic_machine=sparc-sun basic_os=sunos4 ;; sun4sol2) basic_machine=sparc-sun basic_os=solaris2 ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun basic_os= ;; sv1) basic_machine=sv1-cray basic_os=unicos ;; symmetry) basic_machine=i386-sequent basic_os=dynix ;; t3e) basic_machine=alphaev5-cray basic_os=unicos ;; t90) basic_machine=t90-cray basic_os=unicos ;; toad1) basic_machine=pdp10-xkl basic_os=tops20 ;; tpf) basic_machine=s390x-ibm basic_os=tpf ;; udi29k) basic_machine=a29k-amd basic_os=udi ;; ultra3) basic_machine=a29k-nyu basic_os=sym1 ;; v810 | necv810) basic_machine=v810-nec basic_os=none ;; vaxv) basic_machine=vax-dec basic_os=sysv ;; vms) basic_machine=vax-dec basic_os=vms ;; vsta) basic_machine=i386-pc basic_os=vsta ;; vxworks960) basic_machine=i960-wrs basic_os=vxworks ;; vxworks68) basic_machine=m68k-wrs basic_os=vxworks ;; vxworks29k) basic_machine=a29k-wrs basic_os=vxworks ;; xbox) basic_machine=i686-pc basic_os=mingw32 ;; ymp) basic_machine=ymp-cray basic_os=unicos ;; *) basic_machine=$1 basic_os= ;; esac ;; esac # Decode 1-component or ad-hoc basic machines case $basic_machine in |
︙ | ︙ | |||
682 683 684 685 686 687 688 | 3b*) cpu=we32k vendor=att ;; bluegene*) cpu=powerpc vendor=ibm | | | | | | | | 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 | 3b*) cpu=we32k vendor=att ;; bluegene*) cpu=powerpc vendor=ibm basic_os=cnk ;; decsystem10* | dec10*) cpu=pdp10 vendor=dec basic_os=tops10 ;; decsystem20* | dec20*) cpu=pdp10 vendor=dec basic_os=tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) cpu=m68k vendor=motorola ;; dpx2*) cpu=m68k vendor=bull basic_os=sysv3 ;; encore | umax | mmax) cpu=ns32k vendor=encore ;; elxsi) cpu=elxsi vendor=elxsi basic_os=${basic_os:-bsd} ;; fx2800) cpu=i860 vendor=alliant ;; genix) cpu=ns32k vendor=ns ;; h3050r* | hiux*) cpu=hppa1.1 vendor=hitachi basic_os=hiuxwe2 ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) cpu=hppa1.0 vendor=hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) cpu=m68000 |
︙ | ︙ | |||
767 768 769 770 771 772 773 | hp9k8[0-9][0-9] | hp8[0-9][0-9]) cpu=hppa1.0 vendor=hp ;; i*86v32) cpu=`echo "$1" | sed -e 's/86.*/86/'` vendor=pc | | | | | | | | | | | > > | | | | | | 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 | hp9k8[0-9][0-9] | hp8[0-9][0-9]) cpu=hppa1.0 vendor=hp ;; i*86v32) cpu=`echo "$1" | sed -e 's/86.*/86/'` vendor=pc basic_os=sysv32 ;; i*86v4*) cpu=`echo "$1" | sed -e 's/86.*/86/'` vendor=pc basic_os=sysv4 ;; i*86v) cpu=`echo "$1" | sed -e 's/86.*/86/'` vendor=pc basic_os=sysv ;; i*86sol2) cpu=`echo "$1" | sed -e 's/86.*/86/'` vendor=pc basic_os=solaris2 ;; j90 | j90-cray) cpu=j90 vendor=cray basic_os=${basic_os:-unicos} ;; iris | iris4d) cpu=mips vendor=sgi case $basic_os in irix*) ;; *) basic_os=irix4 ;; esac ;; miniframe) cpu=m68000 vendor=convergent ;; *mint | mint[0-9]* | *MiNT | *MiNT[0-9]*) cpu=m68k vendor=atari basic_os=mint ;; news-3600 | risc-news) cpu=mips vendor=sony basic_os=newsos ;; next | m*-next) cpu=m68k vendor=next case $basic_os in openstep*) ;; nextstep*) ;; ns2*) basic_os=nextstep2 ;; *) basic_os=nextstep3 ;; esac ;; np1) cpu=np1 vendor=gould ;; op50n-* | op60c-*) cpu=hppa1.1 vendor=oki basic_os=proelf ;; pa-hitachi) cpu=hppa1.1 vendor=hitachi basic_os=hiuxwe2 ;; pbd) cpu=sparc vendor=tti ;; pbb) cpu=m68k |
︙ | ︙ | |||
866 867 868 869 870 871 872 | cpu=power vendor=ibm ;; ps2) cpu=i386 vendor=ibm ;; | < < < < | | | > > | | 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 | cpu=power vendor=ibm ;; ps2) cpu=i386 vendor=ibm ;; rm[46]00) cpu=mips vendor=siemens ;; rtpc | rtpc-*) cpu=romp vendor=ibm ;; sde) cpu=mipsisa32 vendor=sde basic_os=${basic_os:-elf} ;; simso-wrs) cpu=sparclite vendor=wrs basic_os=vxworks ;; tower | tower-32) cpu=m68k vendor=ncr ;; vpp*|vx|vx-*) cpu=f301 vendor=fujitsu ;; w65) cpu=w65 vendor=wdc ;; w89k-*) cpu=hppa1.1 vendor=winbond basic_os=proelf ;; none) cpu=none vendor=none ;; leon|leon[3-9]) cpu=sparc vendor=$basic_machine ;; leon-*|leon[3-9]-*) cpu=sparc vendor=`echo "$basic_machine" | sed 's/-.*//'` ;; *-*) # shellcheck disable=SC2162 saved_IFS=$IFS IFS="-" read cpu vendor <<EOF $basic_machine EOF IFS=$saved_IFS ;; # We use 'pc' rather than 'unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) cpu=$basic_machine vendor=pc ;; # These rules are duplicated from below for sake of the special case above; |
︙ | ︙ | |||
956 957 958 959 960 961 962 | # Decode basic machines in the full and proper CPU-Company form. case $cpu-$vendor in # Here we handle the default manufacturer of certain CPU types in canonical form. It is in # some cases the only manufacturer, in others, it is the most popular. craynv-unknown) vendor=cray | | | | 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 | # Decode basic machines in the full and proper CPU-Company form. case $cpu-$vendor in # Here we handle the default manufacturer of certain CPU types in canonical form. It is in # some cases the only manufacturer, in others, it is the most popular. craynv-unknown) vendor=cray basic_os=${basic_os:-unicosmp} ;; c90-unknown | c90-cray) vendor=cray basic_os=${Basic_os:-unicos} ;; fx80-unknown) vendor=alliant ;; romp-unknown) vendor=ibm ;; |
︙ | ︙ | |||
1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 | ;; xps-unknown | xps100-unknown) cpu=xps100 vendor=honeywell ;; # Here we normalize CPU types with a missing or matching vendor dpx20-unknown | dpx20-bull) cpu=rs6000 vendor=bull | > > > > > | | | | | | | 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 | ;; xps-unknown | xps100-unknown) cpu=xps100 vendor=honeywell ;; # Here we normalize CPU types with a missing or matching vendor armh-unknown | armh-alt) cpu=armv7l vendor=alt basic_os=${basic_os:-linux-gnueabihf} ;; dpx20-unknown | dpx20-bull) cpu=rs6000 vendor=bull basic_os=${basic_os:-bosx} ;; # Here we normalize CPU types irrespective of the vendor amd64-*) cpu=x86_64 ;; blackfin-*) cpu=bfin basic_os=linux ;; c54x-*) cpu=tic54x ;; c55x-*) cpu=tic55x ;; c6x-*) cpu=tic6x ;; e500v[12]-*) cpu=powerpc basic_os=${basic_os}"spe" ;; mips3*-*) cpu=mips64 ;; ms1-*) cpu=mt ;; m68knommu-*) cpu=m68k basic_os=linux ;; m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*) cpu=s12z ;; openrisc-*) cpu=or32 ;; parisc-*) cpu=hppa basic_os=linux ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) cpu=i586 ;; pentiumpro-* | p6-* | 6x86-* | athlon-* | athlon_*-*) cpu=i686 ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) cpu=i686 ;; pentium4-*) cpu=i786 |
︙ | ︙ | |||
1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 | ;; x64-*) cpu=x86_64 ;; xscale-* | xscalee[bl]-*) cpu=`echo "$cpu" | sed 's/^xscale/arm/'` ;; # Recognize the canonical CPU Types that limit and/or modify the # company names they are paired with. cr16-*) | > > > | | | 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 | ;; x64-*) cpu=x86_64 ;; xscale-* | xscalee[bl]-*) cpu=`echo "$cpu" | sed 's/^xscale/arm/'` ;; arm64-* | aarch64le-*) cpu=aarch64 ;; # Recognize the canonical CPU Types that limit and/or modify the # company names they are paired with. cr16-*) basic_os=${basic_os:-elf} ;; crisv32-* | etraxfs*-*) cpu=crisv32 vendor=axis ;; cris-* | etrax*-*) cpu=cris vendor=axis ;; crx-*) basic_os=${basic_os:-elf} ;; neo-tandem) cpu=neo vendor=tandem ;; nse-tandem) cpu=nse |
︙ | ︙ | |||
1139 1140 1141 1142 1143 1144 1145 | cpu=nsv vendor=tandem ;; nsx-tandem) cpu=nsx vendor=tandem ;; | | | | < < < < | | | | | > > > < | < < < < < < < < < < < < < < < < < < < | > > | > | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < < < | 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 | cpu=nsv vendor=tandem ;; nsx-tandem) cpu=nsx vendor=tandem ;; mipsallegrexel-sony) cpu=mipsallegrexel vendor=sony ;; tile*-*) basic_os=${basic_os:-linux-gnu} ;; *) # Recognize the canonical CPU types that are allowed with any # company name. case $cpu in 1750a | 580 \ | a29k \ | aarch64 | aarch64_be | aarch64c | arm64ec \ | abacus \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \ | alphapca5[67] | alpha64pca5[67] \ | am33_2.0 \ | amdgcn \ | arc | arceb | arc32 | arc64 \ | arm | arm[lb]e | arme[lb] | armv* \ | avr | avr32 \ | asmjs \ | ba \ | be32 | be64 \ | bfin | bpf | bs2000 \ | c[123]* | c30 | [cjt]90 | c4x \ | c8051 | clipper | craynv | csky | cydra \ | d10v | d30v | dlx | dsp16xx \ | e2k | elxsi | epiphany \ | f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \ | javascript \ | h8300 | h8500 \ | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ | i370 | i*86 | i860 | i960 | ia16 | ia64 \ | ip2k | iq2000 \ | k1om \ | kvx \ | le32 | le64 \ | lm32 \ | loongarch32 | loongarch64 \ | m32c | m32r | m32rle \ | m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \ | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \ | m88110 | m88k | maxq | mb | mcore | mep | metag \ | microblaze | microblazeel \ | mips* \ | mmix \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ | nfp \ | nios | nios2 | nios2eb | nios2el \ | none | np1 | ns16k | ns32k | nvptx \ | open8 \ | or1k* \ | or32 \ | orion \ | picochip \ | pdp10 | pdp11 | pj | pjl | pn | power \ | powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \ | pru \ | pyramid \ | riscv | riscv32 | riscv32be | riscv64 | riscv64be \ | rl78 | romp | rs6000 | rx \ | s390 | s390x \ | score \ | sh | shl \ | sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \ | sh[1234]e[lb] | sh[12345][lb]e | sh[23]ele | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \ | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \ | spu \ | tahoe \ | thumbv7* \ | tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \ | tron \ | ubicom32 \ | v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \ | vax \ | visium \ | w65 \ | wasm32 | wasm64 \ | we32k \ | x86 | x86_64 | xc16x | xgate | xps100 \ | xstormy16 | xtensa* \ | ymp \ | z8k | z80) ;; *) echo "Invalid configuration '$1': machine '$cpu-$vendor' not recognized" 1>&2 exit 1 ;; esac ;; esac # Here we canonicalize certain aliases for manufacturers. case $vendor in digital*) vendor=dec ;; commodore*) vendor=cbm ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if test x"$basic_os" != x then # First recognize some ad-hoc cases, or perhaps split kernel-os, or else just # set os. obj= case $basic_os in gnu/linux*) kernel=linux os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'` ;; os2-emx) kernel=os2 os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'` ;; nto-qnx*) kernel=nto os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'` ;; *-*) # shellcheck disable=SC2162 saved_IFS=$IFS IFS="-" read kernel os <<EOF $basic_os EOF IFS=$saved_IFS ;; # Default OS when just kernel was specified nto*) kernel=nto os=`echo "$basic_os" | sed -e 's|nto|qnx|'` ;; linux*) kernel=linux os=`echo "$basic_os" | sed -e 's|linux|gnu|'` ;; managarm*) kernel=managarm os=`echo "$basic_os" | sed -e 's|managarm|mlibc|'` ;; *) kernel= os=$basic_os ;; esac # Now, normalize the OS (knowing we just have one component, it's not a kernel, # etc.) case $os in # First match some system type aliases that might get confused # with valid system types. # solaris* is a basic system type, with this one exception. auroraux) os=auroraux ;; bluegene*) os=cnk ;; solaris1 | solaris1.*) os=`echo "$os" | sed -e 's|solaris1|sunos4|'` ;; solaris) os=solaris2 ;; unixware*) os=sysv4.2uw ;; # es1800 is here to avoid being matched by es* (a different OS) es1800*) os=ose ;; # Some version numbers need modification chorusos*) os=chorusos |
︙ | ︙ | |||
1320 1321 1322 1323 1324 1325 1326 | sco5) os=sco3.2v5 ;; sco4) os=sco3.2v4 ;; sco3.2.[4-9]*) | | < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < > > > | | 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 | sco5) os=sco3.2v5 ;; sco4) os=sco3.2v4 ;; sco3.2.[4-9]*) os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'` ;; sco*v* | scout) # Don't match below ;; sco*) os=sco3.2v2 ;; psos*) os=psos ;; qnx*) os=qnx ;; hiux*) os=hiuxwe2 ;; lynx*178) os=lynxos178 ;; lynx*5) os=lynxos5 ;; lynxos*) # don't get caught up in next wildcard ;; lynx*) os=lynxos ;; mac[0-9]*) os=`echo "$os" | sed -e 's|mac|macos|'` ;; opened*) os=openedition ;; os400*) os=os400 |
︙ | ︙ | |||
1449 1450 1451 1452 1453 1454 1455 | ;; nova*) os=rtmk-nova ;; ns2) os=nextstep2 ;; | < < < | | 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 | ;; nova*) os=rtmk-nova ;; ns2) os=nextstep2 ;; # Preserve the version number of sinix5. sinix5.*) os=`echo "$os" | sed -e 's|sinix|sysv|'` ;; sinix*) os=sysv4 ;; tpf*) os=tpf ;; |
︙ | ︙ | |||
1477 1478 1479 1480 1481 1482 1483 | ;; svr3) os=sysv3 ;; sysvr4) os=sysv4 ;; | < < < < < < | > | < > > | < < < < < < > > > > | > | > | > > | > | | > | > > | > | > | | 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 | ;; svr3) os=sysv3 ;; sysvr4) os=sysv4 ;; ose*) os=ose ;; *mint | mint[0-9]* | *MiNT | MiNT[0-9]*) os=mint ;; dicos*) os=dicos ;; pikeos*) # Until real need of OS specific support for # particular features comes up, bare metal # configurations are quite functional. case $cpu in arm*) os=eabi ;; *) os= obj=elf ;; esac ;; aout* | coff* | elf* | pe*) # These are machine code file formats, not OSes obj=$os os= ;; *) # No normalization, but not necessarily accepted, that comes below. ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. kernel= obj= case $cpu-$vendor in score-*) os= obj=elf ;; spu-*) os= obj=elf ;; *-acorn) os=riscix1.2 ;; arm*-rebel) kernel=linux os=gnu ;; arm*-semi) os= obj=aout ;; c4x-* | tic4x-*) os= obj=coff ;; c8051-*) os= obj=elf ;; clipper-intergraph) os=clix ;; hexagon-*) os= obj=elf ;; tic54x-*) os= obj=coff ;; tic55x-*) os= obj=coff ;; tic6x-*) os= obj=coff ;; # This must come before the *-dec entry. pdp10-*) os=tops20 ;; pdp11-*) os=none |
︙ | ︙ | |||
1587 1588 1589 1590 1591 1592 1593 | i386-sun) os=sunos4.0.2 ;; m68000-sun) os=sunos3 ;; m68*-cisco) | > | | > | > | > > | | > | 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 | i386-sun) os=sunos4.0.2 ;; m68000-sun) os=sunos3 ;; m68*-cisco) os= obj=aout ;; mep-*) os= obj=elf ;; mips*-cisco) os= obj=elf ;; mips*-*) os= obj=elf ;; or32-*) os= obj=coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=sysv3 ;; sparc-* | *-sun) os=sunos4.1.1 ;; pru-*) os= obj=elf ;; *-be) os=beos ;; *-ibm) os=aix ;; |
︙ | ︙ | |||
1689 1690 1691 1692 1693 1694 1695 | *-masscomp) os=rtu ;; f30[01]-fujitsu | f700-fujitsu) os=uxpv ;; *-rom68k) | > | > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | | | | | | | | | | | | > > > | | | | | | | | | | 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 | *-masscomp) os=rtu ;; f30[01]-fujitsu | f700-fujitsu) os=uxpv ;; *-rom68k) os= obj=coff ;; *-*bug) os= obj=coff ;; *-apple) os=macos ;; *-atari*) os=mint ;; *-wrs) os=vxworks ;; *) os=none ;; esac fi # Now, validate our (potentially fixed-up) individual pieces (OS, OBJ). case $os in # Sometimes we do "kernel-libc", so those need to count as OSes. musl* | newlib* | relibc* | uclibc*) ;; # Likewise for "kernel-abi" eabi* | gnueabi*) ;; # VxWorks passes extra cpu info in the 4th filed. simlinux | simwindows | spe) ;; # See `case $cpu-$os` validation below ghcjs) ;; # Now accept the basic system types. # The portable systems comes first. # Each alternative MUST end in a * to match a version number. gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \ | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \ | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \ | sym* | plan9* | psp* | sim* | xray* | os68k* | v88r* \ | hiux* | abug | nacl* | netware* | windows* \ | os9* | macos* | osx* | ios* | tvos* | watchos* \ | mpw* | magic* | mmixware* | mon960* | lnews* \ | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \ | aos* | aros* | cloudabi* | sortix* | twizzler* \ | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \ | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \ | mirbsd* | netbsd* | dicos* | openedition* | ose* \ | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \ | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \ | bosx* | nextstep* | cxux* | oabi* \ | ptx* | ecoff* | winnt* | domain* | vsta* \ | udi* | lites* | ieee* | go32* | aux* | hcos* \ | chorusrdb* | cegcc* | glidix* | serenity* \ | cygwin* | msys* | moss* | proelf* | rtems* \ | midipix* | mingw32* | mingw64* | mint* \ | uxpv* | beos* | mpeix* | udk* | moxiebox* \ | interix* | uwin* | mks* | rhapsody* | darwin* \ | openstep* | oskit* | conix* | pw32* | nonstopux* \ | storm-chaos* | tops10* | tenex* | tops20* | its* \ | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \ | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \ | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \ | skyos* | haiku* | rdos* | toppers* | drops* | es* \ | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \ | fiwix* | mlibc* | cos* | mbr* ) ;; # This one is extra strict with allowed versions sco3.2v2 | sco3.2v[4-9]* | sco5v6*) # Don't forget version if it is 3.2v4 or newer. ;; none) ;; kernel* | msvc* ) # Restricted further below ;; '') if test x"$obj" = x then echo "Invalid configuration '$1': Blank OS only allowed with explicit machine code file format" 1>&2 fi ;; *) echo "Invalid configuration '$1': OS '$os' not recognized" 1>&2 exit 1 ;; esac case $obj in aout* | coff* | elf* | pe*) ;; '') # empty is fine ;; *) echo "Invalid configuration '$1': Machine code format '$obj' not recognized" 1>&2 exit 1 ;; esac # Here we handle the constraint that a (synthetic) cpu and os are # valid only in combination with each other and nowhere else. case $cpu-$os in # The "javascript-unknown-ghcjs" triple is used by GHC; we # accept it here in order to tolerate that, but reject any # variations. javascript-ghcjs) ;; javascript-* | *-ghcjs) echo "Invalid configuration '$1': cpu '$cpu' is not valid with os '$os$obj'" 1>&2 exit 1 ;; esac # As a final step for OS-related things, validate the OS-kernel combination # (given a valid OS), if there is a kernel. case $kernel-$os-$obj in linux-gnu*- | linux-dietlibc*- | linux-android*- | linux-newlib*- \ | linux-musl*- | linux-relibc*- | linux-uclibc*- | linux-mlibc*- ) ;; uclinux-uclibc*- ) ;; managarm-mlibc*- | managarm-kernel*- ) ;; windows*-msvc*-) ;; -dietlibc*- | -newlib*- | -musl*- | -relibc*- | -uclibc*- | -mlibc*- ) # These are just libc implementations, not actual OSes, and thus # require a kernel. echo "Invalid configuration '$1': libc '$os' needs explicit kernel." 1>&2 exit 1 ;; -kernel*- ) echo "Invalid configuration '$1': '$os' needs explicit kernel." 1>&2 exit 1 ;; *-kernel*- ) echo "Invalid configuration '$1': '$kernel' does not support '$os'." 1>&2 exit 1 ;; *-msvc*- ) echo "Invalid configuration '$1': '$os' needs 'windows'." 1>&2 exit 1 ;; kfreebsd*-gnu*- | kopensolaris*-gnu*-) ;; vxworks-simlinux- | vxworks-simwindows- | vxworks-spe-) ;; nto-qnx*-) ;; os2-emx-) ;; *-eabi*- | *-gnueabi*-) ;; none--*) # None (no kernel, i.e. freestanding / bare metal), # can be paired with an machine code file format ;; -*-) # Blank kernel with real OS is always fine. ;; --*) # Blank kernel and OS with real machine code file format is always fine. ;; *-*-*) echo "Invalid configuration '$1': Kernel '$kernel' not known to work with OS '$os'." 1>&2 exit 1 ;; esac # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. case $vendor in unknown) case $cpu-$os in *-riscix*) vendor=acorn ;; *-sunos*) vendor=sun ;; *-cnk* | *-aix*) vendor=ibm ;; *-beos*) vendor=be ;; *-hpux*) vendor=hp ;; *-mpeix*) vendor=hp ;; *-hiux*) vendor=hitachi ;; *-unos*) vendor=crds ;; *-dgux*) vendor=dg ;; *-luna*) vendor=omron ;; *-genix*) vendor=ns ;; *-clix*) vendor=intergraph ;; *-mvs* | *-opened*) vendor=ibm ;; *-os400*) vendor=ibm ;; s390-* | s390x-*) vendor=ibm ;; *-ptx*) vendor=sequent ;; *-tpf*) vendor=ibm ;; *-vxsim* | *-vxworks* | *-windiss*) vendor=wrs ;; *-aux*) vendor=apple ;; *-hms*) vendor=hitachi ;; *-mpw* | *-macos*) vendor=apple ;; *-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*) vendor=atari ;; *-vos*) vendor=stratus ;; esac ;; esac echo "$cpu-$vendor${kernel:+-$kernel}${os:+-$os}${obj:+-$obj}" exit # Local variables: # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: |
Modified build-aux/install-sh from [0170726bd8] to [1cccb4aa97].
1 | #!/bin/sh | > | < | < | < | > > | | | > > | > > | > > > > > > > > > > | | < < < > > > > | | > | > | | > > | > < < | | | > | > > > | | > | > > > > > > > | < < | | | < < | | | | | > | > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > | > | < < > > > < | | | < < | | > > | | > > > > > > > > | > | > > > > > > | | > > > > > > | < < | | > > | | > | > | | | | | < < | > < | > > > | | | > > > | < | < | < | > | | < | < < | < > > > > | > > | > | | < > > | > | | > | < | | | | > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > | > > > > > > > > > > > > > > > | > > > > > > > > | | | | | | < > | | > > > > | > > > > > | | > > > > | > > > | < > < | < | > > | < < < | < > | < | | | > > > > | > > > > > | > > > > > > > > > > > > > > > > > > > > > > > | < > | < | > > > > | | < < | < < < > > > | < < < | < > | | | | > > > > | > > > | < > | > > < | | < < < > > > > > > | > > > > > | > > > > > | | < > | > > > > > > > | > > | < < < < | > > | < < < < | > > > | > > | | > > > > > > | | | | > > | < > | < > > > | | > > > < > | < | > | > > | | > | | > > > | < | < | | < > | > > | | < > > > > > | < < > | > > > > > | < < < < > | > | < < < < < | | > | < | | > > > > > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 | #!/bin/sh # install - install a program, script, or datafile scriptversion=2023-11-23.18; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # 'make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. tab=' ' nl=' ' IFS=" $tab$nl" # Set DOITPROG to "echo" to test this script. doit=${DOITPROG-} doit_exec=${doit:-exec} # Put in absolute file names if you don't have them in your path; # or use environment vars. chgrpprog=${CHGRPPROG-chgrp} chmodprog=${CHMODPROG-chmod} chownprog=${CHOWNPROG-chown} cmpprog=${CMPPROG-cmp} cpprog=${CPPROG-cp} mkdirprog=${MKDIRPROG-mkdir} mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} posix_mkdir= # Desired mode of installed file. mode=0755 # Create dirs (including intermediate dirs) using mode 755. # This is like GNU 'install' as of coreutils 8.32 (2020). mkdir_umask=22 backupsuffix= chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false is_target_a_directory=possibly usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --help display this help and exit. --version display version info and exit. -c (ignored) -C install only if different (preserve data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -p pass -p to $cpprog. -s $stripprog installed files. -S SUFFIX attempt to back up existing files, with suffix SUFFIX. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG By default, rm is invoked with -f; when overridden with RMPROG, it's up to you to specify -f if you want it. If -S is not specified, no backups are attempted. Report bugs to <bug-automake@gnu.org>. GNU Automake home page: <https://www.gnu.org/software/automake/>. General help using GNU software: <https://www.gnu.org/gethelp/>." while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 case $mode in *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -p) cpprog="$cpprog -p";; -s) stripcmd=$stripprog;; -S) backupsuffix="$2" shift;; -t) is_target_a_directory=always dst_arg=$2 # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac shift;; -T) is_target_a_directory=never;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done # We allow the use of options -d and -T together, by making -d # take the precedence; this is for compatibility with GNU install. if test -n "$dir_arg"; then if test -n "$dst_arg"; then echo "$0: target directory not allowed when installing a directory." >&2 exit 1 fi fi if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call 'install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then if test $# -gt 1 || test "$is_target_a_directory" = always; then if test ! -d "$dst_arg"; then echo "$0: $dst_arg: Is not a directory." >&2 exit 1 fi fi fi if test -z "$dir_arg"; then do_exit='(exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 trap "ret=141; $do_exit" 13 trap "ret=143; $do_exit" 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names problematic for 'test' and other utilities. case $src in -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? # Don't chown directories that already exist. if test $dstdir_status = 0; then chowncmd="" fi else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # If destination is a directory, append the input filename. if test -d "$dst"; then if test "$is_target_a_directory" = never; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dstbase=`basename "$src"` case $dst in */) dst=$dst$dstbase;; *) dst=$dst/$dstbase;; esac dstdir_status=0 else dstdir=`dirname "$dst"` test -d "$dstdir" dstdir_status=$? fi fi case $dstdir in */) dstdirslash=$dstdir;; *) dstdirslash=$dstdir/;; esac obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false # The $RANDOM variable is not portable (e.g., dash). Use it # here however when possible just to lower collision chance. tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap ' ret=$? rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null exit $ret ' 0 # Because "mkdir -p" follows existing symlinks and we likely work # directly in world-writeable /tmp, make sure that the '$tmpdir' # directory is successfully created first before we actually test # 'mkdir -p'. if (umask $mkdir_umask && $mkdirprog $mkdir_mode "$tmpdir" && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. test_tmpdir="$tmpdir/a" ls_ld_tmpdir=`ls -ld "$test_tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$test_tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null fi trap '' 0;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in /*) prefix='/';; [-=\(\)!]*) prefix='./';; *) prefix='';; esac oIFS=$IFS IFS=/ set -f set fnord $dstdir shift set +f IFS=$oIFS prefixes= for d do test X"$d" = X && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=${dstdirslash}_inst.$$_ rmtmp=${dstdirslash}_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && { test -z "$stripcmd" || { # Create $dsttmp read-write so that cp doesn't create it read-only, # which would cause strip to fail. if test -z "$doit"; then : >"$dsttmp" # No need to fork-exec 'touch'. else $doit touch "$dsttmp" fi } } && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # If $backupsuffix is set, and the file being installed # already exists, attempt a backup. Don't worry if it fails, # e.g., if mv doesn't support -f. if test -n "$backupsuffix" && test -f "$dst"; then $doit $mvcmd -f "$dst" "$dst$backupsuffix" 2>/dev/null fi # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: |
Modified build-aux/m4/buildsys.m4 from [0e90ccf38e] to [8bcbdfb241].
1 2 | dnl dnl Copyright (c) 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2016, 2017, | | | 1 2 3 4 5 6 7 8 9 10 | dnl dnl Copyright (c) 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2016, 2017, dnl 2018, 2020, 2021, 2022, 2023 dnl Jonathan Schleifer <js@nil.im> dnl dnl https://fossil.nil.im/buildsys dnl dnl Permission to use, copy, modify, and/or distribute this software for any dnl purpose with or without fee is hereby granted, provided that the above dnl copyright notice and this permission notice is present in all copies. |
︙ | ︙ | |||
25 26 27 28 29 30 31 32 33 34 35 36 37 38 | AC_DEFUN([BUILDSYS_INIT], [ AC_REQUIRE([AC_CANONICAL_BUILD]) AC_REQUIRE([AC_CANONICAL_HOST]) AC_ARG_ENABLE(rpath, AS_HELP_STRING([--disable-rpath], [do not use rpath])) case "$build_os" in darwin*) case "$host_os" in darwin*) AC_SUBST(BUILD_AND_HOST_ARE_DARWIN, yes) ;; esac | > > > > | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | AC_DEFUN([BUILDSYS_INIT], [ AC_REQUIRE([AC_CANONICAL_BUILD]) AC_REQUIRE([AC_CANONICAL_HOST]) AC_ARG_ENABLE(rpath, AS_HELP_STRING([--disable-rpath], [do not use rpath])) AC_ARG_ENABLE(silent-rules, AS_HELP_STRING([--disable-silent-rules], [print executed commands during build])) case "$build_os" in darwin*) case "$host_os" in darwin*) AC_SUBST(BUILD_AND_HOST_ARE_DARWIN, yes) ;; esac |
︙ | ︙ | |||
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | "$($TPUT AF 3 2>/dev/null)") AC_SUBST(TERM_SETAF4, "$($TPUT AF 4 2>/dev/null)") AC_SUBST(TERM_SETAF6, "$($TPUT AF 6 2>/dev/null)") fi ]) ]) ]) AC_DEFUN([BUILDSYS_CHECK_IOS], [ case "$host_os" in darwin*) AC_MSG_CHECKING(whether host is iOS) AC_EGREP_CPP(yes, [ #include <TargetConditionals.h> #if (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || \ (defined(TARGET_OS_SIMULATOR) && \ TARGET_OS_SIMULATOR) yes #endif ], [ host_is_ios="yes" ], [ host_is_ios="no" ]) AC_MSG_RESULT($host_is_ios) ;; esac ]) AC_DEFUN([BUILDSYS_PROG_IMPLIB], [ AC_REQUIRE([AC_CANONICAL_HOST]) AC_MSG_CHECKING(whether we need an implib) | > > > > > > > | 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | "$($TPUT AF 3 2>/dev/null)") AC_SUBST(TERM_SETAF4, "$($TPUT AF 4 2>/dev/null)") AC_SUBST(TERM_SETAF6, "$($TPUT AF 6 2>/dev/null)") fi ]) AS_IF([test x"$enable_silent_rules" != x"no"], [ AC_SUBST(SILENT, '.SILENT:') AC_SUBST(MAKEFLAGS_SILENT, '-s') ]) ]) ]) AC_DEFUN([BUILDSYS_CHECK_IOS], [ case "$host_os" in darwin*) AC_MSG_CHECKING(whether host is iOS) AC_EGREP_CPP(yes, [ #include <TargetConditionals.h> #if (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || \ (defined(TARGET_OS_SIMULATOR) && \ TARGET_OS_SIMULATOR) yes #endif ], [ host_is_ios="yes" AC_SUBST(HOST_IS_IOS, yes) ], [ host_is_ios="no" ]) AC_MSG_RESULT($host_is_ios) AC_CHECK_TOOL(CODESIGN, codesign) ;; esac ]) AC_DEFUN([BUILDSYS_PROG_IMPLIB], [ AC_REQUIRE([AC_CANONICAL_HOST]) AC_MSG_CHECKING(whether we need an implib) |
︙ | ︙ | |||
171 172 173 174 175 176 177 | AC_SUBST(PROG_IMPLIB_NEEDED) AC_SUBST(PROG_IMPLIB_LDFLAGS) ]) AC_DEFUN([BUILDSYS_SHARED_LIB], [ AC_REQUIRE([AC_CANONICAL_HOST]) AC_REQUIRE([BUILDSYS_CHECK_IOS]) | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | < < < < < < < < < < < < < < < < < < | | < < < < < < < < < < < | > < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 | AC_SUBST(PROG_IMPLIB_NEEDED) AC_SUBST(PROG_IMPLIB_LDFLAGS) ]) AC_DEFUN([BUILDSYS_SHARED_LIB], [ AC_REQUIRE([AC_CANONICAL_HOST]) AC_REQUIRE([BUILDSYS_CHECK_IOS]) AC_MSG_CHECKING(for shared library type) case "$host" in *-*-darwin*) AC_MSG_RESULT(Darwin) LIB_CFLAGS='-fPIC -DPIC' LIB_LDFLAGS='-dynamiclib -current_version ${LIB_MAJOR}.${LIB_MINOR} -compatibility_version ${LIB_MAJOR}' LIB_LDFLAGS_INSTALL_NAME='-Wl,-install_name,${libdir}/$${out%.dylib}.${LIB_MAJOR}.dylib' LIB_PREFIX='lib' LIB_SUFFIX='.dylib' AS_IF([test x"$enable_rpath" != x"no"], [ LDFLAGS_RPATH='-Wl,-rpath,${libdir}' ]) 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' CLEAN_LIB='' ;; *-*-mingw* | *-*-cygwin*) AC_MSG_RESULT(MinGW / Cygwin) LIB_CFLAGS='' LIB_LDFLAGS='-shared -Wl,--export-all-symbols' LIB_LDFLAGS_INSTALL_NAME='' LIB_PREFIX='' LIB_SUFFIX='${LIB_MAJOR}.dll' LINK_LIB='&& rm -f lib$${out%${LIB_SUFFIX}}.dll.a && ${LN_S} $$out lib$${out%${LIB_SUFFIX}}.dll.a' 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' CLEAN_LIB='${SHARED_LIB}.a ${SHARED_LIB_NOINST}.a' ;; *-*-openbsd* | *-*-mirbsd*) AC_MSG_RESULT(OpenBSD) LIB_CFLAGS='-fPIC -DPIC' LIB_LDFLAGS='-shared' LIB_LDFLAGS_INSTALL_NAME='' LIB_PREFIX='lib' LIB_SUFFIX='.so.${LIB_MAJOR}.${LIB_MINOR}' AS_IF([test x"$enable_rpath" != x"no"], [ LDFLAGS_RPATH='-Wl,-rpath,${libdir}' ]) INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i' UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i' CLEAN_LIB='' ;; *-*-solaris*) AC_MSG_RESULT(Solaris) LIB_CFLAGS='-fPIC -DPIC' LIB_LDFLAGS='-shared -Wl,-soname=$$out.${LIB_MAJOR}.${LIB_MINOR}' LIB_LDFLAGS_INSTALL_NAME='' LIB_PREFIX='lib' LIB_SUFFIX='.so' AS_IF([test x"$enable_rpath" != x"no"], [ LDFLAGS_RPATH='-Wl,-rpath,${libdir}' ]) 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}' 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' INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.${LIB_PATCH} && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.${LIB_PATCH} ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.${LIB_PATCH} ${DESTDIR}${libdir}/$$i' UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.${LIB_PATCH}' CLEAN_LIB='' ;; hppa*-*-hpux*) AC_MSG_RESULT([HP-UX (PA-RISC)]) LIB_CFLAGS='-fPIC -DPIC' LIB_LDFLAGS='-shared -Wl,+h,$$out' LIB_LDFLAGS_INSTALL_NAME='' LIB_PREFIX='lib' LIB_SUFFIX='.${LIB_MAJOR}' LINK_LIB='&& rm -f $${out%%.*}.sl && ${LN_S} $$out $${out%%.*}.sl' AS_IF([test x"$enable_rpath" != x"no"], [ LDFLAGS_RPATH='-Wl,+b,${libdir}' ]) 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' CLEAN_LIB='' ;; ia64*-*-hpux*) AC_MSG_RESULT([HP-UX (Itanium)]) LIB_CFLAGS='-fPIC -DPIC' LIB_LDFLAGS='-shared -Wl,+h,$$out' LIB_LDFLAGS_INSTALL_NAME='' LIB_PREFIX='lib' LIB_SUFFIX='.${LIB_MAJOR}' LINK_LIB='&& rm -f $${out%%.*}.so && ${LN_S} $$out $${out%%.*}.so' AS_IF([test x"$enable_rpath" != x"no"], [ LDFLAGS_RPATH='-Wl,+b,${libdir}' ]) 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' CLEAN_LIB='' ;; *) AC_MSG_RESULT(ELF) LIB_CFLAGS='-fPIC -DPIC' LIB_LDFLAGS='-shared -Wl,-soname=$$out.${LIB_MAJOR}' LIB_LDFLAGS_INSTALL_NAME='' LIB_PREFIX='lib' LIB_SUFFIX='.so' AS_IF([test x"$enable_rpath" != x"no"], [ LDFLAGS_RPATH='-Wl,-rpath,${libdir}' ]) INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.${LIB_PATCH} && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.${LIB_PATCH} ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} && ${LN_S} -f $$i.${LIB_MAJOR}.${LIB_MINOR}.${LIB_PATCH} ${DESTDIR}${libdir}/$$i' UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$$i.${LIB_MAJOR} ${DESTDIR}${libdir}/$$i.${LIB_MAJOR}.${LIB_MINOR}.${LIB_PATCH}' CLEAN_LIB='' ;; esac AC_SUBST(LIB_CFLAGS) AC_SUBST(LIB_LDFLAGS) AC_SUBST(LIB_LDFLAGS_INSTALL_NAME) AC_SUBST(LIB_PREFIX) AC_SUBST(LIB_SUFFIX) AC_SUBST(LINK_LIB) AC_SUBST(LDFLAGS_RPATH) AC_SUBST(INSTALL_LIB) AC_SUBST(UNINSTALL_LIB) AC_SUBST(CLEAN_LIB) ]) AC_DEFUN([BUILDSYS_FRAMEWORK], [ AC_REQUIRE([AC_CANONICAL_HOST]) AC_REQUIRE([BUILDSYS_CHECK_IOS]) AC_REQUIRE([BUILDSYS_SHARED_LIB]) case "$host_os" in darwin*) FRAMEWORK_LDFLAGS='-dynamiclib -current_version ${LIB_MAJOR}.${LIB_MINOR} -compatibility_version ${LIB_MAJOR}' AS_IF([test x"$host_is_ios" = x"yes"], [ FRAMEWORK_LDFLAGS_INSTALL_NAME='-Wl,-install_name,@executable_path/Frameworks/$$out/$${out%.framework}' ], [ FRAMEWORK_LDFLAGS_INSTALL_NAME='-Wl,-install_name,@executable_path/../Frameworks/$$out/$${out%.framework}' ]) AC_SUBST(FRAMEWORK_LDFLAGS) AC_SUBST(FRAMEWORK_LDFLAGS_INSTALL_NAME) AC_SUBST(FRAMEWORK_LIBS) $1 ;; esac ]) AC_DEFUN([BUILDSYS_PLUGIN], [ AC_REQUIRE([AC_CANONICAL_HOST]) AC_REQUIRE([BUILDSYS_CHECK_IOS]) AC_MSG_CHECKING(for plugin type) case "$host" in *-*-darwin*) AC_MSG_RESULT(Darwin) PLUGIN_CFLAGS='-fPIC -DPIC' PLUGIN_LDFLAGS='-bundle ${PLUGIN_LDFLAGS_BUNDLE_LOADER}' PLUGIN_SUFFIX='.bundle' AS_IF([test x"$host_is_ios" = x"yes"], [ LINK_PLUGIN='rm -fr $$out && ${MKDIR_P} $$out && if test -f Info.plist; then ${INSTALL} -m 644 Info.plist $$out/Info.plist; fi && ${LD} -o $$out/$${out%${PLUGIN_SUFFIX}} ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS} && ${CODESIGN} -fs ${CODESIGN_IDENTITY} $$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} $$out' ]) INSTALL_PLUGIN='&& rm -fr ${DESTDIR}${plugindir}/$$i && cp -R $$i ${DESTDIR}${plugindir}/' UNINSTALL_PLUGIN='&& rm -fr ${DESTDIR}${plugindir}/$$i' ;; *-*-mingw* | *-*-cygwin*) AC_MSG_RESULT(MinGW / Cygwin) PLUGIN_CFLAGS='' PLUGIN_LDFLAGS='-shared -Wl,--export-all-symbols' PLUGIN_SUFFIX='.dll' LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}' INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i' UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i' ;; hppa*-*-hpux*) AC_MSG_RESULT([HP-UX (PA-RISC)]) PLUGIN_CFLAGS='-fPIC -DPIC' PLUGIN_LDFLAGS='-shared' PLUGIN_SUFFIX='.sl' LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}' INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i' UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i' ;; *) AC_MSG_RESULT(ELF) PLUGIN_CFLAGS='-fPIC -DPIC' PLUGIN_LDFLAGS='-shared' PLUGIN_SUFFIX='.so' LINK_PLUGIN='${LD} -o $$out ${PLUGIN_OBJS} ${PLUGIN_OBJS_EXTRA} ${PLUGIN_LDFLAGS} ${LDFLAGS} ${LIBS}' INSTALL_PLUGIN='&& ${INSTALL} -m 755 $$i ${DESTDIR}${plugindir}/$$i' UNINSTALL_PLUGIN='&& rm -f ${DESTDIR}${plugindir}/$$i' ;; esac AC_SUBST(PLUGIN_CFLAGS) AC_SUBST(PLUGIN_LDFLAGS) AC_SUBST(PLUGIN_SUFFIX) AC_SUBST(LINK_PLUGIN) AC_SUBST(INSTALL_PLUGIN) AC_SUBST(UNINSTALL_PLUGIN) ]) |
Modified buildsys.mk.in from [2dfee6e012] to [2c79875d24].
1 2 | # # Copyright (c) 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, | | | 1 2 3 4 5 6 7 8 9 10 | # # Copyright (c) 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, # 2017, 2018, 2020, 2021, 2022, 2023 # Jonathan Schleifer <js@nil.im> # # https://fossil.nil.im/buildsys # # Permission to use, copy, modify, and/or distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice is present in all copies. |
︙ | ︙ | |||
119 120 121 122 123 124 125 | DEPS = ${OBJS:.o=.dep} \ ${LIB_OBJS:.o=.dep} \ ${AMIGA_LIB_OBJS:.o=.dep} \ ${PLUGIN_OBJS:.o=.dep} MO_FILES = ${LOCALES:.po=.mo} | | | > | > > | > | | > | > > > > > > > | | | | 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | DEPS = ${OBJS:.o=.dep} \ ${LIB_OBJS:.o=.dep} \ ${AMIGA_LIB_OBJS:.o=.dep} \ ${PLUGIN_OBJS:.o=.dep} MO_FILES = ${LOCALES:.po=.mo} @SILENT@ .SUFFIXES: .SUFFIXES: .amigalib.o .beam .c .cc .class .cxx .d .erl .lib.o .java \ .mo .m .mm .o .plugin.o .po .py .pyc .rc .S .xpm .PHONY: all subdirs subdirs-after pre-depend depend install \ install-extra uninstall uninstall-extra clean distclean locales \ copy-headers-into-framework ${SUBDIRS} ${SUBDIRS_AFTER} all: ${MAKE} @MAKEFLAGS_SILENT@ pre-all ${MAKE} @MAKEFLAGS_SILENT@ subdirs ${MAKE} @MAKEFLAGS_SILENT@ depend ${MAKE} @MAKEFLAGS_SILENT@ \ ${STATIC_LIB} ${STATIC_LIB_NOINST} \ ${STATIC_PIC_LIB} ${STATIC_PIC_LIB_NOINST} \ ${STATIC_AMIGA_LIB}${STATIC_AMIGA_LIB_NOINST} \ ${SHARED_LIB} ${SHARED_LIB_NOINST} \ ${FRAMEWORK} ${FRAMEWORK_NOINST} \ ${AMIGA_LIB} ${AMIGA_LIB_NOINST} \ ${PLUGIN} ${PLUGIN_NOINST} \ ${PROG} ${PROG_NOINST} \ ${JARFILE} locales ${MAKE} @MAKEFLAGS_SILENT@ subdirs-after ${MAKE} @MAKEFLAGS_SILENT@ post-all pre-all post-all: subdirs: ${SUBDIRS} subdirs-after: ${SUBDIRS_AFTER} ${SUBDIRS} ${SUBDIRS_AFTER}: for i in $@; do \ ${DIR_ENTER}; \ ${MAKE} @MAKEFLAGS_SILENT@ || exit $$?; \ ${DIR_LEAVE}; \ done depend: pre-depend : >.deps for i in "" ${DEPS}; do \ test x"$$i" = x"" && continue; \ |
︙ | ︙ | |||
165 166 167 168 169 170 171 | else \ ${LINK_FAILED}; \ fi ${JARFILE}: ${EXT_DEPS} ${JAR_MANIFEST} ${OBJS} ${OBJS_EXTRA} ${LINK_STATUS} if test x"${JAR_MANIFEST}" != x""; then \ | | > | > > > > > | > > > > > > > > > > > > > > | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > | > > | | > | > > | 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | else \ ${LINK_FAILED}; \ fi ${JARFILE}: ${EXT_DEPS} ${JAR_MANIFEST} ${OBJS} ${OBJS_EXTRA} ${LINK_STATUS} if test x"${JAR_MANIFEST}" != x""; then \ if ${JAR} cfm ${JARFILE} ${JAR_MANIFEST} ${OBJS} \ ${OBJS_EXTRA}; then \ ${LINK_OK}; \ else \ ${LINK_FAILED}; \ fi \ else \ if ${JAR} cf ${JARFILE} ${OBJS} ${OBJS_EXTRA}; then \ ${LINK_OK}; \ else \ ${LINK_FAILED}; \ fi \ fi ${SHARED_LIB} ${SHARED_LIB_NOINST}: ${EXT_DEPS} ${LIB_OBJS} ${LIB_OBJS_EXTRA} ${LINK_STATUS} out="$@"; \ if ${LD} -o $@ ${LIB_OBJS} ${LIB_OBJS_EXTRA} ${LIB_LDFLAGS} \ ${LIB_LDFLAGS_INSTALL_NAME} ${LDFLAGS} ${LIBS} ${LINK_LIB}; then \ ${LINK_OK}; \ else \ ${LINK_FAILED}; \ fi ${FRAMEWORK} ${FRAMEWORK_NOINST}: ${EXT_DEPS} ${LIB_OBJS} ${LIB_OBJS_EXTRA} ${LINK_STATUS} out="$@"; \ if test x"@HOST_IS_IOS@" = x"yes"; then \ if rm -fr $@ && \ ${MAKE} @MAKEFLAGS_SILENT@ \ COPY_HEADERS_IF_SUBDIR=${includesubdir} \ COPY_HEADERS_DESTINATION=$$PWD/$@/Headers \ copy-headers-into-framework && \ if test -f Info.plist; then \ ${INSTALL} -m 644 Info.plist $@/Info.plist; \ fi && \ if test -f module.modulemap; then \ ${MKDIR_P} $@/Modules && \ ${INSTALL} -m 644 module.modulemap \ $@/Modules/module.modulemap; \ fi && \ ${LD} -o $@/$${out%.framework} \ ${LIB_OBJS} ${LIB_OBJS_EXTRA} ${FRAMEWORK_LDFLAGS} \ ${FRAMEWORK_LDFLAGS_INSTALL_NAME} ${LDFLAGS} \ ${FRAMEWORK_LIBS} && \ ${CODESIGN} -fs ${CODESIGN_IDENTITY} $@; then \ ${LINK_OK}; \ else \ rm -fr $$out; false; \ ${LINK_FAILED}; \ fi; \ else \ versiondir="$@/Versions/${LIB_MAJOR}"; \ if rm -fr $@ && \ ${MKDIR_P} $$versiondir && \ ${LN_S} ${LIB_MAJOR} $@/Versions/Current && \ ${MAKE} @MAKEFLAGS_SILENT@ \ COPY_HEADERS_IF_SUBDIR=${includesubdir} \ COPY_HEADERS_DESTINATION=$$PWD/$$versiondir/Headers \ copy-headers-into-framework && \ ${LN_S} Versions/Current/Headers $@/Headers && \ if test -f Info.plist; then \ ${MKDIR_P} $$versiondir/Resources && \ ${INSTALL} -m 644 Info.plist \ $$versiondir/Resources/Info.plist && \ ${LN_S} Versions/Current/Resources $@/Resources; \ fi && \ if test -f module.modulemap; then \ ${MKDIR_P} $$versiondir/Modules && \ ${INSTALL} -m 644 module.modulemap \ $$versiondir/Modules/module.modulemap && \ ${LN_S} Versions/Current/Modules $@/Modules; \ fi && \ ${LD} -o $$versiondir/$${out%.framework} \ ${LIB_OBJS} ${LIB_OBJS_EXTRA} ${FRAMEWORK_LDFLAGS} \ ${FRAMEWORK_LDFLAGS_INSTALL_NAME} ${LDFLAGS} \ ${FRAMEWORK_LIBS} && \ ${LN_S} Versions/Current/$${out%.framework} \ $@/$${out%.framework} && \ ${CODESIGN} -fs ${CODESIGN_IDENTITY} $@; then \ ${LINK_OK}; \ else \ rm -fr $$out; false; \ ${LINK_FAILED}; \ fi; \ fi copy-headers-into-framework: for i in "" ${SUBDIRS} ${SUBDIRS_AFTER}; do \ test x"$$i" = x"" && continue; \ cd $$i || exit 1; \ ${MAKE} @MAKEFLAGS_SILENT@ copy-headers-into-framework || \ exit $$?; \ cd .. || exit 1; \ done if test x"${includesubdir}" = x"${COPY_HEADERS_IF_SUBDIR}"; then \ for i in "" ${INCLUDES}; do \ test x"$$i" = x"" && continue; \ ${MKDIR_P} \ $$(dirname ${COPY_HEADERS_DESTINATION}/$$i) || \ exit $$?; \ ${INSTALL} -m 644 $$i \ ${COPY_HEADERS_DESTINATION}/$$i || exit $$?; \ done \ fi ${AMIGA_LIB} ${AMIGA_LIB_NOINST}: ${EXT_DEPS} ${AMIGA_LIB_OBJS_START} \ ${AMIGA_LIB_OBJS} ${AMIGA_LIB_OBJS_EXTRA} ${LINK_STATUS} if ${LD} -o $@ ${AMIGA_LIB_OBJS_START} ${AMIGA_LIB_OBJS} \ ${AMIGA_LIB_OBJS_EXTRA} ${AMIGA_LIB_LDFLAGS} \ ${AMIGA_LIB_LIBS}; then \ ${LINK_OK}; \ else \ ${LINK_FAILED}; \ fi ${PLUGIN} ${PLUGIN_NOINST}: ${EXT_DEPS} ${PLUGIN_OBJS} ${LINK_STATUS} |
︙ | ︙ | |||
278 279 280 281 282 283 284 | fi; \ for i in $$ars; do \ dir=".$$(echo $$i | sed 's/\//_/g').objs"; \ rm -fr $$dir; \ done; \ fi | | > | > | 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | fi; \ for i in $$ars; do \ dir=".$$(echo $$i | sed 's/\//_/g').objs"; \ rm -fr $$dir; \ done; \ fi ${STATIC_PIC_LIB} ${STATIC_PIC_LIB_NOINST}: ${EXT_DEPS} ${LIB_OBJS} \ ${LIB_OBJS_EXTRA} ${LINK_STATUS} rm -f $@ if test x"${BUILD_AND_HOST_ARE_DARWIN}" = x"yes"; then \ if /usr/bin/libtool -static -o $@ ${LIB_OBJS} \ ${LIB_OBJS_EXTRA}; then \ ${LINK_OK}; \ else \ rm -f $@; false; \ ${LINK_FAILED}; \ fi; \ else \ out="$@"; \ |
︙ | ︙ | |||
325 326 327 328 329 330 331 | fi; \ for i in $$ars; do \ dir=".$$(echo $$i | sed 's/\//_/g').objs"; \ rm -fr $$dir; \ done; \ fi | | > | 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | fi; \ for i in $$ars; do \ dir=".$$(echo $$i | sed 's/\//_/g').objs"; \ rm -fr $$dir; \ done; \ fi ${STATIC_AMIGA_LIB} ${STATIC_AMIGA_LIB_NOINST}: ${EXT_DEPS} ${AMIGA_LIB_OBJS} \ ${AMIGA_LIB_OBJS_EXTRA} ${LINK_STATUS} rm -f $@ out="$@"; \ objs=""; \ ars=""; \ for i in ${AMIGA_LIB_OBJS} ${AMIGA_LIB_OBJS_EXTRA}; do \ case $$i in \ |
︙ | ︙ | |||
369 370 371 372 373 374 375 | locales: ${MO_FILES} .c.o: ${COMPILE_STATUS} in="$<"; \ out="$@"; \ | | > | > | > | > | > | > | > | > | 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 | locales: ${MO_FILES} .c.o: ${COMPILE_STATUS} in="$<"; \ out="$@"; \ if ${CC} ${CFLAGS} ${CPPFLAGS} ${CFLAGS_$<} ${CFLAGS_$@} ${DEP_CFLAGS} \ -c -o $@ $<; then \ ${COMPILE_OK}; \ else \ ${COMPILE_FAILED}; \ fi .c.lib.o: ${COMPILE_LIB_STATUS} in="$<"; \ out="$@"; \ if ${CC} ${LIB_CFLAGS} ${CFLAGS} ${CPPFLAGS} ${CFLAGS_$<} ${CFLAGS_$@} \ ${DEP_CFLAGS} -c -o $@ $<; then \ ${COMPILE_LIB_OK}; \ else \ ${COMPILE_LIB_FAILED}; \ fi .c.amigalib.o: ${COMPILE_AMIGA_LIB_STATUS} in="$<"; \ out="$@"; \ if ${CC} ${AMIGA_LIB_CFLAGS} ${CFLAGS} ${CPPFLAGS} ${CFLAGS_$<} \ ${CFLAGS_$@} ${DEP_CFLAGS} -c -o $@ $<; then \ ${COMPILE_AMIGA_LIB_OK}; \ else \ ${COMPILE_AMIGA_LIB_FAILED}; \ fi .c.plugin.o: ${COMPILE_PLUGIN_STATUS} in="$<"; \ out="$@"; \ if ${CC} ${PLUGIN_CFLAGS} ${CFLAGS} ${CPPFLAGS} ${CFLAGS_$<} \ ${CFLAGS_$@} ${DEP_CFLAGS} -c -o $@ $<; then \ ${COMPILE_PLUGIN_OK}; \ else \ ${COMPILE_PLUGIN_FAILED}; \ fi .cc.o .cxx.o: ${COMPILE_STATUS} in="$<"; \ out="$@"; \ if ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${CXXFLAGS_$<} ${CXXFLAGS_$@} \ ${DEP_CXXFLAGS} -c -o $@ $<; then \ ${COMPILE_OK}; \ else \ ${COMPILE_FAILED}; \ fi .cc.lib.o .cxx.lib.o: ${COMPILE_LIB_STATUS} in="$<"; \ out="$@"; \ if ${CXX} ${LIB_CFLAGS} ${CXXFLAGS} ${CPPFLAGS} ${CXXFLAGS_$<} \ ${CXXFLAGS_$@} ${DEP_CXXFLAGS} -c -o $@ $<; then \ ${COMPILE_LIB_OK}; \ else \ ${COMPILE_LIB_FAILED}; \ fi .cc.amigalib.o .cxx.amigalib.o: ${COMPILE_AMIGA_LIB_STATUS} in="$<"; \ out="$@"; \ if ${CXX} ${AMIGA_LIB_CFLAGS} ${CXXFLAGS} ${CPPFLAGS} ${CXXFLAGS_$<} \ ${CXXFLAGS_$@} ${DEP_CXXFLAGS} -c -o $@ $<; then \ ${COMPILE_AMIGA_LIB_OK}; \ else \ ${COMPILE_AMIGA_LIB_FAILED}; \ fi .cc.plugin.o .cxx.plugin.o: ${COMPILE_PLUGIN_STATUS} in="$<"; \ out="$@"; \ if ${CXX} ${PLUGIN_CFLAGS} ${CXXFLAGS} ${CPPFLAGS} ${CXXFLAGS_$<} \ ${CXXFLAGS_$@} ${DEP_CXXFLAGS} -c -o $@ $<; then \ ${COMPILE_PLUGIN_OK}; \ else \ ${COMPILE_PLUGIN_FAILED}; \ fi .d.o: ${COMPILE_STATUS} |
︙ | ︙ | |||
481 482 483 484 485 486 487 | ${COMPILE_FAILED}; \ fi .m.o: ${COMPILE_STATUS} in="$<"; \ out="$@"; \ | | > | > | > | > | > | > > | > > | > > | > | > | > | > | > | > | > | > | | > | > | > > > > | | > > > > | > > | > > | > | | | > | > | 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 | ${COMPILE_FAILED}; \ fi .m.o: ${COMPILE_STATUS} in="$<"; \ out="$@"; \ if ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} ${OBJCFLAGS_$<} ${OBJCFLAGS_$@} \ ${DEP_OBJCFLAGS} -c -o $@ $<; then \ ${COMPILE_OK}; \ else \ ${COMPILE_FAILED}; \ fi .m.lib.o: ${COMPILE_LIB_STATUS} in="$<"; \ out="$@"; \ if ${OBJC} ${LIB_CFLAGS} ${OBJCFLAGS} ${CPPFLAGS} ${OBJCFLAGS_$<} \ ${OBJCFLAGS_$@} ${DEP_OBJCFLAGS} -c -o $@ $<; then \ ${COMPILE_LIB_OK}; \ else \ ${COMPILE_LIB_FAILED}; \ fi .m.amigalib.o: ${COMPILE_AMIGA_LIB_STATUS} in="$<"; \ out="$@"; \ if ${OBJC} ${AMIGA_LIB_CFLAGS} ${OBJCFLAGS} ${CPPFLAGS} \ ${OBJCFLAGS_$<} ${OBJCFLAGS_$@} ${DEP_OBJCFLAGS} -c -o $@ $<; then \ ${COMPILE_AMIGA_LIB_OK}; \ else \ ${COMPILE_AMIGA_LIB_FAILED}; \ fi .m.plugin.o: ${COMPILE_PLUGIN_STATUS} in="$<"; \ out="$@"; \ if ${OBJC} ${PLUGIN_CFLAGS} ${OBJCFLAGS} ${CPPFLAGS} ${OBJCFLAGS_$<} \ ${OBJCFLAGS_$@} ${DEP_OBJCFLAGS} -c -o $@ $<; then \ ${COMPILE_PLUGIN_OK}; \ else \ ${COMPILE_PLUGIN_FAILED}; \ fi .mm.o: ${COMPILE_STATUS} in="$<"; \ out="$@"; \ if ${OBJCXX} ${OBJCXXFLAGS} ${CPPFLAGS} ${OBJCXXFLAGS_$<} \ ${OBJCXXFLAGS_$@} ${DEP_OBJCXXFLAGS} -c -o $@ $<; then \ ${COMPILE_OK}; \ else \ ${COMPILE_FAILED}; \ fi .mm.lib.o: ${COMPILE_LIB_STATUS} in="$<"; \ out="$@"; \ if ${OBJCXX} ${LIB_CFLAGS} ${OBJCXXFLAGS} ${CPPFLAGS} \ ${OBJCXXFLAGS_$<} ${OBJCXXFLAGS_$@} ${DEP_OBJCXXFLAGS} -c -o $@ \ $<; then \ ${COMPILE_LIB_OK}; \ else \ ${COMPILE_LIB_FAILED}; \ fi .mm.amigalib.o: ${COMPILE_AMIGA_LIB_STATUS} in="$<"; \ out="$@"; \ if ${OBJCXX} ${AMIGA_LIB_CFLAGS} ${OBJCXXFLAGS} ${CPPFLAGS} \ ${OBJCXXFLAGS_$<} ${OBJCXXFLAGS_$@} ${DEP_OBJCXXFLAGS} -c -o $@ \ $<; then \ ${COMPILE_AMIGA_LIB_OK}; \ else \ ${COMPILE_AMIGA_LIB_FAILED}; \ fi .mm.plugin.o: ${COMPILE_PLUGIN_STATUS} in="$<"; \ out="$@"; \ if ${OBJCXX} ${PLUGIN_CFLAGS} ${OBJCXXFLAGS} ${CPPFLAGS} \ ${OBJCXXFLAGS_$<} ${OBJCXXFLAGS_$@} ${DEP_OBJCXXFLAGS} -c -o $@ \ $<; then \ ${COMPILE_PLUGIN_OK}; \ else \ ${COMPILE_PLUGIN_FAILED}; \ fi .po.mo: ${COMPILE_STATUS} in="$<"; \ out="$@"; \ if ${MSGFMT} -c -o $@ $<; then \ ${COMPILE_OK}; \ else \ ${COMPILE_FAILED}; \ fi .py.pyc: ${COMPILE_STATUS} in="$<"; \ out="$@"; \ if ${PYTHON} ${PYTHON_FLAGS} -c \ "import py_compile; py_compile.compile('$<')"; then \ ${COMPILE_OK}; \ else \ ${COMPILE_FAILED}; \ fi .rc.o .rc.lib.o .rc.plugin.o: ${COMPILE_STATUS} in="$<"; \ out="$@"; \ if ${RC} ${RCFLAGS} ${CPPFLAGS} -J rc -O coff -o $@ $<; then \ ${COMPILE_OK}; \ else \ ${COMPILE_FAILED}; \ fi .S.o .S.amigalib.o: ${COMPILE_STATUS} in="$<"; \ out="$@"; \ if ${AS} ${ASFLAGS} ${CPPFLAGS} ${ASFLAGS_$<} ${ASFLAGS_$@} \ ${DEP_ASFLAGS} -c -o $@ $<; then \ ${COMPILE_OK}; \ else \ ${COMPILE_FAILED}; \ fi .S.lib.o: ${COMPILE_LIB_STATUS} in="$<"; \ out="$@"; \ if ${AS} ${LIB_CFLAGS} ${ASFLAGS} ${CPPFLAGS} ${ASFLAGS_$<} \ ${ASFLAGS_$@} ${DEP_ASFLAGS} -c -o $@ $<; then \ ${COMPILE_LIB_OK}; \ else \ ${COMPILE_LIB_FAILED}; \ fi .S.plugin.o: ${COMPILE_PLUGIN_STATUS} in="$<"; \ out="$@"; \ if ${AS} ${PLUGIN_CFLAGS} ${ASFLAGS} ${CPPFLAGS} ${ASFLAGS_$<} \ ${ASFLAGS_$@} ${DEP_ASFLAGS} -c -o $@ $<; then \ ${COMPILE_PLUGIN_OK}; \ else \ ${COMPILE_PLUGIN_FAILED}; \ fi .xpm.o: ${COMPILE_STATUS} in="$<"; \ out="$@"; \ if ${CC} ${CFLAGS} ${CPPFLAGS} ${CFLAGS_$<} ${CFLAGS_$@} -x c -c -o $@ \ $<; then \ ${COMPILE_OK}; \ else \ ${COMPILE_FAILED}; \ fi .xpm.lib.o: ${COMPILE_LIB_STATUS} in="$<"; \ out="$@"; \ if ${CC} ${LIB_CFLAGS} ${CFLAGS} ${CPPFLAGS} ${CFLAGS_$<} ${CFLAGS_$@} \ -x c -c -o $@ $<; then \ ${COMPILE_LIB_OK}; \ else \ ${COMPILE_LIB_FAILED}; \ fi .xpm.amigalib.o: ${COMPILE_AMIGA_LIB_STATUS} in="$<"; \ out="$@"; \ if ${CC} ${AMIGA_LIB_CFLAGS} ${CFLAGS} ${CPPFLAGS} ${CFLAGS_$<} \ ${CFLAGS_$@} -x c -c -o $@ $<; then \ ${COMPILE_AMIGA_LIB_OK}; \ else \ ${COMPILE_AMIGA_LIB_FAILED}; \ fi .xpm.plugin.o: ${COMPILE_PLUGIN_STATUS} in="$<"; \ out="$@"; \ if ${CC} ${PLUGIN_CFLAGS} ${CFLAGS} ${CPPFLAGS} ${CFLAGS_$<} \ ${CFLAGS_$@} -x c -c -o $@ $<; then \ ${COMPILE_PLUGIN_OK}; \ else \ ${COMPILE_PLUGIN_FAILED}; \ fi install: all install-extra for i in "" ${SUBDIRS} ${SUBDIRS_AFTER}; do \ test x"$$i" = x"" && continue; \ ${DIR_ENTER}; \ ${MAKE} @MAKEFLAGS_SILENT@ install || exit $$?; \ ${DIR_LEAVE}; \ done for i in "" ${SHARED_LIB}; do \ test x"$$i" = x"" && continue; \ ${INSTALL_STATUS}; \ if ${MKDIR_P} ${DESTDIR}${libdir} @INSTALL_LIB@; then \ ${INSTALL_OK}; \ else \ ${INSTALL_FAILED}; \ fi \ done for i in "" ${FRAMEWORK}; do \ test x"$$i" = x"" && continue; \ ${INSTALL_STATUS}; \ rm -fr ${DESTDIR}${prefix}/Library/Frameworks/$$i; \ if ${MKDIR_P} ${DESTDIR}${prefix}/Library/Frameworks && \ cp -R $$i ${DESTDIR}${prefix}/Library/Frameworks/; then \ ${INSTALL_OK}; \ else \ ${INSTALL_FAILED}; \ fi \ done for i in "" ${AMIGA_LIB}; do \ test x"$$i" = x"" && continue; \ ${INSTALL_STATUS}; \ if ${MKDIR_P} ${DESTDIR}${amigalibdir} && \ ${INSTALL} -m 755 $$i ${DESTDIR}${amigalibdir}/$$i; then \ ${INSTALL_OK}; \ else \ ${INSTALL_FAILED}; \ fi \ done for i in "" ${STATIC_LIB} ${STATIC_PIC_LIB} ${STATIC_AMIGA_LIB}; do \ test x"$$i" = x"" && continue; \ ${INSTALL_STATUS}; \ if ${MKDIR_P} ${DESTDIR}${libdir} && \ ${INSTALL} -m 644 $$i ${DESTDIR}${libdir}/$$i; then \ ${INSTALL_OK}; \ else \ ${INSTALL_FAILED}; \ fi \ done for i in "" ${PLUGIN}; do \ test x"$$i" = x"" && continue; \ ${INSTALL_STATUS}; \ if ${MKDIR_P} ${DESTDIR}${plugindir} @INSTALL_PLUGIN@; then \ ${INSTALL_OK}; \ else \ ${INSTALL_FAILED}; \ fi \ done for i in "" ${DATA}; do \ test x"$$i" = x"" && continue; \ ${INSTALL_STATUS}; \ if ${MKDIR_P} $$(dirname \ ${DESTDIR}${datadir}/${PACKAGE_NAME}/$$i) && \ ${INSTALL} -m 644 $$i \ ${DESTDIR}${datadir}/${PACKAGE_NAME}/$$i; then \ ${INSTALL_OK}; \ else \ ${INSTALL_FAILED}; \ fi \ done for i in "" ${PROG}; do \ test x"$$i" = x"" && continue; \ ${INSTALL_STATUS}; \ if ${MKDIR_P} ${DESTDIR}${bindir} && \ ${INSTALL} -m 755 $$i ${DESTDIR}${bindir}/$$i; then \ ${INSTALL_OK}; \ else \ ${INSTALL_FAILED}; \ fi \ done if test x"${INSTALL_INCLUDES}" = x"yes"; then \ for i in "" ${INCLUDES}; do \ test x"$$i" = x"" && continue; \ ${INSTALL_STATUS}; \ if ${MKDIR_P} $$(dirname \ ${DESTDIR}${includedir}/${includesubdir}/$$i) && \ ${INSTALL} -m 644 $$i \ ${DESTDIR}${includedir}/${includesubdir}/$$i; then \ ${INSTALL_OK}; \ else \ ${INSTALL_FAILED}; \ fi \ done \ fi for i in "" ${MO_FILES}; do \ test x"$$i" = x"" && continue; \ ${INSTALL_STATUS}; \ dest="${localedir}/$${i%.mo}/LC_MESSAGES/${localename}.mo"; \ dest="${DESTDIR}$$dest"; \ if ${MKDIR_P} ${DESTDIR}${localedir}/$${i%.mo}/LC_MESSAGES && \ ${INSTALL} -m 644 $$i $$dest; then \ ${INSTALL_OK}; \ else \ ${INSTALL_FAILED}; \ fi \ done for i in "" ${MAN}; do \ test x"$$i" = x"" && continue; \ ${INSTALL_STATUS}; \ dest="${DESTDIR}${mandir}/${mansubdir}/$$i"; \ if ${MKDIR_P} ${DESTDIR}${mandir}/${mansubdir} && \ ${INSTALL} -m 644 $$i $$dest; then \ ${INSTALL_OK}; \ else \ ${INSTALL_FAILED}; \ fi \ done install-extra: uninstall: for i in "" ${SUBDIRS} ${SUBDIRS_AFTER}; do \ test x"$$i" = x"" && continue; \ ${DIR_ENTER}; \ ${MAKE} @MAKEFLAGS_SILENT@ uninstall || exit $$?; \ ${DIR_LEAVE}; \ done for i in "" ${SHARED_LIB}; do \ test x"$$i" = x"" && continue; \ if test -f ${DESTDIR}${libdir}/$$i \ -o -f ${DESTDIR}${bindir}/$$i; then \ if : @UNINSTALL_LIB@; then \ ${DELETE_OK}; \ else \ ${DELETE_FAILED}; \ fi \ fi; \ done for i in "" ${FRAMEWORK}; do \ test x"$$i" = x"" && continue; \ if test -d ${DESTDIR}${prefix}/Library/Frameworks/$$i; then \ if rm -fr ${DESTDIR}${prefix}/Library/Frameworks/$$i; \ then \ ${DELETE_OK}; \ else \ ${DELETE_FAILED}; \ fi \ fi \ done rmdir ${DESTDIR}${prefix}/Library/Frameworks >/dev/null 2>&1 || true |
︙ | ︙ | |||
817 818 819 820 821 822 823 | fi \ done rmdir ${DESTDIR}${plugindir} >/dev/null 2>&1 || true for i in "" ${DATA}; do \ test x"$$i" = x"" && continue; \ if test -f ${DESTDIR}${datadir}/${PACKAGE_NAME}/$$i; then \ | | > | > | > | | > > > > | | > > > > > > > | > | | 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 | fi \ done rmdir ${DESTDIR}${plugindir} >/dev/null 2>&1 || true for i in "" ${DATA}; do \ test x"$$i" = x"" && continue; \ if test -f ${DESTDIR}${datadir}/${PACKAGE_NAME}/$$i; then \ if rm -f ${DESTDIR}${datadir}/${PACKAGE_NAME}/$$i; \ then \ ${DELETE_OK}; \ else \ ${DELETE_FAILED}; \ fi \ fi; \ rmdir "$$(dirname ${DESTDIR}${datadir}/${PACKAGE_NAME}/$$i)" \ >/dev/null 2>&1 || true; \ done rmdir ${DESTDIR}${datadir}/${PACKAGE_NAME} >/dev/null 2>&1 || true for i in "" ${PROG}; do \ test x"$$i" = x"" && continue; \ if test -f ${DESTDIR}${bindir}/$$i; then \ if rm -f ${DESTDIR}${bindir}/$$i; then \ ${DELETE_OK}; \ else \ ${DELETE_FAILED}; \ fi \ fi \ done for i in "" ${INCLUDES}; do \ test x"$$i" = x"" && continue; \ if test -f ${DESTDIR}${includedir}/${includesubdir}/$$i; then \ if rm -f ${DESTDIR}${includedir}/${includesubdir}/$$i; \ then \ ${DELETE_OK}; \ else \ ${DELETE_FAILED}; \ fi \ fi \ done rmdir ${DESTDIR}${includedir}/${includesubdir} >/dev/null 2>&1 || true for i in "" ${MO_FILES}; do \ test x"$$i" = x"" && continue; \ mo="${localedir}/$${i%.mo}/LC_MESSAGES/${localename}.mo"; \ mo="${DESTDIR}$$mo"; \ if test -f $$mo; then \ if rm -f $$mo; then \ ${DELETE_OK}; \ else \ ${DELETE_FAILED}; \ fi \ fi \ done for i in "" ${MAN}; do \ test x"$$i" = x"" && continue; \ if test -f ${DESTDIR}${mandir}/${mansubdir}/$$i; then \ if rm -f ${DESTDIR}${mandir}/${mansubdir}/$$i; then \ ${DELETE_OK}; \ else \ ${DELETE_FAILED}; \ fi \ fi \ done ${MAKE} @MAKEFLAGS_SILENT@ uninstall-extra uninstall-extra: clean: for i in "" ${SUBDIRS} ${SUBDIRS_AFTER}; do \ test x"$$i" = x"" && continue; \ ${DIR_ENTER}; \ ${MAKE} @MAKEFLAGS_SILENT@ clean || exit $$?; \ ${DIR_LEAVE}; \ done : >.deps for i in "" ${DEPS} ${OBJS} ${OBJS_EXTRA} ${LIB_OBJS} \ ${LIB_OBJS_EXTRA} ${AMIGA_LIB_OBJS} ${AMIGA_LIB_OBJS_START} \ ${AMIGA_LIB_OBJS_EXTRA} ${PLUGIN_OBJS} ${PROG} ${PROG_NOINST} \ ${SHARED_LIB} ${SHARED_LIB_NOINST} ${AMIGA_LIB} \ ${AMIGA_LIB_NOINST} ${STATIC_LIB} ${STATIC_LIB_NOINST} \ ${STATIC_PIC_LIB} ${STATIC_PIC_LIB_NOINST} ${STATIC_AMIGA_LIB} \ ${STATIC_AMIGA_LIB_NOINST} ${FRAMEWORK} ${PLUGIN} ${PLUGIN_NOINST} \ ${CLEAN_LIB} ${MO_FILES} ${CLEAN}; do \ test x"$$i" = x"" && continue; \ if test -f $$i -o -d $$i; then \ if rm -fr $$i; then \ ${DELETE_OK}; \ else \ ${DELETE_FAILED}; \ fi \ fi \ done distclean: clean for i in "" ${SUBDIRS} ${SUBDIRS_AFTER}; do \ test x"$$i" = x"" && continue; \ ${DIR_ENTER}; \ ${MAKE} @MAKEFLAGS_SILENT@ distclean || exit $$?; \ ${DIR_LEAVE}; \ done for i in "" ${DISTCLEAN} .deps *~; do \ test x"$$i" = x"" && continue; \ if test -f $$i -o -d $$i; then \ if rm -fr $$i; then \ ${DELETE_OK}; \ else \ ${DELETE_FAILED}; \ fi \ fi \ done print-hierarchy: for i in "" ${SUBDIRS} ${SUBDIRS_AFTER}; do \ test x"$$i" = x"" && continue; \ echo ${PRINT_HIERARCHY_PREFIX}$$i; \ cd $$i || exit $$?; \ ${MAKE} @MAKEFLAGS_SILENT@ PRINT_HIERARCHY_PREFIX=$$i/ \ print-hierarchy || exit $$?; \ cd .. || exit $$?; \ done print-var: printf '%s\n' '${${VAR}}' DIR_ENTER = printf "@TERM_EL@@TERM_SETAF6@Entering directory @TERM_BOLD@%s@TERM_SGR0@@TERM_SETAF6@.@TERM_SGR0@\n" "$$i"; cd $$i || exit $$? |
︙ | ︙ |
Modified configure.ac from [64eea459b1] to [8d75a3de9d].
|
| | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | AC_INIT(ObjFW, 1.2dev, js@nil.im, objfw, https://objfw.nil.im/) AC_CONFIG_SRCDIR(src) AC_CONFIG_AUX_DIR(build-aux) AC_CONFIG_MACRO_DIR(build-aux/m4) AC_DEFINE(OBJFW_VERSION_MAJOR, 1, [The major version of ObjFW]) AC_DEFINE(OBJFW_VERSION_MINOR, 2, [The minor version of ObjFW]) dnl This may only be set to 1.2 once 1.2 is released AC_SUBST(BUNDLE_VERSION, 1.1.0) AC_SUBST(BUNDLE_SHORT_VERSION, 1.1) for i in configure.ac build-aux/m4/*; do AS_IF([test $i -nt configure], [ AC_MSG_ERROR([$i is newer than configure! Run ./autogen.sh!]) ]) done |
︙ | ︙ | |||
33 34 35 36 37 38 39 | enable_shared="no" enable_threads="no" enable_sockets="no" enable_files="no" ;; m68k-*-amigaos*) | | < < < < < < < < < < < < | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | enable_shared="no" enable_threads="no" enable_sockets="no" enable_files="no" ;; m68k-*-amigaos*) AS_IF([test x"$OBJCFLAGS" = x""], [OBJCFLAGS="-O0 -g"]) OBJCFLAGS="$OBJCFLAGS -noixemul" OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -noixemul" CPPFLAGS="$CPPFLAGS -D__NO_NET_API" LDFLAGS="$LDFLAGS -noixemul" LIBS="$LIBS -ldebug" enable_files="yes" # Required for reading ENV: enable_shared="no" with_tls="no" AC_SUBST(LIBBASES_M, libbases.m) ;; powerpc-*-amigaos*) CPPFLAGS="$CPPFLAGS -D__USE_INLINE__" enable_files="yes" # Required for reading ENV: |
︙ | ︙ | |||
76 77 78 79 80 81 82 | OBJCFLAGS="$OBJCFLAGS -noixemul" OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -noixemul" LDFLAGS="$LDFLAGS -noixemul" LIBS="$LIBS -ldebug" enable_files="yes" # Required for reading ENV: enable_shared="no" | < < < < < < < < < < | | 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | OBJCFLAGS="$OBJCFLAGS -noixemul" OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -noixemul" LDFLAGS="$LDFLAGS -noixemul" LIBS="$LIBS -ldebug" enable_files="yes" # Required for reading ENV: enable_shared="no" AC_SUBST(LIBBASES_M, libbases.m) ;; *-msdosdjgpp*) enable_shared="no" enable_threads="no" enable_sockets="no" ;; *-*-mingw*) LDFLAGS="$LDFLAGS -Wl,--allow-multiple-definition" LIBS="$LIBS -lversion" AC_SUBST(USE_SRCS_WINDOWS, '${SRCS_WINDOWS}') ;; *-psp-*) AS_IF([test x"$DEVKITPSP" = x""], [ AC_MSG_ERROR([DEVKITPSP is not set! Please set DEVKITPSP.]) |
︙ | ︙ | |||
140 141 142 143 144 145 146 147 148 149 150 151 152 153 | LIBS="$LIBS -latomic" ;; *-*-mint*) enable_shared="no" enable_threads="no" # TODO with_tls="no" ;; esac AS_IF([test x"$host_os" = x"msdosdjgpp" -a x"$build_os" = x"msdosdjgpp"], [ dnl Hack to make configure find these on DOS. : ${AR:=ar.exe} : ${GREP:=grep.exe} : ${RANLIB:=ranlib.exe} | > > > > > > > > | 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | LIBS="$LIBS -latomic" ;; *-*-mint*) enable_shared="no" enable_threads="no" # TODO with_tls="no" ;; *-apple-macos*) enable_shared="no" enable_threads="no" # TODO enable_sockets="no" # TODO AC_DEFINE(OF_CLASSIC_MACOS, 1, [Whether we are compiling for classic macOS]) ;; esac AS_IF([test x"$host_os" = x"msdosdjgpp" -a x"$build_os" = x"msdosdjgpp"], [ dnl Hack to make configure find these on DOS. : ${AR:=ar.exe} : ${GREP:=grep.exe} : ${RANLIB:=ranlib.exe} |
︙ | ︙ | |||
162 163 164 165 166 167 168 | ;; *) potential_compilers="clang egcc gcc" ;; esac AC_PROG_OBJC($potential_compilers) AC_PROG_OBJCPP | | | > | 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | ;; *) potential_compilers="clang egcc gcc" ;; esac AC_PROG_OBJC($potential_compilers) AC_PROG_OBJCPP AC_PROG_EGREP AC_PROG_SED AC_PROG_LN_S BUILDSYS_CHECK_IOS AC_ARG_WITH(wii, AS_HELP_STRING([--with-wii], [build for Wii])) AS_IF([test x"$with_wii" = x"yes"], [ AS_IF([test x"$DEVKITPRO" = x""], [ |
︙ | ︙ | |||
212 213 214 215 216 217 218 219 220 221 222 223 224 225 | enable_files="no" # TODO enable_shared="no" # TODO enable_threads="no" # TODO enable_sockets="no" # TODO AC_DEFINE(OF_WII_U, 1, [Whether we are compiling for Wii U]) AC_SUBST(MAP_LDFLAGS, ['-Wl,-Map,$@.map']) ]) AC_ARG_WITH(nds, AS_HELP_STRING([--with-nds], [build for Nintendo DS])) AS_IF([test x"$with_nds" = x"yes"], [ AS_IF([test x"$DEVKITPRO" = x""], [ AC_MSG_ERROR([DEVKITPRO is not set! Please set DEVKITPRO.]) | > > > > > > | 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | enable_files="no" # TODO enable_shared="no" # TODO enable_threads="no" # TODO enable_sockets="no" # TODO AC_DEFINE(OF_WII_U, 1, [Whether we are compiling for Wii U]) AC_SUBST(MAP_LDFLAGS, ['-Wl,-Map,$@.map']) # Repetition of libraries is required for Wii U, as otherwise it cannot # find main. Just moving -lobjfwtest later doesn't work either, as then # the linker cannot find ObjFW symbols. So the only solution is to list # everything twice, but hide it behind a variable because listing it # twice causes a warning on macOS. AC_SUBST(WII_U_TESTS_LIBS, '-lobjfwtest ${TESTS_LIBS} ${LIBS}') ]) AC_ARG_WITH(nds, AS_HELP_STRING([--with-nds], [build for Nintendo DS])) AS_IF([test x"$with_nds" = x"yes"], [ AS_IF([test x"$DEVKITPRO" = x""], [ AC_MSG_ERROR([DEVKITPRO is not set! Please set DEVKITPRO.]) |
︙ | ︙ | |||
344 345 346 347 348 349 350 351 352 353 354 355 356 357 | AX_CHECK_COMPILER_FLAGS(-pipe, [OBJCFLAGS="$OBJCFLAGS -pipe"]) AX_CHECK_COMPILER_FLAGS(-fno-common, [OBJCFLAGS="$OBJCFLAGS -fno-common"]) AX_CHECK_COMPILER_FLAGS(-Xclang -fno-constant-cfstrings, [ flag="-Xclang -fno-constant-cfstrings" OBJCFLAGS="$OBJCFLAGS $flag" OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flag" ]) AX_CHECK_COMPILER_FLAGS([-Wsign-compare -Werror], [OBJCFLAGS="$OBJCFLAGS -Wsign-compare"]) AS_IF([test x"$with_nds" != x"yes"], [ AX_CHECK_COMPILER_FLAGS([-Wshadow -Werror], [OBJCFLAGS="$OBJCFLAGS -Wshadow"]) ]) AX_CHECK_COMPILER_FLAGS([-Wshorten-64-to-32 -Werror], | > | 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | AX_CHECK_COMPILER_FLAGS(-pipe, [OBJCFLAGS="$OBJCFLAGS -pipe"]) AX_CHECK_COMPILER_FLAGS(-fno-common, [OBJCFLAGS="$OBJCFLAGS -fno-common"]) AX_CHECK_COMPILER_FLAGS(-Xclang -fno-constant-cfstrings, [ flag="-Xclang -fno-constant-cfstrings" OBJCFLAGS="$OBJCFLAGS $flag" OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flag" ]) AX_CHECK_COMPILER_FLAGS([-Wsign-compare -Werror], [OBJCFLAGS="$OBJCFLAGS -Wsign-compare"]) AS_IF([test x"$with_nds" != x"yes"], [ AX_CHECK_COMPILER_FLAGS([-Wshadow -Werror], [OBJCFLAGS="$OBJCFLAGS -Wshadow"]) ]) AX_CHECK_COMPILER_FLAGS([-Wshorten-64-to-32 -Werror], |
︙ | ︙ | |||
408 409 410 411 412 413 414 | ;; esac 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 | > > | | < < < < < < < < < < | | 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 | ;; esac AC_ARG_ENABLE(shared, AS_HELP_STRING([--disable-shared], [do not build shared library])) AS_IF([test x"$enable_shared" != x"no"], [ BUILDSYS_SHARED_LIB BUILDSYS_PLUGIN AC_SUBST(OBJFW_SHARED_LIB, '${LIB_PREFIX}objfw${LIB_SUFFIX}') AC_SUBST(EXCEPTIONS_LIB_A, "exceptions.lib.a") AC_SUBST(FORWARDING_LIB_A, "forwarding.lib.a") AC_SUBST(LOOKUP_ASM_LIB_A, "lookup-asm.lib.a") BUILDSYS_FRAMEWORK([ AC_SUBST(OBJFW_FRAMEWORK, "ObjFW.framework") build_framework="yes" ]) ], [ AC_DEFINE(OF_NO_SHARED, 1, [Whether no shared library was built]) AC_SUBST(LIBOBJFW_DEP, "../src/libobjfw.a") AC_SUBST(LIBOBJFW_DEP_LVL2, "../../src/libobjfw.a") ]) AS_IF([test x"$build_framework" = x"yes"], [ TESTS_LIBS="-framework ObjFW \${RUNTIME_FRAMEWORK_LIBS} $TESTS_LIBS" TESTS_LIBS="-F../src -F../src/runtime $TESTS_LIBS" ], [ TESTS_LIBS="\${RUNTIME_LIBS} $TESTS_LIBS" TESTS_LIBS="-L../src/runtime $TESTS_LIBS" TESTS_LIBS="-L../src -lobjfw $TESTS_LIBS" ]) AC_ARG_ENABLE(static, AS_HELP_STRING([--enable-static], [build static library])) AS_IF([test x"$enable_shared" = x"no"], [ enable_static="yes" ]) AS_IF([test x"$enable_static" = x"yes"], [ AC_SUBST(OBJFW_STATIC_LIB, "libobjfw.a") AC_SUBST(EXCEPTIONS_A, "exceptions.a") AC_SUBST(FORWARDING_A, "forwarding.a") AC_SUBST(LOOKUP_ASM_A, "lookup-asm.a") |
︙ | ︙ | |||
523 524 525 526 527 528 529 530 531 532 533 534 535 536 | ]) ]) AC_MSG_RESULT($objc_runtime) case "$objc_runtime" in "ObjFW runtime") AC_DEFINE(OF_OBJFW_RUNTIME, 1, [Whether we use the ObjFW runtime]) AC_MSG_CHECKING([whether -fobjc-runtime=objfw is supported]) old_OBJCFLAGS="$OBJCFLAGS" OBJCFLAGS="$OBJCFLAGS -Xclang -fobjc-runtime=objfw" AC_LINK_IFELSE([ AC_LANG_PROGRAM([ | > | 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 | ]) ]) AC_MSG_RESULT($objc_runtime) case "$objc_runtime" in "ObjFW runtime") AC_DEFINE(OF_OBJFW_RUNTIME, 1, [Whether we use the ObjFW runtime]) AC_SUBST(USE_SRCS_TAGGED_POINTERS, '${SRCS_TAGGED_POINTERS}') AC_MSG_CHECKING([whether -fobjc-runtime=objfw is supported]) old_OBJCFLAGS="$OBJCFLAGS" OBJCFLAGS="$OBJCFLAGS -Xclang -fobjc-runtime=objfw" AC_LINK_IFELSE([ AC_LANG_PROGRAM([ |
︙ | ︙ | |||
573 574 575 576 577 578 579 | ]) AC_SUBST(RUNTIME, "runtime") AC_CONFIG_FILES(src/runtime/Info.plist) AS_IF([test x"$enable_shared" != x"no"], [ AC_SUBST(OBJFWRT_SHARED_LIB, | | < < < < < < < | < | < < | < | | < | < < < < < > | < < < | | < | > | > | | | < < < < < < < < < < < < < < < < < < < < < | | | > > | 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 | ]) 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}') ]) AS_IF([test x"$enable_static" = x"yes"], [ AC_SUBST(OBJFWRT_STATIC_LIB, "libobjfwrt.a") ]) AS_IF([test x"$build_framework" = x"yes"], [ AC_SUBST(OBJFWRT_FRAMEWORK, "ObjFWRT.framework") AC_SUBST(RUNTIME_FRAMEWORK_LIBS, "-framework ObjFWRT") ]) AC_SUBST(RUNTIME_LIBS, "-lobjfwrt") AS_IF([test x"$enable_shared" = x"no"], [ AC_SUBST(LIBOBJFWRT_DEP, "../src/runtime/libobjfwrt.a") AC_SUBST(LIBOBJFWRT_DEP_LVL2, "../../src/runtime/libobjfwrt.a") ]) AS_IF([test x"$enable_seluid24" = x"yes"], [ AC_DEFINE(OF_SELUID24, 1, [Whether to use 24 bit selector UIDs]) ]) AC_MSG_CHECKING(for exception type) AC_EGREP_CPP(egrep_cpp_yes, [ #ifdef __SEH__ egrep_cpp_yes #endif ], [ AC_MSG_RESULT(SEH) exception_type="SEH" raise_exception="_Unwind_RaiseException" ], [ AC_EGREP_CPP(egrep_cpp_yes, [ #ifdef __USING_SJLJ_EXCEPTIONS__ egrep_cpp_yes #endif ], [ AC_MSG_RESULT(SjLj) exception_type="SjLj" raise_exception="_Unwind_SjLj_RaiseException" ], [ AC_MSG_RESULT(DWARF) exception_type="DWARF" raise_exception="_Unwind_RaiseException" ]) ]) AC_SEARCH_LIBS($raise_exception, [c++abi gcc_s gcc unwind], [ dnl c++abi requires pthread on OpenBSD AS_IF([test x"$ac_lib" = x"c++abi"], [LIBS="$LIBS -lpthread"]) ], [ AC_MSG_ERROR([$raise_exception missing!]) |
︙ | ︙ | |||
686 687 688 689 690 691 692 693 694 695 696 697 698 699 | AC_CHECK_FUNC(objc_autoreleasePoolPush, [], [ AC_SUBST(RUNTIME_AUTORELEASE_M, "runtime/autorelease.m") ]) AC_CHECK_FUNC(objc_constructInstance, [], [ AC_SUBST(RUNTIME_INSTANCE_M, "runtime/instance.m") ]) OBJCFLAGS="$old_OBJCFLAGS" ;; esac case "$host_os" in mint*) | > > > | 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 | AC_CHECK_FUNC(objc_autoreleasePoolPush, [], [ AC_SUBST(RUNTIME_AUTORELEASE_M, "runtime/autorelease.m") ]) AC_CHECK_FUNC(objc_constructInstance, [], [ AC_SUBST(RUNTIME_INSTANCE_M, "runtime/instance.m") ]) AC_CHECK_FUNCS(objc_setAssociatedObject, [], [ AC_SUBST(RUNTIME_ASSOCIATION_M, "runtime/association.m") ]) OBJCFLAGS="$old_OBJCFLAGS" ;; esac case "$host_os" in mint*) |
︙ | ︙ | |||
764 765 766 767 768 769 770 | @end ], [[ __weak id foo = [Foo alloc]; (void)foo; ]]) ], [ AC_MSG_RESULT(yes) | < | 717 718 719 720 721 722 723 724 725 726 727 728 729 730 | @end ], [[ __weak id foo = [Foo alloc]; (void)foo; ]]) ], [ AC_MSG_RESULT(yes) AC_SUBST(RUNTIME_ARC_TESTS_M, RuntimeARCTests.m) ], [ AC_MSG_RESULT(no) ]) OBJCFLAGS="$old_OBJCFLAGS" AC_C_BIGENDIAN([ |
︙ | ︙ | |||
815 816 817 818 819 820 821 | AC_CHECK_HEADER(inttypes.h, [AC_DEFINE(OF_HAVE_INTTYPES_H, 1, [Whether we have inttypes.h])]) AC_CHECK_HEADER(sys/types.h, [AC_DEFINE(OF_HAVE_SYS_TYPES_H, 1, [Whether we have sys/types.h])]) | < < < | > > | | 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 | AC_CHECK_HEADER(inttypes.h, [AC_DEFINE(OF_HAVE_INTTYPES_H, 1, [Whether we have inttypes.h])]) AC_CHECK_HEADER(sys/types.h, [AC_DEFINE(OF_HAVE_SYS_TYPES_H, 1, [Whether we have sys/types.h])]) AC_CHECK_HEADER(stdnoreturn.h, [AC_DEFINE(OF_HAVE_STDNORETURN_H, 1, [Whether we have stdnoreturn.h])]) AC_CHECK_TYPE(wchar_t) AC_CHECK_HEADER(wchar.h) AC_CHECK_SIZEOF(float) AC_CHECK_SIZEOF(double) AS_IF([test x"$ac_cv_sizeof_float" != x"4" -o x"$ac_cv_sizeof_double" != x"8"], [AC_MSG_ERROR( [Floating point implementation does not conform to IEEE 754!])]) AC_MSG_CHECKING(for floating point endianess) fp_endianess="unknown" AS_IF([test x"$ac_cv_c_bigendian" != x"universal"], [ AC_COMPILE_IFELSE([ AC_LANG_SOURCE([ double endianess = 2.993700760838795055656993580068609688772747263874402942272934826871811872228512759832626847251963763755836687759498519784550143745834860002945223766052808125982053455555265216112722718870586961456110693379343178124592311441022662940307099598578775368547768968914916965731708568179631324904813506101190853720749196062963892799499230635163056742330563321122389331703618066046034494287335316842529021563862331183541255013987734473643350285400060357711238514186776429325214739886098119655678483017894951556639821088508565036657794343031121375178126860889964700274558728491825977274341798997758923017217660272136611938897932105874133412726223468780517578125e-259; ]) ], [ AS_IF([$SED 's/[[^[:print:]]]//g' <conftest.$ac_objext | \ $EGREP BigEnd >/dev/null], [ AC_DEFINE(OF_FLOAT_BIG_ENDIAN, 1, [Whether floats are big endian]) fp_endianess="big endian" ], [ AS_IF([$SED 's/[[^[:print:]]]//g' \ <conftest.$ac_objext | $EGREP dnEgiB >/dev/null], [ fp_endianess="little endian" ]) ]) ]) ], [ fp_endianess="universal" ]) |
︙ | ︙ | |||
875 876 877 878 879 880 881 882 883 884 885 886 887 888 | ], [ AC_DEFINE(HAVE_VFP2, 1, [Whether we have VFP2 or above]) AC_MSG_RESULT(yes) ], [ AC_MSG_RESULT(no) ]) ;; esac AC_CHECK_LIB(m, fmod, LIBS="$LIBS -lm") AC_CHECK_LIB(complex, creal, TESTS_LIBS="$TESTS_LIBS -lcomplex") AC_CHECK_FUNCS(strtof truncf) | > > > > > > > > > > > > > > > > | 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 | ], [ AC_DEFINE(HAVE_VFP2, 1, [Whether we have VFP2 or above]) AC_MSG_RESULT(yes) ], [ AC_MSG_RESULT(no) ]) ;; aarch64* | arm64*) AC_MSG_CHECKING(for bti) AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([], [ __asm__ __volatile__ ("bti c"); ]) ], [ AC_DEFINE(HAVE_BTI, 1, [Whether we have bti]) AC_MSG_RESULT(yes) ], [ AC_MSG_RESULT(no) ]) ;; i?86 | x86_64) AC_CHECK_HEADERS(cet.h) ;; esac AC_CHECK_LIB(m, fmod, LIBS="$LIBS -lm") AC_CHECK_LIB(complex, creal, TESTS_LIBS="$TESTS_LIBS -lcomplex") AC_CHECK_FUNCS(strtof truncf) |
︙ | ︙ | |||
1030 1031 1032 1033 1034 1035 1036 | AC_CHECK_FUNC(sched_yield, [ AC_DEFINE(OF_HAVE_SCHED_YIELD, 1, [Whether we have sched_yield()]) ]) AC_CHECK_FUNCS(pthread_attr_getschedpolicy) | > > > > > > > > | > > > > > > > > > > | 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 | AC_CHECK_FUNC(sched_yield, [ AC_DEFINE(OF_HAVE_SCHED_YIELD, 1, [Whether we have sched_yield()]) ]) AC_CHECK_FUNCS(pthread_attr_getschedpolicy) old_OBJCFLAGS="$OBJCFLAGS" OBJCFLAGS="$OBJCFLAGS -Werror" AC_MSG_CHECKING(for pthread_attr_setinheritsched) AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([ #include <pthread.h> ], [ pthread_attr_setinheritsched( (pthread_attr_t *)-1, 0); ]) ], [ AC_MSG_RESULT(yes) AC_DEFINE(HAVE_PTHREAD_ATTR_SETINHERITSCHED, 1, [Whether we have pthread_attr_setinheritsched]) ], [ AC_MSG_RESULT(no) ]) OBJCFLAGS="$old_OBJCFLAGS" AC_CHECK_HEADERS(pthread_np.h, [], [], [#include <pthread.h>]) AC_CHECK_FUNCS(pthread_set_name_np pthread_setname_np, break) ;; esac AC_DEFINE(OF_HAVE_THREADS, 1, [Whether we have threads]) |
︙ | ︙ | |||
1267 1268 1269 1270 1271 1272 1273 | AC_CHECK_FUNC(symlink, [ AC_DEFINE(OF_HAVE_SYMLINK, 1, [Whether we have symlink()]) ]) AC_CHECK_FUNCS([lstat]) AC_CHECK_MEMBERS([struct stat.st_birthtime], [], [], [ #include <sys/stat.h> ]) | < < < < < < < < < < < < < < < < < < < < | | 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 | AC_CHECK_FUNC(symlink, [ AC_DEFINE(OF_HAVE_SYMLINK, 1, [Whether we have symlink()]) ]) AC_CHECK_FUNCS([lstat]) AC_CHECK_MEMBERS([struct stat.st_birthtime], [], [], [ #include <sys/stat.h> ]) ]) AC_CHECK_HEADERS(dirent.h) AC_CHECK_FUNCS([sysconf gmtime_r localtime_r]) case "$host_os" in amigaos* | morphos*) dnl We don't want fcntl() or nanosleep() on AmigaOS / MorphOS, despite dnl a symbol existing. The reason is that we cannot use fcntl() for dnl sockets and that nanosleep() is yet another function that uses dnl errno, so would need to be passed from the linklib. ;; *) AC_CHECK_HEADERS(fcntl.h) AC_CHECK_FUNCS([fcntl nanosleep]) ;; esac AC_CHECK_HEADERS(xlocale.h) AC_CHECK_FUNCS([strtod_l strtof_l asprintf_l uselocale]) AS_IF([test x"$gnu_source" != x"yes" -a \( \ x"$ac_cv_func_strtod_l" = x"yes" -o x"$ac_cv_func_strtof_l" = x"yes" -o \ x"$ac_cv_func_asprintf_l" = x"yes" \)], [ AC_MSG_CHECKING(whether *_l functions need _GNU_SOURCE) AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([ #include <stdlib.h> |
︙ | ︙ | |||
1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 | ;; esac AC_CHECK_HEADER(sys/socket.h, [ AC_DEFINE(OF_HAVE_SYS_SOCKET_H, 1, [Whether we have sys/socket.h]) ]) 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_HEADER(netinet/sctp.h, [ AC_DEFINE(OF_HAVE_SCTP, 1, [Whether we have SCTP]) AC_DEFINE(OF_HAVE_NETINET_SCTP_H, 1, [Whether we have netinet/sctp.h]) AC_SUBST(USE_SRCS_SCTP, '${SRCS_SCTP}') ]) | > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > | > > > > > > > > > > > > > > > > > > | 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 | ;; esac AC_CHECK_HEADER(sys/socket.h, [ AC_DEFINE(OF_HAVE_SYS_SOCKET_H, 1, [Whether we have sys/socket.h]) ]) AC_CHECK_MEMBERS([struct sockaddr.sa_len], [], [], [ #ifdef OF_HAVE_SYS_TYPES_H # include <sys/types.h> #endif #ifdef OF_HAVE_SYS_SOCKET_H # include <sys/socket.h> #endif #ifdef _WIN32 # include <winsock2.h> #endif ]) AC_CHECK_TYPE([struct sockaddr_storage], [ AC_DEFINE(OF_HAVE_SOCKADDR_STORAGE, 1, [Whether we have struct sockaddr_storage]) ], [], [ #ifdef OF_HAVE_SYS_TYPES_H # include <sys/types.h> #endif #ifdef OF_HAVE_SYS_SOCKET_H # include <sys/socket.h> #endif #ifdef _WIN32 # include <winsock2.h> #endif ]) AC_CHECK_HEADER(netinet/in.h, [ AC_DEFINE(OF_HAVE_NETINET_IN_H, 1, [Whether we have netinet/in.h]) ]) AC_CHECK_HEADER(netinet/tcp.h, [ AC_DEFINE(OF_HAVE_NETINET_TCP_H, 1, [Whether we have netinet/tcp.h]) ]) AC_CHECK_HEADER(netinet/sctp.h, [ AC_DEFINE(OF_HAVE_SCTP, 1, [Whether we have SCTP]) AC_DEFINE(OF_HAVE_NETINET_SCTP_H, 1, [Whether we have netinet/sctp.h]) AC_SUBST(USE_SRCS_SCTP, '${SRCS_SCTP}') ]) AC_CHECK_HEADERS([arpa/inet.h netdb.h sys/sockio.h]) AC_CHECK_HEADERS([net/if.h], [], [], [ #ifdef OF_HAVE_SYS_SOCKET_H # include <sys/socket.h> #endif ]) AC_CHECK_HEADERS([net/if_arp.h net/if_dl.h net/if_types.h]) AC_CHECK_FUNCS([if_indextoname if_nametoindex if_nameindex]) AC_CHECK_TYPES([struct sockaddr_dl], [], [], [ #ifdef HAVE_SYS_TYPES_H # include <sys/types.h> #endif #ifdef HAVE_NET_IF_DL_H # include <net/if_dl.h> #endif ]) AC_CHECK_TYPES([struct lifconf], [], [], [ #ifdef HAVE_NET_IF_H # include <net/if.h> #endif ]) AC_CHECK_MEMBERS([struct ifreq.ifr_hwaddr], [], [], [ #ifdef HAVE_NET_IF_H # include <net/if.h> #endif ]) AC_CHECK_HEADER(sys/un.h, [ AC_DEFINE(OF_HAVE_SYS_UN_H, 1, [Whether we have sys/un.h]) ]) AC_CHECK_MEMBER([struct sockaddr_in6.sin6_addr], [ AC_EGREP_CPP(egrep_cpp_yes, [ #ifdef _WIN32 typedef int BOOL; |
︙ | ︙ | |||
1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 | # include <winsock2.h> #endif ]) AC_CHECK_MEMBER(struct sockaddr_un.sun_path, [ AC_DEFINE(OF_HAVE_UNIX_SOCKETS, 1, [Whether we have UNIX sockets]) AC_SUBST(USE_SRCS_UNIX_SOCKETS, '${SRCS_UNIX_SOCKETS}') ], [], [ #ifdef OF_HAVE_SYS_TYPES_H # include <sys/types.h> #endif #ifdef OF_HAVE_SYS_UN_H # include <sys/un.h> #endif | > > > > > > > > > > > > > > > | 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 | # include <winsock2.h> #endif ]) AC_CHECK_MEMBER(struct sockaddr_un.sun_path, [ AC_DEFINE(OF_HAVE_UNIX_SOCKETS, 1, [Whether we have UNIX sockets]) AC_SUBST(USE_SRCS_UNIX_SOCKETS, '${SRCS_UNIX_SOCKETS}') AC_CHECK_MEMBERS(struct sockaddr_un.sun_len, [], [], [ #ifdef OF_HAVE_SYS_TYPES_H # include <sys/types.h> #endif #ifdef OF_HAVE_SYS_UN_H # include <sys/un.h> #endif #ifdef _WIN32 # include <winsock2.h> #endif #ifdef HAVE_AFUNIX_H # include <afunix.h> #endif ]) ], [], [ #ifdef OF_HAVE_SYS_TYPES_H # include <sys/types.h> #endif #ifdef OF_HAVE_SYS_UN_H # include <sys/un.h> #endif |
︙ | ︙ | |||
1503 1504 1505 1506 1507 1508 1509 | ]) 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, [], [ | | > > > > > > > > > > > > > > > > > > > | > | 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 | ]) 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.sipx_addr.x_port, [], [], [ #ifdef HAVE_SYS_TYPES_H # include <sys/types.h> #endif #ifdef OF_HAVE_NETIPX_IPX_H # include <netipx/ipx.h> #endif ]) ], [ #ifdef _WIN32 typedef int BOOL; #endif #ifdef HAVE_SYS_TYPES_H # include <sys/types.h> #endif #ifdef OF_HAVE_NETIPX_IPX_H # include <netipx/ipx.h> #endif #ifdef _WIN32 # ifdef __MINGW32__ # include <_mingw.h> # ifdef __MINGW64_VERSION_MAJOR # include <winsock2.h> # endif # endif # include <windows.h> # include <wsipx.h> #endif ]) ], [ #ifdef _WIN32 typedef int BOOL; #endif #ifdef HAVE_SYS_TYPES_H # include <sys/types.h> #endif #ifdef OF_HAVE_NETIPX_IPX_H # include <netipx/ipx.h> #endif #ifdef _WIN32 # ifdef __MINGW32__ # include <_mingw.h> # ifdef __MINGW64_VERSION_MAJOR # include <winsock2.h> # endif # endif # include <windows.h> # include <wsipx.h> #endif ]) AS_IF([test x"$ac_cv_member_struct_sockaddr_ipx_sipx_network" = x"yes" \ -o x"$ac_cv_member_struct_sockaddr_ipx_sa_netnum" = x"yes" -o \ x"$ac_cv_member_struct_sockaddr_ipx_sipx_addr_x_port" = x"yes"], [ AC_EGREP_CPP(egrep_cpp_yes, [ #ifdef _WIN32 typedef int BOOL; #endif #ifdef OF_HAVE_SYS_SOCKET_H # include <sys/socket.h> |
︙ | ︙ | |||
1713 1714 1715 1716 1717 1718 1719 | ]) ;; esac AC_ARG_WITH(tls, AS_HELP_STRING([--with-tls], [ enable TLS support using the specified library | | > | < < < < < < < < < < < < < < < < < < < < | < < < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 | ]) ;; esac AC_ARG_WITH(tls, AS_HELP_STRING([--with-tls], [ enable TLS support using the specified library (yes, openssl, gnutls, securetransport, mbedtls 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"], [ AC_CHECK_HEADERS(Security/SecureTransport.h, [ old_LIBS="$LIBS" LIBS="-framework Security -framework Foundation $LIBS" AC_CHECK_FUNC(SSLHandshake, [ tls_support="Secure Transport" TLS_LIBS="-framework Foundation $TLS_LIBS" TLS_LIBS="-framework Security $TLS_LIBS" AC_SUBST(OF_SECURE_TRANSPORT_TLS_STREAM_M, "OFSecureTransportTLSStream.m") AC_CHECK_FUNCS(SSLCreateContext) ], []) LIBS="$old_LIBS" ]) ]) AS_IF([test x"$with_tls" = x"openssl" \ -o \( x"$with_tls" = x"yes" -a x"$tls_support" = x"no" \)], [ case "$host_os" in morphos*) ssl="ssl_shared" crypto="crypto_shared" ;; *) ssl="ssl" crypto="crypto" ;; esac AC_CHECK_LIB($ssl, SSL_set1_host, [ AC_CHECK_HEADER(openssl/ssl.h, [ tls_support="OpenSSL" TLS_LIBS="-l$ssl -l$crypto $TLS_LIBS" AC_SUBST(OF_OPENSSL_TLS_STREAM_M, "OFOpenSSLTLSStream.m") old_LIBS="$LIBS" LIBS="$TLS_LIBS $LIBS" AC_CHECK_FUNCS(SSL_has_pending) LIBS="$old_LIBS" ]) ], [], [-l$crypto]) ]) AS_IF([test x"$with_tls" = x"gnutls" \ -o \( x"$with_tls" = x"yes" -a x"$tls_support" = x"no" \)], [ PKG_CHECK_MODULES(gnutls, [gnutls >= 3.5.0], [ tls_support="GnuTLS" TLS_CPPFLAGS="$gnutls_CFLAGS $TLS_CPPFLAGS" TLS_LIBS="$gnutls_LIBS $TLS_LIBS" AC_SUBST(OF_GNUTLS_TLS_STREAM_M, "OFGnuTLSTLSStream.m") ], [ dnl Disable default action-if-not-found, which exits dnl configure with an error. : ]) ]) AS_IF([test x"$with_tls" = x"mbedtls"], [ AC_CHECK_LIB(mbedtls, mbedtls_net_init, [ AC_CHECK_HEADER(mbedtls/ssl.h, [ tls_support="Mbed TLS" TLS_LIBS="-lmbedx509 -lmbedcrypto $TLS_LIBS" TLS_LIBS="-lmbedtls $TLS_LIBS" AC_SUBST(OF_MBEDTLS_TLS_STREAM_M, "OFMbedTLSTLSStream.m") ]) ], [], [-lmbedx509 -lmbedcrypto]) ]) AS_IF([test x"$tls_support" != x"no"], [ AC_SUBST(TLS, "tls") AC_SUBST(TLS_CPPFLAGS) AC_SUBST(TLS_LIBS) AC_DEFINE(HAVE_TLS_SUPPORT, 1, [Whether we have an implementation for TLS]) AC_CONFIG_FILES(src/tls/Info.plist) OFARC_LIBS="-lobjfwtls $TLS_LIBS $OFARC_LIBS" OFHASH_LIBS="-lobjfwtls $TLS_LIBS $OFHASH_LIBS" 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}') ]) AS_IF([test x"$enable_static" = x"yes" \ -o x"$enable_shared" = x"no"], [ AC_SUBST(OBJFWTLS_STATIC_LIB, "libobjfwtls.a") ]) AS_IF([test x"$build_framework" = x"yes"], [ AC_SUBST(OBJFWTLS_FRAMEWORK, "ObjFWTLS.framework") ]) ]) AS_IF([test x"$with_tls" != x"no" -a x"$tls_support" = x"no"], [ AC_MSG_ERROR(m4_normalize([ No TLS implementation was found. Please install OpenSSL, GnuTLS, Mbed TLS or use --without-tls. ])) ]) AS_IF([test x"$enable_threads" != x"no"], [ AC_SUBST(OF_HTTP_CLIENT_TESTS_M, "OFHTTPClientTests.m") ]) |
︙ | ︙ | |||
1861 1862 1863 1864 1865 1866 1867 | #if (!defined(TARGET_OS_IPHONE) || !TARGET_OS_IPHONE) && \ (!defined(TARGET_OS_SIMULATOR) || !TARGET_OS_SIMULATOR) egrep_cpp_yes #endif ], [ AC_MSG_RESULT(yes) | < < < < < > > | | < | | > < < > > | | | | 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 | #if (!defined(TARGET_OS_IPHONE) || !TARGET_OS_IPHONE) && \ (!defined(TARGET_OS_SIMULATOR) || !TARGET_OS_SIMULATOR) egrep_cpp_yes #endif ], [ AC_MSG_RESULT(yes) ], [ AC_MSG_RESULT(no) have_subprocesses="no" ]) ;; mingw*) have_subprocesses="yes" ;; msdosdjgpp*) have_subprocesses="no" ;; esac AS_IF([test x"$have_subprocesses" = x""], [ AC_HEADER_SYS_WAIT AC_CHECK_FUNCS(kill) AC_CHECK_FUNCS(posix_spawnp, [ AS_IF([test x"$ac_cv_func_kill" = x"yes"], [ 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" \ -a x"$ac_cv_func_kill" = x"yes" \ -a x"$ac_cv_func__exit" = x"yes"], [ have_subprocesses="yes" ]) ], [ break ]) ]) ]) AS_IF([test x"$have_subprocesses" = x"yes"], [ AC_SUBST(USE_SRCS_SUBPROCESSES, '${SRCS_SUBPROCESSES}') AC_SUBST(SUBPROCESS, "subprocess") 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(ioctl isatty) AC_CHECK_FUNC(pledge, [ AC_DEFINE(OF_HAVE_PLEDGE, 1, [Whether we have pledge()]) ]) AS_IF([test x"$objc_runtime" = x"Apple runtime"], [ AC_CHECK_HEADER(Foundation/NSObject.h, [ AC_SUBST(BRIDGE, "bridge") AC_CONFIG_FILES(src/bridge/Info.plist) AS_IF([test x"$enable_shared" != x"no"], [ AC_SUBST(OBJFWBRIDGE_SHARED_LIB, '${LIB_PREFIX}objfwbridge${LIB_SUFFIX}') ]) AS_IF([test x"$enable_static" = x"yes" \ -o x"$enable_shared" = x"no"], [ AC_SUBST(OBJFWBRIDGE_STATIC_LIB, "libobjfwbridge.a") ]) AS_IF([test x"$build_framework" = x"yes"], [ AC_SUBST(OBJFWBRIDGE_FRAMEWORK, |
︙ | ︙ | |||
1955 1956 1957 1958 1959 1960 1961 | AC_MSG_RESULT(yes) ], [ AC_MSG_RESULT(no) OBJCFLAGS="$old_OBJCFLAGS" ]) AS_IF([test x"$GOBJC" = x"yes"], [ | | > > > > > > > > | 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 | AC_MSG_RESULT(yes) ], [ AC_MSG_RESULT(no) OBJCFLAGS="$old_OBJCFLAGS" ]) AS_IF([test x"$GOBJC" = x"yes"], [ OBJCFLAGS="$OBJCFLAGS -Wwrite-strings -Wpointer-arith" AC_ARG_ENABLE(werror, AS_HELP_STRING([--disable-werror], [do not build with -Werror])) AS_IF([test x"$enable_werror" != x"no"], [ OBJCFLAGS="$OBJCFLAGS -Werror" ]) old_OBJCFLAGS="$OBJCFLAGS" OBJCFLAGS="$OBJCFLAGS -Werror" AC_MSG_CHECKING(whether we need -Wno-strict-aliasing due to GCC bugs) AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([ #ifdef __has_attribute # if __has_attribute(objc_root_class) __attribute__((__objc_root_class__)) # endif |
︙ | ︙ | |||
1980 1981 1982 1983 1984 1985 1986 1987 1988 | } object; ], [ Foo *test = (Foo *)&object; (void)test; /* Get rid of unused variable warning */ ]) ], [ AC_MSG_RESULT(no) ], [ AC_MSG_RESULT(yes) | > | > > | 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 | } object; ], [ Foo *test = (Foo *)&object; (void)test; /* Get rid of unused variable warning */ ]) ], [ AC_MSG_RESULT(no) OBJCFLAGS="$old_OBJCFLAGS" ], [ AC_MSG_RESULT(yes) OBJCFLAGS="$old_OBJCFLAGS -Wno-strict-aliasing" ]) old_OBJCFLAGS="$OBJCFLAGS" OBJCFLAGS="$OBJCFLAGS -Werror" AC_MSG_CHECKING( whether we need -Wno-unused-property-ivar due to Clang bugs) AC_COMPILE_IFELSE([ AC_LANG_SOURCE([ #ifdef __has_attribute # if __has_attribute(objc_root_class) __attribute__((__objc_root_class__)) |
︙ | ︙ | |||
2016 2017 2018 2019 2020 2021 2022 2023 2024 | { return (Foo *)0; } @end ]) ], [ AC_MSG_RESULT(no) ], [ AC_MSG_RESULT(yes) | > | | | 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 | { return (Foo *)0; } @end ]) ], [ AC_MSG_RESULT(no) OBJCFLAGS="$old_OBJCFLAGS" ], [ AC_MSG_RESULT(yes) OBJCFLAGS="$old_OBJCFLAGS -Wno-unused-property-ivar" ]) old_OBJCFLAGS="$OBJCFLAGS" OBJCFLAGS="$OBJCFLAGS -Wcast-align -Werror" AC_MSG_CHECKING(whether -Wcast-align is buggy) AC_COMPILE_IFELSE([ AC_LANG_SOURCE([ #ifdef __has_attribute # if __has_attribute(objc_root_class) __attribute__((__objc_root_class__)) # endif |
︙ | ︙ | |||
2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 | struct objc_class *c = _isa; (void)c; } @end ]) ], [ AC_MSG_RESULT(no) ], [ AC_MSG_RESULT(yes) OBJCFLAGS="$old_OBJCFLAGS" ]) old_OBJCFLAGS="$OBJCFLAGS" | > | | 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 | struct objc_class *c = _isa; (void)c; } @end ]) ], [ AC_MSG_RESULT(no) OBJCFLAGS="$old_OBJCFLAGS -Wcast-align" ], [ AC_MSG_RESULT(yes) OBJCFLAGS="$old_OBJCFLAGS" ]) old_OBJCFLAGS="$OBJCFLAGS" OBJCFLAGS="$OBJCFLAGS -Wunreachable-code -Werror" AC_MSG_CHECKING(whether -Wunreachable-code can be used) AC_COMPILE_IFELSE([ AC_LANG_SOURCE([[ #include <stdlib.h> struct objc_selector; typedef const struct objc_selector *SEL; |
︙ | ︙ | |||
2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 | { OF_DEALLOC_UNSUPPORTED } @end ]]) ], [ AC_MSG_RESULT(yes) ], [ AC_MSG_RESULT(no) OBJCFLAGS="$old_OBJCFLAGS" ]) old_OBJCFLAGS="$OBJCFLAGS" | > | | 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 | { OF_DEALLOC_UNSUPPORTED } @end ]]) ], [ AC_MSG_RESULT(yes) OBJCFLAGS="$old_OBJCFLAGS -Wunreachable-code" ], [ AC_MSG_RESULT(no) OBJCFLAGS="$old_OBJCFLAGS" ]) old_OBJCFLAGS="$OBJCFLAGS" OBJCFLAGS="$OBJCFLAGS -Wdocumentation -Werror" AC_MSG_CHECKING(whether -Wdocumentation works correctly) AC_COMPILE_IFELSE([ AC_LANG_SOURCE([ /** * @class Test conftest.m conftest.m */ #ifdef __has_attribute |
︙ | ︙ | |||
2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 | /** * @struct Foo conftest.m conftest.m */ typedef struct {} Foo; ]) ], [ AC_MSG_RESULT(yes) ], [ AC_MSG_RESULT(no) OBJCFLAGS="$old_OBJCFLAGS" ]) AS_IF([test x"$check_pedantic" = x"yes"], [ old_OBJCFLAGS="$OBJCFLAGS" | > | | 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 | /** * @struct Foo conftest.m conftest.m */ typedef struct {} Foo; ]) ], [ AC_MSG_RESULT(yes) OBJCFLAGS="$old_OBJCFLAGS -Wdocumentation" ], [ AC_MSG_RESULT(no) OBJCFLAGS="$old_OBJCFLAGS" ]) AS_IF([test x"$check_pedantic" = x"yes"], [ old_OBJCFLAGS="$OBJCFLAGS" OBJCFLAGS="$OBJCFLAGS -pedantic -Werror" AC_MSG_CHECKING(whether -pedantic is buggy) AC_COMPILE_IFELSE([ AC_LANG_SOURCE([ #include <stdlib.h> #include <assert.h> |
︙ | ︙ | |||
2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 | */ assert(1); } @end ]) ], [ AC_MSG_RESULT(no) ], [ AC_MSG_RESULT(yes) OBJCFLAGS="$old_OBJCFLAGS" ]) ]) AS_IF([test x"$ac_cv_header_complex_h" = x"yes"], [ AC_MSG_CHECKING(whether we need -Wno-gnu-imaginary-constant) AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([ #include <complex.h> ], [ complex float f = 0.5 + 0.5 * I; (void)f; ]) ], [ AC_MSG_RESULT(no) ], [ AC_MSG_RESULT(yes) | > > > > > > > > > > > > > > > > > > > > > | < | < < < < < < < < < < < < < | 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 | */ assert(1); } @end ]) ], [ AC_MSG_RESULT(no) OBJCFLAGS="$old_OBJCFLAGS -pedantic" ], [ AC_MSG_RESULT(yes) OBJCFLAGS="$old_OBJCFLAGS" ]) ]) old_OBJCFLAGS="$OBJCFLAGS" OBJCFLAGS="$OBJCFLAGS -Werror" AC_MSG_CHECKING(whether we need -Wno-strict-prototypes) AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([ #include <signal.h> ], [ signal(SIGINT, SIG_DFL); ]) ], [ AC_MSG_RESULT(no) OBJCFLAGS="$old_OBJCFLAGS" ], [ AC_MSG_RESULT(yes) OBJCFLAGS="$old_OBJCFLAGS -Wno-strict-prototypes" ]) AS_IF([test x"$ac_cv_header_complex_h" = x"yes"], [ old_OBJCFLAGS="$OBJCFLAGS" OBJCFLAGS="$OBJCFLAGS -Werror" AC_MSG_CHECKING(whether we need -Wno-gnu-imaginary-constant) AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([ #include <complex.h> ], [ complex float f = 0.5 + 0.5 * I; (void)f; ]) ], [ AC_MSG_RESULT(no) OBJCFLAGS="$old_OBJCFLAGS" ], [ AC_MSG_RESULT(yes) OBJCFLAGS="$old_OBJCFLAGS -Wno-gnu-imaginary-constant" ]) ]) ]) AS_IF([test x"$cross_compiling" = x"yes"], [ AC_SUBST(BIN_PREFIX, "${host_alias}-") case "$host" in i?86-*-mingw*) AC_CHECK_PROG(WINE, wine, wine) ;; x86_64-*-mingw*) AC_CHECK_PROG(WINE, wine64, wine64) ;; esac AS_IF([test x"$WINE" != x""], [AC_SUBST(WRAPPER, "$WINE")]) AS_IF([test x"$with_wii" = x"yes"], [ dnl Keep this lowercase, as WIILOAD is a variable used by dnl wiiload and thus likely already set by the user to something dnl that is not the path of the wiiload binary. AC_CHECK_PROG(wiiload, wiiload, wiiload) AS_IF([test x"$wiiload" != x""], [ AC_SUBST(WRAPPER, "$wiiload") ]) ]) ]) dnl We don't call AC_PROG_CPP, but only AC_PROG_OBJCPP and set CPP to OBJCPP dnl and add OBJCPPFLAGS to CPPFLAGS, thus we need to AC_SUBST these ourself. AC_SUBST(CPP) AC_SUBST(CPPFLAGS) dnl We use the ObjC compiler as our assembler AC_SUBST(AS, $OBJC) AC_SUBST(ASFLAGS) |
︙ | ︙ |
Modified extra.mk.in from [67feba0f37] to [c6e7ecc5a6].
1 2 3 | OBJFW_SHARED_LIB = @OBJFW_SHARED_LIB@ OBJFW_STATIC_LIB = @OBJFW_STATIC_LIB@ OBJFW_FRAMEWORK = @OBJFW_FRAMEWORK@ | | | > | | | > > > > > > < < < > > > < > < < | > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | OBJFW_SHARED_LIB = @OBJFW_SHARED_LIB@ OBJFW_STATIC_LIB = @OBJFW_STATIC_LIB@ OBJFW_FRAMEWORK = @OBJFW_FRAMEWORK@ OBJFW_LIB_MAJOR = 1 OBJFW_LIB_MINOR = 1 OBJFW_LIB_PATCH = 0 OBJFW_LIB_MAJOR_MINOR = ${OBJFW_LIB_MAJOR}.${OBJFW_LIB_MINOR} OBJFWRT_SHARED_LIB = @OBJFWRT_SHARED_LIB@ OBJFWRT_STATIC_LIB = @OBJFWRT_STATIC_LIB@ OBJFWRT_FRAMEWORK = @OBJFWRT_FRAMEWORK@ OBJFWRT_LIB_MAJOR = 1 OBJFWRT_LIB_MINOR = 1 OBJFWRT_LIB_PATCH = 0 OBJFWRT_LIB_MAJOR_MINOR = ${OBJFWRT_LIB_MAJOR}.${OBJFWRT_LIB_MINOR} OBJFWBRIDGE_SHARED_LIB = @OBJFWBRIDGE_SHARED_LIB@ OBJFWBRIDGE_STATIC_LIB = @OBJFWBRIDGE_STATIC_LIB@ OBJFWBRIDGE_FRAMEWORK = @OBJFWBRIDGE_FRAMEWORK@ OBJFWBRIDGE_LIB_MAJOR = 1 OBJFWBRIDGE_LIB_MINOR = 0 OBJFWBRIDGE_LIB_PATCH = 0 OBJFWTLS_SHARED_LIB = @OBJFWTLS_SHARED_LIB@ OBJFWTLS_STATIC_LIB = @OBJFWTLS_STATIC_LIB@ OBJFWTLS_FRAMEWORK = @OBJFWTLS_FRAMEWORK@ OBJFWTLS_LIB_MAJOR = 1 OBJFWTLS_LIB_MINOR = 0 OBJFWTLS_LIB_PATCH = 2 BIN_PREFIX = @BIN_PREFIX@ BRIDGE = @BRIDGE@ CVINCLUDE_INLINE_H = @CVINCLUDE_INLINE_H@ ENCODINGS_A = @ENCODINGS_A@ ENCODINGS_LIB_A = @ENCODINGS_LIB_A@ ENCODINGS_SRCS = @ENCODINGS_SRCS@ EXCEPTIONS_A = @EXCEPTIONS_A@ EXCEPTIONS_LIB_A = @EXCEPTIONS_LIB_A@ FORWARDING_A = @FORWARDING_A@ FORWARDING_LIB_A = @FORWARDING_LIB_A@ LIBBASES_M = @LIBBASES_M@ LIBOBJFWRT_DEP = @LIBOBJFWRT_DEP@ LIBOBJFWRT_DEP_LVL2 = @LIBOBJFWRT_DEP_LVL2@ LIBOBJFW_DEP = @LIBOBJFW_DEP@ LIBOBJFW_DEP_LVL2 = @LIBOBJFW_DEP_LVL2@ LOOKUP_ASM_A = @LOOKUP_ASM_A@ LOOKUP_ASM_LIB_A = @LOOKUP_ASM_LIB_A@ MAP_LDFLAGS = @MAP_LDFLAGS@ OBJC_SYNC = @OBJC_SYNC@ OBJFW_NEW = @OBJFW_NEW@ OFARC = @OFARC@ OFARC_LIBS = @OFARC_LIBS@ OFDNS = @OFDNS@ OFHASH = @OFHASH@ OFHASH_LIBS = @OFHTTP_LIBS@ OFHTTP = @OFHTTP@ OFHTTP_LIBS = @OFHTTP_LIBS@ OF_BLOCK_TESTS_M = @OF_BLOCK_TESTS_M@ OF_EPOLL_KERNEL_EVENT_OBSERVER_M = @OF_EPOLL_KERNEL_EVENT_OBSERVER_M@ OF_GNUTLS_TLS_STREAM_M = @OF_GNUTLS_TLS_STREAM_M@ OF_HTTP_CLIENT_TESTS_M = @OF_HTTP_CLIENT_TESTS_M@ OF_KQUEUE_KERNEL_EVENT_OBSERVER_M = @OF_KQUEUE_KERNEL_EVENT_OBSERVER_M@ OF_MBEDTLS_TLS_STREAM_M = @OF_MBEDTLS_TLS_STREAM_M@ OF_OPENSSL_TLS_STREAM_M = @OF_OPENSSL_TLS_STREAM_M@ OF_POLL_KERNEL_EVENT_OBSERVER_M = @OF_POLL_KERNEL_EVENT_OBSERVER_M@ OF_SCTP_SOCKET_M = @OF_SCTP_SOCKET_M@ OF_SECURE_TRANSPORT_TLS_STREAM_M = @OF_SECURE_TRANSPORT_TLS_STREAM_M@ OF_SELECT_KERNEL_EVENT_OBSERVER_M = @OF_SELECT_KERNEL_EVENT_OBSERVER_M@ REEXPORT_RUNTIME = @REEXPORT_RUNTIME@ REEXPORT_RUNTIME_FRAMEWORK = @REEXPORT_RUNTIME_FRAMEWORK@ RUNTIME = @RUNTIME@ RUNTIME_ARC_TESTS_M = @RUNTIME_ARC_TESTS_M@ RUNTIME_ASSOCIATION_M = @RUNTIME_ASSOCIATION_M@ RUNTIME_AUTORELEASE_M = @RUNTIME_AUTORELEASE_M@ RUNTIME_FRAMEWORK_LIBS = @RUNTIME_FRAMEWORK_LIBS@ RUNTIME_INSTANCE_M = @RUNTIME_INSTANCE_M@ RUNTIME_LIBS = @RUNTIME_LIBS@ SUBPROCESS = @SUBPROCESS@ TESTPLUGIN = @TESTPLUGIN@ TESTPLUGIN_LIBS = @TESTPLUGIN_LIBS@ TESTS_LIBS = @TESTS_LIBS@ TESTS_STATIC_LIB = @TESTS_STATIC_LIB@ TLS = @TLS@ TLS_CPPFLAGS = @TLS_CPPFLAGS@ TLS_LIBS = @TLS_LIBS@ UNICODE_M = @UNICODE_M@ USE_INCLUDES_ATOMIC = @USE_INCLUDES_ATOMIC@ USE_SRCS_APPLETALK = @USE_SRCS_APPLETALK@ USE_SRCS_FILES = @USE_SRCS_FILES@ USE_SRCS_IPX = @USE_SRCS_IPX@ USE_SRCS_PLUGINS = @USE_SRCS_PLUGINS@ USE_SRCS_SCTP = @USE_SRCS_SCTP@ USE_SRCS_SOCKETS = @USE_SRCS_SOCKETS@ USE_SRCS_SUBPROCESSES = @USE_SRCS_SUBPROCESSES@ USE_SRCS_TAGGED_POINTERS = @USE_SRCS_TAGGED_POINTERS@ USE_SRCS_THREADS = @USE_SRCS_THREADS@ USE_SRCS_UNIX_SOCKETS = @USE_SRCS_UNIX_SOCKETS@ USE_SRCS_WINDOWS = @USE_SRCS_WINDOWS@ WII_U_TESTS_LIBS = @WII_U_TESTS_LIBS@ WRAPPER = @WRAPPER@ |
Deleted generators/library/FuncArrayGenerator.h version [2d0edf7996].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted generators/library/FuncArrayGenerator.m version [4ed090453c].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted generators/library/GlueGenerator.h version [df3f9366c5].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted generators/library/GlueGenerator.m version [a4f73aa06c].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted generators/library/LibraryGenerator.m version [69ede2939c].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted generators/library/LinkLibGenerator.h version [58647bf17f].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted generators/library/LinkLibGenerator.m version [e9161f0524].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted generators/library/Makefile version [b62d874949].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted generators/library/copyright.h version [c0b22b50fd].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Modified generators/unicode/Makefile from [9009fb89e7] to [f73c114258].
︙ | ︙ | |||
10 11 12 13 14 15 16 | rm -f libobjfw.so.${OBJFW_LIB_MAJOR} rm -f libobjfw.so.${OBJFW_LIB_MAJOR_MINOR} rm -f objfw${OBJFW_LIB_MAJOR}.dll libobjfw.${OBJFW_LIB_MAJOR}.dylib rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR} rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR} rm -f objfwrt${OBJFWRT_LIB_MAJOR}.dll rm -f libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib | < | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | rm -f libobjfw.so.${OBJFW_LIB_MAJOR} rm -f libobjfw.so.${OBJFW_LIB_MAJOR_MINOR} rm -f objfw${OBJFW_LIB_MAJOR}.dll libobjfw.${OBJFW_LIB_MAJOR}.dylib rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR} rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR} rm -f objfwrt${OBJFWRT_LIB_MAJOR}.dll rm -f libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib if test -f ../../src/libobjfw.so; then \ ${LN_S} ../../src/libobjfw.so libobjfw.so.${OBJFW_LIB_MAJOR}; \ ${LN_S} ../../src/libobjfw.so \ libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \ elif test -f ../../src/libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; then \ ${LN_S} ../../src/libobjfw.so.${OBJFW_LIB_MAJOR_MINOR} \ libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \ |
︙ | ︙ | |||
43 44 45 46 47 48 49 | ${LN_S} ../../src/runtime/objfwrt${OBJFWRT_LIB_MAJOR}.dll \ objfwrt${OBJFWRT_LIB_MAJOR}.dll; \ fi if test -f ../../src/runtime/libobjfwrt.dylib; then \ ${LN_S} ../../src/runtime/libobjfwrt.dylib \ libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib; \ fi | < < < < | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | ${LN_S} ../../src/runtime/objfwrt${OBJFWRT_LIB_MAJOR}.dll \ objfwrt${OBJFWRT_LIB_MAJOR}.dll; \ fi if test -f ../../src/runtime/libobjfwrt.dylib; then \ ${LN_S} ../../src/runtime/libobjfwrt.dylib \ libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib; \ fi LD_LIBRARY_PATH=.$${LD_LIBRARY_PATH+:}$$LD_LIBRARY_PATH \ DYLD_FRAMEWORK_PATH=../../src:../../src/runtime$${DYLD_FRAMEWORK_PATH+:}$$DYLD_FRAMEWORK_PATH \ DYLD_LIBRARY_PATH=.$${DYLD_LIBRARY_PATH+:}$$DYLD_LIBRARY_PATH \ LIBRARY_PATH=.$${LIBRARY_PATH+:}$$LIBRARY_PATH \ ASAN_OPTIONS=allocator_may_return_null=1 \ ${WRAPPER} ./${PROG_NOINST}; EXIT=$$?; \ rm -f libobjfw.so.${OBJFW_LIB_MAJOR}; \ |
︙ | ︙ |
Modified generators/unicode/TableGenerator.h from [d5ba8e12b8] to [de9d82ab31].
1 | /* | | | | | | > > > > | < > | < < < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFHTTPClient.h" @class OFString; @interface TableGenerator: OFObject <OFApplicationDelegate, OFHTTPClientDelegate> { OFHTTPClient *_HTTPClient; OFUnichar _uppercaseTable[0x110000]; OFUnichar _lowercaseTable[0x110000]; OFUnichar _titlecaseTable[0x110000]; OFUnichar _caseFoldingTable[0x110000]; char _uppercaseTableUsed[0x1100]; char _lowercaseTableUsed[0x1100]; char _titlecaseTableUsed[0x1100]; char _caseFoldingTableUsed[0x1100]; size_t _uppercaseTableSize; size_t _lowercaseTableSize; size_t _titlecaseTableSize; size_t _caseFoldingTableSize; enum { stateUnicodeData, stateCaseFolding } _state; } - (void)parseUnicodeData: (OFHTTPResponse *)response; - (void)parseCaseFolding: (OFHTTPResponse *)response; - (void)writeFiles; - (void)writeTablesToFile: (OFString *)path; - (void)writeHeaderToFile: (OFString *)path; @end |
Modified generators/unicode/TableGenerator.m from [c1835e042f] to [4286c92f40].
1 | /* | | | | | | > > > > | < > | | | | | | | | | < < | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "OFApplication.h" #import "OFArray.h" #import "OFFile.h" #import "OFHTTPClient.h" #import "OFHTTPRequest.h" #import "OFHTTPResponse.h" #import "OFIRI.h" #import "OFStdIOStream.h" #import "OFString.h" #import "OFOutOfRangeException.h" #import "TableGenerator.h" #import "copyright.h" static OFString *const unicodeDataIRI = @"http://www.unicode.org/Public/UNIDATA/UnicodeData.txt"; static OFString *const caseFoldingIRI = @"http://www.unicode.org/Public/UNIDATA/CaseFolding.txt"; OF_APPLICATION_DELEGATE(TableGenerator) @implementation TableGenerator - (instancetype)init { self = [super init]; @try { _HTTPClient = [[OFHTTPClient alloc] init]; _HTTPClient.delegate = self; _uppercaseTableSize = SIZE_MAX; _lowercaseTableSize = SIZE_MAX; _titlecaseTableSize = SIZE_MAX; _caseFoldingTableSize = SIZE_MAX; } @catch (id e) { [self release]; @throw e; } return self; } - (void)applicationDidFinishLaunching: (OFNotification *)notification { OFHTTPRequest *request; [OFStdOut writeString: @"Downloading UnicodeData.txt…"]; _state = stateUnicodeData; request = [OFHTTPRequest requestWithIRI: [OFIRI IRIWithString: unicodeDataIRI]]; [_HTTPClient asyncPerformRequest: request]; } - (void)client: (OFHTTPClient *)client didPerformRequest: (OFHTTPRequest *)request response: (OFHTTPResponse *)response exception: (id)exception |
︙ | ︙ | |||
125 126 127 128 129 130 131 | _uppercaseTable[codePoint] = (OFUnichar)[[components objectAtIndex: 12] unsignedLongLongValueWithBase: 16]; _lowercaseTable[codePoint] = (OFUnichar)[[components objectAtIndex: 13] unsignedLongLongValueWithBase: 16]; _titlecaseTable[codePoint] = (OFUnichar)[[components objectAtIndex: 14] unsignedLongLongValueWithBase: 16]; | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | | 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | _uppercaseTable[codePoint] = (OFUnichar)[[components objectAtIndex: 12] unsignedLongLongValueWithBase: 16]; _lowercaseTable[codePoint] = (OFUnichar)[[components objectAtIndex: 13] unsignedLongLongValueWithBase: 16]; _titlecaseTable[codePoint] = (OFUnichar)[[components objectAtIndex: 14] unsignedLongLongValueWithBase: 16]; objc_autoreleasePoolPop(pool2); } [OFStdOut writeLine: @" done"]; [OFStdOut writeString: @"Downloading CaseFolding.txt…"]; _state = stateCaseFolding; request = [OFHTTPRequest requestWithIRI: [OFIRI IRIWithString: caseFoldingIRI]]; [_HTTPClient asyncPerformRequest: request]; } - (void)parseCaseFolding: (OFHTTPResponse *)response { OFString *line; |
︙ | ︙ | |||
212 213 214 215 216 217 218 | } [OFStdOut writeLine: @" done"]; [self writeFiles]; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | | | | < | 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | } [OFStdOut writeLine: @" done"]; [self writeFiles]; } - (void)writeFiles { OFIRI *IRI; [OFStdOut writeString: @"Writing files…"]; IRI = [OFIRI fileIRIWithPath: @"../../src/unicode.m"]; [self writeTablesToFile: IRI.fileSystemRepresentation]; IRI = [OFIRI fileIRIWithPath: @"../../src/unicode.h"]; [self writeHeaderToFile: IRI.fileSystemRepresentation]; [OFStdOut writeLine: @" done"]; [OFApplication terminate]; } - (void)writeTablesToFile: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFFile *file = [OFFile fileWithPath: path mode: @"w"]; [file writeString: COPYRIGHT @"#include \"config.h\"\n" @"\n" @"#import \"OFString.h\"\n\n" @"static const OFUnichar emptyPage[0x100] = { 0 };\n" @"\n"]; /* Write uppercasePage%u */ for (OFUnichar i = 0; i < 0x110000; i += 0x100) { bool isEmpty = true; for (OFUnichar j = i; j < i + 0x100; j++) { |
︙ | ︙ | |||
453 454 455 456 457 458 459 | [file writeString: @"};\n\n"]; objc_autoreleasePoolPop(pool2); } } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 | [file writeString: @"};\n\n"]; objc_autoreleasePoolPop(pool2); } } /* * Those are currently set to the last index. * But from now on, we need the size. */ _uppercaseTableSize++; _lowercaseTableSize++; _titlecaseTableSize++; _caseFoldingTableSize++; /* Write OFUnicodeUppercaseTable */ [file writeFormat: @"const OFUnichar *const " @"OFUnicodeUppercaseTable[0x%X] = {\n\t", _uppercaseTableSize]; for (OFUnichar i = 0; i < _uppercaseTableSize; i++) { |
︙ | ︙ | |||
671 672 673 674 675 676 677 | else [file writeString: @", "]; } } [file writeString: @"\n};\n\n"]; | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < | < < < < < < < | 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 | else [file writeString: @", "]; } } [file writeString: @"\n};\n\n"]; objc_autoreleasePoolPop(pool); } - (void)writeHeaderToFile: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFFile *file = [OFFile fileWithPath: path mode: @"w"]; [file writeString: COPYRIGHT @"#import \"OFString.h\"\n\n"]; [file writeFormat: @"#define OFUnicodeUppercaseTableSize 0x%X\n" @"#define OFUnicodeLowercaseTableSize 0x%X\n" @"#define OFUnicodeTitlecaseTableSize 0x%X\n" @"#define OFUnicodeCaseFoldingTableSize 0x%X\n\n", _uppercaseTableSize, _lowercaseTableSize, _titlecaseTableSize, _caseFoldingTableSize]; [file writeString: @"#ifdef __cplusplus\n" @"extern \"C\" {\n" @"#endif\n" @"extern const OFUnichar *const _Nonnull\n" @" OFUnicodeUppercaseTable[OFUnicodeUppercaseTableSize];\n" @"extern const OFUnichar *const _Nonnull\n" @" OFUnicodeLowercaseTable[OFUnicodeLowercaseTableSize];\n" @"extern const OFUnichar *const _Nonnull\n" @" OFUnicodeTitlecaseTable[OFUnicodeTitlecaseTableSize];\n" @"extern const OFUnichar *const _Nonnull\n" @" OFUnicodeCaseFoldingTable[OFUnicodeCaseFoldingTableSize];\n" @"#ifdef __cplusplus\n" @"}\n" @"#endif\n"]; objc_autoreleasePoolPop(pool); } @end |
Modified generators/unicode/copyright.h from [c0b22b50fd] to [376e224716].
1 | /* | | | | | | > > > > | < > | | | | | | | | | | | | | | > > | > | > | < > | > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFString.h" #define COPYRIGHT \ @"/*\n" \ @" * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im>\n" \ @" *\n" \ @" * All rights reserved.\n" \ @" *\n" \ @" * This program is free software: you can redistribute it " \ @"and/or modify it\n" \ @" * under the terms of the GNU Lesser General Public License " \ @"version 3.0 only,\n" \ @" * as published by the Free Software Foundation.\n" \ @" *\n" \ @" * This program is distributed in the hope that it will be " \ @"useful, but WITHOUT\n" \ @" * ANY WARRANTY; without even the implied warranty of " \ @"MERCHANTABILITY or\n" \ @" * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General " \ @"Public License\n" \ @" * version 3.0 for more details.\n" \ @" *\n" \ @" * You should have received a copy of the GNU Lesser General " \ @"Public License\n" \ @" * version 3.0 along with this program. If not, see\n" \ @" * <https://www.gnu.org/licenses/>.\n" \ @" */\n" \ @"\n" |
Added misc/keys.asc version [1717b09117].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | -----BEGIN PGP PUBLIC KEY BLOCK----- mDMEWtyz7hYJKwYBBAHaRw8BAQdAsw2r74WiB54Nr73sY2sxBLu0RUges2iPeBor 1Wc6Cre0O0pvbmF0aGFuIFNjaGxlaWZlciAoQ29tbWl0IFNpZ25pbmcgS2V5IDIw MTgpIDxqc0BoZWFwLnpvbmU+iJkEExYKAEECGwMHCwoNDAgLBwYVCgkICwMFFgMC AQACHgECF4AWIQTGxY7C74kJHg4TzVjYOna/43Y0XgUCXESzpAUJAWlRNgAKCRDY Ona/43Y0XhA1AP4nIiBUL2nMtkDJSbSb0/kbyIoTNhRXtlI4crYIqfs07gD+NMdH HzMnGtHkpaX7GAqVTeTiThZUnTGNMwnV9aerQQe0OkpvbmF0aGFuIFNjaGxlaWZl ciAoT2JqRlcgU2lnbmluZyBLZXkgMjAxOCkgPGpzQGhlYXAuem9uZT6ImQQTFgoA QQIbAwcLCg0MCAsHBhUKCQgLAwUWAwIBAAIeAQIXgBYhBMbFjsLviQkeDhPNWNg6 dr/jdjReBQJcRLOoBQkBaVE2AAoJENg6dr/jdjReDVoBANvkIYUTLemog3UhjZYh Zdvq9Axd63L2lnpzm+For3tNAP9GmJwbq/oi8E0mAwesbvQYY/R4NOOKIdV7rkVj JzoeCJgzBFxA+ccWCSsGAQQB2kcPAQEHQIe0NK4nnagyINx6Z2DJt4lUzv7a7e6x PLifEvo1iQVptDpKb25hdGhhbiBTY2hsZWlmZXIgKE9iakZXIFNpZ25pbmcgS2V5 IDIwMTkpIDxqc0BoZWFwLnpvbmU+iJkEExYKAEEWIQQtKx7sQXauZ6pvl2B50hGJ otRwjQUCXED55wIbAwUJAeEzgAcLCg0MCAsHBhUKCQgLAwUWAwIBAAIeAQIXgAAK CRB50hGJotRwjeuIAP9wQ8r+13S0ZHPmOkeVQNqpVdvszisfszQKNRrkKrS7fgEA AF4eI4IXb13x5hHvzYn2DMMe2ugx6LoCdzYcVlvFFQ60O0pvbmF0aGFuIFNjaGxl aWZlciAoQ29tbWl0IFNpZ25pbmcgS2V5IDIwMTkpIDxqc0BoZWFwLnpvbmU+iJkE ExYKAEEWIQQtKx7sQXauZ6pvl2B50hGJotRwjQUCXED5xwIbAwUJAeEzgAcLCg0M CAsHBhUKCQgLAwUWAwIBAAIeAQIXgAAKCRB50hGJotRwjXTdAP4oYHIg5+LBhfO+ SNSQl008KH35KmyO4xtZPKfcbWjXcgD/dWVqZDjUYkCs/0oprdJDZPRBIB5QQhjc 1un38+eCiAeYMwReJFsBFgkrBgEEAdpHDwEBB0CjTf7buaAeNxgLpbv9/j4UgcjJ Z97STkAaM7Xac+Dg1rQ3Sm9uYXRoYW4gU2NobGVpZmVyIChPYmpGVyBTaWduaW5n IEtleSAyMDIwKSA8anNAbmlsLmltPoiZBBMWCgBBFiEEMOaUj6yAQrWMtKlu4rzO azXhr4sFAl4kWykCGwMFCQHhM4AHCwoNDAgLBwYVCgkICwMFFgMCAQACHgECF4AA CgkQ4rzOazXhr4tQAgD+P45Nx/YGk2Q/JzBz+cbsdtcha7IehgXulltd3xLjdwsB AMoefVWwHOJa7q10ZRxDN48kDGD+kiqvSdIvKRGuLmMAiQIzBBMBCgAdFiEEbR7C JpvAtUWci6kgz9q0H4KSzu4FAl6KMHcACgkQz9q0H4KSzu7HLBAAo2it0ci2HuJT 1+x1n74dBI5nwKak15OoABW37vxt10gMdm1wo9hq0cJorXdQmE07pMWpMmz883Yg ayqTXyEJJydVqq3rgR1zcEKOGpiJT6azRfGxcvsNh8bMto9dC6cVVmknydyvNTg7 3TpofPmRlH8W8gt8w55EiO3Lk4RJODzGhCOrDxbR1o9rF39fUHj+g3NB7grK/TTt dZvomOS+mcM+pANYivOTmMc5mn0mEVua3F6wRvUck8ij2JFTvJ5GV3xie6JIDa2h l/hM2BLx2XRrwjnD+kig/CjpoFEP8bzc+epHb6ODAt2SQ5i4Zx30TFWiVeeljX1Q zFq5pfJr3nbHQNhkzsu3uWXfqUu1M6mBadzYmLYLDgVFLFKdwhBgbvInr39UAtwE Yl70NoqgVswPzWSkAyrLWs0+2XUXZlyhFxNaOqheWE7VQv/DPYDBPXrim3f5Alv2 PtQJ2BXDvl1PyDg6Ckg6Pe6XoVKPJwMYsiWZOrsnRRJzeQWa1zFsVWX+CYINPiEY v4Ls2OFGZj67tzNU8Wf2EFbNmm/V82sXrPeu0iqcJ99aaxZw+tk+h5WS0BiXceZ9 J6dRKo2qHJJAq0FJnAt+6NRam1KYAknd9y6g5S2bRqiI1wJminmksbSLQ5wmeunl EynylSIJx+UbXBYVbvmpLWZFFRUKBM60OEpvbmF0aGFuIFNjaGxlaWZlciAoQ29t bWl0IFNpZ25pbmcgS2V5IDIwMjApIDxqc0BuaWwuaW0+iJkEExYKAEEWIQQw5pSP rIBCtYy0qW7ivM5rNeGviwUCXiRbAQIbAwUJAeEzgAcLCg0MCAsHBhUKCQgLAwUW AwIBAAIeAQIXgAAKCRDivM5rNeGvi4HuAPsEi38R7E8716m2ua2KvFB3CClSCsVT tZjbIQBEHzQ/iAD/UEZtjaNUW/Mf8vFExbnqFes0dwF0p6PzQ0GLix12JQKJAjME EwEKAB0WIQRtHsImm8C1RZyLqSDP2rQfgpLO7gUCXoowgQAKCRDP2rQfgpLO7jtA D/403WskqoPnw+woWaeCPZcTU1LQ/o5baUUxbQDWTAUNav3hzDxBDQ1yPacZhwBu ea6SNnrEZwc5wd5TPozh9sXday3vqDe6R9/AT+MokxJT3EWptTXmcawRSyDdFNZr V8KJqfDjRNkv9Iqxsjjp9fD5Vw8zVC/KIr0JOq2oxzjU+Wukk94NhSOU2LDRaQLV 8vMpXZRpVJh30+7rq46sTzhZqB5AsTdBykFOsTl9LRmRJXnLjdK/4U7uhoj5ntfR QzPUG3mmbHf5RlGoQIFq2Byop0MiGVWjHI93C5OU7fyjfnARnENOqCgUxs+yXauY J+wngqdJroGEo/5kgbJxpTksuK9zQ3DDtE1p5y48qct0gvw3hYz1UGvpEQ2/Prcy 1q0Nc4hzQ2zrG9jO5971KW2alUT5lrILos17ZJlN5pI8NHhat7T9RX82ziB1fQKG OzbSjxT8gXasy9gbMh8w9zm1prZ1+VRQT8JGLYPHM6mZID20F1q5cRLT41UyTjSe zzStci/zo/dQKFKaTX9KesTSwVS9Zlo7yldUgH+lWyaSjF9VCrjyNI3YbEJ+/Fqt rwxAp8kzFviOd7R5F4zAJBRwgfQNI46v9F3X9KpaTeuuJhm4KvyqPRE/0G0ond8G yJYePoL3jMhfl50163cO69TGXyJmvKwATEa1xRU8n9lE9bg4BF4kWwESCisGAQQB l1UBBQEBB0Cc6UB0PD0kppdYyeJV3uXSuXk7stS6si393JPKFX2wMgMBCAeIfgQY FgoAJhYhBDDmlI+sgEK1jLSpbuK8zms14a+LBQJeJFsBAhsMBQkB4TOAAAoJEOK8 zms14a+L7UoBAJkNXZsY3zHeiSQ23YeaABQUTtpjWb0o6xljq3PXR/hEAP44Rvf3 hTkPPDuMCJelOxzkvr83upYCIyIpP5HpzqFWBpkCDQReih1/ARAAuXxV9zzoO2UY YlXdNlNSxu9iJKH/RySUzIPtCWVxUfsI1NOo2ByhxxGWpATRye61Lm6cAU+tvEXj saKpTi4i9WSy6m6xuLLqQrpDrbVOlazzM1MRQcqGK2wFPtNKV9qz+oOdPXK9a2Rl gI2iwQh6AjCjq8oa3T1MtDF4D3uGBE+Fn9g+gryAf/TZ8gKWyYd8UZwtrlFLC7nq 8gSj2hFiRYTAPGy8GhcdyKvD0cP2xiFlpJmzCn5B+i9a5i3EJDcbfcc0BSyqxkz2 BY8bymw4kTt5e8Bmf4KdzK5OE4w3PFPiMq+Z3LVohQCI2CRh1wGw6lzntU5nqJ0c eD2YV9C8dHwVEN1Vu2M5mXkoe9q4iLWETppxchrQWVAWZWCOeElNxdOrW/uhxpdX RmzTMuCIHolB4VhszS+Wr3Uj98DWa9n/cPZpvRdVdXmy95G9ocp+uBozQEjdmLOm rqPUUbE/WLUO/tRFqp6w6QVfh81G5omLo5VWlxCODK8OjOR4/rfCH28I75bjrm9H pIYtSasVG1/XSV+ilv3PCwadftz8BR5iE0JJtk8NtI1jOvPrIe5d9hJ9109xk/r9 one51VLFFQDsNJexCswjD25xgpqnhZBd0yOtcE9+6hiENLZ0DFrKZSJjNC7xY/ts K9usWwm3CBx2VFi+GpjL04Apo9ooPA0AEQEAAbQeSm9uYXRoYW4gU2NobGVpZmVy IDxqc0BuaWwuaW0+iQJbBBMBCgBFAhsDAh4BAheACAsJCg0MCAsHBhUKCQgLAwUW AwIBAAIZARYhBG0ewiabwLVFnIupIM/atB+Cks7uBQJj6WbtBQkJIbBuAAoJEM/a tB+Cks7u1qUP+gLBceY67YURSNLLCO+L537Xukf2eYlzJzUvBI1nYv8C94dQcmSa sBcAsg2ELfKE6GD1/7VwHQHwclpa3kSX55V6+Ep3VUSR7+2fqz4Ahr10FeOpjS5C Ir51C44mAjeTkkmPIqhOWSoZyg2RxUZOAUZyFqpLDPFGrRTGmuEFnP1tXOAn3TR2 xllK9iAbB9ZcJ+MHEz+rVW5yj3XY8/QW1kcsWIA6qV7eHPP4Y8tEIoefvsU5g188 uHIhxWhB0Xd52VMxd32yiKRgPp9z+6e4PQ+XULv5oGiqR17XKMtMIfAe6kiDYXWT HpqOHnOekVPuqTsjAFttgKeCEzbyit6HIFlqoXjoj23eTFQEi2qiSLCRDm2uGZJI hAL5YeHPaNa82dg6YNCGD8FFSwP+hhXMaQ7zB2jB8smX9A9C+nHCKCFF4ba1RRNq sFRziE2YuY+KX6bQKz6AZ7OxB16YAx75e4J/H/Si8bqm+1EKc6Xpg7uVjYYNH+dr j4qvNsTf4tLr3FAm5tSRCdZkSlilS+565J4PInBVjcLnlRAxh1X1RJGVuFuueVdM 6joGmsPDnwdv8NOvy+4LvBHWkPLm3FVZE9fyDem+0SDooTpvFEuSRfna8agJB5kH zA532hu1dEX/XJMCCJT4RBYy7KOVXqcjrLn/TqRiBZKPK4QbmC/JjdKJiQEiBBAB CAAMBQJj6WgVBQMAEnUAAAoJEJcQuJvKV618c0IIAKLZVwWsgQWBjtjaIsXKUhoo 5HBwNpsNCnWAyUj0ayspkvM+hh5fa70s4Mj4oRdCd44X1iDHQw2bV6PVA+TvqkY2 NV7iL30Vqpyt50qreUz9qCdEittaFIkRNk2qkQB89cKTrrLDu2k80NZdV4sAAJKu XFUOEecZVv5D3gYSKDQJ0lTUzSyS4cC5wdSpeEFRTVXpOQOI32mRM9BxmjtDSBct fnHSWYoE+IoC+OPqDvbbP4TRz3UYjAz5lbLSL5BnlHxZDG2NryH9tUn+/wnJd41m weKZidDO/AUQ9eKKaIsgzCXAjrLjKcgBBANn1yXl+YAr7J8GFdiGkVznYhGjmAW0 IkpvbmF0aGFuIFNjaGxlaWZlciA8anNATmV0QlNELm9yZz6JAlgEEwEKAEICGwMI CwkKDQwICwcGFQoJCAsDBRYDAgEAAh4BAheAFiEEbR7CJpvAtUWci6kgz9q0H4KS zu4FAmPpZvIFCQkhsG4ACgkQz9q0H4KSzu4/nRAAk5+6zavoleNtZ0/l9xs0lwwq sENTfdWqp19YvkiQTWz0gDvRoxKbXHI4HK25th0rBu77ryQYjKrRjXhEZrNq2k6f hTBwJ1sbsDceksaHRlUlVgn112gf6B/iKG3JpLxuFxuMS4ndN9z7H67t2RWDY/+M qSgaNFWXQtfmtC3tfV8e5etZScVO8w+0Wed6MjGjA76crgVWXm2hGCokEk7+0uNd VmFC+cPEBMixgAHqZvM+Gu3pZvHgV50Ybczalx/6KV2W37MsaX6iRUCCpnnoAAxN pWo2Z2LIBVaoO9nuzO8pgF8dRdxwq3Px/RpseHtEUY4v1/aylB4z1joI7sWPqXOR 3QlRmCd2O36kCiLIvm9OQ5tmjmW9T+t/gcCzq5pHDNIx8D50urqnUH+WU/WaT5fp uM6VifBpSZslTuRavc6kxa7kuGCrsBtVOzlMCxSVAqSgMMm4vVxJm20pYIItHHTZ TXEehnLEst/EdEAmLmHO2Qch/qUh2i0w5+4pwjY1pIOVP8Si3xbxtoN6PIM/UBEP fBQGB4NzljQwISdUUSGiWn7pcun350IsCjnC2c+tJQ/lHjhrJjZ+aMAi7OSV6g9P pjFrz+z9UmTP0QUeBSNGBqAWgvC4okGgFr4cf9H01FbZPNkWIfZYPZ1Nv3apxNOx lpzSHcURnFhXPJDlqNC0IkpvbmF0aGFuIFNjaGxlaWZlciA8anNAcGtnc3JjLm9y Zz6JAlgEEwEKAEICGwMICwkKDQwICwcGFQoJCAsDBRYDAgEAAh4BAheAFiEEbR7C JpvAtUWci6kgz9q0H4KSzu4FAmPpZvcFCQkhsG4ACgkQz9q0H4KSzu4TrxAAnWBr gJnU96KbYRS7KkpUzeLeaLrHK5LIhaJ7rVxVrOo+x5Ey2NjGJKoTxC9UAfITCfO9 9vsycp3Gb9fJnowieuQ1y1MFCrYLPPLOfNxh4Jc9GZK64DlexrsXvDhx84wgN+el rnjuatm9LUJWe5czWKiAnoki/u+SGFVxwOUtND205I4go/8FtY8rZ1P3VEGiXeZq hjNOodDoGEGZJwQIycN5YCrweYPwM+p80ZbzkWGB+Ov3lOO+omMf7NQ3LFtueV0J Nq7SjmNESYLm1Gg2NFHZp4D12sSUfHTvNVJBr1qCJggQs2mefRB/aKcS4i9Ajmfk i7TkEwutDMX6rOCZRppYpS8N6aYoiAOZHQmffk8bdi0RBGVSxR+04IwpYObUbDIZ US2exkiaDB0tFeguIlgHU/V+3GWEUDF4AhQLbSYkEwUc65FstULrDCRfegFoUBsY 9D+qPYnsNOlTRlalR8hZaQlwZLAuZx0kn+YGxs+9z2UhgMExRtCM/3FRpDuiFJGs QML2DUArYZeh7JyJy0m9PIt59wg5wnHUyCLop8g1gn6Wh22/R/Le6CEusJsO2qiM oE6PSB89g3nhsvUadRpYOP9eZS0aoRgNPLp+qigthgEV9fvSADHtAvsaLYpQ+wjr O+Ih57Y2MrU8mPehwqGz17Ur58VcI65qXTkZpni5Ag0EXoodfwEQAPc4JUVqZGxS KtipZKGewKuNyqASMq8gNwL7ToSni5cTuQLa9YU+5Zo/BX3OEJkXp+MNN3Y1wFxV cPBZsYpBAx3apWhi0Fki+zdPjTmRE7QcFE+UE17OnnFReb93G2ErSiY+BzsfbW/3 dMjLfLhrVjJktLA9pGMoR483jI6rIVEBa6TikoMo8b790Ulo0xicl6ehFhQVUGN4 CfovBjCZ9CIX6dmRGaB/FMyOXgXWsx5+UilTgJhRHbJnggw6U1H8lk/WhJzCyLyY Tg+YkHx3WwAF37pR6g1XACMQEdumCLxW21ELC5D4aX0QejM8oIDf/xw5mHcgB0xg 07FmRbyiZheg+CSPgwHWW/K6urw/G04SbYxnk1/kPA66x6Fss3BxTuJOYmEZqklV Np2KfJdEiBECftRRWIbZu2zFOMGK1olPIOgsKdJvaATkgeYSxjCu9+o4vY1yGXtz BEwBfIUkU2B33QzWLq+I61WeVbqRC6k0SYBKiQK/uQJSVYuEtNJ8pttYxdYkyY+r s0yCZHlTlJcYKhAdMi1Gbh2L6WbzsHIHfmdraWqcv7EEuVacjrgerdk3ezOQspC5 Gfa6pLEmOoF/ctwg/uoGCyhnWBmHiuLdN7F4+z6BHBoqHU1i3z2oUJ3tHDoVnEmh jYNOgIs7UgKxXiuczMJT4gpNM35ym32hABEBAAGJAjwEGAEKACYCGwwWIQRtHsIm m8C1RZyLqSDP2rQfgpLO7gUCY+lnIwUJCSGwpAAKCRDP2rQfgpLO7oIlD/4oLDMH qTzdDIXjM9x5U4ENBeGwUKHEkKeRduXuj0pZTnWTHmdXD3RPbG1EfGJU3PVBudZU iEREibNaEYM5VFuDwMw51qw7Ox8j4r+RtP+8AI0zpRdababPP1/A4ap+xwReTWVM /CFF3VekqeElgxSjM6luFPNDdwyBNavOLtbrWhmyclw3DLB03ZtS0sPvu0hXTnp4 nbuWdsPOxGIomb9UF0IplMPm5ChjkZaypKY75P1k5Il+AZFWEi5YB6y8yl1gmOxY 3pnKCJWcoGsaEoxREqHH/tZAeI299u8aE8Gjl+ZxGunuPDMUd8OSlE8MI3osnWU4 7rbVueWqJ4CG3OcYJP8Vj1Ygy68R5xBL5ku3ddv5oI2ZIDkqTBFKJQnhWMUX6Trz e7US0jSdVFv4fYf3aHDJ0afc9RsKebPgbfN3FWak03zInVqdXRrraa410qz8fKBI 1CKalErJN7/dpXu3vfJJ2TgYcgAN9N0lY+YFQ834qpDk6KOTYzvIMJASVIJ1gjvl iE94hE6FYuHU9DlwYL3/qbOOb6lLIFHxaeQ95ZZR+raPyi1FGVGXV8oZI5f2Uzxo LYyioTRjgC0cr9aIK56ZQ5I/npwuEYSL/8oIWdRrYGQT0FFQQAnhhkd61DuPt3GA fhsY1fGkPo/YC3yulOJt98FIMg/lRlYfOrxIbLkCDQReiiM/ARAAwIzaby43las5 ApAWVw4MxCIpdY9S0tKUBgF4koKKkgUQ20KzI395LctZ6TwRSaBp9df/Wi9JtXe3 bkt46ASjq8CCMggVptq80KyhnVMYDJD8mH+gFjUdlxTgILg1tnYwt01oBIMh8T1c EUQ2kcWkDbIRnrrSkVxh+ntu8aqZaF9E9iScPbNO8V5qIGCTfeFti1IUfClQ10Cs dANPxVngzttHs7eg+ddwZdiwxb7vxKy1/juqWTNFcHYd4XQ8MIuedXliHpvI5quf MbFvOmX6xxxoXTL/efGoA/zCM6/BcM2ul1o/prJTauRuVKawE3mcMpTrubN+usf6 QEUohxsxCvxVqGcJVAU5286Hv0Kc2jzqcWqEfiyjCJI0vwCzFk3sRbuawlDuC535 paR23QC/ClSCghMzfRRnN4OpJQjzgc6yOZ3ydqmF5UeqGrgZhrW+O92jBb1XqGFV zTOYHvLNJCQ0Cj53fiYpju4Pdf2BWvDo1oSoKbrvSd3DUyXlgN2Ar6t3X2uz7HhL 2496v3BoIOqzzcdvpCaDZjDdrw8SHpp45u9qrzMPKEIdqy4u5KjsKjuCZKczy4pc u44+JjDzNJRik0Ppf2AUJLBCnik6prZIttbCfGsvid7SR5sZZgjbGk/fuQCF/tQt aksvsIqb598/sTzNVBGkp6qWttTkPs8AEQEAAYkCPAQYAQoAJgIbIBYhBG0ewiab wLVFnIupIM/atB+Cks7uBQJj6WcnBQkJIarkAAoJEM/atB+Cks7uei8QAIa+BrMi fmLTSLe09CnGvacepKNao6UqSHwbmf6Tonv9rOU2EquKyCW/0YK53WGO6fnPE7FV 8JYDWxecBvtLjj+hloEHJ/wliYwd4W3FOuGnb/E9mzQgyKdWcSBIxreZLdD7xZ5B iv3VLeKyx+xnJ99dC2+MBuL6CBk+gmzwri7/hkYG9GQW9TJEe7qi8D87iTN1YkXl cJXdDcqapEZxv8+nAa5E4gTmLlXnKYNidC6+9gtnGpCRZtSpLwX0pMVY27w9sthU Acnx5N3AwS7rCodqnU3ANa5a00wbWOmZ90qbofRX9RC3qkfoisr62bRELY7KFt7M VTV0YBTCPHFeP+bubyOOyUe1OJsCvWJfIhJm87qjS37WXxYDUU+KHGN4MX9LDvTS xy+h30Ba0XFfU1fgNtIvVR+MrrIGACq5VU2uSyBQLmIkgcusUComEx77mETE92Mw ROJfy1O5VGsNDr61xIu72MjKAlukwgwX/qQ7i8Flyf8N++J7fETf/4DHXxNS9imV JTVxHfvIWpclRfdUCZB6R1Ihv+n1T+yx/FroTxQ5wuilV7+0r2DhrW6Q0YISoWv5 L1sfohVZCXF7EQgteax0/86WSboerrWQmfGk0k4SjKhBJK1O8Jhh2tk8OmlUz6Fs 7MhFJ5NGASlFL7p0W5iB3qWYwn52sEBaI8VpmDMEYBW6BBYJKwYBBAHaRw8BAQdA WWTgOvzlX/x5OiYhMLK72aKOMvr0g6KIaynmN2YMp5O0M0pvbmF0aGFuIFNjaGxl aWZlciAoQ29tbWl0IFNpZ25pbmcgS2V5KSA8anNAbmlsLmltPoiaBBMWCgBCAhsD CAsJCg0MCAsHBhUKCQgLAwUWAwIBAAIeAQIXgBYhBAzGrFQcetxzPGQWEGNnA1dz lTEvBQJj6WYYBQkFtN+UAAoJEGNnA1dzlTEvXKQBAPQ4mbtEmbuMbfpeV3pMP8bO 1OhOB4/Thx4tUrrV7JcjAQCveLdvBrB+cSh+DA7edl6/XWfafCT0qrzRFhaoEZhx Dbg4BGAVugQSCisGAQQBl1UBBQEBB0A2sxWorhv9BEE+urAmX5GBUfcCdta9Un6E t5wEG5jLVAMBCAeIfgQYFgoAJgIbDBYhBAzGrFQcetxzPGQWEGNnA1dzlTEvBQJj 6WYtBQkFtN+pAAoJEGNnA1dzlTEvi+8BANiiPjamWJ3iSeMEaaYPoZXNZ7NAHlK0 UUgQvB/osfQWAP9NKXMO7P5R/K+D2nRE/Ndmk0lqBykzumouPVuR21pYB5gzBGWW /sEWCSsGAQQB2kcPAQEHQAujl3ehBqKz3PFMW+rl8/d/1KS7Skx00xYU6xsLout+ tDhKb25hdGhhbiBTY2hsZWlmZXIgKENvbW1pdCBTaWduaW5nIEtleSAyMDI0KSA8 anNAbmlsLmltPoiaBBMWCgBCFiEEYy4qTb/j80NaLyG/lClu8uyb5oMFAmWW/sEC GwMFCQHhM4AICwkKDQwICwcGFQoJCAsDBRYDAgEAAh4FAheAAAoJEJQpbvLsm+aD g10BAP5MpkFbauicEGNTUJnmfbWZsGmmOTov7nG3ylVPp6UpAP4jIbm0Nz5L0+1B vA35PeZfJ8z2dIcuKPKkCgxbv55NAIkCNwQTAQoAIRYhBG0ewiabwLVFnIupIM/a tB+Cks7uBQJllwC0AwUBeAAKCRDP2rQfgpLO7sktEACdIKHR7vTHKgokw/6j2zwd Na3sBt0jC7tsqA7xbfobwMR3yoVnD49T4zHlW5MwKaQBsTkwI9pS4qbaPsX7VoXV 5I8UpWPbXeDnofO9B+sO55ybVrGf1Fb2PmykZ85dgEe168hL0c5UX+9zCXjfFTHa GAxRmTrYKP0h+jYZJns1QK3KZEWh0pkqJz5oOLELqeZS2GMGn1PQjmbzz72/korZ sUswS5sDBbMVeusCWuNeY6FJZ6ziv97geu+uWe7ppwv25rebEKJgsuaIqDuAT2Gg 3NgrubfXFVLlDxjuYdaO+ieBQur5z8UPaSzEYlF2p7/cut24A8WV/d3D5dX3XO/g AuEMkyAws9zOeY3NMMfkHEZsuX0AetH7cOQYyAUIlpye30OxeoZgO4Cl3G5q95sk Q4i/LpzNERq+JydmniPMbM/TL8p87RYr/bidO+0KeHwRzsesVu2ae1xO/ZRSyqny un5RZblS9QY1H3xUgKQWpMLxJGXr6n+9eRThRsrTK/JH6GFpkFnjmMpuxquAw32w PdxGWDUUE35pC4f0X/6rL8IBf32spXG+mKbBLTJkSkteSM26Uff4zVFludQU+N06 c6XFX7eBpbhhHhsCabOskGFXXS0bdi6NcZgazm1I4rhqrT+pQFHDOZg/dgl5cND/ Q4zqQ9Xrv/iV6ljHHAPYGrg4BGWW/sESCisGAQQBl1UBBQEBB0CTeGWS64rbAwJz Sioh6y0Urd5/pGIj5UEdyAFrjhiKDgMBCAeIfgQYFgoAJhYhBGMuKk2/4/NDWi8h v5QpbvLsm+aDBQJllv7BAhsMBQkB4TOAAAoJEJQpbvLsm+aDv0sBAIFCR1MA+d7V ll+AxWH/k2ghgfJ661e88iaoG7qUyve5APsFQbV5thutm99chCp8Sc+fulHNtrKJ WBymwZqetu7HBg== =mVJw -----END PGP PUBLIC KEY BLOCK----- |
Deleted objfw.spec version [218ec62f80].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Modified src/Makefile from [cfe5b64764] to [6486149d8c].
1 2 3 | include ../extra.mk SUBDIRS = ${RUNTIME} exceptions encodings forwarding | | > > > > > < > < < > < < < < < < > > > > > > | > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | include ../extra.mk SUBDIRS = ${RUNTIME} exceptions encodings forwarding SUBDIRS_AFTER = ${BRIDGE} ${TLS} test DISTCLEAN = Info.plist objfw-defs.h SHARED_LIB = ${OBJFW_SHARED_LIB} STATIC_LIB = ${OBJFW_STATIC_LIB} FRAMEWORK = ${OBJFW_FRAMEWORK} LIB_MAJOR = ${OBJFW_LIB_MAJOR} LIB_MINOR = ${OBJFW_LIB_MINOR} LIB_PATCH = ${OBJFW_LIB_PATCH} SRCS = OFApplication.m \ OFArray.m \ OFBlock.m \ OFCharacterSet.m \ OFColor.m \ OFConstantString.m \ OFCountedSet.m \ OFData.m \ OFData+CryptographicHashing.m \ OFData+MessagePackParsing.m \ OFDate.m \ OFDictionary.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 \ OFMutableZIPArchiveEntry.m \ OFMutableZooArchiveEntry.m \ OFNotification.m \ OFNotificationCenter.m \ OFNull.m \ OFNumber.m \ OFObject.m \ OFObject+KeyValueCoding.m \ OFOnce.m \ OFOptionsParser.m \ OFPBKDF2.m \ OFPair.m \ OFRIPEMD160Hash.m \ OFRunLoop.m \ OFSHA1Hash.m \ OFSHA224Hash.m \ OFSHA224Or256Hash.m \ OFSHA256Hash.m \ OFSHA384Hash.m \ OFSHA384Or512Hash.m \ OFSHA512Hash.m \ OFScrypt.m \ OFSecureData.m \ OFSeekableStream.m \ OFSet.m \ OFSettings.m \ OFSortedList.m \ OFStdIOStream.m \ OFStream.m \ OFString.m \ OFString+CryptographicHashing.m \ OFString+JSONParsing.m \ OFString+PercentEncoding.m \ OFString+PropertyListParsing.m \ OFString+XMLEscaping.m \ OFString+XMLUnescaping.m \ OFSystemInfo.m \ OFTarArchive.m \ OFTarArchiveEntry.m \ OFThread.m \ OFTimer.m \ OFTriple.m \ OFUUID.m \ OFValue.m \ OFXMLAttribute.m \ OFXMLCDATA.m \ OFXMLCharacters.m \ OFXMLComment.m \ OFXMLElement.m \ OFXMLElementBuilder.m \ OFXMLNode.m \ OFXMLParser.m \ OFXMLProcessingInstruction.m \ OFZIPArchive.m \ OFZIPArchiveEntry.m \ OFZooArchive.m \ OFZooArchiveEntry.m \ ${USE_SRCS_FILES} \ ${USE_SRCS_PLUGINS} \ ${USE_SRCS_SOCKETS} \ ${USE_SRCS_SUBPROCESSES} \ ${USE_SRCS_THREADS} \ ${USE_SRCS_WINDOWS} SRCS_FILES = OFFile.m \ OFString+PathAdditions.m SRCS_PLUGINS = OFPlugin.m SRCS_SOCKETS = OFAAAADNSResourceRecord.m \ OFADNSResourceRecord.m \ OFCNAMEDNSResourceRecord.m \ OFDNSQuery.m \ OFDNSResolver.m \ OFDNSResourceRecord.m \ OFDNSResponse.m \ OFDatagramSocket.m \ OFHINFODNSResourceRecord.m \ OFHTTPClient.m \ OFHTTPCookie.m \ OFHTTPCookieManager.m \ OFHTTPRequest.m \ OFHTTPResponse.m \ OFHTTPServer.m \ OFLOCDNSResourceRecord.m \ OFMXDNSResourceRecord.m \ OFNSDNSResourceRecord.m \ OFPTRDNSResourceRecord.m \ OFRPDNSResourceRecord.m \ OFSOADNSResourceRecord.m \ OFSRVDNSResourceRecord.m \ OFSequencedPacketSocket.m \ OFSocket.m \ OFStreamSocket.m \ OFSystemInfo+NetworkInterfaces.m \ OFTCPSocket.m \ OFTLSStream.m \ OFTXTDNSResourceRecord.m \ OFUDPSocket.m \ OFURIDNSResourceRecord.m \ ${USE_SRCS_APPLETALK} \ ${USE_SRCS_IPX} \ ${USE_SRCS_SCTP} \ ${USE_SRCS_UNIX_SOCKETS} SRCS_APPLETALK = OFDDPSocket.m SRCS_IPX = OFIPXSocket.m \ OFSPXSocket.m \ OFSPXStreamSocket.m SRCS_SCTP = OFSCTPSocket.m SRCS_UNIX_SOCKETS = OFUNIXDatagramSocket.m \ OFUNIXStreamSocket.m SRCS_SUBPROCESSES = OFSubprocess.m SRCS_THREADS = OFCondition.m \ OFMutex.m \ OFPlainCondition.m \ OFPlainMutex.m \ OFPlainThread.m \ OFRecursiveMutex.m \ OFTLSKey.m |
︙ | ︙ | |||
175 176 177 178 179 180 181 | ObjFW.h \ macros.h \ objfw-defs.h \ platform.h \ ${USE_INCLUDES_ATOMIC} SRCS += OFASPrintF.m \ | < < | < > > > > > > > > > | > > > > | < < < < < < < < < < | > > | > | | > > > | 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | ObjFW.h \ macros.h \ objfw-defs.h \ platform.h \ ${USE_INCLUDES_ATOMIC} SRCS += OFASPrintF.m \ OFArchiveIRIHandler.m \ OFBase64.m \ OFBitSetCharacterSet.m \ OFCRC16.m \ OFCRC32.m \ OFConcreteArray.m \ OFConcreteColor.m \ OFConcreteCountedSet.m \ OFConcreteData.m \ OFConcreteDate.m \ OFConcreteDictionary.m \ OFConcreteMutableArray.m \ OFConcreteMutableData.m \ OFConcreteMutableDictionary.m \ OFConcreteMutableSet.m \ OFConcreteNumber.m \ OFConcreteSet.m \ OFConcreteSubarray.m \ OFConcreteValue.m \ OFEmbeddedIRIHandler.m \ OFHuffmanTree.m \ OFINIFileSettings.m \ OFInvertedCharacterSet.m \ OFLHADecompressingStream.m \ OFMutableUTF8String.m \ OFRangeCharacterSet.m \ OFSandbox.m \ OFStrFTime.m \ OFStrPTime.m \ OFSubarray.m \ OFSubdata.m \ OFUTF8String.m \ ${LIBBASES_M} \ ${RUNTIME_ASSOCIATION_M} \ ${RUNTIME_AUTORELEASE_M} \ ${RUNTIME_INSTANCE_M} \ ${UNICODE_M} \ ${USE_SRCS_TAGGED_POINTERS} SRCS_FILES += OFFileIRIHandler.m SRCS_SOCKETS += OFAsyncIPSocketConnector.m \ OFDNSResolverSettings.m \ ${OF_EPOLL_KERNEL_EVENT_OBSERVER_M} \ OFHTTPIRIHandler.m \ OFHostAddressResolver.m \ OFKernelEventObserver.m \ ${OF_KQUEUE_KERNEL_EVENT_OBSERVER_M} \ ${OF_POLL_KERNEL_EVENT_OBSERVER_M} \ ${OF_SELECT_KERNEL_EVENT_OBSERVER_M} \ OFTCPSocketSOCKS5Connector.m SRCS_TAGGED_POINTERS = OFTaggedPointerColor.m \ OFTaggedPointerDate.m \ OFTaggedPointerNumber.m SRCS_WINDOWS += platform/Windows/OFWin32ConsoleStdIOStream.m \ versioninfo.rc OBJS_EXTRA = exceptions/exceptions.a \ encodings/encodings.a \ forwarding/forwarding.a LIB_OBJS_EXTRA = exceptions/exceptions.lib.a \ |
︙ | ︙ | |||
245 246 247 248 249 250 251 | ${LIBS} LIBS := -Lruntime ${RUNTIME_LIBS} ${REEXPORT_RUNTIME} ${LIBS} RCFLAGS = --use-temp-file \ -DOBJFW_LIB_MAJOR=${OBJFW_LIB_MAJOR} \ -DOBJFW_LIB_MINOR=${OBJFW_LIB_MINOR} \ -DOBJFW_LIB_VERSION=\"${OBJFW_LIB_MAJOR}.${OBJFW_LIB_MINOR}\" \ -DOBJFW_SHARED_LIB=\"${OBJFW_SHARED_LIB}\" | > > > > > > > > | 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | ${LIBS} LIBS := -Lruntime ${RUNTIME_LIBS} ${REEXPORT_RUNTIME} ${LIBS} RCFLAGS = --use-temp-file \ -DOBJFW_LIB_MAJOR=${OBJFW_LIB_MAJOR} \ -DOBJFW_LIB_MINOR=${OBJFW_LIB_MINOR} \ -DOBJFW_LIB_VERSION=\"${OBJFW_LIB_MAJOR}.${OBJFW_LIB_MINOR}\" \ -DOBJFW_SHARED_LIB=\"${OBJFW_SHARED_LIB}\" uninstall-extra: for i in platform/GCC4 platform/GCC4.7 platform/PowerPC platform/macOS \ platform/x86 platform ""; do \ if test -d ${DESTDIR}${includedir}/${includesubdir}/$$i; then \ rmdir ${DESTDIR}${includedir}/${includesubdir}/$$i; \ fi; \ done |
Added src/OFAAAADNSResourceRecord.h version [a5488a265d].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFDNSResourceRecord.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFAAAADNSResourceRecord \ * OFDNSResourceRecord.h ObjFW/OFDNSResourceRecord.h * * @brief A class representing a DNS resource record. */ OF_SUBCLASSING_RESTRICTED @interface OFAAAADNSResourceRecord: OFDNSResourceRecord { OFSocketAddress _address; } /** * @brief The IPv6 address of the resource record. */ @property (readonly, nonatomic) const OFSocketAddress *address; - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFAAAADNSResourceRecord with the * specified name, class, address and time to live. * * @param name The name for the resource record * @param address The address for the resource record * @param TTL The time to live for the resource record * @return An initialized OFAAAADNSResourceRecord */ - (instancetype)initWithName: (OFString *)name address: (const OFSocketAddress *)address TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END |
Added src/OFAAAADNSResourceRecord.m version [1e9052e833].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFAAAADNSResourceRecord.h" @implementation OFAAAADNSResourceRecord - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } - (instancetype)initWithName: (OFString *)name address: (const OFSocketAddress *)address TTL: (uint32_t)TTL { self = [super initWithName: name DNSClass: OFDNSClassIN recordType: OFDNSRecordTypeAAAA TTL: TTL]; _address = *address; return self; } - (const OFSocketAddress *)address { return &_address; } - (bool)isEqual: (id)object { OFAAAADNSResourceRecord *record; if (object == self) return true; if (![object isKindOfClass: [OFAAAADNSResourceRecord class]]) return false; record = object; if (record->_name != _name && ![record->_name isEqual: _name]) return false; if (record->_DNSClass != _DNSClass) return false; if (record->_recordType != _recordType) return false; if (!OFSocketAddressEqual(&record->_address, &_address)) return false; return true; } - (unsigned long)hash { unsigned long hash; OFHashInit(&hash); OFHashAddHash(&hash, _name.hash); OFHashAddByte(&hash, _DNSClass >> 8); OFHashAddByte(&hash, _DNSClass); OFHashAddByte(&hash, _recordType >> 8); OFHashAddByte(&hash, _recordType); OFHashAddHash(&hash, OFSocketAddressHash(&_address)); OFHashFinalize(&hash); return hash; } - (OFString *)description { return [OFString stringWithFormat: @"<%@:\n" @"\tName = %@\n" @"\tAddress = %@\n" @"\tTTL = %" PRIu32 "\n" @">", self.className, _name, OFSocketAddressString(&_address), _TTL]; } @end |
Added src/OFADNSResourceRecord.h version [bb9bbbbb01].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFDNSResourceRecord.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFADNSResourceRecord OFDNSResourceRecord.h ObjFW/OFDNSResourceRecord.h * * @brief A class representing an A DNS resource record. */ OF_SUBCLASSING_RESTRICTED @interface OFADNSResourceRecord: OFDNSResourceRecord { OFSocketAddress _address; } /** * @brief The IPv4 address of the resource record. */ @property (readonly, nonatomic) const OFSocketAddress *address; - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFADNSResourceRecord with the * specified name, class, address and time to live. * * @param name The name for the resource record * @param address The address for the resource record * @param TTL The time to live for the resource record * @return An initialized OFADNSResourceRecord */ - (instancetype)initWithName: (OFString *)name address: (const OFSocketAddress *)address TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END |
Added src/OFADNSResourceRecord.m version [82d49868e9].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFADNSResourceRecord.h" @implementation OFADNSResourceRecord - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } - (instancetype)initWithName: (OFString *)name address: (const OFSocketAddress *)address TTL: (uint32_t)TTL { self = [super initWithName: name DNSClass: OFDNSClassIN recordType: OFDNSRecordTypeA TTL: TTL]; _address = *address; return self; } - (const OFSocketAddress *)address { return &_address; } - (bool)isEqual: (id)object { OFADNSResourceRecord *record; if (object == self) return true; if (![object isKindOfClass: [OFADNSResourceRecord class]]) return false; record = object; if (record->_name != _name && ![record->_name isEqual: _name]) return false; if (record->_DNSClass != _DNSClass) return false; if (record->_recordType != _recordType) return false; if (!OFSocketAddressEqual(&record->_address, &_address)) return false; return true; } - (unsigned long)hash { unsigned long hash; OFHashInit(&hash); OFHashAddHash(&hash, _name.hash); OFHashAddByte(&hash, _DNSClass >> 8); OFHashAddByte(&hash, _DNSClass); OFHashAddByte(&hash, _recordType >> 8); OFHashAddByte(&hash, _recordType); OFHashAddHash(&hash, OFSocketAddressHash(&_address)); OFHashFinalize(&hash); return hash; } - (OFString *)description { return [OFString stringWithFormat: @"<%@:\n" @"\tName = %@\n" @"\tAddress = %@\n" @"\tTTL = %" PRIu32 "\n" @">", self.className, _name, OFSocketAddressString(&_address), _TTL]; } @end |
Modified src/OFASPrintF.h from [090f42d33a] to [e19f4f7099].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS #endif #ifndef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS |
︙ | ︙ |
Modified src/OFASPrintF.m from [882db55cea] to [e60e10983b].
1 | /* | | | | | | > > > > | < > | | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdarg.h> #include <stdbool.h> #ifdef HAVE_WCHAR_H # include <wchar.h> #endif #if defined(HAVE_ASPRINTF_L) || defined(HAVE_USELOCALE) # include <locale.h> #endif #ifdef HAVE_XLOCALE_H # include <xlocale.h> #endif #ifdef OF_HAVE_SYS_TYPES_H # include <sys/types.h> #endif #import "OFASPrintF.h" #import "OFString.h" #import "OFLocale.h" #import "OFInitializationFailedException.h" #define maxSubformatLen 64 |
︙ | ︙ | |||
79 80 81 82 83 84 85 | lengthModifierZ, lengthModifierT, lengthModifierCapitalL } lengthModifier; bool useLocale; }; | | | 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | lengthModifierZ, lengthModifierT, lengthModifierCapitalL } lengthModifier; bool useLocale; }; #if defined(HAVE_ASPRINTF_L) || defined(HAVE_USELOCALE) static locale_t cLocale; OF_CONSTRUCTOR() { if ((cLocale = newlocale(LC_ALL_MASK, "C", NULL)) == NULL) @throw [OFInitializationFailedException exception]; } |
︙ | ︙ | |||
373 374 375 376 377 378 379 | } static bool formatConversionSpecifierState(struct Context *ctx) { char *tmp = NULL; int tmpLen = 0; | | | 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 | } static bool formatConversionSpecifierState(struct Context *ctx) { char *tmp = NULL; int tmpLen = 0; #if !defined(HAVE_ASPRINTF_L) && !defined(HAVE_USELOCALE) OFString *point; #endif if (!appendSubformat(ctx, ctx->format + ctx->i, 1)) return false; switch (ctx->format[ctx->i]) { |
︙ | ︙ | |||
544 545 546 547 548 549 550 | case 'g': case 'G': case 'a': case 'A': switch (ctx->lengthModifier) { case lengthModifierNone: case lengthModifierL: | | > > > > > > > | > > > > > > > | | | | | 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 | case 'g': case 'G': case 'a': case 'A': switch (ctx->lengthModifier) { case lengthModifierNone: case lengthModifierL: #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: #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; } #if !defined(HAVE_ASPRINTF_L) && !defined(HAVE_USELOCALE) if (tmpLen == -1) return false; /* * If there's no asprintf_l and no uselocale, we have no other * choice than to use this ugly hack to replace the locale's * decimal point back to ".". */ point = [OFLocale decimalSeparator]; if (!ctx->useLocale && point != nil && ![point isEqual: @"."]) { void *pool = objc_autoreleasePoolPush(); char *tmp2; |
︙ | ︙ |
Modified src/OFApplication.h from [d7b817478b] to [757b90a7e1].
1 | /* | | | | | | > > > > | < > | > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include <signal.h> #import "OFObject.h" #import "OFNotification.h" OF_ASSUME_NONNULL_BEGIN /** @file */ @class OFArray OF_GENERIC(ObjectType); @class OFDictionary OF_GENERIC(KeyType, ObjectType); @class OFMutableArray OF_GENERIC(ObjectType); @class OFMutableDictionary OF_GENERIC(KeyType, ObjectType); @class OFSandbox; @class OFString; /** * @brief A notification that will be sent when the application did finish * launching. */ extern const OFNotificationName OFApplicationDidFinishLaunchingNotification; /** * @brief A notification that will be sent when the application will terminate. */ extern const OFNotificationName OFApplicationWillTerminateNotification; /** * @brief Specify the class to be used as the application delegate. |
︙ | ︙ | |||
47 48 49 50 51 52 53 | * @interface MyAppDelegate: OFObject <OFApplicationDelegate> * @end * * // In MyAppDelegate.m: * OF_APPLICATION_DELEGATE(MyAppDelegate) * * @implementation MyAppDelegate | | | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | * @interface MyAppDelegate: OFObject <OFApplicationDelegate> * @end * * // In MyAppDelegate.m: * OF_APPLICATION_DELEGATE(MyAppDelegate) * * @implementation MyAppDelegate * - (void)applicationDidFinishLaunching: (OFNotification *)notification * { * [OFApplication terminate]; * } * @end * @endcode */ #define OF_APPLICATION_DELEGATE(class_) \ |
︙ | ︙ | |||
77 78 79 80 81 82 83 84 | * * @note Signals are not available on AmigaOS! */ @protocol OFApplicationDelegate <OFObject> /** * @brief A method which is called when the application was initialized and is * running now. */ | > > > | > > > | | 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | * * @note Signals are not available on AmigaOS! */ @protocol OFApplicationDelegate <OFObject> /** * @brief A method which is called when the application was initialized and is * running now. * * @param notification A notification with name * OFApplicationDidFinishLaunchingNotification */ - (void)applicationDidFinishLaunching: (OFNotification *)notification; @optional /** * @brief A method which is called when the application will terminate. * * @param notification A notification with name * OFApplicationWillTerminateNotification */ - (void)applicationWillTerminate: (OFNotification *)notification; /** * @brief A method which is called when the application received a SIGINT. * * @warning You are not allowed to send any messages inside this method, as * message dispatching is not signal-safe! You are only allowed to do * signal-safe operations like setting a variable or calling a |
︙ | ︙ | |||
149 150 151 152 153 154 155 | * @brief A class which represents the application as an object. * * In order to create a new OFApplication, you should create a class conforming * to the optional @ref OFApplicationDelegate protocol and put * `OF_APPLICATION_DELEGATE(NameOfYourClass)` in the .m file of that class. * * When the application is about to be terminated, | | | 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | * @brief A class which represents the application as an object. * * In order to create a new OFApplication, you should create a class conforming * to the optional @ref OFApplicationDelegate protocol and put * `OF_APPLICATION_DELEGATE(NameOfYourClass)` in the .m file of that class. * * When the application is about to be terminated, * @ref OFApplicationDelegate#applicationWillTerminate: will be called on the * delegate and an @ref OFApplicationWillTerminateNotification will be sent. */ OF_SUBCLASSING_RESTRICTED @interface OFApplication: OFObject { OFString *_programName; OFArray OF_GENERIC(OFString *) *_arguments; |
︙ | ︙ |
Modified src/OFApplication.m from [1a4d3713d8] to [f87eabe4cc].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdio.h> #include <stdlib.h> #include <string.h> |
︙ | ︙ | |||
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | #endif #import "OFLocale.h" #import "OFNotificationCenter.h" #import "OFPair.h" #import "OFRunLoop+Private.h" #import "OFRunLoop.h" #import "OFSandbox.h" #import "OFString.h" #import "OFSystemInfo.h" #import "OFThread+Private.h" #import "OFThread.h" #import "OFActivateSandboxFailedException.h" #import "OFInvalidArgumentException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #if defined(OF_MACOS) # include <crt_externs.h> #elif defined(OF_WINDOWS) # include <windows.h> extern int _CRT_glob; extern void __wgetmainargs(int *, wchar_t ***, wchar_t ***, int, int *); #elif defined(OF_AMIGAOS) # include <proto/exec.h> # include <proto/dos.h> #elif !defined(OF_IOS) extern char **environ; #endif #ifdef OF_PSP # include <pspkerneltypes.h> # include <psploadexec.h> | > > > | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | #endif #import "OFLocale.h" #import "OFNotificationCenter.h" #import "OFPair.h" #import "OFRunLoop+Private.h" #import "OFRunLoop.h" #import "OFSandbox.h" #import "OFStdIOStream.h" #import "OFString.h" #import "OFSystemInfo.h" #import "OFThread+Private.h" #import "OFThread.h" #import "OFActivateSandboxFailedException.h" #import "OFInvalidArgumentException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #if defined(OF_MACOS) # include <crt_externs.h> #elif defined(OF_WINDOWS) # include <windows.h> extern int _CRT_glob; extern void __wgetmainargs(int *, wchar_t ***, wchar_t ***, int, int *); #elif defined(OF_AMIGAOS) # define Class IntuitionClass # include <proto/exec.h> # include <proto/dos.h> # undef Class #elif !defined(OF_IOS) extern char **environ; #endif #ifdef OF_PSP # include <pspkerneltypes.h> # include <psploadexec.h> |
︙ | ︙ | |||
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | andArgumentValues: (char **[])argv andWideArgumentCount: (int)wargc andWideArgumentValues: (wchar_t *[])wargv; #endif - (void)of_run; @end const OFNotificationName OFApplicationWillTerminateNotification = @"OFApplicationWillTerminateNotification"; static OFApplication *app = nil; static void atexitHandler(void) { id <OFApplicationDelegate> delegate = app.delegate; | > > < | | | | > > < < < < < | > > > > | 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | andArgumentValues: (char **[])argv andWideArgumentCount: (int)wargc andWideArgumentValues: (wchar_t *[])wargv; #endif - (void)of_run; @end const OFNotificationName OFApplicationDidFinishLaunchingNotification = @"OFApplicationDidFinishLaunchingNotification"; const OFNotificationName OFApplicationWillTerminateNotification = @"OFApplicationWillTerminateNotification"; static OFApplication *app = nil; static void atexitHandler(void) { id <OFApplicationDelegate> delegate = app.delegate; OFNotification *notification = [OFNotification notificationWithName: OFApplicationWillTerminateNotification object: app]; if ([delegate respondsToSelector: @selector(applicationWillTerminate:)]) [delegate applicationWillTerminate: notification]; [delegate release]; [[OFNotificationCenter defaultCenter] postNotification: notification]; #if defined(OF_HAVE_THREADS) && defined(OF_HAVE_SOCKETS) && \ defined(OF_AMIGAOS) && !defined(OF_MORPHOS) OFSocketDeinit(); #endif } int OFApplicationMain(int *argc, char **argv[], id <OFApplicationDelegate> delegate) { [OFLocale currentLocale]; app = [[OFApplication alloc] of_init]; #ifdef OF_WINDOWS if ([OFSystemInfo isWindowsNT]) { wchar_t **wargv, **wenvp; int wargc, si = 0; __wgetmainargs(&wargc, &wargv, &wenvp, _CRT_glob, &si); [app of_setArgumentCount: argc andArgumentValues: argv andWideArgumentCount: wargc andWideArgumentValues: wargv]; } else #endif [app of_setArgumentCount: argc andArgumentValues: argv]; |
︙ | ︙ | |||
256 257 258 259 260 261 262 | if ([tmp hasPrefix: @"="]) { objc_autoreleasePoolPop(pool); continue; } pos = [tmp rangeOfString: @"="].location; if (pos == OFNotFound) { | < | | | 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | if ([tmp hasPrefix: @"="]) { objc_autoreleasePoolPop(pool); continue; } pos = [tmp rangeOfString: @"="].location; if (pos == OFNotFound) { OFLog(@"Warning: Invalid environment " "variable: %@", tmp); continue; } key = [tmp substringToIndex: pos]; value = [tmp substringFromIndex: pos + 1]; [_environment setObject: value forKey: key]; |
︙ | ︙ | |||
298 299 300 301 302 303 304 | if ([tmp hasPrefix: @"="]) { objc_autoreleasePoolPop(pool); continue; } pos = [tmp rangeOfString: @"="].location; if (pos == OFNotFound) { | < | | | 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | if ([tmp hasPrefix: @"="]) { objc_autoreleasePoolPop(pool); continue; } pos = [tmp rangeOfString: @"="].location; if (pos == OFNotFound) { OFLog(@"Warning: Invalid environment " "variable: %@", tmp); continue; } key = [tmp substringToIndex: pos]; value = [tmp substringFromIndex: pos + 1]; [_environment setObject: value forKey: key]; |
︙ | ︙ | |||
392 393 394 395 396 397 398 | for (; *env != NULL; env++) { void *pool = objc_autoreleasePoolPush(); OFString *key, *value; char *sep; if ((sep = strchr(*env, '=')) == NULL) { | | | | 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 | for (; *env != NULL; env++) { void *pool = objc_autoreleasePoolPush(); OFString *key, *value; char *sep; if ((sep = strchr(*env, '=')) == NULL) { OFLog(@"Warning: Invalid environment " "variable: %s", *env); continue; } key = [OFString stringWithCString: *env encoding: encoding length: sep - *env]; |
︙ | ︙ | |||
576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 | #undef REGISTER_SIGNAL } - (void)of_run { void *pool = objc_autoreleasePoolPush(); OFRunLoop *runLoop; #ifdef OF_HAVE_THREADS [OFThread of_createMainThread]; runLoop = [OFRunLoop currentRunLoop]; #else runLoop = [[[OFRunLoop alloc] init] autorelease]; #endif [OFRunLoop of_setMainRunLoop: runLoop]; objc_autoreleasePoolPop(pool); /* * Note: runLoop is still valid after the release of the pool, as * of_setMainRunLoop: retained it. However, we only have a weak * reference to it now, whereas we had a strong reference before. */ pool = objc_autoreleasePoolPush(); | > > > > > > > > | > | 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 | #undef REGISTER_SIGNAL } - (void)of_run { void *pool = objc_autoreleasePoolPush(); OFRunLoop *runLoop; OFNotification *notification; #ifdef OF_HAVE_THREADS [OFThread of_createMainThread]; runLoop = [OFRunLoop currentRunLoop]; #else runLoop = [[[OFRunLoop alloc] init] autorelease]; #endif [OFRunLoop of_setMainRunLoop: runLoop]; objc_autoreleasePoolPop(pool); /* * Note: runLoop is still valid after the release of the pool, as * of_setMainRunLoop: retained it. However, we only have a weak * reference to it now, whereas we had a strong reference before. */ pool = objc_autoreleasePoolPush(); notification = [OFNotification notificationWithName: OFApplicationDidFinishLaunchingNotification object: app]; [[OFNotificationCenter defaultCenter] postNotification: notification]; [_delegate applicationDidFinishLaunching: notification]; objc_autoreleasePoolPop(pool); [runLoop run]; } - (void)terminate { |
︙ | ︙ |
Modified src/OFArchiveEntry.h from [70aea150d9] to [ce610002c7].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFString.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ |
Renamed and modified src/OFArchiveURIHandler.h [7c81cf8db2] to src/OFArchiveIRIHandler.h [4bae7280e5].
1 | /* | | | | | | > > > > | < > | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "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 |
Renamed and modified src/OFArchiveURIHandler.m [010e8050b6] to src/OFArchiveIRIHandler.m [0a5674435c].
1 | /* | | | | | | > > > > | < > | | > | | | | | | | | | | | | | | | | > > | | | | | | | | | > > > > > > > > > > > > > > > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #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 "OFZooArchive.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: mode]; stream = [OFGZIPStream streamWithStream: stream mode: mode]; goto end; } percentEncodedPath = IRI.percentEncodedPath; pos = [percentEncodedPath rangeOfString: @"!" options: OFStringSearchBackwards].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: mode]; 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: mode]; 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: mode]; stream = [archive streamForReadingFile: path]; } else if ([scheme isEqual: @"zoo"]) { OFZooArchive *archive = [OFZooArchive archiveWithIRI: archiveIRI mode: mode]; OFZooArchiveEntry *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 @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; } |
︙ | ︙ | |||
168 169 170 171 172 173 174 | - (bool)characterIsMember: (OFUnichar)character { return (character != '!' && _characterIsMember(_characterSet, @selector(characterIsMember:), character)); } @end | | | | | < < < < | | 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | - (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(); OFOnce(&onceControl, initPathAllowedCharacters); pathInArchive = [pathInArchive stringByAddingPercentEncodingWithAllowedCharacters: pathAllowedCharacters]; ret.percentEncodedPath = [OFString stringWithFormat: @"%@!%@", archiveIRI.string, pathInArchive]; [ret makeImmutable]; objc_autoreleasePoolPop(pool); return ret; } |
Modified src/OFArray+Private.h from [9a457a5499] to [05809a33b9].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFArray.h" OF_ASSUME_NONNULL_BEGIN OF_DIRECT_MEMBERS |
︙ | ︙ |
Modified src/OFArray.h from [f90f803ff9] to [b7cc4fb107].
1 | /* | | | | | | > > > > | < > | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS #endif #ifndef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS #endif #include <stdarg.h> #import "OFObject.h" #import "OFCollection.h" #import "OFEnumerator.h" #import "OFJSONRepresentation.h" #import "OFMessagePackRepresentation.h" OF_ASSUME_NONNULL_BEGIN /** @file */ |
︙ | ︙ | |||
98 99 100 101 102 103 104 | * @class OFArray OFArray.h ObjFW/OFArray.h * * @brief An abstract class for storing objects in an array. * * @note Subclasses must implement @ref count and @ref objectAtIndex:. */ @interface OFArray OF_GENERIC(ObjectType): OFObject <OFCopying, | | | 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | * @class OFArray OFArray.h ObjFW/OFArray.h * * @brief An abstract class for storing objects in an array. * * @note Subclasses must implement @ref count and @ref objectAtIndex:. */ @interface OFArray OF_GENERIC(ObjectType): OFObject <OFCopying, OFMutableCopying, OFCollection, OFJSONRepresentation, OFMessagePackRepresentation> #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) # define ObjectType id #endif /** * @brief The objects of the array as a C array. * |
︙ | ︙ | |||
181 182 183 184 185 186 187 188 189 190 191 192 193 194 | * @param objects A C array of objects * @param count The length of the C array * @return A new autoreleased OFArray */ + (instancetype)arrayWithObjects: (ObjectType const _Nonnull *_Nonnull)objects count: (size_t)count; /** * @brief Initializes an OFArray with the specified object. * * @param object An object * @return An initialized OFArray */ - (instancetype)initWithObject: (ObjectType)object; | > > > > > > > | 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | * @param objects A C array of objects * @param count The length of the C array * @return A new autoreleased OFArray */ + (instancetype)arrayWithObjects: (ObjectType const _Nonnull *_Nonnull)objects count: (size_t)count; /** * @brief Initializes an OFArray with no objects. * * @return An initialized OFArray */ - (instancetype)init OF_DESIGNATED_INITIALIZER; /** * @brief Initializes an OFArray with the specified object. * * @param object An object * @return An initialized OFArray */ - (instancetype)initWithObject: (ObjectType)object; |
︙ | ︙ | |||
224 225 226 227 228 229 230 | * the specified length. * * @param objects A C array of objects * @param count The length of the C array * @return An initialized OFArray */ - (instancetype)initWithObjects: (ObjectType const _Nonnull *_Nonnull)objects | | | 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | * the specified length. * * @param objects A C array of objects * @param count The length of the C array * @return An initialized OFArray */ - (instancetype)initWithObjects: (ObjectType const _Nonnull *_Nonnull)objects count: (size_t)count OF_DESIGNATED_INITIALIZER; /** * @brief Returns an OFEnumerator to enumerate through all objects of the array. * * @return An OFEnumerator to enumerate through all objects of the array */ - (OFEnumerator OF_GENERIC(ObjectType) *)objectEnumerator; |
︙ | ︙ | |||
401 402 403 404 405 406 407 408 409 410 411 412 413 414 | * @param options The options to use when sorting the array * @return A sorted copy of the array */ - (OFArray OF_GENERIC(ObjectType) *) sortedArrayUsingSelector: (SEL)selector options: (OFArraySortOptions)options; #ifdef OF_HAVE_BLOCKS /** * @brief Returns a copy of the array sorted using the specified selector and * options. * * @param comparator The comparator to use to sort the array * @param options The options to use when sorting the array | > > > > > > > > > > > > > > | 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 | * @param options The options to use when sorting the array * @return A sorted copy of the array */ - (OFArray OF_GENERIC(ObjectType) *) sortedArrayUsingSelector: (SEL)selector options: (OFArraySortOptions)options; /** * @brief Returns a copy of the array sorted using the specified function and * options. * * @param compare The function to use to sort the array * @param context Context passed to the function to compare * @param options The options to use when sorting the array * @return A sorted copy of the array */ - (OFArray OF_GENERIC(ObjectType) *) sortedArrayUsingFunction: (OFCompareFunction)compare context: (nullable void *)context options: (OFArraySortOptions)options; #ifdef OF_HAVE_BLOCKS /** * @brief Returns a copy of the array sorted using the specified selector and * options. * * @param comparator The comparator to use to sort the array * @param options The options to use when sorting the array |
︙ | ︙ |
Modified src/OFArray.m from [c89de989b4] to [26f7548752].
1 | /* | | | | | | > > > > | < > | < < | < > > > > > > | | | | | | | < < < < | < < < < | < | < < | < < < < < < < < | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdarg.h> #include <stdlib.h> #import "OFArray.h" #import "OFArray+Private.h" #import "OFConcreteArray.h" #import "OFData.h" #import "OFNull.h" #import "OFString.h" #import "OFSubarray.h" #import "OFEnumerationMutationException.h" #import "OFInvalidArgumentException.h" #import "OFOutOfRangeException.h" static struct { Class isa; } placeholder; @interface OFArray () - (OFString *) of_JSONRepresentationWithOptions: (OFJSONRepresentationOptions)options depth: (size_t)depth; @end @interface OFPlaceholderArray: OFArray @end @implementation OFPlaceholderArray #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)init { return (id)[[OFConcreteArray alloc] init]; } - (instancetype)initWithObject: (id)object { return (id)[[OFConcreteArray alloc] initWithObject: object]; } - (instancetype)initWithObjects: (id)firstObject, ... { id ret; va_list arguments; va_start(arguments, firstObject); ret = [[OFConcreteArray alloc] initWithObject: firstObject arguments: arguments]; va_end(arguments); return ret; } - (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments { return (id)[[OFConcreteArray alloc] initWithObject: firstObject arguments: arguments]; } - (instancetype)initWithArray: (OFArray *)array { return (id)[[OFConcreteArray alloc] initWithArray: array]; } - (instancetype)initWithObjects: (id const *)objects count: (size_t)count { return (id)[[OFConcreteArray alloc] initWithObjects: objects count: count]; } #ifdef __clang__ # pragma clang diagnostic pop #endif OF_SINGLETON_METHODS @end @implementation OFArray + (void)initialize { if (self == [OFArray class]) object_setClass((id)&placeholder, [OFPlaceholderArray class]); } + (instancetype)alloc { if (self == [OFArray class]) return (id)&placeholder; |
︙ | ︙ | |||
162 163 164 165 166 167 168 | { return [[[self alloc] initWithObjects: objects count: count] autorelease]; } - (instancetype)init { | | > < < < < < | | > > | > | > > | > > > | > > > > > | > > > > > > > > > > > > > > > > > > > | > > > | > > > > > | > > > > > > > > > > > > > > > > | | < < < > | 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | { return [[[self alloc] initWithObjects: objects count: count] autorelease]; } - (instancetype)init { if ([self isMemberOfClass: [OFArray class]] || [self isMemberOfClass: [OFMutableArray class]]) { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @throw e; } abort(); } return [super init]; } - (instancetype)initWithObject: (id)object { return [self initWithObjects: &object count: 1]; } - (instancetype)initWithObjects: (id)firstObject, ... { id ret; va_list arguments; va_start(arguments, firstObject); ret = [self initWithObject: firstObject arguments: arguments]; va_end(arguments); return ret; } - (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments { size_t count = 1; va_list argumentsCopy; id *objects; if (firstObject == nil) return [self init]; va_copy(argumentsCopy, arguments); while (va_arg(argumentsCopy, id) != nil) count++; @try { objects = OFAllocMemory(count, sizeof(id)); } @catch (id e) { [self release]; @throw e; } @try { objects[0] = firstObject; for (size_t i = 1; i < count; i++) { objects[i] = va_arg(arguments, id); OFEnsure(objects[i] != nil); } self = [self initWithObjects: objects count: count]; } @finally { OFFreeMemory(objects); } return self; } - (instancetype)initWithArray: (OFArray *)array { id *objects; size_t count; @try { count = array.count; objects = OFAllocMemory(count, sizeof(id)); [array getObjects: objects inRange: OFMakeRange(0, count)]; } @catch (id e) { [self release]; @throw e; } @try { self = [self initWithObjects: objects count: count]; } @finally { OFFreeMemory(objects); } return self; } #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)initWithObjects: (id const *)objects count: (size_t)count { OF_INVALID_INIT_METHOD } #ifdef __clang__ # pragma clang diagnostic pop #endif - (size_t)count { OF_UNRECOGNIZED_SELECTOR } - (void)getObjects: (id *)buffer inRange: (OFRange)range |
︙ | ︙ | |||
373 374 375 376 377 378 379 | id *buffer; if (range.length > SIZE_MAX - range.location || range.location + range.length < self.count) @throw [OFOutOfRangeException exception]; if (![self isKindOfClass: [OFMutableArray class]]) | > | | 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 | id *buffer; if (range.length > SIZE_MAX - range.location || range.location + range.length < self.count) @throw [OFOutOfRangeException exception]; if (![self isKindOfClass: [OFMutableArray class]]) return [[[OFSubarray alloc] initWithArray: self range: range] autorelease]; buffer = OFAllocMemory(range.length, sizeof(*buffer)); @try { [self getObjects: buffer inRange: range]; ret = [OFArray arrayWithObjects: buffer count: range.length]; } @finally { |
︙ | ︙ | |||
546 547 548 549 550 551 552 | objc_autoreleasePoolPop(pool); [ret makeImmutable]; return [ret autorelease]; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < | 585 586 587 588 589 590 591 592 593 594 595 596 597 598 | objc_autoreleasePoolPop(pool); [ret makeImmutable]; return [ret autorelease]; } - (OFString *)JSONRepresentation { return [self of_JSONRepresentationWithOptions: 0 depth: 0]; } - (OFString *)JSONRepresentationWithOptions: (OFJSONRepresentationOptions)options |
︙ | ︙ | |||
685 686 687 688 689 690 691 | child = [object messagePackRepresentation]; [data addItems: child.items count: child.count]; objc_autoreleasePoolPop(pool2); } | | | 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 | child = [object messagePackRepresentation]; [data addItems: child.items count: child.count]; objc_autoreleasePoolPop(pool2); } OFAssert(i == count); [data makeImmutable]; objc_autoreleasePoolPop(pool); return data; } |
︙ | ︙ | |||
723 724 725 726 727 728 729 730 731 732 733 734 735 736 | options: (OFArraySortOptions)options { OFMutableArray *new = [[self mutableCopy] autorelease]; [new sortUsingSelector: selector options: options]; [new makeImmutable]; return new; } #ifdef OF_HAVE_BLOCKS - (OFArray *)sortedArrayUsingComparator: (OFComparator)comparator options: (OFArraySortOptions)options { OFMutableArray *new = [[self mutableCopy] autorelease]; [new sortUsingComparator: comparator options: options]; | > > > > > > > > > > | 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 | options: (OFArraySortOptions)options { OFMutableArray *new = [[self mutableCopy] autorelease]; [new sortUsingSelector: selector options: options]; [new makeImmutable]; return new; } - (OFArray *)sortedArrayUsingFunction: (OFCompareFunction)compare context: (void *)context options: (OFArraySortOptions)options { OFMutableArray *new = [[self mutableCopy] autorelease]; [new sortUsingFunction: compare context: context options: options]; [new makeImmutable]; return new; } #ifdef OF_HAVE_BLOCKS - (OFArray *)sortedArrayUsingComparator: (OFComparator)comparator options: (OFArraySortOptions)options { OFMutableArray *new = [[self mutableCopy] autorelease]; [new sortUsingComparator: comparator options: options]; |
︙ | ︙ | |||
747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 | return new; } - (int)countByEnumeratingWithState: (OFFastEnumerationState *)state objects: (id *)objects count: (int)count { OFRange range = OFMakeRange(state->state, count); if (range.length > SIZE_MAX - range.location) @throw [OFOutOfRangeException exception]; if (range.location + range.length > self.count) range.length = self.count - range.location; [self getObjects: objects inRange: range]; if (range.location + range.length > ULONG_MAX) @throw [OFOutOfRangeException exception]; state->state = (unsigned long)(range.location + range.length); state->itemsPtr = objects; | > | | 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 | return new; } - (int)countByEnumeratingWithState: (OFFastEnumerationState *)state objects: (id *)objects count: (int)count { static unsigned long dummyMutations; OFRange range = OFMakeRange(state->state, count); if (range.length > SIZE_MAX - range.location) @throw [OFOutOfRangeException exception]; if (range.location + range.length > self.count) range.length = self.count - range.location; [self getObjects: objects inRange: range]; if (range.location + range.length > ULONG_MAX) @throw [OFOutOfRangeException exception]; state->state = (unsigned long)(range.location + range.length); state->itemsPtr = objects; state->mutationsPtr = &dummyMutations; return (int)range.length; } - (OFEnumerator *)objectEnumerator { return [[[OFArrayEnumerator alloc] initWithArray: self |
︙ | ︙ |
Modified src/OFAsyncIPSocketConnector.h from [00aff2415e] to [45b199b3c1].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFDNSResolver.h" #import "OFRunLoop.h" #import "OFRunLoop+Private.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ |
Modified src/OFAsyncIPSocketConnector.m from [329d7de863] to [cdf0c8e6b2].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #import "OFAsyncIPSocketConnector.h" |
︙ | ︙ |
Modified src/OFAtomic.h from [25c89d25b5] to [98096c2476].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include <stdlib.h> #import "macros.h" #ifndef OF_HAVE_ATOMIC_OPS |
︙ | ︙ | |||
165 166 167 168 169 170 171 | } static OF_INLINE void OFReleaseMemoryBarrier(void) { /* nop */ } | | | 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | } static OF_INLINE void OFReleaseMemoryBarrier(void) { /* nop */ } #elif (defined(OF_AMD64) || defined(OF_X86)) && defined(__GNUC__) # import "platform/x86/OFAtomic.h" #elif defined(OF_POWERPC) && defined(__GNUC__) && !defined(__APPLE_CC__) && \ !defined(OF_AIX) # import "platform/PowerPC/OFAtomic.h" #elif defined(OF_HAVE_ATOMIC_BUILTINS) # import "platform/GCC4.7/OFAtomic.h" #elif defined(OF_HAVE_SYNC_BUILTINS) # import "platform/GCC4/OFAtomic.h" #elif defined(OF_HAVE_OSATOMIC) # import "platform/macOS/OFAtomic.h" #else # error No atomic operations available! #endif |
Modified src/OFBase64.h from [14838b60d0] to [c69641ab41].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS #endif #ifndef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS |
︙ | ︙ |
Modified src/OFBase64.m from [7cc5f21d9d] to [1bbfb68f90].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFBase64.h" #import "OFString.h" #import "OFData.h" |
︙ | ︙ |
Modified src/OFBitSetCharacterSet.h from [6dd7022dff] to [9f3314050d].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFCharacterSet.h" OF_ASSUME_NONNULL_BEGIN @interface OFBitSetCharacterSet: OFCharacterSet |
︙ | ︙ |
Modified src/OFBitSetCharacterSet.m from [d65aed83c7] to [b1982608cc].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFBitSetCharacterSet.h" #import "OFString.h" |
︙ | ︙ |
Modified src/OFBlock.h from [ae09bf0d6b] to [5e518a0a02].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/OFBlock.m from [0c18ed18b9] to [e8eabc79e2].
1 | /* | | | | | | > > > > | < > | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdint.h> #include <stdlib.h> #include <string.h> #import "OFBlock.h" #ifdef OF_HAVE_ATOMIC_OPS # import "OFAtomic.h" #endif #ifdef OF_HAVE_THREADS # import "OFPlainMutex.h" #endif #import "OFString.h" #import "OFAllocFailedException.h" #import "OFInitializationFailedException.h" #if defined(OF_OBJFW_RUNTIME) # import "runtime/private.h" #endif |
︙ | ︙ | |||
159 160 161 162 163 164 165 | struct class _NSConcreteGlobalBlock_metaclass; struct class _NSConcreteMallocBlock_metaclass; # endif #endif static struct { Class isa; | | | | | < | 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | struct class _NSConcreteGlobalBlock_metaclass; struct class _NSConcreteMallocBlock_metaclass; # endif #endif static struct { Class isa; } allocFailedException; #ifndef OF_HAVE_ATOMIC_OPS # define numSpinlocks 8 /* needs to be a power of 2 */ # define SPINLOCK_HASH(p) ((uintptr_t)p >> 4) & (numSpinlocks - 1) static OFSpinlock blockSpinlocks[numSpinlocks]; static OFSpinlock byrefSpinlocks[numSpinlocks]; #endif void * _Block_copy(const void *block_) { struct Block *block = (struct Block *)block_; if ([(id)block isMemberOfClass: (Class)&_NSConcreteStackBlock]) { struct Block *copy; if ((copy = malloc(block->descriptor->size)) == NULL) { object_setClass((id)&allocFailedException, [OFAllocFailedException class]); @throw (OFAllocFailedException *)&allocFailedException; } memcpy(copy, block, block->descriptor->size); object_setClass((id)copy, (Class)&_NSConcreteMallocBlock); copy->flags++; if (block->flags & OFBlockHasCopyDispose) |
︙ | ︙ | |||
266 267 268 269 270 271 272 | struct Byref *src = (struct Byref *)src_; struct Byref **dst = (struct Byref **)dst_; src = src->forwarding; if ((src->flags & OFBlockRefCountMask) == 0) { if ((*dst = malloc(src->size)) == NULL) { | | | | | 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | struct Byref *src = (struct Byref *)src_; struct Byref **dst = (struct Byref **)dst_; src = src->forwarding; if ((src->flags & OFBlockRefCountMask) == 0) { if ((*dst = malloc(src->size)) == NULL) { object_setClass((id)&allocFailedException, [OFAllocFailedException class]); @throw (OFAllocFailedException *) &allocFailedException; } memcpy(*dst, src, src->size); (*dst)->flags = ((*dst)->flags & ~OFBlockRefCountMask) | 1; (*dst)->forwarding = *dst; |
︙ | ︙ |
Added src/OFCNAMEDNSResourceRecord.h version [8c5d9d3a48].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFDNSResourceRecord.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFCNAMEDNSResourceRecord \ * OFDNSResourceRecord.h ObjFW/OFDNSResourceRecord.h * * @brief A class representing a CNAME DNS resource record. */ OF_SUBCLASSING_RESTRICTED @interface OFCNAMEDNSResourceRecord: OFDNSResourceRecord { OFString *_alias; } /** * @brief The alias of the resource record. */ @property (readonly, nonatomic) OFString *alias; - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFCNAMEDNSResourceRecord with the * specified name, class, alias and time to live. * * @param name The name for the resource record * @param DNSClass The class code for the resource record * @param alias The alias for the resource record * @param TTL The time to live for the resource record * @return An initialized OFCNAMEDNSResourceRecord */ - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass alias: (OFString *)alias TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END |
Added src/OFCNAMEDNSResourceRecord.m version [cf92a76b34].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFCNAMEDNSResourceRecord.h" @implementation OFCNAMEDNSResourceRecord @synthesize alias = _alias; - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass alias: (OFString *)alias TTL: (uint32_t)TTL { self = [super initWithName: name DNSClass: DNSClass recordType: OFDNSRecordTypeCNAME TTL: TTL]; @try { _alias = [alias copy]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_alias release]; [super dealloc]; } - (bool)isEqual: (id)object { OFCNAMEDNSResourceRecord *record; if (object == self) return true; if (![object isKindOfClass: [OFCNAMEDNSResourceRecord class]]) return false; record = object; if (record->_name != _name && ![record->_name isEqual: _name]) return false; if (record->_DNSClass != _DNSClass) return false; if (record->_recordType != _recordType) return false; if (record->_alias != _alias && ![record->_alias isEqual: _alias]) return false; return true; } - (unsigned long)hash { unsigned long hash; OFHashInit(&hash); OFHashAddHash(&hash, _name.hash); OFHashAddByte(&hash, _DNSClass >> 8); OFHashAddByte(&hash, _DNSClass); OFHashAddByte(&hash, _recordType >> 8); OFHashAddByte(&hash, _recordType); OFHashAddHash(&hash, _alias.hash); OFHashFinalize(&hash); return hash; } - (OFString *)description { return [OFString stringWithFormat: @"<%@:\n" @"\tName = %@\n" @"\tClass = %@\n" @"\tAlias = %@\n" @"\tTTL = %" PRIu32 "\n" @">", self.className, _name, OFDNSClassName(_DNSClass), _alias, _TTL]; } @end |
Modified src/OFCRC16.h from [6bd74791bc] to [3f16abe72b].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS #endif #ifndef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS |
︙ | ︙ |
Modified src/OFCRC16.m from [ba4e599142] to [84c30fd412].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFCRC16.h" static const uint16_t CRC16Magic = 0xA001; |
︙ | ︙ |
Modified src/OFCRC32.h from [139d8dccac] to [8d31bcaac4].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS #endif #ifndef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS |
︙ | ︙ |
Modified src/OFCRC32.m from [b50ad38210] to [9efe742312].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFCRC32.h" static const uint32_t CRC32Magic = 0xEDB88320; |
︙ | ︙ |
Modified src/OFCharacterSet.h from [20dd965c47] to [90927d9aea].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFString.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ |
Modified src/OFCharacterSet.m from [76e8828364] to [61b9142dd2].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFCharacterSet.h" #import "OFBitSetCharacterSet.h" #import "OFInvertedCharacterSet.h" |
︙ | ︙ | |||
52 53 54 55 56 57 58 | } - (instancetype)initWithRange: (OFRange)range { return (id)[[OFRangeCharacterSet alloc] initWithRange: range]; } | < < < < | < < < < < < < < < < < < < | < | | | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | } - (instancetype)initWithRange: (OFRange)range { return (id)[[OFRangeCharacterSet alloc] initWithRange: range]; } OF_SINGLETON_METHODS @end @implementation OFCharacterSet + (void)initialize { if (self == [OFCharacterSet class]) object_setClass((id)&placeholder, [OFPlaceholderCharacterSet class]); } + (instancetype)alloc { if (self == [OFCharacterSet class]) return (id)&placeholder; |
︙ | ︙ | |||
147 148 149 150 151 152 153 | { return [[[OFInvertedCharacterSet alloc] initWithCharacterSet: self] autorelease]; } @end @implementation OFWhitespaceCharacterSet | < < < < < < < < < < < < < < < < < < < | 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | { return [[[OFInvertedCharacterSet alloc] initWithCharacterSet: self] autorelease]; } @end @implementation OFWhitespaceCharacterSet - (bool)characterIsMember: (OFUnichar)character { switch (character) { case 0x0009: case 0x0020: case 0x00A0: case 0x1680: |
︙ | ︙ | |||
192 193 194 195 196 197 198 199 | case 0x205F: case 0x3000: return true; default: return false; } } @end | > > | 159 160 161 162 163 164 165 166 167 168 | case 0x205F: case 0x3000: return true; default: return false; } } OF_SINGLETON_METHODS @end |
Modified src/OFCollection.h from [8d8461caff] to [d38e82bc8e].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFEnumerator.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/OFColor.h from [bce9432d45] to [3615b89131].
1 | /* | | | | | | > > > > | < > | < < < < < > | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFColor OFColor.h ObjFW/OFColor.h * * @brief A class for storing a color. */ @interface OFColor: OFObject #ifdef OF_HAVE_CLASS_PROPERTIES @property (class, readonly, nonatomic) OFColor *black; @property (class, readonly, nonatomic) OFColor *silver; @property (class, readonly, nonatomic) OFColor *gray; @property (class, readonly, nonatomic) OFColor *grey OF_DEPRECATED(ObjFW, 1, 1, "Use gray instead"); @property (class, readonly, nonatomic) OFColor *white; @property (class, readonly, nonatomic) OFColor *maroon; @property (class, readonly, nonatomic) OFColor *red; @property (class, readonly, nonatomic) OFColor *purple; @property (class, readonly, nonatomic) OFColor *fuchsia; @property (class, readonly, nonatomic) OFColor *green; @property (class, readonly, nonatomic) OFColor *lime; |
︙ | ︙ | |||
77 78 79 80 81 82 83 | * The RGBA value is (0.75, 0.75, 0.75, 1). * * @return The HTML color `silver` */ + (OFColor *)silver; /** | | > > > > > > > > > > > | | | 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | * The RGBA value is (0.75, 0.75, 0.75, 1). * * @return The HTML color `silver` */ + (OFColor *)silver; /** * @brief Returns the HTML color `gray`. * * The RGBA value is (0.5, 0.5, 0.5, 1). * * @return The HTML color `gray` */ + (OFColor *)gray; /** * @brief Returns the HTML color `gray`. * * @deprecated Use @ref gray instead. * * The RGBA value is (0.5, 0.5, 0.5, 1). * * @return The HTML color `gray` */ + (OFColor *)grey OF_DEPRECATED(ObjFW, 1, 1, "Use gray instead"); /** * @brief Returns the HTML color `white`. * * The RGBA value is (1, 1, 1, 1). * * @return The HTML color `white` |
︙ | ︙ |
Modified src/OFColor.m from [ff82ab6aae] to [d2e720bd5b].
1 | /* | | | | | | > > > > | < > | > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | | > > > > > < | | < < < < < | < < < < | | | | > > > | > > > > > > > | | | | > > > | > > > > | | < < < < > > | > > | | > > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <math.h> #import "OFColor.h" #import "OFConcreteColor.h" #import "OFOnce.h" #import "OFString.h" #import "OFTaggedPointerColor.h" @interface OFPlaceholderColor: OFColor @end @interface OFConcreteColorSingleton: OFConcreteColor @end static struct { Class isa; } placeholder; #ifdef OF_OBJFW_RUNTIME static const float allowedImprecision = 0.0000001; #endif @implementation OFPlaceholderColor - (instancetype)initWithRed: (float)red green: (float)green blue: (float)blue alpha: (float)alpha { #ifdef OF_OBJFW_RUNTIME uint8_t redInt = roundf(red * 255); uint8_t greenInt = roundf(green * 255); uint8_t blueInt = roundf(blue * 255); if (fabsf(red * 255 - redInt) < allowedImprecision && fabsf(green * 255 - greenInt) < allowedImprecision && fabsf(blue * 255 - blueInt) < allowedImprecision && alpha == 1) { id ret = [OFTaggedPointerColor colorWithRed: redInt green: greenInt blue: blueInt]; if (ret != nil) return ret; } #endif return (id)[[OFConcreteColor alloc] initWithRed: red green: green blue: blue alpha: alpha]; } OF_SINGLETON_METHODS @end @implementation OFConcreteColorSingleton OF_SINGLETON_METHODS @end @implementation OFColor + (void)initialize { if (self == [OFColor class]) object_setClass((id)&placeholder, [OFPlaceholderColor class]); } + (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 = [[OFConcreteColorSingleton alloc] \ initWithRed: redValue \ green: greenValue \ blue: blueValue \ alpha: 1]; \ } \ \ + (OFColor *)name \ { \ static OFOnceControl onceControl = OFOnceControlInitValue; \ OFOnce(&onceControl, initPredefinedColor_##name); \ \ return name##Color; \ } PREDEFINED_COLOR(black, 0.00f, 0.00f, 0.00f) PREDEFINED_COLOR(silver, 0.75f, 0.75f, 0.75f) PREDEFINED_COLOR(gray, 0.50f, 0.50f, 0.50f) PREDEFINED_COLOR(white, 1.00f, 1.00f, 1.00f) PREDEFINED_COLOR(maroon, 0.50f, 0.00f, 0.00f) PREDEFINED_COLOR(red, 1.00f, 0.00f, 0.00f) PREDEFINED_COLOR(purple, 0.50f, 0.00f, 0.50f) PREDEFINED_COLOR(fuchsia, 1.00f, 0.00f, 1.00f) PREDEFINED_COLOR(green, 0.00f, 0.50f, 0.00f) PREDEFINED_COLOR(lime, 0.00f, 1.00f, 0.00f) PREDEFINED_COLOR(olive, 0.50f, 0.50f, 0.00f) PREDEFINED_COLOR(yellow, 1.00f, 1.00f, 0.00f) PREDEFINED_COLOR(navy, 0.00f, 0.00f, 0.50f) PREDEFINED_COLOR(blue, 0.00f, 0.00f, 1.00f) PREDEFINED_COLOR(teal, 0.00f, 0.50f, 0.50f) PREDEFINED_COLOR(aqua, 0.00f, 1.00f, 1.00f) + (OFColor *)grey { return [self gray]; } + (instancetype)colorWithRed: (float)red green: (float)green blue: (float)blue alpha: (float)alpha { return [[[self alloc] initWithRed: red green: green blue: blue alpha: alpha] autorelease]; } - (instancetype)initWithRed: (float)red green: (float)green blue: (float)blue alpha: (float)alpha { if ([self isMemberOfClass: [OFColor class]]) { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @throw e; } abort(); } return [super init]; } - (bool)isEqual: (id)object { OFColor *other; float red, green, blue, alpha; float otherRed, otherGreen, otherBlue, otherAlpha; if (object == self) return true; if (![object isKindOfClass: [OFColor class]]) return false; other = object; [self getRed: &red green: &green blue: &blue alpha: &alpha]; [other getRed: &otherRed green: &otherGreen blue: &otherBlue alpha: &otherAlpha]; if (otherRed != red) return false; if (otherGreen != green) return false; if (otherBlue != blue) return false; if (otherAlpha != alpha) return false; return true; } - (unsigned long)hash { float red, green, blue, alpha; unsigned long hash; float tmp; [self getRed: &red green: &green blue: &blue alpha: &alpha]; OFHashInit(&hash); tmp = OFToLittleEndianFloat(red); for (uint_fast8_t i = 0; i < sizeof(float); i++) OFHashAddByte(&hash, ((char *)&tmp)[i]); tmp = OFToLittleEndianFloat(green); for (uint_fast8_t i = 0; i < sizeof(float); i++) OFHashAddByte(&hash, ((char *)&tmp)[i]); tmp = OFToLittleEndianFloat(blue); for (uint_fast8_t i = 0; i < sizeof(float); i++) OFHashAddByte(&hash, ((char *)&tmp)[i]); tmp = OFToLittleEndianFloat(alpha); for (uint_fast8_t i = 0; i < sizeof(float); i++) OFHashAddByte(&hash, ((char *)&tmp)[i]); OFHashFinalize(&hash); return hash; } - (void)getRed: (float *)red green: (float *)green blue: (float *)blue alpha: (float *)alpha { OF_UNRECOGNIZED_SELECTOR } - (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 |
Renamed and modified src/OFAdjacentArray.h [9facc27db0] to src/OFConcreteArray.h [5960b54901].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFArray.h" OF_ASSUME_NONNULL_BEGIN @class OFMutableData; @interface OFConcreteArray: OFArray { OFMutableData *_array; } @end OF_ASSUME_NONNULL_END |
Renamed and modified src/OFAdjacentArray.m [e305e33733] to src/OFConcreteArray.m [5f573cdeaa].
1 | /* | | | | | | > > > > | < > | | | | | < | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdarg.h> #import "OFConcreteArray.h" #import "OFConcreteMutableArray.h" #import "OFConcreteSubarray.h" #import "OFData.h" #import "OFString.h" #import "OFEnumerationMutationException.h" #import "OFInvalidArgumentException.h" #import "OFOutOfRangeException.h" @implementation OFConcreteArray - (instancetype)init { self = [super init]; @try { _array = [[OFMutableData alloc] initWithItemSize: sizeof(id)]; } @catch (id e) { |
︙ | ︙ | |||
122 123 124 125 126 127 128 | } return self; } - (instancetype)initWithObjects: (id const *)objects count: (size_t)count { | | > > < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | } return self; } - (instancetype)initWithObjects: (id const *)objects count: (size_t)count { self = [super init]; @try { bool ok = true; for (size_t i = 0; i < count; i++) { if (objects[i] == nil) ok = false; [objects[i] retain]; } if (!ok) @throw [OFInvalidArgumentException exception]; _array = [[OFMutableData alloc] initWithItemSize: sizeof(id) capacity: count]; [_array addItems: objects count: count]; } @catch (id e) { for (size_t i = 0; i < count; i++) [objects[i] release]; [self release]; @throw e; } return self; } - (size_t)count { return _array.count; } |
︙ | ︙ | |||
263 264 265 266 267 268 269 | @throw [OFOutOfRangeException exception]; if ([self isKindOfClass: [OFMutableArray class]]) return [OFArray arrayWithObjects: (id *)_array.items + range.location count: range.length]; | > | | | | 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | @throw [OFOutOfRangeException exception]; if ([self isKindOfClass: [OFMutableArray class]]) return [OFArray arrayWithObjects: (id *)_array.items + range.location count: range.length]; return [[[OFConcreteSubarray alloc] initWithArray: self range: range] autorelease]; } - (bool)isEqual: (id)object { OFArray *otherArray; id const *objects, *otherObjects; size_t count; if (object == self) return true; if (![object isKindOfClass: [OFConcreteArray class]] && ![object isKindOfClass: [OFConcreteMutableArray class]]) return [super isEqual: object]; otherArray = object; count = _array.count; if (count != otherArray.count) |
︙ | ︙ | |||
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | return hash; } - (int)countByEnumeratingWithState: (OFFastEnumerationState *)state objects: (id *)objects count: (int)count_ { size_t count = _array.count; if (count > INT_MAX) /* * Use the implementation from OFArray, which is slower, but can * enumerate in chunks. */ return [super countByEnumeratingWithState: state objects: objects count: count_]; if (state->state >= count) return 0; state->state = (unsigned long)count; state->itemsPtr = (id *)_array.items; | > | | 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 | return hash; } - (int)countByEnumeratingWithState: (OFFastEnumerationState *)state objects: (id *)objects count: (int)count_ { static unsigned long dummyMutations; size_t count = _array.count; if (count > INT_MAX) /* * Use the implementation from OFArray, which is slower, but can * enumerate in chunks. */ return [super countByEnumeratingWithState: state objects: objects count: count_]; if (state->state >= count) return 0; state->state = (unsigned long)count; state->itemsPtr = (id *)_array.items; state->mutationsPtr = &dummyMutations; return (int)count; } #ifdef OF_HAVE_BLOCKS - (void)enumerateObjectsUsingBlock: (OFArrayEnumerationBlock)block { |
︙ | ︙ |
Added src/OFConcreteColor.h version [754de7e694].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFColor.h" OF_ASSUME_NONNULL_BEGIN @interface OFConcreteColor: OFColor { float _red, _green, _blue, _alpha; } @end OF_ASSUME_NONNULL_END |
Added src/OFConcreteColor.m version [0d96845149].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFConcreteColor.h" #import "OFInvalidArgumentException.h" @implementation OFConcreteColor - (instancetype)initWithRed: (float)red green: (float)green blue: (float)blue alpha: (float)alpha { self = [super init]; @try { if (red < 0.0 || red > 1.0 || green < 0.0 || green > 1.0 || blue < 0.0 || blue > 1.0 || alpha < 0.0 || alpha > 1.0) @throw [OFInvalidArgumentException exception]; _red = red; _green = green; _blue = blue; _alpha = alpha; } @catch (id e) { [self release]; @throw e; } return self; } - (void)getRed: (float *)red green: (float *)green blue: (float *)blue alpha: (float *)alpha { *red = _red; *green = _green; *blue = _blue; if (alpha != NULL) *alpha = _alpha; } @end |
Renamed and modified src/OFCountedMapTableSet.h [1da95cb48f] to src/OFConcreteCountedSet.h [9b4fe5f377].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFCountedSet.h" OF_ASSUME_NONNULL_BEGIN @class OFMapTable; @interface OFConcreteCountedSet: OFCountedSet { OFMapTable *_mapTable; } @end OF_ASSUME_NONNULL_END |
Renamed and modified src/OFCountedMapTableSet.m [d7ae224517] to src/OFConcreteCountedSet.m [f2a709e493].
1 | /* | | | | | | > > > > | < > | | | | < | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFConcreteCountedSet.h" #import "OFArray.h" #import "OFConcreteMutableSet.h" #import "OFMapTable.h" #import "OFString.h" #import "OFXMLAttribute.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFEnumerationMutationException.h" #import "OFOutOfRangeException.h" @implementation OFConcreteCountedSet + (void)initialize { if (self == [OFConcreteCountedSet class]) [self inheritMethodsFromClass: [OFConcreteMutableSet class]]; } - (instancetype)initWithSet: (OFSet *)set { self = [self init]; @try { |
︙ | ︙ | |||
110 111 112 113 114 115 116 | while ((object = va_arg(arguments, id)) != nil) [self addObject: object]; } @catch (id e) { [self release]; @throw e; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | while ((object = va_arg(arguments, id)) != nil) [self addObject: object]; } @catch (id e) { [self release]; @throw e; } return self; } - (size_t)countForObject: (id)object { return (size_t)(uintptr_t)[_mapTable objectForKey: object]; } |
︙ | ︙ |
Added src/OFConcreteData.h version [e053dd0249].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFData.h" OF_ASSUME_NONNULL_BEGIN @interface OFConcreteData: OFData { unsigned char *_Nullable _items; size_t _capacity, _count, _itemSize; bool _freeWhenDone; } @end OF_ASSUME_NONNULL_END |
Added src/OFConcreteData.m version [3f11c622a1].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <limits.h> #include <string.h> #import "OFConcreteData.h" #import "OFInvalidArgumentException.h" #import "OFOutOfRangeException.h" @implementation OFConcreteData - (instancetype)init { return [self initWithItemSize: 1]; } - (instancetype)initWithItemSize: (size_t)itemSize { self = [super init]; @try { if (itemSize == 0) @throw [OFInvalidArgumentException exception]; _itemSize = itemSize; _freeWhenDone = true; } @catch (id e) { [self release]; @throw e; } return self; } - (instancetype)initWithItems: (const void *)items count: (size_t)count itemSize: (size_t)itemSize { self = [super init]; @try { if (itemSize == 0) @throw [OFInvalidArgumentException exception]; _items = OFAllocMemory(count, itemSize); _capacity = _count = count; _itemSize = itemSize; _freeWhenDone = true; memcpy(_items, items, count * itemSize); } @catch (id e) { [self release]; @throw e; } return self; } - (instancetype)initWithItemsNoCopy: (void *)items count: (size_t)count itemSize: (size_t)itemSize freeWhenDone: (bool)freeWhenDone { self = [super init]; @try { if (itemSize == 0) @throw [OFInvalidArgumentException exception]; _items = (unsigned char *)items; _capacity = _count = count; _itemSize = itemSize; _freeWhenDone = freeWhenDone; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { if (_freeWhenDone) OFFreeMemory(_items); [super dealloc]; } - (size_t)count { return _count; } - (size_t)itemSize { return _itemSize; } - (const void *)items { return _items; } @end |
Added src/OFConcreteDate.h version [e36defe5b8].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFDate.h" OF_ASSUME_NONNULL_BEGIN @interface OFConcreteDate: OFDate { OFTimeInterval _seconds; } @end OF_ASSUME_NONNULL_END |
Added src/OFConcreteDate.m version [cefe253370].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFConcreteDate.h" @implementation OFConcreteDate - (instancetype)initWithTimeIntervalSince1970: (OFTimeInterval)seconds { self = [super initWithTimeIntervalSince1970: seconds]; _seconds = seconds; return self; } - (OFTimeInterval)timeIntervalSince1970 { return _seconds; } @end |
Renamed and modified src/OFMapTableDictionary.h [23bbcf2cb0] to src/OFConcreteDictionary.h [5100464eb6].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFDictionary.h" OF_ASSUME_NONNULL_BEGIN @class OFMapTable; @class OFMapTableEnumerator; @interface OFConcreteDictionary: OFDictionary { OFMapTable *_mapTable; } - (instancetype)initWithCapacity: (size_t)capacity; @end |
︙ | ︙ |
Renamed and modified src/OFMapTableDictionary.m [3e7005d616] to src/OFConcreteDictionary.m [46f4740c40].
1 | /* | | | | | | > > > > | < > | < | | | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFConcreteDictionary.h" #import "OFArray.h" #import "OFConcreteMutableDictionary.h" #import "OFMapTable+Private.h" #import "OFMapTable.h" #import "OFString.h" #import "OFEnumerationMutationException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" static void * copy(void *object) |
︙ | ︙ | |||
68 69 70 71 72 73 74 | static const OFMapTableFunctions objectFunctions = { .retain = retain, .release = release, .hash = hash, .equal = equal }; | | | 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | static const OFMapTableFunctions objectFunctions = { .retain = retain, .release = release, .hash = hash, .equal = equal }; @implementation OFConcreteDictionary - (instancetype)init { return [self initWithCapacity: 0]; } - (instancetype)initWithCapacity: (size_t)capacity { |
︙ | ︙ | |||
98 99 100 101 102 103 104 | - (instancetype)initWithDictionary: (OFDictionary *)dictionary { size_t count; if (dictionary == nil) return [self init]; | | | | | | 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | - (instancetype)initWithDictionary: (OFDictionary *)dictionary { size_t count; if (dictionary == nil) return [self init]; if ([dictionary isKindOfClass: [OFConcreteDictionary class]] || [dictionary isKindOfClass: [OFConcreteMutableDictionary class]]) { self = [super init]; @try { OFConcreteDictionary *dictionary_ = (OFConcreteDictionary *)dictionary; _mapTable = [dictionary_->_mapTable copy]; } @catch (id e) { [self release]; @throw e; } |
︙ | ︙ | |||
228 229 230 231 232 233 234 | [self release]; @throw e; } return self; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | | | | 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | [self release]; @throw e; } return self; } - (void)dealloc { [_mapTable release]; [super dealloc]; } - (id)objectForKey: (id)key { return [_mapTable objectForKey: key]; } - (size_t)count { return _mapTable.count; } - (bool)isEqual: (id)object { OFConcreteDictionary *dictionary; if (object == self) return true; if (![object isKindOfClass: [OFConcreteDictionary class]] && ![object isKindOfClass: [OFConcreteMutableDictionary class]]) return [super isEqual: object]; dictionary = (OFConcreteDictionary *)object; return [dictionary->_mapTable isEqual: _mapTable]; } - (bool)containsObject: (id)object { return [_mapTable containsObject: object]; |
︙ | ︙ | |||
342 343 344 345 346 347 348 | OFMapTableEnumerator *enumerator; void **keyPtr; size_t i; i = 0; enumerator = [_mapTable keyEnumerator]; while ((keyPtr = [enumerator nextObject]) != NULL) { | | | 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | OFMapTableEnumerator *enumerator; void **keyPtr; size_t i; i = 0; enumerator = [_mapTable keyEnumerator]; while ((keyPtr = [enumerator nextObject]) != NULL) { OFAssert(i < count); keys[i++] = (id)*keyPtr; } objc_autoreleasePoolPop(pool); ret = [OFArray arrayWithObjects: keys count: count]; |
︙ | ︙ | |||
375 376 377 378 379 380 381 | OFMapTableEnumerator *enumerator; void **objectPtr; size_t i; i = 0; enumerator = [_mapTable objectEnumerator]; while ((objectPtr = [enumerator nextObject]) != NULL) { | | | 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | OFMapTableEnumerator *enumerator; void **objectPtr; size_t i; i = 0; enumerator = [_mapTable objectEnumerator]; while ((objectPtr = [enumerator nextObject]) != NULL) { OFAssert(i < count); objects[i++] = (id)*objectPtr; } objc_autoreleasePoolPop(pool); ret = [OFArray arrayWithObjects: objects count: count]; |
︙ | ︙ |
Renamed and modified src/OFMutableAdjacentArray.h [def2b8877c] to src/OFConcreteMutableArray.h [bf78f9afe6].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFArray.h" OF_ASSUME_NONNULL_BEGIN @class OFMutableData; @interface OFConcreteMutableArray: OFMutableArray { OFMutableData *_array; unsigned long _mutations; } @end OF_ASSUME_NONNULL_END |
Renamed and modified src/OFMutableAdjacentArray.m [7ff7f8969c] to src/OFConcreteMutableArray.m [e72b0d5b82].
1 | /* | | | | | | > > > > | < > | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "OFConcreteMutableArray.h" #import "OFConcreteArray.h" #import "OFArray+Private.h" #import "OFData.h" #import "OFEnumerationMutationException.h" #import "OFInvalidArgumentException.h" #import "OFOutOfRangeException.h" @implementation OFConcreteMutableArray + (void)initialize { if (self == [OFConcreteMutableArray class]) [self inheritMethodsFromClass: [OFConcreteArray class]]; } - (instancetype)initWithCapacity: (size_t)capacity { self = [super init]; @try { |
︙ | ︙ | |||
374 375 376 377 378 379 380 | } } } #endif - (void)makeImmutable { | | | 378 379 380 381 382 383 384 385 386 387 | } } } #endif - (void)makeImmutable { object_setClass(self, [OFConcreteArray class]); } @end |
Added src/OFConcreteMutableData.h version [9ddedfbd10].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFMutableData.h" OF_ASSUME_NONNULL_BEGIN @interface OFConcreteMutableData: OFMutableData { unsigned char *_Nullable _items; size_t _capacity, _count, _itemSize; bool _freeWhenDone; } @end OF_ASSUME_NONNULL_END |
Added src/OFConcreteMutableData.m version [6993f8c0dc].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <limits.h> #include <string.h> #import "OFConcreteMutableData.h" #import "OFConcreteData.h" #import "OFInvalidArgumentException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" @implementation OFConcreteMutableData + (void)initialize { if (self == [OFConcreteMutableData class]) [self inheritMethodsFromClass: [OFConcreteData class]]; } - (instancetype)initWithItemSize: (size_t)itemSize capacity: (size_t)capacity { self = [super init]; @try { if (itemSize == 0) @throw [OFInvalidArgumentException exception]; _items = OFAllocMemory(capacity, itemSize); _itemSize = itemSize; _capacity = capacity; _freeWhenDone = true; } @catch (id e) { [self release]; @throw e; } return self; } - (instancetype)initWithItemsNoCopy: (void *)items count: (size_t)count itemSize: (size_t)itemSize freeWhenDone: (bool)freeWhenDone { self = [self initWithItems: items count: count itemSize: itemSize]; if (freeWhenDone) OFFreeMemory(items); return self; } - (void *)mutableItems { return _items; } - (void)addItem: (const void *)item { if (SIZE_MAX - _count < 1) @throw [OFOutOfRangeException exception]; if (_count + 1 > _capacity) { _items = OFResizeMemory(_items, _count + 1, _itemSize); _capacity = _count + 1; } memcpy(_items + _count * _itemSize, item, _itemSize); _count++; } - (void)addItems: (const void *)items count: (size_t)count { if (count > SIZE_MAX - _count) @throw [OFOutOfRangeException exception]; if (_count + count > _capacity) { _items = OFResizeMemory(_items, _count + count, _itemSize); _capacity = _count + count; } memcpy(_items + _count * _itemSize, items, count * _itemSize); _count += count; } - (void)insertItems: (const void *)items atIndex: (size_t)idx count: (size_t)count { if (count > SIZE_MAX - _count || idx > _count) @throw [OFOutOfRangeException exception]; if (_count + count > _capacity) { _items = OFResizeMemory(_items, _count + count, _itemSize); _capacity = _count + count; } memmove(_items + (idx + count) * _itemSize, _items + idx * _itemSize, (_count - idx) * _itemSize); memcpy(_items + idx * _itemSize, items, count * _itemSize); _count += count; } - (void)increaseCountBy: (size_t)count { if (count > SIZE_MAX - _count) @throw [OFOutOfRangeException exception]; if (_count + count > _capacity) { _items = OFResizeMemory(_items, _count + count, _itemSize); _capacity = _count + count; } memset(_items + _count * _itemSize, '\0', count * _itemSize); _count += count; } - (void)removeItemsInRange: (OFRange)range { if (range.length > SIZE_MAX - range.location || range.location + range.length > _count) @throw [OFOutOfRangeException exception]; memmove(_items + range.location * _itemSize, _items + (range.location + range.length) * _itemSize, (_count - range.location - range.length) * _itemSize); _count -= range.length; @try { _items = OFResizeMemory(_items, _count, _itemSize); _capacity = _count; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ } } - (void)removeLastItem { if (_count == 0) return; _count--; @try { _items = OFResizeMemory(_items, _count, _itemSize); _capacity = _count; } @catch (OFOutOfMemoryException *e) { /* We don't care, as we only made it smaller */ } } - (void)removeAllItems { OFFreeMemory(_items); _items = NULL; _count = 0; _capacity = 0; } - (void)makeImmutable { if (_capacity != _count) { @try { _items = OFResizeMemory(_items, _count, _itemSize); _capacity = _count; } @catch (OFOutOfMemoryException *e) { /* We don't care, as we only made it smaller */ } } object_setClass(self, [OFConcreteData class]); } @end |
Renamed and modified src/OFMutableMapTableDictionary.h [e3ea116447] to src/OFConcreteMutableDictionary.h [fb80aa15d4].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFDictionary.h" OF_ASSUME_NONNULL_BEGIN @class OFMapTable; @interface OFConcreteMutableDictionary: OFMutableDictionary { OFMapTable *_mapTable; } @end OF_ASSUME_NONNULL_END |
Renamed and modified src/OFMutableMapTableDictionary.m [eda929d7fd] to src/OFConcreteMutableDictionary.m [30e324a7ed].
1 | /* | | | | | | > > > > | < > | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "OFConcreteMutableDictionary.h" #import "OFConcreteDictionary.h" #import "OFMapTable.h" #import "OFEnumerationMutationException.h" #import "OFOutOfRangeException.h" @implementation OFConcreteMutableDictionary + (void)initialize { if (self == [OFConcreteMutableDictionary class]) [self inheritMethodsFromClass: [OFConcreteDictionary class]]; } - (void)setObject: (id)object forKey: (id)key { [_mapTable setObject: object forKey: key]; } |
︙ | ︙ | |||
59 60 61 62 63 64 65 | exceptionWithObject: self]; } } #endif - (void)makeImmutable { | | | 63 64 65 66 67 68 69 70 71 72 | exceptionWithObject: self]; } } #endif - (void)makeImmutable { object_setClass(self, [OFConcreteDictionary class]); } @end |
Renamed and modified src/OFMutableMapTableSet.h [ee94211a1c] to src/OFConcreteMutableSet.h [118a0eb46e].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFMutableSet.h" OF_ASSUME_NONNULL_BEGIN @class OFMapTable; @interface OFConcreteMutableSet: OFMutableSet { OFMapTable *_mapTable; } @end OF_ASSUME_NONNULL_END |
Renamed and modified src/OFMutableMapTableSet.m [134371a3b6] to src/OFConcreteMutableSet.m [539a9b4a18].
1 | /* | | | | | | > > > > | < > | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFConcreteMutableSet.h" #import "OFConcreteSet.h" #import "OFMapTable.h" @implementation OFConcreteMutableSet + (void)initialize { if (self == [OFConcreteMutableSet class]) [self inheritMethodsFromClass: [OFConcreteSet class]]; } - (void)addObject: (id)object { [_mapTable setObject: (void *)1 forKey: object]; } - (void)removeObject: (id)object { [_mapTable removeObjectForKey: object]; } - (void)removeAllObjects { [_mapTable removeAllObjects]; } - (void)makeImmutable { object_setClass(self, [OFConcreteSet class]); } @end |
Added src/OFConcreteNumber.h version [6831367bef].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFNumber.h" OF_ASSUME_NONNULL_BEGIN @interface OFConcreteNumber: OFNumber { union { double float_; long long signed_; unsigned long long unsigned_; } _value; char _typeEncoding; } @end OF_ASSUME_NONNULL_END |
Added src/OFConcreteNumber.m version [f478d5383d].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "OFConcreteNumber.h" #import "OFInvalidFormatException.h" static bool isUnsigned(OFNumber *number) { switch (*number.objCType) { case 'B': case 'C': case 'S': case 'I': case 'L': case 'Q': return true; default: return false; } } static bool isSigned(OFNumber *number) { switch (*number.objCType) { case 'c': case 's': case 'i': case 'l': case 'q': return true; default: return false; } } static bool isFloat(OFNumber *number) { switch (*number.objCType) { case 'f': case 'd': return true; default: return false; } } @implementation OFConcreteNumber - (instancetype)initWithBytes: (const void *)bytes objCType: (const char *)objCType { #define CASE(type, method) \ if (strcmp(objCType, @encode(type)) == 0) { \ type value; \ memcpy(&value, bytes, sizeof(type)); \ return [self method value]; \ } CASE(bool, initWithBool:) CASE(signed char, initWithChar:) CASE(short, initWithShort:) CASE(int, initWithInt:) CASE(long, initWithLong:) CASE(long long, initWithLongLong:) CASE(unsigned char, initWithUnsignedChar:) CASE(unsigned short, initWithUnsignedShort:) CASE(unsigned int, initWithUnsignedInt:) CASE(unsigned long, initWithUnsignedLong:) CASE(unsigned long long, initWithUnsignedLongLong:) CASE(float, initWithFloat:) CASE(double, initWithDouble:) [self release]; @throw [OFInvalidFormatException exception]; } - (instancetype)initWithBool: (bool)value { self = [super initWithBytes: &value objCType: @encode(bool)]; _value.unsigned_ = value; _typeEncoding = *@encode(bool); return self; } - (instancetype)initWithChar: (signed char)value { self = [super initWithBytes: &value objCType: @encode(signed char)]; _value.signed_ = value; _typeEncoding = *@encode(signed char); return self; } - (instancetype)initWithShort: (short)value { self = [super initWithBytes: &value objCType: @encode(short)]; _value.signed_ = value; _typeEncoding = *@encode(short); return self; } - (instancetype)initWithInt: (int)value { self = [super initWithBytes: &value objCType: @encode(int)]; _value.signed_ = value; _typeEncoding = *@encode(int); return self; } - (instancetype)initWithLong: (long)value { self = [super initWithBytes: &value objCType: @encode(long)]; _value.signed_ = value; _typeEncoding = *@encode(long); return self; } - (instancetype)initWithLongLong: (long long)value { self = [super initWithBytes: &value objCType: @encode(long long)]; _value.signed_ = value; _typeEncoding = *@encode(long long); return self; } - (instancetype)initWithUnsignedChar: (unsigned char)value { self = [super initWithBytes: &value objCType: @encode(unsigned char)]; _value.unsigned_ = value; _typeEncoding = *@encode(unsigned long); return self; } - (instancetype)initWithUnsignedShort: (unsigned short)value { self = [super initWithBytes: &value objCType: @encode(unsigned short)]; _value.unsigned_ = value; _typeEncoding = *@encode(unsigned short); return self; } - (instancetype)initWithUnsignedInt: (unsigned int)value { self = [super initWithBytes: &value objCType: @encode(unsigned int)]; _value.unsigned_ = value; _typeEncoding = *@encode(unsigned int); return self; } - (instancetype)initWithUnsignedLong: (unsigned long)value { self = [super initWithBytes: &value objCType: @encode(unsigned long)]; _value.unsigned_ = value; _typeEncoding = *@encode(unsigned long); return self; } - (instancetype)initWithUnsignedLongLong: (unsigned long long)value { self = [super initWithBytes: &value objCType: @encode(unsigned long long)]; _value.unsigned_ = value; _typeEncoding = *@encode(unsigned long long); return self; } - (instancetype)initWithFloat: (float)value { self = [super initWithBytes: &value objCType: @encode(float)]; _value.float_ = value; _typeEncoding = *@encode(float); return self; } - (instancetype)initWithDouble: (double)value { self = [super initWithBytes: &value objCType: @encode(double)]; _value.float_ = value; _typeEncoding = *@encode(double); return self; } - (const char *)objCType { return &_typeEncoding; } - (long long)longLongValue { if (isFloat(self)) return _value.float_; else if (isSigned(self)) return _value.signed_; else if (isUnsigned(self)) return _value.unsigned_; else @throw [OFInvalidFormatException exception]; } - (unsigned long long)unsignedLongLongValue { if (isFloat(self)) return _value.float_; else if (isSigned(self)) return _value.signed_; else if (isUnsigned(self)) return _value.unsigned_; else @throw [OFInvalidFormatException exception]; } - (double)doubleValue { if (isFloat(self)) return _value.float_; else if (isSigned(self)) return _value.signed_; else if (isUnsigned(self)) return _value.unsigned_; else @throw [OFInvalidFormatException exception]; } @end |
Renamed and modified src/OFMapTableSet.h [1664d9d036] to src/OFConcreteSet.h [4f22e2594b].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFSet.h" OF_ASSUME_NONNULL_BEGIN @class OFMapTable; @interface OFConcreteSet: OFSet { OFMapTable *_mapTable; } - (instancetype)initWithCapacity: (size_t)capacity; @end |
︙ | ︙ |
Renamed and modified src/OFMapTableSet.m [87bc750df2] to src/OFConcreteSet.m [8ec07b2262].
1 | /* | | | | | | > > > > | < > | | | | | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFConcreteSet.h" #import "OFArray.h" #import "OFConcreteCountedSet.h" #import "OFConcreteMutableSet.h" #import "OFMapTable+Private.h" #import "OFMapTable.h" #import "OFString.h" #import "OFInvalidArgumentException.h" #import "OFEnumerationMutationException.h" static void * retain(void *object) { |
︙ | ︙ | |||
55 56 57 58 59 60 61 | .retain = retain, .release = release, .hash = hash, .equal = equal }; static const OFMapTableFunctions objectFunctions = { NULL }; | | | 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | .retain = retain, .release = release, .hash = hash, .equal = equal }; static const OFMapTableFunctions objectFunctions = { NULL }; @implementation OFConcreteSet - (instancetype)init { return [self initWithCapacity: 0]; } - (instancetype)initWithCapacity: (size_t)capacity { |
︙ | ︙ | |||
177 178 179 180 181 182 183 | [self release]; @throw e; } return self; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | [self release]; @throw e; } return self; } - (void)dealloc { [_mapTable release]; [super dealloc]; } |
︙ | ︙ | |||
230 231 232 233 234 235 236 | return false; return ([_mapTable objectForKey: object] != nil); } - (bool)isEqual: (id)object { | | | | | | 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | return false; return ([_mapTable objectForKey: object] != nil); } - (bool)isEqual: (id)object { OFConcreteSet *set; if (object == self) return true; if (![object isKindOfClass: [OFConcreteSet class]] && ![object isKindOfClass: [OFConcreteMutableSet class]] && ![object isKindOfClass: [OFConcreteCountedSet class]]) return [super isEqual: object]; set = object; return [set->_mapTable isEqual: _mapTable]; } |
︙ | ︙ |
Renamed and modified src/OFAdjacentSubarray.h [08f4f942e1] to src/OFConcreteSubarray.h [393a08ad41].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFSubarray.h" OF_ASSUME_NONNULL_BEGIN @interface OFConcreteSubarray: OFSubarray @end OF_ASSUME_NONNULL_END |
Renamed and modified src/OFAdjacentSubarray.m [76d5c349a9] to src/OFConcreteSubarray.m [2b31d26b5c].
1 | /* | | | | | | > > > > | < > | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFConcreteSubarray.h" #import "OFConcreteArray.h" #import "OFConcreteMutableArray.h" @implementation OFConcreteSubarray - (const id *)objects { return _array.objects + _range.location; } - (bool)isEqual: (id)object { OFArray *otherArray; id const *objects, *otherObjects; if (object == self) return true; if (![object isKindOfClass: [OFConcreteArray class]] && ![object isKindOfClass: [OFConcreteMutableArray class]]) return [super isEqual: object]; otherArray = object; if (_range.length != otherArray.count) return false; |
︙ | ︙ |
Renamed and modified src/OFBytesValue.h [ca1dbf0669] to src/OFConcreteValue.h [ac9952a890].
1 | /* | | | | | | > > > > | < > | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFValue.h" OF_ASSUME_NONNULL_BEGIN @interface OFConcreteValue: OFValue { size_t _size; void *_bytes; char *_objCType; } @end OF_ASSUME_NONNULL_END |
Renamed and modified src/OFBytesValue.m [b331442837] to src/OFConcreteValue.m [8933b62636].
1 | /* | | | | | | > > > > | < > | | > | < < | | < > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFConcreteValue.h" #import "OFMethodSignature.h" #import "OFString.h" #import "OFOutOfRangeException.h" @implementation OFConcreteValue - (instancetype)initWithBytes: (const void *)bytes objCType: (const char *)objCType { self = [super initWithBytes: bytes objCType: objCType]; @try { _size = OFSizeOfTypeEncoding(objCType); _objCType = OFStrDup(objCType); _bytes = OFAllocMemory(1, _size); memcpy(_bytes, bytes, _size); } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { OFFreeMemory(_bytes); OFFreeMemory(_objCType); [super dealloc]; } - (const char *)objCType { return _objCType; } - (void)getValue: (void *)value size: (size_t)size { if (size != _size) @throw [OFOutOfRangeException exception]; memcpy(value, _bytes, _size); |
︙ | ︙ |
Modified src/OFCondition.h from [2de2d56fa5] to [4139cd3063].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFMutex.h" #import "OFPlainCondition.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ | |||
46 47 48 49 50 51 52 | * @note Waiting might have been interrupted by a signal. It is thus recommended * to check the condition again after @ref wait returned! * * @throw OFWaitForConditionFailedException Waiting for the condition failed */ - (void)wait; | | | 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | * @note Waiting might have been interrupted by a signal. It is thus recommended * to check the condition again after @ref wait returned! * * @throw OFWaitForConditionFailedException Waiting for the condition failed */ - (void)wait; #if defined(OF_AMIGAOS) || defined(DOXYGEN) /** * @brief Blocks the current thread until another thread calls @ref signal, * @ref broadcast or an Exec Signal is received. * * @note This is only available on AmigaOS! * * @param signalMask A pointer to a signal mask of Exec Signals to receive. |
︙ | ︙ | |||
73 74 75 76 77 78 79 | * * @param timeInterval The time interval until the timeout is reached * @return Whether the condition has been signaled * @throw OFWaitForConditionFailedException Waiting for the condition failed */ - (bool)waitForTimeInterval: (OFTimeInterval)timeInterval; | | | 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | * * @param timeInterval The time interval until the timeout is reached * @return Whether the condition has been signaled * @throw OFWaitForConditionFailedException Waiting for the condition failed */ - (bool)waitForTimeInterval: (OFTimeInterval)timeInterval; #if defined(OF_AMIGAOS) || defined(DOXYGEN) /** * @brief Blocks the current thread until another thread calls @ref signal, * @ref broadcast, the timeout is reached or an Exec Signal is received. * * @note This is only available on AmigaOS! * * @param timeInterval The time interval until the timeout is reached |
︙ | ︙ | |||
103 104 105 106 107 108 109 | * * @param date The date at which the timeout is reached * @return Whether the condition has been signaled * @throw OFWaitForConditionFailedException Waiting for the condition failed */ - (bool)waitUntilDate: (OFDate *)date; | | | 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | * * @param date The date at which the timeout is reached * @return Whether the condition has been signaled * @throw OFWaitForConditionFailedException Waiting for the condition failed */ - (bool)waitUntilDate: (OFDate *)date; #if defined(OF_AMIGAOS) || defined(DOXYGEN) /** * @brief Blocks the current thread until another thread calls @ref signal, * @ref broadcast, the timeout is reached or an Exec Signal is received. * * @note This is only available on AmigaOS! * * @param date The date at which the timeout is reached |
︙ | ︙ |
Modified src/OFCondition.m from [6291bb097b] to [74d65a81a7].
1 | /* | | | | | | > > > > | < > | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #import "OFCondition.h" #import "OFDate.h" #import "OFString.h" #import "OFBroadcastConditionFailedException.h" #import "OFConditionStillWaitingException.h" #import "OFInitializationFailedException.h" #import "OFSignalConditionFailedException.h" #import "OFWaitForConditionFailedException.h" |
︙ | ︙ |
Modified src/OFConstantString.h from [4428a8bf71] to [db51ac0cae].
1 | /* | | | | | | > | < | < | > | | > | < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFString.h" OF_ASSUME_NONNULL_BEGIN #if !defined(OF_CONSTANT_STRING_M) && \ defined(OF_APPLE_RUNTIME) && !defined(__OBJC2__) # ifdef __cplusplus extern "C" { # endif extern void *_OFConstantStringClassReference; # ifdef __cplusplus } # endif #endif /** * @class OFConstantString OFConstantString.h ObjFW/OFConstantString.h * * @brief A class for storing constant strings using the `@""` literal. */ OF_SUBCLASSING_RESTRICTED @interface OFConstantString: OFString { char *_cString; unsigned int _cStringLength; } @end OF_ASSUME_NONNULL_END |
Modified src/OFConstantString.m from [3adc07df05] to [cde23b7b44].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #define OF_CONSTANT_STRING_M #include "config.h" #include <stdlib.h> |
︙ | ︙ | |||
48 49 50 51 52 53 54 | @implementation OFConstantUTF8String + (instancetype)alloc { OF_UNRECOGNIZED_SELECTOR } | < < < < | < < < < < < < < < < < < < < < < < < | 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | @implementation OFConstantUTF8String + (instancetype)alloc { OF_UNRECOGNIZED_SELECTOR } OF_SINGLETON_METHODS @end @implementation OFConstantString + (void)load { #if defined(OF_APPLE_RUNTIME) && !defined(__OBJC2__) /* |
︙ | ︙ | |||
131 132 133 134 135 136 137 | } + (instancetype)alloc { OF_UNRECOGNIZED_SELECTOR } | < < < < | < < < < < < < < < < < < < < < < < < | 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | } + (instancetype)alloc { OF_UNRECOGNIZED_SELECTOR } OF_SINGLETON_METHODS /* * In all following methods, the constant string is converted to an * OFConstantUTF8String and the message sent again. */ /* From protocol OFCopying */ |
︙ | ︙ | |||
545 546 547 548 549 550 551 | - (OFData *)dataWithEncoding: (OFStringEncoding)encoding { [self finishInitialization]; return [self dataWithEncoding: encoding]; } | < < < < < < < < < < < < < < | 505 506 507 508 509 510 511 512 513 514 515 516 517 518 | - (OFData *)dataWithEncoding: (OFStringEncoding)encoding { [self finishInitialization]; return [self dataWithEncoding: encoding]; } #ifdef OF_WINDOWS - (OFString *)stringByExpandingWindowsEnvironmentStrings { [self finishInitialization]; return self.stringByExpandingWindowsEnvironmentStrings; } #endif |
︙ | ︙ | |||
581 582 583 584 585 586 587 | - (void)writeToFile: (OFString *)path encoding: (OFStringEncoding)encoding { [self finishInitialization]; [self writeToFile: path encoding: encoding]; } #endif | | | | | | 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 | - (void)writeToFile: (OFString *)path encoding: (OFStringEncoding)encoding { [self finishInitialization]; [self writeToFile: path encoding: encoding]; } #endif - (void)writeToIRI: (OFIRI *)IRI { [self finishInitialization]; [self writeToIRI: IRI]; } - (void)writeToIRI: (OFIRI *)IRI encoding: (OFStringEncoding)encoding { [self finishInitialization]; [self writeToIRI: IRI encoding: encoding]; } #ifdef OF_HAVE_BLOCKS - (void)enumerateLinesUsingBlock: (OFStringLineEnumerationBlock)block { [self finishInitialization]; [self enumerateLinesUsingBlock: block]; } #endif @end |
Modified src/OFCountedSet.h from [b22ee9691d] to [cffac6f600].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFSet.h" OF_ASSUME_NONNULL_BEGIN /** @file */ |
︙ | ︙ |
Modified src/OFCountedSet.m from [985e10aa24] to [21cc8322f9].
1 | /* | | | | | | > > > > | < > | | < | | > > > > > > | | | | | | | < < < < < | < < < < | < | < < | < < < < < < < < | > < < < < < < < < < < < < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdlib.h> #import "OFCountedSet.h" #import "OFConcreteCountedSet.h" #import "OFNumber.h" #import "OFString.h" static struct { Class isa; } placeholder; @interface OFPlaceholderCountedSet: OFCountedSet @end @implementation OFPlaceholderCountedSet #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)init { return (id)[[OFConcreteCountedSet alloc] init]; } - (instancetype)initWithSet: (OFSet *)set { return (id)[[OFConcreteCountedSet alloc] initWithSet: set]; } - (instancetype)initWithArray: (OFArray *)array { return (id)[[OFConcreteCountedSet alloc] initWithArray: array]; } - (instancetype)initWithObjects: (id)firstObject, ... { id ret; va_list arguments; va_start(arguments, firstObject); ret = [[OFConcreteCountedSet alloc] initWithObject: firstObject arguments: arguments]; va_end(arguments); return ret; } - (instancetype)initWithObjects: (id const *)objects count: (size_t)count { return (id)[[OFConcreteCountedSet alloc] initWithObjects: objects count: count]; } - (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments { return (id)[[OFConcreteCountedSet alloc] initWithObject: firstObject arguments: arguments]; } #ifdef __clang__ # pragma clang diagnostic pop #endif OF_SINGLETON_METHODS @end @implementation OFCountedSet + (void)initialize { if (self == [OFCountedSet class]) object_setClass((id)&placeholder, [OFPlaceholderCountedSet class]); } + (instancetype)alloc { if (self == [OFCountedSet class]) return (id)&placeholder; return [super alloc]; } - (size_t)countForObject: (id)object { OF_UNRECOGNIZED_SELECTOR } - (OFString *)description { |
︙ | ︙ | |||
173 174 175 176 177 178 179 | } - (id)mutableCopy { return [[OFCountedSet alloc] initWithSet: self]; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | } - (id)mutableCopy { return [[OFCountedSet alloc] initWithSet: self]; } #ifdef OF_HAVE_BLOCKS - (void)enumerateObjectsAndCountUsingBlock: (OFCountedSetEnumerationBlock)block { [self enumerateObjectsUsingBlock: ^ (id object, bool *stop) { block(object, [self countForObject: object], stop); }]; } |
︙ | ︙ |
Modified src/OFCryptographicHash.h from [635d4f982a] to [383dbc1889].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/OFDDPSocket.h from [86e7a28476] to [26b6139e72].
1 | /* | | | | | | > > > > | < > | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFDatagramSocket.h" OF_ASSUME_NONNULL_BEGIN @class OFString; @class OFDictionary OF_GENERIC(KeyType, ObjectType); /** * @protocol OFDDPSocketDelegate OFDDPSocket.h ObjFW/OFDDPSocket.h * * @brief A delegate for OFDDPSocket. */ @protocol OFDDPSocketDelegate <OFDatagramSocketDelegate> |
︙ | ︙ | |||
39 40 41 42 43 44 45 | * @ref OFSocketAddressAppleTalkNode to get the AppleTalk node and * @ref OFSocketAddressAppleTalkPort to get the port (sometimes also called * socket number). * * @note On some systems, packets received with the wrong protocol type just * get filtered by the kernel, however, on other systems, the packet is * queued up and will raise an @ref OFReadFailedException with the | | | 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | * @ref OFSocketAddressAppleTalkNode to get the AppleTalk node and * @ref OFSocketAddressAppleTalkPort to get the port (sometimes also called * socket number). * * @note On some systems, packets received with the wrong protocol type just * get filtered by the kernel, however, on other systems, the packet is * queued up and will raise an @ref OFReadFailedException with the * @ref OFReadFailedException#errNo set to `ENOMSG` when being received. * * @warning Even though the OFCopying protocol is implemented, it does *not* * return an independent copy of the socket, but instead retains it. * This is so that the socket can be used as a key for a dictionary, * so context can be associated with a socket. Using a socket in more * than one thread at the same time is not thread-safe, even if copy * was called to create one "instance" for every thread! |
︙ | ︙ | |||
77 78 79 80 81 82 83 | * @param port The port to bind to. 0 means to pick one and return it via the * returned socket address. * @param protocolType The DDP protocol type to use. Must not be 0. If you want * to use DDP directly and not a protocol built on top of * it, use 11 for compatibility with Open Transport. * @return The address on which this socket can be reached * @throw OFBindDDPSockeFailedException Binding failed | | | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | * @param port The port to bind to. 0 means to pick one and return it via the * returned socket address. * @param protocolType The DDP protocol type to use. Must not be 0. If you want * to use DDP directly and not a protocol built on top of * it, use 11 for compatibility with Open Transport. * @return The address on which this socket can be reached * @throw OFBindDDPSockeFailedException Binding failed * @throw OFAlreadyOpenException The socket is already bound */ - (OFSocketAddress)bindToNetwork: (uint16_t)network node: (uint8_t)node port: (uint8_t)port protocolType: (uint8_t)protocolType; @end OF_ASSUME_NONNULL_END |
Modified src/OFDDPSocket.m from [d532fdd70f] to [9c71163b23].
1 | /* | | | | | | > > > > | < > | > > > | > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #ifdef HAVE_FCNTL_H # include <fcntl.h> #endif #import "OFDDPSocket.h" #import "OFDictionary.h" #import "OFNumber.h" #import "OFPair.h" #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFAlreadyOpenException.h" #import "OFBindDDPSocketFailedException.h" #import "OFGetOptionFailedException.h" #import "OFInvalidArgumentException.h" #import "OFNotOpenException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFSetOptionFailedException.h" #import "OFWriteFailedException.h" #ifdef HAVE_NET_IF_H # include <net/if.h> #endif #ifdef HAVE_SYS_IOCTL_H # include <sys/ioctl.h> #endif #ifdef OF_HAVE_NETAT_APPLETALK_H # include <netat/ddp.h> # include <sys/ioctl.h> /* Unfortulately, there is no struct for the following in userland headers */ struct ATInterfaceConfig { |
︙ | ︙ | |||
63 64 65 66 67 68 69 | int flags; #endif if (protocolType == 0) @throw [OFInvalidArgumentException exception]; if (_socket != OFInvalidSocketHandle) | | | 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | int flags; #endif if (protocolType == 0) @throw [OFInvalidArgumentException exception]; if (_socket != OFInvalidSocketHandle) @throw [OFAlreadyOpenException exceptionWithObject: self]; address = OFSocketAddressMakeAppleTalk(network, node, port); #if defined(OF_MACOS) if ((_socket = socket(address.sockaddr.at.sat_family, SOCK_RAW | SOCK_CLOEXEC, protocolType)) == OFInvalidSocketHandle) #elif defined(OF_WINDOWS) |
︙ | ︙ |
Modified src/OFDNSQuery.h from [b49f52a5a4] to [7a330f0d37].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFDNSResourceRecord.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ |
Modified src/OFDNSQuery.m from [eb5858939c] to [3a77240507].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFDNSQuery.h" #import "OFString.h" |
︙ | ︙ | |||
39 40 41 42 43 44 45 | @try { void *pool = objc_autoreleasePoolPush(); if (![domainName hasSuffix: @"."]) domainName = [domainName stringByAppendingString: @"."]; | | | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | @try { void *pool = objc_autoreleasePoolPush(); if (![domainName hasSuffix: @"."]) domainName = [domainName stringByAppendingString: @"."]; _domainName = [domainName.lowercaseString copy]; _DNSClass = DNSClass; _recordType = recordType; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; |
︙ | ︙ |
Modified src/OFDNSResolver.h from [a91104c174] to [8d933f9a52].
1 | /* | | | | | | > > > > | < > | > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFDNSQuery.h" #import "OFDNSResourceRecord.h" #import "OFDNSResponse.h" #import "OFRunLoop.h" #import "OFString.h" OF_ASSUME_NONNULL_BEGIN #define OFDNSResolverBufferLength 512 @class OFArray OF_GENERIC(ObjectType); @class OFDNSResolver; @class OFDNSResolverContext; @class OFDNSResolverSettings; @class OFDate; @class OFDictionary OF_GENERIC(KeyType, ObjectType); @class OFMutableArray OF_GENERIC(ObjectType); @class OFMutableDictionary OF_GENERIC(KeyType, ObjectType); @class OFNumber; @class OFPair OF_GENERIC(FirstType, SecondType); @class OFTCPSocket; @class OFUDPSocket; /** * @enum OFDNSResolverErrorCode OFDNSResolver.h ObjFW/OFDNSResolver.h * * @brief An enum describing why resolving a host failed. |
︙ | ︙ | |||
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | OFUDPSocket *_IPv6Socket; #endif char _buffer[OFDNSResolverBufferLength]; OFMutableDictionary OF_GENERIC(OFNumber *, OFDNSResolverContext *) *_queries; OFMutableDictionary OF_GENERIC(OFTCPSocket *, OFDNSResolverContext *) *_TCPQueries; } /** * @brief A dictionary of static hosts. * * This dictionary is checked before actually looking up a host. */ @property (copy, nonatomic) OFDictionary OF_GENERIC(OFString *, OFArray OF_GENERIC(OFString *) *) *staticHosts; /** * @brief An array of name servers to use. * * The name servers are tried in order. */ @property (copy, nonatomic) OFArray OF_GENERIC(OFString *) *nameServers; /** * @brief The local domain. */ @property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *localDomain; /** * @brief The domains to search for queries for short names. */ @property (copy, nonatomic) OFArray OF_GENERIC(OFString *) *searchDomains; /** * @brief The timeout, in seconds, after which the next name server should be * tried. */ @property (nonatomic) OFTimeInterval timeout; /** * @brief The number of attempts before giving up to resolve a host. * * Trying all name servers once is considered a single attempt. */ @property (nonatomic) unsigned int maxAttempts; /** * @brief The minimum number of dots for a name to be considered absolute. */ @property (nonatomic) unsigned int minNumberOfDotsInAbsoluteName; /** | > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > | > > > > | 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | OFUDPSocket *_IPv6Socket; #endif char _buffer[OFDNSResolverBufferLength]; OFMutableDictionary OF_GENERIC(OFNumber *, OFDNSResolverContext *) *_queries; OFMutableDictionary OF_GENERIC(OFTCPSocket *, OFDNSResolverContext *) *_TCPQueries; OFMutableDictionary OF_GENERIC(OFDNSQuery *, OFPair OF_GENERIC(OFDate *, OFDNSResponse *) *) *_cache; OFMutableArray OF_GENERIC(OFString *) *_lastNameServers; OFTimeInterval _lastCacheCleanup; } /** * @brief A dictionary of static hosts. * * This dictionary is checked before actually looking up a host. * * @warning If you change this, you need to set @ref configReloadInterval to 0 * to disable reloading the config after some time. If you don't, the * config will be reloaded and your change overridden. */ @property (copy, nonatomic) OFDictionary OF_GENERIC(OFString *, OFArray OF_GENERIC(OFString *) *) *staticHosts; /** * @brief An array of name servers to use. * * The name servers are tried in order. * * @warning If you change this, you need to set @ref configReloadInterval to 0 * to disable reloading the config after some time. If you don't, the * config will be reloaded and your change overridden. */ @property (copy, nonatomic) OFArray OF_GENERIC(OFString *) *nameServers; /** * @brief The local domain. */ @property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *localDomain; /** * @brief The domains to search for queries for short names. * * @warning If you change this, you need to set @ref configReloadInterval to 0 * to disable reloading the config after some time. If you don't, the * config will be reloaded and your change overridden. */ @property (copy, nonatomic) OFArray OF_GENERIC(OFString *) *searchDomains; /** * @brief The timeout, in seconds, after which the next name server should be * tried. * * @warning If you change this, you need to set @ref configReloadInterval to 0 * to disable reloading the config after some time. If you don't, the * config will be reloaded and your change overridden. */ @property (nonatomic) OFTimeInterval timeout; /** * @brief The number of attempts before giving up to resolve a host. * * Trying all name servers once is considered a single attempt. * * @warning If you change this, you need to set @ref configReloadInterval to 0 * to disable reloading the config after some time. If you don't, the * config will be reloaded and your change overridden. */ @property (nonatomic) unsigned int maxAttempts; /** * @brief The minimum number of dots for a name to be considered absolute. * * @warning If you change this, you need to set @ref configReloadInterval to 0 * to disable reloading the config after some time. If you don't, the * config will be reloaded and your change overridden. */ @property (nonatomic) unsigned int minNumberOfDotsInAbsoluteName; /** * @brief Whether the resolver forces TCP to talk to a name server. * * @warning If you change this, you need to set @ref configReloadInterval to 0 * to disable reloading the config after some time. If you don't, the * config will be reloaded and your change overridden. */ @property (nonatomic) bool forcesTCP; /** * @brief The interval in seconds in which the config should be reloaded. * * Setting this to 0 disables config reloading. * * @warning If you change this to anything other than 0, the config will be * reloaded eventually, which in turn can override the config * reloading interval itself again. */ @property (nonatomic) OFTimeInterval configReloadInterval; /** * @brief Creates a new, autoreleased OFDNSResolver. */ + (instancetype)resolver; |
︙ | ︙ |
Modified src/OFDNSResolver.m from [9048cbfc52] to [ae23ada8bd].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "OFDNSResolver.h" |
︙ | ︙ | |||
375 376 377 378 379 380 381 382 383 384 385 386 387 388 | #endif memcpy(address.sockaddr.in6.sin6_addr.s6_addr, buffer + i, 16); return [[[OFAAAADNSResourceRecord alloc] initWithName: name address: &address TTL: TTL] autorelease]; } else if (recordType == OFDNSRecordTypeSRV && DNSClass == OFDNSClassIN) { uint16_t priority, weight, port; size_t j; OFString *target; if (dataLength < 6) | > > > > > > > > > > > > > > > > > > > > > > > > > > > | 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 | #endif memcpy(address.sockaddr.in6.sin6_addr.s6_addr, buffer + i, 16); return [[[OFAAAADNSResourceRecord alloc] initWithName: name address: &address TTL: TTL] autorelease]; } else if (recordType == OFDNSRecordTypeLOC) { uint8_t size, horizontalPrecision, verticalPrecision; uint32_t latitude, longitude, altitude; if (dataLength < 16 || buffer[i] != 0) @throw [OFInvalidServerResponseException exception]; size = buffer[i + 1]; horizontalPrecision = buffer[i + 2]; verticalPrecision = buffer[i + 3]; latitude = (buffer[i + 4] << 24) | (buffer[i + 5] << 16) | (buffer[i + 6] << 8) | buffer[i + 7]; longitude = (buffer[i + 8] << 24) | (buffer[i + 9] << 16) | (buffer[i + 10] << 8) | buffer[i + 11]; altitude = (buffer[i + 12] << 24) | (buffer[i + 13] << 16) | (buffer[i + 14] << 8) | buffer[i + 15]; return [[[OFLOCDNSResourceRecord alloc] initWithName: name DNSClass: DNSClass size: size horizontalPrecision: horizontalPrecision verticalPrecision: verticalPrecision latitude: latitude longitude: longitude altitude: altitude TTL: TTL] autorelease]; } else if (recordType == OFDNSRecordTypeSRV && DNSClass == OFDNSClassIN) { uint16_t priority, weight, port; size_t j; OFString *target; if (dataLength < 6) |
︙ | ︙ | |||
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 | return [[[OFSRVDNSResourceRecord alloc] initWithName: name priority: priority weight: weight target: target port: port TTL: TTL] autorelease]; } else return [[[OFDNSResourceRecord alloc] initWithName: name DNSClass: DNSClass recordType: recordType TTL: TTL] autorelease]; } static OFDictionary * parseSection(const unsigned char *buffer, size_t length, size_t *i, uint_fast16_t count) { OFMutableDictionary *ret = [OFMutableDictionary dictionary]; OFEnumerator OF_GENERIC(OFMutableArray *) *objectEnumerator; OFMutableArray *array; for (uint_fast16_t j = 0; j < count; j++) { OFString *name = parseName(buffer, length, i, | > > > > > > > > > > > > > > > > > > > > | | | | | 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 | return [[[OFSRVDNSResourceRecord alloc] initWithName: name priority: priority weight: weight target: target port: port TTL: TTL] autorelease]; } else if (recordType == OFDNSRecordTypeURI) { uint16_t priority, weight; OFString *target; if (dataLength < 4) @throw [OFInvalidServerResponseException exception]; priority = (buffer[i] << 8) | buffer[i + 1]; weight = (buffer[i + 2] << 8) | buffer[i + 3]; target = [OFString stringWithUTF8String: (char *)buffer + i + 4 length: dataLength - 4]; return [[[OFURIDNSResourceRecord alloc] initWithName: name DNSClass: DNSClass priority: priority weight: weight target: target TTL: TTL] autorelease]; } else return [[[OFDNSResourceRecord alloc] initWithName: name DNSClass: DNSClass recordType: recordType TTL: TTL] autorelease]; } static OFDictionary * parseSection(const unsigned char *buffer, size_t length, size_t *i, uint_fast16_t count) { OFMutableDictionary *ret = [OFMutableDictionary dictionary]; OFEnumerator OF_GENERIC(OFMutableArray *) *objectEnumerator; OFMutableArray *array; for (uint_fast16_t j = 0; j < count; j++) { OFString *name = parseName(buffer, length, i, maxAllowedPointers).lowercaseString; OFDNSClass DNSClass; OFDNSRecordType recordType; uint32_t TTL; uint16_t dataLength; OFDNSResourceRecord *record; if (*i + 10 > length) @throw [OFTruncatedDataException exception]; recordType = (buffer[*i] << 8) | buffer[*i + 1]; DNSClass = (buffer[*i + 2] << 8) | buffer[*i + 3]; TTL = (buffer[*i + 4] << 24) | (buffer[*i + 5] << 16) | (buffer[*i + 6] << 8) | buffer[*i + 7]; dataLength = (buffer[*i + 8] << 8) | buffer[*i + 9]; *i += 10; if (*i + dataLength > length) @throw [OFTruncatedDataException exception]; record = parseResourceRecord(name, DNSClass, recordType, TTL, |
︙ | ︙ | |||
462 463 464 465 466 467 468 469 470 471 472 473 474 475 | while ((array = [objectEnumerator nextObject]) != nil) [array makeImmutable]; [ret makeImmutable]; return ret; } @implementation OFDNSResolverContext - (instancetype)initWithQuery: (OFDNSQuery *)query ID: (OFNumber *)ID settings: (OFDNSResolverSettings *)settings delegate: (id <OFDNSResolverQueryDelegate>)delegate { | > > > > > > > > > > > > > > | 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 | while ((array = [objectEnumerator nextObject]) != nil) [array makeImmutable]; [ret makeImmutable]; return ret; } static bool containsExpiredRecord(OFDNSResponseRecords responseRecords, uint32_t age) { OFEnumerator *enumerator = [responseRecords objectEnumerator]; OFArray OF_GENERIC(OFDNSResourceRecord *) *records; while ((records = [enumerator nextObject]) != nil) for (OFDNSResourceRecord *record in records) if (record.TTL < age) return true; return false; } @implementation OFDNSResolverContext - (instancetype)initWithQuery: (OFDNSQuery *)query ID: (OFNumber *)ID settings: (OFDNSResolverSettings *)settings delegate: (id <OFDNSResolverQueryDelegate>)delegate { |
︙ | ︙ | |||
574 575 576 577 578 579 580 581 582 583 584 585 586 587 | { self = [super init]; @try { _settings = [[OFDNSResolverSettings alloc] init]; _queries = [[OFMutableDictionary alloc] init]; _TCPQueries = [[OFMutableDictionary alloc] init]; [_settings reload]; } @catch (id e) { [self release]; @throw e; } | > | 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 | { self = [super init]; @try { _settings = [[OFDNSResolverSettings alloc] init]; _queries = [[OFMutableDictionary alloc] init]; _TCPQueries = [[OFMutableDictionary alloc] init]; _cache = [[OFMutableDictionary alloc] init]; [_settings reload]; } @catch (id e) { [self release]; @throw e; } |
︙ | ︙ | |||
597 598 599 600 601 602 603 604 605 606 607 608 609 610 | [_IPv4Socket release]; #ifdef OF_HAVE_IPV6 [_IPv6Socket cancelAsyncRequests]; [_IPv6Socket release]; #endif [_queries release]; [_TCPQueries release]; [super dealloc]; } - (OFDictionary *)staticHosts { return _settings->_staticHosts; | > > | 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 | [_IPv4Socket release]; #ifdef OF_HAVE_IPV6 [_IPv6Socket cancelAsyncRequests]; [_IPv6Socket release]; #endif [_queries release]; [_TCPQueries release]; [_cache release]; [_lastNameServers release]; [super dealloc]; } - (OFDictionary *)staticHosts { return _settings->_staticHosts; |
︙ | ︙ | |||
674 675 676 677 678 679 680 | - (void)setMinNumberOfDotsInAbsoluteName: (unsigned int)minNumberOfDotsInAbsoluteName { _settings->_minNumberOfDotsInAbsoluteName = minNumberOfDotsInAbsoluteName; } | | | | | | 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 | - (void)setMinNumberOfDotsInAbsoluteName: (unsigned int)minNumberOfDotsInAbsoluteName { _settings->_minNumberOfDotsInAbsoluteName = minNumberOfDotsInAbsoluteName; } - (bool)forcesTCP { return _settings->_forcesTCP; } - (void)setForcesTCP: (bool)forcesTCP { _settings->_forcesTCP = forcesTCP; } - (OFTimeInterval)configReloadInterval { return _settings->_configReloadInterval; } |
︙ | ︙ | |||
719 720 721 722 723 724 725 | repeats: false]; [[OFRunLoop currentRunLoop] addTimer: context->_cancelTimer forMode: runLoopMode]; nameServer = [context->_settings->_nameServers objectAtIndex: context->_nameServersIndex]; | | | 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 | repeats: false]; [[OFRunLoop currentRunLoop] addTimer: context->_cancelTimer forMode: runLoopMode]; nameServer = [context->_settings->_nameServers objectAtIndex: context->_nameServersIndex]; if (context->_settings->_forcesTCP) { OFEnsure(context->_TCPSocket == nil); context->_TCPSocket = [[OFTCPSocket alloc] init]; [_TCPQueries setObject: context forKey: context->_TCPSocket]; context->_TCPSocket.delegate = self; [context->_TCPSocket asyncConnectToHost: nameServer |
︙ | ︙ | |||
784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 | [sock asyncSendData: context->_queryData receiver: &context->_usedNameServer runLoopMode: runLoopMode]; [sock asyncReceiveIntoBuffer: _buffer length: bufferLength runLoopMode: runLoopMode]; } - (void)asyncPerformQuery: (OFDNSQuery *)query delegate: (id <OFDNSResolverQueryDelegate>)delegate { [self asyncPerformQuery: query runLoopMode: OFDefaultRunLoopMode delegate: delegate]; } - (void)asyncPerformQuery: (OFDNSQuery *)query runLoopMode: (OFRunLoopMode)runLoopMode delegate: (id <OFDNSResolverQueryDelegate>)delegate { void *pool = objc_autoreleasePoolPush(); OFNumber *ID; OFDNSResolverContext *context; /* Random, unused ID */ do { ID = [OFNumber numberWithUnsignedShort: OFRandom16()]; } while ([_queries objectForKey: ID] != nil); if (query.domainName.UTF8StringLength > 253) | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 | [sock asyncSendData: context->_queryData receiver: &context->_usedNameServer runLoopMode: runLoopMode]; [sock asyncReceiveIntoBuffer: _buffer length: bufferLength runLoopMode: runLoopMode]; } - (void)of_cleanUpCache { OFTimeInterval now = [[OFDate date] timeIntervalSince1970]; OFMutableArray *removeList; if (_lastNameServers != _settings->_nameServers && ![_lastNameServers isEqual: _settings->_nameServers]) { OFArray *old = _lastNameServers; _lastNameServers = [_settings->_nameServers copy]; [old release]; [_cache removeAllObjects]; return; } if (now - _lastCacheCleanup < 1) return; _lastCacheCleanup = now; removeList = [OFMutableArray arrayWithCapacity: _cache.count]; for (OFDNSQuery *query in _cache) { OFPair OF_GENERIC(OFDate *, OFDNSResponse *) *entry = [_cache objectForKey: query]; uint32_t age = (uint32_t)now - (uint32_t)[entry.firstObject timeIntervalSince1970]; OFDNSResponse *response = entry.secondObject; if (containsExpiredRecord(response.answerRecords, age) || containsExpiredRecord(response.authorityRecords, age) || containsExpiredRecord(response.additionalRecords, age)) [removeList addObject: query]; } for (OFDNSQuery *query in removeList) [_cache removeObjectForKey: query]; } - (void)asyncPerformQuery: (OFDNSQuery *)query delegate: (id <OFDNSResolverQueryDelegate>)delegate { [self asyncPerformQuery: query runLoopMode: OFDefaultRunLoopMode delegate: delegate]; } - (void)asyncPerformQuery: (OFDNSQuery *)query runLoopMode: (OFRunLoopMode)runLoopMode delegate: (id <OFDNSResolverQueryDelegate>)delegate { void *pool = objc_autoreleasePoolPush(); OFNumber *ID; OFDNSResolverContext *context; OFPair OF_GENERIC(OFDate *, OFDNSResponse *) *cacheEntry; [self of_cleanUpCache]; if ((cacheEntry = [_cache objectForKey: query]) != nil) { uint32_t age = (uint32_t)-[cacheEntry.firstObject timeIntervalSinceNow]; OFDNSResponse *response = cacheEntry.secondObject; if (!containsExpiredRecord(response.answerRecords, age) && !containsExpiredRecord(response.authorityRecords, age) && !containsExpiredRecord(response.additionalRecords, age)) { OFTimer *timer = [OFTimer timerWithTimeInterval: 0 target: delegate selector: @selector(resolver: didPerformQuery:response: exception:) object: self object: query object: response object: nil repeats: false]; [[OFRunLoop currentRunLoop] addTimer: timer forMode: runLoopMode]; objc_autoreleasePoolPop(pool); return; } } /* Random, unused ID */ do { ID = [OFNumber numberWithUnsignedShort: OFRandom16()]; } while ([_queries objectForKey: ID] != nil); if (query.domainName.UTF8StringLength > 253) |
︙ | ︙ | |||
944 945 946 947 948 949 950 | if ((buffer[2] & 0x78) != (queryDataBuffer[2] & 0x78)) @throw [OFInvalidServerResponseException exception]; /* TC */ if (buffer[2] & 0x02) { OFRunLoopMode runLoopMode; | | | | 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 | if ((buffer[2] & 0x78) != (queryDataBuffer[2] & 0x78)) @throw [OFInvalidServerResponseException exception]; /* TC */ if (buffer[2] & 0x02) { OFRunLoopMode runLoopMode; if (context->_settings->_forcesTCP) @throw [OFTruncatedDataException exception]; context->_settings->_forcesTCP = true; runLoopMode = [OFRunLoop currentRunLoop].currentMode; [self of_sendQueryForContext: context runLoopMode: runLoopMode]; return false; } /* RCODE */ |
︙ | ︙ | |||
1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 | } @catch (id e) { exception = e; } if (exception != nil) response = nil; [context->_delegate resolver: self didPerformQuery: context->_query response: response exception: exception]; return false; } | > > > > > > > > > | 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 | } @catch (id e) { exception = e; } if (exception != nil) response = nil; [self of_cleanUpCache]; if (response != nil) [_cache setObject: [OFPair pairWithFirstObject: [OFDate date] secondObject: response] forKey: context->_query]; else [_cache removeObjectForKey: context->_query]; [context->_delegate resolver: self didPerformQuery: context->_query response: response exception: exception]; return false; } |
︙ | ︙ |
Modified src/OFDNSResolverSettings.h from [1250cc4b4c] to [86cd954544].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" OF_ASSUME_NONNULL_BEGIN @class OFArray OF_GENERIC(ObjectType); @class OFDate; @class OFDictionary OF_GENERIC(KeyType, ObjectType); @interface OFDNSResolverSettings: OFObject <OFCopying> { @public OFDictionary OF_GENERIC(OFString *, OFArray OF_GENERIC(OFString *) *) *_staticHosts; OFArray OF_GENERIC(OFString *) *_nameServers; OFString *_Nullable _localDomain; OFArray OF_GENERIC(OFString *) *_searchDomains; OFTimeInterval _timeout; unsigned int _maxAttempts, _minNumberOfDotsInAbsoluteName; bool _forcesTCP; OFTimeInterval _configReloadInterval; @protected OFDate *_lastConfigReload; } - (void)reload; @end OF_ASSUME_NONNULL_END |
Modified src/OFDNSResolverSettings.m from [1a84838633] to [07e382325c].
1 | /* | | | | | | > > > > | < > | > | > > > > > > > > > > > < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include "unistd_wrapper.h" #import "OFDNSResolverSettings.h" #import "OFArray.h" #import "OFCharacterSet.h" #import "OFDate.h" #import "OFDictionary.h" #ifdef OF_HAVE_FILES # import "OFFile.h" # import "OFFileManager.h" #endif #import "OFLocale.h" #import "OFSocket+Private.h" #import "OFString.h" #ifdef OF_WINDOWS # import "OFWindowsRegistryKey.h" #endif #import "OFInvalidFormatException.h" #import "OFOpenItemFailedException.h" #ifdef OF_WINDOWS # import "OFOpenWindowsRegistryKeyFailedException.h" #endif #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "OFUndefinedKeyException.h" #ifdef OF_WINDOWS # define interface struct # include <iphlpapi.h> # undef interface #endif #ifdef OF_NINTENDO_3DS /* Newer versions of libctru started using id as a parameter name. */ # define id id_3ds # include <3ds.h> # undef id #endif #if defined(OF_AMIGAOS_M68K) || defined(OF_AMIGAOS4) # define Class IntuitionClass # include <proto/dos.h> # undef Class #endif #ifdef OF_MORPHOS # include <proto/rexxsyslib.h> # include <rexx/errors.h> # include <rexx/storage.h> #endif #if defined(OF_HAIKU) # define HOSTS_PATH @"/system/settings/network/hosts" # define RESOLV_CONF_PATH @"/system/settings/network/resolv.conf" #else # define HOSTS_PATH @"/etc/hosts" # define RESOLV_CONF_PATH @"/etc/resolv.conf" #endif #ifndef HOST_NAME_MAX # define HOST_NAME_MAX 255 |
︙ | ︙ | |||
111 112 113 114 115 116 117 118 119 120 121 122 123 124 | if (gethostname(hostname, HOST_NAME_MAX + 1) != 0) return nil; return [OFString stringWithCString: hostname encoding: [OFLocale encoding]]; } #endif #ifdef OF_MORPHOS static OFString * arexxCommand(const char *port, const char *command) { struct Library *RexxSysBase; struct MsgPort *replyPort = NULL; | > > > > > > > > > > > | 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | if (gethostname(hostname, HOST_NAME_MAX + 1) != 0) return nil; return [OFString stringWithCString: hostname encoding: [OFLocale encoding]]; } #endif #ifdef OF_AMIGAOS_M68K static bool assignExists(const char *assign) { struct DosList *list = LockDosList(LDF_ASSIGNS | LDF_READ); bool found = (FindDosEntry(list, assign, LDF_ASSIGNS) != NULL); UnLockDosList(LDF_ASSIGNS | LDF_READ); return found; } #endif #ifdef OF_MORPHOS static OFString * arexxCommand(const char *port, const char *command) { struct Library *RexxSysBase; struct MsgPort *replyPort = NULL; |
︙ | ︙ | |||
209 210 211 212 213 214 215 | copy->_nameServers = [_nameServers copy]; copy->_localDomain = [_localDomain copy]; copy->_searchDomains = [_searchDomains copy]; copy->_timeout = _timeout; copy->_maxAttempts = _maxAttempts; copy->_minNumberOfDotsInAbsoluteName = _minNumberOfDotsInAbsoluteName; | | | 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | copy->_nameServers = [_nameServers copy]; copy->_localDomain = [_localDomain copy]; copy->_searchDomains = [_searchDomains copy]; copy->_timeout = _timeout; copy->_maxAttempts = _maxAttempts; copy->_minNumberOfDotsInAbsoluteName = _minNumberOfDotsInAbsoluteName; copy->_forcesTCP = _forcesTCP; copy->_configReloadInterval = _configReloadInterval; copy->_lastConfigReload = [_lastConfigReload copy]; } @catch (id e) { [copy release]; @throw e; } |
︙ | ︙ | |||
237 238 239 240 241 242 243 | [_searchDomains release]; _searchDomains = nil; _timeout = 2; _maxAttempts = 3; _minNumberOfDotsInAbsoluteName = 1; | | > > | | > > | | | 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 | [_searchDomains release]; _searchDomains = nil; _timeout = 2; _maxAttempts = 3; _minNumberOfDotsInAbsoluteName = 1; _forcesTCP = false; #ifndef OF_NINTENDO_3DS _configReloadInterval = 2; #else _configReloadInterval = 0; #endif } #if defined(OF_HAVE_FILES) && !defined(OF_MORPHOS) && !defined(OF_NINTENDO_3DS) - (void)parseHosts: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFCharacterSet *whitespaceCharacterSet = [OFCharacterSet whitespaceCharacterSet]; OFCharacterSet *commentCharacters = [OFCharacterSet characterSetWithCharactersInString: @"#;"]; OFMutableDictionary *staticHosts; OFFile *file; OFString *line; @try { file = [OFFile fileWithPath: path mode: @"r"]; } @catch (OFOpenItemFailedException *e) { objc_autoreleasePoolPop(pool); return; } staticHosts = [OFMutableDictionary dictionary]; while ((line = [file readLineWithEncoding: [OFLocale encoding]]) != nil) { OFArray *components, *hosts; size_t pos; OFString *address; pos = [line indexOfCharacterFromSet: commentCharacters]; if (pos != OFNotFound) line = [line substringToIndex: pos]; components = [line componentsSeparatedByCharactersInSet: whitespaceCharacterSet options: OFStringSkipEmptyComponents]; if (components.count < 2) continue; address = components.firstObject; hosts = [components objectsInRange: OFMakeRange(1, components.count - 1)]; for (OFString *host in hosts) { OFMutableArray *addresses; host = host.lowercaseString; addresses = [staticHosts objectForKey: host]; if (addresses == nil) { addresses = [OFMutableArray array]; [staticHosts setObject: addresses forKey: host]; } [addresses addObject: address]; } } for (OFMutableArray *addresses in [staticHosts objectEnumerator]) [addresses makeImmutable]; [staticHosts makeImmutable]; _staticHosts = [staticHosts copy]; objc_autoreleasePoolPop(pool); } # ifndef OF_WINDOWS - (void)parseResolvConfOption: (OFString *)option { @try { if ([option hasPrefix: @"ndots:"]) { unsigned long long number; option = [option substringFromIndex: 6]; |
︙ | ︙ | |||
339 340 341 342 343 344 345 | _maxAttempts = (unsigned int)number; } else if ([option hasPrefix: @"reload-period:"]) { option = [option substringFromIndex: 14]; _configReloadInterval = option.unsignedLongLongValue; } else if ([option isEqual: @"tcp"]) | | | 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | _maxAttempts = (unsigned int)number; } else if ([option hasPrefix: @"reload-period:"]) { option = [option substringFromIndex: 14]; _configReloadInterval = option.unsignedLongLongValue; } else if ([option isEqual: @"tcp"]) _forcesTCP = true; } @catch (OFInvalidFormatException *e) { } } - (void)parseResolvConf: (OFString *)path { void *pool = objc_autoreleasePoolPush(); |
︙ | ︙ | |||
385 386 387 388 389 390 391 | options: OFStringSkipEmptyComponents]; if (components.count < 2) { objc_autoreleasePoolPop(pool2); continue; } | | | 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 | options: OFStringSkipEmptyComponents]; if (components.count < 2) { objc_autoreleasePoolPop(pool2); continue; } option = [components.firstObject lowercaseString]; arguments = [components objectsInRange: OFMakeRange(1, components.count - 1)]; if ([option isEqual: @"nameserver"]) { if (arguments.count != 1) { objc_autoreleasePoolPop(pool2); continue; |
︙ | ︙ | |||
443 444 445 446 447 448 449 | PIP_ADDR_STRING iter; if (GetNetworkParams(fixedInfo, &length) != ERROR_SUCCESS) return; nameServers = [OFMutableArray array]; | | > | | > > > > | 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 | PIP_ADDR_STRING iter; if (GetNetworkParams(fixedInfo, &length) != ERROR_SUCCESS) return; nameServers = [OFMutableArray array]; for (iter = &fixedInfo->DnsServerList; iter != NULL; iter = iter->Next) { OFString *nameServer = [OFString stringWithCString: iter->IpAddress.String encoding: encoding]; if (nameServer.length > 0) [nameServers addObject: nameServer]; } if (nameServers.count > 0) { [nameServers makeImmutable]; _nameServers = [nameServers copy]; } if (fixedInfo->DomainName[0] != '\0') |
︙ | ︙ | |||
489 490 491 492 493 494 495 | continue; address = components.firstObject; hosts = [components objectsInRange: OFMakeRange(1, components.count - 1)]; for (OFString *host in hosts) { | | > > | | | | | | > > > > > > > > > | 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 | continue; address = components.firstObject; hosts = [components objectsInRange: OFMakeRange(1, components.count - 1)]; for (OFString *host in hosts) { OFMutableArray *addresses; host = host.lowercaseString; addresses = [staticHosts objectForKey: host]; if (addresses == nil) { addresses = [OFMutableArray array]; [staticHosts setObject: addresses forKey: host]; } [addresses addObject: address]; } } for (OFMutableArray *addresses in [staticHosts objectEnumerator]) [addresses makeImmutable]; [staticHosts makeImmutable]; _staticHosts = [staticHosts copy]; objc_autoreleasePoolPop(pool); } #endif #if defined(OF_AMIGAOS_M68K) || defined(OF_AMIGAOS4) - (bool)obtainRoadshowSystemConfig { OFMutableArray *nameServers; OFStringEncoding encoding; struct List *nameServerList; char buffer[MAXHOSTNAMELEN]; LONG hasDNSAPI; if (SocketBaseTags(SBTM_GETREF(SBTC_HAVE_DNS_API), (ULONG)&hasDNSAPI, TAG_END) != 0 || !hasDNSAPI) return false; nameServers = [OFMutableArray array]; encoding = [OFLocale encoding]; nameServerList = ObtainDomainNameServerList(); if (nameServerList == NULL) @throw [OFOutOfMemoryException exception]; @try { struct DomainNameServerNode *iter = (struct DomainNameServerNode *)&nameServerList->lh_Head; |
︙ | ︙ | |||
550 551 552 553 554 555 556 557 558 559 560 561 562 563 | [nameServers makeImmutable]; _nameServers = [nameServers copy]; } if (GetDefaultDomainName(buffer, sizeof(buffer))) _localDomain = [[OFString alloc] initWithCString: buffer encoding: encoding]; } #endif #ifdef OF_NINTENDO_3DS - (void)obtainNintendo3DSSytemConfig { OFMutableArray *nameServers = [OFMutableArray array]; | > > | 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 | [nameServers makeImmutable]; _nameServers = [nameServers copy]; } if (GetDefaultDomainName(buffer, sizeof(buffer))) _localDomain = [[OFString alloc] initWithCString: buffer encoding: encoding]; return true; } #endif #ifdef OF_NINTENDO_3DS - (void)obtainNintendo3DSSytemConfig { OFMutableArray *nameServers = [OFMutableArray array]; |
︙ | ︙ | |||
598 599 600 601 602 603 604 | _nameServers = [nameServers copy]; } } #endif - (void)reload { | < | > > > > > | > > | | | | | | | > > > > > | > > > > > > > > > > > > > > | > | > | 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 | _nameServers = [nameServers copy]; } } #endif - (void)reload { #ifdef OF_WINDOWS OFString *path = nil; #endif #if (defined(OF_AMIGAOS_M68K) || defined(OF_AMIGAOS4)) && defined(OF_HAVE_FILES) OFFileManager *fileManager = [OFFileManager defaultManager]; #endif void *pool; /* * TODO: Rather than reparsing every time, check what actually changed * (mtime) and only reset those. */ if (_lastConfigReload != nil && _configReloadInterval > 0 && _lastConfigReload.timeIntervalSinceNow < _configReloadInterval) return; pool = objc_autoreleasePoolPush(); [self setDefaults]; #if defined(OF_WINDOWS) # ifdef OF_HAVE_FILES @try { OFWindowsRegistryKey *key; key = [[OFWindowsRegistryKey localMachineKey] openSubkeyAtPath: @"SYSTEM\\CurrentControlSet\\Services\\" @"Tcpip\\Parameters" accessRights: KEY_QUERY_VALUE options: 0]; path = [[[key stringForValueNamed: @"DataBasePath"] stringByAppendingPathComponent: @"hosts"] stringByExpandingWindowsEnvironmentStrings]; } @catch (OFOpenWindowsRegistryKeyFailedException *e) { /* Ignore */ } @catch (OFUndefinedKeyException *e) { /* Ignore */ } if (path != nil) [self parseHosts: path]; # endif [self obtainWindowsSystemConfig]; #elif defined(OF_MORPHOS) [self obtainMorphOSSystemConfig]; #elif defined(OF_AMIGAOS_M68K) || defined(OF_AMIGAOS4) # ifdef OF_HAVE_FILES if (![self obtainRoadshowSystemConfig]) { if (assignExists("AmiTCP")) /* * FIXME: The installer puts it there, but theoretically * it could also be in AmiTCP:db/netdb or any of * the files included there. */ [self parseResolvConf: @"AmiTCP:db/netdb-myhost"]; } if ([fileManager fileExistsAtPath: @"DEVS:Internet/hosts"]) [self parseHosts: @"DEVS:Internet/hosts"]; else if (assignExists("AmiTCP")) [self parseHosts: @"AmiTCP:db/hosts"]; # else [self obtainRoadshowSystemConfig]; # endif #elif defined(OF_NINTENDO_3DS) [self obtainNintendo3DSSytemConfig]; #elif defined(OF_HAVE_FILES) [self parseHosts: HOSTS_PATH]; [self parseResolvConf: RESOLV_CONF_PATH]; #endif |
︙ | ︙ |
Modified src/OFDNSResourceRecord.h from [30273f1f1b] to [62b5eead32].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFSocket.h" #import "OFString.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ | |||
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | OFDNSRecordTypeMX = 15, /** TXT */ OFDNSRecordTypeTXT = 16, /** RP */ OFDNSRecordTypeRP = 17, /** AAAA */ OFDNSRecordTypeAAAA = 28, /** SRV */ OFDNSRecordTypeSRV = 33, /** All types. Only for queries. */ OFDNSRecordTypeAll = 255, } OFDNSRecordType; /** * @class OFDNSResourceRecord OFDNSResourceRecord.h ObjFW/OFDNSResourceRecord.h * * @brief A class representing a DNS resource record. */ | > > > > | 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | OFDNSRecordTypeMX = 15, /** TXT */ OFDNSRecordTypeTXT = 16, /** RP */ OFDNSRecordTypeRP = 17, /** AAAA */ OFDNSRecordTypeAAAA = 28, /** LOC */ OFDNSRecordTypeLOC = 29, /** SRV */ OFDNSRecordTypeSRV = 33, /** All types. Only for queries. */ OFDNSRecordTypeAll = 255, /** URI */ OFDNSRecordTypeURI = 256, } OFDNSRecordType; /** * @class OFDNSResourceRecord OFDNSResourceRecord.h ObjFW/OFDNSResourceRecord.h * * @brief A class representing a DNS resource record. */ |
︙ | ︙ | |||
111 112 113 114 115 116 117 | */ - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER; @end | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | */ - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER; @end #ifdef __cplusplus extern "C" { #endif /** * @brief Returns the name for the specified OFDNSClass. * * @param DNSClass The OFDNSClass to return the name for |
︙ | ︙ | |||
654 655 656 657 658 659 660 | */ extern OFDNSRecordType OFDNSRecordTypeParseName(OFString *_Nonnull string); #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END | > > > > > > > > > > > > > > | 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | */ extern OFDNSRecordType OFDNSRecordTypeParseName(OFString *_Nonnull string); #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END #import "OFAAAADNSResourceRecord.h" #import "OFADNSResourceRecord.h" #import "OFCNAMEDNSResourceRecord.h" #import "OFHINFODNSResourceRecord.h" #import "OFLOCDNSResourceRecord.h" #import "OFMXDNSResourceRecord.h" #import "OFNSDNSResourceRecord.h" #import "OFPTRDNSResourceRecord.h" #import "OFRPDNSResourceRecord.h" #import "OFSOADNSResourceRecord.h" #import "OFSRVDNSResourceRecord.h" #import "OFTXTDNSResourceRecord.h" #import "OFURIDNSResourceRecord.h" |
Modified src/OFDNSResourceRecord.m from [b7ec251a31] to [17e7a911f6].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFDNSResourceRecord.h" #import "OFArray.h" #import "OFData.h" |
︙ | ︙ | |||
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | return @"MX"; case OFDNSRecordTypeTXT: return @"TXT"; case OFDNSRecordTypeRP: return @"RP"; case OFDNSRecordTypeAAAA: return @"AAAA"; case OFDNSRecordTypeSRV: return @"SRV"; case OFDNSRecordTypeAll: return @"all"; default: return [OFString stringWithFormat: @"%u", recordType]; } } OFDNSClass OFDNSClassParseName(OFString *string) | > > > > | 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | return @"MX"; case OFDNSRecordTypeTXT: return @"TXT"; case OFDNSRecordTypeRP: return @"RP"; case OFDNSRecordTypeAAAA: return @"AAAA"; case OFDNSRecordTypeLOC: return @"LOC"; case OFDNSRecordTypeSRV: return @"SRV"; case OFDNSRecordTypeAll: return @"all"; case OFDNSRecordTypeURI: return @"URI"; default: return [OFString stringWithFormat: @"%u", recordType]; } } OFDNSClass OFDNSClassParseName(OFString *string) |
︙ | ︙ | |||
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | recordType = OFDNSRecordTypeMX; else if ([string isEqual: @"TXT"]) recordType = OFDNSRecordTypeTXT; else if ([string isEqual: @"RP"]) recordType = OFDNSRecordTypeRP; else if ([string isEqual: @"AAAA"]) recordType = OFDNSRecordTypeAAAA; else if ([string isEqual: @"SRV"]) recordType = OFDNSRecordTypeSRV; else if ([string isEqual: @"ALL"]) recordType = OFDNSRecordTypeAll; else { recordType = (OFDNSRecordType)[string unsignedLongLongValueWithBase: 0]; } objc_autoreleasePoolPop(pool); | > > > > | 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | recordType = OFDNSRecordTypeMX; else if ([string isEqual: @"TXT"]) recordType = OFDNSRecordTypeTXT; else if ([string isEqual: @"RP"]) recordType = OFDNSRecordTypeRP; else if ([string isEqual: @"AAAA"]) recordType = OFDNSRecordTypeAAAA; else if ([string isEqual: @"LOC"]) recordType = OFDNSRecordTypeLOC; else if ([string isEqual: @"SRV"]) recordType = OFDNSRecordTypeSRV; else if ([string isEqual: @"ALL"]) recordType = OFDNSRecordTypeAll; else if ([string isEqual: @"URI"]) recordType = OFDNSRecordTypeURI; else { recordType = (OFDNSRecordType)[string unsignedLongLongValueWithBase: 0]; } objc_autoreleasePoolPop(pool); |
︙ | ︙ | |||
173 174 175 176 177 178 179 180 | @"\tClass = %@\n" @"\tType = %@\n" @"\tTTL = %" PRIu32 "\n" @">", self.className, _name, OFDNSClassName(_DNSClass), OFDNSRecordTypeName(_recordType), _TTL]; } @end | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 185 186 187 188 189 190 191 192 | @"\tClass = %@\n" @"\tType = %@\n" @"\tTTL = %" PRIu32 "\n" @">", self.className, _name, OFDNSClassName(_DNSClass), OFDNSRecordTypeName(_recordType), _TTL]; } @end |
Modified src/OFDNSResponse.h from [229f42ebfc] to [535fb0208d].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFDNSResourceRecord.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ |
Modified src/OFDNSResponse.m from [6e61ece6f0] to [ff489b9d6a].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFDNSResponse.h" #import "OFDictionary.h" #import "OFString.h" |
︙ | ︙ |
Modified src/OFData+CryptographicHashing.h from [7264dfad2c] to [d846d34b23].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFData.h" OF_ASSUME_NONNULL_BEGIN @class OFString; |
︙ | ︙ |
Modified src/OFData+CryptographicHashing.m from [caf70aabc2] to [948f292398].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFData+CryptographicHashing.h" #import "OFString.h" #import "OFCryptographicHash.h" |
︙ | ︙ | |||
35 36 37 38 39 40 41 | void *pool = objc_autoreleasePoolPush(); id <OFCryptographicHash> hash = [class hashWithAllowsSwappableMemory: true]; size_t digestSize = [class digestSize]; const unsigned char *digest; char cString[digestSize * 2]; | | | | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | void *pool = objc_autoreleasePoolPush(); id <OFCryptographicHash> hash = [class hashWithAllowsSwappableMemory: true]; size_t digestSize = [class digestSize]; const unsigned char *digest; char cString[digestSize * 2]; [hash updateWithBuffer: self.items length: self.count * self.itemSize]; [hash calculate]; digest = hash.digest; for (size_t i = 0; i < digestSize; i++) { uint8_t high, low; high = digest[i] >> 4; |
︙ | ︙ |
Modified src/OFData+MessagePackParsing.h from [1a7c410992] to [6de5acbf5d].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFData.h" OF_ASSUME_NONNULL_BEGIN #ifdef __cplusplus |
︙ | ︙ |
Modified src/OFData+MessagePackParsing.m from [8bd7ef8227] to [58c96d9fe8].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "OFData+MessagePackParsing.h" |
︙ | ︙ | |||
254 255 256 257 258 259 260 | readUInt64(buffer + 1)]; return 9; /* Signed integers */ case 0xD0: /* int 8 */ if (length < 2) @throw [OFTruncatedDataException exception]; | | | > | > | > | 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | readUInt64(buffer + 1)]; return 9; /* Signed integers */ case 0xD0: /* int 8 */ if (length < 2) @throw [OFTruncatedDataException exception]; *object = [OFNumber numberWithChar: (int8_t)buffer[1]]; return 2; case 0xD1: /* int 16 */ if (length < 3) @throw [OFTruncatedDataException exception]; *object = [OFNumber numberWithShort: (int16_t)readUInt16(buffer + 1)]; return 3; case 0xD2: /* int 32 */ if (length < 5) @throw [OFTruncatedDataException exception]; *object = [OFNumber numberWithLong: (int32_t)readUInt32(buffer + 1)]; return 5; case 0xD3: /* int 64 */ if (length < 9) @throw [OFTruncatedDataException exception]; *object = [OFNumber numberWithLongLong: (int64_t)readUInt64(buffer + 1)]; return 9; /* Floating point */ case 0xCA:; /* float 32 */ float f; if (length < 5) @throw [OFTruncatedDataException exception]; |
︙ | ︙ |
Modified src/OFData.h from [750f7eff94] to [be89a6ec69].
1 | /* | | | | | | > > > > | < > | < | | < < < | < < < < < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFMessagePackRepresentation.h" /*! @file */ OF_ASSUME_NONNULL_BEGIN @class OFIRI; @class OFString; /** * @brief Options for searching in data. * * This is a bit mask. */ typedef enum { /** Search backwards in the data */ OFDataSearchBackwards = 1 } OFDataSearchOptions; /** * @class OFData OFData.h ObjFW/OFData.h * * @brief A class for storing arbitrary data in an array. */ @interface OFData: OFObject <OFCopying, OFMutableCopying, OFComparing, OFMessagePackRepresentation> /** * @brief The size of a single item in the OFData in bytes. */ @property (readonly, nonatomic) size_t itemSize; /** * @brief The number of items in the OFData. |
︙ | ︙ | |||
92 93 94 95 96 97 98 99 100 101 102 103 104 105 | @property (readonly, nonatomic) OFString *stringRepresentation; /** * @brief A string containing the data in Base64 encoding. */ @property (readonly, nonatomic) OFString *stringByBase64Encoding; /** * @brief Creates a new OFData with the specified `count` items of size 1. * * @param items The items to store in the OFData * @param count The number of items * @return A new autoreleased OFData */ | > > > > > > > > > > > > > > > | 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | @property (readonly, nonatomic) OFString *stringRepresentation; /** * @brief A string containing the data in Base64 encoding. */ @property (readonly, nonatomic) OFString *stringByBase64Encoding; /** * @brief Creates a new OFData that is empty with an item size of 1. * * @return A new autoreleased OFData */ + (instancetype)data; /** * @brief Creates a new OFData that is empty with the specified item size. * * @param itemSize The size of a single element in the OFData * @return A new autoreleased OFData */ + (instancetype)dataWithItemSize: (size_t)itemSize; /** * @brief Creates a new OFData with the specified `count` items of size 1. * * @param items The items to store in the OFData * @param count The number of items * @return A new autoreleased OFData */ |
︙ | ︙ | |||
119 120 121 122 123 124 125 | itemSize: (size_t)itemSize; /** * @brief Creates a new OFData with the specified `count` items of size 1 by * taking over ownership of the specified items pointer. * * If initialization fails for whatever reason, the passed memory is *not* | | | | 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | itemSize: (size_t)itemSize; /** * @brief Creates a new OFData with the specified `count` items of size 1 by * taking over ownership of the specified items pointer. * * If initialization fails for whatever reason, the passed memory is *not* * freed if `freeWhenDone` is true. * * @param items The items to store in the OFData * @param count The number of items * @param freeWhenDone Whether to free the pointer when it is no longer needed * by the OFData * @return A new autoreleased OFData */ + (instancetype)dataWithItemsNoCopy: (void *)items count: (size_t)count freeWhenDone: (bool)freeWhenDone; /** * @brief Creates a new OFData with the specified `count` items of the * specified size by taking ownership of the specified items pointer. * * If initialization fails for whatever reason, the passed memory is *not* * freed if `freeWhenDone` is true. * * @param items The items to store in the OFData * @param count The number of items * @param itemSize The item size of a single item in bytes * @param freeWhenDone Whether to free the pointer when it is no longer needed * by the OFData * @return A new autoreleased OFData |
︙ | ︙ | |||
163 164 165 166 167 168 169 | * @return A new autoreleased OFData */ + (instancetype)dataWithContentsOfFile: (OFString *)path; #endif /** * @brief Creates a new OFData with an item size of 1, containing the data of | | | | | 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | * @return A new autoreleased OFData */ + (instancetype)dataWithContentsOfFile: (OFString *)path; #endif /** * @brief Creates a new OFData with an item size of 1, containing the data of * the specified IRI. * * @param IRI The IRI to the contents for the OFData * @return A new autoreleased OFData */ + (instancetype)dataWithContentsOfIRI: (OFIRI *)IRI; /** * @brief Creates a new OFData with an item size of 1, containing the data of * the hex string representation. * * @param string The hex string representation of the data * @return A new autoreleased OFData |
︙ | ︙ | |||
192 193 194 195 196 197 198 199 200 201 202 203 204 205 | * @param string The string with the Base64-encoded data * @return A new autoreleased OFData * @throw OFInvalidFormatException The specified string is not correctly * formatted */ + (instancetype)dataWithBase64EncodedString: (OFString *)string; /** * @brief Initializes an already allocated OFData with the specified `count` * items of size 1. * * @param items The items to store in the OFData * @param count The number of items * @return An initialized OFData | > > > > > > > > > > > > > > > > > | 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | * @param string The string with the Base64-encoded data * @return A new autoreleased OFData * @throw OFInvalidFormatException The specified string is not correctly * formatted */ + (instancetype)dataWithBase64EncodedString: (OFString *)string; /** * @brief Initializes an already allocated OFData to be empty with an item size * of 1. * * @return An initialized OFData */ - (instancetype)init; /** * @brief Initializes an already allocated OFData to be empty with the * specified item size. * * @param itemSize The size of a single element in the OFData * @return An initialized OFData */ - (instancetype)initWithItemSize: (size_t)itemSize; /** * @brief Initializes an already allocated OFData with the specified `count` * items of size 1. * * @param items The items to store in the OFData * @param count The number of items * @return An initialized OFData |
︙ | ︙ | |||
221 222 223 224 225 226 227 | /** * @brief Initializes an already allocated OFData with the specified `count` * items of size 1 by taking over ownership of the specified items * pointer. * * If initialization fails for whatever reason, the passed memory is *not* | | | | 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | /** * @brief Initializes an already allocated OFData with the specified `count` * items of size 1 by taking over ownership of the specified items * pointer. * * If initialization fails for whatever reason, the passed memory is *not* * freed if `freeWhenDone` is true. * * @param items The items to store in the OFData * @param count The number of items * @param freeWhenDone Whether to free the pointer when it is no longer needed * by the OFData * @return An initialized OFData */ - (instancetype)initWithItemsNoCopy: (void *)items count: (size_t)count freeWhenDone: (bool)freeWhenDone; /** * @brief Initializes an already allocated OFData with the specified `count` * items of the specified size by taking ownership of the specified * items pointer. * * If initialization fails for whatever reason, the passed memory is *not* * freed if `freeWhenDone` is true. * * @param items The items to store in the OFData * @param count The number of items * @param itemSize The item size of a single item in bytes * @param freeWhenDone Whether to free the pointer when it is no longer needed * by the OFData * @return An initialized OFData |
︙ | ︙ | |||
266 267 268 269 270 271 272 | * @return An initialized OFData */ - (instancetype)initWithContentsOfFile: (OFString *)path; #endif /** * @brief Initializes an already allocated OFData with an item size of 1, | | | | | 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | * @return An initialized OFData */ - (instancetype)initWithContentsOfFile: (OFString *)path; #endif /** * @brief Initializes an already allocated OFData with an item size of 1, * containing the data of the specified IRI. * * @param IRI The IRI to the contents for the OFData * @return A new autoreleased OFData */ - (instancetype)initWithContentsOfIRI: (OFIRI *)IRI; /** * @brief Initializes an already allocated OFData with an item size of 1, * containing the data of the hex string representation. * * @param string The hex string representation of the data * @return A new autoreleased OFData |
︙ | ︙ | |||
342 343 344 345 346 347 348 | * * @param path The path of the file to write to */ - (void)writeToFile: (OFString *)path; #endif /** | | | | | 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | * * @param path The path of the file to write to */ - (void)writeToFile: (OFString *)path; #endif /** * @brief Writes the OFData to the specified IRI. * * @param IRI The IRI to write to */ - (void)writeToIRI: (OFIRI *)IRI; @end OF_ASSUME_NONNULL_END #import "OFMutableData.h" #import "OFData+CryptographicHashing.h" #import "OFData+MessagePackParsing.h" |
Modified src/OFData.m from [b0fcc38dae] to [4dc9cb934e].
1 | /* | | | | | | > > > > | < > | > | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdlib.h> #include <string.h> #include <limits.h> #import "OFData.h" #import "OFBase64.h" #import "OFConcreteData.h" #import "OFDictionary.h" #ifdef OF_HAVE_FILES # import "OFFile.h" # import "OFFileManager.h" #endif #import "OFIRI.h" #import "OFIRIHandler.h" #import "OFStream.h" #import "OFString.h" #import "OFSubdata.h" #import "OFSystemInfo.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFNotImplementedException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "OFTruncatedDataException.h" #import "OFUnsupportedProtocolException.h" static struct { Class isa; } placeholder; @interface OFPlaceholderData: OFString @end /* References for static linking */ void _references_to_categories_of_OFData(void) { _OFData_CryptographicHashing_reference = 1; _OFData_MessagePackParsing_reference = 1; } @implementation OFPlaceholderData - (instancetype)init { return (id)[[OFConcreteData alloc] init]; } - (instancetype)initWithItemSize: (size_t)itemSize { return (id)[[OFConcreteData alloc] initWithItemSize: itemSize]; } - (instancetype)initWithItems: (const void *)items count: (size_t)count { return (id)[[OFConcreteData alloc] initWithItems: items count: count]; } - (instancetype)initWithItems: (const void *)items count: (size_t)count itemSize: (size_t)itemSize { return (id)[[OFConcreteData alloc] initWithItems: items count: count itemSize: itemSize]; } - (instancetype)initWithItemsNoCopy: (void *)items count: (size_t)count freeWhenDone: (bool)freeWhenDone { return (id)[[OFConcreteData alloc] initWithItemsNoCopy: items count: count freeWhenDone: freeWhenDone]; } - (instancetype)initWithItemsNoCopy: (void *)items count: (size_t)count itemSize: (size_t)itemSize freeWhenDone: (bool)freeWhenDone { return (id)[[OFConcreteData alloc] initWithItemsNoCopy: items count: count itemSize: itemSize freeWhenDone: freeWhenDone]; } #ifdef OF_HAVE_FILES - (instancetype)initWithContentsOfFile: (OFString *)path { return (id)[[OFConcreteData alloc] initWithContentsOfFile: path]; } #endif - (instancetype)initWithContentsOfIRI: (OFIRI *)IRI { return (id)[[OFConcreteData alloc] initWithContentsOfIRI: IRI]; } - (instancetype)initWithStringRepresentation: (OFString *)string { return (id)[[OFConcreteData alloc] initWithStringRepresentation: string]; } - (instancetype)initWithBase64EncodedString: (OFString *)string { return (id)[[OFConcreteData alloc] initWithBase64EncodedString: string]; } OF_SINGLETON_METHODS @end @implementation OFData + (void)initialize { if (self == [OFData class]) object_setClass((id)&placeholder, [OFPlaceholderData class]); } + (instancetype)alloc { if (self == [OFData class]) return (id)&placeholder; return [super alloc]; } + (instancetype)data { return [[[self alloc] init] autorelease]; } + (instancetype)dataWithItemSize: (size_t)itemSize { return [[[self alloc] initWithItemSize: itemSize] autorelease]; } + (instancetype)dataWithItems: (const void *)items count: (size_t)count { return [[[self alloc] initWithItems: items count: count] autorelease]; } + (instancetype)dataWithItems: (const void *)items |
︙ | ︙ | |||
89 90 91 92 93 94 95 | #ifdef OF_HAVE_FILES + (instancetype)dataWithContentsOfFile: (OFString *)path { return [[[self alloc] initWithContentsOfFile: path] autorelease]; } #endif | | | > > > > > > > > > > > > > > > > > > > > > > < | < < < < < < < < < < < < < < < < < | < < < | < < < < < < < | < < < < < < < < | < < | < < < | < < | < < < < | < < < < < | > | > | | < < < < < < | | < | | | < | < | | < < < > > > > > > > > > > > > > > | > > | < < | < < < | 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 | #ifdef OF_HAVE_FILES + (instancetype)dataWithContentsOfFile: (OFString *)path { return [[[self alloc] initWithContentsOfFile: path] autorelease]; } #endif + (instancetype)dataWithContentsOfIRI: (OFIRI *)IRI { return [[[self alloc] initWithContentsOfIRI: IRI] autorelease]; } + (instancetype)dataWithStringRepresentation: (OFString *)string { return [[[self alloc] initWithStringRepresentation: string] autorelease]; } + (instancetype)dataWithBase64EncodedString: (OFString *)string { return [[[self alloc] initWithBase64EncodedString: string] autorelease]; } - (instancetype)init { if ([self isMemberOfClass: [OFData class]] || [self isMemberOfClass: [OFMutableData class]]) { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @throw e; } abort(); } return [super init]; } - (instancetype)initWithItemSize: (size_t)itemSize { OF_INVALID_INIT_METHOD } - (instancetype)initWithItems: (const void *)items count: (size_t)count { return [self initWithItems: items count: count itemSize: 1]; } - (instancetype)initWithItems: (const void *)items count: (size_t)count itemSize: (size_t)itemSize { OF_INVALID_INIT_METHOD } - (instancetype)initWithItemsNoCopy: (void *)items count: (size_t)count freeWhenDone: (bool)freeWhenDone { return [self initWithItemsNoCopy: items count: count itemSize: 1 freeWhenDone: freeWhenDone]; } - (instancetype)initWithItemsNoCopy: (void *)items count: (size_t)count itemSize: (size_t)itemSize freeWhenDone: (bool)freeWhenDone { OF_INVALID_INIT_METHOD } #ifdef OF_HAVE_FILES - (instancetype)initWithContentsOfFile: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFIRI *IRI; @try { IRI = [OFIRI fileIRIWithPath: path isDirectory: false]; } @catch (id e) { [self release]; @throw e; } self = [self initWithContentsOfIRI: IRI]; objc_autoreleasePoolPop(pool); return self; } #endif - (instancetype)initWithContentsOfIRI: (OFIRI *)IRI { char *items = NULL, *buffer = NULL; size_t count = 0; @try { void *pool = objc_autoreleasePoolPush(); OFStream *stream = [OFIRIHandler openItemAtIRI: IRI mode: @"r"]; size_t pageSize; pageSize = [OFSystemInfo pageSize]; buffer = OFAllocMemory(1, pageSize); while (!stream.atEndOfStream) { size_t length = [stream readIntoBuffer: buffer length: pageSize]; if (SIZE_MAX - count < length) @throw [OFOutOfRangeException exception]; items = OFResizeMemory(items, count + length, 1); memcpy(items + count, buffer, length); count += length; } objc_autoreleasePoolPop(pool); } @catch (id e) { OFFreeMemory(items); [self release]; @throw e; } @finally { OFFreeMemory(buffer); } @try { self = [self initWithItemsNoCopy: items count: count freeWhenDone: true]; } @catch (id e) { OFFreeMemory(items); @throw e; } return self; } - (instancetype)initWithStringRepresentation: (OFString *)string { char *items = NULL; size_t count = 0; @try { const char *cString; count = [string cStringLengthWithEncoding: OFStringEncodingASCII]; if (count % 2 != 0) @throw [OFInvalidFormatException exception]; count /= 2; items = OFAllocMemory(count, 1); cString = [string cStringWithEncoding: OFStringEncodingASCII]; for (size_t i = 0; i < count; i++) { uint8_t c1 = cString[2 * i]; uint8_t c2 = cString[2 * i + 1]; uint8_t byte; |
︙ | ︙ | |||
296 297 298 299 300 301 302 | else if (c2 >= 'a' && c2 <= 'f') byte |= c2 - 'a' + 10; else if (c2 >= 'A' && c2 <= 'F') byte |= c2 - 'A' + 10; else @throw [OFInvalidFormatException exception]; | | > > > > > > > > > > > < | < < | | | | < | > | | | > | | < < < > | | > < < < | < > > > > > > > | | < < | < | < | < | < > | | | > > | | > > > | | | | | > > > | | | | > | | | | | | > > | | < < | < > > | < < < | > > > > > | | | > > | | | | > > | | | | | | | > | | < < < < < < < < < < < < < < < < < < < < < < > | > > | | | | | | | | | | | 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 | else if (c2 >= 'a' && c2 <= 'f') byte |= c2 - 'a' + 10; else if (c2 >= 'A' && c2 <= 'F') byte |= c2 - 'A' + 10; else @throw [OFInvalidFormatException exception]; items[i] = byte; } } @catch (id e) { OFFreeMemory(items); [self release]; @throw e; } @try { self = [self initWithItemsNoCopy: items count: count freeWhenDone: true]; } @catch (id e) { OFFreeMemory(items); @throw e; } return self; } - (instancetype)initWithBase64EncodedString: (OFString *)string { void *pool = objc_autoreleasePoolPush(); OFMutableData *data; @try { data = [OFMutableData data]; if (!OFBase64Decode(data, [string cStringWithEncoding: OFStringEncodingASCII], [string cStringLengthWithEncoding: OFStringEncodingASCII])) @throw [OFInvalidFormatException exception]; } @catch (id e) { [self release]; @throw e; } /* Avoid copying if the class already matches. */ if (data.class == self.class) { [self release]; self = [data retain]; objc_autoreleasePoolPop(pool); return self; } /* * Make it immutable and avoid copying if the class already matches * after that. */ @try { [data makeImmutable]; } @catch (id e) { [self release]; @throw e; } if (data.class == self.class) { [self release]; self = [data retain]; objc_autoreleasePoolPop(pool); return self; } self = [self initWithItems: data.items count: data.count]; objc_autoreleasePoolPop(pool); return self; } - (size_t)count { OF_UNRECOGNIZED_SELECTOR } - (size_t)itemSize { OF_UNRECOGNIZED_SELECTOR } - (const void *)items { OF_UNRECOGNIZED_SELECTOR } - (const void *)itemAtIndex: (size_t)idx { if (idx >= self.count) @throw [OFOutOfRangeException exception]; return (const unsigned char *)self.items + idx * self.itemSize; } - (const void *)firstItem { const void *items = self.items; if (items == NULL || self.count == 0) return NULL; return items; } - (const void *)lastItem { const unsigned char *items = self.items; size_t count = self.count; if (items == NULL || count == 0) return NULL; return items + (count - 1) * self.itemSize; } - (id)copy { return [self retain]; } - (id)mutableCopy { return [[OFMutableData alloc] initWithItems: self.items count: self.count itemSize: self.itemSize]; } - (bool)isEqual: (id)object { size_t count, itemSize; OFData *data; if (object == self) return true; if (![object isKindOfClass: [OFData class]]) return false; count = self.count; itemSize = self.itemSize; data = object; if (data.count != count || data.itemSize != itemSize) return false; if (memcmp(data.items, self.items, count * itemSize) != 0) return false; return true; } - (OFComparisonResult)compare: (OFData *)data { int comparison; size_t count, dataCount, minCount; if (![data isKindOfClass: [OFData class]]) @throw [OFInvalidArgumentException exception]; if (data.itemSize != self.itemSize) @throw [OFInvalidArgumentException exception]; count = self.count; dataCount = data.count; minCount = (count > dataCount ? dataCount : count); if ((comparison = memcmp(self.items, data.items, minCount * self.itemSize)) == 0) { if (count > dataCount) return OFOrderedDescending; if (count < dataCount) return OFOrderedAscending; return OFOrderedSame; } if (comparison > 0) return OFOrderedDescending; else return OFOrderedAscending; } - (unsigned long)hash { const unsigned char *items = self.items; size_t count = self.count, itemSize = self.itemSize; unsigned long hash; OFHashInit(&hash); for (size_t i = 0; i < count * itemSize; i++) OFHashAddByte(&hash, items[i]); OFHashFinalize(&hash); return hash; } - (OFData *)subdataWithRange: (OFRange)range { if (range.length > SIZE_MAX - range.location || range.location + range.length > self.count) @throw [OFOutOfRangeException exception]; if (![self isKindOfClass: [OFMutableData class]]) return [[[OFSubdata alloc] initWithData: self range: range] autorelease]; return [OFData dataWithItems: (const unsigned char *)self.items + (range.location * self.itemSize) count: self.count itemSize: self.itemSize]; } - (OFString *)description { OFMutableString *ret = [OFMutableString stringWithString: @"<"]; const unsigned char *items = self.items; size_t count = self.count, itemSize = self.itemSize; for (size_t i = 0; i < count; i++) { if (i > 0) [ret appendString: @" "]; for (size_t j = 0; j < itemSize; j++) [ret appendFormat: @"%02x", items[i * itemSize + j]]; } [ret appendString: @">"]; [ret makeImmutable]; return ret; } - (OFString *)stringRepresentation { OFMutableString *ret = [OFMutableString string]; const unsigned char *items = self.items; size_t count = self.count, itemSize = self.itemSize; for (size_t i = 0; i < count; i++) for (size_t j = 0; j < itemSize; j++) [ret appendFormat: @"%02x", items[i * itemSize + j]]; [ret makeImmutable]; return ret; } - (OFString *)stringByBase64Encoding { return OFBase64Encode(self.items, self.count * self.itemSize); } - (OFRange)rangeOfData: (OFData *)data options: (OFDataSearchOptions)options range: (OFRange)range { const unsigned char *items = self.items; size_t count = self.count, itemSize = self.itemSize; const char *search; size_t searchLength; if (range.length > SIZE_MAX - range.location || range.location + range.length > count) @throw [OFOutOfRangeException exception]; if (data == nil || data.itemSize != itemSize) @throw [OFInvalidArgumentException exception]; if ((searchLength = data.count) == 0) return OFMakeRange(0, 0); if (searchLength > range.length) return OFMakeRange(OFNotFound, 0); search = data.items; if (options & OFDataSearchBackwards) { for (size_t i = range.length - searchLength;; i--) { if (memcmp(items + i * itemSize, search, searchLength * itemSize) == 0) return OFMakeRange(i, searchLength); /* No match and we're at the last item */ if (i == 0) break; } } else { for (size_t i = range.location; i <= range.length - searchLength; i++) if (memcmp(items + i * itemSize, search, searchLength * itemSize) == 0) return OFMakeRange(i, searchLength); } return OFMakeRange(OFNotFound, 0); } #ifdef OF_HAVE_FILES - (void)writeToFile: (OFString *)path { OFFile *file = [[OFFile alloc] initWithPath: path mode: @"w"]; @try { [file writeBuffer: self.items length: self.count * self.itemSize]; } @finally { [file release]; } } #endif - (void)writeToIRI: (OFIRI *)IRI { void *pool = objc_autoreleasePoolPush(); [[OFIRIHandler openItemAtIRI: IRI mode: @"w"] writeData: self]; objc_autoreleasePoolPop(pool); } - (OFData *)messagePackRepresentation { OFMutableData *data; size_t count; if (self.itemSize != 1) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; count = self.count; if (count <= UINT8_MAX) { uint8_t type = 0xC4; uint8_t tmp = (uint8_t)count; data = [OFMutableData dataWithCapacity: count + 2]; [data addItem: &type]; [data addItem: &tmp]; } else if (count <= UINT16_MAX) { uint8_t type = 0xC5; uint16_t tmp = OFToBigEndian16((uint16_t)count); data = [OFMutableData dataWithCapacity: count + 3]; [data addItem: &type]; [data addItems: &tmp count: sizeof(tmp)]; } else if (count <= UINT32_MAX) { uint8_t type = 0xC6; uint32_t tmp = OFToBigEndian32((uint32_t)count); data = [OFMutableData dataWithCapacity: count + 5]; [data addItem: &type]; [data addItems: &tmp count: sizeof(tmp)]; } else @throw [OFOutOfRangeException exception]; [data addItems: self.items count: count]; [data makeImmutable]; return data; } @end |
Modified src/OFDatagramSocket.h from [81b28eb069] to [b82d6edd45].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFKernelEventObserver.h" #import "OFRunLoop.h" #import "OFSocket.h" |
︙ | ︙ | |||
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | * than one thread at the same time is not thread-safe, even if copy * was called to create one "instance" for every thread! */ @interface OFDatagramSocket: OFObject <OFCopying, OFReadyForReadingObserving, OFReadyForWritingObserving> { OFSocketHandle _socket; bool _canBlock; #ifdef OF_WII bool _canSendToBroadcastAddresses; #endif id <OFDatagramSocketDelegate> _Nullable _delegate; OF_RESERVE_IVARS(OFDatagramSocket, 4) } /** * @brief Whether the socket can block. * * By default, a socket can block. * * @throw OFSetOptionFailedException The option could not be set */ @property (nonatomic) bool canBlock; /** * @brief Whether the socket can send to broadcast addresses. * * @throw OFSetOptionFailedException The option could not be set */ @property (nonatomic) bool canSendToBroadcastAddresses; /** * @brief The delegate for asynchronous operations on the socket. * | > > > > > > | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | * than one thread at the same time is not thread-safe, even if copy * was called to create one "instance" for every thread! */ @interface OFDatagramSocket: OFObject <OFCopying, OFReadyForReadingObserving, OFReadyForWritingObserving> { OFSocketHandle _socket; #ifdef OF_AMIGAOS LONG _socketID; int _family; /* unused, reserved for ABI stability */ #endif bool _canBlock; #ifdef OF_WII bool _canSendToBroadcastAddresses; #endif id <OFDatagramSocketDelegate> _Nullable _delegate; OF_RESERVE_IVARS(OFDatagramSocket, 4) } /** * @brief Whether the socket can block. * * By default, a socket can block. * * @throw OFGetOptionFailedException The option could not be retrieved * @throw OFSetOptionFailedException The option could not be set */ @property (nonatomic) bool canBlock; /** * @brief Whether the socket can send to broadcast addresses. * * @throw OFGetOptionFailedException The option could not be retrieved * @throw OFSetOptionFailedException The option could not be set */ @property (nonatomic) bool canSendToBroadcastAddresses; /** * @brief The delegate for asynchronous operations on the socket. * |
︙ | ︙ | |||
177 178 179 180 181 182 183 | * @brief Asynchronously receives a datagram and stores it into the specified * buffer. * * If the buffer is too small, the datagram is truncated. * * @param buffer The buffer to write the datagram to * @param length The length of the buffer | | > | 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | * @brief Asynchronously receives a datagram and stores it into the specified * buffer. * * If the buffer is too small, the datagram is truncated. * * @param buffer The buffer to write the datagram to * @param length The length of the buffer * @param runLoopMode The run loop mode in which to perform the asynchronous * receive */ - (void)asyncReceiveIntoBuffer: (void *)buffer length: (size_t)length runLoopMode: (OFRunLoopMode)runLoopMode; #ifdef OF_HAVE_BLOCKS /** |
︙ | ︙ | |||
211 212 213 214 215 216 217 | * @brief Asynchronously receives a datagram and stores it into the specified * buffer. * * If the buffer is too small, the datagram is truncated. * * @param buffer The buffer to write the datagram to * @param length The length of the buffer | | > | 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | * @brief Asynchronously receives a datagram and stores it into the specified * buffer. * * If the buffer is too small, the datagram is truncated. * * @param buffer The buffer to write the datagram to * @param length The length of the buffer * @param runLoopMode The run loop mode in which to perform the asynchronous * receive * @param block The block to call when the datagram has been received. If the * block returns true, it will be called again with the same * buffer and maximum length when more datagrams have been * received. If you want the next method in the queue to handle * the datagram received next, you need to return false from the * method. */ |
︙ | ︙ | |||
253 254 255 256 257 258 259 | - (void)asyncSendData: (OFData *)data receiver: (const OFSocketAddress *)receiver; /** * @brief Asynchronously sends the specified datagram to the specified address. * * @param data The data to send as a datagram | | | > | 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | - (void)asyncSendData: (OFData *)data receiver: (const OFSocketAddress *)receiver; /** * @brief Asynchronously sends the specified datagram to the specified address. * * @param data The data to send as a datagram * @param receiver A pointer to an @ref OFSocketAddress to which the datagram * should be sent. The receiver is copied. * @param runLoopMode The run loop mode in which to perform the asynchronous * send */ - (void)asyncSendData: (OFData *)data receiver: (const OFSocketAddress *)receiver runLoopMode: (OFRunLoopMode)runLoopMode; #ifdef OF_HAVE_BLOCKS /** |
︙ | ︙ | |||
282 283 284 285 286 287 288 | /** * @brief Asynchronously sends the specified datagram to the specified address. * * @param data The data to send as a datagram * @param receiver A pointer to an @ref OFSocketAddress to which the datagram * should be sent. The receiver is copied. | | > > > > > > > > > > > > > > > > > > > > > > > > > | 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 | /** * @brief Asynchronously sends the specified datagram to the specified address. * * @param data The data to send as a datagram * @param receiver A pointer to an @ref OFSocketAddress to which the datagram * should be sent. The receiver is copied. * @param runLoopMode The run loop mode in which to perform the asynchronous * send * @param block The block to call when the packet has been sent. It should * return the data for the next send with the same callback or nil * if it should not repeat. */ - (void)asyncSendData: (OFData *)data receiver: (const OFSocketAddress *)receiver runLoopMode: (OFRunLoopMode)runLoopMode block: (OFDatagramSocketAsyncSendDataBlock)block; #endif /** * @brief Releases the socket from the current thread. * * This is necessary on some platforms in order to allow a different thread to * use the socket, e.g. on AmigaOS, but you should call it on all operating * systems before using the socket from a different thread. * * After calling this method, you must no longer use the socket until * @ref obtainSocketForCurrentThread has been called. */ - (void)releaseSocketFromCurrentThread; /** * @brief Obtains the socket for the current thread. * * This is necessary on some platforms in order to allow a different thread to * use the socket, e.g. on AmigaOS, but you should call it on all operating * systems before using the socket from a different thread. * * You must only call this method after @ref releaseSocketFromCurrentThread has * been called from a different thread. */ - (void)obtainSocketForCurrentThread; /** * @brief Cancels all pending asynchronous requests on the socket. */ - (void)cancelAsyncRequests; /** * @brief Closes the socket so that it can neither receive nor send any more |
︙ | ︙ |
Modified src/OFDatagramSocket.m from [ea19c6b109] to [65c253c5c9].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #ifndef _XOPEN_SOURCE_EXTENDED # define _XOPEN_SOURCE_EXTENDED #endif |
︙ | ︙ | |||
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | #import "OFDatagramSocket.h" #import "OFData.h" #import "OFRunLoop.h" #import "OFRunLoop+Private.h" #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFGetOptionFailedException.h" #import "OFInitializationFailedException.h" #import "OFNotOpenException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFSetOptionFailedException.h" #import "OFSetOptionFailedException.h" #import "OFWriteFailedException.h" @implementation OFDatagramSocket @synthesize delegate = _delegate; + (void)initialize { if (self != [OFDatagramSocket class]) | > > > > > > | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | #import "OFDatagramSocket.h" #import "OFData.h" #import "OFRunLoop.h" #import "OFRunLoop+Private.h" #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFAlreadyOpenException.h" #import "OFGetOptionFailedException.h" #import "OFInitializationFailedException.h" #import "OFNotOpenException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFSetOptionFailedException.h" #import "OFSetOptionFailedException.h" #import "OFWriteFailedException.h" #if defined(OF_AMIGAOS) && !defined(UNIQUE_ID) # define UNIQUE_ID -1 #endif @implementation OFDatagramSocket @synthesize delegate = _delegate; + (void)initialize { if (self != [OFDatagramSocket class]) |
︙ | ︙ | |||
67 68 69 70 71 72 73 74 75 76 77 78 79 80 | @try { if (self.class == [OFDatagramSocket class]) { [self doesNotRecognizeSelector: _cmd]; abort(); } _socket = OFInvalidSocketHandle; _canBlock = true; } @catch (id e) { [self release]; @throw e; } return self; | > > > | 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | @try { if (self.class == [OFDatagramSocket class]) { [self doesNotRecognizeSelector: _cmd]; abort(); } _socket = OFInvalidSocketHandle; #ifdef OF_HAVE_AMIGAOS _socketID = -1; #endif _canBlock = true; } @catch (id e) { [self release]; @throw e; } return self; |
︙ | ︙ | |||
194 195 196 197 198 199 200 | @throw [OFReadFailedException exceptionWithObject: self requestedLength: length errNo: OFSocketErrNo()]; #endif if (sender != NULL) { | | > > > | | | | | | | | | | | | | | | | | | | > > | 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | @throw [OFReadFailedException exceptionWithObject: self requestedLength: length errNo: OFSocketErrNo()]; #endif if (sender != NULL) { struct sockaddr *sa = (struct sockaddr *)&sender->sockaddr; if (sender->length >= (socklen_t)sizeof(sa->sa_family)) { switch (sa->sa_family) { case AF_INET: sender->family = OFSocketAddressFamilyIPv4; break; #ifdef OF_HAVE_IPV6 case AF_INET6: sender->family = OFSocketAddressFamilyIPv6; break; #endif #ifdef OF_HAVE_UNIX_SOCKETS case AF_UNIX: sender->family = OFSocketAddressFamilyUNIX; break; #endif #ifdef OF_HAVE_IPX case AF_IPX: sender->family = OFSocketAddressFamilyIPX; break; #endif #ifdef OF_HAVE_APPLETALK case AF_APPLETALK: sender->family = OFSocketAddressFamilyAppleTalk; break; #endif default: sender->family = OFSocketAddressFamilyUnknown; break; } } else sender->family = OFSocketAddressFamilyUnknown; } return ret; } - (void)asyncReceiveIntoBuffer: (void *)buffer length: (size_t)length { |
︙ | ︙ | |||
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | if (_socket > INT_MAX) @throw [OFOutOfRangeException exception]; return (int)_socket; #endif } - (void)close { if (_socket == OFInvalidSocketHandle) @throw [OFNotOpenException exceptionWithObject: self]; closesocket(_socket); _socket = OFInvalidSocketHandle; } @end | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 | if (_socket > INT_MAX) @throw [OFOutOfRangeException exception]; return (int)_socket; #endif } - (void)releaseSocketFromCurrentThread { #ifdef OF_AMIGAOS if (_socket == OFInvalidSocketHandle) @throw [OFNotOpenException exceptionWithObject: self]; if ((_socketID = ReleaseSocket(_socket, UNIQUE_ID)) == -1) { switch (Errno()) { case ENOMEM: @throw [OFOutOfMemoryException exceptionWithRequestedSize: 0]; case EBADF: @throw [OFNotOpenException exceptionWithObject: self]; default: OFEnsure(0); } } _socket = OFInvalidSocketHandle; #endif } - (void)obtainSocketForCurrentThread { #ifdef OF_AMIGAOS if (_socket != OFInvalidSocketHandle) @throw [OFAlreadyOpenException exceptionWithObject: self]; if (_socketID == -1) @throw [OFNotOpenException exceptionWithObject: self]; /* * FIXME: We should store these, but that requires changing all * subclasses. This only becomes a problem if IPv6 support ever * gets added. */ _socket = ObtainSocket(_socketID, AF_INET, SOCK_DGRAM, 0); if (_socket == OFInvalidSocketHandle) @throw [OFInitializationFailedException exceptionWithClass: self.class]; _socketID = -1; #endif } - (void)close { if (_socket == OFInvalidSocketHandle) @throw [OFNotOpenException exceptionWithObject: self]; closesocket(_socket); _socket = OFInvalidSocketHandle; } @end |
Modified src/OFDate.h from [ba59d767f1] to [0ad2116703].
1 | /* | | | | | | > > > > | < > | < < < < | < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFMessagePackRepresentation.h" OF_ASSUME_NONNULL_BEGIN @class OFString; @class OFConstantString; /** * @class OFDate OFDate.h ObjFW/OFDate.h * * @brief A class for storing, accessing and comparing dates. */ @interface OFDate: OFObject <OFCopying, OFComparing, OFMessagePackRepresentation> #ifdef OF_HAVE_CLASS_PROPERTIES @property (class, readonly, nonatomic) OFDate *distantFuture; @property (class, readonly, nonatomic) OFDate *distantPast; #endif /** * @brief The microsecond of the date. |
︙ | ︙ | |||
193 194 195 196 197 198 199 | */ + (instancetype)dateWithLocalDateString: (OFString *)string format: (OFString *)format; /** * @brief Returns a date in the distant future. * | | | | 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | */ + (instancetype)dateWithLocalDateString: (OFString *)string format: (OFString *)format; /** * @brief Returns a date in the distant future. * * The date is system-dependent. * * @return A date in the distant future */ + (instancetype)distantFuture; /** * @brief Returns a date in the distant past. * * The date is system-dependent. * * @return A date in the distant past */ + (instancetype)distantPast; /** * @brief Initializes an already allocated OFDate with the specified date and |
︙ | ︙ | |||
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | */ - (OFComparisonResult)compare: (OFDate *)date; /** * @brief Creates a string of the date with the specified format. * * See the man page for `strftime` for information on the format. * * @param format The format for the date string * @return A new, autoreleased OFString * @throw OFInvalidFormatException The specified format is invalid */ - (OFString *)dateStringWithFormat: (OFConstantString *)format; /** * @brief Creates a string of the local date with the specified format. * * See the man page for `strftime` for information on the format. * * @param format The format for the date string * @return A new, autoreleased OFString * @throw OFInvalidFormatException The specified format is invalid */ - (OFString *)localDateStringWithFormat: (OFConstantString *)format; | > > > > > > > > | 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 | */ - (OFComparisonResult)compare: (OFDate *)date; /** * @brief Creates a string of the date with the specified format. * * See the man page for `strftime` for information on the format. * * @warning The format is currently limited to the following format specifiers: * %%a, %%b, %%d, %%e, %%H, %%m, %%M, %%S, %%y, %%Y, %%z, %%, %%n and * %%t. * * @param format The format for the date string * @return A new, autoreleased OFString * @throw OFInvalidFormatException The specified format is invalid */ - (OFString *)dateStringWithFormat: (OFConstantString *)format; /** * @brief Creates a string of the local date with the specified format. * * See the man page for `strftime` for information on the format. * * @warning The format is currently limited to the following format specifiers: * %%a, %%b, %%d, %%e, %%H, %%m, %%M, %%S, %%y, %%Y, %%z, %%, %%n and * %%t. * * @param format The format for the date string * @return A new, autoreleased OFString * @throw OFInvalidFormatException The specified format is invalid */ - (OFString *)localDateStringWithFormat: (OFConstantString *)format; |
︙ | ︙ |
Modified src/OFDate.m from [692871b1cf] to [2047693bf0].
1 | /* | | | | | | > > > > | < > | > > | | | < | < < < < < < < < | < < < > | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #define OF_DATE_M #include "config.h" #include <limits.h> #include <time.h> #include <math.h> #include <sys/time.h> #import "OFDate.h" #import "OFConcreteDate.h" #import "OFData.h" #import "OFDictionary.h" #import "OFMessagePackExtension.h" #ifdef OF_HAVE_THREADS # import "OFMutex.h" #endif #import "OFStrFTime.h" #import "OFStrPTime.h" #import "OFString.h" #import "OFSystemInfo.h" #import "OFTaggedPointerDate.h" #import "OFXMLAttribute.h" #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #if defined(OF_AMIGAOS_M68K) || defined(OF_MINT) /* amiga-gcc and freemint-gcc do not have trunc() */ # define trunc(x) ((int64_t)(x)) #endif @interface OFPlaceholderDate: OFDate @end @interface OFConcreteDateSingleton: OFConcreteDate @end static struct { Class isa; } placeholder; static OFConcreteDateSingleton *zeroDate, *distantFuture, *distantPast; static void initZeroDate(void) { zeroDate = [[OFConcreteDateSingleton alloc] initWithTimeIntervalSince1970: 0]; } static void initDistantFuture(void) { distantFuture = [[OFConcreteDateSingleton alloc] initWithTimeIntervalSince1970: 64060588800.0]; } static void initDistantPast(void) { distantPast = [[OFConcreteDateSingleton alloc] initWithTimeIntervalSince1970: -62167219200.0]; } static OFTimeInterval now(void) { struct timeval tv; |
︙ | ︙ | |||
256 257 258 259 260 261 262 | seconds += tm->tm_sec; /* Time zone */ seconds += -(double)tz * 60; return seconds; } | | < < < < | < < < < < < < < < < < < < | | 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | seconds += tm->tm_sec; /* Time zone */ seconds += -(double)tz * 60; return seconds; } @implementation OFConcreteDateSingleton OF_SINGLETON_METHODS @end @implementation OFPlaceholderDate #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)initWithTimeIntervalSince1970: (OFTimeInterval)seconds |
︙ | ︙ | |||
302 303 304 305 306 307 308 | #if defined(OF_OBJFW_RUNTIME) && UINTPTR_MAX == UINT64_MAX value = OFFromBigEndian64(OFDoubleToRawUInt64(OFToBigEndianDouble( seconds))); /* Almost all dates fall into this range. */ if (value & (UINT64_C(4) << 60)) { | | | > | < < < < < < | < < < < < < | | < < < < < < < < < | 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 | #if defined(OF_OBJFW_RUNTIME) && UINTPTR_MAX == UINT64_MAX value = OFFromBigEndian64(OFDoubleToRawUInt64(OFToBigEndianDouble( seconds))); /* Almost all dates fall into this range. */ if (value & (UINT64_C(4) << 60)) { id ret = [OFTaggedPointerDate dateWithUInt64TimeIntervalSince1970: value]; if (ret != nil) return ret; } #endif return (id)[[OFConcreteDate alloc] initWithTimeIntervalSince1970: seconds]; } #ifdef __clang__ # pragma clang diagnostic pop #endif OF_SINGLETON_METHODS @end @implementation OFDate + (void)initialize { #ifdef OF_WINDOWS HMODULE module; #endif if (self != [OFDate class]) return; object_setClass((id)&placeholder, [OFPlaceholderDate class]); #if (!defined(HAVE_GMTIME_R) || !defined(HAVE_LOCALTIME_R)) && \ defined(OF_HAVE_THREADS) mutex = [[OFMutex alloc] init]; atexit(releaseMutex); #endif #ifdef OF_WINDOWS if ((module = GetModuleHandle("msvcrt.dll")) != NULL) _mktime64FuncPtr = (__time64_t (*)(struct tm *)) GetProcAddress(module, "_mktime64"); #endif } + (instancetype)alloc { if (self == [OFDate class]) return (id)&placeholder; |
︙ | ︙ | |||
425 426 427 428 429 430 431 | - (instancetype)init { return [self initWithTimeIntervalSince1970: now()]; } - (instancetype)initWithTimeIntervalSince1970: (OFTimeInterval)seconds { | > > > > | > | | > | > | | 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 | - (instancetype)init { return [self initWithTimeIntervalSince1970: now()]; } - (instancetype)initWithTimeIntervalSince1970: (OFTimeInterval)seconds { if ([self isMemberOfClass: [OFDate class]]) { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @throw e; } abort(); } return [super init]; } - (instancetype)initWithTimeIntervalSinceNow: (OFTimeInterval)seconds { return [self initWithTimeIntervalSince1970: now() + seconds]; } |
︙ | ︙ | |||
492 493 494 495 496 497 498 | seconds = tmAndTzToTime(&tm, tz); objc_autoreleasePoolPop(pool); return [self initWithTimeIntervalSince1970: seconds]; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 457 458 459 460 461 462 463 464 465 466 467 468 469 470 | seconds = tmAndTzToTime(&tm, tz); objc_autoreleasePoolPop(pool); return [self initWithTimeIntervalSince1970: seconds]; } - (bool)isEqual: (id)object { OFDate *otherDate; if (object == self) return true; |
︙ | ︙ | |||
580 581 582 583 584 585 586 | return OFOrderedDescending; return OFOrderedSame; } - (OFString *)description { | | < < < < < < < < < < < < < < < < < < < < | 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 | return OFOrderedDescending; return OFOrderedSame; } - (OFString *)description { return [self dateStringWithFormat: @"%Y-%m-%dT%H:%M:%S%z"]; } - (OFData *)messagePackRepresentation { void *pool = objc_autoreleasePoolPush(); OFTimeInterval timeInterval = self.timeIntervalSince1970; int64_t seconds = (int64_t)timeInterval; |
︙ | ︙ | |||
746 747 748 749 750 751 752 | - (OFString *)dateStringWithFormat: (OFConstantString *)format { OFString *ret; OFTimeInterval timeInterval = self.timeIntervalSince1970; time_t seconds = (time_t)timeInterval; struct tm tm; size_t pageSize; | < < < < | 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 | - (OFString *)dateStringWithFormat: (OFConstantString *)format { OFString *ret; OFTimeInterval timeInterval = self.timeIntervalSince1970; time_t seconds = (time_t)timeInterval; struct tm tm; size_t pageSize; char *buffer; if (seconds != trunc(timeInterval)) @throw [OFOutOfRangeException exception]; #ifdef HAVE_GMTIME_R if (gmtime_r(&seconds, &tm) == NULL) @throw [OFOutOfRangeException exception]; |
︙ | ︙ | |||
780 781 782 783 784 785 786 | } # endif #endif pageSize = [OFSystemInfo pageSize]; buffer = OFAllocMemory(1, pageSize); @try { | < | > < < < < < < < < < < < | 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 | } # endif #endif pageSize = [OFSystemInfo pageSize]; buffer = OFAllocMemory(1, pageSize); @try { if (OFStrFTime(buffer, pageSize, format.UTF8String, &tm, 0) == 0) @throw [OFOutOfRangeException exception]; ret = [OFString stringWithUTF8String: buffer]; } @finally { OFFreeMemory(buffer); } return ret; } - (OFString *)localDateStringWithFormat: (OFConstantString *)format { OFString *ret; OFTimeInterval timeInterval = self.timeIntervalSince1970; time_t seconds = (time_t)timeInterval; struct tm tm; size_t pageSize; char *buffer; if (seconds != trunc(timeInterval)) @throw [OFOutOfRangeException exception]; #ifdef HAVE_LOCALTIME_R if (localtime_r(&seconds, &tm) == NULL) @throw [OFOutOfRangeException exception]; |
︙ | ︙ | |||
840 841 842 843 844 845 846 | } # endif #endif pageSize = [OFSystemInfo pageSize]; buffer = OFAllocMemory(1, pageSize); @try { | < | > < < < < < < < | 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 | } # endif #endif pageSize = [OFSystemInfo pageSize]; buffer = OFAllocMemory(1, pageSize); @try { if (OFStrFTime(buffer, pageSize, format.UTF8String, &tm, 0) == 0) @throw [OFOutOfRangeException exception]; ret = [OFString stringWithUTF8String: buffer]; } @finally { OFFreeMemory(buffer); } return ret; } |
︙ | ︙ | |||
883 884 885 886 887 888 889 | return otherDate; return self; } - (OFTimeInterval)timeIntervalSince1970 { | | | 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 | return otherDate; return self; } - (OFTimeInterval)timeIntervalSince1970 { OF_UNRECOGNIZED_SELECTOR } - (OFTimeInterval)timeIntervalSinceDate: (OFDate *)otherDate { return self.timeIntervalSince1970 - otherDate.timeIntervalSince1970; } |
︙ | ︙ |
Modified src/OFDictionary.h from [73af2a9ef3] to [845e95ee6f].
1 | /* | | | | | | > > > > | < > | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS #endif #ifndef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS #endif #include <stdarg.h> #import "OFObject.h" #import "OFCollection.h" #import "OFEnumerator.h" #import "OFJSONRepresentation.h" #import "OFMessagePackRepresentation.h" OF_ASSUME_NONNULL_BEGIN @class OFArray OF_GENERIC(ObjectType); |
︙ | ︙ | |||
73 74 75 76 77 78 79 | * @note Fast enumeration on a dictionary enumerates through the keys of the * dictionary. * * @note Subclasses must implement @ref objectForKey:, @ref count and * @ref keyEnumerator. */ @interface OFDictionary OF_GENERIC(KeyType, ObjectType): OFObject <OFCopying, | | | 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | * @note Fast enumeration on a dictionary enumerates through the keys of the * dictionary. * * @note Subclasses must implement @ref objectForKey:, @ref count and * @ref keyEnumerator. */ @interface OFDictionary OF_GENERIC(KeyType, ObjectType): OFObject <OFCopying, OFMutableCopying, OFCollection, OFJSONRepresentation, OFMessagePackRepresentation> #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) # define KeyType id # define ObjectType id #endif /** * @brief An array of all keys. |
︙ | ︙ | |||
146 147 148 149 150 151 152 153 154 155 156 157 158 159 | * * @param firstKey The first key * @return A new autoreleased OFDictionary */ + (instancetype)dictionaryWithKeysAndObjects: (KeyType)firstKey, ... OF_SENTINEL; /** * @brief Initializes an already allocated OFDictionary with the specified * OFDictionary. * * @param dictionary An OFDictionary * @return An initialized OFDictionary */ | > > > > > > > | 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | * * @param firstKey The first key * @return A new autoreleased OFDictionary */ + (instancetype)dictionaryWithKeysAndObjects: (KeyType)firstKey, ... OF_SENTINEL; /** * @brief Initializes an already allocated OFDictionary to be empty. * * @return An initialized OFDictionary */ - (instancetype)init OF_DESIGNATED_INITIALIZER; /** * @brief Initializes an already allocated OFDictionary with the specified * OFDictionary. * * @param dictionary An OFDictionary * @return An initialized OFDictionary */ |
︙ | ︙ | |||
188 189 190 191 192 193 194 | * @param keys An array of keys * @param objects An array of objects * @param count The number of objects in the arrays * @return An initialized OFDictionary */ - (instancetype)initWithObjects: (ObjectType const _Nonnull *_Nonnull)objects forKeys: (KeyType const _Nonnull *_Nonnull)keys | | | 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | * @param keys An array of keys * @param objects An array of objects * @param count The number of objects in the arrays * @return An initialized OFDictionary */ - (instancetype)initWithObjects: (ObjectType const _Nonnull *_Nonnull)objects forKeys: (KeyType const _Nonnull *_Nonnull)keys count: (size_t)count OF_DESIGNATED_INITIALIZER; /** * @brief Initializes an already allocated OFDictionary with the specified keys * and objects. * * @param firstKey The first key * @return An initialized OFDictionary |
︙ | ︙ |
Modified src/OFDictionary.m from [9689ae0f89] to [d2c729f348].
1 | /* | | | | | | > > > > | < > | < < > < < < < | | | | > > > | < < | | | | | | | | < < < < < | < < < < < < < < < < < < < < < < < < | < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdlib.h> #import "OFDictionary.h" #import "OFArray.h" #import "OFCharacterSet.h" #import "OFConcreteDictionary.h" #import "OFData.h" #import "OFEnumerator.h" #import "OFString.h" #import "OFInvalidArgumentException.h" #import "OFOutOfRangeException.h" #import "OFUndefinedKeyException.h" static struct { Class isa; } placeholder; @interface OFDictionary () - (OFString *) of_JSONRepresentationWithOptions: (OFJSONRepresentationOptions)options depth: (size_t)depth; @end @interface OFPlaceholderDictionary: OFDictionary @end OF_DIRECT_MEMBERS @interface OFDictionaryObjectEnumerator: OFEnumerator { OFDictionary *_dictionary; OFEnumerator *_keyEnumerator; } - (instancetype)initWithDictionary: (OFDictionary *)dictionary; @end @implementation OFPlaceholderDictionary #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)init { return (id)[[OFConcreteDictionary alloc] init]; } - (instancetype)initWithDictionary: (OFDictionary *)dictionary { return (id)[[OFConcreteDictionary alloc] initWithDictionary: dictionary]; } - (instancetype)initWithObject: (id)object forKey: (id)key { return (id)[[OFConcreteDictionary alloc] initWithObject: object forKey: key]; } - (instancetype)initWithObjects: (OFArray *)objects forKeys: (OFArray *)keys { return (id)[[OFConcreteDictionary alloc] initWithObjects: objects forKeys: keys]; } - (instancetype)initWithObjects: (id const *)objects forKeys: (id const *)keys count: (size_t)count { return (id)[[OFConcreteDictionary alloc] initWithObjects: objects forKeys: keys count: count]; } - (instancetype)initWithKeysAndObjects: (id <OFCopying>)firstKey, ... { id ret; va_list arguments; va_start(arguments, firstKey); ret = [[OFConcreteDictionary alloc] initWithKey: firstKey arguments: arguments]; va_end(arguments); return ret; } - (instancetype)initWithKey: (id <OFCopying>)firstKey arguments: (va_list)arguments { return (id)[[OFConcreteDictionary alloc] initWithKey: firstKey arguments: arguments]; } #ifdef __clang__ # pragma clang diagnostic pop #endif OF_SINGLETON_METHODS @end @implementation OFDictionary + (void)initialize { if (self == [OFDictionary class]) object_setClass((id)&placeholder, [OFPlaceholderDictionary class]); } + (instancetype)alloc { if (self == [OFDictionary class]) return (id)&placeholder; |
︙ | ︙ | |||
259 260 261 262 263 264 265 | va_end(arguments); return ret; } - (instancetype)init { | | > > > > | > > > | > > > > > > > > > > > > > > > > > > > > > > > | | > > > | > | > | | > > > > > > > > > > > > > > > > | > > | > > > > > > | > > | > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 | va_end(arguments); return ret; } - (instancetype)init { if ([self isMemberOfClass: [OFDictionary class]] || [self isMemberOfClass: [OFMutableDictionary class]]) { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @throw e; } abort(); } return [super init]; } - (instancetype)initWithDictionary: (OFDictionary *)dictionary { void *pool = objc_autoreleasePoolPush(); id const *objects, *keys; size_t count; @try { OFArray *objects_ = [dictionary.objectEnumerator allObjects]; OFArray *keys_ = [dictionary.keyEnumerator allObjects]; count = dictionary.count; if (count != keys_.count || count != objects_.count) @throw [OFInvalidArgumentException exception]; objects = objects_.objects; keys = keys_.objects; } @catch (id e) { [self release]; @throw e; } @try { self = [self initWithObjects: objects forKeys: keys count: count]; } @finally { objc_autoreleasePoolPop(pool); } return self; } - (instancetype)initWithObject: (id)object forKey: (id)key { @try { if (key == nil || object == nil) @throw [OFInvalidArgumentException exception]; } @catch (id e) { [self release]; @throw e; } return [self initWithObjects: &object forKeys: &key count: 1]; } - (instancetype)initWithObjects: (OFArray *)objects_ forKeys: (OFArray *)keys_ { void *pool = objc_autoreleasePoolPush(); id const *objects, *keys; size_t count; @try { count = objects_.count; if (count != keys_.count) @throw [OFInvalidArgumentException exception]; objects = objects_.objects; keys = keys_.objects; } @catch (id e) { [self release]; @throw e; } self = [self initWithObjects: objects forKeys: keys count: count]; objc_autoreleasePoolPop(pool); return self; } #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)initWithObjects: (id const *)objects forKeys: (id const *)keys count: (size_t)count { OF_INVALID_INIT_METHOD } #ifdef __clang__ # pragma clang diagnostic pop #endif - (instancetype)initWithKeysAndObjects: (id)firstKey, ... { id ret; va_list arguments; va_start(arguments, firstKey); ret = [self initWithKey: firstKey arguments: arguments]; va_end(arguments); return ret; } - (instancetype)initWithKey: (id)firstKey arguments: (va_list)arguments { size_t count = 1; id *objects = NULL, *keys = NULL; va_list argumentsCopy; if (firstKey == nil) return [self init]; va_copy(argumentsCopy, arguments); while (va_arg(argumentsCopy, id) != nil) count++; @try { size_t i = 0; id key, object; if (count % 2 != 0) @throw [OFInvalidArgumentException exception]; count /= 2; objects = OFAllocMemory(count, sizeof(id)); keys = OFAllocMemory(count, sizeof(id)); keys[i] = firstKey; objects[i] = va_arg(arguments, id); if (objects[i] == nil) @throw [OFInvalidArgumentException exception]; i++; while ((key = va_arg(arguments, id)) != nil && (object = va_arg(arguments, id)) != nil) { OFEnsure(i < count); objects[i] = object; keys[i] = key; i++; } } @catch (id e) { OFFreeMemory(objects); OFFreeMemory(keys); [self release]; @throw e; } @try { self = [self initWithObjects: objects forKeys: keys count: count]; } @finally { OFFreeMemory(objects); OFFreeMemory(keys); } return self; } - (id)objectForKey: (id)key { OF_UNRECOGNIZED_SELECTOR } |
︙ | ︙ | |||
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 | initWithDictionary: self] autorelease]; } - (int)countByEnumeratingWithState: (OFFastEnumerationState *)state objects: (id *)objects count: (int)count { OFEnumerator *enumerator; int i; memcpy(&enumerator, state->extra, sizeof(enumerator)); if (enumerator == nil) { enumerator = [self keyEnumerator]; memcpy(state->extra, &enumerator, sizeof(enumerator)); } state->itemsPtr = objects; | > | | 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 | initWithDictionary: self] autorelease]; } - (int)countByEnumeratingWithState: (OFFastEnumerationState *)state objects: (id *)objects count: (int)count { static unsigned long dummyMutations; OFEnumerator *enumerator; int i; memcpy(&enumerator, state->extra, sizeof(enumerator)); if (enumerator == nil) { enumerator = [self keyEnumerator]; memcpy(state->extra, &enumerator, sizeof(enumerator)); } state->itemsPtr = objects; state->mutationsPtr = &dummyMutations; for (i = 0; i < count; i++) { id object = [enumerator nextObject]; if (object == nil) return i; |
︙ | ︙ | |||
635 636 637 638 639 640 641 | [ret makeImmutable]; objc_autoreleasePoolPop(pool); return ret; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 657 658 659 660 661 662 663 664 665 666 667 668 669 670 | [ret makeImmutable]; objc_autoreleasePoolPop(pool); return ret; } - (OFString *)JSONRepresentation { return [self of_JSONRepresentationWithOptions: 0 depth: 0]; } - (OFString *)JSONRepresentationWithOptions: (OFJSONRepresentationOptions)options |
︙ | ︙ | |||
822 823 824 825 826 827 828 | child = object.messagePackRepresentation; [data addItems: child.items count: child.count]; objc_autoreleasePoolPop(pool2); } | | | 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 | child = object.messagePackRepresentation; [data addItems: child.items count: child.count]; objc_autoreleasePoolPop(pool2); } OFAssert(i == count); [data makeImmutable]; objc_autoreleasePoolPop(pool); return data; } |
︙ | ︙ |
Renamed and modified src/OFEmbeddedURIHandler.h [5163464dd8] to src/OFEmbeddedIRIHandler.h [81de4817d6].
1 | /* | | | | | | > > > > | < > | | | > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "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 |
Renamed and modified src/OFEmbeddedURIHandler.m [bac2da914b] to src/OFEmbeddedIRIHandler.m [0aa22bc193].
1 | /* | | | | | | > > > > | < > | | | | | > | | < | | | > > > > > > > > | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #include <stdlib.h> #include <string.h> #import "OFEmbeddedIRIHandler.h" #import "OFIRI.h" #import "OFMemoryStream.h" #import "OFInvalidArgumentException.h" #import "OFOpenItemFailedException.h" #ifdef OF_HAVE_THREADS # import "OFOnce.h" # import "OFPlainMutex.h" #endif struct EmbeddedFile { OFString *path; const uint8_t *bytes; size_t size; } *embeddedFiles = NULL; size_t numEmbeddedFiles = 0; #ifdef OF_HAVE_THREADS static OFPlainMutex mutex; static OFOnceControl mutexOnceControl = OFOnceControlInitValue; static void 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 |
Modified src/OFEnumerator.h from [bebf66139d] to [bed4d85dff].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" OF_ASSUME_NONNULL_BEGIN @class OFArray OF_GENERIC(ObjectType); |
︙ | ︙ |
Modified src/OFEnumerator.m from [bb10b4629e] to [6b1e08d49c].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdlib.h> #import "OFEnumerator.h" |
︙ | ︙ | |||
57 58 59 60 61 62 63 64 65 66 | return ret; } - (int)countByEnumeratingWithState: (OFFastEnumerationState *)state objects: (id *)objects count: (int)count { int i; state->itemsPtr = objects; | > | | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | return ret; } - (int)countByEnumeratingWithState: (OFFastEnumerationState *)state objects: (id *)objects count: (int)count { static unsigned long dummyMutations; int i; state->itemsPtr = objects; state->mutationsPtr = &dummyMutations; for (i = 0; i < count; i++) { id object = [self nextObject]; if (object == nil) return i; objects[i] = object; } return i; } @end |
Modified src/OFEpollKernelEventObserver.h from [d3c4bbd7da] to [81c2871892].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFKernelEventObserver.h" OF_ASSUME_NONNULL_BEGIN @class OFMapTable; |
︙ | ︙ |
Modified src/OFEpollKernelEventObserver.m from [a510ac5746] to [97cdb30ab0].
1 | /* | | | | | | > > > > | < > | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #ifdef HAVE_FCNTL_H # include <fcntl.h> #endif #include "unistd_wrapper.h" |
︙ | ︙ |
Modified src/OFFile.h from [b56cdf66da] to [844dd75bf0].
1 | /* | | | | | | > > > > | < > | < < | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFSeekableStream.h" #import "OFKernelEventObserver.h" #ifndef OF_AMIGAOS # define OF_FILE_HANDLE_IS_FD typedef int OFFileHandle; static const OFFileHandle OFInvalidFileHandle = -1; #else typedef struct _OFFileHandle *OFFileHandle; static const OFFileHandle OFInvalidFileHandle = NULL; #endif OF_ASSUME_NONNULL_BEGIN /** * @class OFFile OFFile.h ObjFW/OFFile.h * * @brief A class which provides methods to read and write files. */ OF_SUBCLASSING_RESTRICTED @interface OFFile: OFSeekableStream #ifdef OF_FILE_HANDLE_IS_FD <OFReadyForReadingObserving, OFReadyForWritingObserving> #endif { OFFileHandle _handle; bool _initialized, _atEndOfStream; } /** * @brief Creates a new OFFile with the specified path and mode. * * @param path The path to the file to open as a string * @param mode The mode in which the file should be opened. |
︙ | ︙ |
Modified src/OFFile.m from [57c941bba1] to [721f53448e].
1 | /* | | | | | | > > > > | < > | > | > < < > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #ifndef _LARGEFILE64_SOURCE # define _LARGEFILE64_SOURCE 1 #endif #include <errno.h> #ifdef HAVE_FCNTL_H # include <fcntl.h> #endif #include "unistd_wrapper.h" #ifdef HAVE_SYS_STAT_H # include <sys/stat.h> #endif #import "OFFile.h" #import "OFLocale.h" #import "OFString.h" #import "OFSystemInfo.h" #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFNotOpenException.h" #import "OFOpenItemFailedException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFSeekFailedException.h" #import "OFWriteFailedException.h" #ifdef OF_WINDOWS # include <windows.h> #endif #ifdef OF_AMIGAOS # define Class IntuitionClass # include <proto/exec.h> # include <proto/dos.h> # undef Class #endif #ifdef OF_WII # include <fat.h> #endif #ifdef OF_NINTENDO_DS |
︙ | ︙ | |||
335 336 337 338 339 340 341 342 343 344 345 346 347 348 | } - (instancetype)initWithHandle: (OFFileHandle)handle { self = [super init]; _handle = handle; return self; } - (instancetype)init { OF_INVALID_INIT_METHOD | > | 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 | } - (instancetype)initWithHandle: (OFFileHandle)handle { self = [super init]; _handle = handle; _initialized = true; return self; } - (instancetype)init { OF_INVALID_INIT_METHOD |
︙ | ︙ | |||
550 551 552 553 554 555 556 | _handle = OFInvalidFileHandle; [super close]; } - (void)dealloc { | | | 557 558 559 560 561 562 563 564 565 566 567 568 569 | _handle = OFInvalidFileHandle; [super close]; } - (void)dealloc { if (_initialized && _handle != OFInvalidFileHandle) [self close]; [super dealloc]; } @end |
Renamed and modified src/OFFileURIHandler.h [24ec18a27d] to src/OFFileIRIHandler.h [e6e366059a].
1 | /* | | | | | | > > > > | < > | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFIRIHandler.h" OF_ASSUME_NONNULL_BEGIN @interface OFFileIRIHandler: OFIRIHandler + (bool)of_directoryExistsAtPath: (OFString *)path OF_DIRECT; @end OF_ASSUME_NONNULL_END |
Renamed and modified src/OFFileURIHandler.m [d74cbf6f89] to src/OFFileIRIHandler.m [ae11241b71].
1 | /* | | | | | | > > > > | < > | > | > > > > > > > | > > > | > > > | > > < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #ifndef _LARGEFILE64_SOURCE # define _LARGEFILE64_SOURCE 1 #endif #include <errno.h> #include <math.h> #ifdef HAVE_DIRENT_H # include <dirent.h> #endif #include "unistd_wrapper.h" #include "platform.h" #ifdef HAVE_SYS_STAT_H # include <sys/stat.h> #endif #include <sys/time.h> #if defined(OF_LINUX) || defined(OF_MACOS) # include <sys/xattr.h> #endif #if defined(OF_FREEBSD) || defined(OF_NETBSD) # include <sys/extattr.h> #endif #ifdef OF_HAIKU # include <kernel/fs_attr.h> #endif #ifdef OF_DJGPP # include <syslimits.h> #endif #ifdef HAVE_FCNTL_H # include <fcntl.h> #endif #ifdef HAVE_PWD_H # include <pwd.h> #endif #ifdef HAVE_GRP_H # include <grp.h> #endif #import "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" |
︙ | ︙ | |||
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | # include <windows.h> # include <direct.h> # include <ntdef.h> # include <wchar.h> #endif #ifdef OF_AMIGAOS # include <proto/exec.h> # include <proto/dos.h> # include <proto/locale.h> # ifdef OF_AMIGAOS4 # define DeleteFile(path) Delete(path) # endif #endif #if defined(OF_WINDOWS) || defined(OF_AMIGAOS) typedef struct { | > > | 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | # include <windows.h> # include <direct.h> # include <ntdef.h> # include <wchar.h> #endif #ifdef OF_AMIGAOS # define Class IntuitionClass # include <proto/exec.h> # include <proto/dos.h> # include <proto/locale.h> # undef Class # ifdef OF_AMIGAOS4 # define DeleteFile(path) Delete(path) # endif #endif #if defined(OF_WINDOWS) || defined(OF_AMIGAOS) typedef struct { |
︙ | ︙ | |||
112 113 114 115 116 117 118 | static void releasePasswdMutex(void) { [passwdMutex release]; } #endif | | < > > > > > > > > > > > > > > > > > > > > | 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | static void releasePasswdMutex(void) { [passwdMutex release]; } #endif #if defined(OF_HAVE_THREADS) && !defined(__GLIBC__) && !defined(OF_WINDOWS) static OFMutex *readdirMutex; static void releaseReaddirMutex(void) { [readdirMutex release]; } #endif #ifdef OF_WINDOWS static WINAPI BOOLEAN (*createSymbolicLinkWFuncPtr)(LPCWSTR, LPCWSTR, DWORD); static WINAPI BOOLEAN (*createHardLinkWFuncPtr)(LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES); #endif #ifdef OF_FREEBSD static const char *namespaces[] = EXTATTR_NAMESPACE_NAMES; static int numNamespaces = sizeof(namespaces) / sizeof(*namespaces); #endif #ifdef OF_WINDOWS static OFTimeInterval filetimeToTimeInterval(const FILETIME *filetime) { return (double)((int64_t)filetime->dwHighDateTime << 32 | filetime->dwLowDateTime) / 10000000.0 - 11644473600.0; } static FILETIME timeIntervalToFiletime(OFTimeInterval timeInterval) { uint64_t timestamp = (uint64_t)((timeInterval + 11644473600.0) * 10000000.0); FILETIME filetime = { .dwHighDateTime = timestamp >> 32, .dwLowDateTime = timestamp & 0xFFFFFFFF }; return filetime; } static int lastError(void) { switch (GetLastError()) { case ERROR_FILE_NOT_FOUND: case ERROR_PATH_NOT_FOUND: case ERROR_NO_MORE_FILES: return ENOENT; case ERROR_ACCESS_DENIED: return EACCES; case ERROR_PRIVILEGE_NOT_HELD: return EPERM; case ERROR_DIRECTORY: return ENOTDIR; case ERROR_NOT_READY: return EBUSY; default: return EIO; } |
︙ | ︙ | |||
353 354 355 356 357 358 359 360 361 362 363 364 365 366 | # endif return 0; #else return statWrapper(path, buffer); #endif } static void setTypeAttribute(OFMutableFileAttributes attributes, Stat *s) { if (S_ISREG(s->st_mode)) [attributes setObject: OFFileTypeRegular forKey: OFFileType]; else if (S_ISDIR(s->st_mode)) | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 | # endif return 0; #else return statWrapper(path, buffer); #endif } #if defined(OF_FREEBSD) || defined(OF_NETBSD) static void parseAttributeName(OFString **name, int *namespace) { size_t pos = [*name rangeOfString: @"."].location; OFString *namespaceName; const char *cNamespace; if (pos == OFNotFound) @throw [OFInvalidArgumentException exception]; namespaceName = [*name substringToIndex: pos]; cNamespace = [namespaceName cStringWithEncoding: [OFLocale encoding]]; *name = [*name substringFromIndex: pos + 1]; # if defined(OF_FREEBSD) for (int i = 0; i < numNamespaces; i++) { if (strcmp(namespaces[i], cNamespace) == 0) { *namespace = i; return; } } @throw [OFInvalidArgumentException exception]; # elif defined(OF_NETBSD) if (extattr_string_to_namespace(cNamespace, namespace) == -1) @throw [OFInvalidArgumentException exception]; # endif } #endif static void setTypeAttribute(OFMutableFileAttributes attributes, Stat *s) { if (S_ISREG(s->st_mode)) [attributes setObject: OFFileTypeRegular forKey: OFFileType]; else if (S_ISDIR(s->st_mode)) |
︙ | ︙ | |||
453 454 455 456 457 458 459 | # endif #endif } #ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS static void setSymbolicLinkDestinationAttribute(OFMutableFileAttributes attributes, | | | | < < < < < < < < < < < < < < < < < < < < | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | < < < < | | 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 | # endif #endif } #ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS static void setSymbolicLinkDestinationAttribute(OFMutableFileAttributes attributes, OFIRI *IRI) { OFString *path = IRI.fileSystemRepresentation; # ifdef OF_WINDOWS HANDLE handle; OFString *destination; if (createSymbolicLinkWFuncPtr == NULL) return; if ((handle = CreateFileW(path.UTF16String, 0, (FILE_SHARE_READ | FILE_SHARE_WRITE), NULL, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT, NULL)) == INVALID_HANDLE_VALUE) @throw [OFGetItemAttributesFailedException exceptionWithIRI: IRI errNo: lastError()]; @try { union { char bytes[MAXIMUM_REPARSE_DATA_BUFFER_SIZE]; REPARSE_DATA_BUFFER data; } buffer; DWORD size; wchar_t *tmp; if (!DeviceIoControl(handle, FSCTL_GET_REPARSE_POINT, NULL, 0, buffer.bytes, MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &size, NULL)) @throw [OFGetItemAttributesFailedException exceptionWithIRI: IRI errNo: lastError()]; if (buffer.data.ReparseTag != IO_REPARSE_TAG_SYMLINK) @throw [OFGetItemAttributesFailedException exceptionWithIRI: IRI errNo: lastError()]; # define slrb buffer.data.SymbolicLinkReparseBuffer tmp = slrb.PathBuffer + (slrb.SubstituteNameOffset / sizeof(wchar_t)); destination = [OFString stringWithUTF16String: tmp length: slrb.SubstituteNameLength / sizeof(wchar_t)]; [attributes setObject: OFFileTypeSymbolicLink forKey: OFFileType]; [attributes setObject: destination forKey: OFFileSymbolicLinkDestination]; # undef slrb } @finally { CloseHandle(handle); } # elif defined(OF_HURD) OFStringEncoding encoding = [OFLocale encoding]; int fd; OFMutableData *destinationData; OFString *destination; fd = open([path cStringWithEncoding: encoding], O_RDONLY | O_NOLINK); if (fd == -1) @throw [OFGetItemAttributesFailedException exceptionWithIRI: IRI errNo: errno]; @try { char buffer[512]; ssize_t length; destinationData = [OFMutableData data]; while ((length = read(fd, buffer, 512)) > 0) [destinationData addItems: buffer count: length]; } @finally { close(fd); } destination = [OFString stringWithCString: destinationData.items encoding: encoding length: destinationData.count]; [attributes setObject: destination forKey: OFFileSymbolicLinkDestination]; # else OFStringEncoding encoding = [OFLocale encoding]; char destinationC[PATH_MAX]; ssize_t length; OFString *destination; length = readlink([path cStringWithEncoding: encoding], destinationC, PATH_MAX); if (length < 0) @throw [OFGetItemAttributesFailedException exceptionWithIRI: IRI errNo: errno]; destination = [OFString stringWithCString: destinationC encoding: encoding length: length]; [attributes setObject: destination forKey: OFFileSymbolicLinkDestination]; # endif } #endif #ifdef OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES static void setExtendedAttributes(OFMutableFileAttributes attributes, OFIRI *IRI) { OFString *path = IRI.fileSystemRepresentation; OFStringEncoding encoding = [OFLocale encoding]; const char *cPath = [path cStringWithEncoding: encoding]; OFMutableArray *names = nil; # if defined(OF_LINUX) || defined(OF_MACOS) # if defined(OF_LINUX) ssize_t size = llistxattr(cPath, NULL, 0); # elif defined(OF_MACOS) ssize_t size = listxattr(cPath, NULL, 0, XATTR_NOFOLLOW); # endif char *list; if (size < 0) return; list = OFAllocMemory(1, size); @try { char *name; # if defined(OF_LINUX) if ((size = llistxattr(cPath, list, size)) < 0) # elif defined(OF_MACOS) if ((size = listxattr(cPath, list, size, XATTR_NOFOLLOW)) < 0) # endif return; names = [OFMutableArray array]; name = list; while (size > 0) { size_t length = strlen(name); [names addObject: [OFString stringWithCString: name encoding: encoding length: length]]; name += length + 1; size -= length + 1; } } @finally { OFFreeMemory(list); } # elif defined(OF_FREEBSD) || defined(OF_NETBSD) names = [OFMutableArray array]; # if defined(OF_FREEBSD) for (int i = 0; i < numNamespaces; i++) { int namespace = i; const char *cNamespace = namespaces[i]; # elif defined(OF_NETBSD) for (size_t i = 0; extattr_namespaces[i] != 0; i++) { int namespace = extattr_namespaces[i]; char *cNamespace; # endif ssize_t size; char *list; if ((size = extattr_list_link(cPath, namespace, NULL, 0)) < 0) continue; list = OFAllocMemory(1, size); @try { OFString *namespaceName; char *iter; if ((size = extattr_list_link(cPath, namespace, list, size)) < 0) continue; # ifdef OF_NETBSD if (extattr_namespace_to_string(namespace, &cNamespace) == -1) continue; # endif namespaceName = [OFString stringWithCString: cNamespace encoding: encoding]; iter = list; while (size > 0) { ssize_t length = *(unsigned char *)iter; OFString *name; iter++; size--; if (length > size) @throw [OFOutOfRangeException exception]; name = [OFString stringWithCString: iter encoding: encoding length: length]; name = [OFString stringWithFormat: @"%@.%@", namespaceName, name]; [names addObject: name]; iter += length; size -= length; } } @finally { OFFreeMemory(list); } } # elif defined(OF_HAIKU) DIR *dir = fs_open_attr_dir(cPath); if (dir == NULL) return; @try { struct dirent *dirent; names = [OFMutableArray array]; while ((dirent = fs_read_attr_dir(dir)) != NULL) [names addObject: [OFString stringWithCString: dirent->d_name encoding: encoding]]; } @finally { fs_close_attr_dir(dir); } # endif [names makeImmutable]; [attributes setObject: names forKey: OFFileExtendedAttributesNames]; } #endif @implementation OFFileIRIHandler + (void)initialize { #ifdef OF_WINDOWS HMODULE module; #endif if (self != [OFFileIRIHandler class]) return; #if defined(OF_FILE_MANAGER_SUPPORTS_OWNER) && defined(OF_HAVE_THREADS) passwdMutex = [[OFMutex alloc] init]; atexit(releasePasswdMutex); #endif #if defined(OF_HAVE_THREADS) && !defined(__GLIBC__) && !defined(OF_WINDOWS) readdirMutex = [[OFMutex alloc] init]; atexit(releaseReaddirMutex); #endif #ifdef OF_WINDOWS if ((module = GetModuleHandleA("kernel32.dll")) != NULL) { createSymbolicLinkWFuncPtr = (WINAPI BOOLEAN (*)(LPCWSTR, LPCWSTR, DWORD)) GetProcAddress(module, "CreateSymbolicLinkW"); createHardLinkWFuncPtr = (WINAPI BOOLEAN (*)(LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES)) GetProcAddress(module, "CreateHardLinkW"); |
︙ | ︙ | |||
583 584 585 586 587 588 589 | if (statWrapper(path, &s) != 0) return false; return S_ISDIR(s.st_mode); } | | | > > | | > > > > > > > > | | | | | | > > > > | | < < | | | | > | > > > > > > > > > | | | | | | | < < < | < | < < | < < < < | | | | | > > | 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 | if (statWrapper(path, &s) != 0) return false; return S_ISDIR(s.st_mode); } - (OFStream *)openItemAtIRI: (OFIRI *)IRI mode: (OFString *)mode { void *pool = objc_autoreleasePoolPush(); OFFile *file; @try { file = [OFFile fileWithPath: IRI.fileSystemRepresentation mode: mode]; } @catch (OFOpenItemFailedException *e) { /* The thrown one has a path instead of an IRI set. */ @throw [OFOpenItemFailedException exceptionWithIRI: IRI mode: mode errNo: e.errNo]; } [file retain]; objc_autoreleasePoolPop(pool); return [file autorelease]; } - (OFFileAttributes)attributesOfItemAtIRI: (OFIRI *)IRI { OFMutableFileAttributes ret = [OFMutableDictionary dictionary]; void *pool = objc_autoreleasePoolPush(); OFString *path; int error; Stat s; if (IRI == nil) @throw [OFInvalidArgumentException exception]; if (![[IRI scheme] isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; path = IRI.fileSystemRepresentation; if ((error = lstatWrapper(path, &s)) != 0) @throw [OFGetItemAttributesFailedException exceptionWithIRI: IRI errNo: error]; if (s.st_size < 0) @throw [OFOutOfRangeException exception]; [ret setObject: [NSNumber numberWithUnsignedLongLong: s.st_size] forKey: OFFileSize]; setTypeAttribute(ret, &s); [ret setObject: [NSNumber numberWithUnsignedLong: s.st_mode] forKey: OFFilePOSIXPermissions]; setOwnerAndGroupAttributes(ret, &s); setDateAttributes(ret, &s); #ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS if (S_ISLNK(s.st_mode)) setSymbolicLinkDestinationAttribute(ret, IRI); #endif #ifdef OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES setExtendedAttributes(ret, IRI); #endif objc_autoreleasePoolPop(pool); return ret; } - (void)of_setLastAccessDate: (OFDate *)lastAccessDate andModificationDate: (OFDate *)modificationDate ofItemAtIRI: (OFIRI *)IRI attributes: (OFFileAttributes)attributes OF_DIRECT { OFString *path = IRI.fileSystemRepresentation; OFFileAttributeKey attributeKey = (modificationDate != nil ? OFFileModificationDate : OFFileLastAccessDate); if (lastAccessDate == nil) lastAccessDate = modificationDate; if (modificationDate == nil) modificationDate = lastAccessDate; #if defined(OF_WINDOWS) FILETIME accessTime = timeIntervalToFiletime( lastAccessDate.timeIntervalSince1970); FILETIME modificationTime = timeIntervalToFiletime( modificationDate.timeIntervalSince1970); HANDLE handle; if ([OFSystemInfo isWindowsNT]) handle = CreateFileW(path.UTF16String, FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); else handle = CreateFileA( [path cStringWithEncoding: [OFLocale encoding]], FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (handle == NULL) @throw [OFSetItemAttributesFailedException exceptionWithIRI: IRI attributes: attributes failedAttribute: attributeKey errNo: lastError()]; if (!SetFileTime(handle, NULL, &accessTime, &modificationTime)) { int errNo = lastError(); CloseHandle(handle); @throw [OFSetItemAttributesFailedException exceptionWithIRI: IRI attributes: attributes failedAttribute: attributeKey errNo: errNo]; } CloseHandle(handle); #elif defined(OF_AMIGAOS) /* AmigaOS does not support access time. */ OFTimeInterval modificationTime = modificationDate.timeIntervalSince1970; struct Locale *locale; struct DateStamp date; |
︙ | ︙ | |||
724 725 726 727 728 729 730 | if (!SetDate([path cStringWithEncoding: [OFLocale encoding]], &date) != 0) # else if (!SetFileDate([path cStringWithEncoding: [OFLocale encoding]], &date) != 0) # endif @throw [OFSetItemAttributesFailedException | | | | | | | | | | | | | | | | | | | | | | | | | | < < < < < | | | | | | | | | | | | | | | | | | | | 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 | if (!SetDate([path cStringWithEncoding: [OFLocale encoding]], &date) != 0) # else if (!SetFileDate([path cStringWithEncoding: [OFLocale encoding]], &date) != 0) # endif @throw [OFSetItemAttributesFailedException exceptionWithIRI: IRI attributes: attributes failedAttribute: attributeKey errNo: lastError()]; #else OFTimeInterval lastAccessTime = lastAccessDate.timeIntervalSince1970; OFTimeInterval modificationTime = modificationDate.timeIntervalSince1970; struct timeval times[2] = { { .tv_sec = (time_t)lastAccessTime, .tv_usec = (int)((lastAccessTime - (time_t)lastAccessTime) * 1000000) }, { .tv_sec = (time_t)modificationTime, .tv_usec = (int)((modificationTime - (time_t)modificationTime) * 1000000) }, }; if (utimes([path cStringWithEncoding: [OFLocale encoding]], times) != 0) @throw [OFSetItemAttributesFailedException exceptionWithIRI: IRI attributes: attributes failedAttribute: attributeKey errNo: errno]; #endif } - (void)of_setPOSIXPermissions: (OFNumber *)permissions ofItemAtIRI: (OFIRI *)IRI attributes: (OFFileAttributes)attributes OF_DIRECT { #ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS mode_t mode = (mode_t)permissions.unsignedLongValue; OFString *path = IRI.fileSystemRepresentation; int status; # ifdef OF_WINDOWS if ([OFSystemInfo isWindowsNT]) status = _wchmod(path.UTF16String, mode); else # endif status = chmod( [path cStringWithEncoding: [OFLocale encoding]], mode); if (status != 0) @throw [OFSetItemAttributesFailedException exceptionWithIRI: IRI attributes: attributes failedAttribute: OFFilePOSIXPermissions errNo: errno]; #else OF_UNRECOGNIZED_SELECTOR #endif } - (void)of_setOwnerAccountName: (OFString *)owner andGroupOwnerAccountName: (OFString *)group ofItemAtIRI: (OFIRI *)IRI attributeKey: (OFFileAttributeKey)attributeKey attributes: (OFFileAttributes)attributes OF_DIRECT { #ifdef OF_FILE_MANAGER_SUPPORTS_OWNER OFString *path = IRI.fileSystemRepresentation; uid_t uid = -1; gid_t gid = -1; OFStringEncoding encoding; if (owner == nil && group == nil) @throw [OFInvalidArgumentException exception]; encoding = [OFLocale encoding]; # ifdef OF_HAVE_THREADS [passwdMutex lock]; @try { # endif if (owner != nil) { struct passwd *passwd; if ((passwd = getpwnam([owner cStringWithEncoding: encoding])) == NULL) @throw [OFSetItemAttributesFailedException exceptionWithIRI: IRI attributes: attributes failedAttribute: attributeKey errNo: errno]; uid = passwd->pw_uid; } if (group != nil) { struct group *group_; if ((group_ = getgrnam([group cStringWithEncoding: encoding])) == NULL) @throw [OFSetItemAttributesFailedException exceptionWithIRI: IRI attributes: attributes failedAttribute: attributeKey errNo: errno]; gid = group_->gr_gid; } # ifdef OF_HAVE_THREADS } @finally { [passwdMutex unlock]; } # endif if (chown([path cStringWithEncoding: encoding], uid, gid) != 0) @throw [OFSetItemAttributesFailedException exceptionWithIRI: IRI attributes: attributes failedAttribute: attributeKey errNo: errno]; #else OF_UNRECOGNIZED_SELECTOR #endif } - (void)setAttributes: (OFFileAttributes)attributes ofItemAtIRI: (OFIRI *)IRI { void *pool = objc_autoreleasePoolPush(); OFEnumerator OF_GENERIC(OFFileAttributeKey) *keyEnumerator; OFEnumerator *objectEnumerator; OFFileAttributeKey key; id object; OFDate *lastAccessDate, *modificationDate; if (IRI == nil) @throw [OFInvalidArgumentException exception]; if (![IRI.scheme isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; keyEnumerator = [attributes keyEnumerator]; objectEnumerator = [attributes objectEnumerator]; while ((key = [keyEnumerator nextObject]) != nil && (object = [objectEnumerator nextObject]) != nil) { if ([key isEqual: OFFileModificationDate] || [key isEqual: OFFileLastAccessDate]) continue; else if ([key isEqual: OFFilePOSIXPermissions]) [self of_setPOSIXPermissions: object ofItemAtIRI: IRI attributes: attributes]; else if ([key isEqual: OFFileOwnerAccountName]) [self of_setOwnerAccountName: object andGroupOwnerAccountName: nil ofItemAtIRI: IRI attributeKey: key attributes: attributes]; else if ([key isEqual: OFFileGroupOwnerAccountName]) [self of_setOwnerAccountName: nil andGroupOwnerAccountName: object ofItemAtIRI: IRI attributeKey: key attributes: attributes]; else @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; } lastAccessDate = [attributes objectForKey: OFFileLastAccessDate]; modificationDate = [attributes objectForKey: OFFileModificationDate]; if (lastAccessDate != nil || modificationDate != nil) [self of_setLastAccessDate: lastAccessDate andModificationDate: modificationDate ofItemAtIRI: IRI attributes: attributes]; objc_autoreleasePoolPop(pool); } - (bool)fileExistsAtIRI: (OFIRI *)IRI { void *pool = objc_autoreleasePoolPush(); Stat s; bool ret; if (IRI == nil) @throw [OFInvalidArgumentException exception]; if (![IRI.scheme isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; ret = (statWrapper(IRI.fileSystemRepresentation, &s) == 0); objc_autoreleasePoolPop(pool); return ret; } - (bool)directoryExistsAtIRI: (OFIRI *)IRI { void *pool = objc_autoreleasePoolPush(); Stat s; bool ret; if (IRI == nil) @throw [OFInvalidArgumentException exception]; if (![IRI.scheme isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; if (statWrapper(IRI.fileSystemRepresentation, &s) != 0) { objc_autoreleasePoolPop(pool); return false; } ret = S_ISDIR(s.st_mode); objc_autoreleasePoolPop(pool); return ret; } - (void)createDirectoryAtIRI: (OFIRI *)IRI { void *pool = objc_autoreleasePoolPush(); OFString *path; if (IRI == nil) @throw [OFInvalidArgumentException exception]; if (![IRI.scheme isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; path = IRI.fileSystemRepresentation; #if defined(OF_WINDOWS) int status; if ([OFSystemInfo isWindowsNT]) status = _wmkdir(path.UTF16String); else status = _mkdir( [path cStringWithEncoding: [OFLocale encoding]]); if (status != 0) @throw [OFCreateDirectoryFailedException exceptionWithIRI: IRI errNo: errno]; #elif defined(OF_AMIGAOS) BPTR lock; if ((lock = CreateDir( [path cStringWithEncoding: [OFLocale encoding]])) == 0) @throw [OFCreateDirectoryFailedException exceptionWithIRI: IRI errNo: lastError()]; UnLock(lock); #else if (mkdir([path cStringWithEncoding: [OFLocale encoding]], 0777) != 0) @throw [OFCreateDirectoryFailedException exceptionWithIRI: IRI errNo: errno]; #endif objc_autoreleasePoolPop(pool); } - (OFArray OF_GENERIC(OFIRI *) *)contentsOfDirectoryAtIRI: (OFIRI *)IRI { OFMutableArray *IRIs = [OFMutableArray array]; void *pool = objc_autoreleasePoolPush(); OFString *path; if (IRI == nil) @throw [OFInvalidArgumentException exception]; if (![IRI.scheme isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; path = IRI.fileSystemRepresentation; #if defined(OF_WINDOWS) HANDLE handle; path = [path stringByAppendingString: @"\\*"]; if ([OFSystemInfo isWindowsNT]) { WIN32_FIND_DATAW fd; if ((handle = FindFirstFileW(path.UTF16String, &fd)) == INVALID_HANDLE_VALUE) @throw [OFOpenItemFailedException exceptionWithIRI: IRI mode: nil errNo: lastError()]; @try { do { OFString *file; if (wcscmp(fd.cFileName, L".") == 0 || wcscmp(fd.cFileName, L"..") == 0) continue; file = [[OFString alloc] initWithUTF16String: fd.cFileName]; @try { [IRIs addObject: [IRI IRIByAppendingPathComponent: file]]; } @finally { [file release]; } } while (FindNextFileW(handle, &fd)); if (GetLastError() != ERROR_NO_MORE_FILES) @throw [OFReadFailedException |
︙ | ︙ | |||
1061 1062 1063 1064 1065 1066 1067 | OFStringEncoding encoding = [OFLocale encoding]; WIN32_FIND_DATA fd; if ((handle = FindFirstFileA( [path cStringWithEncoding: encoding], &fd)) == INVALID_HANDLE_VALUE) @throw [OFOpenItemFailedException | | | | | 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 | OFStringEncoding encoding = [OFLocale encoding]; WIN32_FIND_DATA fd; if ((handle = FindFirstFileA( [path cStringWithEncoding: encoding], &fd)) == INVALID_HANDLE_VALUE) @throw [OFOpenItemFailedException exceptionWithIRI: IRI mode: nil errNo: lastError()]; @try { do { OFString *file; if (strcmp(fd.cFileName, ".") == 0 || strcmp(fd.cFileName, "..") == 0) continue; file = [[OFString alloc] initWithCString: fd.cFileName encoding: encoding]; @try { [IRIs addObject: [IRI IRIByAppendingPathComponent: file]]; } @finally { [file release]; } } while (FindNextFileA(handle, &fd)); if (GetLastError() != ERROR_NO_MORE_FILES) @throw [OFReadFailedException |
︙ | ︙ | |||
1100 1101 1102 1103 1104 1105 1106 | #elif defined(OF_AMIGAOS) OFStringEncoding encoding = [OFLocale encoding]; BPTR lock; if ((lock = Lock([path cStringWithEncoding: encoding], SHARED_LOCK)) == 0) @throw [OFOpenItemFailedException | | | | | | | | | | < < < < < < < < < < < < < < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 | #elif defined(OF_AMIGAOS) OFStringEncoding encoding = [OFLocale encoding]; BPTR lock; if ((lock = Lock([path cStringWithEncoding: encoding], SHARED_LOCK)) == 0) @throw [OFOpenItemFailedException exceptionWithIRI: IRI mode: nil errNo: lastError()]; @try { # ifdef OF_AMIGAOS4 struct ExamineData *ed; APTR context; if ((context = ObtainDirContextTags(EX_FileLockInput, lock, EX_DoCurrentDir, TRUE, EX_DataFields, EXF_NAME, TAG_END)) == NULL) @throw [OFOpenItemFailedException exceptionWithIRI: IRI mode: nil errNo: lastError()]; @try { while ((ed = ExamineDir(context)) != NULL) { OFString *file = [[OFString alloc] initWithCString: ed->Name encoding: encoding]; @try { [IRIs addObject: [IRI IRIByAppendingPathComponent: file]]; } @finally { [file release]; } } } @finally { ReleaseDirContext(context); } # else struct FileInfoBlock fib; if (!Examine(lock, &fib)) @throw [OFOpenItemFailedException exceptionWithIRI: IRI mode: nil errNo: lastError()]; while (ExNext(lock, &fib)) { OFString *file = [[OFString alloc] initWithCString: fib.fib_FileName encoding: encoding]; @try { [IRIs addObject: [IRI IRIByAppendingPathComponent: file]]; } @finally { [file release]; } } # endif if (IoErr() != ERROR_NO_MORE_ENTRIES) @throw [OFReadFailedException exceptionWithObject: self requestedLength: 0 errNo: lastError()]; } @finally { UnLock(lock); } #else OFStringEncoding encoding = [OFLocale encoding]; DIR *dir; if ((dir = opendir([path cStringWithEncoding: encoding])) == NULL) @throw [OFOpenItemFailedException exceptionWithIRI: IRI mode: nil errNo: errno]; # if defined(OF_HAVE_THREADS) && !defined(__GLIBC__) @try { [readdirMutex lock]; } @catch (id e) { closedir(dir); @throw e; } # endif @try { for (;;) { struct dirent *dirent; OFString *file; errno = 0; if ((dirent = readdir(dir)) == NULL) { if (errno == 0) break; else @throw [OFReadFailedException exceptionWithObject: self requestedLength: 0 errNo: errno]; } if (strcmp(dirent->d_name, ".") == 0 || strcmp(dirent->d_name, "..") == 0) continue; file = [[OFString alloc] initWithCString: dirent->d_name encoding: encoding]; @try { [IRIs addObject: [IRI IRIByAppendingPathComponent: file]]; } @finally { [file release]; } } } @finally { closedir(dir); # if defined(OF_HAVE_THREADS) && !defined(__GLIBC__) [readdirMutex unlock]; # endif } #endif [IRIs makeImmutable]; objc_autoreleasePoolPop(pool); return IRIs; } - (void)removeItemAtIRI: (OFIRI *)IRI { void *pool = objc_autoreleasePoolPush(); OFString *path; int error; Stat s; if (IRI == nil) @throw [OFInvalidArgumentException exception]; if (![IRI.scheme isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; path = IRI.fileSystemRepresentation; if ((error = lstatWrapper(path, &s)) != 0) @throw [OFRemoveItemFailedException exceptionWithIRI: IRI errNo: error]; if (S_ISDIR(s.st_mode)) { OFArray OF_GENERIC(OFIRI *) *contents; @try { contents = [self contentsOfDirectoryAtIRI: IRI]; } @catch (id e) { /* * Only convert exceptions to * OFRemoveItemFailedException that have an errNo * property. This covers all I/O related exceptions * from the operations used to remove an item, all * others should be left as is. */ if ([e respondsToSelector: @selector(errNo)]) @throw [OFRemoveItemFailedException exceptionWithIRI: IRI errNo: [e errNo]]; @throw e; } for (OFIRI *item in contents) { void *pool2 = objc_autoreleasePoolPush(); [self removeItemAtIRI: item]; objc_autoreleasePoolPop(pool2); } #ifndef OF_AMIGAOS int status; # ifdef OF_WINDOWS if ([OFSystemInfo isWindowsNT]) status = _wrmdir(path.UTF16String); else # endif status = rmdir( [path cStringWithEncoding: [OFLocale encoding]]); if (status != 0) @throw [OFRemoveItemFailedException exceptionWithIRI: IRI errNo: errno]; } else { int status; # ifdef OF_WINDOWS if ([OFSystemInfo isWindowsNT]) status = _wunlink(path.UTF16String); else # endif status = unlink( [path cStringWithEncoding: [OFLocale encoding]]); if (status != 0) @throw [OFRemoveItemFailedException exceptionWithIRI: IRI errNo: errno]; #endif } #ifdef OF_AMIGAOS if (!DeleteFile([path cStringWithEncoding: [OFLocale encoding]])) @throw [OFRemoveItemFailedException exceptionWithIRI: IRI errNo: lastError()]; #endif objc_autoreleasePoolPop(pool); } #ifdef OF_FILE_MANAGER_SUPPORTS_LINKS - (void)linkItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination { void *pool = objc_autoreleasePoolPush(); OFString *sourcePath, *destinationPath; if (source == nil || destination == nil) @throw [OFInvalidArgumentException exception]; if (![source.scheme isEqual: _scheme] || ![destination.scheme isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; sourcePath = source.fileSystemRepresentation; destinationPath = destination.fileSystemRepresentation; # ifndef OF_WINDOWS OFStringEncoding encoding = [OFLocale encoding]; if (link([sourcePath cStringWithEncoding: encoding], [destinationPath cStringWithEncoding: encoding]) != 0) @throw [OFLinkItemFailedException exceptionWithSourceIRI: source destinationIRI: destination errNo: errno]; # else if (createHardLinkWFuncPtr == NULL) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; if (!createHardLinkWFuncPtr(destinationPath.UTF16String, sourcePath.UTF16String, NULL)) @throw [OFLinkItemFailedException exceptionWithSourceIRI: source destinationIRI: destination errNo: lastError()]; # endif objc_autoreleasePoolPop(pool); } #endif #ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS - (void)createSymbolicLinkAtIRI: (OFIRI *)IRI withDestinationPath: (OFString *)target { void *pool = objc_autoreleasePoolPush(); OFString *path; if (IRI == nil || target == nil) @throw [OFInvalidArgumentException exception]; if (![IRI.scheme isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; path = IRI.fileSystemRepresentation; # ifndef OF_WINDOWS OFStringEncoding encoding = [OFLocale encoding]; if (symlink([target cStringWithEncoding: encoding], [path cStringWithEncoding: encoding]) != 0) @throw [OFCreateSymbolicLinkFailedException exceptionWithIRI: IRI target: target errNo: errno]; # else if (createSymbolicLinkWFuncPtr == NULL) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; if (!createSymbolicLinkWFuncPtr(path.UTF16String, target.UTF16String, 0)) @throw [OFCreateSymbolicLinkFailedException exceptionWithIRI: IRI target: target errNo: lastError()]; # endif objc_autoreleasePoolPop(pool); } #endif - (bool)moveItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination { void *pool; if (![source.scheme isEqual: _scheme] || ![destination.scheme isEqual: _scheme]) return false; if ([self fileExistsAtIRI: destination]) @throw [OFMoveItemFailedException exceptionWithSourceIRI: source destinationIRI: destination errNo: EEXIST]; pool = objc_autoreleasePoolPush(); #ifdef OF_AMIGAOS OFStringEncoding encoding = [OFLocale encoding]; if (!Rename([source.fileSystemRepresentation cStringWithEncoding: encoding], [destination.fileSystemRepresentation cStringWithEncoding: encoding])) @throw [OFMoveItemFailedException exceptionWithSourceIRI: source destinationIRI: destination errNo: lastError()]; #else int status; # ifdef OF_WINDOWS if ([OFSystemInfo isWindowsNT]) status = _wrename(source.fileSystemRepresentation.UTF16String, |
︙ | ︙ | |||
1460 1461 1462 1463 1464 1465 1466 | cStringWithEncoding: encoding]); # ifdef OF_WINDOWS } # endif if (status != 0) @throw [OFMoveItemFailedException | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 | cStringWithEncoding: encoding]); # ifdef OF_WINDOWS } # endif if (status != 0) @throw [OFMoveItemFailedException exceptionWithSourceIRI: source destinationIRI: destination errNo: errno]; #endif objc_autoreleasePoolPop(pool); return true; } #ifdef OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES - (void)getExtendedAttributeData: (OFData **)data andType: (id *)type forName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI { void *pool = objc_autoreleasePoolPush(); OFString *path = IRI.fileSystemRepresentation; OFStringEncoding encoding = [OFLocale encoding]; const char *cPath = [path cStringWithEncoding: encoding]; void *value = NULL; # if defined(OF_LINUX) || defined(OF_MACOS) const char *cName = [name cStringWithEncoding: encoding]; # if defined(OF_LINUX) ssize_t size = lgetxattr(cPath, cName, NULL, 0); # elif defined(OF_MACOS) ssize_t size = getxattr(cPath, cName, NULL, 0, 0, XATTR_NOFOLLOW); # endif if (size < 0) @throw [OFGetItemAttributesFailedException exceptionWithIRI: IRI errNo: errno]; value = OFAllocMemory(1, size); @try { # if defined(OF_LINUX) if ((size = lgetxattr(cPath, cName, value, size)) < 0) # elif defined(OF_MACOS) if ((size = getxattr(cPath, cName, value, size, 0, XATTR_NOFOLLOW)) < 0) # endif @throw [OFGetItemAttributesFailedException exceptionWithIRI: IRI errNo: errno]; *data = [OFData dataWithItemsNoCopy: value count: size freeWhenDone: true]; value = NULL; } @finally { OFFreeMemory(value); } if (type != NULL) *type = nil; # elif defined(OF_FREEBSD) || defined(OF_NETBSD) int namespace; const char *cName; ssize_t size; parseAttributeName(&name, &namespace); cName = [name cStringWithEncoding: encoding]; if ((size = extattr_get_link(cPath, namespace, cName, NULL, 0)) < 0) @throw [OFGetItemAttributesFailedException exceptionWithIRI: IRI errNo: errno]; value = OFAllocMemory(1, size); @try { if ((size = extattr_get_link(cPath, namespace, cName, value, size)) < 0) @throw [OFGetItemAttributesFailedException exceptionWithIRI: IRI errNo: errno]; *data = [OFData dataWithItemsNoCopy: value count: size freeWhenDone: true]; value = NULL; } @finally { OFFreeMemory(value); } if (type != NULL) *type = nil; # elif defined(OF_HAIKU) const char *cName = [name cStringWithEncoding: encoding]; int fd = open(cPath, O_RDONLY); struct attr_info info; if (fd == -1) @throw [OFGetItemAttributesFailedException exceptionWithIRI: IRI errNo: errno]; @try { if (fs_stat_attr(fd, cName, &info) != 0) @throw [OFGetItemAttributesFailedException exceptionWithIRI: IRI errNo: errno]; if (info.size < 0 || info.size > SSIZE_MAX) @throw [OFOutOfRangeException exception]; value = OFAllocMemory(1, (size_t)info.size); errno = 0; if (fs_read_attr(fd, cName, B_ANY_TYPE, 0, value, (size_t)info.size) != (ssize_t)info.size) @throw [OFGetItemAttributesFailedException exceptionWithIRI: IRI errNo: errno]; *data = [OFData dataWithItemsNoCopy: value count: (size_t)info.size freeWhenDone: true]; value = NULL; if (type != NULL) *type = [OFNumber numberWithUnsignedLong: info.type]; } @finally { OFFreeMemory(value); close(fd); } # endif [*data retain]; if (type != NULL) [*type retain]; objc_autoreleasePoolPop(pool); [*data autorelease]; if (type != NULL) [*type autorelease]; } - (void)setExtendedAttributeData: (OFData *)data andType: (id)type forName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI { void *pool = objc_autoreleasePoolPush(); OFString *path = IRI.fileSystemRepresentation; OFStringEncoding encoding = [OFLocale encoding]; const char *cPath = [path cStringWithEncoding: encoding]; size_t size = data.count * data.itemSize; # if defined(OF_LINUX) || defined(OF_MACOS) const char *cName = [name cStringWithEncoding: encoding]; if (type != nil) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; # if defined(OF_LINUX) if (lsetxattr(cPath, cName, data.items, size, 0) != 0) { # elif defined(OF_MACOS) if (setxattr(cPath, cName, data.items, size, 0, XATTR_NOFOLLOW) != 0) { # endif int errNo = errno; /* TODO: Add an attribute (prefix?) for extended attributes? */ @throw [OFSetItemAttributesFailedException exceptionWithIRI: IRI attributes: [OFDictionary dictionary] failedAttribute: @"" errNo: errNo]; } # elif defined(OF_FREEBSD) || defined(OF_NETBSD) int namespace; const char *cName; if (size > SSIZE_MAX) @throw [OFOutOfRangeException exception]; if (type != nil) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; parseAttributeName(&name, &namespace); cName = [name cStringWithEncoding: encoding]; if (extattr_set_link(cPath, namespace, cName, data.items, size) != (ssize_t)size) { int errNo = errno; /* TODO: Add an attribute (prefix?) for extended attributes? */ @throw [OFSetItemAttributesFailedException exceptionWithIRI: IRI attributes: [OFDictionary dictionary] failedAttribute: @"" errNo: errNo]; } # elif defined(OF_HAIKU) const char *cName = [name cStringWithEncoding: encoding]; unsigned long long typeInt; int fd; if (type != nil && ![type isKindOfClass: [OFNumber class]]) @throw [OFInvalidArgumentException exception]; typeInt = (type != nil ? [type unsignedLongLongValue] : 0); if (typeInt > UINT32_MAX) @throw [OFInvalidArgumentException exception]; if (size > SSIZE_MAX) @throw [OFOutOfRangeException exception]; if ((fd = open(cPath, O_WRONLY)) == -1) { int errNo = errno; /* TODO: Add an attribute (prefix?) for extended attributes? */ @throw [OFSetItemAttributesFailedException exceptionWithIRI: IRI attributes: [OFDictionary dictionary] failedAttribute: @"" errNo: errNo]; } @try { if (fs_write_attr(fd, cName, (uint32_t)typeInt, 0, data.items, size) != (ssize_t)size) { int errNo = errno; /* * TODO: Add an attribute (prefix?) for extended * attributes? */ @throw [OFSetItemAttributesFailedException exceptionWithIRI: IRI attributes: [OFDictionary dictionary] failedAttribute: @"" errNo: errNo]; } } @finally { close(fd); } # endif objc_autoreleasePoolPop(pool); } - (void)removeExtendedAttributeForName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI { void *pool = objc_autoreleasePoolPush(); OFString *path = IRI.fileSystemRepresentation; OFStringEncoding encoding = [OFLocale encoding]; const char *cPath = [path cStringWithEncoding: encoding]; # if defined(OF_LINUX) || defined(OF_MACOS) const char *cName = [name cStringWithEncoding: encoding]; # if defined(OF_LINUX) if (lremovexattr(cPath, cName) != 0) { # elif defined(OF_MACOS) if (removexattr(cPath, cName, XATTR_NOFOLLOW) != 0) { # endif int errNo = errno; /* TODO: Add an attribute (prefix?) for extended attributes? */ @throw [OFSetItemAttributesFailedException exceptionWithIRI: IRI attributes: [OFDictionary dictionary] failedAttribute: @"" errNo: errNo]; } # elif defined(OF_FREEBSD) || defined(OF_NETBSD) int namespace; const char *cName; parseAttributeName(&name, &namespace); cName = [name cStringWithEncoding: encoding]; if (extattr_delete_link(cPath, namespace, cName) != 0) { int errNo = errno; /* TODO: Add an attribute (prefix?) for extended attributes? */ @throw [OFSetItemAttributesFailedException exceptionWithIRI: IRI attributes: [OFDictionary dictionary] failedAttribute: @"" errNo: errNo]; } # elif defined(OF_HAIKU) const char *cName = [name cStringWithEncoding: encoding]; int fd; if ((fd = open(cPath, O_WRONLY)) == -1) { int errNo = errno; /* TODO: Add an attribute (prefix?) for extended attributes? */ @throw [OFSetItemAttributesFailedException exceptionWithIRI: IRI attributes: [OFDictionary dictionary] failedAttribute: @"" errNo: errNo]; } @try { if (fs_remove_attr(fd, cName) != 0) { int errNo = errno; /* * TODO: Add an attribute (prefix?) for extended * attributes? */ @throw [OFSetItemAttributesFailedException exceptionWithIRI: IRI attributes: [OFDictionary dictionary] failedAttribute: @"" errNo: errNo]; } } @finally { close(fd); } # endif objc_autoreleasePoolPop(pool); } #endif @end |
Modified src/OFFileManager.h from [1cfc8cfdf6] to [5fc4b31e8a].
1 | /* | | | | | | > > > > | < > | | | | > | > > > > > | | | > | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFDictionary.h" OF_ASSUME_NONNULL_BEGIN /** @file */ #ifdef OF_HAVE_FILES # if (defined(OF_HAVE_CHMOD) && !defined(OF_AMIGAOS)) || defined(DOXYGEN) # define OF_FILE_MANAGER_SUPPORTS_PERMISSIONS # endif # if (defined(OF_HAVE_CHOWN) && !defined(OF_AMIGAOS)) || defined(DOXYGEN) # define OF_FILE_MANAGER_SUPPORTS_OWNER # endif # if (defined(OF_HAVE_LINK) && !defined(OF_AMIGAOS) && !defined(OF_HAIKU)) || \ defined(OF_WINDOWS) || defined(DOXYGEN) # define OF_FILE_MANAGER_SUPPORTS_LINKS # endif # if (defined(OF_HAVE_SYMLINK) && !defined(OF_AMIGAOS)) || \ defined(OF_WINDOWS) || defined(DOXYGEN) # define OF_FILE_MANAGER_SUPPORTS_SYMLINKS # endif # if defined(OF_LINUX) || defined(OF_MACOS) || defined(OF_FREEBSD) || \ defined(OF_NETBSD) || defined(OF_HAIKU) || defined(DOXYGEN) # define OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES # endif #endif @class OFArray OF_GENERIC(ObjectType); @class OFConstantString; @class OFDate; @class OFIRI; @class OFString; /** * @brief A key for a file attribute in the file attributes dictionary. * * Possible keys for file IRIs are: * * * @ref OFFileSize * * @ref OFFileType * * @ref OFFilePOSIXPermissions * * @ref OFFileOwnerAccountID * * @ref OFFileGroupOwnerAccountID * * @ref OFFileOwnerAccountName * * @ref OFFileGroupOwnerAccountName * * @ref OFFileLastAccessDate * * @ref OFFileModificationDate * * @ref OFFileStatusChangeDate * * @ref OFFileCreationDate * * @ref OFFileSymbolicLinkDestination * * @ref OFFileExtendedAttributesNames * * Other IRI schemes might not have all keys and might have keys not listed. */ typedef OFConstantString *OFFileAttributeKey; /** * @brief The type of a file. * * Possibles values for file IRIs are: * * * @ref OFFileTypeRegular * * @ref OFFileTypeDirectory * * @ref OFFileTypeSymbolicLink * * @ref OFFileTypeFIFO * * @ref OFFileTypeCharacterSpecial * * @ref OFFileTypeBlockSpecial * * @ref OFFileTypeSocket * * @ref OFFileTypeUnknown * * Other IRI schemes might not have all types and might have types not listed. */ typedef OFConstantString *OFFileAttributeType; /** * @brief A dictionary mapping keys of type @ref OFFileAttributeKey to their * attribute values. */ |
︙ | ︙ | |||
184 185 186 187 188 189 190 | * * For convenience, a category on @ref OFDictionary is provided to access this * via @ref OFDictionary#fileCreationDate. */ extern const OFFileAttributeKey OFFileCreationDate; /** | | > > > > > > > > > | 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | * * For convenience, a category on @ref OFDictionary is provided to access this * via @ref OFDictionary#fileCreationDate. */ extern const OFFileAttributeKey OFFileCreationDate; /** * @brief The destination of a symbolic link as an @ref OFString. * * For convenience, a category on @ref OFDictionary is provided to access this * via @ref OFDictionary#fileSymbolicLinkDestination. */ extern const OFFileAttributeKey OFFileSymbolicLinkDestination; /** * @brief The names of the extended attributes as an @ref OFArray of * @ref OFString. * * For convenience, a category on @ref OFDictionary is provided to access this * via @ref OFDictionary#fileExtendedAttributesNames. */ extern const OFFileAttributeKey OFFileExtendedAttributesNames; /** * @brief A regular file. */ extern const OFFileAttributeType OFFileTypeRegular; /** * @brief A directory. |
︙ | ︙ | |||
261 262 263 264 265 266 267 | * @brief The path of the current working directory. * * @throw OFGetCurrentDirectoryFailedException Couldn't get current directory */ @property (readonly, nonatomic) OFString *currentDirectoryPath; /** | | | | 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | * @brief The path of the current working directory. * * @throw OFGetCurrentDirectoryFailedException Couldn't get current directory */ @property (readonly, nonatomic) OFString *currentDirectoryPath; /** * @brief The IRI of the current working directory. * * @throw OFGetCurrentDirectoryFailedException Couldn't get current directory */ @property (readonly, nonatomic) OFIRI *currentDirectoryIRI; #endif /** * @brief Returns the default file manager. */ + (OFFileManager *)defaultManager; |
︙ | ︙ | |||
287 288 289 290 291 292 293 | * @throw OFGetItemAttributesFailedException Failed to get the attributes of * the item */ - (OFFileAttributes)attributesOfItemAtPath: (OFString *)path; #endif /** | | | | | | | | | | | | | | | | | | | | | | 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 | * @throw OFGetItemAttributesFailedException Failed to get the attributes of * the item */ - (OFFileAttributes)attributesOfItemAtPath: (OFString *)path; #endif /** * @brief Returns the attributes for the item at the specified IRI. * * @param IRI The IRI to return the attributes for * @return A dictionary of attributes for the specified IRI, with the keys of * type @ref OFFileAttributeKey * @throw OFGetItemAttributesFailedException Failed to get the attributes of * the item * @throw OFUnsupportedProtocolException No handler is registered for the IRI's * scheme */ - (OFFileAttributes)attributesOfItemAtIRI: (OFIRI *)IRI; #ifdef OF_HAVE_FILES /** * @brief Sets the attributes for the item at the specified path. * * All attributes not part of the dictionary are left unchanged. * * @param attributes The attributes to set for the specified path * @param path The path of the item to set the attributes for * @throw OFSetItemAttributesFailedException Failed to set the attributes of * the item * @throw OFNotImplementedException Setting one or more of the specified * attributes is not implemented for the * specified item */ - (void)setAttributes: (OFFileAttributes)attributes ofItemAtPath: (OFString *)path; #endif /** * @brief Sets the attributes for the item at the specified IRI. * * All attributes not part of the dictionary are left unchanged. * * @param attributes The attributes to set for the specified IRI * @param IRI The IRI of the item to set the attributes for * @throw OFSetItemAttributesFailedException Failed to set the attributes of * the item * @throw OFUnsupportedProtocolException No handler is registered for the IRI's * scheme * @throw OFNotImplementedException Setting one or more of the specified * attributes is not implemented for the * specified item */ - (void)setAttributes: (OFFileAttributes)attributes ofItemAtIRI: (OFIRI *)IRI; #ifdef OF_HAVE_FILES /** * @brief Checks whether a file exists at the specified path. * * @param path The path to check * @return A boolean whether there is a file at the specified path */ - (bool)fileExistsAtPath: (OFString *)path; #endif /** * @brief Checks whether a file exists at the specified IRI. * * @param IRI The IRI to check * @return A boolean whether there is a file at the specified IRI * @throw OFUnsupportedProtocolException No handler is registered for the IRI's * scheme */ - (bool)fileExistsAtIRI: (OFIRI *)IRI; #ifdef OF_HAVE_FILES /** * @brief Checks whether a directory exists at the specified path. * * @param path The path to check * @return A boolean whether there is a directory at the specified path */ - (bool)directoryExistsAtPath: (OFString *)path; #endif /** * @brief Checks whether a directory exists at the specified IRI. * * @param IRI The IRI to check * @return A boolean whether there is a directory at the specified IRI * @throw OFUnsupportedProtocolException No handler is registered for the IRI's * scheme */ - (bool)directoryExistsAtIRI: (OFIRI *)IRI; #ifdef OF_HAVE_FILES /** * @brief Creates a directory at the specified path. * * @param path The path of the directory to create * @throw OFCreateDirectoryFailedException Creating the directory failed |
︙ | ︙ | |||
396 397 398 399 400 401 402 | * parents failed */ - (void)createDirectoryAtPath: (OFString *)path createParents: (bool)createParents; #endif /** | | | | | | | | | | | | | | | 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 | * parents failed */ - (void)createDirectoryAtPath: (OFString *)path createParents: (bool)createParents; #endif /** * @brief Creates a directory at the specified IRI. * * @param IRI The IRI of the directory to create * @throw OFCreateDirectoryFailedException Creating the directory failed * @throw OFUnsupportedProtocolException No handler is registered for the IRI's * scheme */ - (void)createDirectoryAtIRI: (OFIRI *)IRI; /** * @brief Creates a directory at the specified IRI. * * @param IRI The IRI of the directory to create * @param createParents Whether to create the parents of the directory * @throw OFCreateDirectoryFailedException Creating the directory or one of its * parents failed * @throw OFUnsupportedProtocolException No handler is registered for the IRI's * scheme */ - (void)createDirectoryAtIRI: (OFIRI *)IRI createParents: (bool)createParents; #ifdef OF_HAVE_FILES /** * @brief Returns an array with the items in the specified directory. * * @note `.` and `..` are not part of the returned array. * * @param path The path to the directory whose items should be returned * @return An array of OFString with the items in the specified directory * @throw OFOpenItemFailedException Opening the directory failed * @throw OFReadFailedException Reading from the directory failed */ - (OFArray OF_GENERIC(OFString *) *)contentsOfDirectoryAtPath: (OFString *)path; #endif /** * @brief Returns an array with the IRIs of the items in the specified * directory. * * @note `.` and `..` are not part of the returned array. * * @param IRI The IRI to the directory whose items should be returned * @return An array with the IRIs of the items in the specified directory * @throw OFOpenItemFailedException Opening the directory failed * @throw OFReadFailedException Reading from the directory failed * @throw OFUnsupportedProtocolException No handler is registered for the IRI's * scheme */ - (OFArray OF_GENERIC(OFIRI *) *)contentsOfDirectoryAtIRI: (OFIRI *)IRI; #ifdef OF_HAVE_FILES /** * @brief Returns an array with all subpaths of the specified directory. * * @note `.` and `..` (of the directory itself or any subdirectory) are not * part of the returned array. |
︙ | ︙ | |||
470 471 472 473 474 475 476 | * directory failed */ - (void)changeCurrentDirectoryPath: (OFString *)path; /** * @brief Changes the current working directory. * | | | | 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 | * directory failed */ - (void)changeCurrentDirectoryPath: (OFString *)path; /** * @brief Changes the current working directory. * * @param IRI The new directory to change to * @throw OFChangeCurrentDirectoryFailedException Changing the current working * directory failed */ - (void)changeCurrentDirectoryIRI: (OFIRI *)IRI; /** * @brief Copies a file, directory or symbolic link (if supported by the OS). * * The destination path must be a full path, which means it must include the * name of the item. * |
︙ | ︙ | |||
498 499 500 501 502 503 504 | */ - (void)copyItemAtPath: (OFString *)source toPath: (OFString *)destination; #endif /** * @brief Copies a file, directory or symbolic link (if supported by the OS). * | | | | | | 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 | */ - (void)copyItemAtPath: (OFString *)source toPath: (OFString *)destination; #endif /** * @brief Copies a file, directory or symbolic link (if supported by the OS). * * The destination IRI must have a full path, which means it must include the * name of the item. * * If an item already exists, the copy operation fails. This is also the case * if a directory is copied and an item already exists in the destination * directory. * * @param source The file, directory or symbolic link to copy * @param destination The destination IRI * @throw OFCopyItemFailedException Copying failed * @throw OFCreateDirectoryFailedException Creating a destination directory * failed * @throw OFUnsupportedProtocolException No handler is registered for either of * the IRI's scheme */ - (void)copyItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination; #ifdef OF_HAVE_FILES /** * @brief Moves an item. * * The destination path must be a full path, which means it must include the * name of the item. |
︙ | ︙ | |||
543 544 545 546 547 548 549 | */ - (void)moveItemAtPath: (OFString *)source toPath: (OFString *)destination; #endif /** * @brief Moves an item. * | | | | | | | | | | | | | | | | | | | | | | | | > | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 | */ - (void)moveItemAtPath: (OFString *)source toPath: (OFString *)destination; #endif /** * @brief Moves an item. * * The destination IRI must have a full path, which means it must include the * name of the item. * * If the destination is on a different logical device or uses a different * scheme, the source will be copied to the destination using * @ref copyItemAtIRI:toIRI: and the source removed using @ref removeItemAtIRI:. * * @param source The item to rename * @param destination The new name for the item * @throw OFMoveItemFailedException Moving failed * @throw OFCopyItemFailedException Copying (to move between different devices) * failed * @throw OFRemoveItemFailedException Removing the source after copying to the * destination (to move between different * devices) failed * @throw OFCreateDirectoryFailedException Creating a destination directory * failed * @throw OFUnsupportedProtocolException No handler is registered for either of * the IRI's scheme */ - (void)moveItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination; #ifdef OF_HAVE_FILES /** * @brief Removes the item at the specified path. * * If the item at the specified path is a directory, it is removed recursively. * * @param path The path to the item which should be removed * @throw OFRemoveItemFailedException Removing the item failed */ - (void)removeItemAtPath: (OFString *)path; #endif /** * @brief Removes the item at the specified IRI. * * If the item at the specified IRI is a directory, it is removed recursively. * * @param IRI The IRI to the item which should be removed * @throw OFRemoveItemFailedException Removing the item failed * @throw OFUnsupportedProtocolException No handler is registered for the IRI's * scheme */ - (void)removeItemAtIRI: (OFIRI *)IRI; #ifdef OF_FILE_MANAGER_SUPPORTS_LINKS /** * @brief Creates a hard link for the specified item. * * The destination path must be a full path, which means it must include the * name of the item. * * This method is not available on some systems. * * @param source The path to the item for which a link should be created * @param destination The path to the item which should link to the source * @throw OFLinkItemFailedException Linking the item failed * @throw OFNotImplementedException Hardlinks are not implemented for the * specified IRI */ - (void)linkItemAtPath: (OFString *)source toPath: (OFString *)destination; #endif /** * @brief Creates a hard link for the specified item. * * The destination IRI must have a full path, which means it must include the * name of the item. * * This method is not available for all IRIs. * * @param source The IRI to the item for which a link should be created * @param destination The IRI to the item which should link to the source * @throw OFLinkItemFailedException Linking the item failed * @throw OFUnsupportedProtocolException No handler is registered for the IRI's * scheme * @throw OFNotImplementedException Hardlinks are not implemented for the * specified IRI */ - (void)linkItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination; #ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS /** * @brief Creates a symbolic link for an item. * * The destination path must be a full path, which means it must include the * name of the item. * * This method is not available on some systems. * * @note On Windows, this requires at least Windows Vista and administrator * privileges! * * @param path The path to the item which should symbolically link to the target * @param target The target of the symbolic link * @throw OFCreateSymbolicLinkFailedException Creating the symbolic link failed * @throw OFNotImplementedException Symbolic links are not implemented for the * specified IRI */ - (void)createSymbolicLinkAtPath: (OFString *)path withDestinationPath: (OFString *)target; #endif /** * @brief Creates a symbolic link for an item. * * The destination IRI must have a full path, which means it must include the * name of the item. * * This method is not available for all IRIs. * * @note For file IRIs on Windows, this requires at least Windows Vista and * administrator privileges! * * @param IRI The IRI to the item which should symbolically link to the target * @param target The target of the symbolic link * @throw OFOFCreateSymbolicLinkFailedException Creating a symbolic link failed * @throw OFUnsupportedProtocolException No handler is registered for the IRI's * scheme */ - (void)createSymbolicLinkAtIRI: (OFIRI *)IRI withDestinationPath: (OFString *)target; #ifdef OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES /** * @brief Returns the extended attribute data for the specified name of the * item at the specified path. * * This method is not available on some systems. * * @param name The name of the extended attribute * @param path The path of the item to return the extended attribute from * @return The extended attribute data for the specified name of the item at * the specified IRI * @throw OFGetItemAttributesFailedException Getting the extended attribute * failed * @throw OFNotImplementedException Getting extended attributes is not * implemented for the specified item */ - (OFData *)extendedAttributeDataForName: (OFString *)name ofItemAtPath: (OFString *)path; /** * @brief Gets the extended attribute data and type for the specified name * of the item at the specified path. * * This method is not available on some systems. * * @param data A pointer to `OFData *` that gets set to the data of the * extended attribute * @param type A pointer to `id` that gets set to the type of the extended * attribute, if not `NULL`. Gets set to `nil` if the extended * attribute has no type. The type of the type depends on the * system. * @param name The name of the extended attribute * @param path The path of the item to return the extended attribute from * @throw OFGetItemAttributesFailedException Getting the extended attribute * failed * @throw OFNotImplementedException Getting extended attributes is not * implemented for the specified item */ - (void)getExtendedAttributeData: (OFData *_Nonnull *_Nonnull)data andType: (id _Nullable *_Nullable)type forName: (OFString *)name ofItemAtPath: (OFString *)path; #endif /** * @brief Returns the extended attribute data for the specified name of the * item at the specified IRI. * * This method is not available for all IRIs. * * @param name The name of the extended attribute * @param IRI The IRI of the item to return the extended attribute from * @return The extended attribute data for the specified name of the item at * the specified IRI * @throw OFGetItemAttributesFailedException Getting the extended attribute * failed * @throw OFUnsupportedProtocolException No handler is registered for the IRI's * scheme * @throw OFNotImplementedException Getting extended attributes is not * implemented for the specified item */ - (OFData *)extendedAttributeDataForName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI; /** * @brief Gets the extended attribute data and type for the specified name * of the item at the specified IRI. * * This method is not available for all IRIs. * * @param data A pointer to `OFData *` that gets set to the data of the * extended attribute * @param type A pointer to `id` that gets set to the type of the extended * attribute, if not `NULL`. Gets set to `nil` if the extended * attribute has no type. The type of the type depends on the IRI * handler. * @param name The name of the extended attribute * @param IRI The IRI of the item to return the extended attribute from * @throw OFGetItemAttributesFailedException Getting the extended attribute * failed * @throw OFUnsupportedProtocolException No handler is registered for the IRI's * scheme * @throw OFNotImplementedException Getting extended attributes is not * implemented for the specified item */ - (void)getExtendedAttributeData: (OFData *_Nonnull *_Nonnull)data andType: (id _Nullable *_Nullable)type forName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI; #ifdef OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES /** * @brief Sets the extended attribute data for the specified name of the item * at the specified path. * * This method is not available on some systems. * * @param data The data for the extended attribute * @param name The name of the extended attribute * @param path The path of the item to set the extended attribute on * @throw OFSetItemAttributesFailedException Setting the extended attribute * failed * @throw OFNotImplementedException Setting extended attributes is not * implemented for the specified item */ - (void)setExtendedAttributeData: (OFData *)data forName: (OFString *)name ofItemAtPath: (OFString *)path; /** * @brief Sets the extended attribute data for the specified name of the item * at the specified path. * * This method is not available on some systems. * * @param data The data for the extended attribute * @param type The type for the extended attribute. `nil` does not mean to keep * the existing type, but to set it to no type. The type of the * type depends on the system. * @param name The name of the extended attribute * @param path The path of the item to set the extended attribute on * @throw OFSetItemAttributesFailedException Setting the extended attribute * failed * @throw OFNotImplementedException Setting extended attributes is not * implemented for the specified item or a * type was specified and typed extended * attributes are not supported */ - (void)setExtendedAttributeData: (OFData *)data andType: (nullable id)type forName: (OFString *)name ofItemAtPath: (OFString *)path; #endif /** * @brief Sets the extended attribute data for the specified name of the item * at the specified IRI. * * This method is not available for all IRIs. * * @param data The data for the extended attribute * @param name The name of the extended attribute * @param IRI The IRI of the item to set the extended attribute on * @throw OFSetItemAttributesFailedException Setting the extended attribute * failed * @throw OFUnsupportedProtocolException No handler is registered for the IRI's * scheme * @throw OFNotImplementedException Setting extended attributes is not * implemented for the specified item */ - (void)setExtendedAttributeData: (OFData *)data forName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI; /** * @brief Sets the extended attribute data for the specified name of the item * at the specified IRI. * * This method is not available for all IRIs. * * @param data The data for the extended attribute * @param type The type for the extended attribute. `nil` does not mean to keep * the existing type, but to set it to no type. The type of the * type depends on the IRI handler. * @param name The name of the extended attribute * @param IRI The IRI of the item to set the extended attribute on * @throw OFSetItemAttributesFailedException Setting the extended attribute * failed * @throw OFUnsupportedProtocolException No handler is registered for the IRI's * scheme * @throw OFNotImplementedException Setting extended attributes is not * implemented for the specified item or a * type was specified and typed extended * attributes are not supported */ - (void)setExtendedAttributeData: (OFData *)data andType: (nullable id)type forName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI; #ifdef OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES /** * @brief Removes the extended attribute for the specified name of the item at * the specified path. * * This method is not available on some systems. * * @param name The name of the extended attribute to remove * @param path The path of the item to remove the extended attribute from * @throw OFSetItemAttributesFailedException Removing the extended attribute * failed * @throw OFNotImplementedException Removing extended attributes is not * implemented for the specified item */ - (void)removeExtendedAttributeForName: (OFString *)name ofItemAtPath: (OFString *)path; #endif /** * @brief Removes the extended attribute for the specified name of the item at * the specified IRI. * * This method is not available for all IRIs. * * @param name The name of the extended attribute to remove * @param IRI The IRI of the item to remove the extended attribute from * @throw OFSetItemAttributesFailedException Removing the extended attribute * failed * @throw OFUnsupportedProtocolException No handler is registered for the IRI's * scheme * @throw OFNotImplementedException Removing extended attributes is not * implemented for the specified item */ - (void)removeExtendedAttributeForName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI; @end @interface OFDictionary (FileAttributes) /** * @brief The @ref OFFileSize key from the dictionary. * * @throw OFUndefinedKeyException The key is missing |
︙ | ︙ | |||
751 752 753 754 755 756 757 758 759 760 | /** * @brief The @ref OFFileSymbolicLinkDestination key from the dictionary. * * @throw OFUndefinedKeyException The key is missing */ @property (readonly, nonatomic) OFString *fileSymbolicLinkDestination; @end OF_ASSUME_NONNULL_END | > > > > > > > > | 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 | /** * @brief The @ref OFFileSymbolicLinkDestination key from the dictionary. * * @throw OFUndefinedKeyException The key is missing */ @property (readonly, nonatomic) OFString *fileSymbolicLinkDestination; /** * @brief The @ref OFFileExtendedAttributesNames key from the dictionary. * * @throw OFUndefinedKeyException The key is missing */ @property (readonly, nonatomic) OFArray OF_GENERIC(OFString *) *fileExtendedAttributesNames; @end OF_ASSUME_NONNULL_END |
Modified src/OFFileManager.m from [5dfeac045a] to [fee3c0b404].
1 | /* | | | | | | > > > > | < > | > > > > > > < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #define OF_FILE_MANAGER_M #include <errno.h> #include <limits.h> #include "unistd_wrapper.h" #include "platform.h" #ifdef OF_DJGPP # include <syslimits.h> #endif #ifdef OF_PSP # include <sys/syslimits.h> #endif #import "OFArray.h" #import "OFData.h" #import "OFDate.h" #import "OFDictionary.h" #ifdef OF_HAVE_FILES # import "OFFile.h" #endif #import "OFFileManager.h" #import "OFIRI.h" #import "OFIRIHandler.h" #import "OFLocale.h" #import "OFNumber.h" #import "OFStream.h" #import "OFString.h" #import "OFSystemInfo.h" #import "OFChangeCurrentDirectoryFailedException.h" #import "OFCopyItemFailedException.h" #import "OFCreateDirectoryFailedException.h" #import "OFGetCurrentDirectoryFailedException.h" #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" |
︙ | ︙ | |||
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | #ifdef OF_WINDOWS # include <windows.h> # include <direct.h> # include <ntdef.h> #endif #ifdef OF_AMIGAOS # include <proto/exec.h> # include <proto/dos.h> #endif #ifdef OF_MINT # include <bits/local_lim.h> #endif @interface OFDefaultFileManager: OFFileManager | > > | 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | #ifdef OF_WINDOWS # include <windows.h> # include <direct.h> # include <ntdef.h> #endif #ifdef OF_AMIGAOS # define Class IntuitionClass # include <proto/exec.h> # include <proto/dos.h> # undef Class #endif #ifdef OF_MINT # include <bits/local_lim.h> #endif @interface OFDefaultFileManager: OFFileManager |
︙ | ︙ | |||
163 164 165 166 167 168 169 170 171 172 173 174 175 176 | @throw [OFOutOfRangeException exception]; return nil; } return [OFString stringWithCString: buffer encoding: [OFLocale encoding]]; # else char buffer[PATH_MAX]; if ((getcwd(buffer, PATH_MAX)) == NULL) @throw [OFGetCurrentDirectoryFailedException exceptionWithErrNo: errno]; | > > > > > > > > > > > > > > > > | 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | @throw [OFOutOfRangeException exception]; return nil; } return [OFString stringWithCString: buffer encoding: [OFLocale encoding]]; # elif defined(OF_GLIBC) char *buffer; OFString *path; if ((buffer = getcwd(NULL, 0)) == NULL) @throw [OFGetCurrentDirectoryFailedException exceptionWithErrNo: errno]; @try { path = [OFString stringWithCString: buffer encoding: [OFLocale encoding]]; } @finally { free(buffer); } return path; # else char buffer[PATH_MAX]; if ((getcwd(buffer, PATH_MAX)) == NULL) @throw [OFGetCurrentDirectoryFailedException exceptionWithErrNo: errno]; |
︙ | ︙ | |||
185 186 187 188 189 190 191 | # endif return [OFString stringWithCString: buffer encoding: [OFLocale encoding]]; # endif } | | | | | | > | | | | | | | | | | | | | | | | | | | | | | | > | | | | | | | > | > | | | | | | > | > | | | | | | > > > | > | > | > > | | | | | | | | | | | | | | | | | | | > | > | | | | | | | | > | | | | | 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 | # endif return [OFString stringWithCString: buffer encoding: [OFLocale encoding]]; # endif } - (OFIRI *)currentDirectoryIRI { void *pool = objc_autoreleasePoolPush(); OFIRI *ret; ret = [OFIRI fileIRIWithPath: self.currentDirectoryPath isDirectory: true]; ret = [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } #endif - (OFFileAttributes)attributesOfItemAtIRI: (OFIRI *)IRI { OFIRIHandler *IRIHandler; if (IRI == nil) @throw [OFInvalidArgumentException exception]; if ((IRIHandler = [OFIRIHandler handlerForIRI: IRI]) == nil) @throw [OFUnsupportedProtocolException exceptionWithIRI: IRI]; return [IRIHandler attributesOfItemAtIRI: IRI]; } #ifdef OF_HAVE_FILES - (OFFileAttributes)attributesOfItemAtPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFFileAttributes ret; ret = [self attributesOfItemAtIRI: [OFIRI fileIRIWithPath: path isDirectory: false]]; ret = [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } #endif - (void)setAttributes: (OFFileAttributes)attributes ofItemAtIRI: (OFIRI *)IRI { OFIRIHandler *IRIHandler; if (IRI == nil) @throw [OFInvalidArgumentException exception]; if ((IRIHandler = [OFIRIHandler handlerForIRI: IRI]) == nil) @throw [OFUnsupportedProtocolException exceptionWithIRI: IRI]; [IRIHandler setAttributes: attributes ofItemAtIRI: IRI]; } #ifdef OF_HAVE_FILES - (void)setAttributes: (OFFileAttributes)attributes ofItemAtPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); [self setAttributes: attributes ofItemAtIRI: [OFIRI fileIRIWithPath: path isDirectory: false]]; objc_autoreleasePoolPop(pool); } #endif - (bool)fileExistsAtIRI: (OFIRI *)IRI { OFIRIHandler *IRIHandler; if (IRI == nil) @throw [OFInvalidArgumentException exception]; if ((IRIHandler = [OFIRIHandler handlerForIRI: IRI]) == nil) @throw [OFUnsupportedProtocolException exceptionWithIRI: IRI]; return [IRIHandler fileExistsAtIRI: IRI]; } #ifdef OF_HAVE_FILES - (bool)fileExistsAtPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); bool ret; ret = [self fileExistsAtIRI: [OFIRI fileIRIWithPath: path isDirectory: false]]; objc_autoreleasePoolPop(pool); return ret; } #endif - (bool)directoryExistsAtIRI: (OFIRI *)IRI { OFIRIHandler *IRIHandler; if (IRI == nil) @throw [OFInvalidArgumentException exception]; if ((IRIHandler = [OFIRIHandler handlerForIRI: IRI]) == nil) @throw [OFUnsupportedProtocolException exceptionWithIRI: IRI]; return [IRIHandler directoryExistsAtIRI: IRI]; } #ifdef OF_HAVE_FILES - (bool)directoryExistsAtPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); bool ret; ret = [self directoryExistsAtIRI: [OFIRI fileIRIWithPath: path isDirectory: true]]; objc_autoreleasePoolPop(pool); return ret; } #endif - (void)createDirectoryAtIRI: (OFIRI *)IRI { void *pool = objc_autoreleasePoolPush(); OFIRIHandler *IRIHandler; if (IRI == nil) @throw [OFInvalidArgumentException exception]; if ((IRIHandler = [OFIRIHandler handlerForIRI: IRI]) == nil) @throw [OFUnsupportedProtocolException exceptionWithIRI: IRI]; [IRIHandler createDirectoryAtIRI: IRI]; objc_autoreleasePoolPop(pool); } - (void)createDirectoryAtIRI: (OFIRI *)IRI createParents: (bool)createParents { void *pool = objc_autoreleasePoolPush(); OFMutableIRI *mutableIRI; OFArray OF_GENERIC(OFString *) *components; OFMutableArray OF_GENERIC(OFIRI *) *componentIRIs; size_t componentIRIsCount; ssize_t i; if (IRI == nil) @throw [OFInvalidArgumentException exception]; if (!createParents) { [self createDirectoryAtIRI: IRI]; objc_autoreleasePoolPop(pool); return; } /* * Try blindly creating the directory first. * * The reason for this is that we might be sandboxed, so attempting to * create any of the parent directories will fail, while creating the * directory itself will work. */ if ([self directoryExistsAtIRI: IRI]) { objc_autoreleasePoolPop(pool); return; } @try { [self createDirectoryAtIRI: IRI]; objc_autoreleasePoolPop(pool); return; } @catch (OFCreateDirectoryFailedException *e) { /* * If we didn't fail because any of the parents is missing, * there is no point in trying to create the parents. */ if (e.errNo != ENOENT) @throw e; } /* * Because we might be sandboxed (and for remote IRIs don't even know * anything at all), we generate the IRI for every component. We then * iterate them in reverse order until we find the first existing * directory, and then create subdirectories from there. */ mutableIRI = [[IRI mutableCopy] autorelease]; mutableIRI.percentEncodedPath = @"/"; components = IRI.pathComponents; componentIRIs = [OFMutableArray arrayWithCapacity: components.count]; for (OFString *component in components) { [mutableIRI appendPathComponent: component]; if (![mutableIRI.percentEncodedPath isEqual: @"/"]) [componentIRIs addObject: [[mutableIRI copy] autorelease]]; } componentIRIsCount = componentIRIs.count; for (i = componentIRIsCount - 1; i > 0; i--) { if ([self directoryExistsAtIRI: [componentIRIs objectAtIndex: i]]) break; } if (++i == (ssize_t)componentIRIsCount) { /* * The IRI exists, even though before we made sure it did not. * That means it was created in the meantime by something else, * so we're done here. */ objc_autoreleasePoolPop(pool); return; } for (; i < (ssize_t)componentIRIsCount; i++) [self createDirectoryAtIRI: [componentIRIs objectAtIndex: i]]; objc_autoreleasePoolPop(pool); } #ifdef OF_HAVE_FILES - (void)createDirectoryAtPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); [self createDirectoryAtIRI: [OFIRI fileIRIWithPath: path isDirectory: true]]; objc_autoreleasePoolPop(pool); } - (void)createDirectoryAtPath: (OFString *)path createParents: (bool)createParents { void *pool = objc_autoreleasePoolPush(); [self createDirectoryAtIRI: [OFIRI fileIRIWithPath: path isDirectory: true] createParents: createParents]; objc_autoreleasePoolPop(pool); } #endif - (OFArray OF_GENERIC(OFIRI *) *)contentsOfDirectoryAtIRI: (OFIRI *)IRI { OFIRIHandler *IRIHandler; if (IRI == nil) @throw [OFInvalidArgumentException exception]; if ((IRIHandler = [OFIRIHandler handlerForIRI: IRI]) == nil) @throw [OFUnsupportedProtocolException exceptionWithIRI: IRI]; return [IRIHandler contentsOfDirectoryAtIRI: IRI]; } #ifdef OF_HAVE_FILES - (OFArray OF_GENERIC(OFString *) *)contentsOfDirectoryAtPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFArray OF_GENERIC(OFIRI *) *IRIs; OFMutableArray OF_GENERIC(OFString *) *ret; IRIs = [self contentsOfDirectoryAtIRI: [OFIRI fileIRIWithPath: path isDirectory: true]]; ret = [OFMutableArray arrayWithCapacity: IRIs.count]; for (OFIRI *IRI in IRIs) [ret addObject: IRI.lastPathComponent]; [ret makeImmutable]; ret = [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } - (OFArray OF_GENERIC(OFString *) *)subpathsOfDirectoryAtPath: (OFString *)path |
︙ | ︙ | |||
478 479 480 481 482 483 484 | else [ret addObject: fullSubpath]; objc_autoreleasePoolPop(pool2); } [ret makeImmutable]; | | | 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 | else [ret addObject: fullSubpath]; objc_autoreleasePoolPop(pool2); } [ret makeImmutable]; ret = [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } - (void)changeCurrentDirectoryPath: (OFString *)path |
︙ | ︙ | |||
541 542 543 544 545 546 547 | if (status != 0) @throw [OFChangeCurrentDirectoryFailedException exceptionWithPath: path errNo: errno]; # endif } | | | | > | > | | | | | | | | | | | | | | | | | | | | | | | | | 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 | if (status != 0) @throw [OFChangeCurrentDirectoryFailedException exceptionWithPath: path errNo: errno]; # endif } - (void)changeCurrentDirectoryIRI: (OFIRI *)IRI { void *pool = objc_autoreleasePoolPush(); [self changeCurrentDirectoryPath: IRI.fileSystemRepresentation]; objc_autoreleasePoolPop(pool); } - (void)copyItemAtPath: (OFString *)source toPath: (OFString *)destination { void *pool = objc_autoreleasePoolPush(); [self copyItemAtIRI: [OFIRI fileIRIWithPath: source isDirectory: false] toIRI: [OFIRI fileIRIWithPath: destination isDirectory: false]]; objc_autoreleasePoolPop(pool); } #endif - (void)copyItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination { void *pool; OFIRIHandler *IRIHandler; OFFileAttributes attributes; OFFileAttributeType type; if (source == nil || destination == nil) @throw [OFInvalidArgumentException exception]; pool = objc_autoreleasePoolPush(); if ((IRIHandler = [OFIRIHandler handlerForIRI: source]) == nil) @throw [OFUnsupportedProtocolException exceptionWithIRI: source]; if ([IRIHandler copyItemAtIRI: source toIRI: destination]) return; if ([self fileExistsAtIRI: destination]) @throw [OFCopyItemFailedException exceptionWithSourceIRI: source destinationIRI: destination errNo: EEXIST]; @try { attributes = [self attributesOfItemAtIRI: source]; } @catch (OFGetItemAttributesFailedException *e) { @throw [OFCopyItemFailedException exceptionWithSourceIRI: source destinationIRI: destination errNo: e.errNo]; } type = attributes.fileType; if ([type isEqual: OFFileTypeDirectory]) { OFArray OF_GENERIC(OFIRI *) *contents; @try { [self createDirectoryAtIRI: destination]; @try { OFFileAttributeKey key = OFFilePOSIXPermissions; OFNumber *permissions = [attributes objectForKey: key]; OFFileAttributes destinationAttributes; if (permissions != nil) { destinationAttributes = [OFDictionary dictionaryWithObject: permissions forKey: key]; [self setAttributes: destinationAttributes ofItemAtIRI: destination]; } } @catch (OFNotImplementedException *e) { } contents = [self contentsOfDirectoryAtIRI: source]; } @catch (id e) { /* * Only convert exceptions to OFCopyItemFailedException * that have an errNo property. This covers all I/O * related exceptions from the operations used to copy * an item, all others should be left as is. */ if ([e respondsToSelector: @selector(errNo)]) @throw [OFCopyItemFailedException exceptionWithSourceIRI: source destinationIRI: destination errNo: [e errNo]]; @throw e; } for (OFIRI *item in contents) { void *pool2 = objc_autoreleasePoolPush(); OFIRI *destinationIRI = [destination IRIByAppendingPathComponent: item.lastPathComponent]; [self copyItemAtIRI: item toIRI: destinationIRI]; objc_autoreleasePoolPop(pool2); } } else if ([type isEqual: OFFileTypeRegular]) { size_t pageSize = [OFSystemInfo pageSize]; OFStream *sourceStream = nil; OFStream *destinationStream = nil; char *buffer; buffer = OFAllocMemory(1, pageSize); @try { sourceStream = [OFIRIHandler openItemAtIRI: source mode: @"r"]; destinationStream = [OFIRIHandler openItemAtIRI: destination mode: @"w"]; while (!sourceStream.atEndOfStream) { size_t length; length = [sourceStream readIntoBuffer: buffer |
︙ | ︙ | |||
683 684 685 686 687 688 689 | if (permissions != nil) { destinationAttributes = [OFDictionary dictionaryWithObject: permissions forKey: key]; [self setAttributes: destinationAttributes | | | | | | | | | | > | > | | | | | | | | | | | | | | | | | | | | | | > | | | | | | | > | > | | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > < < < < | < < < < < < < < < < < < < | 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 | if (permissions != nil) { destinationAttributes = [OFDictionary dictionaryWithObject: permissions forKey: key]; [self setAttributes: destinationAttributes ofItemAtIRI: destination]; } } @catch (OFNotImplementedException *e) { } } @catch (id e) { /* * Only convert exceptions to OFCopyItemFailedException * that have an errNo property. This covers all I/O * related exceptions from the operations used to copy * an item, all others should be left as is. */ if ([e respondsToSelector: @selector(errNo)]) @throw [OFCopyItemFailedException exceptionWithSourceIRI: source destinationIRI: destination errNo: [e errNo]]; @throw e; } @finally { [sourceStream close]; [destinationStream close]; OFFreeMemory(buffer); } } else if ([type isEqual: OFFileTypeSymbolicLink]) { @try { OFString *linkDestination = attributes.fileSymbolicLinkDestination; [self createSymbolicLinkAtIRI: destination withDestinationPath: linkDestination]; } @catch (id e) { /* * Only convert exceptions to OFCopyItemFailedException * that have an errNo property. This covers all I/O * related exceptions from the operations used to copy * an item, all others should be left as is. */ if ([e respondsToSelector: @selector(errNo)]) @throw [OFCopyItemFailedException exceptionWithSourceIRI: source destinationIRI: destination errNo: [e errNo]]; @throw e; } } else @throw [OFCopyItemFailedException exceptionWithSourceIRI: source destinationIRI: destination errNo: EINVAL]; objc_autoreleasePoolPop(pool); } #ifdef OF_HAVE_FILES - (void)moveItemAtPath: (OFString *)source toPath: (OFString *)destination { void *pool = objc_autoreleasePoolPush(); [self moveItemAtIRI: [OFIRI fileIRIWithPath: source isDirectory: false] toIRI: [OFIRI fileIRIWithPath: destination isDirectory: false]]; objc_autoreleasePoolPop(pool); } #endif - (void)moveItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination { void *pool; OFIRIHandler *IRIHandler; if (source == nil || destination == nil) @throw [OFInvalidArgumentException exception]; pool = objc_autoreleasePoolPush(); if ((IRIHandler = [OFIRIHandler handlerForIRI: source]) == nil) @throw [OFUnsupportedProtocolException exceptionWithIRI: source]; @try { if ([IRIHandler moveItemAtIRI: source toIRI: destination]) return; } @catch (OFMoveItemFailedException *e) { if (e.errNo != EXDEV) @throw e; } if ([self fileExistsAtIRI: destination]) @throw [OFMoveItemFailedException exceptionWithSourceIRI: source destinationIRI: destination errNo: EEXIST]; @try { [self copyItemAtIRI: source toIRI: destination]; } @catch (OFCopyItemFailedException *e) { [self removeItemAtIRI: destination]; @throw [OFMoveItemFailedException exceptionWithSourceIRI: source destinationIRI: destination errNo: e.errNo]; } @try { [self removeItemAtIRI: source]; } @catch (OFRemoveItemFailedException *e) { @throw [OFMoveItemFailedException exceptionWithSourceIRI: source destinationIRI: destination errNo: e.errNo]; } objc_autoreleasePoolPop(pool); } - (void)removeItemAtIRI: (OFIRI *)IRI { OFIRIHandler *IRIHandler; if (IRI == nil) @throw [OFInvalidArgumentException exception]; if ((IRIHandler = [OFIRIHandler handlerForIRI: IRI]) == nil) @throw [OFUnsupportedProtocolException exceptionWithIRI: IRI]; [IRIHandler removeItemAtIRI: IRI]; } #ifdef OF_HAVE_FILES - (void)removeItemAtPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); [self removeItemAtIRI: [OFIRI fileIRIWithPath: path isDirectory: false]]; objc_autoreleasePoolPop(pool); } #endif - (void)linkItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination { void *pool = objc_autoreleasePoolPush(); OFIRIHandler *IRIHandler; if (source == nil || destination == nil) @throw [OFInvalidArgumentException exception]; if (![destination.scheme isEqual: source.scheme]) @throw [OFInvalidArgumentException exception]; IRIHandler = [OFIRIHandler handlerForIRI: source]; if (IRIHandler == nil) @throw [OFUnsupportedProtocolException exceptionWithIRI: source]; [IRIHandler linkItemAtIRI: source toIRI: destination]; objc_autoreleasePoolPop(pool); } #ifdef OF_FILE_MANAGER_SUPPORTS_LINKS - (void)linkItemAtPath: (OFString *)source toPath: (OFString *)destination { void *pool = objc_autoreleasePoolPush(); [self linkItemAtIRI: [OFIRI fileIRIWithPath: source isDirectory: false] toIRI: [OFIRI fileIRIWithPath: destination isDirectory: false]]; objc_autoreleasePoolPop(pool); } #endif - (void)createSymbolicLinkAtIRI: (OFIRI *)IRI withDestinationPath: (OFString *)target { void *pool = objc_autoreleasePoolPush(); OFIRIHandler *IRIHandler; if (IRI == nil || target == nil) @throw [OFInvalidArgumentException exception]; IRIHandler = [OFIRIHandler handlerForIRI: IRI]; if (IRIHandler == nil) @throw [OFUnsupportedProtocolException exceptionWithIRI: IRI]; [IRIHandler createSymbolicLinkAtIRI: IRI withDestinationPath: target]; objc_autoreleasePoolPop(pool); } #ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS - (void)createSymbolicLinkAtPath: (OFString *)path withDestinationPath: (OFString *)target { void *pool = objc_autoreleasePoolPush(); [self createSymbolicLinkAtIRI: [OFIRI fileIRIWithPath: path isDirectory: false] withDestinationPath: target]; objc_autoreleasePoolPop(pool); } #endif - (OFData *)extendedAttributeDataForName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI { OFData *data; [self getExtendedAttributeData: &data andType: NULL forName: name ofItemAtIRI: IRI]; return data; } - (void)getExtendedAttributeData: (OFData **)data andType: (id *)type forName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI { void *pool = objc_autoreleasePoolPush(); OFIRIHandler *IRIHandler; if (IRI == nil) @throw [OFInvalidArgumentException exception]; if ((IRIHandler = [OFIRIHandler handlerForIRI: IRI]) == nil) @throw [OFUnsupportedProtocolException exceptionWithIRI: IRI]; [IRIHandler getExtendedAttributeData: data andType: type forName: name ofItemAtIRI: IRI]; [*data retain]; if (type != NULL) [*type retain]; objc_autoreleasePoolPop(pool); [*data autorelease]; if (type != NULL) [*type autorelease]; } #ifdef OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES - (OFData *)extendedAttributeDataForName: (OFString *)name ofItemAtPath: (OFString *)path { OFData *data; [self getExtendedAttributeData: &data andType: NULL forName: name ofItemAtPath: path]; return data; } - (void)getExtendedAttributeData: (OFData **)data andType: (id *)type forName: (OFString *)name ofItemAtPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); [self getExtendedAttributeData: data andType: type forName: name ofItemAtIRI: [OFIRI fileIRIWithPath: path isDirectory: false]]; [*data retain]; if (type != NULL) [*type retain]; objc_autoreleasePoolPop(pool); [*data autorelease]; if (type != NULL) [*type autorelease]; } #endif - (void)setExtendedAttributeData: (OFData *)data forName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI { [self setExtendedAttributeData: data andType: nil forName: name ofItemAtIRI: IRI]; } - (void)setExtendedAttributeData: (OFData *)data andType: (id)type forName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI { OFIRIHandler *IRIHandler; if (IRI == nil) @throw [OFInvalidArgumentException exception]; if ((IRIHandler = [OFIRIHandler handlerForIRI: IRI]) == nil) @throw [OFUnsupportedProtocolException exceptionWithIRI: IRI]; [IRIHandler setExtendedAttributeData: data andType: type forName: name ofItemAtIRI: IRI]; } #ifdef OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES - (void)setExtendedAttributeData: (OFData *)data forName: (OFString *)name ofItemAtPath: (OFString *)path { [self setExtendedAttributeData: data andType: nil forName: name ofItemAtPath: path]; } - (void)setExtendedAttributeData: (OFData *)data andType: (id)type forName: (OFString *)name ofItemAtPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); [self setExtendedAttributeData: data andType: type forName: name ofItemAtIRI: [OFIRI fileIRIWithPath: path isDirectory: false]]; objc_autoreleasePoolPop(pool); } #endif - (void)removeExtendedAttributeForName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI { OFIRIHandler *IRIHandler; if (IRI == nil) @throw [OFInvalidArgumentException exception]; if ((IRIHandler = [OFIRIHandler handlerForIRI: IRI]) == nil) @throw [OFUnsupportedProtocolException exceptionWithIRI: IRI]; [IRIHandler removeExtendedAttributeForName: name ofItemAtIRI: IRI]; } #ifdef OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES - (void)removeExtendedAttributeForName: (OFString *)name ofItemAtPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); [self removeExtendedAttributeForName: name ofItemAtIRI: [OFIRI fileIRIWithPath: path isDirectory: false]]; objc_autoreleasePoolPop(pool); } #endif @end @implementation OFDefaultFileManager OF_SINGLETON_METHODS @end @implementation OFDictionary (FileAttributes) - (unsigned long long)fileSize { return [attributeForKeyOrException(self, OFFileSize) unsignedLongLongValue]; |
︙ | ︙ | |||
968 969 970 971 972 973 974 975 | return attributeForKeyOrException(self, OFFileCreationDate); } - (OFString *)fileSymbolicLinkDestination { return attributeForKeyOrException(self, OFFileSymbolicLinkDestination); } @end | > > > > > | 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 | return attributeForKeyOrException(self, OFFileCreationDate); } - (OFString *)fileSymbolicLinkDestination { return attributeForKeyOrException(self, OFFileSymbolicLinkDestination); } - (OFArray OF_GENERIC(OFString *) *)fileExtendedAttributesNames { return attributeForKeyOrException(self, OFFileExtendedAttributesNames); } @end |
Modified src/OFFileManagerConstants.inc from [7a3eb9bf4f] to [ffd35a3bd0].
1 | /* | | | | | | > > > > | < > | > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ const OFFileAttributeKey OFFileSize = @"OFFileSize"; const OFFileAttributeKey OFFileType = @"OFFileType"; const OFFileAttributeKey OFFilePOSIXPermissions = @"OFFilePOSIXPermissions"; const OFFileAttributeKey OFFileOwnerAccountID = @"OFFileOwnerAccountID"; const OFFileAttributeKey OFFileGroupOwnerAccountID = @"OFFileGroupOwnerAccountID"; const OFFileAttributeKey OFFileOwnerAccountName = @"OFFileOwnerAccountName"; const OFFileAttributeKey OFFileGroupOwnerAccountName = @"OFFileGroupOwnerAccountName"; const OFFileAttributeKey OFFileLastAccessDate = @"OFFileLastAccessDate"; const OFFileAttributeKey OFFileModificationDate = @"OFFileModificationDate"; const OFFileAttributeKey OFFileStatusChangeDate = @"OFFileStatusChangeDate"; const OFFileAttributeKey OFFileCreationDate = @"OFFileCreationDate"; const OFFileAttributeKey OFFileSymbolicLinkDestination = @"OFFileSymbolicLinkDestination"; const OFFileAttributeKey OFFileExtendedAttributesNames = @"OFFileExtendedAttributesNames"; const OFFileAttributeType OFFileTypeRegular = @"OFFileTypeRegular"; const OFFileAttributeType OFFileTypeDirectory = @"OFFileTypeDirectory"; const OFFileAttributeType OFFileTypeSymbolicLink = @"OFFileTypeSymbolicLink"; const OFFileAttributeType OFFileTypeFIFO = @"OFFileTypeFIFO"; const OFFileAttributeType OFFileTypeCharacterSpecial = @"OFFileTypeCharacterSpecial"; const OFFileAttributeType OFFileTypeBlockSpecial = @"OFFileTypeBlockSpecial"; const OFFileAttributeType OFFileTypeSocket = @"OFFileTypeSocket"; const OFFileAttributeType OFFileTypeUnknown = @"OFFileTypeUnknown"; |
Modified src/OFGZIPStream.h from [40a91bbae5] to [512b5dee6c].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFStream.h" #import "OFDate.h" @class OFInflateStream; |
︙ | ︙ |
Modified src/OFGZIPStream.m from [947da42ac6] to [ba433e4a1c].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFGZIPStream.h" #import "OFCRC32.h" #import "OFDate.h" |
︙ | ︙ | |||
77 78 79 80 81 82 83 | if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; for (;;) { uint8_t byte; uint32_t CRC32, uncompressedSize; | > > > > > > | | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; for (;;) { uint8_t byte; uint32_t CRC32, uncompressedSize; /* * The inflate stream might have overread, causing _stream to * be at the end, but the inflate stream will unread it once it * has reached the end. Hence only check it if the state is not * OFGZIPStreamStateData. */ if (_state != OFGZIPStreamStateData && _stream.atEndOfStream) { if (_state != OFGZIPStreamStateID1) @throw [OFTruncatedDataException exception]; return 0; } switch (_state) { |
︙ | ︙ | |||
246 247 248 249 250 251 252 | [_inflateStream release]; _inflateStream = nil; _state++; break; case OFGZIPStreamStateCRC32: | | > | | 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | [_inflateStream release]; _inflateStream = nil; _state++; break; case OFGZIPStreamStateCRC32: _bytesRead += [_stream readIntoBuffer: _buffer + _bytesRead length: 4 - _bytesRead]; if (_bytesRead < 4) return 0; CRC32 = ((uint32_t)_buffer[3] << 24) | (_buffer[2] << 16) | (_buffer[1] << 8) | _buffer[0]; if (~_CRC32 != CRC32) { |
︙ | ︙ | |||
270 271 272 273 274 275 276 | } _bytesRead = 0; _CRC32 = ~0; _state++; break; case OFGZIPStreamStateUncompressedSize: | | > | > > > | | 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | } _bytesRead = 0; _CRC32 = ~0; _state++; break; case OFGZIPStreamStateUncompressedSize: _bytesRead += [_stream readIntoBuffer: _buffer + _bytesRead length: 4 - _bytesRead]; if (_bytesRead < 4) return 0; uncompressedSize = (_buffer[3] << 24) | (_buffer[2] << 16) | (_buffer[1] << 8) | _buffer[0]; if (_uncompressedSize != uncompressedSize) { OFString *actual = [OFString stringWithFormat: @"%" PRIu32, _uncompressedSize]; OFString *expected = [OFString stringWithFormat: @"%" PRIu32, uncompressedSize]; |
︙ | ︙ | |||
299 300 301 302 303 304 305 306 307 308 | } - (bool)lowlevelIsAtEndOfStream { if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; return _stream.atEndOfStream; } | > > > > > > > > | < | | | | 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 | } - (bool)lowlevelIsAtEndOfStream { if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; /* * The inflate stream might have overread, causing _stream to be at the * end, but the inflate stream will unread it once it has reached the * end. */ if (_state == OFGZIPStreamStateData && !_inflateStream.atEndOfStream) return false; return _stream.atEndOfStream; } - (bool)lowlevelHasDataInReadBuffer { if (_state == OFGZIPStreamStateData) return _inflateStream.hasDataInReadBuffer; else return _stream.hasDataInReadBuffer; } - (void)close { if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; [_stream release]; _stream = nil; [super close]; } @end |
Added src/OFHINFODNSResourceRecord.h version [fdf97914d7].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFDNSResourceRecord.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFHINFODNSResourceRecord \ * OFDNSResourceRecord.h ObjFW/OFDNSResourceRecord.h * * @brief A class representing an HINFO DNS resource record. */ OF_SUBCLASSING_RESTRICTED @interface OFHINFODNSResourceRecord: OFDNSResourceRecord { OFString *_CPU, *_OS; } /** * @brief The CPU of the host info of the resource record. */ @property (readonly, nonatomic) OFString *CPU; /** * @brief The OS of the host info of the resource record. */ @property (readonly, nonatomic) OFString *OS; - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFHINFODNSResourceRecord with the * specified name, class, domain name and time to live. * * @param name The name for the resource record * @param DNSClass The class code for the resource record * @param CPU The CPU of the host info for the resource record * @param OS The OS of the host info for the resource record * @param TTL The time to live for the resource record * @return An initialized OFHINFODNSResourceRecord */ - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass CPU: (OFString *)CPU OS: (OFString *)OS TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END |
Added src/OFHINFODNSResourceRecord.m version [8639372838].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFHINFODNSResourceRecord.h" @implementation OFHINFODNSResourceRecord @synthesize CPU = _CPU, OS = _OS; - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass CPU: (OFString *)CPU OS: (OFString *)OS TTL: (uint32_t)TTL { self = [super initWithName: name DNSClass: DNSClass recordType: OFDNSRecordTypeHINFO TTL: TTL]; @try { _CPU = [CPU copy]; _OS = [OS copy]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_CPU release]; [_OS release]; [super dealloc]; } - (bool)isEqual: (id)object { OFHINFODNSResourceRecord *record; if (object == self) return true; if (![object isKindOfClass: [OFHINFODNSResourceRecord class]]) return false; record = object; if (record->_name != _name && ![record->_name isEqual: _name]) return false; if (record->_DNSClass != _DNSClass) return false; if (record->_recordType != _recordType) return false; if (record->_CPU != _CPU && ![record->_CPU isEqual: _CPU]) return false; if (record->_OS != _OS && ![record->_OS isEqual: _OS]) return false; return true; } - (unsigned long)hash { unsigned long hash; OFHashInit(&hash); OFHashAddHash(&hash, _name.hash); OFHashAddByte(&hash, _DNSClass >> 8); OFHashAddByte(&hash, _DNSClass); OFHashAddByte(&hash, _recordType >> 8); OFHashAddByte(&hash, _recordType); OFHashAddHash(&hash, _CPU.hash); OFHashAddHash(&hash, _OS.hash); OFHashFinalize(&hash); return hash; } - (OFString *)description { return [OFString stringWithFormat: @"<%@:\n" @"\tName = %@\n" @"\tClass = %@\n" @"\tCPU = %@\n" @"\tOS = %@\n" @"\tTTL = %" PRIu32 "\n" @">", self.className, _name, OFDNSClassName(_DNSClass), _CPU, _OS, _TTL]; } @end |
Modified src/OFHMAC.h from [2d8e8879fb] to [7ea4eadcc3].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFCryptographicHash.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ |
Modified src/OFHMAC.m from [2ceebc7fc2] to [8458a2cbdb].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFHMAC.h" #import "OFSecureData.h" |
︙ | ︙ |
Modified src/OFHTTPClient.h from [d5da950339] to [357ba5ad47].
1 | /* | | | | | | > > > > | < > | > < | > | > | > | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #ifndef OF_HAVE_SOCKETS # error No sockets available! #endif OF_ASSUME_NONNULL_BEGIN @class OFDictionary OF_GENERIC(KeyType, ObjectType); @class OFHTTPClient; @class OFHTTPRequest; @class OFHTTPResponse; @class OFIRI; @class OFStream; @class OFTCPSocket; @class OFTLSStream; /** * @protocol OFHTTPClientDelegate OFHTTPClient.h ObjFW/OFHTTPClient.h * * @brief A delegate for OFHTTPClient. */ @protocol OFHTTPClientDelegate <OFObject> /** * @brief A callback which is called when an @ref OFHTTPClient performed a * request. * * @param client The OFHTTPClient which performed the request * @param request The request the OFHTTPClient performed * @param response The response to the request performed, or nil on error * @param exception An exception if the request failed, or nil on success */ - (void)client: (OFHTTPClient *)client didPerformRequest: (OFHTTPRequest *)request response: (nullable OFHTTPResponse *)response exception: (nullable id)exception; @optional /** * @brief A callback which is called when an @ref OFHTTPClient creates a TCP * socket. * * This can be used to tell the socket about a SOCKS5 proxy it should use for * this connection. * * @param client The OFHTTPClient that created a TCP socket * @param TCPSocket The socket created by the OFHTTPClient * @param request The request for which the TCP socket was created */ - (void)client: (OFHTTPClient *)client didCreateTCPSocket: (OFTCPSocket *)TCPSocket request: (OFHTTPRequest *)request; /** * @brief A callback which is called when an @ref OFHTTPClient creates a TLS * stream. * * This can be used to tell the TLS stream about a client certificate it should * use before performing the TLS handshake. * * @param client The OFHTTPClient that created a TLS stream * @param TLSStream The TLS stream created by the OFHTTPClient * @param request The request for which the TLS stream was created */ - (void)client: (OFHTTPClient *)client didCreateTLSStream: (OFTLSStream *)TLSStream request: (OFHTTPRequest *)request; /** * @brief A callback which is called when an @ref OFHTTPClient wants to send * the body for a request. * * @param client The OFHTTPClient that wants to send the body * @param requestBody A stream into which the body of the request should be * written * @param request The request for which the OFHTTPClient wants to send the body */ - (void)client: (OFHTTPClient *)client wantsRequestBody: (OFStream *)requestBody request: (OFHTTPRequest *)request; /** * @brief A callback which is called when an @ref OFHTTPClient received headers. * * @param client The OFHTTPClient which received the headers * @param headers The headers received * @param statusCode The status code received * @param request The request for which the headers and status code have been * received */ - (void)client: (OFHTTPClient *)client didReceiveHeaders: (OFDictionary OF_GENERIC(OFString *, OFString *) *)headers statusCode: (short)statusCode request: (OFHTTPRequest *)request; /** * @brief A callback which is called when an @ref OFHTTPClient wants to follow * a redirect. * * If you want to get the headers and data for each redirect, set the number of * redirects to 0 and perform a new OFHTTPClient for each redirect. However, * this callback will not be called then and you have to look at the status code * to detect a redirect. * * This callback will only be called if the OFHTTPClient will follow a * redirect. If the maximum number of redirects has been reached already, this * callback will not be called. * * @param client The OFHTTPClient which wants to follow a redirect * @param IRI The IRI to which it will follow a redirect * @param statusCode The status code for the redirection * @param request The request for which the OFHTTPClient wants to redirect. * You are allowed to change the request's headers from this * callback and they will be used when following the redirect * (e.g. to set the cookies for the new IRI), however, keep in * mind that this will change the request you originally passed. * @param response The response indicating the redirect * @return A boolean whether the OFHTTPClient should follow the redirect */ - (bool)client: (OFHTTPClient *)client shouldFollowRedirectToIRI: (OFIRI *)IRI statusCode: (short)statusCode request: (OFHTTPRequest *)request response: (OFHTTPResponse *)response; @end /** * @class OFHTTPClient OFHTTPClient.h ObjFW/OFHTTPClient.h * * @brief A class for performing HTTP requests. */ OF_SUBCLASSING_RESTRICTED @interface OFHTTPClient: OFObject { #ifdef OF_HTTP_CLIENT_M @public #endif OFObject <OFHTTPClientDelegate> *_Nullable _delegate; bool _allowsInsecureRedirects, _inProgress; OFStream *_Nullable _stream; OFIRI *_Nullable _lastIRI; bool _lastWasHEAD; OFHTTPResponse *_Nullable _lastResponse; } /** * @brief The delegate of the HTTP request. */ |
︙ | ︙ | |||
182 183 184 185 186 187 188 | * * @param request The request to perform * @return The OFHTTPResponse for the request * @throw OFHTTPRequestFailedException The HTTP request failed * @throw OFInvalidServerResponseException The server sent an invalid response * @throw OFUnsupportedVersionException The server responded in an unsupported * version | | | | | | 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | * * @param request The request to perform * @return The OFHTTPResponse for the request * @throw OFHTTPRequestFailedException The HTTP request failed * @throw OFInvalidServerResponseException The server sent an invalid response * @throw OFUnsupportedVersionException The server responded in an unsupported * version * @throw OFAlreadyOpenException The client is already performing a request */ - (OFHTTPResponse *)performRequest: (OFHTTPRequest *)request; /** * @brief Synchronously performs the specified HTTP request. * * @note You must not change the delegate while a synchronous request is * running! If you want to change the delegate during the request, * perform an asynchronous request instead! * * @param request The request to perform * @param redirects The maximum number of redirects after which no further * attempt is done to follow the redirect, but instead the * redirect is treated as an OFHTTPResponse * @return The OFHTTPResponse for the request * @throw OFHTTPRequestFailedException The HTTP request failed * @throw OFInvalidServerResponseException The server sent an invalid response * @throw OFUnsupportedVersionException The server responded in an unsupported * version * @throw OFAlreadyOpenException The client is already performing a request */ - (OFHTTPResponse *)performRequest: (OFHTTPRequest *)request redirects: (unsigned int)redirects; /** * @brief Asynchronously performs the specified HTTP request. * * @param request The request to perform * @throw OFAlreadyOpenException The client is already performing a request */ - (void)asyncPerformRequest: (OFHTTPRequest *)request; /** * @brief Asynchronously performs the specified HTTP request. * * @param request The request to perform * @param redirects The maximum number of redirects after which no further * attempt is done to follow the redirect, but instead the * redirect is treated as an OFHTTPResponse * @throw OFAlreadyOpenException The client is already performing a request */ - (void)asyncPerformRequest: (OFHTTPRequest *)request redirects: (unsigned int)redirects; /** * @brief Closes connections that are still open due to keep-alive. */ - (void)close; @end OF_ASSUME_NONNULL_END |
Modified src/OFHTTPClient.m from [e887f99bf5] to [8f9fbbe9f5].
1 | /* | | | | | | > > > > | < > | > < | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #define OF_HTTP_CLIENT_M #include "config.h" #include <errno.h> #include <string.h> #import "OFHTTPClient.h" #import "OFData.h" #import "OFDictionary.h" #import "OFHTTPRequest.h" #import "OFHTTPResponse.h" #import "OFIRI.h" #import "OFKernelEventObserver.h" #import "OFNumber.h" #import "OFRunLoop.h" #import "OFString.h" #import "OFTCPSocket.h" #import "OFTLSStream.h" #import "OFAlreadyOpenException.h" #import "OFHTTPRequestFailedException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidEncodingException.h" #import "OFInvalidFormatException.h" #import "OFInvalidServerResponseException.h" #import "OFNotImplementedException.h" #import "OFNotOpenException.h" |
︙ | ︙ | |||
113 114 115 116 117 118 119 | @end static OFString * constructRequestString(OFHTTPRequest *request) { void *pool = objc_autoreleasePoolPush(); OFHTTPRequestMethod method = request.method; | | | | | | | | | | | | 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | @end static OFString * constructRequestString(OFHTTPRequest *request) { void *pool = objc_autoreleasePoolPush(); OFHTTPRequestMethod method = request.method; OFIRI *IRI = request.IRI.IRIByAddingPercentEncodingForUnicodeCharacters; OFString *path; OFString *user = IRI.user, *password = IRI.password; OFMutableString *requestString; OFMutableDictionary OF_GENERIC(OFString *, OFString *) *headers; bool hasContentLength, chunked; OFEnumerator OF_GENERIC(OFString *) *keyEnumerator, *objectEnumerator; OFString *key, *object; if (IRI.path.length > 0) path = IRI.percentEncodedPath; else path = @"/"; requestString = [OFMutableString stringWithFormat: @"%@ %@", OFHTTPRequestMethodString(method), path]; if (IRI.query != nil) { [requestString appendString: @"?"]; [requestString appendString: IRI.percentEncodedQuery]; } [requestString appendString: @" HTTP/"]; [requestString appendString: request.protocolVersionString]; [requestString appendString: @"\r\n"]; headers = [[request.headers mutableCopy] autorelease]; if (headers == nil) headers = [OFMutableDictionary dictionary]; if ([headers objectForKey: @"Host"] == nil) { OFNumber *port = IRI.port; if (port != nil) { OFString *host = [OFString stringWithFormat: @"%@:%@", IRI.percentEncodedHost, port]; [headers setObject: host forKey: @"Host"]; } else [headers setObject: IRI.percentEncodedHost forKey: @"Host"]; } if ((user.length > 0 || password.length > 0) && [headers objectForKey: @"Authorization"] == nil) { OFMutableData *authorizationData = [OFMutableData data]; OFString *authorization; |
︙ | ︙ | |||
174 175 176 177 178 179 180 | authorization = [OFString stringWithFormat: @"Basic %@", authorizationData.stringByBase64Encoding]; [headers setObject: authorization forKey: @"Authorization"]; } if ([headers objectForKey: @"User-Agent"] == nil) | | | | 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | authorization = [OFString stringWithFormat: @"Basic %@", authorizationData.stringByBase64Encoding]; [headers setObject: authorization forKey: @"Authorization"]; } if ([headers objectForKey: @"User-Agent"] == nil) [headers setObject: @"OFHTTPClient (ObjFW's HTTP client class " @"<https://objfw.nil.im/>)" forKey: @"User-Agent"]; if (request.protocolVersion.major == 1 && request.protocolVersion.minor == 0 && [headers objectForKey: @"Connection"] == nil) [headers setObject: @"keep-alive" forKey: @"Connection"]; |
︙ | ︙ | |||
295 296 297 298 299 300 301 | didPerformRequest: _request response: nil exception: exception]; } - (void)createResponseWithStreamOrThrow: (OFStream *)stream { | | | 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | didPerformRequest: _request response: nil exception: exception]; } - (void)createResponseWithStreamOrThrow: (OFStream *)stream { OFIRI *IRI = _request.IRI; OFHTTPClientResponse *response; OFString *connectionHeader; bool keepAlive; OFString *location; id exception; response = [[[OFHTTPClientResponse alloc] initWithStream: stream] |
︙ | ︙ | |||
326 327 328 329 330 331 332 | keepAlive = false; } if (keepAlive) { response.of_keepAlive = true; _client->_stream = [stream retain]; | | | | | | | | | | | | | < | < < < < < < < | | 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 | keepAlive = false; } if (keepAlive) { response.of_keepAlive = true; _client->_stream = [stream retain]; _client->_lastIRI = [IRI copy]; _client->_lastWasHEAD = (_request.method == OFHTTPRequestMethodHead); _client->_lastResponse = [response retain]; } if (_redirects > 0 && (_status == 301 || _status == 302 || _status == 303 || _status == 307) && (location = [_serverHeaders objectForKey: @"Location"]) != nil) { bool follow = true; OFIRI *newIRI; OFString *newIRIScheme; newIRI = [OFIRI IRIWithString: location relativeToIRI: IRI]; newIRIScheme = newIRI.scheme; if ([newIRIScheme caseInsensitiveCompare: @"http"] != OFOrderedSame && [newIRIScheme caseInsensitiveCompare: @"https"] != OFOrderedSame) follow = false; if (!_client->_allowsInsecureRedirects && [IRI.scheme caseInsensitiveCompare: @"https"] == OFOrderedSame && [newIRIScheme caseInsensitiveCompare: @"http"] == OFOrderedSame) follow = false; if (follow && [_client->_delegate respondsToSelector: @selector(client:shouldFollowRedirectToIRI:statusCode: request:response:)]) follow = [_client->_delegate client: _client shouldFollowRedirectToIRI: newIRI statusCode: _status request: _request response: response]; else if (follow) follow = defaultShouldFollow(_request.method, _status); if (follow) { OFDictionary OF_GENERIC(OFString *, OFString *) *headers = _request.headers; OFHTTPRequest *newRequest = [[_request copy] autorelease]; OFMutableDictionary *newHeaders = [[headers mutableCopy] autorelease]; if (![newIRI.host isEqual: IRI.host]) [newHeaders removeObjectForKey: @"Host"]; /* * 303 means the request should be converted to a GET * request before redirection. This also means stripping * the entity of the request. */ if (_status == 303) { for (OFString *key in headers) if ([key hasPrefix: @"Content-"] || [key hasPrefix: @"Transfer-"]) [newHeaders removeObjectForKey: key]; newRequest.method = OFHTTPRequestMethodGet; } newRequest.IRI = newIRI; newRequest.headers = newHeaders; _client->_inProgress = false; [_client asyncPerformRequest: newRequest redirects: _redirects - 1]; return; |
︙ | ︙ | |||
636 637 638 639 640 641 642 | exception: (id)exception { if (exception != nil) { [self raiseException: exception]; return; } | < < | | | > | 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 | exception: (id)exception { if (exception != nil) { [self raiseException: exception]; return; } if ([_client->_delegate respondsToSelector: @selector(client:didCreateTCPSocket:request:)]) [_client->_delegate client: _client didCreateTCPSocket: sock request: _request]; if ([_request.IRI.scheme caseInsensitiveCompare: @"https"] == OFOrderedSame) { OFTLSStream *stream; @try { stream = [OFTLSStream streamWithStream: sock]; } @catch (OFNotImplementedException *e) { [self raiseException: [OFUnsupportedProtocolException exceptionWithIRI: _request.IRI]]; return; } if ([_client->_delegate respondsToSelector: @selector(client:didCreateTLSStream:request:)]) [_client->_delegate client: _client didCreateTLSStream: stream request: _request]; stream.delegate = self; [stream asyncPerformClientHandshakeWithHost: _request.IRI .IRIByAddingPercentEncodingForUnicodeCharacters.host]; } else { sock.delegate = self; [self performSelector: @selector(handleStream:) withObject: sock afterDelay: 0]; } } |
︙ | ︙ | |||
688 689 690 691 692 693 694 | [self performSelector: @selector(handleStream:) withObject: stream afterDelay: 0]; } - (void)start { | | | | | | | | | > | | | | | | | 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 | [self performSelector: @selector(handleStream:) withObject: stream afterDelay: 0]; } - (void)start { OFIRI *IRI = _request.IRI; OFStream *stream; /* Can we reuse the last socket? */ if (_client->_stream != nil && !_client->_stream.atEndOfStream && [_client->_lastIRI.scheme isEqual: IRI.scheme] && [_client->_lastIRI.host isEqual: IRI.host] && (_client->_lastIRI.port == IRI.port || [_client->_lastIRI.port isEqual: IRI.port]) && (_client->_lastWasHEAD || _client->_lastResponse.atEndOfStream)) { /* * Set _stream to nil, so that in case of an error it won't be * reused. If everything is successful, we set _stream again * at the end. */ stream = [_client->_stream autorelease]; _client->_stream = nil; [_client->_lastIRI release]; _client->_lastIRI = nil; [_client->_lastResponse release]; _client->_lastResponse = nil; stream.delegate = self; [self performSelector: @selector(handleStream:) withObject: stream afterDelay: 0]; } else [self closeAndReconnect]; } - (void)closeAndReconnect { @try { OFIRI *IRI = _request.IRI.IRIByAddingPercentEncodingForUnicodeCharacters; OFTCPSocket *sock; uint16_t port; OFNumber *IRIPort; [_client close]; sock = [OFTCPSocket socket]; if ([IRI.scheme caseInsensitiveCompare: @"https"] == OFOrderedSame) port = 443; else port = 80; IRIPort = IRI.port; if (IRIPort != nil) port = IRIPort.unsignedShortValue; sock.delegate = self; [sock asyncConnectToHost: IRI.host port: port]; } @catch (id e) { [self raiseException: e]; } } @end @implementation OFHTTPClientRequestBodyStream |
︙ | ︙ | |||
922 923 924 925 926 927 928 929 930 931 | } - (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length { if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; if (_atEndOfStream) return 0; | > > > < < < | 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 | } - (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length { if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; if (!_hasContentLength && !_chunked) return [_stream readIntoBuffer: buffer length: length]; if (_atEndOfStream) return 0; if (_stream.atEndOfStream) @throw [OFTruncatedDataException exception]; /* Content-Length */ if (!_chunked) { size_t ret; |
︙ | ︙ | |||
1051 1052 1053 1054 1055 1056 1057 | return 0; } } - (bool)lowlevelIsAtEndOfStream { | < < < | | | 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 | return 0; } } - (bool)lowlevelIsAtEndOfStream { if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; if (!_hasContentLength && !_chunked) return _stream.atEndOfStream; return _atEndOfStream; } - (int)fileDescriptorForReading { if (_stream == nil) return -1; return ((OFStream <OFReadyForReadingObserving> *)_stream) .fileDescriptorForReading; } - (bool)lowlevelHasDataInReadBuffer { return _stream.hasDataInReadBuffer; } - (void)close { if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; |
︙ | ︙ | |||
1199 1200 1201 1202 1203 1204 1205 | [_delegate client: client didReceiveHeaders: headers statusCode: statusCode request: request]; } - (bool)client: (OFHTTPClient *)client | | | | | 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 | [_delegate client: client didReceiveHeaders: headers statusCode: statusCode request: request]; } - (bool)client: (OFHTTPClient *)client shouldFollowRedirectToIRI: (OFIRI *)IRI statusCode: (short)statusCode request: (OFHTTPRequest *)request response: (OFHTTPResponse *)response { if ([_delegate respondsToSelector: @selector( client:shouldFollowRedirectToIRI:statusCode:request:response:)]) return [_delegate client: client shouldFollowRedirectToIRI: IRI statusCode: statusCode request: request response: response]; else return defaultShouldFollow(request.method, statusCode); } @end |
︙ | ︙ | |||
1263 1264 1265 1266 1267 1268 1269 | [self asyncPerformRequest: request redirects: defaultRedirects]; } - (void)asyncPerformRequest: (OFHTTPRequest *)request redirects: (unsigned int)redirects { void *pool = objc_autoreleasePoolPush(); | | | | | | | | 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 | [self asyncPerformRequest: request redirects: defaultRedirects]; } - (void)asyncPerformRequest: (OFHTTPRequest *)request redirects: (unsigned int)redirects { void *pool = objc_autoreleasePoolPush(); OFIRI *IRI = request.IRI; OFString *scheme = IRI.scheme; if ([scheme caseInsensitiveCompare: @"http"] != OFOrderedSame && [scheme caseInsensitiveCompare: @"https"] != OFOrderedSame) @throw [OFUnsupportedProtocolException exceptionWithIRI: IRI]; if (_inProgress) @throw [OFAlreadyOpenException exceptionWithObject: self]; _inProgress = true; [[[[OFHTTPClientRequestHandler alloc] initWithClient: self request: request redirects: redirects] autorelease] start]; objc_autoreleasePoolPop(pool); } - (void)close { [_stream release]; _stream = nil; [_lastIRI release]; _lastIRI = nil; [_lastResponse release]; _lastResponse = nil; } @end |
Modified src/OFHTTPCookie.h from [ff53970b1e] to [965e91ed27].
1 | /* | | | | | | > > > > | < > | > < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFString.h" OF_ASSUME_NONNULL_BEGIN @class OFArray OF_GENERIC(ObjectType); @class OFDate; @class OFDictionary OF_GENERIC(KeyType, ObjectType); @class OFIRI; @class OFMutableArray OF_GENERIC(ObjectType); /** * @class OFHTTPCookie OFHTTPCookie.h ObjFW/OFHTTPCookie.h * * @brief A class for storing and manipulating HTTP cookies. */ OF_SUBCLASSING_RESTRICTED |
︙ | ︙ | |||
76 77 78 79 80 81 82 | /** * @brief An array of other attributes. */ @property (readonly, nonatomic) OFMutableArray OF_GENERIC(OFString *) *extensions; /** | | | | | 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | /** * @brief An array of other attributes. */ @property (readonly, nonatomic) OFMutableArray OF_GENERIC(OFString *) *extensions; /** * @brief Parses the specified response header fields for the specified IRI and * returns an array of cookies. * * @param headerFields The response header fields to parse * @param IRI The IRI for the response header fields to parse * @return An array of cookies * @throw OFInvalidFormatException The specified response header has an invalid * format */ + (OFArray OF_GENERIC(OFHTTPCookie *) *)cookiesWithResponseHeaderFields: (OFDictionary OF_GENERIC(OFString *, OFString *) *)headerFields forIRI: (OFIRI *)IRI; /** * @brief Returns the request header fields for the specified cookies. * * @param cookies The cookies to return the request header fields for * @return The request header fields for the specified cookies */ |
︙ | ︙ |
Modified src/OFHTTPCookie.m from [a7d6a07918] to [a90862c08c].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFHTTPCookie.h" #import "OFArray.h" #import "OFDate.h" #import "OFDictionary.h" #import "OFIRI.h" #import "OFInvalidFormatException.h" static void handleAttribute(OFHTTPCookie *cookie, OFString *name, OFString *value) { OFString *lowercaseName = name.lowercaseString; |
︙ | ︙ | |||
58 59 60 61 62 63 64 | @implementation OFHTTPCookie @synthesize name = _name, value = _value, domain = _domain, path = _path; @synthesize expires = _expires, secure = _secure, HTTPOnly = _HTTPOnly; @synthesize extensions = _extensions; + (OFArray OF_GENERIC(OFHTTPCookie *) *)cookiesWithResponseHeaderFields: (OFDictionary OF_GENERIC(OFString *, OFString *) *)headerFields | | | > | 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | @implementation OFHTTPCookie @synthesize name = _name, value = _value, domain = _domain, path = _path; @synthesize expires = _expires, secure = _secure, HTTPOnly = _HTTPOnly; @synthesize extensions = _extensions; + (OFArray OF_GENERIC(OFHTTPCookie *) *)cookiesWithResponseHeaderFields: (OFDictionary OF_GENERIC(OFString *, OFString *) *)headerFields forIRI: (OFIRI *)IRI { OFMutableArray OF_GENERIC(OFHTTPCookie *) *ret = [OFMutableArray array]; void *pool = objc_autoreleasePoolPush(); OFString *string = [headerFields objectForKey: @"Set-Cookie"]; OFString *domain = IRI.IRIByAddingPercentEncodingForUnicodeCharacters .host; const OFUnichar *characters = string.characters; size_t length = string.length, last = 0; enum { statePreName, stateName, stateExpectValue, stateValue, |
︙ | ︙ |
Modified src/OFHTTPCookieManager.h from [3cc0432376] to [49b76b3176].
1 | /* | | | | | | > > > > | < > | > < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" OF_ASSUME_NONNULL_BEGIN @class OFArray OF_GENERIC(ObjectType); @class OFHTTPCookie; @class OFIRI; @class OFMutableArray OF_GENERIC(ObjectType); /** * @class OFHTTPCookieManager OFHTTPCookieManager.h ObjFW/OFHTTPCookieManager.h * * @brief A class for managing cookies for multiple domains. */ OF_SUBCLASSING_RESTRICTED |
︙ | ︙ | |||
42 43 44 45 46 47 48 | * @brief Create a new cookie manager. * * @return A new, autoreleased OFHTTPCookieManager */ + (instancetype)manager; /** | | | | | | | | | | | | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | * @brief Create a new cookie manager. * * @return A new, autoreleased OFHTTPCookieManager */ + (instancetype)manager; /** * @brief Adds the specified cookie for the specified IRI. * * @warning This modifies the cookie (e.g. it sets the domain if it is unset)! * If you do not want this, pass a copy! * * @param cookie The cookie to add to the manager * @param IRI The IRI for which the cookie should be added */ - (void)addCookie: (OFHTTPCookie *)cookie forIRI: (OFIRI *)IRI; /** * @brief Adds the specified cookies for the specified IRI. * * @warning This modifies the cookies (e.g. it sets the domain if it is unset)! * If you do not want this, pass copies! * * @param cookies An array of cookies to add to the manager * @param IRI The IRI for which the cookies should be added */ - (void)addCookies: (OFArray OF_GENERIC(OFHTTPCookie *) *)cookies forIRI: (OFIRI *)IRI; /** * @brief Returns the cookies for the specified IRI. * * @param IRI The IRI for which the cookies should be returned * @return The cookies for the specified IRI */ - (OFArray OF_GENERIC(OFHTTPCookie *) *)cookiesForIRI: (OFIRI *)IRI; /** * @brief Purges all expired cookies. */ - (void)purgeExpiredCookies; @end OF_ASSUME_NONNULL_END |
Modified src/OFHTTPCookieManager.m from [1dd74fe07e] to [86b990dd47].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFHTTPCookieManager.h" #import "OFArray.h" #import "OFDate.h" #import "OFHTTPCookie.h" #import "OFIRI.h" @implementation OFHTTPCookieManager + (instancetype)manager { return [[[self alloc] init] autorelease]; } |
︙ | ︙ | |||
49 50 51 52 53 54 55 | } - (OFArray OF_GENERIC(OFHTTPCookie *) *)cookies { return [[_cookies copy] autorelease]; } | | | > > | | | | | | 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | } - (OFArray OF_GENERIC(OFHTTPCookie *) *)cookies { return [[_cookies copy] autorelease]; } - (void)addCookie: (OFHTTPCookie *)cookie forIRI: (OFIRI *)IRI { void *pool = objc_autoreleasePoolPush(); OFString *cookieDomain, *IRIHost; size_t i; IRI = IRI.IRIByAddingPercentEncodingForUnicodeCharacters; if (![cookie.path hasPrefix: @"/"]) cookie.path = @"/"; if (cookie.secure && [IRI.scheme caseInsensitiveCompare: @"https"] != OFOrderedSame) { objc_autoreleasePoolPop(pool); return; } cookieDomain = cookie.domain.lowercaseString; cookie.domain = cookieDomain; IRIHost = IRI.host.lowercaseString; if (![cookieDomain isEqual: IRIHost]) { IRIHost = [@"." stringByAppendingString: IRIHost]; if (![cookieDomain hasSuffix: IRIHost]) { objc_autoreleasePoolPop(pool); return; } } i = 0; for (OFHTTPCookie *iter in _cookies) { |
︙ | ︙ | |||
96 97 98 99 100 101 102 | [_cookies addObject: cookie]; objc_autoreleasePoolPop(pool); } - (void)addCookies: (OFArray OF_GENERIC(OFHTTPCookie *) *)cookies | | | | > > > | | | | | | | | | | | | | > > | 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | [_cookies addObject: cookie]; objc_autoreleasePoolPop(pool); } - (void)addCookies: (OFArray OF_GENERIC(OFHTTPCookie *) *)cookies forIRI: (OFIRI *)IRI { for (OFHTTPCookie *cookie in cookies) [self addCookie: cookie forIRI: IRI]; } - (OFArray OF_GENERIC(OFHTTPCookie *) *)cookiesForIRI: (OFIRI *)IRI { OFMutableArray *ret = [OFMutableArray array]; void *pool = objc_autoreleasePoolPush(); IRI = IRI.IRIByAddingPercentEncodingForUnicodeCharacters; for (OFHTTPCookie *cookie in _cookies) { void *pool2; OFDate *expires; OFString *cookieDomain, *IRIHost, *cookiePath, *IRIPath; bool match; expires = cookie.expires; if (expires != nil && expires.timeIntervalSinceNow <= 0) continue; if (cookie.secure && [IRI.scheme caseInsensitiveCompare: @"https"] != OFOrderedSame) continue; pool2 = objc_autoreleasePoolPush(); cookieDomain = cookie.domain.lowercaseString; IRIHost = IRI.host.lowercaseString; if ([cookieDomain hasPrefix: @"."]) { if ([IRIHost hasSuffix: cookieDomain]) match = true; else { cookieDomain = [cookieDomain substringFromIndex: 1]; match = [cookieDomain isEqual: IRIHost]; } } else match = [cookieDomain isEqual: IRIHost]; if (!match) { objc_autoreleasePoolPop(pool2); continue; } cookiePath = cookie.path; IRIPath = IRI.path; if (![cookiePath isEqual: @"/"]) { if ([cookiePath isEqual: IRIPath]) match = true; else { if (![cookiePath hasSuffix: @"/"]) cookiePath = [cookiePath stringByAppendingString: @"/"]; match = [IRIPath hasPrefix: cookiePath]; } if (!match) { objc_autoreleasePoolPop(pool2); continue; } } [ret addObject: cookie]; } [ret makeImmutable]; objc_autoreleasePoolPop(pool); return ret; } - (void)purgeExpiredCookies { for (size_t i = 0, count = _cookies.count; i < count; i++) { |
︙ | ︙ |
Renamed and modified src/OFHTTPURIHandler.h [1fbd933246] to src/OFHTTPIRIHandler.h [111aaca712].
1 | /* | | | | | | > > > > | < > | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFIRIHandler.h" OF_ASSUME_NONNULL_BEGIN @interface OFHTTPIRIHandler: OFIRIHandler @end OF_ASSUME_NONNULL_END |
Renamed and modified src/OFHTTPURIHandler.m [9e6fa9d3fe] to src/OFHTTPIRIHandler.m [f48defafc4].
1 | /* | | | | | | > > > > | < > | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFHTTPIRIHandler.h" #import "OFHTTPClient.h" #import "OFHTTPRequest.h" #import "OFHTTPResponse.h" @implementation OFHTTPIRIHandler - (OFStream *)openItemAtIRI: (OFIRI *)IRI mode: (OFString *)mode { void *pool = objc_autoreleasePoolPush(); OFHTTPClient *client = [OFHTTPClient client]; OFHTTPRequest *request = [OFHTTPRequest requestWithIRI: IRI]; OFHTTPResponse *response = [client performRequest: request]; [response retain]; objc_autoreleasePoolPop(pool); return [response autorelease]; |
︙ | ︙ |
Modified src/OFHTTPRequest.h from [1278addd47] to [bd6129a6fd].
1 | /* | | | | | | > > > > | < > | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFSocket.h" #import "OFString.h" OF_ASSUME_NONNULL_BEGIN @class OFData; @class OFDictionary OF_GENERIC(KeyType, ObjectType); @class OFIRI; @class OFString; /** @file */ /** * @brief The type of an HTTP request. */ |
︙ | ︙ | |||
49 50 51 52 53 54 55 | } OFHTTPRequestMethod; /** * @struct OFHTTPRequestProtocolVersion OFHTTPRequest.h ObjFW/OFHTTPRequest.h * * @brief The HTTP version of the HTTP request. */ | | | | | | 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | } OFHTTPRequestMethod; /** * @struct OFHTTPRequestProtocolVersion OFHTTPRequest.h ObjFW/OFHTTPRequest.h * * @brief The HTTP version of the HTTP request. */ typedef struct OF_BOXABLE OFHTTPRequestProtocolVersion { /** The major of the HTTP version */ unsigned char major; /** The minor of the HTTP version */ unsigned char minor; } OFHTTPRequestProtocolVersion; /** * @class OFHTTPRequest OFHTTPRequest.h ObjFW/OFHTTPRequest.h * * @brief A class for storing HTTP requests. */ OF_SUBCLASSING_RESTRICTED @interface OFHTTPRequest: OFObject <OFCopying> { OFIRI *_IRI; OFHTTPRequestMethod _method; OFHTTPRequestProtocolVersion _protocolVersion; OFDictionary OF_GENERIC(OFString *, OFString *) *_Nullable _headers; OFSocketAddress _remoteAddress; bool _hasRemoteAddress; } /** * @brief The IRI of the HTTP request. */ @property (copy, nonatomic) OFIRI *IRI; /** * @brief The protocol version of the HTTP request. * * @throw OFUnsupportedVersionException The specified version cannot be set * because it is not supported */ |
︙ | ︙ | |||
114 115 116 117 118 119 120 | * @brief The remote address from which the request originates. * * @note The setter creates a copy of the remote address. */ @property OF_NULLABLE_PROPERTY (nonatomic) const OFSocketAddress *remoteAddress; /** | | | | | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > | > | 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | * @brief The remote address from which the request originates. * * @note The setter creates a copy of the remote address. */ @property OF_NULLABLE_PROPERTY (nonatomic) const OFSocketAddress *remoteAddress; /** * @brief Creates a new OFHTTPRequest with the specified IRI. * * @param IRI The IRI for the request * @return A new, autoreleased OFHTTPRequest */ + (instancetype)requestWithIRI: (OFIRI *)IRI; /** * @brief Initializes an already allocated OFHTTPRequest with the specified IRI. * * @param IRI The IRI for the request * @return An initialized OFHTTPRequest */ - (instancetype)initWithIRI: (OFIRI *)IRI; - (instancetype)init OF_UNAVAILABLE; @end #ifdef __cplusplus extern "C" { #endif /** * @brief Returns a string describing the specified request method. * * @param method The request method which should be described as a string * @return A string describing the specified request method */ extern OFString *_Nullable OFHTTPRequestMethodString( OFHTTPRequestMethod method); /** * @brief Returns the request method for the specified string. * * @param string The string for which the request method should be returned * @return The request method for the specified string * @throw OFInvalidFormatException The specified string is not a valid HTTP * request method */ extern OFHTTPRequestMethod OFHTTPRequestMethodParseString(OFString *string); /** * @brief Returns a C string describing the specified request method. * * @deprecated Use @ref OFHTTPRequestMethodString instead. * * @param method The request method which should be described as a C string * @return A C string describing the specified request method */ extern const char *_Nullable OFHTTPRequestMethodName(OFHTTPRequestMethod method) OF_DEPRECATED(ObjFW, 1, 1, "Use OFHTTPRequestMethodString instead"); /** * @brief Returns the request method for the specified string. * * @deprecated Use @ref OFHTTPRequestMethodParseString instead. * * @param string The string for which the request method should be returned * @return The request method for the specified string * @throw OFInvalidFormatException The specified string is not a valid HTTP * request method */ extern OFHTTPRequestMethod OFHTTPRequestMethodParseName(OFString *string) OF_DEPRECATED(ObjFW, 1, 1, "Use OFHTTPRequestMethodParseString instead"); #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END |
Modified src/OFHTTPRequest.m from [c85955ea02] to [bea32a7b3c].
1 | /* | | | | | | > > > > | < > | | | | | | | | | | | | | | | | | > > > > > > > > > > > > > > | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "OFHTTPRequest.h" #import "OFArray.h" #import "OFData.h" #import "OFDictionary.h" #import "OFIRI.h" #import "OFString.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFOutOfRangeException.h" #import "OFUnsupportedVersionException.h" OFString * OFHTTPRequestMethodString(OFHTTPRequestMethod method) { switch (method) { case OFHTTPRequestMethodOptions: return @"OPTIONS"; case OFHTTPRequestMethodGet: return @"GET"; case OFHTTPRequestMethodHead: return @"HEAD"; case OFHTTPRequestMethodPost: return @"POST"; case OFHTTPRequestMethodPut: return @"PUT"; case OFHTTPRequestMethodDelete: return @"DELETE"; case OFHTTPRequestMethodTrace: return @"TRACE"; case OFHTTPRequestMethodConnect: return @"CONNECT"; } return nil; } OFHTTPRequestMethod OFHTTPRequestMethodParseString(OFString *string) { if ([string isEqual: @"OPTIONS"]) return OFHTTPRequestMethodOptions; if ([string isEqual: @"GET"]) return OFHTTPRequestMethodGet; if ([string isEqual: @"HEAD"]) return OFHTTPRequestMethodHead; if ([string isEqual: @"POST"]) return OFHTTPRequestMethodPost; if ([string isEqual: @"PUT"]) return OFHTTPRequestMethodPut; if ([string isEqual: @"DELETE"]) return OFHTTPRequestMethodDelete; if ([string isEqual: @"TRACE"]) return OFHTTPRequestMethodTrace; if ([string isEqual: @"CONNECT"]) return OFHTTPRequestMethodConnect; @throw [OFInvalidFormatException exception]; } /* Deprecated */ const char * OFHTTPRequestMethodName(OFHTTPRequestMethod method) { return OFHTTPRequestMethodString(method).UTF8String; } /* Deprecated */ OFHTTPRequestMethod OFHTTPRequestMethodParseName(OFString *string) { return OFHTTPRequestMethodParseString(string); } @implementation OFHTTPRequest @synthesize IRI = _IRI, method = _method, headers = _headers; + (instancetype)requestWithIRI: (OFIRI *)IRI { return [[[self alloc] initWithIRI: IRI] autorelease]; } - (instancetype)initWithIRI: (OFIRI *)IRI { self = [super init]; @try { _IRI = [IRI copy]; _method = OFHTTPRequestMethodGet; _protocolVersion.major = 1; _protocolVersion.minor = 1; } @catch (id e) { [self release]; @throw e; } return self; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (void)dealloc { [_IRI release]; [_headers release]; [super dealloc]; } - (void)setRemoteAddress: (const OFSocketAddress *)remoteAddress { |
︙ | ︙ | |||
129 130 131 132 133 134 135 | return &_remoteAddress; return NULL; } - (id)copy { | | | 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | return &_remoteAddress; return NULL; } - (id)copy { OFHTTPRequest *copy = [[OFHTTPRequest alloc] initWithIRI: _IRI]; @try { copy->_method = _method; copy->_protocolVersion = _protocolVersion; copy.headers = _headers; copy.remoteAddress = self.remoteAddress; } @catch (id e) { |
︙ | ︙ | |||
159 160 161 162 163 164 165 | return false; request = object; if (request->_method != _method || request->_protocolVersion.major != _protocolVersion.major || request->_protocolVersion.minor != _protocolVersion.minor || | | | | 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | return false; request = object; if (request->_method != _method || request->_protocolVersion.major != _protocolVersion.major || request->_protocolVersion.minor != _protocolVersion.minor || ![request->_IRI isEqual: _IRI] || ![request->_headers isEqual: _headers]) return false; if (request.remoteAddress != self.remoteAddress && !OFSocketAddressEqual(request.remoteAddress, self.remoteAddress)) return false; return true; } - (unsigned long)hash { unsigned long hash; OFHashInit(&hash); OFHashAddByte(&hash, _method); OFHashAddByte(&hash, _protocolVersion.major); OFHashAddByte(&hash, _protocolVersion.minor); OFHashAddHash(&hash, _IRI.hash); OFHashAddHash(&hash, _headers.hash); if (_hasRemoteAddress) OFHashAddHash(&hash, OFSocketAddressHash(&_remoteAddress)); OFHashFinalize(&hash); return hash; |
︙ | ︙ | |||
239 240 241 242 243 244 245 | _protocolVersion.major, _protocolVersion.minor]; } - (OFString *)description { void *pool = objc_autoreleasePoolPush(); | | | | | | 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | _protocolVersion.major, _protocolVersion.minor]; } - (OFString *)description { void *pool = objc_autoreleasePoolPush(); OFString *method = OFHTTPRequestMethodString(_method); OFString *indentedHeaders, *remoteAddress, *ret; indentedHeaders = [_headers.description stringByReplacingOccurrencesOfString: @"\n" withString: @"\n\t"]; if (_hasRemoteAddress) remoteAddress = OFSocketAddressString(&_remoteAddress); else remoteAddress = nil; ret = [[OFString alloc] initWithFormat: @"<%@:\n\tIRI = %@\n" @"\tMethod = %@\n" @"\tHeaders = %@\n" @"\tRemote address = %@\n" @">", self.class, _IRI, method, indentedHeaders, remoteAddress]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } @end |
Modified src/OFHTTPResponse.h from [3c482db81b] to [9120aa464f].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFStream.h" #import "OFHTTPRequest.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ | |||
70 71 72 73 74 75 76 | * falling back to the specified encoding if not detectable. * * @return The response as a string */ - (OFString *)readString; /** | | | 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | * falling back to the specified encoding if not detectable. * * @return The response as a string */ - (OFString *)readString; /** * @brief Read the response as a string, trying to detect the encoding and * falling back to the specified encoding if not detectable. * * @return The response as a string */ - (OFString *)readStringWithEncoding: (OFStringEncoding)encoding; @end |
︙ | ︙ |
Modified src/OFHTTPResponse.m from [17a72a5d36] to [a75f9df823].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFHTTPResponse.h" #import "OFString.h" #import "OFDictionary.h" |
︙ | ︙ | |||
210 211 212 213 214 215 216 | length: length - last]; value = value.stringByDeletingTrailingWhitespaces; if ([name isEqual: @"charset"]) charset = value; } | > > | | | < > | 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | length: length - last]; value = value.stringByDeletingTrailingWhitespaces; if ([name isEqual: @"charset"]) charset = value; } ret = OFStringEncodingAutodetect; if (charset != nil) { @try { ret = OFStringEncodingParseName(charset); } @catch (OFInvalidArgumentException *e) { } } return ret; } @implementation OFHTTPResponse @synthesize statusCode = _statusCode, headers = _headers; |
︙ | ︙ |
Modified src/OFHTTPServer.h from [ba5fc5aae1] to [0b2a7cae11].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #ifndef OF_HAVE_SOCKETS # error No sockets available! #endif |
︙ | ︙ | |||
54 55 56 57 58 59 60 | * encountered an exception. * * @param server The HTTP server which encountered an exception * @param exception The exception which occurred on the HTTP server's listening * socket * @return Whether to continue listening. If you return false, existing * connections will still be handled and you can start accepting new | | | 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | * encountered an exception. * * @param server The HTTP server which encountered an exception * @param exception The exception which occurred on the HTTP server's listening * socket * @return Whether to continue listening. If you return false, existing * connections will still be handled and you can start accepting new * connections again by calling @ref OFHTTPServer#start again. */ - (bool)server: (OFHTTPServer *)server didReceiveExceptionOnListeningSocket: (id)exception; /** * @brief This method is called when a socket for a client encountered an * exception. |
︙ | ︙ | |||
102 103 104 105 106 107 108 | OFArray *_threadPool; #endif } /** * @brief The host on which the HTTP server will listen. * | | | | | | | | 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | OFArray *_threadPool; #endif } /** * @brief The host on which the HTTP server will listen. * * @throw OFAlreadyOpenException The host could not be set because @ref start * had already been called */ @property OF_NULLABLE_PROPERTY (copy, nonatomic) OFString *host; /** * @brief The port on which the HTTP server will listen. * * @throw OFAlreadyOpenException The port could not be set because @ref start * had already been called */ @property (nonatomic) uint16_t port; /** * @brief The delegate for the HTTP server. */ @property OF_NULLABLE_PROPERTY (assign, nonatomic) id <OFHTTPServerDelegate> delegate; #ifdef OF_HAVE_THREADS /** * @brief The number of threads the OFHTTPServer should use. * * If this is larger than 1 (the default), one thread will be used to accept * incoming connections and all others will be used to handle connections. * * For maximum CPU utilization, set this to `[OFSystemInfo numberOfCPUs] + 1`. * * @throw OFAlreadyOpenException The number of threads could not be set because * @ref start had already been called */ @property (nonatomic) size_t numberOfThreads; #endif /** * @brief The server name the server presents to clients. * |
︙ | ︙ | |||
154 155 156 157 158 159 160 | * @return A new HTTP server */ + (instancetype)server; /** * @brief Starts the HTTP server in the current thread's run loop. * | | | 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | * @return A new HTTP server */ + (instancetype)server; /** * @brief Starts the HTTP server in the current thread's run loop. * * @throw OFAlreadyOpenException The server had already been started */ - (void)start; /** * @brief Stops the HTTP server, meaning it will not accept any new incoming * connections, but still handle existing connections until they are * finished or timed out. */ - (void)stop; @end OF_ASSUME_NONNULL_END |
Modified src/OFHTTPServer.m from [e75cf57b42] to [61bb060e07].
1 | /* | | | | | | > > > > | < > | > < | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #define OF_HTTP_SERVER_M #include "config.h" #include <errno.h> #include <stdlib.h> #include <string.h> #import "OFHTTPServer.h" #import "OFArray.h" #import "OFData.h" #import "OFDate.h" #import "OFDictionary.h" #import "OFHTTPRequest.h" #import "OFHTTPResponse.h" #import "OFIRI.h" #import "OFNumber.h" #import "OFSocket+Private.h" #import "OFTCPSocket.h" #import "OFThread.h" #import "OFTimer.h" #import "OFAlreadyOpenException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidEncodingException.h" #import "OFInvalidFormatException.h" #import "OFNotOpenException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "OFTruncatedDataException.h" |
︙ | ︙ | |||
378 379 380 381 382 383 384 | pos = [line rangeOfString: @" "].location; if (pos == OFNotFound) return [self sendErrorAndClose: 400]; method = [line substringToIndex: pos]; @try { | | | 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 | pos = [line rangeOfString: @" "].location; if (pos == OFNotFound) return [self sendErrorAndClose: 400]; method = [line substringToIndex: pos]; @try { _method = OFHTTPRequestMethodParseString(method); } @catch (OFInvalidArgumentException *e) { return [self sendErrorAndClose: 405]; } @try { OFRange range = OFMakeRange(pos + 1, line.length - pos - 10); |
︙ | ︙ | |||
510 511 512 513 514 515 516 | date, _server.name]; return false; } - (void)createResponse { void *pool = objc_autoreleasePoolPush(); | | | | | | | | | | | 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 | date, _server.name]; return false; } - (void)createResponse { void *pool = objc_autoreleasePoolPush(); OFMutableIRI *IRI; OFHTTPRequest *request; OFHTTPServerResponse *response; size_t pos; [_timer invalidate]; [_timer release]; _timer = nil; if (_host == nil || _port == 0) { if (_HTTPMinorVersion > 0) { [self sendErrorAndClose: 400]; return; } [_host release]; _host = [_server.host copy]; _port = [_server port]; } IRI = [OFMutableIRI IRIWithScheme: @"http"]; IRI.host = _host; if (_port != 80) IRI.port = [OFNumber numberWithUnsignedShort: _port]; @try { if ((pos = [_path rangeOfString: @"?"].location) != OFNotFound) { OFString *path, *query; path = [_path substringToIndex: pos]; query = [_path substringFromIndex: pos + 1]; IRI.percentEncodedPath = path; IRI.percentEncodedQuery = query; } else IRI.percentEncodedPath = _path; } @catch (OFInvalidFormatException *e) { objc_autoreleasePoolPop(pool); [self sendErrorAndClose: 400]; return; } [IRI makeImmutable]; request = [OFHTTPRequest requestWithIRI: IRI]; request.method = _method; request.protocolVersion = (OFHTTPRequestProtocolVersion){ 1, _HTTPMinorVersion }; request.headers = _headers; request.remoteAddress = _socket.remoteAddress; response = [[[OFHTTPServerResponse alloc] |
︙ | ︙ | |||
731 732 733 734 735 736 737 | objc_autoreleasePoolPop(pool); return 0; } } | | | | 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 | objc_autoreleasePoolPop(pool); return 0; } } - (bool)lowlevelHasDataInReadBuffer { return _socket.hasDataInReadBuffer; } - (int)fileDescriptorForReading { return _socket.fileDescriptorForReading; } |
︙ | ︙ | |||
800 801 802 803 804 805 806 | } - (void)setHost: (OFString *)host { OFString *old; if (_listeningSocket != nil) | | | | > | | > | 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 | } - (void)setHost: (OFString *)host { OFString *old; if (_listeningSocket != nil) @throw [OFAlreadyOpenException exceptionWithObject: self]; old = _host; _host = [host copy]; [old release]; } - (OFString *)host { return _host; } - (void)setPort: (uint16_t)port { if (_listeningSocket != nil) @throw [OFAlreadyOpenException exceptionWithObject: self]; _port = port; } - (uint16_t)port { return _port; } #ifdef OF_HAVE_THREADS - (void)setNumberOfThreads: (size_t)numberOfThreads { if (numberOfThreads == 0) @throw [OFInvalidArgumentException exception]; if (_listeningSocket != nil) @throw [OFAlreadyOpenException exceptionWithObject: self]; _numberOfThreads = numberOfThreads; } - (size_t)numberOfThreads { return _numberOfThreads; } #endif - (void)start { void *pool = objc_autoreleasePoolPush(); OFSocketAddress address; if (_host == nil) @throw [OFInvalidArgumentException exception]; if (_listeningSocket != nil) @throw [OFAlreadyOpenException exceptionWithObject: self]; _listeningSocket = [[OFTCPSocket alloc] init]; address = [_listeningSocket bindToHost: _host port: _port]; _port = OFSocketAddressIPPort(&address); [_listeningSocket listen]; #ifdef OF_HAVE_THREADS if (_numberOfThreads > 1) { OFMutableArray *threads = [OFMutableArray arrayWithCapacity: _numberOfThreads - 1]; |
︙ | ︙ |
Modified src/OFHostAddressResolver.h from [5c6783fd03] to [db2458fcaf].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFDNSResolver.h" #import "OFRunLoop.h" #import "OFSocket.h" |
︙ | ︙ |
Modified src/OFHostAddressResolver.m from [3275d58c93] to [3978a3f46f].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFHostAddressResolver.h" #import "OFArray.h" #import "OFDNSResolver.h" |
︙ | ︙ | |||
149 150 151 152 153 154 155 | } - (void)sendQueries { OFString *domainName; if (!_isFQDN) { | | > > > | | 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | } - (void)sendQueries { OFString *domainName; if (!_isFQDN) { OFString *searchDomain = @""; if (_searchDomainIndex < _settings->_searchDomains.count) searchDomain = [_settings->_searchDomains objectAtIndex: _searchDomainIndex]; domainName = [OFString stringWithFormat: @"%@.%@", _host, searchDomain]; } else domainName = _host; #ifdef OF_HAVE_IPV6 |
︙ | ︙ | |||
284 285 286 287 288 289 290 | addresses, exception); objc_autoreleasePoolPop(pool); return; } @catch (OFInvalidFormatException *e) { } | | > | 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | addresses, exception); objc_autoreleasePoolPop(pool); return; } @catch (OFInvalidFormatException *e) { } if ((aliases = [_settings->_staticHosts objectForKey: _host.lowercaseString]) != nil) { OFMutableData *addresses = [OFMutableData dataWithItemSize: sizeof(OFSocketAddress)]; id exception = nil; for (OFString *alias in aliases) { OFSocketAddress address; |
︙ | ︙ |
Modified src/OFHuffmanTree.h from [0152a399af] to [3269a83550].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include <stdbool.h> #include <stdint.h> #import "macros.h" |
︙ | ︙ |
Modified src/OFHuffmanTree.m from [13f0a946b0] to [7caeda826b].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdint.h> #include <stdlib.h> |
︙ | ︙ |
Modified src/OFINICategory+Private.h from [6b757dc025] to [9fe10387de].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFINICategory.h" #import "OFString.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ |
Modified src/OFINICategory.h from [8e0c968abf] to [ce5c79e0c9].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" OF_ASSUME_NONNULL_BEGIN @class OFArray OF_GENERIC(ObjectType); |
︙ | ︙ | |||
40 41 42 43 44 45 46 | - (instancetype)init OF_UNAVAILABLE; /** * @brief Returns the string for the specified key, or `nil` if it does not * exist. * | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | - (instancetype)init OF_UNAVAILABLE; /** * @brief Returns the string for the specified key, or `nil` if it does not * exist. * * If the specified key is a multi-key (see @ref arrayValueForKey:), the value * of the first key/value pair found is returned. * * @param key The key for which the string should be returned * @return The string for the specified key, or `nil` if it does not exist */ - (nullable OFString *)stringValueForKey: (OFString *)key; /** * @brief Returns the string for the specified key or the specified default * value if it does not exist. * * If the specified key is a multi-key (see @ref arrayValueForKey:), the value * of the first key/value pair found is returned. * * @param key The key for which the string should be returned * @param defaultValue The value to return if the key does not exist * @return The string for the specified key or the specified default value if * it does not exist */ - (nullable OFString *)stringValueForKey: (OFString *)key defaultValue: (nullable OFString *)defaultValue; /** * @brief Returns the long long value for the specified key or the specified * default value if it does not exist. * * If the specified key is a multi-key (see @ref arrayValueForKey:), the value * of the first key/value pair found is returned. * * @param key The key for which the long long should be returned * @param defaultValue The value to return if the key does not exist * @return The long long for the specified key or the specified default value * if it does not exist * @throw OFInvalidFormatException The specified key is not in the correct * format for a long long */ - (long long)longLongValueForKey: (OFString *)key defaultValue: (long long)defaultValue; /** * @brief Returns the bool value for the specified key or the specified default * value if it does not exist. * * If the specified key is a multi-key (see @ref arrayValueForKey:), the value * of the first key/value pair found is returned. * * @param key The key for which the bool should be returned * @param defaultValue The value to return if the key does not exist * @return The bool for the specified key or the specified default value if it * does not exist * @throw OFInvalidFormatException The specified key is not in the correct * format for a bool */ - (bool)boolValueForKey: (OFString *)key defaultValue: (bool)defaultValue; /** * @brief Returns the float value for the specified key or the specified default * value if it does not exist. * * If the specified key is a multi-key (see @ref arrayValueForKey:), the value * of the first key/value pair found is returned. * * @param key The key for which the float should be returned * @param defaultValue The value to return if the key does not exist * @return The float for the specified key or the specified default value if it * does not exist * @throw OFInvalidFormatException The specified key is not in the correct * format for a float */ - (float)floatValueForKey: (OFString *)key defaultValue: (float)defaultValue; /** * @brief Returns the double value for the specified key or the specified * default value if it does not exist. * * If the specified key is a multi-key (see @ref arrayValueForKey:), the value * of the first key/value pair found is returned. * * @param key The key for which the double should be returned * @param defaultValue The value to return if the key does not exist * @return The double for the specified key or the specified default value if * it does not exist * @throw OFInvalidFormatException The specified key is not in the correct * format for a double */ - (double)doubleValueForKey: (OFString *)key defaultValue: (double)defaultValue; /** * @brief Returns an array of strings for the specified multi-key, or an empty * array if the key does not exist. * * A multi-key is a key which exists several times in the same category. Each * occurrence of the key/value pair adds the respective value to the array. * * @param key The multi-key for which the array should be returned * @return The array for the specified key, or an empty array if it does not * exist */ - (OFArray OF_GENERIC(OFString *) *)arrayValueForKey: (OFString *)key; /** * @brief Sets the value of the specified key to the specified string. * * If the specified key is a multi-key (see @ref arrayValueForKey:), the value * of the first key/value pair found is changed. * * @param stringValue The string to which the key should be set * @param key The key for which the new value should be set */ - (void)setStringValue: (OFString *)stringValue forKey: (OFString *)key; /** * @brief Sets the value of the specified key to the specified long long. * * If the specified key is a multi-key (see @ref arrayValueForKey:), the value * of the first key/value pair found is changed. * * @param longLongValue The long long to which the key should be set * @param key The key for which the new value should be set */ - (void)setLongLongValue: (long long)longLongValue forKey: (OFString *)key; /** * @brief Sets the value of the specified key to the specified bool. * * If the specified key is a multi-key (see @ref arrayValueForKey:), the value * of the first key/value pair found is changed. * * @param boolValue The bool to which the key should be set * @param key The key for which the new value should be set */ - (void)setBoolValue: (bool)boolValue forKey: (OFString *)key; /** * @brief Sets the value of the specified key to the specified float. * * If the specified key is a multi-key (see @ref arrayValueForKey:), the value * of the first key/value pair found is changed. * * @param floatValue The float to which the key should be set * @param key The key for which the new value should be set */ - (void)setFloatValue: (float)floatValue forKey: (OFString *)key; /** * @brief Sets the value of the specified key to the specified double. * * If the specified key is a multi-key (see @ref arrayValueForKey:), the value * of the first key/value pair found is changed. * * @param doubleValue The double to which the key should be set * @param key The key for which the new value should be set */ - (void)setDoubleValue: (double)doubleValue forKey: (OFString *)key; /** * @brief Sets the specified multi-key to the specified array of strings. * * It replaces the first occurrence of the multi-key with several key/value * pairs and removes all following occurrences. If the multi-key does not exist * yet, it is appended to the section. * * See also @ref arrayValueForKey: for more information about multi-keys. * * @param arrayValue The array of strings to which the multi-key should be set * @param key The multi-key for which the new values should be set */ - (void)setArrayValue: (OFArray OF_GENERIC(OFString *) *)arrayValue forKey: (OFString *)key; /** * @brief Removes the value for the specified key * * If the specified key is a multi-key (see @ref arrayValueForKey:), all * key/value pairs matching the specified key are removed. * * @param key The key of the value to remove */ - (void)removeValueForKey: (OFString *)key; @end OF_ASSUME_NONNULL_END |
Modified src/OFINICategory.m from [1db2d24df3] to [0e47b76592].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFINICategory.h" #import "OFINICategory+Private.h" #import "OFArray.h" |
︙ | ︙ | |||
174 175 176 177 178 179 180 | comment->_comment = [line copy]; [_lines addObject: comment]; } } | | | | | | | | | | | | | | | | 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | comment->_comment = [line copy]; [_lines addObject: comment]; } } - (OFString *)stringValueForKey: (OFString *)key { return [self stringValueForKey: key defaultValue: nil]; } - (OFString *)stringValueForKey: (OFString *)key defaultValue: (OFString *)defaultValue { for (id line in _lines) { OFINICategoryPair *pair; if (![line isKindOfClass: [OFINICategoryPair class]]) continue; pair = line; if ([pair->_key isEqual: key]) return [[pair->_value copy] autorelease]; } return defaultValue; } - (long long)longLongValueForKey: (OFString *)key defaultValue: (long long)defaultValue { void *pool = objc_autoreleasePoolPush(); OFString *value = [self stringValueForKey: key defaultValue: nil]; long long ret; if (value != nil) ret = [value longLongValueWithBase: 0]; else ret = defaultValue; objc_autoreleasePoolPop(pool); return ret; } - (bool)boolValueForKey: (OFString *)key defaultValue: (bool)defaultValue { void *pool = objc_autoreleasePoolPush(); OFString *value = [self stringValueForKey: key defaultValue: nil]; bool ret; if (value != nil) { if ([value isEqual: @"true"]) ret = true; else if ([value isEqual: @"false"]) ret = false; else @throw [OFInvalidFormatException exception]; } else ret = defaultValue; objc_autoreleasePoolPop(pool); return ret; } - (float)floatValueForKey: (OFString *)key defaultValue: (float)defaultValue { void *pool = objc_autoreleasePoolPush(); OFString *value = [self stringValueForKey: key defaultValue: nil]; float ret; if (value != nil) ret = value.floatValue; else ret = defaultValue; objc_autoreleasePoolPop(pool); return ret; } - (double)doubleValueForKey: (OFString *)key defaultValue: (double)defaultValue { void *pool = objc_autoreleasePoolPush(); OFString *value = [self stringValueForKey: key defaultValue: nil]; double ret; if (value != nil) ret = value.doubleValue; else ret = defaultValue; objc_autoreleasePoolPop(pool); return ret; } - (OFArray OF_GENERIC(OFString *) *)arrayValueForKey: (OFString *)key { OFMutableArray *ret = [OFMutableArray array]; void *pool = objc_autoreleasePoolPush(); for (id line in _lines) { OFINICategoryPair *pair; |
︙ | ︙ | |||
291 292 293 294 295 296 297 | objc_autoreleasePoolPop(pool); [ret makeImmutable]; return ret; } | | | 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | objc_autoreleasePoolPop(pool); [ret makeImmutable]; return ret; } - (void)setStringValue: (OFString *)string forKey: (OFString *)key { void *pool = objc_autoreleasePoolPush(); OFINICategoryPair *pair; for (id line in _lines) { if (![line isKindOfClass: [OFINICategoryPair class]]) continue; |
︙ | ︙ | |||
331 332 333 334 335 336 337 | @throw e; } objc_autoreleasePoolPop(pool); } | | | > | | | | | > > > > > > > > > > | < < < < < < < < < < | | | | | | 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 | @throw e; } objc_autoreleasePoolPop(pool); } - (void)setLongLongValue: (long long)longLongValue forKey: (OFString *)key { void *pool = objc_autoreleasePoolPush(); [self setStringValue: [OFString stringWithFormat: @"%lld", longLongValue] forKey: key]; objc_autoreleasePoolPop(pool); } - (void)setBoolValue: (bool)boolValue forKey: (OFString *)key { [self setStringValue: (boolValue ? @"true" : @"false") forKey: key]; } - (void)setFloatValue: (float)floatValue forKey: (OFString *)key { void *pool = objc_autoreleasePoolPush(); [self setStringValue: [OFString stringWithFormat: @"%g", floatValue] forKey: key]; objc_autoreleasePoolPop(pool); } - (void)setDoubleValue: (double)doubleValue forKey: (OFString *)key { void *pool = objc_autoreleasePoolPush(); [self setStringValue: [OFString stringWithFormat: @"%g", doubleValue] forKey: key]; objc_autoreleasePoolPop(pool); } - (void)setArrayValue: (OFArray OF_GENERIC(OFString *) *)arrayValue forKey: (OFString *)key { void *pool; OFMutableArray *pairs; id const *lines; size_t count; bool replaced; if (arrayValue.count == 0) { [self removeValueForKey: key]; return; } pool = objc_autoreleasePoolPush(); pairs = [OFMutableArray arrayWithCapacity: arrayValue.count]; for (OFString *string in arrayValue) { OFINICategoryPair *pair; if (![string isKindOfClass: [OFString class]]) @throw [OFInvalidArgumentException exception]; pair = [[[OFINICategoryPair alloc] init] autorelease]; pair->_key = [key copy]; |
︙ | ︙ | |||
418 419 420 421 422 423 424 | if (!replaced) { [_lines insertObjectsFromArray: pairs atIndex: i]; replaced = true; /* Continue after inserted pairs */ | | | 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 | if (!replaced) { [_lines insertObjectsFromArray: pairs atIndex: i]; replaced = true; /* Continue after inserted pairs */ i += arrayValue.count - 1; } else i--; /* Continue at same position */ lines = _lines.objects; count = _lines.count; continue; |
︙ | ︙ |
Modified src/OFINIFile.h from [f35fd21473] to [65e9f4aad7].
1 | /* | | | | | | > > > > | < > | > < | | | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFString.h" #import "OFINICategory.h" OF_ASSUME_NONNULL_BEGIN @class OFIRI; @class OFMutableArray OF_GENERIC(ObjectType); /** * @class OFINIFile OFINIFile.h ObjFW/OFINIFile.h * * @brief A class for reading, creating and modifying INI files. */ OF_SUBCLASSING_RESTRICTED @interface OFINIFile: OFObject { OFMutableArray OF_GENERIC(OFINICategory *) *_categories; } /** * @brief All categories in the INI file. */ @property (readonly, nonatomic) OFArray OF_GENERIC(OFINICategory *) *categories; /** * @brief Creates a new OFINIFile with the contents of the specified file. * * @param IRI The IRI to the file whose contents the OFINIFile should contain * * @return A new, autoreleased OFINIFile with the contents of the specified file * @throw OFInvalidFormatException The format of the specified INI file is * invalid * @throw OFInvalidEncodingException The INI file is not in the specified * encoding */ + (instancetype)fileWithIRI: (OFIRI *)IRI; /** * @brief Creates a new OFINIFile with the contents of the specified file in * the specified encoding. * * @param IRI The IRI to the file whose contents the OFINIFile should contain * @param encoding The encoding of the specified file * @return A new, autoreleased OFINIFile with the contents of the specified file * @throw OFInvalidFormatException The format of the specified INI file is * invalid * @throw OFInvalidEncodingException The INI file is not in the specified * encoding */ + (instancetype)fileWithIRI: (OFIRI *)IRI encoding: (OFStringEncoding)encoding; - (instancetype)init OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFINIFile with the contents of the * specified file. * * @param IRI The IRI to the file whose contents the OFINIFile should contain * * @return An initialized OFINIFile with the contents of the specified file * @throw OFInvalidFormatException The format of the specified INI file is * invalid * @throw OFInvalidEncodingException The INI file is not in the specified * encoding */ - (instancetype)initWithIRI: (OFIRI *)IRI; /** * @brief Initializes an already allocated OFINIFile with the contents of the * specified file in the specified encoding. * * @param IRI The IRI to the file whose contents the OFINIFile should contain * @param encoding The encoding of the specified file * @return An initialized OFINIFile with the contents of the specified file * @throw OFInvalidFormatException The format of the specified INI file is * invalid * @throw OFInvalidEncodingException The INI file is not in the specified * encoding */ - (instancetype)initWithIRI: (OFIRI *)IRI encoding: (OFStringEncoding)encoding OF_DESIGNATED_INITIALIZER; /** * @brief Returns an @ref OFINICategory for the category with the specified * name. * * @param name The name of the category for which an @ref OFINICategory should * be returned * * @return An @ref OFINICategory for the category with the specified name */ - (OFINICategory *)categoryForName: (OFString *)name; /** * @brief Writes the contents of the OFINIFile to a file. * * @param IRI The IRI of the file to write to */ - (void)writeToIRI: (OFIRI *)IRI; /** * @brief Writes the contents of the OFINIFile to a file in the specified * encoding. * * @param IRI The IRI of the file to write to * @param encoding The encoding to use */ - (void)writeToIRI: (OFIRI *)IRI encoding: (OFStringEncoding)encoding; @end OF_ASSUME_NONNULL_END |
Modified src/OFINIFile.m from [7850530cf1] to [8879da27e2].
1 | /* | | | | | | > > > > | < > | | | | | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #import "OFINIFile.h" #import "OFArray.h" #import "OFINICategory+Private.h" #import "OFINICategory.h" #import "OFIRI.h" #import "OFIRIHandler.h" #import "OFStream.h" #import "OFString.h" #import "OFInvalidFormatException.h" #import "OFOpenItemFailedException.h" OF_DIRECT_MEMBERS @interface OFINIFile () - (void)of_parseIRI: (OFIRI *)IRI encoding: (OFStringEncoding)encoding; @end static bool isWhitespaceLine(OFString *line) { const char *cString = line.UTF8String; size_t length = line.UTF8StringLength; for (size_t i = 0; i < length; i++) if (!OFASCIIIsSpace(cString[i])) return false; return true; } @implementation OFINIFile @synthesize categories = _categories; + (instancetype)fileWithIRI: (OFIRI *)IRI { return [[[self alloc] initWithIRI: IRI] autorelease]; } + (instancetype)fileWithIRI: (OFIRI *)IRI encoding: (OFStringEncoding)encoding { return [[[self alloc] initWithIRI: IRI encoding: encoding] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithIRI: (OFIRI *)IRI { return [self initWithIRI: IRI encoding: OFStringEncodingAutodetect]; } - (instancetype)initWithIRI: (OFIRI *)IRI encoding: (OFStringEncoding)encoding { self = [super init]; @try { _categories = [[OFMutableArray alloc] init]; [self of_parseIRI: IRI encoding: encoding]; } @catch (id e) { [self release]; @throw e; } return self; } |
︙ | ︙ | |||
106 107 108 109 110 111 112 | [_categories addObject: category]; objc_autoreleasePoolPop(pool); return category; } | | | | 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | [_categories addObject: category]; objc_autoreleasePoolPop(pool); return category; } - (void)of_parseIRI: (OFIRI *)IRI encoding: (OFStringEncoding)encoding { void *pool = objc_autoreleasePoolPush(); OFStream *file; OFINICategory *category = nil; OFString *line; if (encoding == OFStringEncodingAutodetect) encoding = OFStringEncodingUTF8; @try { file = [OFIRIHandler openItemAtIRI: IRI mode: @"r"]; } @catch (OFOpenItemFailedException *e) { /* Handle missing file like an empty file */ if (e.errNo == ENOENT) return; @throw e; } |
︙ | ︙ | |||
152 153 154 155 156 157 158 | [category of_parseLine: line]; } } objc_autoreleasePoolPop(pool); } | | | | | | 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | [category of_parseLine: line]; } } objc_autoreleasePoolPop(pool); } - (void)writeToIRI: (OFIRI *)IRI { [self writeToIRI: IRI encoding: OFStringEncodingUTF8]; } - (void)writeToIRI: (OFIRI *)IRI encoding: (OFStringEncoding)encoding { void *pool = objc_autoreleasePoolPush(); OFStream *file = [OFIRIHandler openItemAtIRI: IRI mode: @"w"]; bool first = true; for (OFINICategory *category in _categories) if ([category of_writeToStream: file encoding: encoding first: first]) first = false; |
︙ | ︙ |
Modified src/OFINIFileSettings.h from [125e92a3e8] to [5b367fe784].
1 | /* | | | | | | > > > > | < > | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFSettings.h" OF_ASSUME_NONNULL_BEGIN @class OFINIFile; @class OFIRI; @class OFString; @interface OFINIFileSettings: OFSettings { OFIRI *_fileIRI; OFINIFile *_INIFile; } @end OF_ASSUME_NONNULL_END |
Modified src/OFINIFileSettings.m from [b3d1a39e2b] to [8937f7c111].
1 | /* | | | | | | > > > > | < > | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFINIFileSettings.h" #import "OFArray.h" #import "OFINIFile.h" #import "OFIRI.h" #import "OFString.h" #import "OFSystemInfo.h" @implementation OFINIFileSettings - (instancetype)initWithApplicationName: (OFString *)applicationName { self = [super initWithApplicationName: applicationName]; @try { void *pool = objc_autoreleasePoolPush(); OFString *fileName; fileName = [applicationName stringByAppendingString: @".ini"]; _fileIRI = [[[OFSystemInfo userConfigIRI] IRIByAppendingPathComponent: fileName] copy]; _INIFile = [[OFINIFile alloc] initWithIRI: _fileIRI]; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_fileIRI release]; [_INIFile release]; [super dealloc]; } - (void)of_getCategory: (OFString **)category andKey: (OFString **)key |
︙ | ︙ | |||
72 73 74 75 76 77 78 | - (void)setString: (OFString *)string forPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; [self of_getCategory: &category andKey: &key forPath: path]; | | > | | | | > | > | | | > | | | | > | | > | | > | | | | 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | - (void)setString: (OFString *)string forPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; [self of_getCategory: &category andKey: &key forPath: path]; [[_INIFile categoryForName: category] setStringValue: string forKey: key]; objc_autoreleasePoolPop(pool); } - (void)setLongLong: (long long)longLong forPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; [self of_getCategory: &category andKey: &key forPath: path]; [[_INIFile categoryForName: category] setLongLongValue: longLong forKey: key]; objc_autoreleasePoolPop(pool); } - (void)setBool: (bool)bool_ forPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; [self of_getCategory: &category andKey: &key forPath: path]; [[_INIFile categoryForName: category] setBoolValue: bool_ forKey: key]; objc_autoreleasePoolPop(pool); } - (void)setFloat: (float)float_ forPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; [self of_getCategory: &category andKey: &key forPath: path]; [[_INIFile categoryForName: category] setFloatValue: float_ forKey: key]; objc_autoreleasePoolPop(pool); } - (void)setDouble: (double)double_ forPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; [self of_getCategory: &category andKey: &key forPath: path]; [[_INIFile categoryForName: category] setDoubleValue: double_ forKey: key]; objc_autoreleasePoolPop(pool); } - (void)setStringArray: (OFArray OF_GENERIC(OFString *) *)array forPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; [self of_getCategory: &category andKey: &key forPath: path]; [[_INIFile categoryForName: category] setArrayValue: array forKey: key]; objc_autoreleasePoolPop(pool); } - (OFString *)stringForPath: (OFString *)path defaultValue: (OFString *)defaultValue { void *pool = objc_autoreleasePoolPush(); OFString *category, *key, *ret; [self of_getCategory: &category andKey: &key forPath: path]; ret = [[_INIFile categoryForName: category] stringValueForKey: key defaultValue: defaultValue]; [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } - (long long)longLongForPath: (OFString *)path defaultValue: (long long)defaultValue { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; long long ret; [self of_getCategory: &category andKey: &key forPath: path]; ret = [[_INIFile categoryForName: category] longLongValueForKey: key defaultValue: defaultValue]; objc_autoreleasePoolPop(pool); return ret; } - (bool)boolForPath: (OFString *)path defaultValue: (bool)defaultValue { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; bool ret; [self of_getCategory: &category andKey: &key forPath: path]; ret = [[_INIFile categoryForName: category] boolValueForKey: key defaultValue: defaultValue]; objc_autoreleasePoolPop(pool); return ret; } - (float)floatForPath: (OFString *)path defaultValue: (float)defaultValue { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; float ret; [self of_getCategory: &category andKey: &key forPath: path]; ret = [[_INIFile categoryForName: category] floatValueForKey: key defaultValue: defaultValue]; objc_autoreleasePoolPop(pool); return ret; } - (double)doubleForPath: (OFString *)path defaultValue: (double)defaultValue { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; double ret; [self of_getCategory: &category andKey: &key forPath: path]; ret = [[_INIFile categoryForName: category] doubleValueForKey: key defaultValue: defaultValue]; objc_autoreleasePoolPop(pool); return ret; } - (OFArray OF_GENERIC(OFString *) *)stringArrayForPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; OFArray *ret; [self of_getCategory: &category andKey: &key forPath: path]; ret = [[_INIFile categoryForName: category] arrayValueForKey: key]; [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } - (void)removeValueForPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFString *category, *key; [self of_getCategory: &category andKey: &key forPath: path]; [[_INIFile categoryForName: category] removeValueForKey: key]; objc_autoreleasePoolPop(pool); } - (void)save { [_INIFile writeToIRI: _fileIRI]; } @end |
Modified src/OFIPXSocket.h from [8dc615311a] to [d0d2506e73].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFDatagramSocket.h" OF_ASSUME_NONNULL_BEGIN @class OFString; |
︙ | ︙ | |||
31 32 33 34 35 36 37 | * @class OFIPXSocket OFIPXSocket.h ObjFW/OFIPXSocket.h * * @brief A class which provides methods to create and use IPX sockets. * * Addresses are of type @ref OFSocketAddress. You can use * @ref OFSocketAddressMakeIPX to create an address or * @ref OFSocketAddressIPXNetwork to get the IPX network, | | | 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | * @class OFIPXSocket OFIPXSocket.h ObjFW/OFIPXSocket.h * * @brief A class which provides methods to create and use IPX sockets. * * Addresses are of type @ref OFSocketAddress. You can use * @ref OFSocketAddressMakeIPX to create an address or * @ref OFSocketAddressIPXNetwork to get the IPX network, * @ref OFSocketAddressGetIPXNode to get the IPX node and * @ref OFSocketAddressIPXPort to get the port (sometimes also called * socket number). * * @warning Even though the OFCopying protocol is implemented, it does *not* * return an independent copy of the socket, but instead retains it. * This is so that the socket can be used as a key for a dictionary, * so context can be associated with a socket. Using a socket in more |
︙ | ︙ | |||
71 72 73 74 75 76 77 | * @param node The IPX network to bind to. An all zero node means the * computer's node. * @param port The port (sometimes called socket number) to bind to. 0 means to * pick one and return via the returned socket address. * @param packetType The packet type to use on the socket * @return The address on which this socket can be reached * @throw OFBindIPXSocketFailedException Binding failed | | | 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | * @param node The IPX network to bind to. An all zero node means the * computer's node. * @param port The port (sometimes called socket number) to bind to. 0 means to * pick one and return via the returned socket address. * @param packetType The packet type to use on the socket * @return The address on which this socket can be reached * @throw OFBindIPXSocketFailedException Binding failed * @throw OFAlreadyOpenException The socket is already bound */ - (OFSocketAddress) bindToNetwork: (uint32_t)network node: (const unsigned char [_Nonnull IPX_NODE_LEN])node port: (uint16_t)port packetType: (uint8_t)packetType; @end OF_ASSUME_NONNULL_END |
Modified src/OFIPXSocket.m from [1dc137a6b3] to [71dcaf90af].
1 | /* | | | | | | > > > > | < > | | > > > > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #ifdef HAVE_FCNTL_H # include <fcntl.h> #endif #import "OFIPXSocket.h" #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFAlreadyOpenException.h" #import "OFBindIPXSocketFailedException.h" #ifndef NSPROTO_IPX # define NSPROTO_IPX 0 #endif @implementation OFIPXSocket @dynamic delegate; - (OFSocketAddress)bindToNetwork: (uint32_t)network node: (const unsigned char [IPX_NODE_LEN])node port: (uint16_t)port packetType: (uint8_t)packetType { OFSocketAddress address; int protocol = 0; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC) int flags; #endif if (_socket != OFInvalidSocketHandle) @throw [OFAlreadyOpenException exceptionWithObject: self]; address = OFSocketAddressMakeIPX(network, node, port); #if defined(OF_WINDOWS) || defined(OF_FREEBSD) protocol = NSPROTO_IPX + packetType; #else _packetType = address.sockaddr.ipx.sipx_type = packetType; #endif if ((_socket = socket(address.sockaddr.ipx.sipx_family, SOCK_DGRAM | SOCK_CLOEXEC, protocol)) == OFInvalidSocketHandle) |
︙ | ︙ | |||
118 119 120 121 122 123 124 | socket: self errNo: EAFNOSUPPORT]; } return address; } | | | 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | socket: self errNo: EAFNOSUPPORT]; } return address; } #if !defined(OF_WINDOWS) && !defined(OF_FREEBSD) - (void)sendBuffer: (const void *)buffer length: (size_t)length receiver: (const OFSocketAddress *)receiver { OFSocketAddress fixedReceiver; memcpy(&fixedReceiver, receiver, sizeof(fixedReceiver)); |
︙ | ︙ |
Renamed and modified src/OFURI+Private.h [c5dc8bc44b] to src/OFIRI+Private.h [2b5f28e828].
1 | /* | | | | | | > > > > | < > | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFIRI.h" OF_ASSUME_NONNULL_BEGIN @interface OFIRI () - (instancetype)of_init OF_METHOD_FAMILY(init); @end OF_ASSUME_NONNULL_END |
Renamed and modified src/OFURI.h [90c837e175] to src/OFIRI.h [46c48a2808].
1 | /* | | | | | | > > > > | < > | < | > | > > | | | | | | | | | | | | | | > > > > > | | | | | | | > > > > > > > > > > > > > > > | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFCharacterSet.h" OF_ASSUME_NONNULL_BEGIN @class OFArray OF_GENERIC(ObjectType); @class OFDictionary OF_GENERIC(KeyType, ObjectType); @class OFNumber; @class OFPair OF_GENERIC(FirstType, SecondType); @class OFString; /** * @class OFIRI OFIRI.h ObjFW/OFIRI.h * * @brief A class for representing IRIs, URIs, URLs and URNs, for parsing them * as well as accessing parts of them. * * This class follows RFC 3976 and RFC 3987. */ @interface OFIRI: OFObject <OFCopying, OFMutableCopying> { OFString *_scheme; OFString *_Nullable _percentEncodedHost; OFNumber *_Nullable _port; OFString *_Nullable _percentEncodedUser; OFString *_Nullable _percentEncodedPassword; OFString *_percentEncodedPath; OFString *_Nullable _percentEncodedQuery; OFString *_Nullable _percentEncodedFragment; OF_RESERVE_IVARS(OFIRI, 4) } /** * @brief The scheme part of the IRI. */ @property (readonly, copy, nonatomic) OFString *scheme; /** * @brief The host part of the IRI. */ @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *host; /** * @brief The host part of the IRI in percent-encoded form. */ @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *percentEncodedHost; /** * @brief The port part of the IRI. */ @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFNumber *port; /** * @brief The user part of the IRI. */ @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *user; /** * @brief The user part of the IRI in percent-encoded form. */ @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *percentEncodedUser; /** * @brief The password part of the IRI. */ @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *password; /** * @brief The password part of the IRI in percent-encoded form. */ @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *percentEncodedPassword; /** * @brief The path part of the IRI. */ @property (readonly, copy, nonatomic) OFString *path; /** * @brief The path part of the IRI in percent-encoded form. */ @property (readonly, copy, nonatomic) OFString *percentEncodedPath; /** * @brief The path of the IRI split into components. * * The first component must always be `/` to designate the root. */ @property (readonly, copy, nonatomic) OFArray OF_GENERIC(OFString *) *pathComponents; /** * @brief The last path component of the IRI. * * Returns the empty string if the path is the root. */ @property (readonly, copy, nonatomic) OFString *lastPathComponent; /** * @brief The path extension of the IRI. */ @property (readonly, copy, nonatomic) OFString *pathExtension; /** * @brief The query part of the IRI. */ @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *query; /** * @brief The query part of the IRI in percent-encoded form. */ @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *percentEncodedQuery; /** * @brief The query part of the IRI as an array. * * For example, a query like `key1=value1&key2=value2` would correspond to the * following array: * * @[ * [OFPair pairWithFirstObject: @"key1" secondObject: @"value1"], * [OFPair pairWithFirstObject: @"key2" secondObject: @"value2"], * ] * * @throw OFInvalidFormatException The query is not in the correct format */ @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFArray OF_GENERIC(OFPair OF_GENERIC(OFString *, OFString *) *) *queryItems; /** * @brief The fragment part of the IRI. */ @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *fragment; /** * @brief The fragment part of the IRI in percent-encoded form. */ @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *percentEncodedFragment; /** * @brief The IRI as a string. */ @property (readonly, nonatomic) OFString *string; /** * @brief The IRI with relative subpaths resolved. */ @property (readonly, nonatomic) OFIRI *IRIByStandardizingPath; /** * @brief The IRI with the last path component deleted. */ @property (readonly, nonatomic) OFIRI *IRIByDeletingLastPathComponent; /** * @brief The IRI with the path extension deleted. */ @property (readonly, nonatomic) OFIRI *IRIByDeletingPathExtension; /** * @brief The IRI with percent-encoding added for all Unicode characters. */ @property (readonly, nonatomic) OFIRI *IRIByAddingPercentEncodingForUnicodeCharacters; #ifdef OF_HAVE_FILES /** * @brief The local file system representation for a file IRI. * * @note This only exists for IRIs with the file scheme and throws an exception * otherwise. */ @property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *fileSystemRepresentation; #endif /** * @brief Creates a new IRI with the specified string. * * @param string A string describing an IRI * @return A new, autoreleased OFIRI * @throw OFInvalidFormatException The specified string is not a valid IRI * string */ + (instancetype)IRIWithString: (OFString *)string; /** * @brief Creates a new IRI with the specified string relative to the * specified IRI. * * @param string A string describing a relative or absolute IRI * @param IRI An IRI to which the string is relative * @return A new, autoreleased OFIRI * @throw OFInvalidFormatException The specified string is not a valid IRI * string */ + (instancetype)IRIWithString: (OFString *)string relativeToIRI: (OFIRI *)IRI; #ifdef OF_HAVE_FILES /** * @brief Creates a new IRI with the specified local file path. * * If a directory exists at the specified path, a slash is appended if there is * no slash yet. * * @param path The local file path * @return A new, autoreleased OFIRI * @throw OFInvalidFormatException The specified path is not a valid path */ + (instancetype)fileIRIWithPath: (OFString *)path; /** * @brief Creates a new IRI with the specified local file path. * * @param path The local file path * @param isDirectory Whether the path is a directory, in which case a slash is * appended if there is no slash yet * @return An initialized OFIRI */ + (instancetype)fileIRIWithPath: (OFString *)path isDirectory: (bool)isDirectory; #endif /** * @brief Initializes an already allocated OFIRI with the specified string. * * @param string A string describing an IRI * @return An initialized OFIRI * @throw OFInvalidFormatException The specified string is not a valid IRI * string */ - (instancetype)initWithString: (OFString *)string; /** * @brief Initializes an already allocated OFIRI with the specified string and * relative IRI. * * @param string A string describing a relative or absolute IRI * @param IRI An IRI to which the string is relative * @return An initialized OFIRI * @throw OFInvalidFormatException The specified string is not a valid IRI * string */ - (instancetype)initWithString: (OFString *)string relativeToIRI: (OFIRI *)IRI; #ifdef OF_HAVE_FILES /** * @brief Initializes an already allocated OFIRI with the specified local file * path. * * If a directory exists at the specified path, a slash is appended if there is * no slash yet. * * @param path The local file path * @return An initialized OFIRI * @throw OFInvalidFormatException The specified path is not a valid path */ - (instancetype)initFileIRIWithPath: (OFString *)path; /** * @brief Initializes an already allocated OFIRI with the specified local file * path. * * @param path The local file path * @param isDirectory Whether the path is a directory, in which case a slash is * appended if there is no slash yet * @return An initialized OFIRI */ - (instancetype)initFileIRIWithPath: (OFString *)path isDirectory: (bool)isDirectory; #endif - (instancetype)init OF_UNAVAILABLE; /** * @brief Returns a new IRI with the specified path component appended. * * If the IRI is a file IRI, the file system is queried whether the appended * component is a directory. * * @param component The path component to append. If it starts with the slash, * the component is not appended, but replaces the path * instead. * @return A new IRI with the specified path component appended */ - (OFIRI *)IRIByAppendingPathComponent: (OFString *)component; /** * @brief Returns a new IRI with the specified path component appended. * * @param component The path component to append. If it starts with the slash, * the component is not appended, but replaces the path * instead. * @param isDirectory Whether the appended component is a directory, meaning * that the IRI path should have a trailing slash * @return A new IRI with the specified path component appended */ - (OFIRI *)IRIByAppendingPathComponent: (OFString *)component isDirectory: (bool)isDirectory; /** * @brief Returns a new IRI with the specified path extension appended. * * @param extension The path extension to append * @return A new IRI with the specified path extension appended. */ - (OFIRI *)IRIByAppendingPathExtension: (OFString *)extension; @end @interface OFCharacterSet (IRICharacterSets) #ifdef OF_HAVE_CLASS_PROPERTIES @property (class, readonly, nonatomic) OFCharacterSet *IRISchemeAllowedCharacterSet; @property (class, readonly, nonatomic) OFCharacterSet *IRIHostAllowedCharacterSet; @property (class, readonly, nonatomic) OFCharacterSet *IRIUserAllowedCharacterSet; @property (class, readonly, nonatomic) OFCharacterSet *IRIPasswordAllowedCharacterSet; @property (class, readonly, nonatomic) OFCharacterSet *IRIPathAllowedCharacterSet; @property (class, readonly, nonatomic) OFCharacterSet *IRIQueryAllowedCharacterSet; @property (class, readonly, nonatomic) OFCharacterSet *IRIQueryKeyValueAllowedCharacterSet; @property (class, readonly, nonatomic) OFCharacterSet *IRIFragmentAllowedCharacterSet; #endif /** * @brief Returns the characters allowed in the scheme part of an IRI. * * @return The characters allowed in the scheme part of an IRI. */ + (OFCharacterSet *)IRISchemeAllowedCharacterSet; /** * @brief Returns the characters allowed in the host part of an IRI. * * @return The characters allowed in the host part of an IRI. */ + (OFCharacterSet *)IRIHostAllowedCharacterSet; /** * @brief Returns the characters allowed in the user part of an IRI. * * @return The characters allowed in the user part of an IRI. */ + (OFCharacterSet *)IRIUserAllowedCharacterSet; /** * @brief Returns the characters allowed in the password part of an IRI. * * @return The characters allowed in the password part of an IRI. */ + (OFCharacterSet *)IRIPasswordAllowedCharacterSet; /** * @brief Returns the characters allowed in the path part of an IRI. * * @return The characters allowed in the path part of an IRI. */ + (OFCharacterSet *)IRIPathAllowedCharacterSet; /** * @brief Returns the characters allowed in the query part of an IRI. * * @return The characters allowed in the query part of an IRI. */ + (OFCharacterSet *)IRIQueryAllowedCharacterSet; /** * @brief Returns the characters allowed in a key/value in the query part of a * IRI. * * @return The characters allowed in a key/value in the query part of an IRI. */ + (OFCharacterSet *)IRIQueryKeyValueAllowedCharacterSet; /** * @brief Returns the characters allowed in the fragment part of an IRI. * * @return The characters allowed in the fragment part of an IRI. */ + (OFCharacterSet *)IRIFragmentAllowedCharacterSet; @end #ifdef __cplusplus extern "C" { #endif extern bool OFIRIIsIPv6Host(OFString *host); extern void OFIRIVerifyIsEscaped(OFString *, OFCharacterSet *, bool); #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END #import "OFMutableIRI.h" |
Renamed and modified src/OFURI.m [fd812a6a57] to src/OFIRI.m [8ff2bb9721].
1 | /* | | | | | | > > > > | < > | | | < | | | | | | > > > | | | | | > | < < | | | | | | | | | | | | | | > > > > > > > | > | < > | < | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | < > > < | | > > > > | | > > > | > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdlib.h> #include <string.h> #import "OFIRI.h" #import "OFArray.h" #import "OFDictionary.h" #ifdef OF_HAVE_FILES # import "OFFileManager.h" # import "OFFileIRIHandler.h" #endif #import "OFNumber.h" #import "OFOnce.h" #import "OFPair.h" #import "OFString.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFOutOfMemoryException.h" @interface OFIRIAllowedCharacterSetBase: OFCharacterSet @end @interface OFIRIAllowedCharacterSet: OFIRIAllowedCharacterSetBase @end @interface OFIRISchemeAllowedCharacterSet: OFIRIAllowedCharacterSetBase @end @interface OFIRIPathAllowedCharacterSet: OFIRIAllowedCharacterSetBase @end @interface OFIRIQueryAllowedCharacterSet: OFIRIAllowedCharacterSetBase @end @interface OFIRIQueryKeyValueAllowedCharacterSet: OFIRIAllowedCharacterSetBase @end @interface OFIRIFragmentAllowedCharacterSet: OFIRIAllowedCharacterSetBase @end OF_DIRECT_MEMBERS @interface OFInvertedCharacterSetWithoutPercent: OFCharacterSet { OFCharacterSet *_characterSet; bool (*_characterIsMember)(id, SEL, OFUnichar); } - (instancetype)initWithCharacterSet: (OFCharacterSet *)characterSet; @end static OFCharacterSet *IRIAllowedCharacterSet = nil; static OFCharacterSet *IRISchemeAllowedCharacterSet = nil; static OFCharacterSet *IRIPathAllowedCharacterSet = nil; static OFCharacterSet *IRIQueryAllowedCharacterSet = nil; static OFCharacterSet *IRIQueryKeyValueAllowedCharacterSet = nil; static OFCharacterSet *IRIFragmentAllowedCharacterSet = nil; static OFOnceControl IRIAllowedCharacterSetOnce = OFOnceControlInitValue; static void initIRIAllowedCharacterSet(void) { IRIAllowedCharacterSet = [[OFIRIAllowedCharacterSet alloc] init]; } static void initIRISchemeAllowedCharacterSet(void) { IRISchemeAllowedCharacterSet = [[OFIRISchemeAllowedCharacterSet alloc] init]; } static void initIRIPathAllowedCharacterSet(void) { IRIPathAllowedCharacterSet = [[OFIRIPathAllowedCharacterSet alloc] init]; } static void initIRIQueryAllowedCharacterSet(void) { IRIQueryAllowedCharacterSet = [[OFIRIQueryAllowedCharacterSet alloc] init]; } static void initIRIQueryKeyValueAllowedCharacterSet(void) { IRIQueryKeyValueAllowedCharacterSet = [[OFIRIQueryKeyValueAllowedCharacterSet alloc] init]; } static void initIRIFragmentAllowedCharacterSet(void) { IRIFragmentAllowedCharacterSet = [[OFIRIFragmentAllowedCharacterSet alloc] init]; } bool OFIRIIsIPv6Host(OFString *host) { const char *UTF8String = host.UTF8String; bool hasColon = false; while (*UTF8String != '\0') { if (!OFASCIIIsDigit(*UTF8String) && *UTF8String != ':' && (*UTF8String < 'a' || *UTF8String > 'f') && (*UTF8String < 'A' || *UTF8String > 'F')) return false; if (*UTF8String == ':') hasColon = true; UTF8String++; } return hasColon; } static bool isUnicode(OFUnichar character) { if (character >= 0xA0 && character <= 0xD7FF) return true; if (character >= 0xF900 && character <= 0xFDCF) return true; if (character >= 0xFDF0 && character <= 0xFFEF) return true; if (character >= 0x10000 && character <= 0x1FFFD) return true; if (character >= 0x20000 && character <= 0x2FFFD) return true; if (character >= 0x30000 && character <= 0x3FFFD) return true; if (character >= 0x40000 && character <= 0x4FFFD) return true; if (character >= 0x50000 && character <= 0x5FFFD) return true; if (character >= 0x60000 && character <= 0x6FFFD) return true; if (character >= 0x70000 && character <= 0x7FFFD) return true; if (character >= 0x80000 && character <= 0x8FFFD) return true; if (character >= 0x90000 && character <= 0x9FFFD) return true; if (character >= 0xA0000 && character <= 0xAFFFD) return true; if (character >= 0xB0000 && character <= 0xBFFFD) return true; if (character >= 0xC0000 && character <= 0xCFFFD) return true; if (character >= 0xD0000 && character <= 0xDFFFD) return true; if (character >= 0xE0000 && character <= 0xEFFFD) return true; return false; } static bool isUnicodePrivate(OFUnichar character) { if (character >= 0xE00 && character <= 0xF8FF) return true; if (character >= 0xF0000 && character <= 0xFFFFD) return true; if (character >= 0x100000 && character <= 0x10FFFD) return true; return false; } @implementation OFIRIAllowedCharacterSetBase OF_SINGLETON_METHODS @end @implementation OFIRIAllowedCharacterSet - (bool)characterIsMember: (OFUnichar)character { if (character < CHAR_MAX && OFASCIIIsAlnum(character)) return true; if (isUnicode(character)) return true; switch (character) { case '-': case '.': case '_': case '~': case '!': |
︙ | ︙ | |||
174 175 176 177 178 179 180 | return true; default: return false; } } @end | | | > > > | 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | return true; default: return false; } } @end @implementation OFIRISchemeAllowedCharacterSet - (bool)characterIsMember: (OFUnichar)character { if (character < CHAR_MAX && OFASCIIIsAlnum(character)) return true; switch (character) { case '+': case '-': case '.': return true; default: return false; } } @end @implementation OFIRIPathAllowedCharacterSet - (bool)characterIsMember: (OFUnichar)character { if (character < CHAR_MAX && OFASCIIIsAlnum(character)) return true; if (isUnicode(character)) return true; switch (character) { case '-': case '.': case '_': case '~': case '!': |
︙ | ︙ | |||
223 224 225 226 227 228 229 | return true; default: return false; } } @end | | > > > | 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | return true; default: return false; } } @end @implementation OFIRIQueryAllowedCharacterSet - (bool)characterIsMember: (OFUnichar)character { if (character < CHAR_MAX && OFASCIIIsAlnum(character)) return true; if (isUnicode(character) || isUnicodePrivate(character)) return true; switch (character) { case '-': case '.': case '_': case '~': case '!': |
︙ | ︙ | |||
256 257 258 259 260 261 262 | return true; default: return false; } } @end | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | return true; default: return false; } } @end @implementation OFIRIQueryKeyValueAllowedCharacterSet - (bool)characterIsMember: (OFUnichar)character { if (character < CHAR_MAX && OFASCIIIsAlnum(character)) return true; if (isUnicode(character) || isUnicodePrivate(character)) return true; switch (character) { case '-': case '.': case '_': case '~': case '!': case '$': case '\'': case '(': case ')': case '*': case '+': case ',': case ';': case ':': case '@': case '/': case '?': return true; default: return false; } } @end @implementation OFIRIFragmentAllowedCharacterSet - (bool)characterIsMember: (OFUnichar)character { if (character < CHAR_MAX && OFASCIIIsAlnum(character)) return true; if (isUnicode(character)) return true; switch (character) { case '-': case '.': case '_': case '~': case '!': case '$': case '&': case '\'': case '(': case ')': case '*': case '+': case ',': case ';': case '=': case ':': case '@': case '/': case '?': return true; default: return false; |
︙ | ︙ | |||
320 321 322 323 324 325 326 | { return (character != '%' && !_characterIsMember(_characterSet, @selector(characterIsMember:), character)); } @end void | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < | | | < | | | | | | | | | 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 | { return (character != '%' && !_characterIsMember(_characterSet, @selector(characterIsMember:), character)); } @end void OFIRIVerifyIsEscaped(OFString *string, OFCharacterSet *characterSet, bool allowPercent) { void *pool = objc_autoreleasePoolPush(); if (allowPercent) characterSet = [[[OFInvertedCharacterSetWithoutPercent alloc] initWithCharacterSet: characterSet] autorelease]; else characterSet = characterSet.invertedSet; if ([string indexOfCharacterFromSet: characterSet] != OFNotFound) @throw [OFInvalidFormatException exception]; objc_autoreleasePoolPop(pool); } @implementation OFCharacterSet (IRICharacterSets) + (OFCharacterSet *)IRISchemeAllowedCharacterSet { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, initIRISchemeAllowedCharacterSet); return IRISchemeAllowedCharacterSet; } + (OFCharacterSet *)IRIHostAllowedCharacterSet { OFOnce(&IRIAllowedCharacterSetOnce, initIRIAllowedCharacterSet); return IRIAllowedCharacterSet; } + (OFCharacterSet *)IRIUserAllowedCharacterSet { OFOnce(&IRIAllowedCharacterSetOnce, initIRIAllowedCharacterSet); return IRIAllowedCharacterSet; } + (OFCharacterSet *)IRIPasswordAllowedCharacterSet { OFOnce(&IRIAllowedCharacterSetOnce, initIRIAllowedCharacterSet); return IRIAllowedCharacterSet; } + (OFCharacterSet *)IRIPathAllowedCharacterSet { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, initIRIPathAllowedCharacterSet); return IRIPathAllowedCharacterSet; } + (OFCharacterSet *)IRIQueryAllowedCharacterSet { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, initIRIQueryAllowedCharacterSet); return IRIQueryAllowedCharacterSet; } + (OFCharacterSet *)IRIQueryKeyValueAllowedCharacterSet { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, initIRIQueryKeyValueAllowedCharacterSet); return IRIQueryKeyValueAllowedCharacterSet; } + (OFCharacterSet *)IRIFragmentAllowedCharacterSet { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, initIRIFragmentAllowedCharacterSet); return IRIFragmentAllowedCharacterSet; } @end @implementation OFIRI + (instancetype)IRI { return [[[self alloc] init] autorelease]; } + (instancetype)IRIWithString: (OFString *)string { return [[[self alloc] initWithString: string] autorelease]; } + (instancetype)IRIWithString: (OFString *)string relativeToIRI: (OFIRI *)IRI { return [[[self alloc] initWithString: string relativeToIRI: IRI] autorelease]; } #ifdef OF_HAVE_FILES + (instancetype)fileIRIWithPath: (OFString *)path { return [[[self alloc] initFileIRIWithPath: path] autorelease]; } + (instancetype)fileIRIWithPath: (OFString *)path isDirectory: (bool)isDirectory { return [[[self alloc] initFileIRIWithPath: path isDirectory: isDirectory] autorelease]; } #endif static void parseUserInfo(OFIRI *self, const char *UTF8String, size_t length) { const char *colon; if ((colon = memchr(UTF8String, ':', length)) != NULL) { self->_percentEncodedUser = [[OFString alloc] initWithUTF8String: UTF8String length: colon - UTF8String]; self->_percentEncodedPassword = [[OFString alloc] initWithUTF8String: colon + 1 length: length - (colon - UTF8String) - 1]; OFIRIVerifyIsEscaped(self->_percentEncodedPassword, [OFCharacterSet IRIPasswordAllowedCharacterSet], true); } else self->_percentEncodedUser = [[OFString alloc] initWithUTF8String: UTF8String length: length]; OFIRIVerifyIsEscaped(self->_percentEncodedUser, [OFCharacterSet IRIUserAllowedCharacterSet], true); } static void parseHostPort(OFIRI *self, const char *UTF8String, size_t length) { OFString *portString; if (*UTF8String == '[') { const char *end = memchr(UTF8String, ']', length); if (end == NULL) |
︙ | ︙ | |||
498 499 500 501 502 503 504 | initWithUTF8String: UTF8String length: length]; UTF8String += length; length = 0; } | | | | 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 | initWithUTF8String: UTF8String length: length]; UTF8String += length; length = 0; } OFIRIVerifyIsEscaped(self->_percentEncodedHost, [OFCharacterSet IRIHostAllowedCharacterSet], true); } if (length == 0) return; if (length <= 1 || *UTF8String != ':') @throw [OFInvalidFormatException exception]; |
︙ | ︙ | |||
525 526 527 528 529 530 531 | @throw [OFInvalidFormatException exception]; self->_port = [[OFNumber alloc] initWithUnsignedShort: (unsigned short)portString.unsignedLongLongValue]; } static size_t | | | 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 | @throw [OFInvalidFormatException exception]; self->_port = [[OFNumber alloc] initWithUnsignedShort: (unsigned short)portString.unsignedLongLongValue]; } static size_t parseAuthority(OFIRI *self, const char *UTF8String, size_t length) { size_t ret; const char *slash, *at; if ((slash = memchr(UTF8String, '/', length)) != NULL) length = slash - UTF8String; |
︙ | ︙ | |||
558 559 560 561 562 563 564 | const char *fragment, *query; if ((fragment = memchr(UTF8String, '#', length)) != NULL) { *fragmentString = [OFString stringWithUTF8String: fragment + 1 length: length - (fragment - UTF8String) - 1]; | | | | | | | | 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 | const char *fragment, *query; if ((fragment = memchr(UTF8String, '#', length)) != NULL) { *fragmentString = [OFString stringWithUTF8String: fragment + 1 length: length - (fragment - UTF8String) - 1]; OFIRIVerifyIsEscaped(*fragmentString, [OFCharacterSet IRIQueryAllowedCharacterSet], true); length = fragment - UTF8String; } if ((query = memchr(UTF8String, '?', length)) != NULL) { *queryString = [OFString stringWithUTF8String: query + 1 length: length - (query - UTF8String) - 1]; OFIRIVerifyIsEscaped(*queryString, [OFCharacterSet IRIFragmentAllowedCharacterSet], true); length = query - UTF8String; } *pathString = [OFString stringWithUTF8String: UTF8String length: length]; OFIRIVerifyIsEscaped(*pathString, [OFCharacterSet IRIPathAllowedCharacterSet], true); } - (instancetype)initWithString: (OFString *)string { self = [super init]; @try { |
︙ | ︙ | |||
601 602 603 604 605 606 607 | colon - UTF8String < 1 || !OFASCIIIsAlpha(UTF8String[0])) @throw [OFInvalidFormatException exception]; _scheme = [[[OFString stringWithUTF8String: UTF8String length: colon - UTF8String] lowercaseString] copy]; | | | | 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 | colon - UTF8String < 1 || !OFASCIIIsAlpha(UTF8String[0])) @throw [OFInvalidFormatException exception]; _scheme = [[[OFString stringWithUTF8String: UTF8String length: colon - UTF8String] lowercaseString] copy]; OFIRIVerifyIsEscaped(_scheme, [OFCharacterSet IRISchemeAllowedCharacterSet], false); length -= colon - UTF8String + 1; UTF8String = colon + 1; if (length >= 2 && UTF8String[0] == '/' && UTF8String[1] == '/') { size_t authorityLength; |
︙ | ︙ | |||
690 691 692 693 694 695 696 | else [components replaceObjectAtIndex: components.count - 1 withObject: path]; return [components componentsJoinedByString: @"/"]; } | | | 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 | else [components replaceObjectAtIndex: components.count - 1 withObject: path]; return [components componentsJoinedByString: @"/"]; } - (instancetype)initWithString: (OFString *)string relativeToIRI: (OFIRI *)IRI { bool absolute; @try { absolute = isAbsolute(string); } @catch (id e) { [self release]; |
︙ | ︙ | |||
713 714 715 716 717 718 719 | @try { void *pool = objc_autoreleasePoolPush(); const char *UTF8String = string.UTF8String; size_t length = string.UTF8StringLength; bool hasAuthority = false; OFString *path, *query = nil, *fragment = nil; | | | | | | | | | | | | | | | 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 | @try { void *pool = objc_autoreleasePoolPush(); const char *UTF8String = string.UTF8String; size_t length = string.UTF8StringLength; bool hasAuthority = false; OFString *path, *query = nil, *fragment = nil; _scheme = [IRI->_scheme copy]; if (length >= 2 && UTF8String[0] == '/' && UTF8String[1] == '/') { size_t authorityLength; hasAuthority = true; UTF8String += 2; length -= 2; authorityLength = parseAuthority(self, UTF8String, length); UTF8String += authorityLength; length -= authorityLength; if (length > 0) OFEnsure(UTF8String[0] == '/'); } else { _percentEncodedHost = [IRI->_percentEncodedHost copy]; _port = [IRI->_port copy]; _percentEncodedUser = [IRI->_percentEncodedUser copy]; _percentEncodedPassword = [IRI->_percentEncodedPassword copy]; } parsePathQueryFragment(UTF8String, length, &path, &query, &fragment); _percentEncodedFragment = [fragment copy]; if (hasAuthority) { _percentEncodedPath = [path copy]; _percentEncodedQuery = [query copy]; } else { if (path.length == 0) { _percentEncodedPath = [IRI->_percentEncodedPath copy]; _percentEncodedQuery = (query != nil ? [query copy] : [IRI->_percentEncodedQuery copy]); } else { if ([path hasPrefix: @"/"]) _percentEncodedPath = [path copy]; else _percentEncodedPath = [merge( IRI->_percentEncodedPath, path) copy]; _percentEncodedQuery = [query copy]; } } objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; } return self; } #ifdef OF_HAVE_FILES - (instancetype)initFileIRIWithPath: (OFString *)path { bool isDirectory; @try { void *pool = objc_autoreleasePoolPush(); isDirectory = [path of_isDirectoryPath]; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; } self = [self initFileIRIWithPath: path isDirectory: isDirectory]; return self; } - (instancetype)initFileIRIWithPath: (OFString *)path isDirectory: (bool)isDirectory { self = [super init]; @try { void *pool = objc_autoreleasePoolPush(); OFString *percentEncodedHost = nil; if (!path.absolutePath) { OFString *currentDirectoryPath = [OFFileManager defaultManager].currentDirectoryPath; path = [currentDirectoryPath stringByAppendingPathComponent: path]; path = path.stringByStandardizingPath; } path = [path of_pathToIRIPathWithPercentEncodedHost: &percentEncodedHost]; _percentEncodedHost = [percentEncodedHost copy]; if (isDirectory && ![path hasSuffix: @"/"]) path = [path stringByAppendingString: @"/"]; _scheme = @"file"; _percentEncodedPath = [[path stringByAddingPercentEncodingWithAllowedCharacters: [OFCharacterSet IRIPathAllowedCharacterSet]] copy]; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; } |
︙ | ︙ | |||
844 845 846 847 848 849 850 | } - (instancetype)of_init { return [super init]; } | < < < < < < < < < < < < < < < < < < < < < < < | | | | | | | | | | | | | | | | | 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 | } - (instancetype)of_init { return [super init]; } - (void)dealloc { [_scheme release]; [_percentEncodedHost release]; [_port release]; [_percentEncodedUser release]; [_percentEncodedPassword release]; [_percentEncodedPath release]; [_percentEncodedQuery release]; [_percentEncodedFragment release]; [super dealloc]; } - (bool)isEqual: (id)object { OFIRI *IRI; if (object == self) return true; if (![object isKindOfClass: [OFIRI class]]) return false; IRI = object; if (![IRI->_scheme isEqual: _scheme]) return false; if (IRI->_percentEncodedHost != _percentEncodedHost && ![IRI->_percentEncodedHost isEqual: _percentEncodedHost]) return false; if (IRI->_port != _port && ![IRI->_port isEqual: _port]) return false; if (IRI->_percentEncodedUser != _percentEncodedUser && ![IRI->_percentEncodedUser isEqual: _percentEncodedUser]) return false; if (IRI->_percentEncodedPassword != _percentEncodedPassword && ![IRI->_percentEncodedPassword isEqual: _percentEncodedPassword]) return false; if (![IRI->_percentEncodedPath isEqual: _percentEncodedPath]) return false; if (IRI->_percentEncodedQuery != _percentEncodedQuery && ![IRI->_percentEncodedQuery isEqual: _percentEncodedQuery]) return false; if (IRI->_percentEncodedFragment != _percentEncodedFragment && ![IRI->_percentEncodedFragment isEqual: _percentEncodedFragment]) return false; return true; } - (unsigned long)hash { |
︙ | ︙ | |||
950 951 952 953 954 955 956 | - (OFString *)host { if ([_percentEncodedHost hasPrefix: @"["] && [_percentEncodedHost hasSuffix: @"]"]) { OFString *host = [_percentEncodedHost substringWithRange: OFMakeRange(1, _percentEncodedHost.length - 2)]; | | | 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 | - (OFString *)host { if ([_percentEncodedHost hasPrefix: @"["] && [_percentEncodedHost hasSuffix: @"]"]) { OFString *host = [_percentEncodedHost substringWithRange: OFMakeRange(1, _percentEncodedHost.length - 2)]; if (!OFIRIIsIPv6Host(host)) @throw [OFInvalidArgumentException exception]; return host; } return _percentEncodedHost.stringByRemovingPercentEncoding; } |
︙ | ︙ | |||
1011 1012 1013 1014 1015 1016 1017 | #endif OFMutableArray *ret; size_t count; #ifdef OF_HAVE_FILES if (isFile) { OFString *path = [_percentEncodedPath | | | | 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 | #endif OFMutableArray *ret; size_t count; #ifdef OF_HAVE_FILES if (isFile) { OFString *path = [_percentEncodedPath of_IRIPathToPathWithPercentEncodedHost: nil]; ret = [[path.pathComponents mutableCopy] autorelease]; if (![ret.firstObject isEqual: @"/"]) [ret insertObject: @"/" atIndex: 0]; } else #endif ret = [[[_percentEncodedPath componentsSeparatedByString: @"/"] mutableCopy] autorelease]; count = ret.count; if (count > 0 && [ret.firstObject length] == 0) [ret replaceObjectAtIndex: 0 withObject: @"/"]; for (size_t i = 0; i < count; i++) { OFString *component = [ret objectAtIndex: i]; #ifdef OF_HAVE_FILES if (isFile) component = [component of_pathComponentToIRIPathComponent]; #endif component = component.stringByRemovingPercentEncoding; [ret replaceObjectAtIndex: i withObject: component]; } [ret makeImmutable]; |
︙ | ︙ | |||
1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 | length: length - (lastComponent - UTF8String)]; ret = [ret.stringByRemovingPercentEncoding retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } - (OFString *)query { return _percentEncodedQuery.stringByRemovingPercentEncoding; } - (OFString *)percentEncodedQuery | > > > > > > > > > > > > > > > > > > > > > | 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 | length: length - (lastComponent - UTF8String)]; ret = [ret.stringByRemovingPercentEncoding retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } - (OFString *)pathExtension { void *pool = objc_autoreleasePoolPush(); OFString *ret, *fileName; size_t pos; fileName = self.lastPathComponent; pos = [fileName rangeOfString: @"." options: OFStringSearchBackwards].location; if (pos == OFNotFound || pos == 0) { objc_autoreleasePoolPop(pool); return @""; } ret = [fileName substringFromIndex: pos + 1]; [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } - (OFString *)query { return _percentEncodedQuery.stringByRemovingPercentEncoding; } - (OFString *)percentEncodedQuery |
︙ | ︙ | |||
1148 1149 1150 1151 1152 1153 1154 | - (id)copy { return [self retain]; } - (id)mutableCopy { | | | 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 | - (id)copy { return [self retain]; } - (id)mutableCopy { OFIRI *copy = [[OFMutableIRI alloc] initWithScheme: _scheme]; @try { copy->_percentEncodedHost = [_percentEncodedHost copy]; copy->_port = [_port copy]; copy->_percentEncodedUser = [_percentEncodedUser copy]; copy->_percentEncodedPassword = [_percentEncodedPassword copy]; copy->_percentEncodedPath = [_percentEncodedPath copy]; |
︙ | ︙ | |||
1214 1215 1216 1217 1218 1219 1220 | if (![_scheme isEqual: @"file"]) @throw [OFInvalidArgumentException exception]; if (![_percentEncodedPath hasPrefix: @"/"]) @throw [OFInvalidFormatException exception]; path = [self.path | | | | | | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > | > > > | > > > > > > > > > > > > > | > > > | < < < < < < < < < < < < < < < < | 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 | if (![_scheme isEqual: @"file"]) @throw [OFInvalidArgumentException exception]; if (![_percentEncodedPath hasPrefix: @"/"]) @throw [OFInvalidFormatException exception]; path = [self.path of_IRIPathToPathWithPercentEncodedHost: _percentEncodedHost]; [path retain]; objc_autoreleasePoolPop(pool); return [path autorelease]; } #endif - (OFIRI *)IRIByAppendingPathComponent: (OFString *)component { OFMutableIRI *IRI = [[self mutableCopy] autorelease]; [IRI appendPathComponent: component]; [IRI makeImmutable]; return IRI; } - (OFIRI *)IRIByAppendingPathComponent: (OFString *)component isDirectory: (bool)isDirectory { OFMutableIRI *IRI = [[self mutableCopy] autorelease]; [IRI appendPathComponent: component isDirectory: isDirectory]; [IRI makeImmutable]; return IRI; } - (OFIRI *)IRIByDeletingLastPathComponent { OFMutableIRI *IRI = [[self mutableCopy] autorelease]; [IRI deleteLastPathComponent]; [IRI makeImmutable]; return IRI; } - (OFIRI *)IRIByAppendingPathExtension: (OFString *)extension { OFMutableIRI *IRI = [[self mutableCopy] autorelease]; [IRI appendPathExtension: extension]; [IRI makeImmutable]; return IRI; } - (OFIRI *)IRIByDeletingPathExtension { OFMutableIRI *IRI = [[self mutableCopy] autorelease]; [IRI deletePathExtension]; [IRI makeImmutable]; return IRI; } - (OFIRI *)IRIByStandardizingPath { OFMutableIRI *IRI = [[self mutableCopy] autorelease]; [IRI standardizePath]; [IRI makeImmutable]; return IRI; } - (OFIRI *)IRIByAddingPercentEncodingForUnicodeCharacters { OFMutableIRI *IRI = [[self mutableCopy] autorelease]; void *pool = objc_autoreleasePoolPush(); OFCharacterSet *ASCII = [OFCharacterSet characterSetWithRange: OFMakeRange(0, 0x80)]; IRI.percentEncodedHost = [_percentEncodedHost stringByAddingPercentEncodingWithAllowedCharacters: ASCII]; IRI.percentEncodedUser = [_percentEncodedUser stringByAddingPercentEncodingWithAllowedCharacters: ASCII]; IRI.percentEncodedPassword = [_percentEncodedPassword stringByAddingPercentEncodingWithAllowedCharacters: ASCII]; IRI.percentEncodedPath = [_percentEncodedPath stringByAddingPercentEncodingWithAllowedCharacters: ASCII]; IRI.percentEncodedQuery = [_percentEncodedQuery stringByAddingPercentEncodingWithAllowedCharacters: ASCII]; IRI.percentEncodedFragment = [_percentEncodedFragment stringByAddingPercentEncodingWithAllowedCharacters: ASCII]; [IRI makeImmutable]; objc_autoreleasePoolPop(pool); return IRI; } - (OFString *)description { return [OFString stringWithFormat: @"<%@: %@>", self.class, self.string]; } @end |
Renamed and modified src/OFURIHandler.h [09864efcca] to src/OFIRIHandler.h [717d2a05d6].
1 | /* | | | | | | > > > > | < > | > | | | | | | | | | | | | | | | | | | | | | | | > > > > | | | | > > > > > > > | | | | > > | | | | > > | | | > > > | | | | > > > > | | | | > > > | | | | | > > > > > | | | | > > > | | | > > > | | > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFFileManager.h" #import "OFObject.h" #import "OFString.h" OF_ASSUME_NONNULL_BEGIN @class OFArray OF_GENERIC(ObjectType); @class OFData; @class OFDate; @class OFIRI; @class OFStream; /** * @class OFIRIHandler OFIRIHandler.h ObjFW/OFIRIHandler.h * * @brief A handler for an IRI scheme. */ @interface OFIRIHandler: OFObject { OFString *_scheme; OF_RESERVE_IVARS(OFIRIHandler, 4) } /** * @brief The scheme this OFIRIHandler handles. */ @property (readonly, nonatomic) OFString *scheme; /** * @brief Registers the specified class as the handler for the specified scheme. * * If the same class is specified for two schemes, one instance of it is * created per scheme. * * @param class_ The class to register as the handler for the specified scheme * @param scheme The scheme for which to register the handler * @return Whether the class was successfully registered. If a handler for the * same scheme is already registered, registration fails. */ + (bool)registerClass: (Class)class_ forScheme: (OFString *)scheme; /** * @brief Returns the handler for the specified IRI. * * @return The handler for the specified IRI. * @throw OFUnsupportedProtocolException The specified IRI is not supported */ + (OFIRIHandler *)handlerForIRI: (OFIRI *)IRI; /** * @brief Opens the item at the specified IRI. * * @param IRI The IRI of the item which should be opened * @param mode The mode in which the file should be opened.@n * Possible modes are: * @n * Mode | Description * ---------------|------------------------------------- * `r` | Read-only * `r+` | Read-write * `w` | Write-only, create or truncate * `wx` | Write-only, create or fail, exclusive * `w+` | Read-write, create or truncate * `w+x` | Read-write, create or fail, exclusive * `a` | Write-only, create or append * `a+` | Read-write, create or append * @n * The handler is allowed to not implement all modes and is also * allowed to implement additional, scheme-specific modes. * @return The opened stream if it was successfully opened * @throw OFOpenItemFailedException Opening the item failed * @throw OFUnsupportedProtocolException The specified IRI is not supported */ + (OFStream *)openItemAtIRI: (OFIRI *)IRI mode: (OFString *)mode; - (instancetype)init OF_UNAVAILABLE; /** * @brief Initializes the handler for the specified scheme. * * @param scheme The scheme to initialize for * @return An initialized IRI handler */ - (instancetype)initWithScheme: (OFString *)scheme OF_DESIGNATED_INITIALIZER; /** * @brief Opens the item at the specified IRI. * * @param IRI The IRI of the item which should be opened * @param mode The mode in which the file should be opened.@n * Possible modes are: * @n * Mode | Description * ---------------|------------------------------------- * `r` | Read-only * `r+` | Read-write * `w` | Write-only, create or truncate * `wx` | Write-only, create or fail, exclusive * `w+` | Read-write, create or truncate * `w+x` | Read-write, create or fail, exclusive * `a` | Write-only, create or append * `a+` | Read-write, create or append * @n * The handler is allowed to not implement all modes and is also * allowed to implement additional, scheme-specific modes. * @return The opened stream if it was successfully opened * @throw OFOpenItemFailedException Opening the item failed * @throw OFUnsupportedProtocolException The specified IRI is not supported by * the handler */ - (OFStream *)openItemAtIRI: (OFIRI *)IRI mode: (OFString *)mode; /** * @brief Returns the attributes for the item at the specified IRI. * * @param IRI The IRI to return the attributes for * @return A dictionary of attributes for the specified IRI, with the keys of * type @ref OFFileAttributeKey * @throw OFGetItemAttributesFailedException Failed to get the attributes of * the item * @throw OFUnsupportedProtocolException The handler cannot handle the IRI's * scheme */ - (OFFileAttributes)attributesOfItemAtIRI: (OFIRI *)IRI; /** * @brief Sets the attributes for the item at the specified IRI. * * All attributes not part of the dictionary are left unchanged. * * @param attributes The attributes to set for the specified IRI * @param IRI The IRI of the item to set the attributes for * @@throw OFSetItemAttributesFailedException Failed to set the attributes of * the item * @throw OFUnsupportedProtocolException The handler cannot handle the IRI's * scheme * @throw OFNotImplementedException Setting one or more of the specified * attributes is not implemented for the * specified item */ - (void)setAttributes: (OFFileAttributes)attributes ofItemAtIRI: (OFIRI *)IRI; /** * @brief Checks whether a file exists at the specified IRI. * * @param IRI The IRI to check * @return A boolean whether there is a file at the specified IRI * @throw OFUnsupportedProtocolException The handler cannot handle the IRI's * scheme */ - (bool)fileExistsAtIRI: (OFIRI *)IRI; /** * @brief Checks whether a directory exists at the specified IRI. * * @param IRI The IRI to check * @return A boolean whether there is a directory at the specified IRI * @throw OFUnsupportedProtocolException The handler cannot handle the IRI's * scheme */ - (bool)directoryExistsAtIRI: (OFIRI *)IRI; /** * @brief Creates a directory at the specified IRI. * * @param IRI The IRI of the directory to create * @throw OFCreateDirectoryFailedException Creating the directory failed * @throw OFUnsupportedProtocolException The handler cannot handle the IRI's * scheme */ - (void)createDirectoryAtIRI: (OFIRI *)IRI; /** * @brief Returns an array with the IRIs of the items in the specified * directory. * * @note `.` and `..` are not part of the returned array. * * @param IRI The IRI to the directory whose items should be returned * @return An array with the IRIs of the items in the specified directory * @throw OFOpenItemFailedException Opening the directory failed * @throw OFReadFailedException Reading from the directory failed * @throw OFUnsupportedProtocolException The handler cannot handle the IRI's * scheme */ - (OFArray OF_GENERIC(OFIRI *) *)contentsOfDirectoryAtIRI: (OFIRI *)IRI; /** * @brief Removes the item at the specified IRI. * * If the item at the specified IRI is a directory, it is removed recursively. * * @param IRI The IRI to the item which should be removed * @throw OFRemoveItemFailedException Removing the item failed * @throw OFUnsupportedProtocolException The handler cannot handle the IRI's * scheme */ - (void)removeItemAtIRI: (OFIRI *)IRI; /** * @brief Creates a hard link for the specified item. * * The destination IRI must have a full path, which means it must include the * name of the item. * * This method is not available for all IRIs. * * @param source The IRI to the item for which a link should be created * @param destination The IRI to the item which should link to the source * @throw OFLinkItemFailedException Linking the item failed * @throw OFUnsupportedProtocolException The handler cannot handle the scheme * of one of the IRIs * @throw OFNotImplementedException Hardlinks are not implemented for the * specified IRI */ - (void)linkItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination; /** * @brief Creates a symbolic link for an item. * * The destination IRI must have a full path, which means it must include the * name of the item. * * This method is not available for all IRIs. * * @note On Windows, this requires at least Windows Vista and administrator * privileges! * * @param IRI The IRI to the item which should symbolically link to the target * @param target The target of the symbolic link * @throw OFCreateSymbolicLinkFailed Creating a symbolic link failed * @throw OFUnsupportedProtocolException The handler cannot handle the IRI's * scheme */ - (void)createSymbolicLinkAtIRI: (OFIRI *)IRI withDestinationPath: (OFString *)target; /** * @brief Tries to efficiently copy an item. If a copy would only be possible * by reading the entire item and then writing it, it returns false. * * The destination IRI must have a full path, which means it must include the * name of the item. * * If an item already exists, the copy operation fails. This is also the case * if a directory is copied and an item already exists in the destination * directory. * * @param source The file, directory or symbolic link to copy * @param destination The destination IRI * @return True if an efficient copy was performed, false if an efficient copy * was not possible. Note that errors while performing a copy are * reported via exceptions and not by returning false! * @throw OFCopyItemFailedException Copying failed * @throw OFUnsupportedProtocolException The handler cannot handle the IRI's * scheme */ - (bool)copyItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination; /** * @brief Tries to efficiently move an item. If a move would only be possible * by copying the source and deleting it, it returns false. * * The destination IRI must have a full path, which means it must include the * name of the item. * * If the destination is on a different logical device or uses a different * scheme, an efficient move is not possible and false is returned. * * @param source The item to rename * @param destination The new name for the item * @return True if an efficient move was performed, false if an efficient move * was not possible. Note that errors while performing a move are * reported via exceptions and not by returning false! * @throw OFMoveItemFailedException Moving failed * @throw OFUnsupportedProtocolException The handler cannot handle the IRI's * scheme */ - (bool)moveItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination; /** * @brief Returns the extended attribute data for the specified name of the * item at the specified IRI. * * @deprecated Use @ref getExtendedAttributeData:andType:forName:ofItemAtIRI: * instead. * * This method is not available for all IRIs. * * @param name The name of the extended attribute * @param IRI The IRI of the item to return the extended attribute from * @return The extended attribute data for the specified name of the item at * the specified IRI * @throw OFGetItemAttributesFailedException Getting the extended attribute * failed * @throw OFUnsupportedProtocolException The handler cannot handle the IRI's * scheme * @throw OFNotImplementedException Getting extended attributes is not * implemented for the specified item */ - (OFData *)extendedAttributeDataForName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI OF_DEPRECATED(ObjFW, 1, 1, "Use -[getExtendedAttributeData:andType:forName:ofItemAtIRI:] instead"); /** * @brief Gets the extended attribute data and type for the specified name * of the item at the specified IRI. * * This method is not available for all IRIs. * * @param data A pointer to `OFData *` that gets set to the data of the * extended attribute * @param type A pointer to `id` that gets set to the type of the extended * attribute, if not `NULL`. Gets set to `nil` if the extended * attribute has no type. The type of the type depends on the IRI * handler. * @param name The name of the extended attribute * @param IRI The IRI of the item to return the extended attribute from * @throw OFGetItemAttributesFailedException Getting the extended attribute * failed * @throw OFUnsupportedProtocolException The handler cannot handle the IRI's * scheme * @throw OFNotImplementedException Getting extended attributes is not * implemented for the specified item */ - (void)getExtendedAttributeData: (OFData *_Nonnull *_Nonnull)data andType: (id _Nullable *_Nullable)type forName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI; /** * @brief Sets the extended attribute data for the specified name of the item * at the specified IRI. * * @deprecated Use @ref setExtendedAttributeData:andType:forName:ofItemAtIRI: * instead. * * This method is not available for all IRIs. * * @param data The data for the extended attribute * @param name The name of the extended attribute * @param IRI The IRI of the item to set the extended attribute on * @throw OFSetItemAttributesFailedException Setting the extended attribute * failed * @throw OFUnsupportedProtocolException The handler cannot handle the IRI's * scheme * @throw OFNotImplementedException Setting extended attributes is not * implemented for the specified item */ - (void)setExtendedAttributeData: (OFData *)data forName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI OF_DEPRECATED(ObjFW, 1, 1, "Use -[setExtendedAttributeData:andType:forName:ofItemAtIRI:] instead"); /** * @brief Sets the extended attribute data and type for the specified name of * the item at the specified IRI. * * This method is not available for all IRIs. * Not all IRIs support a non-nil type. * * @param data The data for the extended attribute * @param type The type for the extended attribute. `nil` does not mean to keep * the existing type, but to set it to no type. The type of the * type depends on the IRI handler. * @param name The name of the extended attribute * @param IRI The IRI of the item to set the extended attribute on * @throw OFSetItemAttributesFailedException Setting the extended attribute * failed * @throw OFUnsupportedProtocolException The handler cannot handle the IRI's * scheme * @throw OFNotImplementedException Setting extended attributes is not * implemented for the specified item or a * type was specified and typed extended * attributes are not supported */ - (void)setExtendedAttributeData: (OFData *)data andType: (nullable id)type forName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI; /** * @brief Removes the extended attribute for the specified name of the item at * the specified IRI. * * This method is not available for all IRIs. * * @param name The name of the extended attribute to remove * @param IRI The IRI of the item to remove the extended attribute from * @throw OFSetItemAttributesFailedException Removing the extended attribute * failed * @throw OFUnsupportedProtocolException The handler cannot handle the IRI's * scheme * @throw OFNotImplementedException Removing extended attributes is not * implemented for the specified item */ - (void)removeExtendedAttributeForName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI; @end OF_ASSUME_NONNULL_END |
Renamed and modified src/OFURIHandler.m [1cc8c8dac2] to src/OFIRIHandler.m [922d7f84e3].
1 | /* | | | | | | > > > > | < > | | | | < < < < | | | | | < < < < < < < < < | | < < < < | | | | | | | | > < < < | | < < < < | | < < < | | < < < < | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFIRIHandler.h" #import "OFDictionary.h" #import "OFIRI.h" #import "OFNumber.h" #import "OFArchiveIRIHandler.h" #import "OFEmbeddedIRIHandler.h" #ifdef OF_HAVE_FILES # import "OFFileIRIHandler.h" #endif #if defined(OF_HAVE_SOCKETS) && defined(OF_HAVE_THREADS) # import "OFHTTPIRIHandler.h" #endif #import "OFUnsupportedProtocolException.h" static OFMutableDictionary OF_GENERIC(OFString *, OFIRIHandler *) *handlers; @implementation OFIRIHandler @synthesize scheme = _scheme; + (void)initialize { if (self != [OFIRIHandler class]) return; handlers = [[OFMutableDictionary alloc] init]; [self registerClass: [OFEmbeddedIRIHandler class] forScheme: @"embedded"]; #ifdef OF_HAVE_FILES [self registerClass: [OFFileIRIHandler class] forScheme: @"file"]; #endif #if defined(OF_HAVE_SOCKETS) && defined(OF_HAVE_THREADS) [self registerClass: [OFHTTPIRIHandler class] forScheme: @"http"]; [self registerClass: [OFHTTPIRIHandler class] forScheme: @"https"]; #endif [self registerClass: [OFArchiveIRIHandler class] forScheme: @"gzip"]; [self registerClass: [OFArchiveIRIHandler class] forScheme: @"lha"]; [self registerClass: [OFArchiveIRIHandler class] forScheme: @"tar"]; [self registerClass: [OFArchiveIRIHandler class] forScheme: @"zip"]; [self registerClass: [OFArchiveIRIHandler class] forScheme: @"zoo"]; } + (bool)registerClass: (Class)class forScheme: (OFString *)scheme { @synchronized (handlers) { OFIRIHandler *handler; if ([handlers objectForKey: scheme] != nil) return false; handler = [[class alloc] initWithScheme: scheme]; @try { [handlers setObject: handler forKey: scheme]; } @finally { [handler release]; } } return true; } + (OFIRIHandler *)handlerForIRI: (OFIRI *)IRI { OF_KINDOF(OFIRIHandler *) handler; @synchronized (handlers) { handler = [handlers objectForKey: IRI.scheme]; } if (handler == nil) @throw [OFUnsupportedProtocolException exceptionWithIRI: IRI]; return handler; } + (OFStream *)openItemAtIRI: (OFIRI *)IRI mode: (OFString *)mode { return [[self handlerForIRI: IRI] openItemAtIRI: IRI mode: mode]; } - (instancetype)init { OF_INVALID_INIT_METHOD } |
︙ | ︙ | |||
149 150 151 152 153 154 155 | - (void)dealloc { [_scheme release]; [super dealloc]; } | | | | | | | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | - (void)dealloc { [_scheme release]; [super dealloc]; } - (OFStream *)openItemAtIRI: (OFIRI *)IRI mode: (OFString *)mode { OF_UNRECOGNIZED_SELECTOR } - (OFFileAttributes)attributesOfItemAtIRI: (OFIRI *)IRI { OF_UNRECOGNIZED_SELECTOR } - (void)setAttributes: (OFFileAttributes)attributes ofItemAtIRI: (OFIRI *)IRI { OF_UNRECOGNIZED_SELECTOR } - (bool)fileExistsAtIRI: (OFIRI *)IRI { OF_UNRECOGNIZED_SELECTOR } - (bool)directoryExistsAtIRI: (OFIRI *)IRI { OF_UNRECOGNIZED_SELECTOR } - (void)createDirectoryAtIRI: (OFIRI *)IRI { OF_UNRECOGNIZED_SELECTOR } - (OFArray OF_GENERIC(OFIRI *) *)contentsOfDirectoryAtIRI: (OFIRI *)IRI { OF_UNRECOGNIZED_SELECTOR } - (void)removeItemAtIRI: (OFIRI *)IRI { OF_UNRECOGNIZED_SELECTOR } - (void)linkItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination { OF_UNRECOGNIZED_SELECTOR } - (void)createSymbolicLinkAtIRI: (OFIRI *)destination withDestinationPath: (OFString *)source { OF_UNRECOGNIZED_SELECTOR } - (bool)copyItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination { return false; } - (bool)moveItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination { return false; } - (OFData *)extendedAttributeDataForName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI { OFData *data; [self getExtendedAttributeData: &data andType: NULL forName: name ofItemAtIRI: IRI]; return data; } - (void)getExtendedAttributeData: (OFData **)data andType: (id *)type forName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI { /* * Only call into -[extendedAttributeDataForName:ofItemAtIRI:] if it * has been overridden. This is to be backwards-compatible to * subclasses that predate the introduction of * -[getExtendedAttributeData:andType:forName:ofItemAtIRI:]. * Without this check, this would result in an infinite loop. */ SEL selector = @selector(extendedAttributeDataForName:ofItemAtIRI:); if (class_getMethodImplementation(object_getClass(self), selector) != class_getMethodImplementation([OFIRIHandler class], selector)) { /* * Use -[performSelector:withObject:withObject:] to avoid * deprecation warning. This entire thing is purely for * backwards compatibility. */ *data = [self performSelector: selector withObject: name withObject: IRI]; if (type != NULL) *type = nil; return; } OF_UNRECOGNIZED_SELECTOR } - (void)setExtendedAttributeData: (OFData *)data forName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI { [self setExtendedAttributeData: data andType: nil forName: name ofItemAtIRI: IRI]; } - (void)setExtendedAttributeData: (OFData *)data andType: (id)type forName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI { if (type == nil) { /* * Only call into * -[setExtendedAttributeData:forName:ofItemAtIRI:] if it has * been overridden. This is to be backwards-compatible to * subclasses that predate the introduction of * -[setExtendedAttributeData:andType:forName:ofItemAtIRI:]. * Without this check, this would result in an infinite loop. */ SEL selector = @selector(setExtendedAttributeData:forName:ofItemAtIRI:); if (class_getMethodImplementation(object_getClass(self), selector) != class_getMethodImplementation([OFIRIHandler class], selector)) { /* * Use * -[performSelector:withObject:withObject:withObject:] * to avoid deprecation warning. This entire thing is * purely for backwards compatibility. */ [self performSelector: selector withObject: data withObject: name withObject: IRI]; return; } } OF_UNRECOGNIZED_SELECTOR } - (void)removeExtendedAttributeForName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI { OF_UNRECOGNIZED_SELECTOR } @end |
Modified src/OFInflate64Stream.h from [2f3dc057f8] to [3d0c8d31ad].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFStream.h" #import "OFKernelEventObserver.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ | |||
66 67 68 69 70 71 72 73 74 75 76 77 78 79 | int state; uint16_t value, length, distance, extraBits; } huffman; } _context; bool _inLastBlock, _atEndOfStream; } /** * @brief Creates a new OFInflate64Stream with the specified underlying stream. * * @param stream The underlying stream to which compressed data is written or * from which compressed data is read * @return A new, autoreleased OFInflate64Stream */ | > > > > > > > > | 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | int state; uint16_t value, length, distance, extraBits; } huffman; } _context; bool _inLastBlock, _atEndOfStream; } /** * @brief The underlying stream of the inflate stream. * * Setting this can be useful if the the data to be inflated is coming from * multiple streams, such as split across multiple files. */ @property (retain, nonatomic) OFStream *underlyingStream; /** * @brief Creates a new OFInflate64Stream with the specified underlying stream. * * @param stream The underlying stream to which compressed data is written or * from which compressed data is read * @return A new, autoreleased OFInflate64Stream */ |
︙ | ︙ |
Modified src/OFInflate64Stream.m from [96e65e9055] to [fe18ab75fb].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #define OF_INFLATE64_STREAM_M #include "OFInflateStream.m" |
Modified src/OFInflateStream.h from [fe62e030fd] to [95f6e299ea].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFStream.h" #import "OFKernelEventObserver.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ | |||
66 67 68 69 70 71 72 73 74 75 76 77 78 79 | int state; uint16_t value, length, distance, extraBits; } huffman; } _context; bool _inLastBlock, _atEndOfStream; } /** * @brief Creates a new OFInflateStream with the specified underlying stream. * * @param stream The underlying stream to which compressed data is written or * from which compressed data is read * @return A new, autoreleased OFInflateStream */ | > > > > > > > > | 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | int state; uint16_t value, length, distance, extraBits; } huffman; } _context; bool _inLastBlock, _atEndOfStream; } /** * @brief The underlying stream of the inflate stream. * * Setting this can be useful if the the data to be inflated is coming from * multiple streams, such as split across multiple files. */ @property (retain, nonatomic) OFStream *underlyingStream; /** * @brief Creates a new OFInflateStream with the specified underlying stream. * * @param stream The underlying stream to which compressed data is written or * from which compressed data is read * @return A new, autoreleased OFInflateStream */ |
︙ | ︙ |
Modified src/OFInflateStream.m from [28d4702177] to [5f2d55b677].
1 | /* | | | | | | > > > > | < > | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdlib.h> #include <string.h> #ifndef OF_INFLATE64_STREAM_M # import "OFInflateStream.h" #else # import "OFInflate64Stream.h" # define OFInflateStream OFInflate64Stream #endif #import "OFHuffmanTree.h" |
︙ | ︙ | |||
98 99 100 101 102 103 104 105 106 107 108 109 | #endif static const uint8_t codeLengthsOrder[19] = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 }; static OFHuffmanTree fixedLitLenTree, fixedDistTree; @implementation OFInflateStream static OF_INLINE bool tryReadBits(OFInflateStream *stream, uint16_t *bits, uint8_t count) { uint16_t ret = stream->_savedBits; | > > | | 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | #endif static const uint8_t codeLengthsOrder[19] = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 }; static OFHuffmanTree fixedLitLenTree, fixedDistTree; @implementation OFInflateStream @synthesize underlyingStream = _stream; static OF_INLINE bool tryReadBits(OFInflateStream *stream, uint16_t *bits, uint8_t count) { uint16_t ret = stream->_savedBits; OFAssert(stream->_savedBitsLength < count); for (uint_fast8_t i = stream->_savedBitsLength; i < count; i++) { if OF_UNLIKELY (stream->_bitIndex == 8) { if OF_LIKELY (stream->_bufferIndex < stream->_bufferLength) stream->_byte = stream->_buffer[stream->_bufferIndex++]; |
︙ | ︙ | |||
323 324 325 326 327 328 329 330 331 332 333 334 335 336 | return bytesWritten; tmp = (length < (size_t)CTX.length - CTX.position ? (uint16_t)length : CTX.length - CTX.position); tmp = (uint16_t)[_stream readIntoBuffer: buffer + bytesWritten length: tmp]; slidingWindow = _slidingWindow; slidingWindowIndex = _slidingWindowIndex; for (uint_fast16_t i = 0; i < tmp; i++) { slidingWindow[slidingWindowIndex] = buffer[bytesWritten + i]; slidingWindowIndex = (slidingWindowIndex + 1) & | > > > | 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | return bytesWritten; tmp = (length < (size_t)CTX.length - CTX.position ? (uint16_t)length : CTX.length - CTX.position); tmp = (uint16_t)[_stream readIntoBuffer: buffer + bytesWritten length: tmp]; if OF_UNLIKELY (tmp == 0) return bytesWritten; slidingWindow = _slidingWindow; slidingWindowIndex = _slidingWindowIndex; for (uint_fast16_t i = 0; i < tmp; i++) { slidingWindow[slidingWindowIndex] = buffer[bytesWritten + i]; slidingWindowIndex = (slidingWindowIndex + 1) & |
︙ | ︙ | |||
670 671 672 673 674 675 676 | - (int)fileDescriptorForReading { return ((id <OFReadyForReadingObserving>)_stream) .fileDescriptorForReading; } | | | | 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 | - (int)fileDescriptorForReading { return ((id <OFReadyForReadingObserving>)_stream) .fileDescriptorForReading; } - (bool)lowlevelHasDataInReadBuffer { return (_stream.hasDataInReadBuffer || _bufferLength - _bufferIndex > 0); } - (void)close { if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; |
︙ | ︙ |
Modified src/OFInvertedCharacterSet.h from [d4b8559d77] to [38e60d520d].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFCharacterSet.h" OF_ASSUME_NONNULL_BEGIN @interface OFInvertedCharacterSet: OFCharacterSet |
︙ | ︙ |
Modified src/OFInvertedCharacterSet.m from [1e78ebb0a4] to [0fc19a0bd8].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFInvertedCharacterSet.h" #import "OFString.h" |
︙ | ︙ |
Modified src/OFInvocation.h from [ab7d9433d5] to [ba0216248b].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" OF_ASSUME_NONNULL_BEGIN @class OFMethodSignature; |
︙ | ︙ |
Modified src/OFInvocation.m from [5937b080ad] to [cdbf3ef879].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "OFInvocation.h" |
︙ | ︙ |
Modified src/OFJSONRepresentation.h from [2bd85161f3] to [e578e83ecf].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" @class OFString; OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ |
Modified src/OFKernelEventObserver.h from [81efdafa0c] to [15425300f6].
1 | /* | | | | | | > > > > | < > | < < < | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #ifdef OF_HAVE_SOCKETS # import "OFSocket.h" #endif #ifdef OF_AMIGAOS # include <exec/types.h> # include <exec/tasks.h> #endif OF_ASSUME_NONNULL_BEGIN @class OFMutableArray OF_GENERIC(ObjectType); @class OFDate; @class OFMutableData; /** * @protocol OFKernelEventObserverDelegate * OFKernelEventObserver.h ObjFW/OFKernelEventObserver.h * * @brief A protocol that needs to be implemented by delegates for * OFKernelEventObserver. */ @protocol OFKernelEventObserverDelegate <OFObject> @optional /** * @brief This callback is called when an object did get ready for reading. * * @note If the object is a subclass of @ref OFStream and * @ref OFStream#tryReadLine or @ref OFStream#tryReadUntilDelimiter: * has been called on the stream, this callback will not be called again * until new data has been received, even though there is still data in * the cache. The reason for this is to prevent spinning in a loop when * there is an incomplete string in the cache. Once the string has been * completed, the callback will be called again as long there is data in * the cache. * * @param object The object which did become ready for reading */ - (void)objectIsReadyForReading: (id)object; /** * @brief This callback is called when an object did get ready for writing. * * @param object The object which did become ready for writing */ - (void)objectIsReadyForWriting: (id)object; #if defined(OF_AMIGAOS) || defined(DOXYGEN) /** * @brief This callback is called when an Exec Signal was received. * * @note This is only available on AmigaOS! */ - (void)execSignalWasReceived: (ULONG)signalMask; #endif |
︙ | ︙ | |||
117 118 119 120 121 122 123 | @interface OFKernelEventObserver: OFObject { OFMutableArray OF_GENERIC(id <OFReadyForReadingObserving>) *_readObjects; OFMutableArray OF_GENERIC(id <OFReadyForWritingObserving>) *_writeObjects; id <OFKernelEventObserverDelegate> _Nullable _delegate; | | | | | | | | | | 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | @interface OFKernelEventObserver: OFObject { OFMutableArray OF_GENERIC(id <OFReadyForReadingObserving>) *_readObjects; OFMutableArray OF_GENERIC(id <OFReadyForWritingObserving>) *_writeObjects; id <OFKernelEventObserverDelegate> _Nullable _delegate; # if defined(OF_AMIGAOS) struct Task *_waitingTask; ULONG _cancelSignal; # elif defined(OF_HAVE_PIPE) int _cancelFD[2]; # else OFSocketHandle _cancelFD[2]; struct sockaddr_in _cancelAddr; # endif # ifdef OF_AMIGAOS ULONG _execSignalMask; # endif OF_RESERVE_IVARS(OFKernelEventObserver, 4) } /** * @brief The delegate for the OFKernelEventObserver. */ @property OF_NULLABLE_PROPERTY (assign, nonatomic) id <OFKernelEventObserverDelegate> delegate; # if defined(OF_AMIGAOS) || defined(DOXYGEN) /** * @brief A mask of Exec Signals to wait for. * * @note This is only available on AmigaOS! */ @property (nonatomic) ULONG execSignalMask; # endif /** * @brief Creates a new OFKernelEventObserver. * * @return A new, autoreleased OFKernelEventObserver */ + (instancetype)observer; |
︙ | ︙ |
Modified src/OFKernelEventObserver.m from [8d008316fd] to [c5333a4c56].
1 | /* | | | | | | > | < | < | > | > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #import "OFKernelEventObserver.h" #import "OFArray.h" |
︙ | ︙ | |||
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | #endif #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFOutOfRangeException.h" #ifdef OF_AMIGAOS # include <proto/exec.h> #endif @implementation OFKernelEventObserver @synthesize delegate = _delegate; #ifdef OF_AMIGAOS @synthesize execSignalMask = _execSignalMask; #endif | > > | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | #endif #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFOutOfRangeException.h" #ifdef OF_AMIGAOS # define Class IntuitionClass # include <proto/exec.h> # undef Class #endif @implementation OFKernelEventObserver @synthesize delegate = _delegate; #ifdef OF_AMIGAOS @synthesize execSignalMask = _execSignalMask; #endif |
︙ | ︙ | |||
202 203 204 205 206 207 208 | - (bool)of_processReadBuffers { void *pool = objc_autoreleasePoolPush(); bool foundInReadBuffer = false; for (id object in [[_readObjects copy] autorelease]) { | | | > > > > | | > | 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | - (bool)of_processReadBuffers { void *pool = objc_autoreleasePoolPush(); bool foundInReadBuffer = false; for (id object in [[_readObjects copy] autorelease]) { void *pool2; if (![object isKindOfClass: [OFStream class]]) continue; pool2 = objc_autoreleasePoolPush(); if ([object hasDataInReadBuffer] && (![object of_isWaitingForDelimiter] || [object lowlevelHasDataInReadBuffer])) { if ([_delegate respondsToSelector: @selector(objectIsReadyForReading:)]) [_delegate objectIsReadyForReading: object]; foundInReadBuffer = true; } |
︙ | ︙ |
Modified src/OFKeyValueCoding.h from [3568d90874] to [cc9621596c].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "macros.h" @class OFString; OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ |
Modified src/OFKqueueKernelEventObserver.h from [79cac968ba] to [d45e5a6763].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFKernelEventObserver.h" OF_ASSUME_NONNULL_BEGIN @class OFMutableArray OF_GENERIC(ObjectType); |
︙ | ︙ |
Modified src/OFKqueueKernelEventObserver.m from [ef6117c8da] to [267d82e6bf].
1 | /* | | | | | | > > > > | < > | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #ifdef HAVE_FCNTL_H # include <fcntl.h> #endif #include "unistd_wrapper.h" |
︙ | ︙ | |||
184 185 186 187 188 189 190 | @throw [OFObserveKernelEventsFailedException exceptionWithObserver: self errNo: (int)eventList[i].data]; if (eventList[i].ident == (uintptr_t)_cancelFD[0]) { char buffer; | | | 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | @throw [OFObserveKernelEventsFailedException exceptionWithObserver: self errNo: (int)eventList[i].data]; if (eventList[i].ident == (uintptr_t)_cancelFD[0]) { char buffer; OFAssert(eventList[i].filter == EVFILT_READ); OFEnsure(read(_cancelFD[0], &buffer, 1) == 1); continue; } pool = objc_autoreleasePoolPush(); |
︙ | ︙ | |||
206 207 208 209 210 211 212 | case EVFILT_WRITE: if ([_delegate respondsToSelector: @selector(objectIsReadyForWriting:)]) [_delegate objectIsReadyForWriting: (id)eventList[i].udata]; break; default: | | | 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | case EVFILT_WRITE: if ([_delegate respondsToSelector: @selector(objectIsReadyForWriting:)]) [_delegate objectIsReadyForWriting: (id)eventList[i].udata]; break; default: OFAssert(0); } objc_autoreleasePoolPop(pool); } } @end |
Modified src/OFLHAArchive.h from [038ec719a6] to [c7a09b4ed8].
1 | /* | | | | | | > > > > | < > | < | | > > | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFLHAArchiveEntry.h" #import "OFString.h" OF_ASSUME_NONNULL_BEGIN @class OFIRI; @class OFStream; /** * @class OFLHAArchive OFLHAArchive.h ObjFW/OFLHAArchive.h * * @brief A class for accessing and manipulating LHA files. */ OF_SUBCLASSING_RESTRICTED @interface OFLHAArchive: OFObject { OFStream *_stream; uint_least8_t _mode; OFStringEncoding _encoding; OFLHAArchiveEntry *_Nullable _currentEntry; #ifdef OF_LHA_ARCHIVE_M @public #endif OFStream *_Nullable _lastReturnedStream; @protected bool _hasWritten; } /** * @brief The encoding to use for the archive. Defaults to UTF-8. */ @property (nonatomic) OFStringEncoding encoding; /** * @brief Creates a new OFLHAArchive object with the specified stream. * * @param stream A stream from which the LHA archive will be read. * For read and append mode, this needs to be an OFSeekableStream. * @param mode The mode for the LHA file. Valid modes are "r" for reading, * "w" for creating a new file and "a" for appending to an existing * archive. * @return A new, autoreleased OFLHAArchive */ + (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode; /** * @brief Creates a new OFLHAArchive object with the specified file. * * @param IRI The IRI to the LHA file * @param mode The mode for the LHA file. Valid modes are "r" for reading, * "w" for creating a new file and "a" for appending to an existing * archive. * @return A new, autoreleased OFLHAArchive */ + (instancetype)archiveWithIRI: (OFIRI *)IRI mode: (OFString *)mode; /** * @brief Creates an IRI for accessing the specified file within the specified * LHA archive. * * @param path The path of the file within the archive * @param IRI The IRI of the archive * @return An IRI for accessing the specified file within the specified LHA * archive */ + (OFIRI *)IRIForFilePath: (OFString *)path inArchiveWithIRI: (OFIRI *)IRI; - (instancetype)init OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFLHAArchive object with the * specified stream. * |
︙ | ︙ | |||
96 97 98 99 100 101 102 | - (instancetype)initWithStream: (OFStream *)stream mode: (OFString *)mode OF_DESIGNATED_INITIALIZER; /** * @brief Initializes an already allocated OFLHAArchive object with the * specified file. * | | | | 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | - (instancetype)initWithStream: (OFStream *)stream mode: (OFString *)mode OF_DESIGNATED_INITIALIZER; /** * @brief Initializes an already allocated OFLHAArchive object with the * specified file. * * @param IRI The IRI to the LHA file * @param mode The mode for the LHA file. Valid modes are "r" for reading, * "w" for creating a new file and "a" for appending to an existing * archive. * @return An initialized OFLHAArchive */ - (instancetype)initWithIRI: (OFIRI *)IRI mode: (OFString *)mode; /** * @brief Returns the next entry from the LHA archive or `nil` if all entries * have been read. * * @note This is only available in read mode. * |
︙ | ︙ | |||
148 149 150 151 152 153 154 | * * @note The uncompressed size, compressed size and CRC16 of the specified * entry are ignored. * * @note The returned stream conforms to @ref OFReadyForWritingObserving if the * underlying stream does so, too. * | | | | 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | * * @note The uncompressed size, compressed size and CRC16 of the specified * entry are ignored. * * @note The returned stream conforms to @ref OFReadyForWritingObserving if the * underlying stream does so, too. * * @warning Calling @ref streamForWritingEntry: will invalidate all streams * returned by @ref streamForReadingCurrentEntry or * @ref streamForWritingEntry:! Reading from or writing to an * invalidated stream will throw an @ref OFReadFailedException or * @ref OFWriteFailedException! * * @param entry The entry for which a stream for writing should be returned * @return A stream for writing the specified entry */ |
︙ | ︙ |
Modified src/OFLHAArchive.m from [fa04eb799a] to [3329a01d33].
1 | /* | | | | | | > > > > | < > | | > > > < < > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #define OF_LHA_ARCHIVE_M #include "config.h" #include <errno.h> #import "OFLHAArchive.h" #import "OFLHAArchiveEntry.h" #import "OFLHAArchiveEntry+Private.h" #import "OFArchiveIRIHandler.h" #import "OFCRC16.h" #import "OFIRI.h" #import "OFIRIHandler.h" #import "OFKernelEventObserver.h" #import "OFLHADecompressingStream.h" #import "OFSeekableStream.h" #import "OFStream.h" #import "OFString.h" #import "OFChecksumMismatchException.h" #import "OFInvalidArgumentException.h" #import "OFNotImplementedException.h" #import "OFNotOpenException.h" #import "OFOutOfRangeException.h" #import "OFTruncatedDataException.h" #import "OFUnsupportedVersionException.h" #import "OFWriteFailedException.h" enum { modeRead, modeWrite, modeAppend }; |
︙ | ︙ | |||
66 67 68 69 70 71 72 | @interface OFLHAArchiveFileWriteStream: OFStream <OFReadyForWritingObserving> { OFLHAArchive *_archive; OFMutableLHAArchiveEntry *_entry; OFStringEncoding _encoding; OFSeekableStream *_stream; OFStreamOffset _headerOffset; | | | | | | | 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | @interface OFLHAArchiveFileWriteStream: OFStream <OFReadyForWritingObserving> { OFLHAArchive *_archive; OFMutableLHAArchiveEntry *_entry; OFStringEncoding _encoding; OFSeekableStream *_stream; OFStreamOffset _headerOffset; uint64_t _bytesWritten; uint16_t _CRC16; } - (instancetype)of_initWithArchive: (OFLHAArchive *)archive stream: (OFSeekableStream *)stream entry: (OFLHAArchiveEntry *)entry encoding: (OFStringEncoding)encoding; @end @implementation OFLHAArchive @synthesize encoding = _encoding; + (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode { return [[[self alloc] initWithStream: stream mode: mode] autorelease]; } + (instancetype)archiveWithIRI: (OFIRI *)IRI mode: (OFString *)mode { return [[[self alloc] initWithIRI: IRI mode: mode] autorelease]; } + (OFIRI *)IRIForFilePath: (OFString *)path inArchiveWithIRI: (OFIRI *)IRI { return OFArchiveIRIHandlerIRIForFileInArchive(@"lha", path, IRI); } - (instancetype)init { OF_INVALID_INIT_METHOD } |
︙ | ︙ | |||
120 121 122 123 124 125 126 | @throw [OFInvalidArgumentException exception]; if ((_mode == modeWrite || _mode == modeAppend) && ![_stream isKindOfClass: [OFSeekableStream class]]) @throw [OFInvalidArgumentException exception]; if (_mode == modeAppend) | > > > > > > | < < | | | | 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | @throw [OFInvalidArgumentException exception]; if ((_mode == modeWrite || _mode == modeAppend) && ![_stream isKindOfClass: [OFSeekableStream class]]) @throw [OFInvalidArgumentException exception]; if (_mode == modeAppend) /* * Only works with properly zero-terminated files that * have no trailing garbage. Unfortunately there is no * good way to check for this other than reading the * entire archive. */ [(OFSeekableStream *)_stream seekToOffset: -1 whence: OFSeekEnd]; } @catch (id e) { [self release]; @throw e; } return self; } - (instancetype)initWithIRI: (OFIRI *)IRI mode: (OFString *)mode { void *pool = objc_autoreleasePoolPush(); OFStream *stream; @try { if ([mode isEqual: @"a"]) stream = [OFIRIHandler openItemAtIRI: IRI mode: @"r+"]; else stream = [OFIRIHandler openItemAtIRI: IRI mode: mode]; } @catch (id e) { [self release]; @throw e; } self = [self initWithStream: stream mode: mode]; |
︙ | ︙ | |||
171 172 173 174 175 176 177 178 179 180 181 182 183 184 | - (OFLHAArchiveEntry *)nextEntry { char header[21]; size_t headerLen; if (_mode != modeRead) @throw [OFInvalidArgumentException exception]; [_currentEntry release]; _currentEntry = nil; [(OFLHAArchiveFileReadStream *)_lastReturnedStream of_skip]; @try { [_lastReturnedStream close]; | > > > > > > > > > > > > > | 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | - (OFLHAArchiveEntry *)nextEntry { char header[21]; size_t headerLen; if (_mode != modeRead) @throw [OFInvalidArgumentException exception]; if (_currentEntry != nil && _lastReturnedStream == nil) { /* * No read stream was created since the last call to * -[nextEntry]. Create it so that we can properly skip the * data. */ void *pool = objc_autoreleasePoolPush(); [self streamForReadingCurrentEntry]; objc_autoreleasePoolPop(pool); } [_currentEntry release]; _currentEntry = nil; [(OFLHAArchiveFileReadStream *)_lastReturnedStream of_skip]; @try { [_lastReturnedStream close]; |
︙ | ︙ | |||
198 199 200 201 202 203 204 | @throw [OFTruncatedDataException exception]; } headerLen += [_stream readIntoBuffer: header + headerLen length: 21 - headerLen]; } | > > > > > > > > > > | | 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | @throw [OFTruncatedDataException exception]; } headerLen += [_stream readIntoBuffer: header + headerLen length: 21 - headerLen]; } /* * Some archives have trailing garbage after the single byte 0 * termination. However, a level 2 header uses 2 bytes for the size, so * could just have a header size that is a multiple of 256. Therefore, * consider it only the end of the archive if what follows would not be * a level 2 header. */ if (header[0] == 0 && header[20] != 2) return nil; _currentEntry = [[OFLHAArchiveEntry alloc] of_initWithHeader: header stream: _stream encoding: _encoding]; return _currentEntry; } |
︙ | ︙ | |||
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | _lastReturnedStream = nil; _lastReturnedStream = [[[OFLHAArchiveFileWriteStream alloc] of_initWithArchive: self stream: (OFSeekableStream *)_stream entry: entry encoding: _encoding] autorelease]; return _lastReturnedStream; } - (void)close { if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; @try { [_lastReturnedStream close]; } @catch (OFNotOpenException *e) { /* Might have already been closed by the user - that's fine. */ } _lastReturnedStream = nil; [_stream release]; _stream = nil; } @end | > > > > > > | 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 | _lastReturnedStream = nil; _lastReturnedStream = [[[OFLHAArchiveFileWriteStream alloc] of_initWithArchive: self stream: (OFSeekableStream *)_stream entry: entry encoding: _encoding] autorelease]; _hasWritten = true; return _lastReturnedStream; } - (void)close { if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; @try { [_lastReturnedStream close]; } @catch (OFNotOpenException *e) { /* Might have already been closed by the user - that's fine. */ } /* LHA archives should be terminated with a header of size 0 */ if (_hasWritten) [_stream writeBuffer: "" length: 1]; _lastReturnedStream = nil; [_stream release]; _stream = nil; } @end |
︙ | ︙ | |||
302 303 304 305 306 307 308 309 | distanceBits: 5 dictionaryBits: 16]; else if ([compressionMethod isEqual: @"-lh7-"]) _decompressedStream = [[OFLHADecompressingStream alloc] of_initWithStream: stream distanceBits: 5 dictionaryBits: 17]; else | > > > > > > > > > > > | | | 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 | distanceBits: 5 dictionaryBits: 16]; else if ([compressionMethod isEqual: @"-lh7-"]) _decompressedStream = [[OFLHADecompressingStream alloc] of_initWithStream: stream distanceBits: 5 dictionaryBits: 17]; else if ([compressionMethod isEqual: @"-lhx-"]) _decompressedStream = [[OFLHADecompressingStream alloc] of_initWithStream: stream distanceBits: 5 dictionaryBits: 20]; else if ([compressionMethod isEqual: @"-lh0-"] || [compressionMethod isEqual: @"-lhd-"] || [compressionMethod isEqual: @"-lz4-"] || [compressionMethod isEqual: @"-pm0-"]) _decompressedStream = [stream retain]; else @throw [OFUnsupportedVersionException exceptionWithVersion: compressionMethod]; _entry = [entry copy]; _toRead = entry.uncompressedSize; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { if (_stream != nil && _decompressedStream != nil) [self close]; [_entry release]; if (_archive->_lastReturnedStream == self) _archive->_lastReturnedStream = nil; |
︙ | ︙ | |||
364 365 366 367 368 369 370 | _CRC16 = OFCRC16(_CRC16, buffer, ret); if (_toRead == 0) { _atEndOfStream = true; if (_CRC16 != _entry.CRC16) { OFString *actualChecksum = [OFString stringWithFormat: | | | | 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 | _CRC16 = OFCRC16(_CRC16, buffer, ret); if (_toRead == 0) { _atEndOfStream = true; if (_CRC16 != _entry.CRC16) { OFString *actualChecksum = [OFString stringWithFormat: @"%04" @PRIX16, _CRC16]; OFString *expectedChecksum = [OFString stringWithFormat: @"%04" @PRIX16, _entry.CRC16]; @throw [OFChecksumMismatchException exceptionWithActualChecksum: actualChecksum expectedChecksum: expectedChecksum]; } } |
︙ | ︙ | |||
503 504 505 506 507 508 509 | } - (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length { if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; | | | | | 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 | } - (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length { if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; if (UINT64_MAX - _bytesWritten < length) @throw [OFOutOfRangeException exception]; @try { [_stream writeBuffer: buffer length: length]; } @catch (OFWriteFailedException *e) { OFEnsure(e.bytesWritten <= length); _bytesWritten += (uint64_t)e.bytesWritten; _CRC16 = OFCRC16(_CRC16, buffer, e.bytesWritten); if (e.errNo == EWOULDBLOCK || e.errNo == EAGAIN) return e.bytesWritten; @throw e; } _bytesWritten += (uint64_t)length; _CRC16 = OFCRC16(_CRC16, buffer, length); return length; } - (bool)lowlevelIsAtEndOfStream { |
︙ | ︙ |
Modified src/OFLHAArchiveEntry+Private.h from [521b95b2fc] to [d5c3ed060e].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFLHAArchive.h" OF_ASSUME_NONNULL_BEGIN @interface OFLHAArchiveEntry () |
︙ | ︙ |
Modified src/OFLHAArchiveEntry.h from [89ea23a8c1] to [0e1c6357f2].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFArchiveEntry.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ |
Modified src/OFLHAArchiveEntry.m from [b338459827] to [14cbf19d20].
1 | /* | | | | | | > > > > | < > | > < > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "OFLHAArchiveEntry.h" #import "OFLHAArchiveEntry+Private.h" #import "OFArray.h" #import "OFCRC16.h" #import "OFData.h" #import "OFDate.h" #import "OFNumber.h" #import "OFSeekableStream.h" #import "OFStream.h" #import "OFString.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFOutOfRangeException.h" #import "OFUnsupportedVersionException.h" static OFDate * parseMSDOSDate(uint32_t MSDOSDate) { uint16_t year = ((MSDOSDate & 0xFE000000) >> 25) + 1980; uint8_t month = (MSDOSDate & 0x1E00000) >> 21; uint8_t day = (MSDOSDate & 0x1F); uint8_t hour = (MSDOSDate & 0xF800) >> 11; uint8_t minute = (MSDOSDate & 0x7E0) >> 5; uint8_t second = (MSDOSDate & 0x1F) << 1; OFString *dateString; dateString = [OFString stringWithFormat: @"%04u-%02u-%02u %02u:%02u:%02u", year, month, day, hour, minute, second]; return [OFDate dateWithLocalDateString: dateString format: @"%Y-%m-%d %H:%M:%S"]; } @implementation OFLHAArchiveEntry static void parseFileNameExtension(OFLHAArchiveEntry *entry, OFData *extension, OFStringEncoding encoding) { [entry->_fileName release]; entry->_fileName = nil; |
︙ | ︙ | |||
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | [entry->_modificationDate release]; entry->_modificationDate = nil; entry->_modificationDate = [[OFDate alloc] initWithTimeIntervalSince1970: modificationDate]; } static bool parseExtension(OFLHAArchiveEntry *entry, OFData *extension, OFStringEncoding encoding, bool allowFileName) { void (*function)(OFLHAArchiveEntry *, OFData *, OFStringEncoding) = NULL; switch (*(char *)[extension itemAtIndex: 0]) { case 0x01: if (allowFileName) function = parseFileNameExtension; break; case 0x02: function = parseDirectoryNameExtension; break; case 0x3F: function = parseCommentExtension; break; case 0x50: function = parsePermissionsExtension; break; case 0x51: function = parseGIDUIDExtension; break; case 0x52: | > > > > > > > > > > > > > > > > > > > | 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | [entry->_modificationDate release]; entry->_modificationDate = nil; entry->_modificationDate = [[OFDate alloc] initWithTimeIntervalSince1970: modificationDate]; } static void parseFileSizeExtension(OFLHAArchiveEntry *entry, OFData *extension, OFStringEncoding encoding) { uint64_t tmp; if (extension.count != 17) @throw [OFInvalidFormatException exception]; memcpy(&tmp, (char *)extension.items + 1, 8); entry->_compressedSize = OFFromLittleEndian64(tmp); memcpy(&tmp, (char *)extension.items + 9, 8); entry->_uncompressedSize = OFFromLittleEndian64(tmp); } static bool parseExtension(OFLHAArchiveEntry *entry, OFData *extension, OFStringEncoding encoding, bool allowFileName) { void (*function)(OFLHAArchiveEntry *, OFData *, OFStringEncoding) = NULL; switch (*(char *)[extension itemAtIndex: 0]) { case 0x01: if (allowFileName) function = parseFileNameExtension; break; case 0x02: function = parseDirectoryNameExtension; break; case 0x3F: function = parseCommentExtension; break; case 0x42: function = parseFileSizeExtension; break; case 0x50: function = parsePermissionsExtension; break; case 0x51: function = parseGIDUIDExtension; break; case 0x52: |
︙ | ︙ | |||
238 239 240 241 242 243 244 | if (function == NULL) return false; function(entry, extension, encoding); return true; } | | > > > | > > > > > | | | > | > > > | > > > > | 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | if (function == NULL) return false; function(entry, extension, encoding); return true; } static size_t readExtensions(OFLHAArchiveEntry *entry, OFStream *stream, OFStringEncoding encoding, bool allowFileName) { size_t consumed = 0; for (;;) { uint32_t size; OFData *extension; if (entry->_headerLevel == 3) { size = [stream readLittleEndianInt32]; consumed += 4; } else { size = [stream readLittleEndianInt16]; consumed += 2; } if (size == 0) break; if (size < 2 || (entry->_headerLevel == 3 && size < 4)) @throw [OFInvalidFormatException exception]; extension = [stream readDataWithCount: size - (entry->_headerLevel == 3 ? 4 : 2)]; consumed += extension.count; if (!parseExtension(entry, extension, encoding, allowFileName)) [entry->_extensions addObject: extension]; if (entry->_headerLevel == 1) { if (entry->_compressedSize < size) @throw [OFInvalidFormatException exception]; entry->_compressedSize -= size; } } return consumed; } static void getFileNameAndDirectoryName(OFLHAArchiveEntry *entry, OFStringEncoding encoding, const char **fileName, size_t *fileNameLength, const char **directoryName, size_t *directoryNameLength) { |
︙ | ︙ | |||
331 332 333 334 335 336 337 | encoding: (OFStringEncoding)encoding { self = [super init]; @try { uint32_t date; | < < < < < < < < < > > > > > > > > > > > > > > > > > > | > > > > > > > | > > > > | > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > | 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 | encoding: (OFStringEncoding)encoding { self = [super init]; @try { uint32_t date; memcpy(&_compressedSize, header + 7, 4); _compressedSize = OFFromLittleEndian32((uint32_t)_compressedSize); memcpy(&_uncompressedSize, header + 11, 4); _uncompressedSize = OFFromLittleEndian32((uint32_t)_uncompressedSize); memcpy(&date, header + 15, 4); date = OFFromLittleEndian32(date); _headerLevel = header[20]; _extensions = [[OFMutableArray alloc] init]; switch (_headerLevel) { case 0: case 1:; void *pool = objc_autoreleasePoolPush(); uint8_t extendedAreaSize; uint8_t fileNameLength; OFString *tmp; if (header[0] < (21 - 2) + 1 + 2) @throw [OFInvalidFormatException exception]; _modificationDate = [parseMSDOSDate(date) retain]; fileNameLength = [stream readInt8]; tmp = [stream readStringWithLength: fileNameLength encoding: encoding]; tmp = [tmp stringByReplacingOccurrencesOfString: @"\\" withString: @"/"]; _fileName = [tmp copy]; _CRC16 = [stream readLittleEndianInt16]; extendedAreaSize = header[0] - (21 - 2) - 1 - fileNameLength - 2; if (_headerLevel == 1) { if (extendedAreaSize < 3) @throw [OFInvalidFormatException exception]; _operatingSystemIdentifier = [stream readInt8]; /* * 1 for the operating system identifier, 2 * because we don't want to skip the size of * the next extended header. */ extendedAreaSize -= 1 + 2; } /* Skip extended area */ if ([stream isKindOfClass: [OFSeekableStream class]]) [(OFSeekableStream *)stream seekToOffset: extendedAreaSize whence: OFSeekCurrent]; else { char buffer[256]; while (extendedAreaSize > 0) extendedAreaSize -= [stream readIntoBuffer: buffer length: extendedAreaSize]; } if (_headerLevel == 1) readExtensions(self, stream, encoding, false); objc_autoreleasePoolPop(pool); break; case 2: case 3:; uint32_t padding = 0; _modificationDate = [[OFDate alloc] initWithTimeIntervalSince1970: date]; _CRC16 = [stream readLittleEndianInt16]; _operatingSystemIdentifier = [stream readInt8]; if (_headerLevel == 3) /* Size of entire header */ padding = [stream readLittleEndianInt32]; else padding = (header[1] << 8) | header[0]; /* * 21 for header, 2 for CRC16, 1 for operating system * identifier. */ padding -= 21 + 2 + 1; padding -= readExtensions(self, stream, encoding, true); /* Skip padding */ if ([stream isKindOfClass: [OFSeekableStream class]]) [(OFSeekableStream *)stream seekToOffset: padding whence: OFSeekCurrent]; else { while (padding > 0) { char buffer[512]; size_t min = padding; if (min > 512) min = 512; padding -= [stream readIntoBuffer: buffer length: min]; } } break; default:; OFString *version = [OFString stringWithFormat: @"%u", _headerLevel]; @throw [OFUnsupportedVersionException exceptionWithVersion: version]; } if (_fileName == nil) @throw [OFInvalidFormatException exception]; _compressionMethod = [[OFString alloc] initWithCString: header + 2 encoding: OFStringEncodingASCII length: 5]; [_extensions makeImmutable]; } @catch (id e) { [self release]; @throw e; } |
︙ | ︙ | |||
554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 | { void *pool = objc_autoreleasePoolPush(); OFMutableData *data = [OFMutableData dataWithCapacity: 24]; const char *fileName, *directoryName; size_t fileNameLength, directoryNameLength; uint16_t tmp16; uint32_t tmp32; size_t headerSize; if ([_compressionMethod cStringLengthWithEncoding: OFStringEncodingASCII] != 5) @throw [OFInvalidArgumentException exception]; getFileNameAndDirectoryName(self, encoding, &fileName, &fileNameLength, &directoryName, &directoryNameLength); if (fileNameLength > UINT16_MAX - 3 || directoryNameLength > UINT16_MAX - 3 || | > | | 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 | { void *pool = objc_autoreleasePoolPush(); OFMutableData *data = [OFMutableData dataWithCapacity: 24]; const char *fileName, *directoryName; size_t fileNameLength, directoryNameLength; uint16_t tmp16; uint32_t tmp32; uint64_t tmp64; size_t headerSize; if ([_compressionMethod cStringLengthWithEncoding: OFStringEncodingASCII] != 5) @throw [OFInvalidArgumentException exception]; getFileNameAndDirectoryName(self, encoding, &fileName, &fileNameLength, &directoryName, &directoryNameLength); if (fileNameLength > UINT16_MAX - 3 || directoryNameLength > UINT16_MAX - 3 || _compressedSize > UINT64_MAX || _uncompressedSize > UINT64_MAX) @throw [OFOutOfRangeException exception]; /* Length. Filled in after we're done. */ [data increaseCountBy: 2]; [data addItems: [_compressionMethod cStringWithEncoding: OFStringEncodingASCII] |
︙ | ︙ | |||
630 631 632 633 634 635 636 637 638 639 640 641 642 643 | tmp16 = OFToLittleEndian16((uint16_t)fileCommentLength + 3); [data addItems: &tmp16 count: sizeof(tmp16)]; [data addItem: "\x3F"]; [data addItems: [_fileComment cStringWithEncoding: encoding] count: fileCommentLength]; } if (_POSIXPermissions != nil) { tmp16 = OFToLittleEndian16(5); [data addItems: &tmp16 count: sizeof(tmp16)]; [data addItem: "\x50"]; tmp16 = OFToLittleEndian16(_POSIXPermissions.unsignedShortValue); | > > > > > > > > > > > > > > | 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 | tmp16 = OFToLittleEndian16((uint16_t)fileCommentLength + 3); [data addItems: &tmp16 count: sizeof(tmp16)]; [data addItem: "\x3F"]; [data addItems: [_fileComment cStringWithEncoding: encoding] count: fileCommentLength]; } /* * Always include the file size extension, as the header can be written * with size 0 initially and then rewritten with the actual size in * case the data to be archived is being streamed - but for that we * need to make sure we always have the space. */ tmp16 = OFToLittleEndian16(19); [data addItems: &tmp16 count: sizeof(tmp16)]; [data addItem: "\x42"]; tmp64 = OFToLittleEndian64(_compressedSize); [data addItems: &tmp64 count: sizeof(tmp64)]; tmp64 = OFToLittleEndian64(_uncompressedSize); [data addItems: &tmp64 count: sizeof(tmp64)]; if (_POSIXPermissions != nil) { tmp16 = OFToLittleEndian16(5); [data addItems: &tmp16 count: sizeof(tmp16)]; [data addItem: "\x50"]; tmp16 = OFToLittleEndian16(_POSIXPermissions.unsignedShortValue); |
︙ | ︙ | |||
703 704 705 706 707 708 709 710 711 712 713 714 715 716 | [data addItems: &tmp16 count: sizeof(tmp16)]; [data addItems: extension.items count: extension.count]; } /* Zero-length extension to terminate */ [data increaseCountBy: 2]; headerSize = data.count; if (headerSize > UINT16_MAX) @throw [OFOutOfRangeException exception]; /* Now fill in the size and CRC16 for the entire header */ tmp16 = OFToLittleEndian16(headerSize); | > > > > > > > > | 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 | [data addItems: &tmp16 count: sizeof(tmp16)]; [data addItems: extension.items count: extension.count]; } /* Zero-length extension to terminate */ [data increaseCountBy: 2]; /* * Some implementations only check the first byte to see if the end of * the archive has been reached, which is 0 for every multiple of 256. * Add one byte of padding to avoid this. */ if ((data.count & 0xFF) == 0) [data increaseCountBy: 1]; headerSize = data.count; if (headerSize > UINT16_MAX) @throw [OFOutOfRangeException exception]; /* Now fill in the size and CRC16 for the entire header */ tmp16 = OFToLittleEndian16(headerSize); |
︙ | ︙ |
Modified src/OFLHADecompressingStream.h from [1061027b73] to [0efe4a0086].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFStream.h" #import "OFHuffmanTree.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ |
Modified src/OFLHADecompressingStream.m from [1c43fdd671] to [83126d0266].
1 | /* | | | | | | > > > > | < > | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFLHADecompressingStream.h" #import "OFKernelEventObserver.h" #import "OFHuffmanTree.h" #import "OFInvalidFormatException.h" #import "OFNotOpenException.h" |
︙ | ︙ | |||
46 47 48 49 50 51 52 | @synthesize bytesConsumed = _bytesConsumed; static OF_INLINE bool tryReadBits(OFLHADecompressingStream *stream, uint16_t *bits, uint8_t count) { uint16_t ret = stream->_savedBits; | | | 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | @synthesize bytesConsumed = _bytesConsumed; static OF_INLINE bool tryReadBits(OFLHADecompressingStream *stream, uint16_t *bits, uint8_t count) { uint16_t ret = stream->_savedBits; OFAssert(stream->_savedBitsLength < count); for (uint_fast8_t i = stream->_savedBitsLength; i < count; i++) { if OF_UNLIKELY (stream->_bitIndex == 8) { if OF_LIKELY (stream->_bufferIndex < stream->_bufferLength) stream->_byte = stream->_buffer[stream->_bufferIndex++]; |
︙ | ︙ | |||
505 506 507 508 509 510 511 | - (int)fileDescriptorForReading { return ((id <OFReadyForReadingObserving>)_stream) .fileDescriptorForReading; } | | | | 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 | - (int)fileDescriptorForReading { return ((id <OFReadyForReadingObserving>)_stream) .fileDescriptorForReading; } - (bool)lowlevelHasDataInReadBuffer { return (_stream.hasDataInReadBuffer || _bufferLength - _bufferIndex > 0); } - (void)close { if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; |
︙ | ︙ |
Added src/OFLOCDNSResourceRecord.h version [b189b794be].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFDNSResourceRecord.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFLOCDNSResourceRecord \ * OFDNSResourceRecord.h ObjFW/OFDNSResourceRecord.h * * @brief A class representing an LOC DNS resource record. */ OF_SUBCLASSING_RESTRICTED @interface OFLOCDNSResourceRecord: OFDNSResourceRecord { uint8_t _size, _horizontalPrecision, _verticalPrecision; uint32_t _latitude, _longitude, _altitude; } /** * @brief The diameter in centimeters of a sphere enclosing the position, * encoded as per RFC 1876. */ @property (readonly, nonatomic) uint8_t size; /** * @brief The horizontal precision in centimeters, encoded as per RFC 1876. */ @property (readonly, nonatomic) uint8_t horizontalPrecision; /** * @brief The vertical precision in centimeters, encoded as per RFC 1876. */ @property (readonly, nonatomic) uint8_t verticalPrecision; /** * @brief The latitude in thousands of a second of an arc. */ @property (readonly, nonatomic) uint32_t latitude; /** * @brief The longitude in thousands of a second of an arc. */ @property (readonly, nonatomic) uint32_t longitude; /** * @brief The altitude in centimeters from a base of 100000 meters below the * GPS reference. */ @property (readonly, nonatomic) uint32_t altitude; - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFLOCDNSResourceRecord with the * specified name, class, domain name and time to live. * * @param name The name for the resource record * @param DNSClass The class code for the resource record * @param size The diameter in centimeters of a sphere enclosing the position, * encoded as per RFC 1876 * @param horizontalPrecision The horizontal precision in centimeters, encoded * as per RFC 1876 * @param verticalPrecision The vertical precision in centimeters, encoded as * per RFC 1876 * @param latitude The latitude in thousands of a second of an arc * @param longitude The longitude in thousands of a second of an arc * @param altitude The altitude in centimeters from a base of 100000 meters * below the GPS reference * @param TTL The time to live for the resource record * @return An initialized OFLOCDNSResourceRecord */ - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass size: (uint8_t)size horizontalPrecision: (uint8_t)horizontalPrecision verticalPrecision: (uint8_t)verticalPrecision latitude: (uint32_t)latitude longitude: (uint32_t)longitude altitude: (uint32_t)altitude TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END |
Added src/OFLOCDNSResourceRecord.m version [97c53e7fef].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFLOCDNSResourceRecord.h" @implementation OFLOCDNSResourceRecord @synthesize size = _size, horizontalPrecision = _horizontalPrecision; @synthesize verticalPrecision = _verticalPrecision, latitude = _latitude; @synthesize longitude = _longitude, altitude = _altitude; - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass size: (uint8_t)size horizontalPrecision: (uint8_t)horizontalPrecision verticalPrecision: (uint8_t)verticalPrecision latitude: (uint32_t)latitude longitude: (uint32_t)longitude altitude: (uint32_t)altitude TTL: (uint32_t)TTL { self = [super initWithName: name DNSClass: DNSClass recordType: OFDNSRecordTypeLOC TTL: TTL]; @try { _size = size; _horizontalPrecision = horizontalPrecision; _verticalPrecision = verticalPrecision; _latitude = latitude; _longitude = longitude; _altitude = altitude; } @catch (id e) { [self release]; @throw e; } return self; } - (bool)isEqual: (id)object { OFLOCDNSResourceRecord *record; if (object == self) return true; if (![object isKindOfClass: [OFLOCDNSResourceRecord class]]) return false; record = object; if (record->_name != _name && ![record->_name isEqual: _name]) return false; if (record->_DNSClass != _DNSClass) return false; if (record->_recordType != _recordType) return false; if (record->_size != _size) return false; if (record->_horizontalPrecision != _horizontalPrecision) return false; if (record->_verticalPrecision != _verticalPrecision) return false; if (record->_latitude != _latitude) return false; if (record->_longitude != _longitude) return false; if (record->_altitude != _altitude) return false; return true; } - (unsigned long)hash { unsigned long hash; OFHashInit(&hash); OFHashAddHash(&hash, _name.hash); OFHashAddByte(&hash, _DNSClass >> 8); OFHashAddByte(&hash, _DNSClass); OFHashAddByte(&hash, _recordType >> 8); OFHashAddByte(&hash, _recordType); OFHashAddByte(&hash, _size); OFHashAddByte(&hash, _horizontalPrecision); OFHashAddByte(&hash, _verticalPrecision); OFHashAddByte(&hash, _latitude >> 24); OFHashAddByte(&hash, _latitude >> 16); OFHashAddByte(&hash, _latitude >> 8); OFHashAddByte(&hash, _latitude); OFHashAddByte(&hash, _longitude >> 24); OFHashAddByte(&hash, _longitude >> 16); OFHashAddByte(&hash, _longitude >> 8); OFHashAddByte(&hash, _longitude); OFHashAddByte(&hash, _altitude >> 24); OFHashAddByte(&hash, _altitude >> 16); OFHashAddByte(&hash, _altitude >> 8); OFHashAddByte(&hash, _altitude); OFHashFinalize(&hash); return hash; } - (OFString *)description { return [OFString stringWithFormat: @"<%@:\n" @"\tName = %@\n" @"\tClass = %@\n" @"\tSize = %ue%u\n" @"\tHorizontal precision = %ue%u\n" @"\tVertical precision = %ue%u\n" @"\tLatitude = %f\n" @"\tLongitude = %f\n" @"\tAltitude = %f\n" @"\tTTL = %" PRIu32 "\n" @">", self.className, _name, OFDNSClassName(_DNSClass), _size >> 4, _size & 0xF, _horizontalPrecision >> 4, _horizontalPrecision & 0xF, _verticalPrecision >> 4, _verticalPrecision & 0xF, ((double)_latitude - 2147483648) / 3600000, ((double)_longitude - 2147483648) / 3600000, ((double)_altitude - 10000000) / 100, _TTL]; } @end |
Modified src/OFList.h from [f2ae387af6] to [9d597032f3].
1 | /* | | | | | | > > > > | < > | < | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFCollection.h" #import "OFEnumerator.h" OF_ASSUME_NONNULL_BEGIN /** @file */ /* * Make clang's -Wdocumentation shut up about about using @struct on something * it thinks is not a struct. Doxygen requires it this way. */ #ifdef __clang__ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wdocumentation" #endif /** * @struct OFListItem OFList.h ObjFW/OFList.h |
︙ | ︙ | |||
77 78 79 80 81 82 83 | #endif /** * @class OFList OFList.h ObjFW/OFList.h * * @brief A class which provides easy to use double-linked lists. */ | | < | 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | #endif /** * @class OFList OFList.h ObjFW/OFList.h * * @brief A class which provides easy to use double-linked lists. */ @interface OFList OF_GENERIC(ObjectType): OFObject <OFCopying, OFCollection> #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) # define ObjectType id #endif { OFListItem _Nullable _firstListItem; OFListItem _Nullable _lastListItem; size_t _count; |
︙ | ︙ |
Modified src/OFList.m from [18864abbc2] to [753180d6a2].
1 | /* | | | | | | > > > > | < > | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "OFList.h" #import "OFString.h" #import "OFArray.h" #import "OFEnumerationMutationException.h" #import "OFInvalidArgumentException.h" struct _OFListItem { struct _OFListItem *previous, *next; |
︙ | ︙ | |||
66 67 68 69 70 71 72 | @synthesize firstListItem = _firstListItem, lastListItem = _lastListItem; + (instancetype)list { return [[[self alloc] init] autorelease]; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | @synthesize firstListItem = _firstListItem, lastListItem = _lastListItem; + (instancetype)list { return [[[self alloc] init] autorelease]; } - (void)dealloc { OFListItem next; for (OFListItem iter = _firstListItem; iter != NULL; iter = next) { [iter->object release]; next = iter->next; |
︙ | ︙ | |||
252 253 254 255 256 257 258 | for (iter = _firstListItem, iter2 = list.firstListItem; iter != NULL && iter2 != NULL; iter = iter->next, iter2 = iter2->next) if (![iter->object isEqual: iter2->object]) return false; /* One is bigger than the other even though we checked the count */ | | | 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | for (iter = _firstListItem, iter2 = list.firstListItem; iter != NULL && iter2 != NULL; iter = iter->next, iter2 = iter2->next) if (![iter->object isEqual: iter2->object]) return false; /* One is bigger than the other even though we checked the count */ OFAssert(iter == NULL && iter2 == NULL); return true; } - (bool)containsObject: (id)object { if (_count == 0) |
︙ | ︙ | |||
370 371 372 373 374 375 376 | [ret appendString: @"\n]"]; [ret makeImmutable]; return ret; } | < < < < < < < < < < < < < < < < < < | 343 344 345 346 347 348 349 350 351 352 353 354 355 356 | [ret appendString: @"\n]"]; [ret makeImmutable]; return ret; } - (int)countByEnumeratingWithState: (OFFastEnumerationState *)state objects: (id *)objects count: (int)count { OFListItem listItem; memcpy(&listItem, state->extra, sizeof(listItem)); |
︙ | ︙ |
Modified src/OFLocale.h from [ca12b9c93f] to [1e2e85a856].
1 | /* | | | | | | > > > > | < > | > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFString.h" OF_ASSUME_NONNULL_BEGIN @class OFIRI; /** @file */ /** * @def OF_LOCALIZED * * @brief Returns the localized string for the specified ID with the specified |
︙ | ︙ | |||
89 90 91 92 93 94 95 | * @brief The decimal separator of the locale. */ @property (readonly, nonatomic) OFString *decimalSeparator; /** * @brief Returns the current OFLocale. * | | < | | 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | * @brief The decimal separator of the locale. */ @property (readonly, nonatomic) OFString *decimalSeparator; /** * @brief Returns the current OFLocale. * * @note If you don't use @ref OFApplication, you need to call this as early as * possible to initialize the locale! * * @return The current OFLocale instance */ + (nullable OFLocale *)currentLocale; /** * @brief Returns the language code of the locale. |
︙ | ︙ | |||
134 135 136 137 138 139 140 | /** * @brief Returns the decimal point of the system's locale. * * @return The decimal point of the system's locale */ + (nullable OFString *)decimalSeparator; | < | | < < < < < < < < < < < | > < | | < | 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | /** * @brief Returns the decimal point of the system's locale. * * @return The decimal point of the system's locale */ + (nullable OFString *)decimalSeparator; /** * @brief Adds a directory to scan for localizations. * * @param IRI The IRI to the directory to scan for localizations */ + (void)addLocalizationDirectoryIRI: (OFIRI *)IRI; - (instancetype)init OF_DEPRECATED(ObjFW, 1, 1, "Manually creating an OFLocale " "is no longer necessary. Use +[OFLocale currentLocale] instead."); /** * @brief Adds a directory to scan for localizations. * * @param IRI The IRI to the directory to scan for localizations */ - (void)addLocalizationDirectoryIRI: (OFIRI *)IRI; /** * @brief Returns the localized string for the specified ID, using the fallback * string if it cannot be looked up or is missing. * * @note This takes a variadic argument, terminated by `nil`, that consists of * pairs of variable names and variable values, which will be replaced |
︙ | ︙ |
Modified src/OFLocale.m from [e8b5569b76] to [86262efe96].
1 | /* | | | | | | > > > > | < > | | | | > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <locale.h> #import "OFLocale.h" #import "OFArray.h" #import "OFDictionary.h" #import "OFIRI.h" #import "OFNumber.h" #import "OFString.h" #import "OFOnce.h" #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFOpenItemFailedException.h" #ifdef OF_AMIGAOS # define Class IntuitionClass # include <proto/dos.h> # include <proto/exec.h> # include <proto/locale.h> # undef Class #endif @interface OFLocale () - (instancetype)of_init OF_METHOD_FAMILY(init); @end static OFOnceControl initLocaleControl = OFOnceControlInitValue; static OFLocale *currentLocale = nil; static OFDictionary *operatorPrecedences = nil; static void initLocale(void) { currentLocale = [[OFLocale alloc] of_init]; } #ifndef OF_AMIGAOS static void parseLocale(char *locale, OFStringEncoding *encoding, OFString **languageCode, OFString **countryCode) { locale = OFStrDup(locale); |
︙ | ︙ | |||
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | @implementation OFLocale @synthesize languageCode = _languageCode, countryCode = _countryCode; @synthesize encoding = _encoding, decimalSeparator = _decimalSeparator; + (void)initialize { OFNumber *one, *two, *three, *four; if (self != [OFLocale class]) return; /* 1 is also used to denote a unary operator. */ one = [OFNumber numberWithUnsignedInt: 1]; two = [OFNumber numberWithUnsignedInt: 2]; three = [OFNumber numberWithUnsignedInt: 3]; four = [OFNumber numberWithUnsignedInt: 4]; | > > > | 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 | @implementation OFLocale @synthesize languageCode = _languageCode, countryCode = _countryCode; @synthesize encoding = _encoding, decimalSeparator = _decimalSeparator; + (void)initialize { void *pool; OFNumber *one, *two, *three, *four; if (self != [OFLocale class]) return; pool = objc_autoreleasePoolPush(); /* 1 is also used to denote a unary operator. */ one = [OFNumber numberWithUnsignedInt: 1]; two = [OFNumber numberWithUnsignedInt: 2]; three = [OFNumber numberWithUnsignedInt: 3]; four = [OFNumber numberWithUnsignedInt: 4]; |
︙ | ︙ | |||
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | @"+", two, @"%", two, @"&&", three, @"||", four, @"!", one, @"is_real", one, nil]; } + (OFLocale *)currentLocale { return currentLocale; } + (OFString *)languageCode { return currentLocale.languageCode; } + (OFString *)countryCode { return currentLocale.countryCode; } + (OFStringEncoding)encoding { return currentLocale.encoding; } + (OFString *)decimalSeparator { return currentLocale.decimalSeparator; } | > > > > > > > > > > > > < | | < > > > > > > > > > > > > > > | | < | > | 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 | @"+", two, @"%", two, @"&&", three, @"||", four, @"!", one, @"is_real", one, nil]; objc_autoreleasePoolPop(pool); } + (OFLocale *)currentLocale { OFOnce(&initLocaleControl, initLocale); return currentLocale; } + (OFString *)languageCode { OFOnce(&initLocaleControl, initLocale); return currentLocale.languageCode; } + (OFString *)countryCode { OFOnce(&initLocaleControl, initLocale); return currentLocale.countryCode; } + (OFStringEncoding)encoding { OFOnce(&initLocaleControl, initLocale); return currentLocale.encoding; } + (OFString *)decimalSeparator { OFOnce(&initLocaleControl, initLocale); return currentLocale.decimalSeparator; } + (void)addLocalizationDirectoryIRI: (OFIRI *)IRI { [currentLocale addLocalizationDirectoryIRI: IRI]; } - (instancetype)init { /* * In the past, applications not using OFApplication were required to * create an instance of OFLocale manually. This is no longer needed * and +[currentLocale] creates the singleton. However, in order to not * break old applications, this method needs to just return the * singleton now. */ [self release]; return [OFLocale currentLocale]; } - (instancetype)of_init { self = [super init]; @try { #ifndef OF_AMIGAOS char *locale, *messagesLocale = NULL; # ifdef OF_MSDOS _encoding = OFStringEncodingCodepage437; # else _encoding = OFStringEncodingUTF8; # endif _decimalSeparator = @"."; _localizedStrings = [[OFMutableArray alloc] init]; if ((locale = setlocale(LC_ALL, "")) != NULL) _decimalSeparator = [[OFString alloc] initWithCString: localeconv()->decimal_point encoding: _encoding]; |
︙ | ︙ | |||
475 476 477 478 479 480 481 | objc_autoreleasePoolPop(pool); #endif } @catch (id e) { [self release]; @throw e; } | < < < < < < < < | < | < < | > | | | | 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 | objc_autoreleasePoolPop(pool); #endif } @catch (id e) { [self release]; @throw e; } return self; } OF_SINGLETON_METHODS - (void)addLocalizationDirectoryIRI: (OFIRI *)IRI { void *pool; OFIRI *mapIRI, *localizationIRI; OFString *languageCode, *countryCode, *localizationFile; OFDictionary *map; if (_languageCode == nil) return; pool = objc_autoreleasePoolPush(); mapIRI = [IRI IRIByAppendingPathComponent: @"localizations.json"]; @try { map = [[OFString stringWithContentsOfIRI: mapIRI] objectByParsingJSON]; } @catch (OFOpenItemFailedException *e) { objc_autoreleasePoolPop(pool); return; } languageCode = _languageCode.lowercaseString; |
︙ | ︙ | |||
528 529 530 531 532 533 534 | objectForKey: @""]; if (localizationFile == nil) { objc_autoreleasePoolPop(pool); return; } | | | | < | 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 | objectForKey: @""]; if (localizationFile == nil) { objc_autoreleasePoolPop(pool); return; } localizationIRI = [IRI IRIByAppendingPathComponent: [localizationFile stringByAppendingString: @".json"]]; [_localizedStrings addObject: [[OFString stringWithContentsOfIRI: localizationIRI] objectByParsingJSON]]; objc_autoreleasePoolPop(pool); } - (OFString *)localizedStringForID: (OFConstantString *)ID fallback: (id)fallback, ... { OFString *ret; va_list args; |
︙ | ︙ |
Modified src/OFLocking.h from [155544ed9e] to [65c4139ffa].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/OFMD5Hash.h from [cdd5a3515e] to [eea66bbc6d].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFCryptographicHash.h" OF_ASSUME_NONNULL_BEGIN @class OFSecureData; |
︙ | ︙ |
Modified src/OFMD5Hash.m from [190d96fa7c] to [75a1c1c537].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "OFMD5Hash.h" |
︙ | ︙ |
Added src/OFMXDNSResourceRecord.h version [84884c0352].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFDNSResourceRecord.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFMXDNSResourceRecord \ * OFDNSResourceRecord.h ObjFW/OFDNSResourceRecord.h * * @brief A class representing an MX DNS resource record. */ OF_SUBCLASSING_RESTRICTED @interface OFMXDNSResourceRecord: OFDNSResourceRecord { uint16_t _preference; OFString *_mailExchange; } /** * @brief The preference of the resource record. */ @property (readonly, nonatomic) uint16_t preference; /** * @brief The mail exchange of the resource record. */ @property (readonly, nonatomic) OFString *mailExchange; - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFMXDNSResourceRecord with the * specified name, class, preference, mail exchange and time to live. * * @param name The name for the resource record * @param DNSClass The class code for the resource record * @param preference The preference for the resource record * @param mailExchange The mail exchange for the resource record * @param TTL The time to live for the resource record * @return An initialized OFMXDNSResourceRecord */ - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass preference: (uint16_t)preference mailExchange: (OFString *)mailExchange TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END |
Added src/OFMXDNSResourceRecord.m version [dbe0185c73].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFMXDNSResourceRecord.h" @implementation OFMXDNSResourceRecord @synthesize preference = _preference, mailExchange = _mailExchange; - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass preference: (uint16_t)preference mailExchange: (OFString *)mailExchange TTL: (uint32_t)TTL { self = [super initWithName: name DNSClass: DNSClass recordType: OFDNSRecordTypeMX TTL: TTL]; @try { _preference = preference; _mailExchange = [mailExchange copy]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_mailExchange release]; [super dealloc]; } - (bool)isEqual: (id)object { OFMXDNSResourceRecord *record; if (object == self) return true; if (![object isKindOfClass: [OFMXDNSResourceRecord class]]) return false; record = object; if (record->_name != _name && ![record->_name isEqual: _name]) return false; if (record->_DNSClass != _DNSClass) return false; if (record->_recordType != _recordType) return false; if (record->_preference != _preference) return false; if (record->_mailExchange != _mailExchange && ![record->_mailExchange isEqual: _mailExchange]) return false; return true; } - (unsigned long)hash { unsigned long hash; OFHashInit(&hash); OFHashAddHash(&hash, _name.hash); OFHashAddByte(&hash, _DNSClass >> 8); OFHashAddByte(&hash, _DNSClass); OFHashAddByte(&hash, _recordType >> 8); OFHashAddByte(&hash, _recordType); OFHashAddByte(&hash, _preference >> 8); OFHashAddByte(&hash, _preference); OFHashAddHash(&hash, _mailExchange.hash); OFHashFinalize(&hash); return hash; } - (OFString *)description { return [OFString stringWithFormat: @"<%@:\n" @"\tName = %@\n" @"\tClass = %@\n" @"\tPreference = %" PRIu16 "\n" @"\tMail Exchange = %@\n" @"\tTTL = %" PRIu32 "\n" @">", self.className, _name, OFDNSClassName(_DNSClass), _preference, _mailExchange, _TTL]; } @end |
Modified src/OFMapTable+Private.h from [34b0bddd51] to [950cbc95ac].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFMapTable.h" OF_ASSUME_NONNULL_BEGIN OF_DIRECT_MEMBERS |
︙ | ︙ |
Modified src/OFMapTable.h from [382835ac81] to [5ec91b5432].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFEnumerator.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ | |||
70 71 72 73 74 75 76 | */ OF_SUBCLASSING_RESTRICTED @interface OFMapTable: OFObject <OFCopying, OFFastEnumeration> { OFMapTableFunctions _keyFunctions, _objectFunctions; struct OFMapTableBucket *_Nonnull *_Nullable _buckets; uint32_t _count, _capacity; | | | 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | */ OF_SUBCLASSING_RESTRICTED @interface OFMapTable: OFObject <OFCopying, OFFastEnumeration> { OFMapTableFunctions _keyFunctions, _objectFunctions; struct OFMapTableBucket *_Nonnull *_Nullable _buckets; uint32_t _count, _capacity; unsigned char _rotation; unsigned long _mutations; } /** * @brief The key functions used by the map table. */ @property (readonly, nonatomic) OFMapTableFunctions keyFunctions; |
︙ | ︙ |
Modified src/OFMapTable.m from [61602c79fe] to [90cee4067e].
1 | /* | | | | | | > > > > | < > | < < | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #define OF_MAP_TABLE_M #include "config.h" #include <stdlib.h> #include <string.h> #import "OFMapTable.h" #import "OFMapTable+Private.h" #import "OFEnumerator.h" #import "OFEnumerationMutationException.h" #import "OFInvalidArgumentException.h" #import "OFOutOfRangeException.h" extern unsigned long OFHashSeed; static const uint32_t minCapacity = 16; struct OFMapTableBucket { void *key, *object; uint32_t hash; }; |
︙ | ︙ | |||
155 156 157 158 159 160 161 | if (_capacity < minCapacity) _capacity = minCapacity; _buckets = OFAllocZeroedMemory(_capacity, sizeof(*_buckets)); if (OFHashSeed != 0) | | | 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | if (_capacity < minCapacity) _capacity = minCapacity; _buckets = OFAllocZeroedMemory(_capacity, sizeof(*_buckets)); if (OFHashSeed != 0) _rotation = OFRandom16() & 31; } @catch (id e) { [self release]; @throw e; } return self; } |
︙ | ︙ | |||
185 186 187 188 189 190 191 192 193 194 195 196 197 198 | } static void resizeForCount(OFMapTable *self, uint32_t count) { uint32_t fullness, capacity; struct OFMapTableBucket **buckets; if (count > UINT32_MAX / sizeof(*self->_buckets) || count > UINT32_MAX / 8) @throw [OFOutOfRangeException exception]; fullness = count * 8 / self->_capacity; | > | 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | } static void resizeForCount(OFMapTable *self, uint32_t count) { uint32_t fullness, capacity; struct OFMapTableBucket **buckets; unsigned char newRotation; if (count > UINT32_MAX / sizeof(*self->_buckets) || count > UINT32_MAX / 8) @throw [OFOutOfRangeException exception]; fullness = count * 8 / self->_capacity; |
︙ | ︙ | |||
211 212 213 214 215 216 217 218 219 220 221 | * below the minimum capacity. */ if ((capacity < self->_capacity && count > self->_count) || capacity < minCapacity) return; buckets = OFAllocZeroedMemory(capacity, sizeof(*buckets)); for (uint32_t i = 0; i < self->_capacity; i++) { if (self->_buckets[i] != NULL && self->_buckets[i] != &deletedBucket) { | > | > > | | > | | | | > > | | | 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | * below the minimum capacity. */ if ((capacity < self->_capacity && count > self->_count) || capacity < minCapacity) return; buckets = OFAllocZeroedMemory(capacity, sizeof(*buckets)); newRotation = (OFHashSeed != 0 ? OFRandom16() & 31 : 0); for (uint32_t i = 0; i < self->_capacity; i++) { if (self->_buckets[i] != NULL && self->_buckets[i] != &deletedBucket) { uint32_t rotatedHash, j, last; rotatedHash = OFRotateLeft(self->_buckets[i]->hash, newRotation); last = capacity; for (j = rotatedHash & (capacity - 1); j < last && buckets[j] != NULL; j++); /* In case the last bucket is already used */ if (j >= last) { last = rotatedHash & (capacity - 1); for (j = 0; j < last && buckets[j] != NULL; j++); } if (j >= last) @throw [OFOutOfRangeException exception]; buckets[j] = self->_buckets[i]; } } OFFreeMemory(self->_buckets); self->_buckets = buckets; self->_capacity = capacity; self->_rotation = newRotation; } static void setObject(OFMapTable *restrict self, void *key, void *object, uint32_t hash) { uint32_t rotatedHash, i, last; void *old; if (key == NULL || object == NULL) @throw [OFInvalidArgumentException exception]; rotatedHash = OFRotateLeft(hash, self->_rotation); last = self->_capacity; for (i = rotatedHash & (self->_capacity - 1); i < last && self->_buckets[i] != NULL; i++) { if (self->_buckets[i] == &deletedBucket) continue; if (self->_keyFunctions.equal(self->_buckets[i]->key, key)) break; } /* In case the last bucket is already used */ if (i >= last) { last = rotatedHash & (self->_capacity - 1); for (i = 0; i < last && self->_buckets[i] != NULL; i++) { if (self->_buckets[i] == &deletedBucket) continue; if (self->_keyFunctions.equal( self->_buckets[i]->key, key)) break; } } /* Key not in map table */ if (i >= last || self->_buckets[i] == NULL || self->_buckets[i] == &deletedBucket || !self->_keyFunctions.equal(self->_buckets[i]->key, key)) { struct OFMapTableBucket *bucket; resizeForCount(self, self->_count + 1); /* Resizing can change the rotation */ rotatedHash = OFRotateLeft(hash, self->_rotation); self->_mutations++; last = self->_capacity; for (i = rotatedHash & (self->_capacity - 1); i < last && self->_buckets[i] != NULL && self->_buckets[i] != &deletedBucket; i++); /* In case the last bucket is already used */ if (i >= last) { last = rotatedHash & (self->_capacity - 1); for (i = 0; i < last && self->_buckets[i] != NULL && self->_buckets[i] != &deletedBucket; i++); } if (i >= last) @throw [OFOutOfRangeException exception]; |
︙ | ︙ | |||
370 371 372 373 374 375 376 | - (unsigned long)hash { unsigned long hash = 0; for (unsigned long i = 0; i < _capacity; i++) { if (_buckets[i] != NULL && _buckets[i] != &deletedBucket) { | | | < | | > > | | | | > > | < < > | | 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 | - (unsigned long)hash { unsigned long hash = 0; for (unsigned long i = 0; i < _capacity; i++) { if (_buckets[i] != NULL && _buckets[i] != &deletedBucket) { hash ^= _buckets[i]->hash; hash ^= _objectFunctions.hash(_buckets[i]->object); } } return hash; } - (id)copy { OFMapTable *copy = [[OFMapTable alloc] initWithKeyFunctions: _keyFunctions objectFunctions: _objectFunctions capacity: _capacity]; @try { for (uint32_t i = 0; i < _capacity; i++) if (_buckets[i] != NULL && _buckets[i] != &deletedBucket) setObject(copy, _buckets[i]->key, _buckets[i]->object, _buckets[i]->hash); } @catch (id e) { [copy release]; @throw e; } return copy; } - (size_t)count { return _count; } - (void *)objectForKey: (void *)key { uint32_t i, rotatedHash, last; if (key == NULL) @throw [OFInvalidArgumentException exception]; rotatedHash = OFRotateLeft((uint32_t)_keyFunctions.hash(key), _rotation); last = _capacity; for (i = rotatedHash & (_capacity - 1); i < last && _buckets[i] != NULL; i++) { if (_buckets[i] == &deletedBucket) continue; if (_keyFunctions.equal(_buckets[i]->key, key)) return _buckets[i]->object; } if (i < last) return nil; /* In case the last bucket is already used */ last = rotatedHash & (_capacity - 1); for (i = 0; i < last && _buckets[i] != NULL; i++) { if (_buckets[i] == &deletedBucket) continue; if (_keyFunctions.equal(_buckets[i]->key, key)) return _buckets[i]->object; } return NULL; } - (void)setObject: (void *)object forKey: (void *)key { setObject(self, key, object, (uint32_t)_keyFunctions.hash(key)); } - (void)removeObjectForKey: (void *)key { uint32_t i, rotatedHash, last; if (key == NULL) @throw [OFInvalidArgumentException exception]; rotatedHash = OFRotateLeft((uint32_t)_keyFunctions.hash(key), _rotation); last = _capacity; for (i = rotatedHash & (_capacity - 1); i < last && _buckets[i] != NULL; i++) { if (_buckets[i] == &deletedBucket) continue; if (_keyFunctions.equal(_buckets[i]->key, key)) { _keyFunctions.release(_buckets[i]->key); _objectFunctions.release(_buckets[i]->object); OFFreeMemory(_buckets[i]); _buckets[i] = &deletedBucket; _count--; _mutations++; resizeForCount(self, _count); return; } } if (i < last) return; /* In case the last bucket is already used */ last = rotatedHash & (_capacity - 1); for (i = 0; i < last && _buckets[i] != NULL; i++) { if (_buckets[i] == &deletedBucket) continue; if (_keyFunctions.equal(_buckets[i]->key, key)) { _keyFunctions.release(_buckets[i]->key); |
︙ | ︙ | |||
523 524 525 526 527 528 529 | } _count = 0; _capacity = minCapacity; _buckets = OFResizeMemory(_buckets, _capacity, sizeof(*_buckets)); /* | | | | 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 | } _count = 0; _capacity = minCapacity; _buckets = OFResizeMemory(_buckets, _capacity, sizeof(*_buckets)); /* * Get a new random value for _rotation, so that it is not less secure * than creating a new hash map. */ if (OFHashSeed != 0) _rotation = OFRandom16() & 31; } - (bool)containsObject: (void *)object { if (object == NULL || _count == 0) return false; |
︙ | ︙ | |||
606 607 608 609 610 611 612 613 614 615 | #ifdef OF_HAVE_BLOCKS - (void)enumerateKeysAndObjectsUsingBlock: (OFMapTableEnumerationBlock)block { bool stop = false; unsigned long mutations = _mutations; for (size_t i = 0; i < _capacity && !stop; i++) { if (_mutations != mutations) @throw [OFEnumerationMutationException exceptionWithObject: self]; | > > > < < < | 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 | #ifdef OF_HAVE_BLOCKS - (void)enumerateKeysAndObjectsUsingBlock: (OFMapTableEnumerationBlock)block { bool stop = false; unsigned long mutations = _mutations; for (size_t i = 0; i < _capacity && !stop; i++) { if (_buckets[i] != NULL && _buckets[i] != &deletedBucket) block(_buckets[i]->key, _buckets[i]->object, &stop); if (_mutations != mutations) @throw [OFEnumerationMutationException exceptionWithObject: self]; } } - (void)replaceObjectsUsingBlock: (OFMapTableReplaceBlock)block { unsigned long mutations = _mutations; |
︙ | ︙ |
Added src/OFMatrix4x4.h version [94485a2518].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" OF_ASSUME_NONNULL_BEGIN /** * @brief A 4x4 matrix of floats. */ OF_SUBCLASSING_RESTRICTED @interface OFMatrix4x4: OFObject <OFCopying> { OF_ALIGN(16) float _values[4][4]; } #ifdef OF_HAVE_CLASS_PROPERTIES @property (readonly, class) OFMatrix4x4 *identityMatrix; #endif /** * @brief A 2D array of the 4x4 floats of the matrix in row-major format. * * These may be modified directly. */ @property (readonly, nonatomic) float (*values)[4]; /** * @brief Returns the 4x4 identity matrix. */ + (OFMatrix4x4 *)identityMatrix; /** * @brief Creates a new 4x4 matrix with the specified values. * * @param values A 2D array of 4x4 floats in row-major format * @return A new, autoreleased OFMatrix4x4 */ + (instancetype)matrixWithValues: (const float [_Nonnull 4][4])values; - (instancetype)init OF_UNAVAILABLE; /** * @brief Initializes an already allocated 4x4 matrix with the specified values. * * @param values A 2D array of 4x4 floats in row-major format * @return An initialized OFMatrix4x4 */ - (instancetype)initWithValues: (const float [_Nonnull 4][4])values OF_DESIGNATED_INITIALIZER; /** * @brief Multiplies the receiver with the specified matrix on the left side * and the receiver on the right side. * * @param matrix The matrix to multiply the receiver with */ - (void)multiplyWithMatrix: (OFMatrix4x4 *)matrix; /** * @brief Translates the matrix with the specified vector. * * @param vector The vector to translate the matrix with */ - (void)translateWithVector: (OFVector3D)vector; /** * @brief Scales the matrix with the specified vector. * * @param vector The vector to scale the matrix with */ - (void)scaleWithVector: (OFVector3D)vector; /** * @brief Transforms the specified vector according to the matrix. * * @param vector The vector to transform * @return The transformed vector */ - (OFVector4D)transformedVector: (OFVector4D)vector; /** * @brief Transforms the specified vectors in-place according to the matrix. * * @warning Please note that the vectors must be 16 byte aligned! This is * required to allow SIMD optimizations. Passing a pointer to vectors * that are not 16 byte aligned will crash if SIMD optimizations are * enabled. * * @param vectors The vectors to transform * @param count The count of the specified vectors */ - (void)transformVectors: (OFVector4D *)vectors count: (size_t)count; @end OF_ASSUME_NONNULL_END |
Added src/OFMatrix4x4.m version [a90d32dcbf].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFMatrix4x4.h" #import "OFString.h" #import "OFSystemInfo.h" #import "OFOnce.h" static const float identityValues[4][4] = { { 1, 0, 0, 0 }, { 0, 1, 0, 0 }, { 0, 0, 1, 0 }, { 0, 0, 0, 1 } }; @implementation OFMatrix4x4 #if (defined(OF_AMD64) || defined(OF_X86)) && defined(__GNUC__) # ifndef __clang__ # pragma GCC push_options # pragma GCC target("sse") # endif static void transformVectors_SSE(OFMatrix4x4 *self, SEL _cmd, OFVector4D *vectors, size_t count) { OF_ALIGN(16) float tmp[4]; __asm__ __volatile__ ( "test %[count], %[count]\n\t" "jz 0f\n" "\n\t" "movaps (%[matrix]), %%xmm0\n\t" "movaps 16(%[matrix]), %%xmm1\n\t" "movaps 32(%[matrix]), %%xmm2\n\t" # ifdef OF_AMD64 "movaps 48(%[matrix]), %%xmm8\n" # endif "\n\t" "0:\n\t" "movaps (%[vectors]), %%xmm3\n" "\n\t" "movaps %%xmm0, %%xmm4\n\t" "mulps %%xmm3, %%xmm4\n\t" "movaps %%xmm4, (%[tmp])\n\t" "addss 4(%[tmp]), %%xmm4\n\t" "addss 8(%[tmp]), %%xmm4\n\t" "addss 12(%[tmp]), %%xmm4\n" "\n\t" "movaps %%xmm1, %%xmm5\n\t" "mulps %%xmm3, %%xmm5\n\t" "movaps %%xmm5, (%[tmp])\n\t" "addss 4(%[tmp]), %%xmm5\n\t" "addss 8(%[tmp]), %%xmm5\n\t" "addss 12(%[tmp]), %%xmm5\n" "\n\t" "movaps %%xmm2, %%xmm6\n\t" "mulps %%xmm3, %%xmm6\n\t" "movaps %%xmm6, (%[tmp])\n\t" "addss 4(%[tmp]), %%xmm6\n\t" "addss 8(%[tmp]), %%xmm6\n\t" "addss 12(%[tmp]), %%xmm6\n" "\n\t" # ifdef OF_AMD64 "movaps %%xmm8, %%xmm7\n\t" # else "movaps 48(%[matrix]), %%xmm7\n\t" # endif "mulps %%xmm3, %%xmm7\n\t" "movaps %%xmm7, (%[tmp])\n\t" "addss 4(%[tmp]), %%xmm7\n\t" "addss 8(%[tmp]), %%xmm7\n\t" "addss 12(%[tmp]), %%xmm7\n" "\n\t" "movss %%xmm4, (%[vectors])\n\t" "movss %%xmm5, 4(%[vectors])\n\t" "movss %%xmm6, 8(%[vectors])\n\t" "movss %%xmm7, 12(%[vectors])\n" "\n\t" "add $16, %[vectors]\n\t" "dec %[count]\n\t" "jnz 0b\n" : [count] "+r" (count), [vectors] "+r" (vectors) : [matrix] "r" (self->_values), [tmp] "r" (&tmp) : "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7", # ifdef OF_AMD64 "xmm8", # endif "memory" ); } # ifndef __clang__ # pragma GCC pop_options # endif # ifndef __clang__ # pragma GCC push_options # pragma GCC target("3dnow") # endif static void multiplyWithMatrix_3DNow(OFMatrix4x4 *self, SEL _cmd, OFMatrix4x4 *matrix) { float (*left)[4] = matrix->_values, (*right)[4] = self->_values; float result[4][4], (*resultPtr)[4] = result; __asm__ __volatile__ ( "movl $4, %%ecx\n\t" "\n\t" "0:\n\t" "movd (%[right]), %%mm0\n\t" "punpckldq 16(%[right]), %%mm0\n\t" "pfmul (%[left]), %%mm0\n\t" "movd 32(%[right]), %%mm1\n\t" "punpckldq 48(%[right]), %%mm1\n\t" "pfmul 8(%[left]), %%mm1\n\t" "pfacc %%mm1, %%mm0\n\t" "pfacc %%mm0, %%mm0\n\t" "movd %%mm0, (%[result])\n\t" "movd 4(%[right]), %%mm0\n\t" "punpckldq 20(%[right]), %%mm0\n\t" "pfmul (%[left]), %%mm0\n\t" "movd 36(%[right]), %%mm1\n\t" "punpckldq 52(%[right]), %%mm1\n\t" "pfmul 8(%[left]), %%mm1\n\t" "pfacc %%mm1, %%mm0\n\t" "pfacc %%mm0, %%mm0\n\t" "movd %%mm0, 4(%[result])\n\t" "movd 8(%[right]), %%mm0\n\t" "punpckldq 24(%[right]), %%mm0\n\t" "pfmul (%[left]), %%mm0\n\t" "movd 40(%[right]), %%mm1\n\t" "punpckldq 56(%[right]), %%mm1\n\t" "pfmul 8(%[left]), %%mm1\n\t" "pfacc %%mm1, %%mm0\n\t" "pfacc %%mm0, %%mm0\n\t" "movd %%mm0, 8(%[result])\n\t" "movd 12(%[right]), %%mm0\n\t" "punpckldq 28(%[right]), %%mm0\n\t" "pfmul (%[left]), %%mm0\n\t" "movd 44(%[right]), %%mm1\n\t" "punpckldq 60(%[right]), %%mm1\n\t" "pfmul 8(%[left]), %%mm1\n\t" "pfacc %%mm1, %%mm0\n\t" "pfacc %%mm0, %%mm0\n\t" "movd %%mm0, 12(%[result])\n" "\n\t" "add $16, %[result]\n\t" "add $16, %[left]\n\t" "decl %%ecx\n\t" "jnz 0b\n" "\n\t" "femms" : [result] "+r" (resultPtr), [left] "+r" (left), [right] "+r" (right) : : "ecx", "mm0", "mm1", "memory" ); memcpy(self->_values, result, 16 * sizeof(float)); } static void transformVectors_3DNow(OFMatrix4x4 *self, SEL _cmd, OFVector4D *vectors, size_t count) { __asm__ __volatile__ ( "test %[count], %[count]\n\t" "jz 0f\n" "\n\t" "0:\n\t" "movq (%[vectors]), %%mm0\n\t" "movq 8(%[vectors]), %%mm1\n" "\n\t" "movq %%mm0, %%mm2\n\t" "movq %%mm1, %%mm3\n\t" "pfmul (%[matrix]), %%mm2\n\t" "pfmul 8(%[matrix]), %%mm3\n\t" "pfacc %%mm3, %%mm2\n\t" "pfacc %%mm2, %%mm2\n\t" "\n\t" "movq %%mm0, %%mm3\n\t" "movq %%mm1, %%mm4\n\t" "pfmul 16(%[matrix]), %%mm3\n\t" "pfmul 24(%[matrix]), %%mm4\n\t" "pfacc %%mm4, %%mm3\n\t" "pfacc %%mm3, %%mm3\n\t" "\n\t" "punpckldq %%mm3, %%mm2\n\t" "movq %%mm2, (%[vectors])\n" "\n\t" "movq %%mm0, %%mm2\n\t" "movq %%mm1, %%mm3\n\t" "pfmul 32(%[matrix]), %%mm2\n\t" "pfmul 40(%[matrix]), %%mm3\n\t" "pfacc %%mm3, %%mm2\n\t" "pfacc %%mm2, %%mm2\n\t" "\n\t" "pfmul 48(%[matrix]), %%mm0\n\t" "pfmul 56(%[matrix]), %%mm1\n\t" "pfacc %%mm1, %%mm0\n\t" "pfacc %%mm0, %%mm0\n\t" "\n\t" "punpckldq %%mm0, %%mm2\n\t" "movq %%mm2, 8(%[vectors])\n" "\n\t" "add $16, %[vectors]\n\t" "dec %[count]\n\t" "jnz 0b\n" "\n\t" "0:\n\t" "femms" : [count] "+r" (count), [vectors] "+r" (vectors) : [matrix] "r" (self->_values) : "mm0", "mm1", "mm2", "mm3", "mm4", "memory" ); } # ifndef __clang__ # pragma GCC pop_options # endif + (void)initialize { const char *typeEncoding; if (self != [OFMatrix4x4 class]) return; # define REPLACE(selector, func) \ typeEncoding = method_getTypeEncoding( \ class_getInstanceMethod(self, selector)); \ class_replaceMethod(self, selector, (IMP)func, typeEncoding); if ([OFSystemInfo supportsSSE]) { REPLACE(@selector(transformVectors:count:), transformVectors_SSE) } else if ([OFSystemInfo supports3DNow]) { REPLACE(@selector(multiplyWithMatrix:), multiplyWithMatrix_3DNow) REPLACE(@selector(transformVectors:count:), transformVectors_3DNow) } # undef REPLACE } #endif + (OFMatrix4x4 *)identityMatrix { return [[[OFMatrix4x4 alloc] initWithValues: identityValues] autorelease]; } + (instancetype)matrixWithValues: (const float [4][4])values { return [[[self alloc] initWithValues: values] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithValues: (const float [4][4])values { self = [super init]; memcpy(_values, values, 16 * sizeof(float)); return self; } - (float (*)[4])values { return _values; } - (instancetype)copy { return [[OFMatrix4x4 alloc] initWithValues: (const float (*)[4])_values]; } - (bool)isEqual: (OFMatrix4x4 *)matrix { if (![matrix isKindOfClass: [OFMatrix4x4 class]]) return false; return (memcmp(_values, matrix->_values, 16 * sizeof(float)) == 0); } - (unsigned long)hash { unsigned long hash; OFHashInit(&hash); for (uint_fast8_t i = 0; i < 4; i++) for (uint_fast8_t j = 0; j < 4; j++) OFHashAddHash(&hash, OFFloatToRawUInt32(_values[i][j])); OFHashFinalize(&hash); return hash; } - (void)multiplyWithMatrix: (OFMatrix4x4 *)matrix { float result[4][4]; for (uint_fast8_t i = 0; i < 4; i++) for (uint_fast8_t j = 0; j < 4; j++) result[i][j] = matrix->_values[i][0] * _values[0][j] + matrix->_values[i][1] * _values[1][j] + matrix->_values[i][2] * _values[2][j] + matrix->_values[i][3] * _values[3][j]; memcpy(_values, result, 16 * sizeof(float)); } - (void)translateWithVector: (OFVector3D)vector { OFMatrix4x4 *translation = [[OFMatrix4x4 alloc] initWithValues: (const float [4][4]){ { 1, 0, 0, vector.x }, { 0, 1, 0, vector.y }, { 0, 0, 1, vector.z }, { 0, 0, 0, 1 } }]; [self multiplyWithMatrix: translation]; [translation release]; } - (void)scaleWithVector: (OFVector3D)vector { OFMatrix4x4 *scale = [[OFMatrix4x4 alloc] initWithValues: (const float [4][4]){ { vector.x, 0, 0, 0 }, { 0, vector.y, 0, 0 }, { 0, 0, vector.z, 0 }, { 0, 0, 0, 1 } }]; [self multiplyWithMatrix: scale]; [scale release]; } - (OFVector4D)transformedVector: (OFVector4D)vector { OF_ALIGN(16) OFVector4D copy = vector; [self transformVectors: © count: 1]; return copy; } - (void)transformVectors: (OFVector4D *)vectors count: (size_t)count { for (size_t i = 0; i < count; i++) { OFVector4D vector = vectors[i]; vectors[i].x = _values[0][0] * vector.x + _values[0][1] * vector.y + _values[0][2] * vector.z + _values[0][3] * vector.w; vectors[i].y = _values[1][0] * vector.x + _values[1][1] * vector.y + _values[1][2] * vector.z + _values[1][3] * vector.w; vectors[i].z = _values[2][0] * vector.x + _values[2][1] * vector.y + _values[2][2] * vector.z + _values[2][3] * vector.w; vectors[i].w = _values[3][0] * vector.x + _values[3][1] * vector.y + _values[3][2] * vector.z + _values[3][3] * vector.w; } } - (OFString *)description { return [OFString stringWithFormat: @"<OFMatrix4x4: {\n" @"\t%g %g %g %g\n" @"\t%g %g %g %g\n" @"\t%g %g %g %g\n" @"\t%g %g %g %g\n" @"}>", _values[0][0], _values[0][1], _values[0][2], _values[0][3], _values[1][0], _values[1][1], _values[1][2], _values[1][3], _values[2][0], _values[2][1], _values[2][2], _values[2][3], _values[3][0], _values[3][1], _values[3][2], _values[3][3]]; } @end |
Modified src/OFMemoryStream.h from [173e3dc728] to [6f52956a37].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFSeekableStream.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/OFMemoryStream.m from [d9d07c7da0] to [9c7e94300e].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #import "OFMemoryStream.h" |
︙ | ︙ |
Modified src/OFMessagePackExtension.h from [99c89d24f1] to [20e8ca070d].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFMessagePackRepresentation.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ |
Modified src/OFMessagePackExtension.m from [a3971287d8] to [fb1e51f9fd].
1 | /* | | | | | | > > > > | < > | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFMessagePackExtension.h" #import "OFData.h" #import "OFString.h" #import "OFInvalidArgumentException.h" #import "OFOutOfRangeException.h" @implementation OFMessagePackExtension @synthesize type = _type, data = _data; + (instancetype)extensionWithType: (int8_t)type data: (OFData *)data { return [[[self alloc] initWithType: type data: data] autorelease]; |
︙ | ︙ | |||
96 97 98 99 100 101 102 | } else if (count == 16) { ret = [OFMutableData dataWithCapacity: 18]; prefix = 0xD8; [ret addItem: &prefix]; [ret addItem: &_type]; | | | | | > | 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | } else if (count == 16) { ret = [OFMutableData dataWithCapacity: 18]; prefix = 0xD8; [ret addItem: &prefix]; [ret addItem: &_type]; } else if (count <= UINT8_MAX) { uint8_t length; ret = [OFMutableData dataWithCapacity: count + 3]; prefix = 0xC7; [ret addItem: &prefix]; length = (uint8_t)count; [ret addItem: &length]; [ret addItem: &_type]; } else if (count <= UINT16_MAX) { uint16_t length; ret = [OFMutableData dataWithCapacity: count + 4]; prefix = 0xC8; [ret addItem: &prefix]; length = OFToBigEndian16((uint16_t)count); [ret addItems: &length count: 2]; [ret addItem: &_type]; } else if (count <= UINT32_MAX) { uint32_t length; ret = [OFMutableData dataWithCapacity: count + 6]; prefix = 0xC9; [ret addItem: &prefix]; length = OFToBigEndian32((uint32_t)count); [ret addItems: &length count: 4]; [ret addItem: &_type]; } else @throw [OFOutOfRangeException exception]; [ret addItems: _data.items count: _data.count]; [ret makeImmutable]; return ret; } |
︙ | ︙ |
Modified src/OFMessagePackRepresentation.h from [d2e100cc65] to [6e430d5348].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" OF_ASSUME_NONNULL_BEGIN @class OFData; |
︙ | ︙ |
Modified src/OFMethodSignature.h from [996cafd8b2] to [4c031a4466].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" OF_ASSUME_NONNULL_BEGIN @class OFMutableData; |
︙ | ︙ | |||
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | * * @param types The ObjC types of the method * @return A new, autoreleased OFMethodSignature * @throw OFInvalidFormatException The type encoding is invalid */ + (instancetype)signatureWithObjCTypes: (const char *)types; /** * @brief Initializes an already allocated OFMethodSignature with the specified * ObjC types. * * @param types The ObjC types of the method * @return An Initialized OFMethodSignature * @throw OFInvalidFormatException The type encoding is invalid */ | > > | > | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | * * @param types The ObjC types of the method * @return A new, autoreleased OFMethodSignature * @throw OFInvalidFormatException The type encoding is invalid */ + (instancetype)signatureWithObjCTypes: (const char *)types; - (instancetype)init OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFMethodSignature with the specified * ObjC types. * * @param types The ObjC types of the method * @return An Initialized OFMethodSignature * @throw OFInvalidFormatException The type encoding is invalid */ - (instancetype)initWithObjCTypes: (const char *)types OF_DESIGNATED_INITIALIZER; /** * @brief Returns the ObjC type for the argument at the specified index. * * @param index The index of the argument for which to return the ObjC type * @return The ObjC type for the argument at the specified index */ |
︙ | ︙ |
Modified src/OFMethodSignature.m from [9c702fcecb] to [57d1160c0a].
1 | /* | | | | | | > > > > | < > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <ctype.h> #import "OFMethodSignature.h" #import "OFData.h" #import "OFString.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFOutOfRangeException.h" #import "macros.h" static size_t alignmentOfEncoding(const char **type, size_t *length, bool inStruct); static size_t sizeOfEncoding(const char **type, size_t *length); static size_t alignmentOfArray(const char **type, size_t *length) { size_t alignment; OFAssert(*length > 0); (*type)++; (*length)--; while (*length > 0 && OFASCIIIsDigit(**type)) { (*type)++; (*length)--; |
︙ | ︙ | |||
61 62 63 64 65 66 67 | alignmentOfStruct(const char **type, size_t *length) { size_t alignment = 0; #if defined(OF_POWERPC) && defined(OF_MACOS) bool first = true; #endif | | | 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | alignmentOfStruct(const char **type, size_t *length) { size_t alignment = 0; #if defined(OF_POWERPC) && defined(OF_MACOS) bool first = true; #endif OFAssert(*length > 0); (*type)++; (*length)--; /* Skip name */ while (*length > 0 && **type != '=') { (*type)++; |
︙ | ︙ | |||
107 108 109 110 111 112 113 | } static size_t alignmentOfUnion(const char **type, size_t *length) { size_t alignment = 0; | | | 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | } static size_t alignmentOfUnion(const char **type, size_t *length) { size_t alignment = 0; OFAssert(*length > 0); (*type)++; (*length)--; /* Skip name */ while (*length > 0 && **type != '=') { (*type)++; |
︙ | ︙ | |||
142 143 144 145 146 147 148 | (*type)++; (*length)--; return alignment; } static size_t | > | | 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | (*type)++; (*length)--; return alignment; } static size_t #if defined(__clang__) && __has_attribute(__optnone__) && \ __clang_major__ == 3 && __clang_minor__ <= 7 /* Work around an ICE in Clang 3.7.0 on Windows/x86 */ __attribute__((__optnone__)) #endif alignmentOfEncoding(const char **type, size_t *length, bool inStruct) { size_t alignment; |
︙ | ︙ | |||
288 289 290 291 292 293 294 | static size_t sizeOfArray(const char **type, size_t *length) { size_t count = 0; size_t size; | | | 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 | static size_t sizeOfArray(const char **type, size_t *length) { size_t count = 0; size_t size; OFAssert(*length > 0); (*type)++; (*length)--; while (*length > 0 && OFASCIIIsDigit(**type)) { count = count * 10 + **type - '0'; |
︙ | ︙ | |||
328 329 330 331 332 333 334 | const char *typeCopy = *type; size_t lengthCopy = *length; size_t alignment = alignmentOfStruct(&typeCopy, &lengthCopy); #if defined(OF_POWERPC) && defined(OF_MACOS) bool first = true; #endif | | | 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 | const char *typeCopy = *type; size_t lengthCopy = *length; size_t alignment = alignmentOfStruct(&typeCopy, &lengthCopy); #if defined(OF_POWERPC) && defined(OF_MACOS) bool first = true; #endif OFAssert(*length > 0); (*type)++; (*length)--; /* Skip name */ while (*length > 0 && **type != '=') { (*type)++; |
︙ | ︙ | |||
401 402 403 404 405 406 407 | } static size_t sizeOfUnion(const char **type, size_t *length) { size_t size = 0; | | | 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 | } static size_t sizeOfUnion(const char **type, size_t *length) { size_t size = 0; OFAssert(*length > 0); (*type)++; (*length)--; /* Skip name */ while (*length > 0 && **type != '=') { (*type)++; |
︙ | ︙ | |||
436 437 438 439 440 441 442 443 444 445 446 447 448 449 | (*type)++; (*length)--; return size; } static size_t sizeOfEncoding(const char **type, size_t *length) { size_t size; if (*length == 0) @throw [OFInvalidFormatException exception]; | > > > > > | 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 | (*type)++; (*length)--; return size; } static size_t #if defined(__clang__) && __has_attribute(__optnone__) && \ __clang_major__ == 3 && __clang_minor__ <= 7 /* Work around an ICE in Clang 3.7.0 on Windows/x86 */ __attribute__((__optnone__)) #endif sizeOfEncoding(const char **type, size_t *length) { size_t size; if (*length == 0) @throw [OFInvalidFormatException exception]; |
︙ | ︙ | |||
581 582 583 584 585 586 587 588 589 590 591 592 593 594 | } @implementation OFMethodSignature + (instancetype)signatureWithObjCTypes: (const char*)types { return [[[self alloc] initWithObjCTypes: types] autorelease]; } - (instancetype)initWithObjCTypes: (const char *)types { self = [super init]; @try { size_t length; | > > > > > | 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 | } @implementation OFMethodSignature + (instancetype)signatureWithObjCTypes: (const char*)types { return [[[self alloc] initWithObjCTypes: types] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithObjCTypes: (const char *)types { self = [super init]; @try { size_t length; |
︙ | ︙ |
Modified src/OFMutableArchiveEntry.h from [ffb170561c] to [7bdf283c16].
1 | /* | | | | | | > > > > | < > | | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFArchiveEntry.h" OF_ASSUME_NONNULL_BEGIN /** * @protocol OFMutableArchiveEntry OFArchiveEntry.h ObjFW/OFArchiveEntry.h * * @brief A class which represents a mutable entry in an archive. */ @protocol OFMutableArchiveEntry <OFArchiveEntry> /** * @brief The file name of the entry. |
︙ | ︙ |
Modified src/OFMutableArray.h from [43a8133fa8] to [f701e95621].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFArray.h" OF_ASSUME_NONNULL_BEGIN /** @file */ |
︙ | ︙ | |||
49 50 51 52 53 54 55 56 57 58 59 60 61 62 | * number of objects. * * @param capacity The initial capacity for the OFMutableArray * @return A new autoreleased OFMutableArray */ + (instancetype)arrayWithCapacity: (size_t)capacity; /** * @brief Initializes an already allocated OFMutableArray with enough memory to * hold the specified number of objects. * * @param capacity The initial capacity for the OFMutableArray * @return An initialized OFMutableArray */ | > > > > > > > | | 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | * number of objects. * * @param capacity The initial capacity for the OFMutableArray * @return A new autoreleased OFMutableArray */ + (instancetype)arrayWithCapacity: (size_t)capacity; /** * @brief Initializes an OFMutableArray with no objects. * * @return An initialized OFMutableArray */ - (instancetype)init OF_DESIGNATED_INITIALIZER; /** * @brief Initializes an already allocated OFMutableArray with enough memory to * hold the specified number of objects. * * @param capacity The initial capacity for the OFMutableArray * @return An initialized OFMutableArray */ - (instancetype)initWithCapacity: (size_t)capacity OF_DESIGNATED_INITIALIZER; /** * @brief Adds an object to the end of the array. * * @param object An object to add */ - (void)addObject: (ObjectType)object; |
︙ | ︙ | |||
119 120 121 122 123 124 125 | * * @param index The index of the object to replace * @param object The replacement object */ - (void)setObject: (ObjectType)object atIndexedSubscript: (size_t)index; /** | | | 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | * * @param index The index of the object to replace * @param object The replacement object */ - (void)setObject: (ObjectType)object atIndexedSubscript: (size_t)index; /** * @brief Replaces all objects that have the same address as the specified * object with the other specified object. * * @param oldObject The object to replace * @param newObject The replacement object */ - (void)replaceObjectIdenticalTo: (ObjectType)oldObject withObject: (ObjectType)newObject; |
︙ | ︙ | |||
198 199 200 201 202 203 204 205 206 207 208 209 210 211 | * * @param selector The selector to use to sort the array. It's signature * should be the same as that of -[compare:]. * @param options The options to use when sorting the array */ - (void)sortUsingSelector: (SEL)selector options: (OFArraySortOptions)options; #ifdef OF_HAVE_BLOCKS /** * @brief Sorts the array using the specified comparator and options. * * @param comparator The comparator to use to sort the array * @param options The options to use when sorting the array */ | > > > > > > > > > > > | 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | * * @param selector The selector to use to sort the array. It's signature * should be the same as that of -[compare:]. * @param options The options to use when sorting the array */ - (void)sortUsingSelector: (SEL)selector options: (OFArraySortOptions)options; /** * @brief Sorts the array 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 */ - (void)sortUsingFunction: (OFCompareFunction)compare context: (nullable void *)context options: (OFArraySortOptions)options; #ifdef OF_HAVE_BLOCKS /** * @brief Sorts the array using the specified comparator and options. * * @param comparator The comparator to use to sort the array * @param options The options to use when sorting the array */ |
︙ | ︙ |
Modified src/OFMutableArray.m from [ba1c079bde] to [5945457370].
1 | /* | | | | | | > > > > | < > | < < | | < < < < < < < < < < | | | | | | > < < < < < < | < < < < < < < | < < < < | < < < < | < < < | < < < < | < < < < < < < < < < < < < | | | | | | | | < < < < < | < < < < | < | < < | < < < < < < < < > | < < < < < | < | | > > > > > > > > | < > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdlib.h> #include <string.h> #import "OFMutableArray.h" #import "OFConcreteMutableArray.h" #import "OFEnumerationMutationException.h" #import "OFInvalidArgumentException.h" #import "OFOutOfRangeException.h" static struct { Class isa; } placeholder; @interface OFPlaceholderMutableArray: OFMutableArray @end static void quicksort(OFMutableArray *array, size_t left, size_t right, OFCompareFunction compare, void *context, OFArraySortOptions options) { OFComparisonResult ascending, descending; if (options & OFArraySortDescending) { ascending = OFOrderedDescending; descending = OFOrderedAscending; } else { ascending = OFOrderedAscending; descending = OFOrderedDescending; } while (left < right) { size_t i = left; size_t j = right - 1; id pivot = [array objectAtIndex: right]; do { while (compare([array objectAtIndex: i], pivot, context) != descending && i < right) i++; while (compare([array objectAtIndex: j], pivot, context) != ascending && j > left) j--; if (i < j) [array exchangeObjectAtIndex: i withObjectAtIndex: j]; } while (i < j); if (compare([array objectAtIndex: i], pivot, context) == descending) [array exchangeObjectAtIndex: i withObjectAtIndex: right]; if (i > 0) quicksort(array, left, i - 1, compare, context, options); left = i + 1; } } @implementation OFPlaceholderMutableArray #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)init { return (id)[[OFConcreteMutableArray alloc] init]; } - (instancetype)initWithCapacity: (size_t)capacity { return (id)[[OFConcreteMutableArray alloc] initWithCapacity: capacity]; } - (instancetype)initWithObject: (id)object { return (id)[[OFConcreteMutableArray alloc] initWithObject: object]; } - (instancetype)initWithObjects: (id)firstObject, ... { id ret; va_list arguments; va_start(arguments, firstObject); ret = [[OFConcreteMutableArray alloc] initWithObject: firstObject arguments: arguments]; va_end(arguments); return ret; } - (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments { return (id)[[OFConcreteMutableArray alloc] initWithObject: firstObject arguments: arguments]; } - (instancetype)initWithArray: (OFArray *)array { return (id)[[OFConcreteMutableArray alloc] initWithArray: array]; } - (instancetype)initWithObjects: (id const *)objects count: (size_t)count { return (id)[[OFConcreteMutableArray alloc] initWithObjects: objects count: count]; } #ifdef __clang__ # pragma clang diagnostic pop #endif OF_SINGLETON_METHODS @end @implementation OFMutableArray + (void)initialize { if (self == [OFMutableArray class]) object_setClass((id)&placeholder, [OFPlaceholderMutableArray class]); } + (instancetype)alloc { if (self == [OFMutableArray class]) return (id)&placeholder; return [super alloc]; } + (instancetype)arrayWithCapacity: (size_t)capacity { return [[[self alloc] initWithCapacity: capacity] autorelease]; } - (instancetype)init { return [super init]; } #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)initWithObjects: (id const *)objects count: (size_t)count { OF_INVALID_INIT_METHOD } - (instancetype)initWithCapacity: (size_t)capacity { OF_INVALID_INIT_METHOD } #ifdef __clang__ # pragma clang diagnostic pop #endif - (id)copy { return [[OFArray alloc] initWithArray: self]; } - (void)addObject: (id)object |
︙ | ︙ | |||
305 306 307 308 309 310 311 | size_t count; if (oldObject == nil || newObject == nil) @throw [OFInvalidArgumentException exception]; count = self.count; | | | < < < < | 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | size_t count; if (oldObject == nil || newObject == nil) @throw [OFInvalidArgumentException exception]; count = self.count; for (size_t i = 0; i < count; i++) if ([self objectAtIndex: i] == oldObject) [self replaceObjectAtIndex: i withObject: newObject]; } - (void)removeObjectAtIndex: (size_t)idx { OF_UNRECOGNIZED_SELECTOR } |
︙ | ︙ | |||
411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 | } } - (void)sort { [self sortUsingSelector: @selector(compare:) options: 0]; } - (void)sortUsingSelector: (SEL)selector options: (OFArraySortOptions)options { size_t count = self.count; if (count == 0 || count == 1) return; | > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > | | 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 | } } - (void)sort { [self sortUsingSelector: @selector(compare:) options: 0]; } static OFComparisonResult selectorCompare(id left, id right, void *context) { SEL selector = context; OFComparisonResult (*comparator)(id, SEL, id) = (OFComparisonResult (*)(id, SEL, id)) [left methodForSelector: selector]; return comparator(left, selector, right); } - (void)sortUsingSelector: (SEL)selector options: (OFArraySortOptions)options { size_t count = self.count; if (count == 0 || count == 1) return; quicksort(self, 0, count - 1, selectorCompare, (void *)selector, options); } - (void)sortUsingFunction: (OFCompareFunction)compare context: (void *)context options: (OFArraySortOptions)options { size_t count = self.count; if (count == 0 || count == 1) return; quicksort(self, 0, count - 1, compare, context, options); } #ifdef OF_HAVE_BLOCKS static OFComparisonResult blockCompare(id left, id right, void *context) { OFComparator block = (OFComparator)context; return block(left, right); } - (void)sortUsingComparator: (OFComparator)comparator options: (OFArraySortOptions)options { size_t count = self.count; if (count == 0 || count == 1) return; quicksort(self, 0, count - 1, blockCompare, comparator, options); } #endif - (void)reverse { size_t i, j, count = self.count; |
︙ | ︙ |
Modified src/OFMutableData.h from [23548715da] to [d58a2cfa38].
1 | /* | | | | | | > > > > | < > | < < < | < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFData.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFMutableData OFData.h ObjFW/OFData.h * * @brief A class for storing and manipulating arbitrary data in an array. */ @interface OFMutableData: OFData /** * @brief All items of the OFMutableData as a C array. * * @warning The pointer is only valid until the OFMutableData is changed! * * Modifying the returned array directly is allowed and will change the contents * of the data. |
︙ | ︙ | |||
50 51 52 53 54 55 56 | /** * @brief The last item of the OFMutableData or `NULL`. */ @property OF_NULLABLE_PROPERTY (readonly, nonatomic) void *mutableLastItem OF_RETURNS_INNER_POINTER; | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | /** * @brief The last item of the OFMutableData or `NULL`. */ @property OF_NULLABLE_PROPERTY (readonly, nonatomic) void *mutableLastItem OF_RETURNS_INNER_POINTER; /** * @brief Creates a new OFMutableData with enough memory to hold the specified * number of items which all have an item size of 1. * * @param capacity The initial capacity for the OFMutableData * @return A new autoreleased OFMutableData */ + (instancetype)dataWithCapacity: (size_t)capacity; /** * @brief Creates a new OFMutableData with enough memory to hold the specified * number of items which all have the same specified size. * * @param itemSize The size of a single element in the OFMutableData * @param capacity The initial capacity for the OFMutableData * @return A new autoreleased OFMutableData */ + (instancetype)dataWithItemSize: (size_t)itemSize capacity: (size_t)capacity; /** * @brief Initializes an already allocated OFMutableData with enough memory to * hold the the specified number of items which all have an item size of * 1. * * @param capacity The initial capacity for the OFMutableData * @return An initialized OFMutableData |
︙ | ︙ |
Modified src/OFMutableData.m from [b4151ce5ed] to [5e6a229fd6].
1 | /* | | | | | | > > > > | < > | | < < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > | > < < < < < < < < < < < < < < < < < < < < < < < | | < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < > | | > | > | > > > | | > > | > | > | < < | < < < < < < < < < < | < < < < < < < < < | < < < < < < < < < < < < | < < < < < < < < < < | < < < < < < < < < < < | < | | < < < < | > < < | < | | | < < < < < < | < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdlib.h> #include <string.h> #include <limits.h> #import "OFMutableData.h" #import "OFConcreteMutableData.h" #import "OFOutOfRangeException.h" static struct { Class isa; } placeholder; @interface OFPlaceholderMutableData: OFMutableData @end @implementation OFPlaceholderMutableData - (instancetype)init { return (id)[[OFConcreteMutableData alloc] init]; } - (instancetype)initWithItemSize: (size_t)itemSize { return (id)[[OFConcreteMutableData alloc] initWithItemSize: itemSize]; } - (instancetype)initWithItems: (const void *)items count: (size_t)count { return (id)[[OFConcreteMutableData alloc] initWithItems: items count: count]; } - (instancetype)initWithItems: (const void *)items count: (size_t)count itemSize: (size_t)itemSize { return (id)[[OFConcreteMutableData alloc] initWithItems: items count: count itemSize: itemSize]; } - (instancetype)initWithItemsNoCopy: (void *)items count: (size_t)count freeWhenDone: (bool)freeWhenDone { return (id)[[OFConcreteMutableData alloc] initWithItemsNoCopy: items count: count freeWhenDone: freeWhenDone]; } - (instancetype)initWithItemsNoCopy: (void *)items count: (size_t)count itemSize: (size_t)itemSize freeWhenDone: (bool)freeWhenDone { return (id)[[OFConcreteMutableData alloc] initWithItemsNoCopy: items count: count itemSize: itemSize freeWhenDone: freeWhenDone]; } #ifdef OF_HAVE_FILES - (instancetype)initWithContentsOfFile: (OFString *)path { return (id)[[OFConcreteMutableData alloc] initWithContentsOfFile: path]; } #endif - (instancetype)initWithContentsOfIRI: (OFIRI *)IRI { return (id)[[OFConcreteMutableData alloc] initWithContentsOfIRI: IRI]; } - (instancetype)initWithStringRepresentation: (OFString *)string { return (id)[[OFConcreteMutableData alloc] initWithStringRepresentation: string]; } - (instancetype)initWithBase64EncodedString: (OFString *)string { return (id)[[OFConcreteMutableData alloc] initWithBase64EncodedString: string]; } - (instancetype)initWithCapacity: (size_t)capacity { return (id)[[OFConcreteMutableData alloc] initWithCapacity: capacity]; } - (instancetype)initWithItemSize: (size_t)itemSize capacity: (size_t)capacity { return (id)[[OFConcreteMutableData alloc] initWithItemSize: itemSize capacity: capacity]; } OF_SINGLETON_METHODS @end @implementation OFMutableData + (void)initialize { if (self == [OFMutableData class]) object_setClass((id)&placeholder, [OFPlaceholderMutableData class]); } + (instancetype)alloc { if (self == [OFMutableData class]) return (id)&placeholder; return [super alloc]; } + (instancetype)dataWithItemSize: (size_t)itemSize { return [[[self alloc] initWithItemSize: itemSize] autorelease]; } + (instancetype)dataWithCapacity: (size_t)capacity { return [[[self alloc] initWithCapacity: capacity] autorelease]; } + (instancetype)dataWithItemSize: (size_t)itemSize capacity: (size_t)capacity { return [[[self alloc] initWithItemSize: itemSize capacity: capacity] autorelease]; } - (instancetype)initWithItemSize: (size_t)itemSize { return [self initWithItemSize: 1 capacity: 0]; } - (instancetype)initWithCapacity: (size_t)capacity { return [self initWithItemSize: 1 capacity: capacity]; } - (instancetype)initWithItemSize: (size_t)itemSize capacity: (size_t)capacity { OF_INVALID_INIT_METHOD } - (instancetype)initWithItemsNoCopy: (void *)items count: (size_t)count itemSize: (size_t)itemSize freeWhenDone: (bool)freeWhenDone { self = [self initWithItems: items count: count itemSize: itemSize]; if (freeWhenDone) OFFreeMemory(items); return self; } - (void *)mutableItems { OF_UNRECOGNIZED_SELECTOR } - (void *)mutableItemAtIndex: (size_t)idx { if (idx >= self.count) @throw [OFOutOfRangeException exception]; return (unsigned char *)self.mutableItems + idx * self.itemSize; } - (void *)mutableFirstItem { void *mutableItems = self.mutableItems; if (mutableItems == NULL || self.count == 0) return NULL; return mutableItems; } - (void *)mutableLastItem { unsigned char *mutableItems = self.mutableItems; size_t count = self.count; if (mutableItems == NULL || count == 0) return NULL; return mutableItems + (count - 1) * self.itemSize; } - (OFData *)subdataWithRange: (OFRange)range { size_t itemSize; if (range.length > SIZE_MAX - range.location || range.location + range.length > self.count) @throw [OFOutOfRangeException exception]; itemSize = self.itemSize; return [OFData dataWithItems: (unsigned char *)self.mutableItems + (range.location * itemSize) count: range.length itemSize: itemSize]; } - (void)addItem: (const void *)item { [self insertItems: item atIndex: self.count count: 1]; } - (void)insertItem: (const void *)item atIndex: (size_t)idx { [self insertItems: item atIndex: idx count: 1]; } - (void)addItems: (const void *)items count: (size_t)count { [self insertItems: items atIndex: self.count count: count]; } - (void)insertItems: (const void *)items atIndex: (size_t)idx count: (size_t)count { OF_UNRECOGNIZED_SELECTOR } - (void)increaseCountBy: (size_t)count { OF_UNRECOGNIZED_SELECTOR } - (void)removeItemAtIndex: (size_t)idx { [self removeItemsInRange: OFMakeRange(idx, 1)]; } - (void)removeItemsInRange: (OFRange)range { OF_UNRECOGNIZED_SELECTOR } - (void)removeLastItem { size_t count = self.count; if (count == 0) return; [self removeItemsInRange: OFMakeRange(count - 1, 1)]; } - (void)removeAllItems { [self removeItemsInRange: OFMakeRange(0, self.count)]; } - (id)copy { return [[OFData alloc] initWithItems: self.mutableItems count: self.count itemSize: self.itemSize]; } - (void)makeImmutable { } @end |
Modified src/OFMutableDictionary.h from [851a8f19f7] to [529de7c130].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFDictionary.h" OF_ASSUME_NONNULL_BEGIN /** @file */ |
︙ | ︙ | |||
50 51 52 53 54 55 56 57 58 59 60 61 62 63 | * specified number of objects. * * @param capacity The initial capacity for the OFMutableDictionary * @return A new autoreleased OFMutableDictionary */ + (instancetype)dictionaryWithCapacity: (size_t)capacity; /** * @brief Initializes an already allocated OFMutableDictionary with enough * memory to hold the specified number of objects. * * @param capacity The initial capacity for the OFMutableDictionary * @return An initialized OFMutableDictionary */ | > > > > > > > | | 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | * specified number of objects. * * @param capacity The initial capacity for the OFMutableDictionary * @return A new autoreleased OFMutableDictionary */ + (instancetype)dictionaryWithCapacity: (size_t)capacity; /** * @brief Initializes an already allocated OFMutableDictionary to be empty. * * @return An initialized OFMutableDictionary */ - (instancetype)init OF_DESIGNATED_INITIALIZER; /** * @brief Initializes an already allocated OFMutableDictionary with enough * memory to hold the specified number of objects. * * @param capacity The initial capacity for the OFMutableDictionary * @return An initialized OFMutableDictionary */ - (instancetype)initWithCapacity: (size_t)capacity OF_DESIGNATED_INITIALIZER; /** * @brief Sets an object for a key. * * A key can be any object that conforms to the OFCopying protocol. * * @param key The key to set |
︙ | ︙ |
Modified src/OFMutableDictionary.m from [459ca84c71] to [29c2abbd28].
1 | /* | | | | | | > > > > | < > | | | | | | | | | | | < < < < < < | < < < < | < < < < < < < < < < < < < > | < < < < | < | > > > > > > > | < > | < > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdlib.h> #import "OFConcreteMutableDictionary.h" #import "OFArray.h" #import "OFString.h" static struct { Class isa; } placeholder; @interface OFPlaceholderMutableDictionary: OFDictionary @end @implementation OFPlaceholderMutableDictionary - (instancetype)init { return (id)[[OFConcreteMutableDictionary alloc] init]; } - (instancetype)initWithDictionary: (OFDictionary *)dictionary { return (id)[[OFConcreteMutableDictionary alloc] initWithDictionary: dictionary]; } - (instancetype)initWithObject: (id)object forKey: (id)key { return (id)[[OFConcreteMutableDictionary alloc] initWithObject: object forKey: key]; } - (instancetype)initWithObjects: (OFArray *)objects forKeys: (OFArray *)keys { return (id)[[OFConcreteMutableDictionary alloc] initWithObjects: objects forKeys: keys]; } - (instancetype)initWithObjects: (id const *)objects forKeys: (id const *)keys count: (size_t)count { return (id)[[OFConcreteMutableDictionary alloc] initWithObjects: objects forKeys: keys count: count]; } - (instancetype)initWithKeysAndObjects: (id)firstKey, ... { id ret; va_list arguments; va_start(arguments, firstKey); ret = (id)[[OFConcreteMutableDictionary alloc] initWithKey: firstKey arguments: arguments]; va_end(arguments); return ret; } - (instancetype)initWithKey: (id)firstKey arguments: (va_list)arguments { return (id)[[OFConcreteMutableDictionary alloc] initWithKey: firstKey arguments: arguments]; } - (instancetype)initWithCapacity: (size_t)capacity { return (id)[[OFConcreteMutableDictionary alloc] initWithCapacity: capacity]; } OF_SINGLETON_METHODS @end @implementation OFMutableDictionary + (void)initialize { if (self == [OFMutableDictionary class]) object_setClass((id)&placeholder, [OFPlaceholderMutableDictionary class]); } + (instancetype)alloc { if (self == [OFMutableDictionary class]) return (id)&placeholder; return [super alloc]; } + (instancetype)dictionaryWithCapacity: (size_t)capacity { return [[[self alloc] initWithCapacity: capacity] autorelease]; } - (instancetype)init { return [super init]; } #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)initWithObjects: (id const *)objects forKeys: (id const *)keys count: (size_t)count { OF_INVALID_INIT_METHOD } - (instancetype)initWithCapacity: (size_t)capacity { OF_INVALID_INIT_METHOD } #ifdef __clang__ # pragma clang diagnostic pop #endif - (void)setObject: (id)object forKey: (id)key { OF_UNRECOGNIZED_SELECTOR } - (void)setObject: (id)object forKeyedSubscript: (id)key |
︙ | ︙ |
Renamed and modified src/OFMutableURI.h [9400cfdc05] to src/OFMutableIRI.h [549868d3c9].
1 | /* | | | | | | > > > > | < > | | | | | > > | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > > > > > > > > > > > > > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFIRI.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFMutableIRI OFIRI.h ObjFW/OFIRI.h * * @brief A class for representing IRIs, URIs, URLs and URNs, for parsing them, * accessing parts of them as well as modifying them. * * This class follows RFC 3976 and RFC 3987. */ @interface OFMutableIRI: OFIRI { OF_RESERVE_IVARS(OFMutableIRI, 4) } /** * @brief The scheme part of the IRI. * * @throw OFInvalidFormatException The scheme being set is not in the correct * format */ @property (readwrite, copy, nonatomic) OFString *scheme; /** * @brief The host part of the IRI. */ @property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFString *host; /** * @brief The host part of the IRI in percent-encoded form. * * Setting this retains the original percent-encoding used - if more characters * than necessary are percent-encoded, it is kept this way. * * @throw OFInvalidFormatException The host being set is not in the correct * format */ @property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFString *percentEncodedHost; /** * @brief The port part of the IRI. * * @throw OFInvalidArgumentException The port is not valid (e.g. negative or * too big) */ @property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFNumber *port; /** * @brief The user part of the IRI. */ @property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFString *user; /** * @brief The user part of the IRI in percent-encoded form. * * Setting this retains the original percent-encoding used - if more characters * than necessary are percent-encoded, it is kept this way. * * @throw OFInvalidFormatException The user being set is not in the correct * format */ @property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFString *percentEncodedUser; /** * @brief The password part of the IRI. */ @property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFString *password; /** * @brief The password part of the IRI in percent-encoded form. * * Setting this retains the original percent-encoding used - if more characters * than necessary are percent-encoded, it is kept this way. * * @throw OFInvalidFormatException The password being set is not in the correct * format */ @property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFString *percentEncodedPassword; /** * @brief The path part of the IRI. */ @property (readwrite, copy, nonatomic) OFString *path; /** * @brief The path part of the IRI in percent-encoded form. * * Setting this retains the original percent-encoding used - if more characters * than necessary are percent-encoded, it is kept this way. * * @throw OFInvalidFormatException The path being set is not in the correct * format */ @property (readwrite, copy, nonatomic) OFString *percentEncodedPath; /** * @brief The path of the IRI split into components. * * The first component must always be empty to designate the root. * * @throw OFInvalidFormatException The path components being set are not in the * correct format */ @property (readwrite, copy, nonatomic) OFArray OF_GENERIC(OFString *) *pathComponents; /** * @brief The query part of the IRI. */ @property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFString *query; /** * @brief The query part of the IRI in percent-encoded form. * * Setting this retains the original percent-encoding used - if more characters * than necessary are percent-encoded, it is kept this way. * * @throw OFInvalidFormatException The query being set is not in the correct * format */ @property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFString *percentEncodedQuery; /** * @brief The query part of the IRI as an array. * * For example, a query like `key1=value1&key2=value2` would correspond to the * following array: * * @[ * [OFPair pairWithFirstObject: @"key1" secondObject: @"value1"], * [OFPair pairWithFirstObject: @"key2" secondObject: @"value2"], * ] * * @throw OFInvalidFormatException The query is not in the correct format */ @property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFArray OF_GENERIC(OFPair OF_GENERIC(OFString *, OFString *) *) *queryItems; /** * @brief The fragment part of the IRI. */ @property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFString *fragment; /** * @brief The fragment part of the IRI in percent-encoded form. * * Setting this retains the original percent-encoding used - if more characters * than necessary are percent-encoded, it is kept this way. * * @throw OFInvalidFormatException The fragment being set is not in the correct * format */ @property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFString *percentEncodedFragment; /** * @brief Creates a new mutable IRI with the specified schemed. * * @param scheme The scheme for the IRI * @return A new, autoreleased OFMutableIRI */ + (instancetype)IRIWithScheme: (OFString *)scheme; /** * @brief Initializes an already allocated mutable IRI with the specified * schemed. * * @param scheme The scheme for the IRI * @return An initialized OFMutableIRI */ - (instancetype)initWithScheme: (OFString *)scheme; /** * @brief Appends the specified path component. * * @param component The component to append */ - (void)appendPathComponent: (OFString *)component; /** * @brief Appends the specified path component. * * @param component The component to append * @param isDirectory Whether the path is a directory, in which case a slash is * appended if there is no slash yet */ - (void)appendPathComponent: (OFString *)component isDirectory: (bool)isDirectory; /** * @brief Appends the specified path extension * * @param extension The path extension to append */ - (void)appendPathExtension: (OFString *)extension; /** * @brief Deletes the last path component. */ - (void)deleteLastPathComponent; /** * @brief Deletes the path extension. */ - (void)deletePathExtension; /** * @brief Resolves relative subpaths. */ - (void)standardizePath; /** * @brief Converts the mutable IRI to an immutable IRI. */ - (void)makeImmutable; @end OF_ASSUME_NONNULL_END |
Renamed and modified src/OFMutableURI.m [375c07c449] to src/OFMutableIRI.m [0e3da0ee00].
1 | /* | | | | | | > > > > | < > | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFMutableIRI.h" #import "OFIRI+Private.h" #import "OFArray.h" #import "OFDictionary.h" #ifdef OF_HAVE_FILES # import "OFFileManager.h" #endif #import "OFNumber.h" #import "OFPair.h" #import "OFString.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" @implementation OFMutableIRI @dynamic scheme, host, percentEncodedHost, port, user, percentEncodedUser; @dynamic password, percentEncodedPassword, path, percentEncodedPath; @dynamic pathComponents, query, percentEncodedQuery, queryItems, fragment; @dynamic percentEncodedFragment; + (instancetype)IRIWithScheme: (OFString *)scheme { return [[[self alloc] initWithScheme: scheme] autorelease]; } - (instancetype)initWithScheme: (OFString *)scheme { self = [super of_init]; |
︙ | ︙ | |||
59 60 61 62 63 64 65 | { void *pool = objc_autoreleasePoolPush(); OFString *old = _scheme; if (scheme.length < 1 || !OFASCIIIsAlpha(*scheme.UTF8String)) @throw [OFInvalidFormatException exception]; | | | | | | | | | 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | { void *pool = objc_autoreleasePoolPush(); OFString *old = _scheme; if (scheme.length < 1 || !OFASCIIIsAlpha(*scheme.UTF8String)) @throw [OFInvalidFormatException exception]; OFIRIVerifyIsEscaped(scheme, [OFCharacterSet IRISchemeAllowedCharacterSet], false); _scheme = [scheme.lowercaseString copy]; [old release]; objc_autoreleasePoolPop(pool); } - (void)setHost: (OFString *)host { void *pool = objc_autoreleasePoolPush(); OFString *old = _percentEncodedHost; if (OFIRIIsIPv6Host(host)) _percentEncodedHost = [[OFString alloc] initWithFormat: @"[%@]", host]; else _percentEncodedHost = [[host stringByAddingPercentEncodingWithAllowedCharacters: [OFCharacterSet IRIHostAllowedCharacterSet]] copy]; [old release]; objc_autoreleasePoolPop(pool); } - (void)setPercentEncodedHost: (OFString *)percentEncodedHost { OFString *old; if ([percentEncodedHost hasPrefix: @"["] && [percentEncodedHost hasSuffix: @"]"]) { if (!OFIRIIsIPv6Host([percentEncodedHost substringWithRange: OFMakeRange(1, percentEncodedHost.length - 2)])) @throw [OFInvalidFormatException exception]; } else if (percentEncodedHost != nil) OFIRIVerifyIsEscaped(percentEncodedHost, [OFCharacterSet IRIHostAllowedCharacterSet], true); old = _percentEncodedHost; _percentEncodedHost = [percentEncodedHost copy]; [old release]; } - (void)setPort: (OFNumber *)port |
︙ | ︙ | |||
123 124 125 126 127 128 129 | - (void)setUser: (OFString *)user { void *pool = objc_autoreleasePoolPush(); OFString *old = _percentEncodedUser; _percentEncodedUser = [[user stringByAddingPercentEncodingWithAllowedCharacters: | | | | | | | | | | | 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | - (void)setUser: (OFString *)user { void *pool = objc_autoreleasePoolPush(); OFString *old = _percentEncodedUser; _percentEncodedUser = [[user stringByAddingPercentEncodingWithAllowedCharacters: [OFCharacterSet IRIUserAllowedCharacterSet]] copy]; [old release]; objc_autoreleasePoolPop(pool); } - (void)setPercentEncodedUser: (OFString *)percentEncodedUser { OFString *old; if (percentEncodedUser != nil) OFIRIVerifyIsEscaped(percentEncodedUser, [OFCharacterSet IRIUserAllowedCharacterSet], true); old = _percentEncodedUser; _percentEncodedUser = [percentEncodedUser copy]; [old release]; } - (void)setPassword: (OFString *)password { void *pool = objc_autoreleasePoolPush(); OFString *old = _percentEncodedPassword; _percentEncodedPassword = [[password stringByAddingPercentEncodingWithAllowedCharacters: [OFCharacterSet IRIPasswordAllowedCharacterSet]] copy]; [old release]; objc_autoreleasePoolPop(pool); } - (void)setPercentEncodedPassword: (OFString *)percentEncodedPassword { OFString *old; if (percentEncodedPassword != nil) OFIRIVerifyIsEscaped(percentEncodedPassword, [OFCharacterSet IRIPasswordAllowedCharacterSet], true); old = _percentEncodedPassword; _percentEncodedPassword = [percentEncodedPassword copy]; [old release]; } - (void)setPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFString *old = _percentEncodedPath; _percentEncodedPath = [[path stringByAddingPercentEncodingWithAllowedCharacters: [OFCharacterSet IRIPathAllowedCharacterSet]] copy]; [old release]; objc_autoreleasePoolPop(pool); } - (void)setPercentEncodedPath: (OFString *)percentEncodedPath { OFString *old; OFIRIVerifyIsEscaped(percentEncodedPath, [OFCharacterSet IRIPathAllowedCharacterSet], true); old = _percentEncodedPath; _percentEncodedPath = [percentEncodedPath copy]; [old release]; } - (void)setPathComponents: (OFArray *)components |
︙ | ︙ | |||
222 223 224 225 226 227 228 | - (void)setQuery: (OFString *)query { void *pool = objc_autoreleasePoolPush(); OFString *old = _percentEncodedQuery; _percentEncodedQuery = [[query stringByAddingPercentEncodingWithAllowedCharacters: | | | | | 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | - (void)setQuery: (OFString *)query { void *pool = objc_autoreleasePoolPush(); OFString *old = _percentEncodedQuery; _percentEncodedQuery = [[query stringByAddingPercentEncodingWithAllowedCharacters: [OFCharacterSet IRIQueryAllowedCharacterSet]] copy]; [old release]; objc_autoreleasePoolPop(pool); } - (void)setPercentEncodedQuery: (OFString *)percentEncodedQuery { OFString *old; if (percentEncodedQuery != nil) OFIRIVerifyIsEscaped(percentEncodedQuery, [OFCharacterSet IRIQueryAllowedCharacterSet], true); old = _percentEncodedQuery; _percentEncodedQuery = [percentEncodedQuery copy]; [old release]; } - (void)setQueryItems: |
︙ | ︙ | |||
259 260 261 262 263 264 265 | [_percentEncodedQuery release]; _percentEncodedQuery = nil; return; } pool = objc_autoreleasePoolPush(); percentEncodedQuery = [OFMutableString string]; | | | 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | [_percentEncodedQuery release]; _percentEncodedQuery = nil; return; } pool = objc_autoreleasePoolPush(); percentEncodedQuery = [OFMutableString string]; characterSet = [OFCharacterSet IRIQueryKeyValueAllowedCharacterSet]; for (OFPair OF_GENERIC(OFString *, OFString *) *item in queryItems) { OFString *key = [item.firstObject stringByAddingPercentEncodingWithAllowedCharacters: characterSet]; OFString *value = [item.secondObject stringByAddingPercentEncodingWithAllowedCharacters: |
︙ | ︙ | |||
289 290 291 292 293 294 295 | - (void)setFragment: (OFString *)fragment { void *pool = objc_autoreleasePoolPush(); OFString *old = _percentEncodedFragment; _percentEncodedFragment = [[fragment stringByAddingPercentEncodingWithAllowedCharacters: | | | | | | < | | < | < < | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 | - (void)setFragment: (OFString *)fragment { void *pool = objc_autoreleasePoolPush(); OFString *old = _percentEncodedFragment; _percentEncodedFragment = [[fragment stringByAddingPercentEncodingWithAllowedCharacters: [OFCharacterSet IRIFragmentAllowedCharacterSet]] copy]; [old release]; objc_autoreleasePoolPop(pool); } - (void)setPercentEncodedFragment: (OFString *)percentEncodedFragment { OFString *old; if (percentEncodedFragment != nil) OFIRIVerifyIsEscaped(percentEncodedFragment, [OFCharacterSet IRIFragmentAllowedCharacterSet], true); old = _percentEncodedFragment; _percentEncodedFragment = [percentEncodedFragment copy]; [old release]; } - (id)copy { OFMutableIRI *copy = [self mutableCopy]; [copy makeImmutable]; return copy; } - (void)appendPathComponent: (OFString *)component { [self appendPathComponent: component isDirectory: false]; #ifdef OF_HAVE_FILES if ([_scheme isEqual: @"file"] && ![_percentEncodedPath hasSuffix: @"/"] && [[OFFileManager defaultManager] directoryExistsAtIRI: self]) { OFString *path = [[_percentEncodedPath stringByAppendingString: @"/"] retain]; [_percentEncodedPath release]; _percentEncodedPath = path; } #endif } - (void)appendPathComponent: (OFString *)component isDirectory: (bool)isDirectory { void *pool; OFString *path; if ([component isEqual: @"/"] && [_percentEncodedPath hasSuffix: @"/"]) return; pool = objc_autoreleasePoolPush(); component = [component stringByAddingPercentEncodingWithAllowedCharacters: [OFCharacterSet IRIPathAllowedCharacterSet]]; #if defined(OF_WINDOWS) || defined(OF_MSDOS) if ([_percentEncodedPath hasSuffix: @"/"] || ([_scheme isEqual: @"file"] && [_percentEncodedPath hasSuffix: @":"])) #else if ([_percentEncodedPath hasSuffix: @"/"]) #endif path = [_percentEncodedPath stringByAppendingString: component]; else path = [_percentEncodedPath stringByAppendingFormat: @"/%@", component]; if (isDirectory && ![path hasSuffix: @"/"]) path = [path stringByAppendingString: @"/"]; [_percentEncodedPath release]; _percentEncodedPath = [path retain]; objc_autoreleasePoolPop(pool); } - (void)appendPathExtension: (OFString *)extension { void *pool; OFMutableString *path; bool isDirectory = false; if (_percentEncodedPath.length == 0) return; pool = objc_autoreleasePoolPush(); path = [[_percentEncodedPath mutableCopy] autorelease]; extension = [extension stringByAddingPercentEncodingWithAllowedCharacters: [OFCharacterSet IRIPathAllowedCharacterSet]]; if ([path hasSuffix: @"/"]) { [path deleteCharactersInRange: OFMakeRange(path.length - 1, 1)]; isDirectory = true; } [path appendFormat: @".%@", extension]; if (isDirectory) [path appendString: @"/"]; [path makeImmutable]; [_percentEncodedPath release]; _percentEncodedPath = [path retain]; objc_autoreleasePoolPop(pool); } - (void)deleteLastPathComponent { void *pool = objc_autoreleasePoolPush(); OFString *path = _percentEncodedPath; size_t pos; if (path.length == 0 || [path isEqual: @"/"]) { objc_autoreleasePoolPop(pool); return; } if ([path hasSuffix: @"/"]) path = [path substringToIndex: path.length - 1]; pos = [path rangeOfString: @"/" options: OFStringSearchBackwards].location; if (pos == OFNotFound) { objc_autoreleasePoolPop(pool); return; } path = [path substringToIndex: pos + 1]; [_percentEncodedPath release]; _percentEncodedPath = [path retain]; objc_autoreleasePoolPop(pool); } - (void)deletePathExtension { void *pool = objc_autoreleasePoolPush(); OFMutableString *path = [[_percentEncodedPath mutableCopy] autorelease]; bool isDirectory = false; size_t pos; if ([path hasSuffix: @"/"]) { [path deleteCharactersInRange: OFMakeRange(path.length - 1, 1)]; isDirectory = true; } pos = [path rangeOfString: @"." options: OFStringSearchBackwards].location; if (pos == OFNotFound) { objc_autoreleasePoolPop(pool); return; } [path deleteCharactersInRange: OFMakeRange(pos, path.length - pos)]; if (isDirectory) [path appendString: @"/"]; [path makeImmutable]; [_percentEncodedPath release]; _percentEncodedPath = [path retain]; objc_autoreleasePoolPop(pool); } - (void)standardizePath |
︙ | ︙ | |||
430 431 432 433 434 435 436 | self.percentEncodedPath = path; objc_autoreleasePoolPop(pool); } - (void)makeImmutable { | | | 522 523 524 525 526 527 528 529 530 531 | self.percentEncodedPath = path; objc_autoreleasePoolPop(pool); } - (void)makeImmutable { object_setClass(self, [OFIRI class]); } @end |
Modified src/OFMutableLHAArchiveEntry.h from [5bfb2f1e47] to [196b52ae24].
1 | /* | | | | | | > > > > | < > | < | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFLHAArchiveEntry.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFMutableLHAArchiveEntry OFLHAArchiveEntry.h ObjFW/OFHAArchiveEntry.h * * @brief A class which represents a mutable entry in an LHA archive. */ @interface OFMutableLHAArchiveEntry: OFLHAArchiveEntry <OFMutableArchiveEntry> { OF_RESERVE_IVARS(OFMutableLHAArchiveEntry, 4) } |
︙ | ︙ |
Modified src/OFMutableLHAArchiveEntry.m from [84adbb8df8] to [f305542721].
1 | /* | | | | | | > > > > | < > | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFMutableLHAArchiveEntry.h" #import "OFLHAArchiveEntry+Private.h" #import "OFArray.h" #import "OFData.h" #import "OFDate.h" #import "OFNumber.h" #import "OFString.h" @implementation OFMutableLHAArchiveEntry |
︙ | ︙ |
Modified src/OFMutablePair.h from [fd02ba0f90] to [a8445e5058].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFPair.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFMutablePair OFPair.h ObjFW/OFPair.h * * @brief A class for storing a pair of two objects. */ @interface OFMutablePair OF_GENERIC(FirstType, SecondType): OFPair OF_GENERIC(FirstType, SecondType) #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) # define FirstType id |
︙ | ︙ |
Modified src/OFMutablePair.m from [6901454ea9] to [1cf4d9c670].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFMutablePair.h" @implementation OFMutablePair |
︙ | ︙ |
Modified src/OFMutableSet.h from [c05177c6a6] to [c0b42ff301].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFSet.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ | |||
34 35 36 37 38 39 40 41 42 43 44 45 46 47 | * number of objects. * * @param capacity The initial capacity for the OFMutableSet * @return A new autoreleased OFMutableSet */ + (instancetype)setWithCapacity: (size_t)capacity; /** * @brief Initializes an already allocated OFMutableSet with enough memory to * hold the specified number of objects. * * @param capacity The initial capacity for the OFMutableSet * @return An initialized OFMutableSet */ | > > > > > > > | | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | * number of objects. * * @param capacity The initial capacity for the OFMutableSet * @return A new autoreleased OFMutableSet */ + (instancetype)setWithCapacity: (size_t)capacity; /** * @brief Initializes an already allocated OFMutableSet to be empty. * * @return An initialized OFMutableSet */ - (instancetype)init OF_DESIGNATED_INITIALIZER; /** * @brief Initializes an already allocated OFMutableSet with enough memory to * hold the specified number of objects. * * @param capacity The initial capacity for the OFMutableSet * @return An initialized OFMutableSet */ - (instancetype)initWithCapacity: (size_t)capacity OF_DESIGNATED_INITIALIZER; /** * @brief Adds the specified object to the set. * * @param object The object to add to the set */ - (void)addObject: (ObjectType)object; |
︙ | ︙ |
Modified src/OFMutableSet.m from [b126234b89] to [bbb9f25aa2].
1 | /* | | | | | | > > > > | < > | < < > | | | > > > > > > | | | | | | < < < < < < | | < < < < | < < < < | < | < | < < < < | > < < < < < | < | | > > > > > > > | < > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdlib.h> #import "OFMutableSet.h" #import "OFConcreteMutableSet.h" #import "OFString.h" static struct { Class isa; } placeholder; @interface OFPlaceholderMutableSet: OFMutableSet @end @implementation OFPlaceholderMutableSet #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)init { return (id)[[OFConcreteMutableSet alloc] init]; } - (instancetype)initWithSet: (OFSet *)set { return (id)[[OFConcreteMutableSet alloc] initWithSet: set]; } - (instancetype)initWithArray: (OFArray *)array { return (id)[[OFConcreteMutableSet alloc] initWithArray: array]; } - (instancetype)initWithObjects: (id)firstObject, ... { id ret; va_list arguments; va_start(arguments, firstObject); ret = [[OFConcreteMutableSet alloc] initWithObject: firstObject arguments: arguments]; va_end(arguments); return ret; } - (instancetype)initWithObjects: (id const *)objects count: (size_t)count { return (id)[[OFConcreteMutableSet alloc] initWithObjects: objects count: count]; } - (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments { return (id)[[OFConcreteMutableSet alloc] initWithObject: firstObject arguments: arguments]; } - (instancetype)initWithCapacity: (size_t)capacity { return (id)[[OFConcreteMutableSet alloc] initWithCapacity: capacity]; } #ifdef __clang__ # pragma clang diagnostic pop #endif OF_SINGLETON_METHODS @end @implementation OFMutableSet + (void)initialize { if (self == [OFMutableSet class]) object_setClass((id)&placeholder, [OFPlaceholderMutableSet class]); } + (instancetype)alloc { if (self == [OFMutableSet class]) return (id)&placeholder; return [super alloc]; } + (instancetype)setWithCapacity: (size_t)capacity { return [[[self alloc] initWithCapacity: capacity] autorelease]; } - (instancetype)init { return [super init]; } #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)initWithObjects: (id const *)objects count: (size_t)count { OF_INVALID_INIT_METHOD } - (instancetype)initWithCapacity: (size_t)capacity { OF_INVALID_INIT_METHOD } #ifdef __clang__ # pragma clang diagnostic pop #endif - (id)copy { return [[OFSet alloc] initWithSet: self]; } - (void)addObject: (id)object |
︙ | ︙ | |||
170 171 172 173 174 175 176 | cArray = OFAllocMemory(count, sizeof(id)); @try { size_t i; i = 0; for (id object in self) { | | | 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | cArray = OFAllocMemory(count, sizeof(id)); @try { size_t i; i = 0; for (id object in self) { OFAssert(i < count); cArray[i++] = object; } for (i = 0; i < count; i++) if (![set containsObject: cArray[i]]) [self removeObject: cArray[i]]; } @finally { |
︙ | ︙ |
Modified src/OFMutableString.h from [f372a7a142] to [7801b02182].
1 | /* | | | | | | > | < | < | > | | > | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFString.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFMutableString OFString.h ObjFW/OFString.h * * @brief A class for storing and modifying strings. */ @interface OFMutableString: OFString /** |
︙ | ︙ | |||
177 178 179 180 181 182 183 | /** * @brief Replaces all occurrences of a string in the specified range with * another string. * * @param string The string to replace * @param replacement The string with which it should be replaced | | | 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | /** * @brief Replaces all occurrences of a string in the specified range with * another string. * * @param string The string to replace * @param replacement The string with which it should be replaced * @param options Options modifying search behavior * Possible values: None yet * @param range The range in which the string should be replaced */ - (void)replaceOccurrencesOfString: (OFString *)string withString: (OFString *)replacement options: (int)options range: (OFRange)range; |
︙ | ︙ | |||
206 207 208 209 210 211 212 | - (void)deleteEnclosingWhitespaces; /** * @brief Converts the mutable string to an immutable string. */ - (void)makeImmutable; @end | < < < | 206 207 208 209 210 211 212 213 214 | - (void)deleteEnclosingWhitespaces; /** * @brief Converts the mutable string to an immutable string. */ - (void)makeImmutable; @end OF_ASSUME_NONNULL_END |
Modified src/OFMutableString.m from [eb3bef8a08] to [f4575ddf27].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdarg.h> #include <stdlib.h> #include <string.h> |
︙ | ︙ | |||
29 30 31 32 33 34 35 | #import "unicode.h" static struct { Class isa; } placeholder; | | | > > > > > > | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | #import "unicode.h" static struct { Class isa; } placeholder; @interface OFPlaceholderMutableString: OFMutableString @end @implementation OFPlaceholderMutableString #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)init { return (id)[[OFMutableUTF8String alloc] init]; } - (instancetype)initWithUTF8String: (const char *)UTF8String { |
︙ | ︙ | |||
170 171 172 173 174 175 176 | { return (id)[[OFMutableUTF8String alloc] initWithContentsOfFile: path encoding: encoding]; } #endif | | | | | | < < < < | < < < < | < | < < | < < < < < < < < > | | 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | { return (id)[[OFMutableUTF8String alloc] initWithContentsOfFile: path encoding: encoding]; } #endif - (instancetype)initWithContentsOfIRI: (OFIRI *)IRI { return (id)[[OFMutableUTF8String alloc] initWithContentsOfIRI: IRI]; } - (instancetype)initWithContentsOfIRI: (OFIRI *)IRI encoding: (OFStringEncoding)encoding { return (id)[[OFMutableUTF8String alloc] initWithContentsOfIRI: IRI encoding: encoding]; } #ifdef __clang__ # pragma clang diagnostic pop #endif OF_SINGLETON_METHODS @end @implementation OFMutableString + (void)initialize { if (self == [OFMutableString class]) object_setClass((id)&placeholder, [OFPlaceholderMutableString class]); } + (instancetype)alloc { if (self == [OFMutableString class]) return (id)&placeholder; |
︙ | ︙ |
Modified src/OFMutableTarArchiveEntry.h from [d5cbafa370] to [549409ec6b].
1 | /* | | | | | | > > > > | < > | < | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFTarArchiveEntry.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFMutableTarArchiveEntry OFTarArchiveEntry.h ObjFW/OFTarArchiveEntry.h * * @brief A class which represents a mutable entry of a tar archive. */ @interface OFMutableTarArchiveEntry: OFTarArchiveEntry <OFMutableArchiveEntry> { OF_RESERVE_IVARS(OFMutableTarArchiveEntry, 4) } |
︙ | ︙ |
Modified src/OFMutableTarArchiveEntry.m from [693af0fda5] to [514e3f078d].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFMutableTarArchiveEntry.h" #import "OFTarArchiveEntry+Private.h" #import "OFDate.h" |
︙ | ︙ |
Modified src/OFMutableTriple.h from [9e67514e20] to [1657859b32].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFTriple.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFMutableTriple OFTriple.h ObjFW/OFTriple.h * * @brief A class for storing a triple of three objects. */ @interface OFMutableTriple OF_GENERIC(FirstType, SecondType, ThirdType): OFTriple OF_GENERIC(FirstType, SecondType, ThirdType) #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) # define FirstType id |
︙ | ︙ |
Modified src/OFMutableTriple.m from [a54e7551cb] to [d0de5a7635].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFMutableTriple.h" @implementation OFMutableTriple |
︙ | ︙ |
Modified src/OFMutableUTF8String.h from [681d1d0ba4] to [57ecfdee55].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFMutableString.h" #import "OFUTF8String.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ |
Modified src/OFMutableUTF8String.m from [57e4df0b5d] to [3ea1ecdd6c].
1 | /* | | | | | | > > > > | < > | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdarg.h> #include <stdlib.h> #include <string.h> #import "OFMutableUTF8String.h" #import "OFASPrintF.h" #import "OFString.h" #import "OFUTF8String.h" #import "OFInvalidArgumentException.h" |
︙ | ︙ | |||
75 76 77 78 79 80 81 | char *newCString; bool isStart = true; if (!_s->isUTF8) { uint8_t t; const OFUnichar *const *table; | | | 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | char *newCString; bool isStart = true; if (!_s->isUTF8) { uint8_t t; const OFUnichar *const *table; OFAssert(startTableSize >= 1 && middleTableSize >= 1); _s->hasHash = false; for (i = 0; i < _s->cStringLength; i++) { if (isStart) table = startTable; else |
︙ | ︙ | |||
169 170 171 172 173 174 175 | OFFreeMemory(unicodeString); OFFreeMemory(newCString); @throw [OFInvalidEncodingException exception]; } j += d; } | | | 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | OFFreeMemory(unicodeString); OFFreeMemory(newCString); @throw [OFInvalidEncodingException exception]; } j += d; } OFAssert(j == newCStringLength); newCString[j] = 0; OFFreeMemory(unicodeString); OFFreeMemory(_s->cString); _s->hasHash = false; _s->cString = newCString; _s->cStringLength = newCStringLength; |
︙ | ︙ |
Modified src/OFMutableZIPArchiveEntry.h from [019337b54d] to [a0b0b47fda].
1 | /* | | | | | | > > > > | < > | < | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFZIPArchiveEntry.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFMutableZIPArchiveEntry OFZIPArchiveEntry.h ObjFW/OFZIPArchiveEntry.h * * @brief A class which represents a mutable entry in the central directory of * a ZIP archive. */ @interface OFMutableZIPArchiveEntry: OFZIPArchiveEntry <OFMutableArchiveEntry> { OF_RESERVE_IVARS(OFMutableZIPArchiveEntry, 4) |
︙ | ︙ |
Modified src/OFMutableZIPArchiveEntry.m from [6a8c882277] to [306ccce6f3].
1 | /* | | | | | | > > > > | < > | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFMutableZIPArchiveEntry.h" #import "OFZIPArchiveEntry+Private.h" #import "OFData.h" #import "OFDate.h" #import "OFString.h" #import "OFInvalidArgumentException.h" #import "OFOutOfRangeException.h" @implementation OFMutableZIPArchiveEntry @dynamic fileName, fileComment, extraField, versionMadeBy, minVersionNeeded; @dynamic modificationDate, compressionMethod, compressedSize, uncompressedSize; @dynamic CRC32, versionSpecificAttributes, generalPurposeBitFlag; @dynamic of_startDiskNumber, of_localFileHeaderOffset; /* * The following are optional in OFMutableArchiveEntry, but Apple GCC 4.0.1 is * buggy and needs this to stop complaining. */ @dynamic POSIXPermissions, ownerAccountID, groupOwnerAccountID; @dynamic ownerAccountName, groupOwnerAccountName; |
︙ | ︙ | |||
168 169 170 171 172 173 174 175 176 177 178 179 180 181 | _versionSpecificAttributes = versionSpecificAttributes; } - (void)setGeneralPurposeBitFlag: (uint16_t)generalPurposeBitFlag { _generalPurposeBitFlag = generalPurposeBitFlag; } - (void)of_setLocalFileHeaderOffset: (int64_t)localFileHeaderOffset { if (localFileHeaderOffset < 0) @throw [OFInvalidArgumentException exception]; _localFileHeaderOffset = localFileHeaderOffset; | > > > > > | 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | _versionSpecificAttributes = versionSpecificAttributes; } - (void)setGeneralPurposeBitFlag: (uint16_t)generalPurposeBitFlag { _generalPurposeBitFlag = generalPurposeBitFlag; } - (void)of_setStartDiskNumber: (uint32_t)startDiskNumber { _startDiskNumber = startDiskNumber; } - (void)of_setLocalFileHeaderOffset: (int64_t)localFileHeaderOffset { if (localFileHeaderOffset < 0) @throw [OFInvalidArgumentException exception]; _localFileHeaderOffset = localFileHeaderOffset; |
︙ | ︙ |
Added src/OFMutableZooArchiveEntry.h version [f22125ceab].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFZooArchiveEntry.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFMutableZooArchiveEntry OFZooArchiveEntry.h ObjFW/OFZooArchiveEntry.h * * @brief A class which represents a mutable entry in a Zoo archive. */ @interface OFMutableZooArchiveEntry: OFZooArchiveEntry <OFMutableArchiveEntry> { OF_RESERVE_IVARS(OFMutableZooArchiveEntry, 4) } /** * @brief The header type of the entry. */ @property (readwrite, nonatomic) uint8_t headerType; /** * @brief The compression method of the entry. */ @property (readwrite, nonatomic) uint8_t compressionMethod; /** * @brief The CRC16 of the file. */ @property (readwrite, nonatomic) uint16_t CRC16; /** * @brief The minimum version required to extract the file. * * The upper 8 bits are the major version and the lower 8 bits the minor * version. */ @property (readwrite, nonatomic) uint16_t minVersionNeeded; /** * @brief Whether the file was deleted. */ @property (readwrite, nonatomic, getter=isDeleted) bool deleted; /** * @brief The operating system identifier of the file. */ @property (readwrite, nonatomic) uint16_t operatingSystemIdentifier; /** * @brief The time zone in which the file was stored, as an offset in hours * from UTC (as a float). * * @note Make sure to set the correct time zone before setting the modification * date! */ @property OF_NULLABLE_PROPERTY (readwrite, retain, nonatomic) OFNumber *timeZone; /** * @brief Creates a new OFMutableZooArchiveEntry with the specified file name. * * @param fileName The file name for the OFZooArchiveEntry * @return A new, autoreleased OFZooArchiveEntry */ + (instancetype)entryWithFileName: (OFString *)fileName; /** * @brief Initializes an already allocated OFMutableZooArchiveEntry with the * specified file name. * * @param fileName The file name for the OFZooArchiveEntry * @return An initialized OFZooArchiveEntry */ - (instancetype)initWithFileName: (OFString *)fileName; /** * @brief Converts the OFMutableZooArchiveEntry to an immutable * OFZooArchiveEntry. */ - (void)makeImmutable; @end OF_ASSUME_NONNULL_END |
Added src/OFMutableZooArchiveEntry.m version [0dfbc7e2aa].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFMutableZooArchiveEntry.h" #import "OFZooArchiveEntry+Private.h" #import "OFDate.h" #import "OFNumber.h" #import "OFString.h" @implementation OFMutableZooArchiveEntry @dynamic headerType, compressionMethod, modificationDate, CRC16; @dynamic uncompressedSize, compressedSize, minVersionNeeded, deleted; @dynamic fileComment, fileName, operatingSystemIdentifier, POSIXPermissions; @dynamic timeZone; /* * The following properties are not implemented, but old Apple GCC requries * @dynamic for @optional properties. */ @dynamic ownerAccountID, groupOwnerAccountID, ownerAccountName; @dynamic groupOwnerAccountName; + (instancetype)entryWithFileName: (OFString *)fileName { return [[[self alloc] initWithFileName: fileName] autorelease]; } - (instancetype)initWithFileName: (OFString *)fileName { self = [super of_init]; @try { void *pool = objc_autoreleasePoolPush(); self.fileName = fileName; self.modificationDate = [OFDate date]; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; } return self; } - (id)copy { OFMutableZooArchiveEntry *copy = [self mutableCopy]; [copy makeImmutable]; return copy; } - (void)setHeaderType: (uint8_t)headerType { _headerType = headerType; } - (void)setCompressionMethod: (uint8_t)compressionMethod { _compressionMethod = compressionMethod; } - (void)setModificationDate: (OFDate *)date { void *pool = objc_autoreleasePoolPush(); if (_timeZone == 0x7F) { _lastModifiedFileDate = (((date.localYear - 1980) & 0xFF) << 9) | ((date.localMonthOfYear & 0x0F) << 5) | (date.localDayOfMonth & 0x1F); _lastModifiedFileTime = ((date.localHour & 0x1F) << 11) | ((date.localMinute & 0x3F) << 5) | ((date.second >> 1) & 0x0F); } else { date = [date dateByAddingTimeInterval: -(OFTimeInterval)_timeZone * 900]; _lastModifiedFileDate = (((date.year - 1980) & 0xFF) << 9) | ((date.monthOfYear & 0x0F) << 5) | (date.dayOfMonth & 0x1F); _lastModifiedFileTime = ((date.hour & 0x1F) << 11) | ((date.minute & 0x3F) << 5) | ((date.second >> 1) & 0x0F); } objc_autoreleasePoolPop(pool); } - (void)setCRC16: (uint16_t)CRC16 { _CRC16 = CRC16; } - (void)setUncompressedSize: (unsigned long long)uncompressedSize { _uncompressedSize = uncompressedSize; } - (void)setCompressedSize: (unsigned long long)compressedSize { _compressedSize = compressedSize; } - (void)setMinVersionNeeded: (uint16_t)minVersionNeeded { _minVersionNeeded = minVersionNeeded; } - (void)setDeleted: (bool)deleted { _deleted = deleted; } - (void)setFileComment: (OFString *)fileComment { OFString *old = _fileComment; _fileComment = [fileComment copy]; [old release]; } - (void)setFileName: (OFString *)fileName { void *pool = objc_autoreleasePoolPush(); OFString *oldFileName = _fileName, *oldDirectoryName = _directoryName; size_t lastSlash; lastSlash = [fileName rangeOfString: @"/" options: OFStringSearchBackwards].location; if (lastSlash != OFNotFound) { _fileName = [[fileName substringWithRange: OFMakeRange( lastSlash + 1, fileName.length - lastSlash - 1)] copy]; [oldFileName release]; _directoryName = [[fileName substringWithRange: OFMakeRange(0, lastSlash)] copy]; [oldDirectoryName release]; } else { _fileName = [fileName copy]; [oldFileName release]; [_directoryName release]; _directoryName = nil; } objc_autoreleasePoolPop(pool); } - (void)setOperatingSystemIdentifier: (uint16_t)operatingSystemIdentifier { _operatingSystemIdentifier = operatingSystemIdentifier; } - (void)setPOSIXPermissions: (OFNumber *)POSIXPermissions { OFNumber *old = _POSIXPermissions; _POSIXPermissions = [POSIXPermissions copy]; [old release]; } - (void)setTimeZone: (OFNumber *)timeZone { if (timeZone == nil) _timeZone = 0x7F; else _timeZone = -timeZone.floatValue * 4; } - (void)makeImmutable { object_setClass(self, [OFZooArchiveEntry class]); } @end |
Modified src/OFMutex.h from [60974c2165] to [ee9e3ea25c].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFLocking.h" #import "OFPlainMutex.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ |
Modified src/OFMutex.m from [91291c7344] to [e26fea3ad3].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #import "OFMutex.h" |
︙ | ︙ |
Added src/OFNSDNSResourceRecord.h version [7211808de7].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFDNSResourceRecord.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFNSDNSResourceRecord \ * OFDNSResourceRecord.h ObjFW/OFDNSResourceRecord.h * * @brief A class representing an NS DNS resource record. */ OF_SUBCLASSING_RESTRICTED @interface OFNSDNSResourceRecord: OFDNSResourceRecord { OFString *_authoritativeHost; } /** * @brief The authoritative host of the resource record. */ @property (readonly, nonatomic) OFString *authoritativeHost; - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFNSDNSResourceRecord with the * specified name, class, authoritative host and time to live. * * @param name The name for the resource record * @param DNSClass The class code for the resource record * @param authoritativeHost The authoritative host for the resource record * @param TTL The time to live for the resource record * @return An initialized OFNSDNSResourceRecord */ - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass authoritativeHost: (OFString *)authoritativeHost TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END |
Added src/OFNSDNSResourceRecord.m version [23d4aa45c8].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFMXDNSResourceRecord.h" @implementation OFNSDNSResourceRecord @synthesize authoritativeHost = _authoritativeHost; - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass authoritativeHost: (OFString *)authoritativeHost TTL: (uint32_t)TTL { self = [super initWithName: name DNSClass: DNSClass recordType: OFDNSRecordTypeNS TTL: TTL]; @try { _authoritativeHost = [authoritativeHost copy]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_authoritativeHost release]; [super dealloc]; } - (bool)isEqual: (id)object { OFNSDNSResourceRecord *record; if (object == self) return true; if (![object isKindOfClass: [OFNSDNSResourceRecord class]]) return false; record = object; if (record->_name != _name && ![record->_name isEqual: _name]) return false; if (record->_DNSClass != _DNSClass) return false; if (record->_recordType != _recordType) return false; if (record->_authoritativeHost != _authoritativeHost && ![record->_authoritativeHost isEqual: _authoritativeHost]) return false; return true; } - (unsigned long)hash { unsigned long hash; OFHashInit(&hash); OFHashAddHash(&hash, _name.hash); OFHashAddByte(&hash, _DNSClass >> 8); OFHashAddByte(&hash, _DNSClass); OFHashAddByte(&hash, _recordType >> 8); OFHashAddByte(&hash, _recordType); OFHashAddHash(&hash, _authoritativeHost.hash); OFHashFinalize(&hash); return hash; } - (OFString *)description { return [OFString stringWithFormat: @"<%@:\n" @"\tName = %@\n" @"\tClass = %@\n" @"\tAuthoritative Host = %@\n" @"\tTTL = %" PRIu32 "\n" @">", self.className, _name, OFDNSClassName(_DNSClass), _authoritativeHost, _TTL]; } @end |
Deleted src/OFNonretainedObjectValue.h version [3bd7c9c6b7].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/OFNonretainedObjectValue.m version [93108c2968].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Modified src/OFNotification.h from [c3409634e1] to [8f02867be5].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" OF_ASSUME_NONNULL_BEGIN /** @file */ |
︙ | ︙ |
Modified src/OFNotification.m from [d51e2a4110] to [87bbc919a6].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFNotification.h" #import "OFDictionary.h" #import "OFString.h" |
︙ | ︙ |
Modified src/OFNotificationCenter.h from [2edf55e2db] to [ca155ce1ef].
1 | /* | | | | | | > > > > | < > | < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFNotification.h" OF_ASSUME_NONNULL_BEGIN @class OFMutableDictionary OF_GENERIC(KeyType, ObjectType); #ifdef OF_HAVE_BLOCKS /** * @brief A block which is called when a notification has been posted. * * @param notification The notification that has been posted */ |
︙ | ︙ | |||
40 41 42 43 44 45 46 | * @brief A class to send and register for notifications. */ #ifndef OF_NOTIFICATION_CENTER_M OF_SUBCLASSING_RESTRICTED #endif @interface OFNotificationCenter: OFObject { | < < < | | | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | * @brief A class to send and register for notifications. */ #ifndef OF_NOTIFICATION_CENTER_M OF_SUBCLASSING_RESTRICTED #endif @interface OFNotificationCenter: OFObject { OFMutableDictionary *_handles; } #ifdef OF_HAVE_CLASS_PROPERTIES @property (class, readonly, nonatomic) OFNotificationCenter *defaultCenter; #endif /** * @brief Returns the default notification center. */ + (OFNotificationCenter *)defaultCenter; /** * @brief Adds an observer for the specified notification and object. * * @param observer The object that should receive notifications * @param selector The selector to call on the observer on notifications. The * method must take exactly one object of type * @ref OFNotification. * @param name The name of the notification to observe * @param object The object that should be sending the notification, or `nil` * if the object should be ignored to determine what * notifications to deliver */ - (void)addObserver: (id)observer selector: (SEL)selector |
︙ | ︙ | |||
99 100 101 102 103 104 105 | * @param name The name of the notification to observe * @param object The object that should be sending the notification, or `nil` * if the object should be ignored to determine what * notifications to deliver * @param block The block to handle notifications * @return An opaque object to remove the observer again */ | < | | | | | 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | * @param name The name of the notification to observe * @param object The object that should be sending the notification, or `nil` * if the object should be ignored to determine what * notifications to deliver * @param block The block to handle notifications * @return An opaque object to remove the observer again */ - (id)addObserverForName: (OFNotificationName)name object: (nullable id)object usingBlock: (OFNotificationCenterBlock)block; /** * @brief Removes an observer. The specified observer must be one returned by * @ref addObserver:selector:name:object:. * * @param observer The object that was returned when adding the observer */ - (void)removeObserver: (id)observer; #endif /** * @brief Posts the specified notification. * * @param notification The notification to post */ |
︙ | ︙ |
Modified src/OFNotificationCenter.m from [a7b0a81fd8] to [eb7640502b].
1 | /* | | | | | | > > > > | < > | < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #define OF_NOTIFICATION_CENTER_M #include "config.h" #import "OFNotificationCenter.h" #import "OFArray.h" #import "OFDictionary.h" #import "OFSet.h" #import "OFString.h" #import "OFInvalidArgumentException.h" @interface OFDefaultNotificationCenter: OFNotificationCenter @end |
︙ | ︙ | |||
65 66 67 68 69 70 71 | { self = [super init]; @try { void *pool = objc_autoreleasePoolPush(); _name = [name copy]; | | | 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | { self = [super init]; @try { void *pool = objc_autoreleasePoolPush(); _name = [name copy]; _observer = observer; _selector = selector; _object = [object retain]; _selectorHash = [[OFString stringWithUTF8String: sel_getName(_selector)] hash]; objc_autoreleasePoolPop(pool); |
︙ | ︙ | |||
104 105 106 107 108 109 110 | return self; } #endif - (void)dealloc { [_name release]; | < | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | return self; } #endif - (void)dealloc { [_name release]; [_object release]; #ifdef OF_HAVE_BLOCKS [_block release]; #endif [super dealloc]; } |
︙ | ︙ | |||
180 181 182 183 184 185 186 | } - (instancetype)init { self = [super init]; @try { | < < < < < < < < < | < < < < < | | | | > | < | | > > > > | < < | < < < < | 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | } - (instancetype)init { self = [super init]; @try { _handles = [[OFMutableDictionary alloc] init]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_handles release]; [super dealloc]; } - (void)of_addObserver: (OFNotificationCenterHandle *)handle { @synchronized (_handles) { OFMutableSet *handlesForName = [_handles objectForKey: handle->_name]; if (handlesForName == nil) { handlesForName = [OFMutableSet set]; [_handles setObject: handlesForName forKey: handle->_name]; } [handlesForName addObject: handle]; } } - (void)addObserver: (id)observer selector: (SEL)selector name: (OFNotificationName)name object: (id)object { void *pool = objc_autoreleasePoolPush(); [self of_addObserver: [[[OFNotificationCenterHandle alloc] initWithName: name observer: observer selector: selector object: object] autorelease]]; objc_autoreleasePoolPop(pool); } #ifdef OF_HAVE_BLOCKS - (id)addObserverForName: (OFNotificationName)name object: (id)object usingBlock: (OFNotificationCenterBlock)block { void *pool = objc_autoreleasePoolPush(); OFNotificationCenterHandle *handle = [[[OFNotificationCenterHandle alloc] initWithName: name object: object block: block] autorelease]; [self of_addObserver: handle]; [handle retain]; objc_autoreleasePoolPop(pool); return [handle autorelease]; } #endif - (void)removeObserver: (id)handle_ { OFNotificationCenterHandle *handle; void *pool; if (![handle_ isKindOfClass: [OFNotificationCenterHandle class]]) @throw [OFInvalidArgumentException exception]; handle = handle_; pool = objc_autoreleasePoolPush(); if (![handle isKindOfClass: [OFNotificationCenterHandle class]]) @throw [OFInvalidArgumentException exception]; @synchronized (_handles) { OFNotificationName name = [[handle->_name copy] autorelease]; OFMutableSet *handlesForName = [_handles objectForKey: name]; [handlesForName removeObject: handle]; if (handlesForName.count == 0) [_handles removeObjectForKey: name]; } objc_autoreleasePoolPop(pool); } - (void)removeObserver: (id)observer selector: (SEL)selector name: (OFNotificationName)name |
︙ | ︙ | |||
316 317 318 319 320 321 322 | } - (void)postNotification: (OFNotification *)notification { void *pool = objc_autoreleasePoolPush(); OFMutableArray *matchedHandles = [OFMutableArray array]; | < < < | < < < < | 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 | } - (void)postNotification: (OFNotification *)notification { void *pool = objc_autoreleasePoolPush(); OFMutableArray *matchedHandles = [OFMutableArray array]; @synchronized (_handles) { for (OFNotificationCenterHandle *handle in [_handles objectForKey: notification.name]) if (handle->_object == nil || handle->_object == notification.object) [matchedHandles addObject: handle]; } for (OFNotificationCenterHandle *handle in matchedHandles) { #ifdef OF_HAVE_BLOCKS if (handle->_block != NULL) handle->_block(notification); else { #endif |
︙ | ︙ | |||
374 375 376 377 378 379 380 | userInfo: userInfo]]; objc_autoreleasePoolPop(pool); } @end @implementation OFDefaultNotificationCenter | < < < < | < < < < < < < < < < < < < | 351 352 353 354 355 356 357 358 359 | userInfo: userInfo]]; objc_autoreleasePoolPop(pool); } @end @implementation OFDefaultNotificationCenter OF_SINGLETON_METHODS @end |
Modified src/OFNull.h from [787aabc24c] to [64e34ec5e2].
1 | /* | | | | | | > > > > | < > | < | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFJSONRepresentation.h" #import "OFMessagePackRepresentation.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFNull OFNull.h ObjFW/OFNull.h * * @brief A class for representing null values in collections. */ OF_SUBCLASSING_RESTRICTED @interface OFNull: OFObject <OFCopying, OFJSONRepresentation, OFMessagePackRepresentation> /** * @brief Returns an OFNull singleton. * * @return An OFNull singleton */ + (OFNull *)null; |
︙ | ︙ |
Modified src/OFNull.m from [bf841d1a2e] to [22bd7fb582].
1 | /* | | | | | | > > > > | < > | | < | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFNull.h" #import "OFData.h" #import "OFString.h" #import "OFInvalidArgumentException.h" @interface OFNull () - (OFString *) of_JSONRepresentationWithOptions: (OFJSONRepresentationOptions)options depth: (size_t)depth; |
︙ | ︙ | |||
37 38 39 40 41 42 43 | } + (OFNull *)null { return null; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | } + (OFNull *)null { return null; } - (OFString *)description { return @"<null>"; } - (id)copy { return self; } - (OFString *)JSONRepresentation { return [self of_JSONRepresentationWithOptions: 0 depth: 0]; } - (OFString *)JSONRepresentationWithOptions: (OFJSONRepresentationOptions)options |
︙ | ︙ | |||
103 104 105 106 107 108 109 | - (OFData *)messagePackRepresentation { uint8_t type = 0xC0; return [OFData dataWithItems: &type count: 1]; } | < < < < | < < < < < < < < < < < < < < < < < < | 74 75 76 77 78 79 80 81 82 | - (OFData *)messagePackRepresentation { uint8_t type = 0xC0; return [OFData dataWithItems: &type count: 1]; } OF_SINGLETON_METHODS @end |
Modified src/OFNumber.h from [eff21822aa] to [d74225adc3].
1 | /* | | | | | | > > > > | < > | < < < < | | < < < < < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS #endif #ifndef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS #endif #include "objfw-defs.h" #ifdef OF_HAVE_SYS_TYPES_H # include <sys/types.h> #endif #import "OFJSONRepresentation.h" #import "OFMessagePackRepresentation.h" #import "OFValue.h" OF_ASSUME_NONNULL_BEGIN /** @file */ /** * @class OFNumber OFNumber.h ObjFW/OFNumber.h * * @brief Provides a way to store a number in an object. */ @interface OFNumber: OFValue <OFComparing, OFJSONRepresentation, OFMessagePackRepresentation> /** * @brief The OFNumber as a `bool`. */ @property (readonly, nonatomic) bool boolValue; /** * @brief The OFNumber as a `signed char`. |
︙ | ︙ | |||
120 121 122 123 124 125 126 | @property (readonly, nonatomic) double doubleValue; /** * @brief The OFNumber as a string. */ @property (readonly, nonatomic) OFString *stringValue; | < < | 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | @property (readonly, nonatomic) double doubleValue; /** * @brief The OFNumber as a string. */ @property (readonly, nonatomic) OFString *stringValue; + (instancetype)valueWithPointer: (const void *)pointer OF_UNAVAILABLE; + (instancetype)valueWithNonretainedObject: (id)object OF_UNAVAILABLE; + (instancetype)valueWithRange: (OFRange)range OF_UNAVAILABLE; + (instancetype)valueWithPoint: (OFPoint)point OF_UNAVAILABLE; + (instancetype)valueWithSize: (OFSize)size OF_UNAVAILABLE; + (instancetype)valueWithRect: (OFRect)rect OF_UNAVAILABLE; |
︙ | ︙ | |||
233 234 235 236 237 238 239 | * @brief Creates a new OFNumber with the specified `double`. * * @param value The `double` value which the OFNumber should contain * @return A new autoreleased OFNumber */ + (instancetype)numberWithDouble: (double)value; | < < < < | 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | * @brief Creates a new OFNumber with the specified `double`. * * @param value The `double` value which the OFNumber should contain * @return A new autoreleased OFNumber */ + (instancetype)numberWithDouble: (double)value; /** * @brief Initializes an already allocated OFNumber with the specified `bool`. * * @param value The `bool` value which the OFNumber should contain * @return An initialized OFNumber */ - (instancetype)initWithBool: (bool)value; |
︙ | ︙ |
Modified src/OFNumber.m from [0d84e74204] to [f7bfac6fc7].
1 | /* | | | | | | > | < | < | > | > > | | | | < | | < < < < < < < < < < < < < < < < < < < < | | | | | | | < < < < < < < < < < < < < < | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <math.h> #import "OFNumber.h" #import "OFConcreteNumber.h" #import "OFData.h" #import "OFString.h" #import "OFTaggedPointerNumber.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFOutOfRangeException.h" @interface OFNumber () - (OFString *) of_JSONRepresentationWithOptions: (OFJSONRepresentationOptions)options depth: (size_t)depth; @end @interface OFPlaceholderNumber: OFNumber @end @interface OFConcreteNumberSingleton: OFConcreteNumber @end static struct { Class isa; } placeholder; #define SINGLETON(var, sel, val) \ static OFConcreteNumberSingleton *var; \ \ static void \ var##Init(void) \ { \ var = [[OFConcreteNumberSingleton alloc] sel val]; \ } SINGLETON(falseNumber, initWithBool:, false) SINGLETON(trueNumber, initWithBool:, true) SINGLETON(charZeroNumber, initWithChar:, 0) SINGLETON(shortZeroNumber, initWithShort:, 0) SINGLETON(intZeroNumber, initWithInt:, 0) SINGLETON(longZeroNumber, initWithLong:, 0) SINGLETON(longLongZeroNumber, initWithLongLong:, 0) SINGLETON(unsignedCharZeroNumber, initWithUnsignedChar:, 0) SINGLETON(unsignedShortZeroNumber, initWithUnsignedShort:, 0) SINGLETON(unsignedIntZeroNumber, initWithUnsignedInt:, 0) SINGLETON(unsignedLongZeroNumber, initWithUnsignedLong:, 0) SINGLETON(unsignedLongLongZeroNumber, initWithUnsignedLongLong:, 0) SINGLETON(floatZeroNumber, initWithFloat:, 0) SINGLETON(doubleZeroNumber, initWithDouble:, 0) #undef SINGLETON static bool isUnsigned(OFNumber *number) { switch (*number.objCType) { case 'B': case 'C': case 'S': case 'I': case 'L': case 'Q': return true; default: return false; } } static bool isSigned(OFNumber *number) { switch (*number.objCType) { case 'c': case 's': case 'i': case 'l': case 'q': return true; default: return false; } } static bool isFloat(OFNumber *number) { switch (*number.objCType) { case 'f': case 'd': return true; default: return false; } } @implementation OFPlaceholderNumber - (instancetype)initWithBool: (bool)value { if (value) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, trueNumberInit); return (id)trueNumber; } else { |
︙ | ︙ | |||
168 169 170 171 172 173 174 | - (instancetype)initWithChar: (signed char)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, charZeroNumberInit); return (id)charZeroNumber; #ifdef OF_OBJFW_RUNTIME | | | | | | | | | | | | | | | | | | | < | | | | < | | | < | | | < | | | < | | | | | | | < < < < < < < < < < < | < < < < < < < < < < < < < < | < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < | < < < < < < < < < < < < < < < < < | 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | - (instancetype)initWithChar: (signed char)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, charZeroNumberInit); return (id)charZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if ((unsigned char)value <= (UINTPTR_MAX >> OFTaggedPointerNumberTagBits)) { id ret = [OFTaggedPointerNumber numberWithChar: value]; if (ret != nil) return ret; #endif } return (id)[[OFConcreteNumber alloc] initWithChar: value]; } - (instancetype)initWithShort: (short)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, shortZeroNumberInit); return (id)shortZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if ((unsigned short)value <= (UINTPTR_MAX >> OFTaggedPointerNumberTagBits)) { id ret = [OFTaggedPointerNumber numberWithShort: value]; if (ret != nil) return ret; #endif } return (id)[[OFConcreteNumber alloc] initWithShort: value]; } - (instancetype)initWithInt: (int)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, intZeroNumberInit); return (id)intZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if ((unsigned int)value <= (UINTPTR_MAX >> OFTaggedPointerNumberTagBits)) { id ret = [OFTaggedPointerNumber numberWithInt: value]; if (ret != nil) return ret; #endif } return (id)[[OFConcreteNumber alloc] initWithInt: value]; } - (instancetype)initWithLong: (long)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, longZeroNumberInit); return (id)longZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if ((unsigned long)value <= (UINTPTR_MAX >> OFTaggedPointerNumberTagBits)) { id ret = [OFTaggedPointerNumber numberWithLong: value]; if (ret != nil) return ret; #endif } return (id)[[OFConcreteNumber alloc] initWithLong: value]; } - (instancetype)initWithLongLong: (long long)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, longLongZeroNumberInit); return (id)longLongZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if ((unsigned long long)value <= (UINTPTR_MAX >> OFTaggedPointerNumberTagBits)) { id ret = [OFTaggedPointerNumber numberWithLongLong: value]; if (ret != nil) return ret; #endif } return (id)[[OFConcreteNumber alloc] initWithLongLong: value]; } - (instancetype)initWithUnsignedChar: (unsigned char)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, unsignedCharZeroNumberInit); return (id)unsignedCharZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if (value <= (UINTPTR_MAX >> OFTaggedPointerNumberTagBits)) { id ret = [OFTaggedPointerNumber numberWithUnsignedChar: value]; if (ret != nil) return ret; #endif } return (id)[[OFConcreteNumber alloc] initWithUnsignedChar: value]; } - (instancetype)initWithUnsignedShort: (unsigned short)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, unsignedShortZeroNumberInit); return (id)unsignedShortZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if (value <= (UINTPTR_MAX >> OFTaggedPointerNumberTagBits)) { id ret = [OFTaggedPointerNumber numberWithUnsignedShort: value]; if (ret != nil) return ret; #endif } return (id)[[OFConcreteNumber alloc] initWithUnsignedShort: value]; } - (instancetype)initWithUnsignedInt: (unsigned int)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, unsignedIntZeroNumberInit); return (id)unsignedIntZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if (value <= (UINTPTR_MAX >> OFTaggedPointerNumberTagBits)) { id ret = [OFTaggedPointerNumber numberWithUnsignedInt: value]; if (ret != nil) return ret; #endif } return (id)[[OFConcreteNumber alloc] initWithUnsignedInt: value]; } - (instancetype)initWithUnsignedLong: (unsigned long)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, unsignedLongZeroNumberInit); return (id)unsignedLongZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if (value <= (UINTPTR_MAX >> OFTaggedPointerNumberTagBits)) { id ret = [OFTaggedPointerNumber numberWithUnsignedLong: value]; if (ret != nil) return ret; #endif } return (id)[[OFConcreteNumber alloc] initWithUnsignedLong: value]; } - (instancetype)initWithUnsignedLongLong: (unsigned long long)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, unsignedLongLongZeroNumberInit); return (id)unsignedLongLongZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if (value <= (UINTPTR_MAX >> OFTaggedPointerNumberTagBits)) { id ret = [OFTaggedPointerNumber numberWithUnsignedLongLong: value]; if (ret != nil) return ret; #endif } return (id)[[OFConcreteNumber alloc] initWithUnsignedLongLong: value]; } - (instancetype)initWithFloat: (float)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, floatZeroNumberInit); return (id)floatZeroNumber; } return (id)[[OFConcreteNumber alloc] initWithFloat: value]; } - (instancetype)initWithDouble: (double)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, doubleZeroNumberInit); return (id)doubleZeroNumber; } return (id)[[OFConcreteNumber alloc] initWithDouble: value]; } #ifdef __clang__ # pragma clang diagnostic pop #endif OF_SINGLETON_METHODS @end @implementation OFConcreteNumberSingleton OF_SINGLETON_METHODS @end @implementation OFNumber + (void)initialize { if (self == [OFNumber class]) object_setClass((id)&placeholder, [OFPlaceholderNumber class]); } + (instancetype)alloc { if (self == [OFNumber class]) return (id)&placeholder; return [super alloc]; } + (instancetype)valueWithPointer: (const void *)pointer { OF_UNRECOGNIZED_SELECTOR } + (instancetype)valueWithNonretainedObject: (id)object { |
︙ | ︙ | |||
609 610 611 612 613 614 615 | } + (instancetype)numberWithDouble: (double)value { return [[[self alloc] initWithDouble: value] autorelease]; } | < < < < < < < < < < < < | < < < < < < < | < < < | < < < < < | < < < < < | < < < < < < < | < < < | < < < < < < < | < < < < < | < < < < < | | < | < < | < | | < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < > | < < < < < < < | < < < < < < < | 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 | } + (instancetype)numberWithDouble: (double)value { return [[[self alloc] initWithDouble: value] autorelease]; } - (instancetype)initWithBool: (bool)value { return [self initWithBytes: &value objCType: @encode(bool)]; } - (instancetype)initWithChar: (signed char)value { return [self initWithBytes: &value objCType: @encode(signed char)]; } - (instancetype)initWithShort: (short)value { return [self initWithBytes: &value objCType: @encode(short)]; } - (instancetype)initWithInt: (int)value { return [self initWithBytes: &value objCType: @encode(int)]; } - (instancetype)initWithLong: (long)value { return [self initWithBytes: &value objCType: @encode(long)]; } - (instancetype)initWithLongLong: (long long)value { return [self initWithBytes: &value objCType: @encode(long long)]; } - (instancetype)initWithUnsignedChar: (unsigned char)value { return [self initWithBytes: &value objCType: @encode(unsigned char)]; } - (instancetype)initWithUnsignedShort: (unsigned short)value { return [self initWithBytes: &value objCType: @encode(unsigned short)]; } - (instancetype)initWithUnsignedInt: (unsigned int)value { return [self initWithBytes: &value objCType: @encode(unsigned int)]; } - (instancetype)initWithUnsignedLong: (unsigned long)value { return [self initWithBytes: &value objCType: @encode(unsigned long)]; } - (instancetype)initWithUnsignedLongLong: (unsigned long long)value { return [self initWithBytes: &value objCType: @encode(unsigned long long)]; } - (instancetype)initWithFloat: (float)value { return [self initWithBytes: &value objCType: @encode(float)]; } - (instancetype)initWithDouble: (double)value { return [self initWithBytes: &value objCType: @encode(double)]; } - (long long)longLongValue { OF_UNRECOGNIZED_SELECTOR } - (unsigned long long)unsignedLongLongValue { OF_UNRECOGNIZED_SELECTOR } - (double)doubleValue { OF_UNRECOGNIZED_SELECTOR } - (bool)boolValue { return (bool)self.unsignedLongLongValue; } |
︙ | ︙ | |||
1062 1063 1064 1065 1066 1067 1068 | - (OFString *)description { return [self stringValue]; } - (OFString *)stringValue { | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | > > > | 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 | - (OFString *)description { return [self stringValue]; } - (OFString *)stringValue { if (self.objCType[0] == 'B' && self.objCType[1] == '\0') return (self.boolValue ? @"true" : @"false"); if (isFloat(self)) return [OFString stringWithFormat: @"%g", self.doubleValue]; if (isSigned(self)) return [OFString stringWithFormat: @"%lld", self.longLongValue]; if (isUnsigned(self)) return [OFString stringWithFormat: @"%llu", self.unsignedLongLongValue]; @throw [OFInvalidFormatException exception]; } - (OFString *)JSONRepresentation { return [self of_JSONRepresentationWithOptions: 0 depth: 0]; } - (OFString *)JSONRepresentationWithOptions: (OFJSONRepresentationOptions)options { return [self of_JSONRepresentationWithOptions: options depth: 0]; } - (OFString *) of_JSONRepresentationWithOptions: (OFJSONRepresentationOptions)options depth: (size_t)depth { double doubleValue; if (self.objCType[0] == 'B' && self.objCType[1] == '\0') return (self.boolValue ? @"true" : @"false"); doubleValue = self.doubleValue; if (isinf(doubleValue)) { if (options & OFJSONRepresentationOptionJSON5) { if (doubleValue > 0) return @"Infinity"; else return @"-Infinity"; } else @throw [OFInvalidArgumentException exception]; } return self.description; } - (OFData *)messagePackRepresentation { OFMutableData *data; const char *typeEncoding = self.objCType; if (typeEncoding[0] == '\0' || typeEncoding[1] != '\0') @throw [OFInvalidFormatException exception]; if (*typeEncoding == 'B') { uint8_t type = (self.boolValue ? 0xC3 : 0xC2); data = [OFMutableData dataWithItems: &type count: 1]; } else if (*typeEncoding == 'f') { uint8_t type = 0xCA; float tmp = OFToBigEndianFloat(self.floatValue); |
︙ | ︙ |
Modified src/OFObject+KeyValueCoding.h from [c0e7932d00] to [0118a5fa63].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFKeyValueCoding.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ |
Modified src/OFObject+KeyValueCoding.m from [8a83d2aa9e] to [abcb6de2fd].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdlib.h> #import "OFObject.h" |
︙ | ︙ |
Deleted src/OFObject+Serialization.h version [ed19e260ae].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/OFObject+Serialization.m version [0bfdaef011].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Modified src/OFObject.h from [698abcee0b] to [08353423b4].
1 | /* | | | | | | > | < | < | > | | > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "objfw-defs.h" #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS #endif #ifndef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS #endif #include <stddef.h> #include <stdint.h> #include <stdbool.h> #include <limits.h> #include "macros.h" #import "OFOnce.h" /* * Some versions of MinGW require <winsock2.h> to be included before * <windows.h>. Do this here to make sure this is always done in the correct * order, even if another header includes just <windows.h>. */ #ifdef __MINGW32__ |
︙ | ︙ | |||
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | OFOrderedAscending = -1, /** Both objects are equal */ OFOrderedSame = 0, /** The left object is bigger than the right */ OFOrderedDescending = 1 } OFComparisonResult; #ifdef OF_HAVE_BLOCKS /** * @brief A comparator to compare two objects. * * @param left The left object * @param right The right object * @return The order of the objects */ typedef OFComparisonResult (^OFComparator)(id _Nonnull left, id _Nonnull right); #endif /** | > > > > > > > > > > > | | | | 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | OFOrderedAscending = -1, /** Both objects are equal */ OFOrderedSame = 0, /** The left object is bigger than the right */ OFOrderedDescending = 1 } OFComparisonResult; /** * @brief A function to compare two objects. * * @param left The left object * @param right The right object * @param context Context passed along for comparing * @return The order of the objects */ typedef OFComparisonResult (*OFCompareFunction)(id _Nonnull left, id _Nonnull right, void *_Nullable context); #ifdef OF_HAVE_BLOCKS /** * @brief A comparator to compare two objects. * * @param left The left object * @param right The right object * @return The order of the objects */ typedef OFComparisonResult (^OFComparator)(id _Nonnull left, id _Nonnull right); #endif /** * @brief An enum for representing endianness. */ typedef enum { /** Most significant byte first (big endian) */ OFByteOrderBigEndian, /** Least significant byte first (little endian) */ OFByteOrderLittleEndian, /** Native byte order of the system */ #ifdef OF_BIG_ENDIAN OFByteOrderNative = OFByteOrderBigEndian #else OFByteOrderNative = OFByteOrderLittleEndian #endif } OFByteOrder; /** * @struct OFRange OFObject.h ObjFW/OFObject.h * * @brief A range. */ typedef struct OF_BOXABLE OFRange { /** The start of the range */ size_t location; /** The length of the range */ size_t length; } OFRange; /** * @brief Creates a new OFRange. * * @param start The starting index of the range * @param length The length of the range * @return An OFRange with the specified start and length */ static OF_INLINE OFRange OF_CONST_FUNC OFMakeRange(size_t start, size_t length) { OFRange range = { start, length }; return range; |
︙ | ︙ | |||
140 141 142 143 144 145 146 | * @brief A time interval in seconds. */ typedef double OFTimeInterval; /** * @struct OFPoint OFObject.h ObjFW/OFObject.h * | | | | 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | * @brief A time interval in seconds. */ typedef double OFTimeInterval; /** * @struct OFPoint OFObject.h ObjFW/OFObject.h * * @brief A point in 2D space. */ typedef struct OF_BOXABLE OFPoint { /** The x coordinate of the point */ float x; /** The y coordinate of the point */ float y; } OFPoint; /** |
︙ | ︙ | |||
188 189 190 191 192 193 194 | } /** * @struct OFSize OFObject.h ObjFW/OFObject.h * * @brief A size. */ | | | 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | } /** * @struct OFSize OFObject.h ObjFW/OFObject.h * * @brief A size. */ typedef struct OF_BOXABLE OFSize { /** The width of the size */ float width; /** The height of the size */ float height; } OFSize; /** |
︙ | ︙ | |||
234 235 236 237 238 239 240 | } /** * @struct OFRect OFObject.h ObjFW/OFObject.h * * @brief A rectangle. */ | | | 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | } /** * @struct OFRect OFObject.h ObjFW/OFObject.h * * @brief A rectangle. */ typedef struct OF_BOXABLE OFRect { /** The point from where the rectangle originates */ OFPoint origin; /** The size of the rectangle */ OFSize size; } OFRect; /** |
︙ | ︙ | |||
277 278 279 280 281 282 283 284 285 286 287 288 289 290 | { if (!OFEqualPoints(rect1.origin, rect2.origin)) return false; if (!OFEqualSizes(rect1.size, rect2.size)) return false; return true; } /** * @brief Adds the specified byte to the hash. * * @param hash A pointer to a hash to add the byte to | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 | { if (!OFEqualPoints(rect1.origin, rect2.origin)) return false; if (!OFEqualSizes(rect1.size, rect2.size)) return false; return true; } /** * @struct OFVector3D OFObject.h ObjFW/OFObject.h * * @brief A vector in 3D space. */ typedef struct OF_BOXABLE OFVector3D { /** The x coordinate of the vector */ float x; /** The y coordinate of the vector */ float y; /** The z coordinate of the vector */ float z; } OFVector3D; /** * @brief Creates a new OFVector3D. * * @param x The x coordinate of the vector * @param y The x coordinate of the vector * @param z The z coordinate of the vector * @return An OFVector3D with the specified coordinates */ static OF_INLINE OFVector3D OF_CONST_FUNC OFMakeVector3D(float x, float y, float z) { OFVector3D vector = { x, y, z }; return vector; } /** * @brief Returns whether the two vectors are equal. * * @param vector1 The first vector for the comparison * @param vector2 The second vectors for the comparison * @return Whether the two vectors are equal */ static OF_INLINE bool OFEqualVectors3D(OFVector3D vector1, OFVector3D vector2) { if (vector1.x != vector2.x) return false; if (vector1.y != vector2.y) return false; if (vector1.z != vector2.z) return false; return true; } /** * @struct OFVector4D OFObject.h ObjFW/OFObject.h * * @brief A vector in 4D space. */ typedef struct OF_BOXABLE OFVector4D { /** The x coordinate of the vector */ float x; /** The y coordinate of the vector */ float y; /** The z coordinate of the vector */ float z; /** The w coordinate of the vector */ float w; } OFVector4D; /** * @brief Creates a new OFVector4D. * * @param x The x coordinate of the vector * @param y The x coordinate of the vector * @param z The z coordinate of the vector * @param w The w coordinate of the vector * @return An OFVector4D with the specified coordinates */ static OF_INLINE OFVector4D OF_CONST_FUNC OFMakeVector4D(float x, float y, float z, float w) { OFVector4D vector = { x, y, z, w }; return vector; } /** * @brief Returns whether the two vectors are equal. * * @param vector1 The first vector for the comparison * @param vector2 The second vectors for the comparison * @return Whether the two vectors are equal */ static OF_INLINE bool OFEqualVectors4D(OFVector4D vector1, OFVector4D vector2) { if (vector1.x != vector2.x) return false; if (vector1.y != vector2.y) return false; if (vector1.z != vector2.z) return false; if (vector1.w != vector2.w) return false; return true; } /** * @brief Adds the specified byte to the hash. * * @param hash A pointer to a hash to add the byte to |
︙ | ︙ | |||
332 333 334 335 336 337 338 | tmp += tmp << 15; *hash = tmp; } static const size_t OFNotFound = SIZE_MAX; | < | 454 455 456 457 458 459 460 461 462 463 464 465 466 467 | tmp += tmp << 15; *hash = tmp; } static const size_t OFNotFound = SIZE_MAX; @class OFMethodSignature; @class OFString; @class OFThread; /** * @protocol OFObject OFObject.h ObjFW/OFObject.h * |
︙ | ︙ | |||
555 556 557 558 559 560 561 | /** * @brief Retain a weak reference to this object. * * @return Whether a weak reference to this object has been retained */ - (bool)retainWeakReference; @end | < < | | | | | | | | | | | 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 | /** * @brief Retain a weak reference to this object. * * @return Whether a weak reference to this object has been retained */ - (bool)retainWeakReference; @end /** * @class OFObject OFObject.h ObjFW/OFObject.h * * @brief The root class for all other classes inside ObjFW. */ OF_ROOT_CLASS @interface OFObject <OFObject> { @private #ifndef __clang_analyzer__ Class _isa; #else Class _isa __attribute__((__unused__)); #endif } #ifdef OF_HAVE_CLASS_PROPERTIES # ifndef __cplusplus @property (class, readonly, nonatomic) Class class; # else @property (class, readonly, nonatomic, getter=class) Class class_; # endif @property (class, readonly, nonatomic) OFString *className; @property (class, readonly, nullable, nonatomic) Class superclass; @property (class, readonly, nonatomic) OFString *description; #endif #ifndef __cplusplus @property (readonly, nonatomic) Class class; #else @property (readonly, nonatomic, getter=class) Class class_; #endif @property OF_NULLABLE_PROPERTY (readonly, nonatomic) Class superclass; @property (readonly, nonatomic) unsigned long hash; @property (readonly, nonatomic) unsigned int retainCount; @property (readonly, nonatomic) bool isProxy; @property (readonly, nonatomic) bool allowsWeakReference; |
︙ | ︙ | |||
655 656 657 658 659 660 661 | * @return The allocated object * @throw OFAllocFailedException There was not enough memory to allocate the * object * @throw OFInitializationFailedException The instance could not be constructed */ + (instancetype)alloc; | < < < < < < < | 774 775 776 777 778 779 780 781 782 783 784 785 786 787 | * @return The allocated object * @throw OFAllocFailedException There was not enough memory to allocate the * object * @throw OFInitializationFailedException The instance could not be constructed */ + (instancetype)alloc; /** * @brief Returns the class. * * @return The class */ + (Class)class; |
︙ | ︙ | |||
940 941 942 943 944 945 946 | - (void)performSelector: (SEL)selector withObject: (nullable id)object1 withObject: (nullable id)object2 withObject: (nullable id)object3 withObject: (nullable id)object4 afterDelay: (OFTimeInterval)delay; | | | 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 | - (void)performSelector: (SEL)selector withObject: (nullable id)object1 withObject: (nullable id)object2 withObject: (nullable id)object3 withObject: (nullable id)object4 afterDelay: (OFTimeInterval)delay; #ifdef OF_HAVE_THREADS /** * @brief Performs the specified selector on the specified thread. * * @param selector The selector to perform * @param thread The thread on which to perform the selector * @param waitUntilDone Whether to wait until the perform finished */ |
︙ | ︙ | |||
1198 1199 1200 1201 1202 1203 1204 | - (void)performSelector: (SEL)selector onThread: (OFThread *)thread withObject: (nullable id)object1 withObject: (nullable id)object2 withObject: (nullable id)object3 withObject: (nullable id)object4 afterDelay: (OFTimeInterval)delay; | | | 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 | - (void)performSelector: (SEL)selector onThread: (OFThread *)thread withObject: (nullable id)object1 withObject: (nullable id)object2 withObject: (nullable id)object3 withObject: (nullable id)object4 afterDelay: (OFTimeInterval)delay; #endif /** * @brief This method is called when @ref resolveClassMethod: or * @ref resolveInstanceMethod: returned false. It should return a target * to which the message should be forwarded. * * @note When the message should not be forwarded, you should not return `nil`, |
︙ | ︙ | |||
1224 1225 1226 1227 1228 1229 1230 | * returns! * * @param selector The selector not understood by the receiver * @throw OFNotImplementedException */ - (void)doesNotRecognizeSelector: (SEL)selector OF_NO_RETURN; @end | < < < < | 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 | * returns! * * @param selector The selector not understood by the receiver * @throw OFNotImplementedException */ - (void)doesNotRecognizeSelector: (SEL)selector OF_NO_RETURN; @end /** * @protocol OFCopying OFObject.h ObjFW/OFObject.h * * @brief A protocol for the creation of copies. */ @protocol OFCopying /** |
︙ | ︙ | |||
1269 1270 1271 1272 1273 1274 1275 | @end /** * @protocol OFComparing OFObject.h ObjFW/OFObject.h * * @brief A protocol for comparing objects. * | | > < | 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 | @end /** * @protocol OFComparing OFObject.h ObjFW/OFObject.h * * @brief A protocol for comparing objects. * * This protocol is implemented by objects that can be compared. Its only * method, @ref compare:, should be overridden with a stronger type. */ @protocol OFComparing /** * @brief Compares the object to another object. * * @param object An object to compare the object to * @return The result of the comparison */ - (OFComparisonResult)compare: (id <OFComparing>)object; @end #ifdef __cplusplus extern "C" { #endif /** * @brief Allocates memory for the specified number of items of the specified * size. |
︙ | ︙ | |||
1343 1344 1345 1346 1347 1348 1349 | extern void *_Nullable OFResizeMemory(void *_Nullable pointer, size_t count, size_t size) OF_WARN_UNUSED_RESULT; /** * @brief Frees memory allocated by @ref OFAllocMemory, @ref OFAllocZeroedMemory * or @ref OFResizeMemory. * | | > > > > > > > > > > > > > > > > > > > > < < < < < < < | < < | < < < < | 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 | extern void *_Nullable OFResizeMemory(void *_Nullable pointer, size_t count, size_t size) OF_WARN_UNUSED_RESULT; /** * @brief Frees memory allocated by @ref OFAllocMemory, @ref OFAllocZeroedMemory * or @ref OFResizeMemory. * * @param pointer A pointer to the memory to free or nil (passing nil does * nothing) */ extern void OFFreeMemory(void *_Nullable pointer); #ifdef OF_APPLE_RUNTIME extern void *_Null_unspecified objc_autoreleasePoolPush(void); extern void objc_autoreleasePoolPop(void *_Null_unspecified pool); # ifndef __OBJC2__ extern id _Nullable objc_constructInstance(Class _Nullable class_, void *_Nullable bytes); extern void *_Nullable objc_destructInstance(id _Nullable object); typedef enum objc_associationPolicy { OBJC_ASSOCIATION_ASSIGN = 0, OBJC_ASSOCIATION_RETAIN_NONATOMIC = 1, OBJC_ASSOCIATION_RETAIN = OBJC_ASSOCIATION_RETAIN_NONATOMIC | 0x300, OBJC_ASSOCIATION_COPY_NONATOMIC = 3, OBJC_ASSOCIATION_COPY = OBJC_ASSOCIATION_COPY_NONATOMIC | 0x300 } objc_associationPolicy; extern void objc_setAssociatedObject(id _Nonnull object, const void *_Nonnull key, id _Nullable value, objc_associationPolicy policy); extern id _Nullable objc_getAssociatedObject(id _Nonnull object, const void *_Nonnull key); extern void objc_removeAssociatedObjects(id _Nonnull object); # endif #endif extern id OFAllocObject(Class class_, size_t extraSize, size_t extraAlignment, void *_Nullable *_Nullable extra); extern void OF_NO_RETURN_FUNC OFMethodNotFound(id self, SEL _cmd); /** * @brief Initializes the specified hash. * * @param hash A pointer to the hash to initialize */ extern void OFHashInit(unsigned long *_Nonnull hash); /** * @brief Returns 16 bit or non-cryptographical randomness. * * @return 16 bit or non-cryptographical randomness */ extern uint16_t OFRandom16(void); /** * @brief Returns 32 bit or non-cryptographical randomness. * * @return 32 bit or non-cryptographical randomness */ extern uint32_t OFRandom32(void); /** * @brief Returns 64 bit or non-cryptographical randomness. * * @return 64 bit or non-cryptographical randomness */ extern uint64_t OFRandom64(void); #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END #import "OFBlock.h" #import "OFObject+KeyValueCoding.h" |
Modified src/OFObject.m from [0477c3fb09] to [aac1ccf77b].
1 | /* | | | | | | > > > > | < > | < < > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include "unistd_wrapper.h" #ifdef OF_APPLE_RUNTIME # include <dlfcn.h> #endif #ifdef HAVE_GETRANDOM # include <sys/random.h> #endif #import "OFObject.h" #import "OFArray.h" #ifdef OF_HAVE_ATOMIC_OPS # import "OFAtomic.h" #endif #import "OFLocale.h" #import "OFMethodSignature.h" #import "OFRunLoop.h" #if !defined(OF_HAVE_ATOMIC_OPS) && defined(OF_HAVE_THREADS) # import "OFPlainMutex.h" /* For OFSpinlock */ #endif #import "OFStdIOStream.h" #import "OFString.h" #import "OFThread.h" #import "OFTimer.h" #import "OFValue.h" #import "OFAllocFailedException.h" #import "OFEnumerationMutationException.h" |
︙ | ︙ | |||
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | #endif #ifdef OF_WINDOWS # include <windows.h> #endif #ifdef OF_AMIGAOS # include <proto/exec.h> #endif #ifdef OF_APPLE_RUNTIME extern id _Nullable _objc_rootAutorelease(id _Nullable object); #endif #if defined(OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR) extern id OFForward(id, SEL, ...); extern struct Stret OFForward_stret(id, SEL, ...); #else # define OFForward OFMethodNotFound # define OFForward_stret OFMethodNotFound_stret #endif struct PreIvars { int retainCount; #if !defined(OF_HAVE_ATOMIC_OPS) && !defined(OF_AMIGAOS) OFSpinlock retainCountSpinlock; #endif }; | > > > > > > > > > | | | 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | #endif #ifdef OF_WINDOWS # include <windows.h> #endif #ifdef OF_AMIGAOS # define Class IntuitionClass # include <proto/exec.h> # undef Class #endif #ifdef OF_APPLE_RUNTIME extern id _Nullable _objc_rootAutorelease(id _Nullable object); #endif #if defined(OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR) extern id OFForward(id, SEL, ...); extern struct Stret OFForward_stret(id, SEL, ...); #else # define OFForward OFMethodNotFound # define OFForward_stret OFMethodNotFound_stret #endif #ifdef OF_WINDOWS static BOOLEAN NTAPI (*RtlGenRandomFuncPtr)(PVOID, ULONG); #endif struct PreIvars { #ifdef OF_MSDOS ptrdiff_t offset; #endif int retainCount; #if !defined(OF_HAVE_ATOMIC_OPS) && !defined(OF_AMIGAOS) OFSpinlock retainCountSpinlock; #endif }; #define PRE_IVARS_ALIGN \ OFRoundUpToPowerOf2(sizeof(struct PreIvars), OF_BIGGEST_ALIGNMENT) #define PRE_IVARS ((struct PreIvars *)(void *)((char *)self - PRE_IVARS_ALIGN)) static struct { Class isa; } allocFailedException; unsigned long OFHashSeed; |
︙ | ︙ | |||
153 154 155 156 157 158 159 | void OFFreeMemory(void *pointer) { free(pointer); } | > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > | 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | void OFFreeMemory(void *pointer) { free(pointer); } #ifdef OF_MSDOS /* Unfortunately, DJGPP's memalign() is broken. */ static void * alignedAlloc(size_t size, size_t alignment, ptrdiff_t *offset) { char *ptr, *aligned; if ((ptr = malloc(size + alignment)) == NULL) return NULL; aligned = (char *)OFRoundUpToPowerOf2(alignment, (uintptr_t)ptr); *offset = aligned - ptr; return aligned; } static void alignedFree(void *ptr, ptrdiff_t offset) { if (ptr == NULL) return; free((void *)((uintptr_t)ptr - offset)); } #endif #if (!defined(HAVE_ARC4RANDOM) && !defined(HAVE_GETRANDOM)) || \ defined(OF_WINDOWS) static OFOnceControl randomOnceControl = OFOnceControlInitValue; static void initRandom(void) { struct timeval tv; # ifdef OF_WINDOWS HANDLE handle; if ((handle = GetModuleHandleA("advapi32.dll")) != NULL && (RtlGenRandomFuncPtr = (BOOLEAN NTAPI (*)(PVOID, ULONG)) GetProcAddress(handle, "SystemFunction036")) != NULL) return; # endif # ifdef HAVE_RANDOM gettimeofday(&tv, NULL); srandom((unsigned)(tv.tv_sec ^ tv.tv_usec)); # else gettimeofday(&tv, NULL); srand((unsigned)(tv.tv_sec ^ tv.tv_usec)); |
︙ | ︙ | |||
181 182 183 184 185 186 187 | #elif defined(HAVE_GETRANDOM) uint16_t buffer; OFEnsure(getrandom(&buffer, sizeof(buffer), 0) == sizeof(buffer)); return buffer; #else | > | > > > > > > > | > > > > > > > > > > > > > > > > > > > > | 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | #elif defined(HAVE_GETRANDOM) uint16_t buffer; OFEnsure(getrandom(&buffer, sizeof(buffer), 0) == sizeof(buffer)); return buffer; #else OFOnce(&randomOnceControl, initRandom); # ifdef OF_WINDOWS if (RtlGenRandomFuncPtr != NULL) { uint16_t buffer; OFEnsure(RtlGenRandomFuncPtr(&buffer, sizeof(buffer))); return buffer; } # endif # ifdef HAVE_RANDOM return random() & 0xFFFF; # else return rand() & 0xFFFF; # endif #endif } uint32_t OFRandom32(void) { #if defined(HAVE_ARC4RANDOM) return arc4random(); #elif defined(HAVE_GETRANDOM) uint32_t buffer; OFEnsure(getrandom(&buffer, sizeof(buffer), 0) == sizeof(buffer)); return buffer; #else # ifdef OF_WINDOWS OFOnce(&randomOnceControl, initRandom); if (RtlGenRandomFuncPtr != NULL) { uint32_t buffer; OFEnsure(RtlGenRandomFuncPtr(&buffer, sizeof(buffer))); return buffer; } # endif return ((uint32_t)OFRandom16() << 16) | OFRandom16(); #endif } uint64_t OFRandom64(void) { #if defined(HAVE_ARC4RANDOM_BUF) uint64_t buffer; arc4random_buf(&buffer, sizeof(buffer)); return buffer; #elif defined(HAVE_GETRANDOM) uint64_t buffer; OFEnsure(getrandom(&buffer, sizeof(buffer), 0) == sizeof(buffer)); return buffer; #else # ifdef OF_WINDOWS OFOnce(&randomOnceControl, initRandom); if (RtlGenRandomFuncPtr != NULL) { uint64_t buffer; OFEnsure(RtlGenRandomFuncPtr(&buffer, sizeof(buffer))); return buffer; } # endif return ((uint64_t)OFRandom32() << 32) | OFRandom32(); #endif } void OFHashInit(unsigned long *hash) { |
︙ | ︙ | |||
248 249 250 251 252 253 254 | return method_getTypeEncoding(method); } #if !defined(OF_APPLE_RUNTIME) || defined(__OBJC2__) static void uncaughtExceptionHandler(id exception) { | < | | > | | | < < | 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 | return method_getTypeEncoding(method); } #if !defined(OF_APPLE_RUNTIME) || defined(__OBJC2__) static void uncaughtExceptionHandler(id exception) { OFArray OF_GENERIC(OFValue *) *stackTraceAddresses = nil; OFArray OF_GENERIC(OFString *) *stackTraceSymbols = nil; OFStringEncoding encoding = [OFLocale encoding]; OFLog(@"Runtime error: Unhandled exception:"); OFLog(@"%@", exception); if ([exception respondsToSelector: @selector(stackTraceAddresses)]) stackTraceAddresses = [exception stackTraceAddresses]; if (stackTraceAddresses != nil) { size_t count = stackTraceAddresses.count; if ([exception respondsToSelector: @selector(stackTraceSymbols)]) stackTraceSymbols = [exception stackTraceSymbols]; if (stackTraceSymbols.count != count) stackTraceSymbols = nil; OFLog(@""); OFLog(@"Stack trace:"); if (stackTraceSymbols != nil) { for (size_t i = 0; i < count; i++) { void *address = [[stackTraceAddresses objectAtIndex: i] pointerValue]; const char *symbol = [[stackTraceSymbols objectAtIndex: i] cStringWithEncoding: encoding]; OFLog(@" %p %s", address, symbol); } } else { for (size_t i = 0; i < count; i++) { void *address = [[stackTraceAddresses objectAtIndex: i] pointerValue]; OFLog(@" %p", address); } } } abort(); } #endif static void |
︙ | ︙ | |||
329 330 331 332 333 334 335 336 337 338 339 | id OFAllocObject(Class class, size_t extraSize, size_t extraAlignment, void **extra) { OFObject *instance; size_t instanceSize; instanceSize = class_getInstanceSize(class); if OF_UNLIKELY (extraAlignment > 1) | > > > | | > > > > > > > > > > > > | > > | > > > > > > > > > > > > > > > > > | 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 | id OFAllocObject(Class class, size_t extraSize, size_t extraAlignment, void **extra) { OFObject *instance; size_t instanceSize; #ifdef OF_MSDOS ptrdiff_t offset; #endif instanceSize = class_getInstanceSize(class); if OF_UNLIKELY (extraAlignment > 1) extraAlignment = OFRoundUpToPowerOf2(extraAlignment, PRE_IVARS_ALIGN + instanceSize) - PRE_IVARS_ALIGN - instanceSize; #if defined(OF_WINDOWS) instance = __mingw_aligned_malloc(PRE_IVARS_ALIGN + instanceSize + extraAlignment + extraSize, OF_BIGGEST_ALIGNMENT); #elif defined(OF_MSDOS) instance = alignedAlloc(PRE_IVARS_ALIGN + instanceSize + extraAlignment + extraSize, OF_BIGGEST_ALIGNMENT, &offset); #elif defined(OF_SOLARIS) if (posix_memalign((void **)&instance, OF_BIGGEST_ALIGNMENT, PRE_IVARS_ALIGN + instanceSize + extraAlignment + extraSize) != 0) instance = NULL; #else instance = malloc(PRE_IVARS_ALIGN + instanceSize + extraAlignment + extraSize); #endif if OF_UNLIKELY (instance == nil) { object_setClass((id)&allocFailedException, [OFAllocFailedException class]); @throw (id)&allocFailedException; } #ifdef OF_MSDOS ((struct PreIvars *)instance)->offset = offset; #endif ((struct PreIvars *)instance)->retainCount = 1; #if !defined(OF_HAVE_ATOMIC_OPS) && !defined(OF_AMIGAOS) if OF_UNLIKELY (OFSpinlockNew( &((struct PreIvars *)instance)->retainCountSpinlock) != 0) { # if defined(OF_WINDOWS) __mingw_aligned_free(instance); # elif defined(OF_MSDOS) alignedFree(instance, offset); # else free(instance); # endif @throw [OFInitializationFailedException exceptionWithClass: class]; } #endif instance = (OFObject *)(void *)((char *)instance + PRE_IVARS_ALIGN); memset(instance, 0, instanceSize + extraAlignment + extraSize); if (!objc_constructInstance(class, instance)) { #if !defined(OF_HAVE_ATOMIC_OPS) && !defined(OF_AMIGAOS) OFSpinlockFree(&((struct PreIvars *)(void *) ((char *)instance - PRE_IVARS_ALIGN))->retainCountSpinlock); #endif #if defined(OF_WINDOWS) __mingw_aligned_free((char *)instance - PRE_IVARS_ALIGN); #elif defined(OF_MSDOS) alignedFree((char *)instance - PRE_IVARS_ALIGN, offset); #else free((char *)instance - PRE_IVARS_ALIGN); #endif @throw [OFInitializationFailedException exceptionWithClass: class]; } if OF_UNLIKELY (extra != NULL) *extra = (char *)instance + instanceSize + extraAlignment; |
︙ | ︙ | |||
384 385 386 387 388 389 390 | } /* References for static linking */ void _references_to_categories_of_OFObject(void) { _OFObject_KeyValueCoding_reference = 1; | < | 495 496 497 498 499 500 501 502 503 504 505 506 507 508 | } /* References for static linking */ void _references_to_categories_of_OFObject(void) { _OFObject_KeyValueCoding_reference = 1; } @implementation OFObject + (void)load { #if !defined(OF_APPLE_RUNTIME) || defined(__OBJC2__) objc_setUncaughtExceptionHandler(uncaughtExceptionHandler); |
︙ | ︙ | |||
436 437 438 439 440 441 442 | } + (instancetype)alloc { return OFAllocObject(self, 0, 0, NULL); } | < < < < < | 546 547 548 549 550 551 552 553 554 555 556 557 558 559 | } + (instancetype)alloc { return OFAllocObject(self, 0, 0, NULL); } + (Class)class { return self; } + (OFString *)className { |
︙ | ︙ | |||
473 474 475 476 477 478 479 | + (bool)instancesRespondToSelector: (SEL)selector { return class_respondsToSelector(self, selector); } + (bool)conformsToProtocol: (Protocol *)protocol { | < | < | | 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 | + (bool)instancesRespondToSelector: (SEL)selector { return class_respondsToSelector(self, selector); } + (bool)conformsToProtocol: (Protocol *)protocol { for (Class iter = self; iter != Nil; iter = class_getSuperclass(iter)) if (class_conformsToProtocol(iter, protocol)) return true; return false; } + (IMP)instanceMethodForSelector: (SEL)selector { |
︙ | ︙ | |||
578 579 580 581 582 583 584 | } [self inheritMethodsFromClass: superclass]; } + (bool)resolveClassMethod: (SEL)selector { | | | | 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 | } [self inheritMethodsFromClass: superclass]; } + (bool)resolveClassMethod: (SEL)selector { return false; } + (bool)resolveInstanceMethod: (SEL)selector { return false; } - (instancetype)init { return self; } |
︙ | ︙ | |||
1167 1168 1169 1170 1171 1172 1173 | #endif return self; } - (unsigned int)retainCount { | | | 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 | #endif return self; } - (unsigned int)retainCount { OFAssert(PRE_IVARS->retainCount >= 0); return PRE_IVARS->retainCount; } - (void)release { #if defined(OF_HAVE_ATOMIC_OPS) OFReleaseMemoryBarrier(); |
︙ | ︙ | |||
1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 | { objc_destructInstance(self); #if !defined(OF_HAVE_ATOMIC_OPS) && !defined(OF_AMIGAOS) OFSpinlockFree(&PRE_IVARS->retainCountSpinlock); #endif free((char *)self - PRE_IVARS_ALIGN); } /* Required to use properties with the Apple runtime */ - (id)copyWithZone: (void *)zone { if OF_UNLIKELY (zone != NULL) { [self doesNotRecognizeSelector: _cmd]; | > > > > > > | 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 | { objc_destructInstance(self); #if !defined(OF_HAVE_ATOMIC_OPS) && !defined(OF_AMIGAOS) OFSpinlockFree(&PRE_IVARS->retainCountSpinlock); #endif #if defined(OF_WINDOWS) __mingw_aligned_free((char *)self - PRE_IVARS_ALIGN); #elif defined(OF_MSDOS) alignedFree((char *)self - PRE_IVARS_ALIGN, PRE_IVARS->offset); #else free((char *)self - PRE_IVARS_ALIGN); #endif } /* Required to use properties with the Apple runtime */ - (id)copyWithZone: (void *)zone { if OF_UNLIKELY (zone != NULL) { [self doesNotRecognizeSelector: _cmd]; |
︙ | ︙ |
Modified src/OFOnce.h from [fef3956998] to [63325ff0f7].
1 | /* | | | | | | > > > > | < > | > > > > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "objfw-defs.h" #import "macros.h" #if defined(OF_HAVE_PTHREADS) # include <pthread.h> typedef pthread_once_t OFOnceControl; # define OFOnceControlInitValue PTHREAD_ONCE_INIT #elif defined(OF_HAVE_ATOMIC_OPS) typedef volatile int OFOnceControl; # define OFOnceControlInitValue 0 #elif defined(OF_AMIGAOS) || !defined(OF_HAVE_THREADS) typedef int OFOnceControl; # define OFOnceControlInitValue 0 #endif OF_ASSUME_NONNULL_BEGIN /** @file */ typedef void (*OFOnceFunction)(void); #ifdef __cplusplus extern "C" { #endif /** * @brief Executes the specified function exactly once in the application's * lifetime, even in a multi-threaded environment. * * @param control An OFOnceControl. This should be a static variable * preinitialized to `OFOnceControlInitValue`. * @param function The function to execute once */ extern void OFOnce(OFOnceControl *control, OFOnceFunction function); #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END |
Modified src/OFOnce.m from [72d5ba7049] to [06c9cd7dc5].
1 | /* | | | | | | > > > > | < > | > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdbool.h> #import "OFOnce.h" #if defined(OF_HAVE_THREADS) && defined(OF_HAVE_ATOMIC_OPS) # import "OFAtomic.h" # import "OFPlainMutex.h" #endif #ifdef OF_AMIGAOS # define Class IntuitionClass # include <proto/exec.h> # undef Class #endif void OFOnce(OFOnceControl *control, void (*function)(void)) { #if !defined(OF_HAVE_THREADS) if (*control == 0) { |
︙ | ︙ |
Modified src/OFOptionsParser.h from [14db018626] to [1af2e946a2].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFString.h" @class OFMapTable; |
︙ | ︙ |
Modified src/OFOptionsParser.m from [c0426ac296] to [62d916df57].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFOptionsParser.h" #import "OFApplication.h" #import "OFArray.h" |
︙ | ︙ |
Modified src/OFPBKDF2.h from [fc763da9ca] to [bea3999398].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS #endif #ifndef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS |
︙ | ︙ | |||
58 59 60 61 62 63 64 | #ifdef __cplusplus extern "C" { #endif /** * @brief Derives a key from a password and a salt using PBKDF2. * | | | | | 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | #ifdef __cplusplus extern "C" { #endif /** * @brief Derives a key from a password and a salt using PBKDF2. * * @note This will call @ref OFHMAC#reset on the `HMAC` first, making it * possible to reuse the `HMAC`, but also meaning all previous results * from the `HMAC` get invalidated if they have not been copied. * * @param parameters The parameters to use */ extern void OFPBKDF2(OFPBKDF2Parameters parameters); #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END |
Modified src/OFPBKDF2.m from [cca92e4a20] to [379dcfcbbf].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdlib.h> #import "OFPBKDF2.h" |
︙ | ︙ |
Added src/OFPTRDNSResourceRecord.h version [c4171660b0].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFDNSResourceRecord.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFPTRDNSResourceRecord \ * OFDNSResourceRecord.h ObjFW/OFDNSResourceRecord.h * * @brief A class representing a PTR DNS resource record. */ OF_SUBCLASSING_RESTRICTED @interface OFPTRDNSResourceRecord: OFDNSResourceRecord { OFString *_domainName; } /** * @brief The domain name of the resource record. */ @property (readonly, nonatomic) OFString *domainName; - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFPTRDNSResourceRecord with the * specified name, class, domain name and time to live. * * @param name The name for the resource record * @param DNSClass The class code for the resource record * @param domainName The domain name for the resource record * @param TTL The time to live for the resource record * @return An initialized OFPTRDNSResourceRecord */ - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass domainName: (OFString *)domainName TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END |
Added src/OFPTRDNSResourceRecord.m version [d626700ced].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFPTRDNSResourceRecord.h" @implementation OFPTRDNSResourceRecord @synthesize domainName = _domainName; - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass domainName: (OFString *)domainName TTL: (uint32_t)TTL { self = [super initWithName: name DNSClass: DNSClass recordType: OFDNSRecordTypePTR TTL: TTL]; @try { _domainName = [domainName copy]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_domainName release]; [super dealloc]; } - (bool)isEqual: (id)object { OFPTRDNSResourceRecord *record; if (object == self) return true; if (![object isKindOfClass: [OFPTRDNSResourceRecord class]]) return false; record = object; if (record->_name != _name && ![record->_name isEqual: _name]) return false; if (record->_DNSClass != _DNSClass) return false; if (record->_recordType != _recordType) return false; if (record->_domainName != _domainName && ![record->_domainName isEqual: _domainName]) return false; return true; } - (unsigned long)hash { unsigned long hash; OFHashInit(&hash); OFHashAddHash(&hash, _name.hash); OFHashAddByte(&hash, _DNSClass >> 8); OFHashAddByte(&hash, _DNSClass); OFHashAddByte(&hash, _recordType >> 8); OFHashAddByte(&hash, _recordType); OFHashAddHash(&hash, _domainName.hash); OFHashFinalize(&hash); return hash; } - (OFString *)description { return [OFString stringWithFormat: @"<%@:\n" @"\tName = %@\n" @"\tClass = %@\n" @"\tDomain Name = %@\n" @"\tTTL = %" PRIu32 "\n" @">", self.className, _name, OFDNSClassName(_DNSClass), _domainName, _TTL]; } @end |
Modified src/OFPair.h from [96e09802be] to [98ef1cf7f2].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/OFPair.m from [22c01e92c3] to [030b70db3e].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFPair.h" #import "OFString.h" |
︙ | ︙ |
Modified src/OFPlainCondition.h from [fd9b66a9ca] to [bbdacbeb4f].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "objfw-defs.h" #include "platform.h" #if !defined(OF_HAVE_THREADS) || \ |
︙ | ︙ | |||
52 53 54 55 56 57 58 | extern int OFPlainConditionNew(OFPlainCondition *condition); extern int OFPlainConditionSignal(OFPlainCondition *condition); extern int OFPlainConditionBroadcast(OFPlainCondition *condition); extern int OFPlainConditionWait(OFPlainCondition *condition, OFPlainMutex *mutex); extern int OFPlainConditionTimedWait(OFPlainCondition *condition, OFPlainMutex *mutex, OFTimeInterval timeout); | | | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | extern int OFPlainConditionNew(OFPlainCondition *condition); extern int OFPlainConditionSignal(OFPlainCondition *condition); extern int OFPlainConditionBroadcast(OFPlainCondition *condition); extern int OFPlainConditionWait(OFPlainCondition *condition, OFPlainMutex *mutex); extern int OFPlainConditionTimedWait(OFPlainCondition *condition, OFPlainMutex *mutex, OFTimeInterval timeout); #if defined(OF_AMIGAOS) || defined(DOXYGEN) extern int OFPlainConditionWaitOrExecSignal(OFPlainCondition *condition, OFPlainMutex *mutex, ULONG *signalMask); extern int OFPlainConditionTimedWaitOrExecSignal(OFPlainCondition *condition, OFPlainMutex *mutex, OFTimeInterval timeout, ULONG *signalMask); #endif extern int OFPlainConditionFree(OFPlainCondition *condition); #ifdef __cplusplus } #endif |
Modified src/OFPlainCondition.m from [b7456714c7] to [e3761f4f15].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include "platform.h" #if defined(OF_HAVE_PTHREADS) |
︙ | ︙ |
Modified src/OFPlainMutex.h from [e51d623af9] to [b1091dda6a].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "objfw-defs.h" #include <errno.h> #include "platform.h" |
︙ | ︙ |
Modified src/OFPlainMutex.m from [0367193fde] to [ee16a026b0].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include "platform.h" #if defined(OF_HAVE_PTHREADS) |
︙ | ︙ |
Modified src/OFPlainThread.h from [312286356e] to [3654325ef3].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "objfw-defs.h" #include "platform.h" #if !defined(OF_HAVE_THREADS) || \ (!defined(OF_HAVE_PTHREADS) && !defined(OF_WINDOWS) && !defined(OF_AMIGAOS)) # error No threads available! #endif #import "OFObject.h" #if defined(OF_HAVE_PTHREADS) # include <pthread.h> typedef pthread_t OFPlainThread; #elif defined(OF_WINDOWS) # include <windows.h> typedef HANDLE OFPlainThread; |
︙ | ︙ |
Modified src/OFPlainThread.m from [ef8a973be8] to [7b3faa9baf].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include "platform.h" #if defined(OF_HAVE_PTHREADS) |
︙ | ︙ |
Modified src/OFPlugin.h from [a9cf165ddb] to [3c7ae9a953].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" @class OFString; #ifndef OF_WINDOWS |
︙ | ︙ | |||
71 72 73 74 75 76 77 | */ - (instancetype)initWithPath: (OFString *)path; /** * @brief Returns the address for the specified symbol, or `nil` if not found. * * @param symbol The symbol to return the address for | | | 75 76 77 78 79 80 81 82 83 84 85 86 87 | */ - (instancetype)initWithPath: (OFString *)path; /** * @brief Returns the address for the specified symbol, or `nil` if not found. * * @param symbol The symbol to return the address for * @return The address for the specified symbol, or `nil` if not found */ - (nullable void *)addressForSymbol: (OFString *)symbol; @end OF_ASSUME_NONNULL_END |
Modified src/OFPlugin.m from [dfbf2c9e77] to [cb86f84c31].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdlib.h> #include <string.h> |
︙ | ︙ |
Deleted src/OFPointValue.h version [42acb9db9a].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/OFPointValue.m version [d80a9e47ec].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/OFPointerValue.h version [9280ad762d].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/OFPointerValue.m version [0b6a62e87f].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Modified src/OFPollKernelEventObserver.h from [1b31db8247] to [39d9774f28].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFKernelEventObserver.h" OF_ASSUME_NONNULL_BEGIN @class OFMutableData; |
︙ | ︙ |
Modified src/OFPollKernelEventObserver.m from [e4119778c6] to [ec212c6a2f].
1 | /* | | | | | | > | < | < | > | > > < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #ifdef HAVE_POLL_H # include <poll.h> #endif #import "OFPollKernelEventObserver.h" |
︙ | ︙ | |||
188 189 190 191 192 193 194 | if (events < 0) @throw [OFObserveKernelEventsFailedException exceptionWithObserver: self errNo: errno]; for (size_t i = 0; i < nFDs; i++) { | | | 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | if (events < 0) @throw [OFObserveKernelEventsFailedException exceptionWithObserver: self errNo: errno]; for (size_t i = 0; i < nFDs; i++) { OFAssert(FDs[i].fd <= _maxFD); if (FDs[i].revents & POLLIN) { void *pool2; if (FDs[i].fd == _cancelFD[0]) { char buffer; |
︙ | ︙ |
Modified src/OFRIPEMD160Hash.h from [6a4a8d87d4] to [67cfd43ad3].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFCryptographicHash.h" OF_ASSUME_NONNULL_BEGIN @class OFSecureData; |
︙ | ︙ |
Modified src/OFRIPEMD160Hash.m from [a6c68d768d] to [52ccc3eb83].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "OFRIPEMD160Hash.h" |
︙ | ︙ |
Added src/OFRPDNSResourceRecord.h version [e2c2d99bf4].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFDNSResourceRecord.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFRPDNSResourceRecord \ * OFDNSResourceRecord.h ObjFW/OFDNSResourceRecord.h * * @brief A class representing an RP DNS resource record. */ OF_SUBCLASSING_RESTRICTED @interface OFRPDNSResourceRecord: OFDNSResourceRecord { OFString *_mailbox, *_TXTDomainName; } /** * @brief The mailbox of the responsible person of the resource record. */ @property (readonly, nonatomic) OFString *mailbox; /** * @brief A domain name that contains a TXT resource record for the responsible * person of the resource record. */ @property (readonly, nonatomic) OFString *TXTDomainName; - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFRPDNSResourceRecord with the * specified name, class, alias and time to live. * * @param name The name for the resource record * @param DNSClass The class code for the resource record * @param mailbox The mailbox of the responsible person of the resource record * @param TXTDomainName A domain name that contains a TXT resource record for * the responsible person of the resource record * @param TTL The time to live for the resource record * @return An initialized OFRPDNSResourceRecord */ - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass mailbox: (OFString *)mailbox TXTDomainName: (OFString *)TXTDomainName TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END |
Added src/OFRPDNSResourceRecord.m version [a4885cf8d2].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFRPDNSResourceRecord.h" @implementation OFRPDNSResourceRecord @synthesize mailbox = _mailbox, TXTDomainName = _TXTDomainName; - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass mailbox: (OFString *)mailbox TXTDomainName: (OFString *)TXTDomainName TTL: (uint32_t)TTL { self = [super initWithName: name DNSClass: DNSClass recordType: OFDNSRecordTypeRP TTL: TTL]; @try { _mailbox = [mailbox copy]; _TXTDomainName = [TXTDomainName copy]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_mailbox release]; [_TXTDomainName release]; [super dealloc]; } - (bool)isEqual: (id)object { OFRPDNSResourceRecord *record; if (object == self) return true; if (![object isKindOfClass: [OFRPDNSResourceRecord class]]) return false; record = object; if (record->_name != _name && ![record->_name isEqual: _name]) return false; if (record->_DNSClass != _DNSClass) return false; if (record->_recordType != _recordType) return false; if (record->_mailbox != _mailbox && ![record->_mailbox isEqual: _mailbox]) return false; if (record->_TXTDomainName != _TXTDomainName && ![record->_TXTDomainName isEqual: _TXTDomainName]) return false; return true; } - (unsigned long)hash { unsigned long hash; OFHashInit(&hash); OFHashAddHash(&hash, _name.hash); OFHashAddByte(&hash, _DNSClass >> 8); OFHashAddByte(&hash, _DNSClass); OFHashAddByte(&hash, _recordType >> 8); OFHashAddByte(&hash, _recordType); OFHashAddHash(&hash, _mailbox.hash); OFHashAddHash(&hash, _TXTDomainName.hash); OFHashFinalize(&hash); return hash; } - (OFString *)description { return [OFString stringWithFormat: @"<%@:\n" @"\tName = %@\n" @"\tClass = %@\n" @"\tMailbox = %@\n" @"\tTXT Domain Name = %@\n" @"\tTTL = %" PRIu32 "\n" @">", self.className, _name, OFDNSClassName(_DNSClass), _mailbox, _TXTDomainName, _TTL]; } @end |
Modified src/OFRangeCharacterSet.h from [c903dba907] to [888dbfde70].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFCharacterSet.h" OF_ASSUME_NONNULL_BEGIN @interface OFRangeCharacterSet: OFCharacterSet |
︙ | ︙ |
Modified src/OFRangeCharacterSet.m from [4870541066] to [1e2167cae0].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFRangeCharacterSet.h" #import "OFString.h" |
︙ | ︙ |
Deleted src/OFRangeValue.h version [3251ae1de3].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/OFRangeValue.m version [72e3ffee04].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/OFRectValue.h version [83e8354a4a].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/OFRectValue.m version [0064a9b262].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Modified src/OFRecursiveMutex.h from [e91aa73730] to [6dad2f7f53].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFLocking.h" #import "OFPlainMutex.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ |
Modified src/OFRecursiveMutex.m from [cb58226e3c] to [ed601fd944].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #import "OFRecursiveMutex.h" |
︙ | ︙ |
Modified src/OFRunLoop+Private.h from [1af8d65653] to [f80d306a90].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFRunLoop.h" #import "OFStream.h" #ifdef OF_HAVE_SOCKETS # import "OFDatagramSocket.h" # import "OFSequencedPacketSocket.h" |
︙ | ︙ |
Modified src/OFRunLoop.h from [e058e5f18b] to [a1c1d19578].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFString.h" #ifdef OF_AMIGAOS # include <exec/types.h> |
︙ | ︙ | |||
99 100 101 102 103 104 105 | * @brief Adds an OFTimer to the run loop for the specified mode. * * @param timer The timer to add * @param mode The run loop mode in which to run the timer */ - (void)addTimer: (OFTimer *)timer forMode: (OFRunLoopMode)mode; | | | 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | * @brief Adds an OFTimer to the run loop for the specified mode. * * @param timer The timer to add * @param mode The run loop mode in which to run the timer */ - (void)addTimer: (OFTimer *)timer forMode: (OFRunLoopMode)mode; #if defined(OF_AMIGAOS) || defined(DOXYGEN) /** * @brief Adds an Exec Signal to the run loop. * * If a signal is added multiple times, the specified methods will be performed * in the order added. * * @note This is only available on AmigaOS! |
︙ | ︙ |
Modified src/OFRunLoop.m from [ccade11e78] to [b4afc33feb].
1 | /* | | | | | | > > > > | < > | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #import "OFRunLoop.h" #import "OFRunLoop+Private.h" #import "OFArray.h" #import "OFData.h" #import "OFDictionary.h" |
︙ | ︙ | |||
270 271 272 273 274 275 276 | /* * Retain the queue so that it doesn't disappear from us because the * handler called -[cancelAsyncRequests]. */ OFList OF_GENERIC(OF_KINDOF(OFRunLoopReadQueueItem *)) *queue = [[_readQueues objectForKey: object] retain]; | | | 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | /* * Retain the queue so that it doesn't disappear from us because the * handler called -[cancelAsyncRequests]. */ OFList OF_GENERIC(OF_KINDOF(OFRunLoopReadQueueItem *)) *queue = [[_readQueues objectForKey: object] retain]; OFAssert(queue != nil); @try { if (![queue.firstObject handleObject: object]) { OFListItem listItem = queue.firstListItem; /* * The handler might have called -[cancelAsyncRequests] |
︙ | ︙ | |||
314 315 316 317 318 319 320 | { /* * Retain the queue so that it doesn't disappear from us because the * handler called -[cancelAsyncRequests]. */ OFList *queue = [[_writeQueues objectForKey: object] retain]; | | | 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 | { /* * Retain the queue so that it doesn't disappear from us because the * handler called -[cancelAsyncRequests]. */ OFList *queue = [[_writeQueues objectForKey: object] retain]; OFAssert(queue != nil); @try { if (![queue.firstObject handleObject: object]) { OFListItem listItem = queue.firstListItem; /* * The handler might have called -[cancelAsyncRequests] |
︙ | ︙ | |||
1324 1325 1326 1327 1328 1329 1330 | OFRunLoopState *state = stateForMode(runLoop, mode, false); OFList *queue; if (state == nil) return; if ((queue = [state->_writeQueues objectForKey: object]) != nil) { | | | | 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 | OFRunLoopState *state = stateForMode(runLoop, mode, false); OFList *queue; if (state == nil) return; if ((queue = [state->_writeQueues objectForKey: object]) != nil) { OFAssert(queue.count > 0); /* * Clear the queue now, in case this has been called from a * handler, as otherwise, we'd do the cleanups below twice. */ [queue removeAllObjects]; [state->_kernelEventObserver removeObjectForWriting: object]; [state->_writeQueues removeObjectForKey: object]; } if ((queue = [state->_readQueues objectForKey: object]) != nil) { OFAssert(queue.count > 0); /* * Clear the queue now, in case this has been called from a * handler, as otherwise, we'd do the cleanups below twice. */ [queue removeAllObjects]; |
︙ | ︙ | |||
1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 | #ifdef OF_HAVE_THREADS } @finally { [state->_timersQueueMutex unlock]; } #endif if (timer.valid) { [timer fire]; return; } } #ifdef OF_HAVE_THREADS [state->_timersQueueMutex lock]; | > | 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 | #ifdef OF_HAVE_THREADS } @finally { [state->_timersQueueMutex unlock]; } #endif if (timer.valid) { [timer of_reschedule]; [timer fire]; return; } } #ifdef OF_HAVE_THREADS [state->_timersQueueMutex lock]; |
︙ | ︙ |
Modified src/OFRunLoopConstants.inc from [04d2ca961c] to [f15ab41743].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ const OFRunLoopMode OFDefaultRunLoopMode = @"OFDefaultRunLoopMode"; |
Modified src/OFSCTPSocket.h from [009248f90f] to [4e07124e27].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFSequencedPacketSocket.h" #import "OFRunLoop.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ |
Modified src/OFSCTPSocket.m from [5e9ca7609a] to [23fe3787d2].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #include <stdio.h> #include <stdlib.h> |
︙ | ︙ | |||
32 33 34 35 36 37 38 | #import "OFRunLoop.h" #import "OFRunLoop+Private.h" #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFString.h" #import "OFThread.h" | | | 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | #import "OFRunLoop.h" #import "OFRunLoop+Private.h" #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFString.h" #import "OFThread.h" #import "OFAlreadyOpenException.h" #import "OFBindIPSocketFailedException.h" #import "OFGetOptionFailedException.h" #import "OFNotOpenException.h" #import "OFSetOptionFailedException.h" static const OFRunLoopMode connectRunLoopMode = @"OFSCTPSocketConnectRunLoopMode"; |
︙ | ︙ | |||
81 82 83 84 85 86 87 | errNo: (int *)errNo { #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) int flags; #endif if (_socket != OFInvalidSocketHandle) | | | 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | errNo: (int *)errNo { #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) int flags; #endif if (_socket != OFInvalidSocketHandle) @throw [OFAlreadyOpenException exceptionWithObject: self]; if ((_socket = socket( ((struct sockaddr *)&address->sockaddr)->sa_family, SOCK_STREAM | SOCK_CLOEXEC, IPPROTO_SCTP)) == OFInvalidSocketHandle) { *errNo = OFSocketErrNo(); return false; |
︙ | ︙ | |||
161 162 163 164 165 166 167 | - (void)asyncConnectToHost: (OFString *)host port: (uint16_t)port runLoopMode: (OFRunLoopMode)runLoopMode { void *pool = objc_autoreleasePoolPush(); if (_socket != OFInvalidSocketHandle) | | | 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | - (void)asyncConnectToHost: (OFString *)host port: (uint16_t)port runLoopMode: (OFRunLoopMode)runLoopMode { void *pool = objc_autoreleasePoolPush(); if (_socket != OFInvalidSocketHandle) @throw [OFAlreadyOpenException exceptionWithObject: self]; [[[[OFAsyncIPSocketConnector alloc] initWithSocket: self host: host port: port delegate: _delegate block: NULL |
︙ | ︙ | |||
193 194 195 196 197 198 199 | port: (uint16_t)port runLoopMode: (OFRunLoopMode)runLoopMode block: (OFSCTPSocketAsyncConnectBlock)block { void *pool = objc_autoreleasePoolPush(); if (_socket != OFInvalidSocketHandle) | | | 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | port: (uint16_t)port runLoopMode: (OFRunLoopMode)runLoopMode block: (OFSCTPSocketAsyncConnectBlock)block { void *pool = objc_autoreleasePoolPush(); if (_socket != OFInvalidSocketHandle) @throw [OFAlreadyOpenException exceptionWithObject: self]; [[[[OFAsyncIPSocketConnector alloc] initWithSocket: self host: host port: port delegate: nil block: block] autorelease] |
︙ | ︙ | |||
218 219 220 221 222 223 224 | OFData *socketAddresses; OFSocketAddress address; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) int flags; #endif if (_socket != OFInvalidSocketHandle) | | | 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | OFData *socketAddresses; OFSocketAddress address; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) int flags; #endif if (_socket != OFInvalidSocketHandle) @throw [OFAlreadyOpenException exceptionWithObject: self]; socketAddresses = [[OFThread DNSResolver] resolveAddressesForHost: host addressFamily: OFSocketAddressFamilyAny]; address = *(OFSocketAddress *)[socketAddresses itemAtIndex: 0]; OFSocketAddressSetIPPort(&address, port); |
︙ | ︙ |
Modified src/OFSHA1Hash.h from [c7a73ceb16] to [64d2afb749].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFCryptographicHash.h" OF_ASSUME_NONNULL_BEGIN @class OFSecureData; |
︙ | ︙ |
Modified src/OFSHA1Hash.m from [6da836d4ff] to [caff9753e0].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "OFSHA1Hash.h" |
︙ | ︙ |
Modified src/OFSHA224Hash.h from [ecc593c441] to [0f1d9ba717].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFSHA224Or256Hash.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/OFSHA224Hash.m from [5e5ae70827] to [d7e40afd7b].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFSHA224Hash.h" static const size_t digestSize = 28; |
︙ | ︙ |
Modified src/OFSHA224Or256Hash.h from [9235d0cf7a] to [25c662b13e].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFCryptographicHash.h" OF_ASSUME_NONNULL_BEGIN @class OFSecureData; |
︙ | ︙ |
Modified src/OFSHA224Or256Hash.m from [de7aa6c8f4] to [86fb1d5e3c].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdlib.h> #include <string.h> |
︙ | ︙ |
Modified src/OFSHA256Hash.h from [29c7ad23a9] to [98d58bd47b].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFSHA224Or256Hash.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/OFSHA256Hash.m from [d082eb2586] to [7079ea7257].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFSHA256Hash.h" static const size_t digestSize = 32; |
︙ | ︙ |
Modified src/OFSHA384Hash.h from [7c87550526] to [6c20a3b87e].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFSHA384Or512Hash.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/OFSHA384Hash.m from [30d7ff4a68] to [12d0f065a8].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFSHA384Hash.h" static const size_t digestSize = 48; |
︙ | ︙ |
Modified src/OFSHA384Or512Hash.h from [889dffbb99] to [66ab5358ed].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFCryptographicHash.h" OF_ASSUME_NONNULL_BEGIN @class OFSecureData; |
︙ | ︙ |
Modified src/OFSHA384Or512Hash.m from [f0d2e79fad] to [3134f6cb6f].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdlib.h> #include <string.h> |
︙ | ︙ |
Modified src/OFSHA512Hash.h from [b25fc86287] to [ef90c0c9c8].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFSHA384Or512Hash.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/OFSHA512Hash.m from [b08066342d] to [d90caa623d].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFSHA512Hash.h" static const size_t digestSize = 64; |
︙ | ︙ |
Added src/OFSOADNSResourceRecord.h version [c302dba47e].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFDNSResourceRecord.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFSOADNSResourceRecord \ * OFDNSResourceRecord.h ObjFW/OFDNSResourceRecord.h * * @brief A class representing an SOA DNS resource record. */ OF_SUBCLASSING_RESTRICTED @interface OFSOADNSResourceRecord: OFDNSResourceRecord { OFString *_primaryNameServer, *_responsiblePerson; uint32_t _serialNumber, _refreshInterval, _retryInterval; uint32_t _expirationInterval, _minTTL; } /** * @brief The the primary name server for the zone. */ @property (readonly, nonatomic) OFString *primaryNameServer; /** * @brief The mailbox of the person responsible for the zone. */ @property (readonly, nonatomic) OFString *responsiblePerson; /** * @brief The serial number of the original copy of the zone. */ @property (readonly, nonatomic) uint32_t serialNumber; /** * @brief The refresh interval of the zone. */ @property (readonly, nonatomic) uint32_t refreshInterval; /** * @brief The retry interval of the zone. */ @property (readonly, nonatomic) uint32_t retryInterval; /** * @brief The expiration interval of the zone. */ @property (readonly, nonatomic) uint32_t expirationInterval; /** * @brief The minimum TTL of the zone. */ @property (readonly, nonatomic) uint32_t minTTL; - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFSOADNSResourceRecord with the * specified name, class, text data and time to live. * * @param name The name for the resource record * @param DNSClass The class code for the resource record * @param primaryNameServer The the primary name server for the zone * @param responsiblePerson The mailbox of the person responsible for the zone * @param serialNumber The serial number of the original copy of the zone * @param refreshInterval The refresh interval of the zone * @param retryInterval The retry interval of the zone * @param expirationInterval The expiration interval of the zone * @param minTTL The minimum TTL of the zone * @param TTL The time to live for the resource record * @return An initialized OFSOADNSResourceRecord */ - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass primaryNameServer: (OFString *)primaryNameServer responsiblePerson: (OFString *)responsiblePerson serialNumber: (uint32_t)serialNumber refreshInterval: (uint32_t)refreshInterval retryInterval: (uint32_t)retryInterval expirationInterval: (uint32_t)expirationInterval minTTL: (uint32_t)minTTL TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END |
Added src/OFSOADNSResourceRecord.m version [d35ce9d3ce].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFSOADNSResourceRecord.h" @implementation OFSOADNSResourceRecord @synthesize primaryNameServer = _primaryNameServer; @synthesize responsiblePerson = _responsiblePerson; @synthesize serialNumber = _serialNumber, refreshInterval = _refreshInterval; @synthesize retryInterval = _retryInterval; @synthesize expirationInterval = _expirationInterval, minTTL = _minTTL; - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass primaryNameServer: (OFString *)primaryNameServer responsiblePerson: (OFString *)responsiblePerson serialNumber: (uint32_t)serialNumber refreshInterval: (uint32_t)refreshInterval retryInterval: (uint32_t)retryInterval expirationInterval: (uint32_t)expirationInterval minTTL: (uint32_t)minTTL TTL: (uint32_t)TTL { self = [super initWithName: name DNSClass: DNSClass recordType: OFDNSRecordTypeSOA TTL: TTL]; @try { _primaryNameServer = [primaryNameServer copy]; _responsiblePerson = [responsiblePerson copy]; _serialNumber = serialNumber; _refreshInterval = refreshInterval; _retryInterval = retryInterval; _expirationInterval = expirationInterval; _minTTL = minTTL; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_primaryNameServer release]; [_responsiblePerson release]; [super dealloc]; } - (bool)isEqual: (id)object { OFSOADNSResourceRecord *record; if (object == self) return true; if (![object isKindOfClass: [OFSOADNSResourceRecord class]]) return false; record = object; if (record->_name != _name && ![record->_name isEqual: _name]) return false; if (record->_DNSClass != _DNSClass) return false; if (record->_recordType != _recordType) return false; if (record->_primaryNameServer != _primaryNameServer && ![record->_primaryNameServer isEqual: _primaryNameServer]) return false; if (record->_responsiblePerson != _responsiblePerson && ![record->_responsiblePerson isEqual: _responsiblePerson]) return false; if (record->_serialNumber != _serialNumber) return false; if (record->_refreshInterval != _refreshInterval) return false; if (record->_retryInterval != _retryInterval) return false; if (record->_expirationInterval != _expirationInterval) return false; if (record->_minTTL != _minTTL) return false; return true; } - (unsigned long)hash { unsigned long hash; OFHashInit(&hash); OFHashAddHash(&hash, _name.hash); OFHashAddByte(&hash, _DNSClass >> 8); OFHashAddByte(&hash, _DNSClass); OFHashAddByte(&hash, _recordType >> 8); OFHashAddByte(&hash, _recordType); OFHashAddHash(&hash, _primaryNameServer.hash); OFHashAddHash(&hash, _responsiblePerson.hash); OFHashAddByte(&hash, _serialNumber >> 24); OFHashAddByte(&hash, _serialNumber >> 16); OFHashAddByte(&hash, _serialNumber >> 8); OFHashAddByte(&hash, _serialNumber); OFHashAddByte(&hash, _refreshInterval >> 24); OFHashAddByte(&hash, _refreshInterval >> 16); OFHashAddByte(&hash, _refreshInterval >> 8); OFHashAddByte(&hash, _refreshInterval); OFHashAddByte(&hash, _retryInterval >> 24); OFHashAddByte(&hash, _retryInterval >> 16); OFHashAddByte(&hash, _retryInterval >> 8); OFHashAddByte(&hash, _retryInterval); OFHashAddByte(&hash, _expirationInterval >> 24); OFHashAddByte(&hash, _expirationInterval >> 16); OFHashAddByte(&hash, _expirationInterval >> 8); OFHashAddByte(&hash, _expirationInterval); OFHashAddByte(&hash, _minTTL >> 24); OFHashAddByte(&hash, _minTTL >> 16); OFHashAddByte(&hash, _minTTL >> 8); OFHashAddByte(&hash, _minTTL); OFHashFinalize(&hash); return hash; } - (OFString *)description { return [OFString stringWithFormat: @"<%@:\n" @"\tName = %@\n" @"\tClass = %@\n" @"\tPrimary Name Server = %@\n" @"\tResponsible Person = %@\n" @"\tSerial Number = %" PRIu32 "\n" @"\tRefresh Interval = %" PRIu32 "\n" @"\tRetry Interval = %" PRIu32 "\n" @"\tExpiration Interval = %" PRIu32 "\n" @"\tMinimum TTL = %" PRIu32 "\n" @"\tTTL = %" PRIu32 "\n" @">", self.className, _name, OFDNSClassName(_DNSClass), _primaryNameServer, _responsiblePerson, _serialNumber, _refreshInterval, _retryInterval, _expirationInterval, _minTTL, _TTL]; } @end |
Modified src/OFSPXSocket.h from [62171025db] to [f511a1a1ba].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFSequencedPacketSocket.h" #import "OFRunLoop.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ | |||
86 87 88 89 90 91 92 | * @brief Connect the OFSPXSocket to the specified destination. * * @param network The network on which the node to connect to is * @param node The node to connect to * @param port The port (sometimes also called socket number) on the node to * connect to * @throw OFConnectSPXSocketFailedException Connecting failed | | | 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | * @brief Connect the OFSPXSocket to the specified destination. * * @param network The network on which the node to connect to is * @param node The node to connect to * @param port The port (sometimes also called socket number) on the node to * connect to * @throw OFConnectSPXSocketFailedException Connecting failed * @throw OFAlreadyOpenException The socket is already connected or bound */ - (void)connectToNetwork: (uint32_t)network node: (const unsigned char [_Nonnull IPX_NODE_LEN])node port: (uint16_t)port; /** * @brief Asynchronously connect the OFSPXSocket to the specified destination. |
︙ | ︙ | |||
111 112 113 114 115 116 117 | /** * @brief Asynchronously connect the OFSPXSocket to the specified destination. * * @param network The network on which the node to connect to is * @param node The node to connect to * @param port The port (sometimes also called socket number) on the node to * connect to | | > | 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | /** * @brief Asynchronously connect the OFSPXSocket to the specified destination. * * @param network The network on which the node to connect to is * @param node The node to connect to * @param port The port (sometimes also called socket number) on the node to * connect to * @param runLoopMode The run loop mode in which to perform the asynchronous * connect */ - (void)asyncConnectToNetwork: (uint32_t)network node: (const unsigned char [_Nonnull IPX_NODE_LEN])node port: (uint16_t)port runLoopMode: (OFRunLoopMode)runLoopMode; #ifdef OF_HAVE_BLOCKS |
︙ | ︙ | |||
140 141 142 143 144 145 146 | /** * @brief Asynchronously connect the OFSPXSocket to the specified destination. * * @param node The node to connect to * @param network The network on which the node to connect to is * @param port The port (sometimes also called socket number) on the node to * connect to | | > | | 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | /** * @brief Asynchronously connect the OFSPXSocket to the specified destination. * * @param node The node to connect to * @param network The network on which the node to connect to is * @param port The port (sometimes also called socket number) on the node to * connect to * @param runLoopMode The run loop mode in which to perform the asynchronous * connect * @param block The block to execute once the connection has been established */ - (void)asyncConnectToNetwork: (uint32_t)network node: (const unsigned char [_Nonnull IPX_NODE_LEN])node port: (uint16_t)port runLoopMode: (OFRunLoopMode)runLoopMode block: (OFSPXSocketAsyncConnectBlock)block; #endif /** * @brief Bind the socket to the specified network, node and port. * * @param network The IPX network to bind to. 0 means the current network. * @param node The IPX network to bind to. An all zero node means the * computer's node. * @param port The port (sometimes called socket number) to bind to. 0 means to * pick one and return via the returned socket address. * @return The address on which this socket can be reached * @throw OFBindIPXSocketFailedException Binding failed * @throw OFAlreadyOpenException The socket is already connected or bound */ - (OFSocketAddress) bindToNetwork: (uint32_t)network node: (const unsigned char [_Nonnull IPX_NODE_LEN])node port: (uint16_t)port; @end OF_ASSUME_NONNULL_END |
Modified src/OFSPXSocket.m from [4bb1b2f501] to [007210b145].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #import "OFSPXSocket.h" #import "OFRunLoop.h" #import "OFRunLoop+Private.h" #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFAlreadyOpenException.h" #import "OFBindIPXSocketFailedException.h" #import "OFConnectSPXSocketFailedException.h" #import "OFNotOpenException.h" #ifndef NSPROTO_SPX # define NSPROTO_SPX 0 #endif |
︙ | ︙ | |||
181 182 183 184 185 186 187 | errNo: (int *)errNo { #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) int flags; #endif if (_socket != OFInvalidSocketHandle) | | | 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | errNo: (int *)errNo { #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) int flags; #endif if (_socket != OFInvalidSocketHandle) @throw [OFAlreadyOpenException exceptionWithObject: self]; if ((_socket = socket(address->sockaddr.ipx.sipx_family, SOCK_SEQPACKET | SOCK_CLOEXEC, NSPROTO_SPX)) == OFInvalidSocketHandle) { *errNo = OFSocketErrNo(); return false; } |
︙ | ︙ | |||
319 320 321 322 323 324 325 | { OFSocketAddress address; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC) int flags; #endif if (_socket != OFInvalidSocketHandle) | | | 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | { OFSocketAddress address; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC) int flags; #endif if (_socket != OFInvalidSocketHandle) @throw [OFAlreadyOpenException exceptionWithObject: self]; address = OFSocketAddressMakeIPX(network, node, port); if ((_socket = socket(address.sockaddr.ipx.sipx_family, SOCK_SEQPACKET | SOCK_CLOEXEC, NSPROTO_SPX)) == OFInvalidSocketHandle) @throw [OFBindIPXSocketFailedException |
︙ | ︙ |
Modified src/OFSPXStreamSocket.h from [454aa9fc7f] to [9da00513f1].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFStreamSocket.h" #import "OFRunLoop.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ | |||
87 88 89 90 91 92 93 | * @brief Connect the OFSPXStreamSocket to the specified destination. * * @param network The network on which the node to connect to is * @param node The node to connect to * @param port The port (sometimes also called socket number) on the node to * connect to * @throw OFConnectSPXSocketFailedException Connecting failed | | | 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | * @brief Connect the OFSPXStreamSocket to the specified destination. * * @param network The network on which the node to connect to is * @param node The node to connect to * @param port The port (sometimes also called socket number) on the node to * connect to * @throw OFConnectSPXSocketFailedException Connecting failed * @throw OFAlreadyOpenException The socket is already connected or bound */ - (void)connectToNetwork: (uint32_t)network node: (const unsigned char [_Nonnull IPX_NODE_LEN])node port: (uint16_t)port; /** * @brief Asynchronously connect the OFSPXStreamSocket to the specified |
︙ | ︙ | |||
114 115 116 117 118 119 120 | * @brief Asynchronously connect the OFSPXStreamSocket to the specified * destination. * * @param network The network on which the node to connect to is * @param node The node to connect to * @param port The port (sometimes also called socket number) on the node to * connect to | | > | 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | * @brief Asynchronously connect the OFSPXStreamSocket to the specified * destination. * * @param network The network on which the node to connect to is * @param node The node to connect to * @param port The port (sometimes also called socket number) on the node to * connect to * @param runLoopMode The run loop mode in which to perform the asynchronous * connect */ - (void)asyncConnectToNetwork: (uint32_t)network node: (const unsigned char [_Nonnull IPX_NODE_LEN])node port: (uint16_t)port runLoopMode: (OFRunLoopMode)runLoopMode; #ifdef OF_HAVE_BLOCKS |
︙ | ︙ | |||
145 146 147 148 149 150 151 | * @brief Asynchronously connect the OFSPXStreamSocket to the specified * destination. * * @param network The network on which the node to connect to is * @param node The node to connect to * @param port The port (sometimes also called socket number) on the node to * connect to | | > | | 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | * @brief Asynchronously connect the OFSPXStreamSocket to the specified * destination. * * @param network The network on which the node to connect to is * @param node The node to connect to * @param port The port (sometimes also called socket number) on the node to * connect to * @param runLoopMode The run loop mode in which to perform the asynchronous * connect * @param block The block to execute once the connection has been established */ - (void)asyncConnectToNetwork: (uint32_t)network node: (const unsigned char [_Nonnull IPX_NODE_LEN])node port: (uint16_t)port runLoopMode: (OFRunLoopMode)runLoopMode block: (OFSPXStreamSocketAsyncConnectBlock)block; #endif /** * @brief Bind the socket to the specified network, node and port. * * @param network The IPX network to bind to. 0 means the current network. * @param node The IPX network to bind to. An all zero node means the * computer's node. * @param port The port (sometimes called socket number) to bind to. 0 means to * pick one and return via the returned socket address. * @return The address on which this socket can be reached * @throw OFBindIPXSocketFailedException Binding failed * @throw OFAlreadyOpenException The socket is already connected or bound */ - (OFSocketAddress) bindToNetwork: (uint32_t)network node: (const unsigned char [_Nonnull IPX_NODE_LEN])node port: (uint16_t)port; @end OF_ASSUME_NONNULL_END |
Modified src/OFSPXStreamSocket.m from [3d76de2dbb] to [90372031f9].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #import "OFSPXStreamSocket.h" #import "OFRunLoop.h" #import "OFRunLoop+Private.h" #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFAlreadyOpenException.h" #import "OFBindIPXSocketFailedException.h" #import "OFConnectSPXSocketFailedException.h" #import "OFNotOpenException.h" #ifndef NSPROTO_SPX # define NSPROTO_SPX 0 #endif |
︙ | ︙ | |||
183 184 185 186 187 188 189 | errNo: (int *)errNo { #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) int flags; #endif if (_socket != OFInvalidSocketHandle) | | | 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | errNo: (int *)errNo { #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) int flags; #endif if (_socket != OFInvalidSocketHandle) @throw [OFAlreadyOpenException exceptionWithObject: self]; if ((_socket = socket(address->sockaddr.ipx.sipx_family, SOCK_STREAM | SOCK_CLOEXEC, NSPROTO_SPX)) == OFInvalidSocketHandle) { *errNo = OFSocketErrNo(); return false; } |
︙ | ︙ | |||
321 322 323 324 325 326 327 | { OFSocketAddress address; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC) int flags; #endif if (_socket != OFInvalidSocketHandle) | | | 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 | { OFSocketAddress address; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC) int flags; #endif if (_socket != OFInvalidSocketHandle) @throw [OFAlreadyOpenException exceptionWithObject: self]; address = OFSocketAddressMakeIPX(network, node, port); if ((_socket = socket(address.sockaddr.ipx.sipx_family, SOCK_STREAM | SOCK_CLOEXEC, NSPROTO_SPX)) == OFInvalidSocketHandle) @throw [OFBindIPXSocketFailedException exceptionWithNetwork: network |
︙ | ︙ |
Added src/OFSRVDNSResourceRecord.h version [784df248e7].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFDNSResourceRecord.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFSRVDNSResourceRecord \ * OFDNSResourceRecord.h ObjFW/OFDNSResourceRecord.h * * @brief A class representing an SRV DNS resource record. */ OF_SUBCLASSING_RESTRICTED @interface OFSRVDNSResourceRecord: OFDNSResourceRecord { uint16_t _priority, _weight; OFString *_target; uint16_t _port; } /** * @brief The priority of the resource record. */ @property (readonly, nonatomic) uint16_t priority; /** * @brief The weight of the resource record. */ @property (readonly, nonatomic) uint16_t weight; /** * @brief The target of the resource record. */ @property (readonly, nonatomic) OFString *target; /** * @brief The port on the target of the resource record. */ @property (readonly, nonatomic) uint16_t port; - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFSRVDNSResourceRecord with the * specified name, priority, weight, target, port and time to live. * * @param name The name for the resource record * @param priority The priority for the resource record * @param weight The weight for the resource record * @param target The target for the resource record * @param port The port on the target for the resource record * @param TTL The time to live for the resource record * @return An initialized OFSRVDNSResourceRecord */ - (instancetype)initWithName: (OFString *)name priority: (uint16_t)priority weight: (uint16_t)weight target: (OFString *)target port: (uint16_t)port TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END |
Added src/OFSRVDNSResourceRecord.m version [139c58b4df].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFSRVDNSResourceRecord.h" @implementation OFSRVDNSResourceRecord @synthesize priority = _priority, weight = _weight, target = _target; @synthesize port = _port; - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } - (instancetype)initWithName: (OFString *)name priority: (uint16_t)priority weight: (uint16_t)weight target: (OFString *)target port: (uint16_t)port TTL: (uint32_t)TTL { self = [super initWithName: name DNSClass: OFDNSClassIN recordType: OFDNSRecordTypeSRV TTL: TTL]; @try { _priority = priority; _weight = weight; _target = [target copy]; _port = port; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_target release]; [super dealloc]; } - (bool)isEqual: (id)object { OFSRVDNSResourceRecord *record; if (object == self) return true; if (![object isKindOfClass: [OFSRVDNSResourceRecord class]]) return false; record = object; if (record->_name != _name && ![record->_name isEqual: _name]) return false; if (record->_DNSClass != _DNSClass) return false; if (record->_recordType != _recordType) return false; if (record->_priority != _priority) return false; if (record->_weight != _weight) return false; if (record->_target != _target && ![record->_target isEqual: _target]) return false; if (record->_port != _port) return false; return true; } - (unsigned long)hash { unsigned long hash; OFHashInit(&hash); OFHashAddHash(&hash, _name.hash); OFHashAddByte(&hash, _DNSClass >> 8); OFHashAddByte(&hash, _DNSClass); OFHashAddByte(&hash, _recordType >> 8); OFHashAddByte(&hash, _recordType); OFHashAddByte(&hash, _priority >> 8); OFHashAddByte(&hash, _priority); OFHashAddByte(&hash, _weight >> 8); OFHashAddByte(&hash, _weight); OFHashAddHash(&hash, _target.hash); OFHashAddByte(&hash, _port >> 8); OFHashAddByte(&hash, _port); OFHashFinalize(&hash); return hash; } - (OFString *)description { return [OFString stringWithFormat: @"<%@:\n" @"\tName = %@\n" @"\tPriority = %" PRIu16 "\n" @"\tWeight = %" PRIu16 "\n" @"\tTarget = %@\n" @"\tPort = %" PRIu16 "\n" @"\tTTL = %" PRIu32 "\n" @">", self.className, _name, _priority, _weight, _target, _port, _TTL]; } @end |
Modified src/OFSandbox.h from [021642ddcf] to [beadde934b].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" OF_ASSUME_NONNULL_BEGIN @class OFArray OF_GENERIC(ObjectType); |
︙ | ︙ |
Modified src/OFSandbox.m from [de6e0ab02e] to [99a2c0b47e].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFSandbox.h" #import "OFArray.h" #import "OFPair.h" |
︙ | ︙ |
Modified src/OFScrypt.h from [7e18036f48] to [76bac8d2f2].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS #endif #ifndef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS |
︙ | ︙ | |||
66 67 68 69 70 71 72 | size_t blockSize); extern void OFScryptROMix(uint32_t *buffer, size_t blockSize, size_t costFactor, uint32_t *tmp); /** * @brief Derives a key from a password and a salt using scrypt. * | | | | 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | size_t blockSize); extern void OFScryptROMix(uint32_t *buffer, size_t blockSize, size_t costFactor, uint32_t *tmp); /** * @brief Derives a key from a password and a salt using scrypt. * * @param parameters The parameters to use */ extern void OFScrypt(OFScryptParameters parameters); #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END |
Modified src/OFScrypt.m from [730aa203eb] to [94500350d8].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFHMAC.h" #import "OFSHA256Hash.h" #import "OFSecureData.h" |
︙ | ︙ |
Modified src/OFSecureData.h from [9dc679ab94] to [1f30249f31].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFData.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ | |||
28 29 30 31 32 33 34 35 | * deallocated. Check the @ref allowsSwappableMemory property to see * whether a particular OFSecureData might be allocated in swappable * memory. */ OF_SUBCLASSING_RESTRICTED @interface OFSecureData: OFData { void *_page; | > > > < | 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | * deallocated. Check the @ref allowsSwappableMemory property to see * whether a particular OFSecureData might be allocated in swappable * memory. */ OF_SUBCLASSING_RESTRICTED @interface OFSecureData: OFData { unsigned char *_Nullable _items; size_t _count, _itemSize; bool _freeWhenDone, _allowsSwappableMemory; void *_page; } /** * @brief Whether the data may be stored in swappable memory. */ @property (readonly, nonatomic) bool allowsSwappableMemory; |
︙ | ︙ | |||
100 101 102 103 104 105 106 | + (instancetype)dataWithItemsNoCopy: (void *)items count: (size_t)count itemSize: (size_t)itemSize freeWhenDone: (bool)freeWhenDone OF_UNAVAILABLE; #ifdef OF_HAVE_FILES + (instancetype)dataWithContentsOfFile: (OFString *)path OF_UNAVAILABLE; #endif | | | 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | + (instancetype)dataWithItemsNoCopy: (void *)items count: (size_t)count itemSize: (size_t)itemSize freeWhenDone: (bool)freeWhenDone OF_UNAVAILABLE; #ifdef OF_HAVE_FILES + (instancetype)dataWithContentsOfFile: (OFString *)path OF_UNAVAILABLE; #endif + (instancetype)dataWithContentsOfIRI: (OFIRI *)IRI OF_UNAVAILABLE; + (instancetype)dataWithStringRepresentation: (OFString *)string OF_UNAVAILABLE; + (instancetype)dataWithBase64EncodedString: (OFString *)string OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFSecureData with `count` items of * item size 1, all set to zero. * |
︙ | ︙ | |||
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | * @return An initialized OFSecureData */ - (instancetype)initWithCount: (size_t)count itemSize: (size_t)itemSize allowsSwappableMemory: (bool)allowsSwappableMemory OF_DESIGNATED_INITIALIZER; - (instancetype)initWithItems: (const void *)items count: (size_t)count OF_UNAVAILABLE; - (instancetype)initWithItems: (const void *)items count: (size_t)count itemSize: (size_t)itemSize OF_UNAVAILABLE; - (instancetype)initWithItemsNoCopy: (void *)items count: (size_t)count freeWhenDone: (bool)freeWhenDone OF_UNAVAILABLE; - (instancetype)initWithItemsNoCopy: (void *)items count: (size_t)count itemSize: (size_t)itemSize freeWhenDone: (bool)freeWhenDone OF_UNAVAILABLE; #ifdef OF_HAVE_FILES - (instancetype)initWithContentsOfFile: (OFString *)path OF_UNAVAILABLE; #endif | > > | < | 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | * @return An initialized OFSecureData */ - (instancetype)initWithCount: (size_t)count itemSize: (size_t)itemSize allowsSwappableMemory: (bool)allowsSwappableMemory OF_DESIGNATED_INITIALIZER; - (instancetype)init OF_UNAVAILABLE; - (instancetype)initWithItemSize: (size_t)itemSize OF_UNAVAILABLE; - (instancetype)initWithItems: (const void *)items count: (size_t)count OF_UNAVAILABLE; - (instancetype)initWithItems: (const void *)items count: (size_t)count itemSize: (size_t)itemSize OF_UNAVAILABLE; - (instancetype)initWithItemsNoCopy: (void *)items count: (size_t)count freeWhenDone: (bool)freeWhenDone OF_UNAVAILABLE; - (instancetype)initWithItemsNoCopy: (void *)items count: (size_t)count itemSize: (size_t)itemSize freeWhenDone: (bool)freeWhenDone OF_UNAVAILABLE; #ifdef OF_HAVE_FILES - (instancetype)initWithContentsOfFile: (OFString *)path OF_UNAVAILABLE; #endif - (instancetype)initWithContentsOfIRI: (OFIRI *)IRI OF_UNAVAILABLE; - (instancetype)initWithStringRepresentation: (OFString *)string OF_UNAVAILABLE; - (instancetype)initWithBase64EncodedString: (OFString *)string OF_UNAVAILABLE; /** * @brief Returns a specific item of the OFSecureData. * * Modifying the returned item directly is allowed and will change the contents * of the data array. * |
︙ | ︙ | |||
183 184 185 186 187 188 189 | - (void)zero; - (OFString *)stringRepresentation OF_UNAVAILABLE; - (OFString *)stringByBase64Encoding OF_UNAVAILABLE; #ifdef OF_HAVE_FILES - (void)writeToFile: (OFString *)path OF_UNAVAILABLE; #endif | | < | 190 191 192 193 194 195 196 197 198 199 200 201 | - (void)zero; - (OFString *)stringRepresentation OF_UNAVAILABLE; - (OFString *)stringByBase64Encoding OF_UNAVAILABLE; #ifdef OF_HAVE_FILES - (void)writeToFile: (OFString *)path OF_UNAVAILABLE; #endif - (void)writeToIRI: (OFIRI *)IRI OF_UNAVAILABLE; - (OFData *)messagePackRepresentation OF_UNAVAILABLE; @end OF_ASSUME_NONNULL_END |
Modified src/OFSecureData.m from [7420c1ca0e] to [5df33e3bf5].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #include <stdlib.h> |
︙ | ︙ | |||
336 337 338 339 340 341 342 | { return [[[self alloc] initWithCount: count itemSize: itemSize allowsSwappableMemory: allowsSwappableMemory] autorelease]; } | | < | 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 | { return [[[self alloc] initWithCount: count itemSize: itemSize allowsSwappableMemory: allowsSwappableMemory] autorelease]; } + (instancetype)dataWithItems: (const void *)items count: (size_t)count { OF_UNRECOGNIZED_SELECTOR } + (instancetype)dataWithItems: (const void *)items count: (size_t)count itemSize: (size_t)itemSize |
︙ | ︙ | |||
371 372 373 374 375 376 377 | #ifdef OF_HAVE_FILES + (instancetype)dataWithContentsOfFile: (OFString *)path { OF_UNRECOGNIZED_SELECTOR } #endif | | < | 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 | #ifdef OF_HAVE_FILES + (instancetype)dataWithContentsOfFile: (OFString *)path { OF_UNRECOGNIZED_SELECTOR } #endif + (instancetype)dataWithContentsOfIRI: (OFIRI *)IRI { OF_UNRECOGNIZED_SELECTOR } + (instancetype)dataWithStringRepresentation: (OFString *)string { OF_UNRECOGNIZED_SELECTOR } + (instancetype)dataWithBase64EncodedString: (OFString *)string { OF_UNRECOGNIZED_SELECTOR } - (instancetype)initWithCount: (size_t)count allowsSwappableMemory: (bool)allowsSwappableMemory { return [self initWithCount: count itemSize: 1 allowsSwappableMemory: allowsSwappableMemory]; |
︙ | ︙ | |||
460 461 462 463 464 465 466 467 468 469 470 471 472 473 | } @catch (id e) { [self release]; @throw e; } return self; } - (instancetype)initWithItems: (const void *)items count: (size_t)count { OF_INVALID_INIT_METHOD } - (instancetype)initWithItems: (const void *)items | > > > > > > > > > > | 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 | } @catch (id e) { [self release]; @throw e; } return self; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithItemSize: (size_t)itemSize { OF_INVALID_INIT_METHOD } - (instancetype)initWithItems: (const void *)items count: (size_t)count { OF_INVALID_INIT_METHOD } - (instancetype)initWithItems: (const void *)items |
︙ | ︙ | |||
495 496 497 498 499 500 501 | #ifdef OF_HAVE_FILES - (instancetype)initWithContentsOfFile: (OFString *)path { OF_INVALID_INIT_METHOD } #endif | | < < < < < | 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 | #ifdef OF_HAVE_FILES - (instancetype)initWithContentsOfFile: (OFString *)path { OF_INVALID_INIT_METHOD } #endif - (instancetype)initWithContentsOfIRI: (OFIRI *)IRI { OF_INVALID_INIT_METHOD } - (instancetype)initWithStringRepresentation: (OFString *)string { OF_INVALID_INIT_METHOD } - (instancetype)initWithBase64EncodedString: (OFString *)string { OF_INVALID_INIT_METHOD } - (void)dealloc { [self zero]; |
︙ | ︙ | |||
536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 | freeMemory(_page, _items, _count * _itemSize); removePageIfEmpty(_page); } } #endif [super dealloc]; } - (void *)mutableItems { return _items; } - (void *)mutableItemAtIndex: (size_t)idx | > > > > > > > > > > > > > > > > > > | 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 | freeMemory(_page, _items, _count * _itemSize); removePageIfEmpty(_page); } } #endif if (_freeWhenDone) OFFreeMemory(_items); [super dealloc]; } - (size_t)count { return _count; } - (size_t)itemSize { return _itemSize; } - (const void *)items { return _items; } - (void *)mutableItems { return _items; } - (void *)mutableItemAtIndex: (size_t)idx |
︙ | ︙ | |||
584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 | return copy; } - (bool)isEqual: (id)object { OFData *otherData; unsigned char diff; if (object == self) return true; if (![object isKindOfClass: [OFData class]]) return false; otherData = object; | > > | | | 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 | return copy; } - (bool)isEqual: (id)object { OFData *otherData; const unsigned char *otherDataItems; unsigned char diff; if (object == self) return true; if (![object isKindOfClass: [OFData class]]) return false; otherData = object; otherDataItems = otherData.items; if (otherData.count != _count || otherData.itemSize != _itemSize) return false; diff = 0; for (size_t i = 0; i < _count * _itemSize; i++) diff |= otherDataItems[i] ^ _items[i]; return (diff == 0); } - (OFString *)description { return @"<OFSecureData>"; |
︙ | ︙ | |||
627 628 629 630 631 632 633 | #ifdef OF_HAVE_FILES - (void)writeToFile: (OFString *)path { OF_UNRECOGNIZED_SELECTOR } #endif | | < < < < < | 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 | #ifdef OF_HAVE_FILES - (void)writeToFile: (OFString *)path { OF_UNRECOGNIZED_SELECTOR } #endif - (void)writeToIRI: (OFIRI *)IRI { OF_UNRECOGNIZED_SELECTOR } - (OFData *)messagePackRepresentation { OF_UNRECOGNIZED_SELECTOR } @end |
Modified src/OFSeekableStream.h from [b1e0890846] to [3fa3c64a98].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS #endif #ifndef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS |
︙ | ︙ | |||
33 34 35 36 37 38 39 | /** @file */ #if defined(OF_WINDOWS) typedef __int64 OFStreamOffset; #elif defined(OF_ANDROID) typedef long long OFStreamOffset; #elif defined(OF_MORPHOS) | | | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | /** @file */ #if defined(OF_WINDOWS) typedef __int64 OFStreamOffset; #elif defined(OF_ANDROID) typedef long long OFStreamOffset; #elif defined(OF_MORPHOS) typedef long long OFStreamOffset; #elif defined(OF_HAVE_OFF64_T) typedef off64_t OFStreamOffset; #else typedef off_t OFStreamOffset; #endif /** |
︙ | ︙ |
Modified src/OFSeekableStream.m from [b6c980d4ae] to [6663c9bf74].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #define OF_SEEKABLE_STREAM_M #include "config.h" #include <stdlib.h> |
︙ | ︙ |
Modified src/OFSelectKernelEventObserver.h from [87e3b347a2] to [8bddb9b8ba].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "objfw-defs.h" #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS #endif |
︙ | ︙ |
Modified src/OFSelectKernelEventObserver.m from [178271bdfe] to [93d2c09c3e].
1 | /* | | | | | | > > > > | < > | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include "platform.h" #ifdef OF_WINDOWS /* Win32 has a ridiculous default of 64, even though it supports much more. */ # define FD_SETSIZE 1024 #endif |
︙ | ︙ | |||
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | #import "OFSocket+Private.h" #import "OFInitializationFailedException.h" #import "OFObserveKernelEventsFailedException.h" #import "OFOutOfRangeException.h" #ifdef OF_AMIGAOS # include <proto/exec.h> #endif #ifdef OF_HPUX /* FD_SET causes warnings on HP-UX/IA64. */ # pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif | > > | 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | #import "OFSocket+Private.h" #import "OFInitializationFailedException.h" #import "OFObserveKernelEventsFailedException.h" #import "OFOutOfRangeException.h" #ifdef OF_AMIGAOS # define Class IntuitionClass # include <proto/exec.h> # undef Class #endif #ifdef OF_HPUX /* FD_SET causes warnings on HP-UX/IA64. */ # pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif |
︙ | ︙ |
Modified src/OFSequencedPacketSocket+Private.h from [779ca7e02d] to [091ab3f9e8].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFSequencedPacketSocket.h" OF_ASSUME_NONNULL_BEGIN @interface OFSequencedPacketSocket () |
︙ | ︙ |
Modified src/OFSequencedPacketSocket.h from [0f03522481] to [4c02dd2b99].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFKernelEventObserver.h" #import "OFRunLoop.h" #import "OFSocket.h" |
︙ | ︙ | |||
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | * than one thread at the same time is not thread-safe, even if copy * was called to create one "instance" for every thread! */ @interface OFSequencedPacketSocket: OFObject <OFCopying, OFReadyForReadingObserving, OFReadyForWritingObserving> { OFSocketHandle _socket; bool _canBlock, _listening; OFSocketAddress _remoteAddress; id _Nullable _delegate; OF_RESERVE_IVARS(OFSequencedPacketSocket, 4) } /** * @brief Whether the socket can block. * * By default, a socket can block. * * @throw OFSetOptionFailedException The option could not be set */ @property (nonatomic) bool canBlock; /** * @brief Whether the socket is a listening socket. */ | > > > > > | 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | * than one thread at the same time is not thread-safe, even if copy * was called to create one "instance" for every thread! */ @interface OFSequencedPacketSocket: OFObject <OFCopying, OFReadyForReadingObserving, OFReadyForWritingObserving> { OFSocketHandle _socket; #ifdef OF_AMIGAOS LONG _socketID; /* unused, reserved for ABI stability */ int _family; /* unused, reserved for ABI stability */ #endif bool _canBlock, _listening; OFSocketAddress _remoteAddress; id _Nullable _delegate; OF_RESERVE_IVARS(OFSequencedPacketSocket, 4) } /** * @brief Whether the socket can block. * * By default, a socket can block. * * @throw OFGetOptionFailedException The option could not be retrieved * @throw OFSetOptionFailedException The option could not be set */ @property (nonatomic) bool canBlock; /** * @brief Whether the socket is a listening socket. */ |
︙ | ︙ | |||
200 201 202 203 204 205 206 | * @brief Asynchronously receives a packet and stores it into the specified * buffer. * * If the buffer is too small, the receive operation fails. * * @param buffer The buffer to write the packet to * @param length The length of the buffer | | > | 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | * @brief Asynchronously receives a packet and stores it into the specified * buffer. * * If the buffer is too small, the receive operation fails. * * @param buffer The buffer to write the packet to * @param length The length of the buffer * @param runLoopMode The run loop mode in which to perform the asynchronous * receive */ - (void)asyncReceiveIntoBuffer: (void *)buffer length: (size_t)length runLoopMode: (OFRunLoopMode)runLoopMode; #ifdef OF_HAVE_BLOCKS /** |
︙ | ︙ | |||
233 234 235 236 237 238 239 | * @brief Asynchronously receives a packet and stores it into the specified * buffer. * * If the buffer is too small, the receive operation fails. * * @param buffer The buffer to write the packet to * @param length The length of the buffer | | > | 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | * @brief Asynchronously receives a packet and stores it into the specified * buffer. * * If the buffer is too small, the receive operation fails. * * @param buffer The buffer to write the packet to * @param length The length of the buffer * @param runLoopMode The run loop mode in which to perform the asynchronous * receive * @param block The block to call when the packet has been received. If the * block returns true, it will be called again with the same * buffer and maximum length when more packets have been received. * If you want the next method in the queue to handle the packet * received next, you need to return false from the method. */ - (void)asyncReceiveIntoBuffer: (void *)buffer |
︙ | ︙ | |||
267 268 269 270 271 272 273 | */ - (void)asyncSendData: (OFData *)data; /** * @brief Asynchronously sends the specified packet. * * @param data The data to send as a packet | | > | > | 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 | */ - (void)asyncSendData: (OFData *)data; /** * @brief Asynchronously sends the specified packet. * * @param data The data to send as a packet * @param runLoopMode The run loop mode in which to perform the asynchronous * send */ - (void)asyncSendData: (OFData *)data runLoopMode: (OFRunLoopMode)runLoopMode; #ifdef OF_HAVE_BLOCKS /** * @brief Asynchronously sends the specified packet. * * @param data The data to send as a packet * @param block The block to call when the packet has been sent. It should * return the data for the next send with the same callback or nil * if it should not repeat. */ - (void)asyncSendData: (OFData *)data block: (OFSequencedPacketSocketAsyncSendDataBlock)block; /** * @brief Asynchronously sends the specified packet. * * @param data The data to send as a packet * @param runLoopMode The run loop mode in which to perform the asynchronous * send * @param block The block to call when the packet has been sent. It should * return the data for the next send with the same callback or nil * if it should not repeat. */ - (void)asyncSendData: (OFData *)data runLoopMode: (OFRunLoopMode)runLoopMode block: (OFSequencedPacketSocketAsyncSendDataBlock)block; |
︙ | ︙ | |||
331 332 333 334 335 336 337 | * @brief Asynchronously accept an incoming connection. */ - (void)asyncAccept; /** * @brief Asynchronously accept an incoming connection. * | | > | > > > > > > > > > > > > > > > > > > > > > > > > > | 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 | * @brief Asynchronously accept an incoming connection. */ - (void)asyncAccept; /** * @brief Asynchronously accept an incoming connection. * * @param runLoopMode The run loop mode in which to perform the asynchronous * accept */ - (void)asyncAcceptWithRunLoopMode: (OFRunLoopMode)runLoopMode; #ifdef OF_HAVE_BLOCKS /** * @brief Asynchronously accept an incoming connection. * * @param block The block to execute when a new connection has been accepted. * Returns whether the next incoming connection should be accepted * by the specified block as well. */ - (void)asyncAcceptWithBlock: (OFSequencedPacketSocketAsyncAcceptBlock)block; /** * @brief Asynchronously accept an incoming connection. * * @param runLoopMode The run loop mode in which to perform the asynchronous * accept * @param block The block to execute when a new connection has been accepted. * Returns whether the next incoming connection should be accepted * by the specified block as well. */ - (void) asyncAcceptWithRunLoopMode: (OFRunLoopMode)runLoopMode block: (OFSequencedPacketSocketAsyncAcceptBlock)block; #endif /** * @brief Cancels all pending asynchronous requests on the socket. */ - (void)cancelAsyncRequests; /** * @brief Releases the socket from the current thread. * * This is necessary on some platforms in order to allow a different thread to * use the socket, e.g. on AmigaOS, but you should call it on all operating * systems before using the socket from a different thread. * * After calling this method, you must no longer use the socket until * @ref obtainSocketForCurrentThread has been called. */ - (void)releaseSocketFromCurrentThread; /** * @brief Obtains the socket for the current thread. * * This is necessary on some platforms in order to allow a different thread to * use the socket, e.g. on AmigaOS, but you should call it on all operating * systems before using the socket from a different thread. * * You must only call this method after @ref releaseSocketFromCurrentThread has * been called from a different thread. */ - (void)obtainSocketForCurrentThread; /** * @brief Closes the socket so that it can neither receive nor send any more * datagrams. * * @throw OFNotOpenException The socket is not open */ - (void)close; @end OF_ASSUME_NONNULL_END |
Modified src/OFSequencedPacketSocket.m from [0b38781929] to [ccecd9e1f0].
1 | /* | | | | | | > > > > | < > | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #ifndef _XOPEN_SOURCE_EXTENDED # define _XOPEN_SOURCE_EXTENDED #endif #define _HPUX_ALT_XOPEN_SOCKET_API #include <errno.h> #ifdef HAVE_FCNTL_H # include <fcntl.h> #endif #import "OFSequencedPacketSocket.h" |
︙ | ︙ | |||
358 359 360 361 362 363 364 | # if defined(HAVE_FCNTL) && defined(FD_CLOEXEC) if ((flags = fcntl(client->_socket, F_GETFD, 0)) != -1) fcntl(client->_socket, F_SETFD, flags | FD_CLOEXEC); # endif #endif | | | 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 | # if defined(HAVE_FCNTL) && defined(FD_CLOEXEC) if ((flags = fcntl(client->_socket, F_GETFD, 0)) != -1) fcntl(client->_socket, F_SETFD, flags | FD_CLOEXEC); # endif #endif OFAssert(client->_remoteAddress.length <= (socklen_t)sizeof(client->_remoteAddress.sockaddr)); switch (((struct sockaddr *)&client->_remoteAddress.sockaddr) ->sa_family) { case AF_INET: client->_remoteAddress.family = OFSocketAddressFamilyIPv4; break; |
︙ | ︙ | |||
463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 | if (_socket > INT_MAX) @throw [OFOutOfRangeException exception]; return (int)_socket; #endif } - (void)close { if (_socket == OFInvalidSocketHandle) @throw [OFNotOpenException exceptionWithObject: self]; _listening = false; memset(&_remoteAddress, 0, sizeof(_remoteAddress)); closesocket(_socket); _socket = OFInvalidSocketHandle; } @end | > > > > > > > > > > > > > > > > | 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 | if (_socket > INT_MAX) @throw [OFOutOfRangeException exception]; return (int)_socket; #endif } - (void)releaseSocketFromCurrentThread { /* * Currently a nop, as all supported OSes that have SOCK_SEQPACKET do * not need anything to move sockets between threads. */ } - (void)obtainSocketForCurrentThread { /* * Currently a nop, as all supported OSes that have SOCK_SEQPACKET do * not need anything to move sockets between threads. */ } - (void)close { if (_socket == OFInvalidSocketHandle) @throw [OFNotOpenException exceptionWithObject: self]; _listening = false; memset(&_remoteAddress, 0, sizeof(_remoteAddress)); closesocket(_socket); _socket = OFInvalidSocketHandle; } @end |
Deleted src/OFSerialization.h version [6c8c4c9563].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/OFSerialization.m version [0e1e99b940].
|
| < < < < < < < < < < < < < < < < < < < < |
Modified src/OFSet.h from [4c0dd3a76f] to [2fb0412f03].
1 | /* | | | | | | > > > > | < > | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS #endif #ifndef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS #endif #include <stdarg.h> #import "OFObject.h" #import "OFCollection.h" OF_ASSUME_NONNULL_BEGIN /** @file */ @class OFArray OF_GENERIC(ObjectType); |
︙ | ︙ | |||
59 60 61 62 63 64 65 | * @warning Do not mutate objects that are in a set! Changing the hash of * objects in a set breaks the internal representation of the set! * * @note Subclasses must implement @ref count, @ref containsObject: and * @ref objectEnumerator. */ @interface OFSet OF_GENERIC(ObjectType): OFObject <OFCollection, OFCopying, | | | 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | * @warning Do not mutate objects that are in a set! Changing the hash of * objects in a set breaks the internal representation of the set! * * @note Subclasses must implement @ref count, @ref containsObject: and * @ref objectEnumerator. */ @interface OFSet OF_GENERIC(ObjectType): OFObject <OFCollection, OFCopying, OFMutableCopying> #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) # define ObjectType id #endif /** * @brief An array of all objects in the set. */ @property (readonly, nonatomic) OFArray OF_GENERIC(ObjectType) *allObjects; |
︙ | ︙ | |||
114 115 116 117 118 119 120 121 122 123 124 125 126 127 | * @param objects An array of objects for the set * @param count The number of objects in the specified array * @return A new, autoreleased set with the specified objects */ + (instancetype)setWithObjects: (ObjectType const _Nonnull *_Nonnull)objects count: (size_t)count; /** * @brief Initializes an already allocated set with the specified set. * * @param set The set to initialize the set with * @return An initialized set with the specified set */ - (instancetype)initWithSet: (OFSet OF_GENERIC(ObjectType) *)set; | > > > > > > > | 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | * @param objects An array of objects for the set * @param count The number of objects in the specified array * @return A new, autoreleased set with the specified objects */ + (instancetype)setWithObjects: (ObjectType const _Nonnull *_Nonnull)objects count: (size_t)count; /** * @brief Initializes an already allocated set to be empty. * * @return An initialized set */ - (instancetype)init OF_DESIGNATED_INITIALIZER; /** * @brief Initializes an already allocated set with the specified set. * * @param set The set to initialize the set with * @return An initialized set with the specified set */ - (instancetype)initWithSet: (OFSet OF_GENERIC(ObjectType) *)set; |
︙ | ︙ | |||
157 158 159 160 161 162 163 | * @brief Initializes an already allocated set with the specified objects. * * @param objects An array of objects for the set * @param count The number of objects in the specified array * @return An initialized set with the specified objects */ - (instancetype)initWithObjects: (ObjectType const _Nonnull *_Nonnull)objects | | | 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | * @brief Initializes an already allocated set with the specified objects. * * @param objects An array of objects for the set * @param count The number of objects in the specified array * @return An initialized set with the specified objects */ - (instancetype)initWithObjects: (ObjectType const _Nonnull *_Nonnull)objects count: (size_t)count OF_DESIGNATED_INITIALIZER; /** * @brief Returns an OFEnumerator to enumerate through all objects of the set. * * @return An OFEnumerator to enumerate through all objects of the set */ - (OFEnumerator OF_GENERIC(ObjectType) *)objectEnumerator; |
︙ | ︙ |
Modified src/OFSet.m from [c2dcb9f429] to [73f0a1068f].
1 | /* | | | | | | > > > > | < > | | | | | | | > > > > > > | | | | | | | < < < < | < < < < | < | < < | < < < < < < < < | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdlib.h> #import "OFSet.h" #import "OFArray.h" #import "OFConcreteSet.h" #import "OFCountedSet.h" #import "OFNull.h" #import "OFString.h" static struct { Class isa; } placeholder; @interface OFPlaceholderSet: OFSet @end @implementation OFPlaceholderSet #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)init { return (id)[[OFConcreteSet alloc] init]; } - (instancetype)initWithSet: (OFSet *)set { return (id)[[OFConcreteSet alloc] initWithSet: set]; } - (instancetype)initWithArray: (OFArray *)array { return (id)[[OFConcreteSet alloc] initWithArray: array]; } - (instancetype)initWithObjects: (id)firstObject, ... { id ret; va_list arguments; va_start(arguments, firstObject); ret = [[OFConcreteSet alloc] initWithObject: firstObject arguments: arguments]; va_end(arguments); return ret; } - (instancetype)initWithObjects: (id const *)objects count: (size_t)count { return (id)[[OFConcreteSet alloc] initWithObjects: objects count: count]; } - (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments { return (id)[[OFConcreteSet alloc] initWithObject: firstObject arguments: arguments]; } #ifdef __clang__ # pragma clang diagnostic pop #endif OF_SINGLETON_METHODS @end @implementation OFSet + (void)initialize { if (self == [OFSet class]) object_setClass((id)&placeholder, [OFPlaceholderSet class]); } + (instancetype)alloc { if (self == [OFSet class]) return (id)&placeholder; |
︙ | ︙ | |||
144 145 146 147 148 149 150 | { return [[[self alloc] initWithObjects: objects count: count] autorelease]; } - (instancetype)init { | | > > > > | > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > | > > > > > > > > > > > > > > > > > > > | > > | > > > > > > > > > | > > | > > > > | > > > > > > | 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | { return [[[self alloc] initWithObjects: objects count: count] autorelease]; } - (instancetype)init { if ([self isMemberOfClass: [OFSet class]] || [self isMemberOfClass: [OFMutableSet class]] || [self isMemberOfClass: [OFCountedSet class]]) { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @throw e; } abort(); } return [super init]; } - (instancetype)initWithSet: (OFSet *)set { id *objects = NULL; size_t count; @try { void *pool = objc_autoreleasePoolPush(); size_t i = 0; count = set.count; objects = OFAllocMemory(count, sizeof(id)); for (id object in set) { OFEnsure(i < count); objects[i++] = object; } objc_autoreleasePoolPop(pool); } @catch (id e) { OFFreeMemory(objects); [self release]; @throw e; } @try { self = [self initWithObjects: objects count: count]; } @finally { OFFreeMemory(objects); } return self; } - (instancetype)initWithArray: (OFArray *)array { void *pool = objc_autoreleasePoolPush(); size_t count; const id *objects; @try { count = array.count; objects = array.objects; } @catch (id e) { [self release]; @throw e; } self = [self initWithObjects: objects count: count]; objc_autoreleasePoolPop(pool); return self; } #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)initWithObjects: (id const *)objects count: (size_t)count { OF_INVALID_INIT_METHOD } #ifdef __clang__ # pragma clang diagnostic pop #endif - (instancetype)initWithObjects: (id)firstObject, ... { id ret; va_list arguments; va_start(arguments, firstObject); ret = [self initWithObject: firstObject arguments: arguments]; va_end(arguments); return ret; } - (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments { size_t count = 1; va_list argumentsCopy; id *objects; if (firstObject == nil) return [self init]; va_copy(argumentsCopy, arguments); while (va_arg(argumentsCopy, id) != nil) count++; @try { objects = OFAllocMemory(count, sizeof(id)); } @catch (id e) { [self release]; @throw e; } @try { objects[0] = firstObject; for (size_t i = 1; i < count; i++) { objects[i] = va_arg(arguments, id); OFEnsure(objects[i] != nil); } self = [self initWithObjects: objects count: count]; } @finally { OFFreeMemory(objects); } return self; } - (size_t)count { OF_UNRECOGNIZED_SELECTOR } |
︙ | ︙ | |||
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | OF_UNRECOGNIZED_SELECTOR } - (int)countByEnumeratingWithState: (OFFastEnumerationState *)state objects: (id *)objects count: (int)count { OFEnumerator *enumerator; int i; memcpy(&enumerator, state->extra, sizeof(enumerator)); if (enumerator == nil) { enumerator = [self objectEnumerator]; memcpy(state->extra, &enumerator, sizeof(enumerator)); } state->itemsPtr = objects; | > | | 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | OF_UNRECOGNIZED_SELECTOR } - (int)countByEnumeratingWithState: (OFFastEnumerationState *)state objects: (id *)objects count: (int)count { static unsigned long dummyMutations; OFEnumerator *enumerator; int i; memcpy(&enumerator, state->extra, sizeof(enumerator)); if (enumerator == nil) { enumerator = [self objectEnumerator]; memcpy(state->extra, &enumerator, sizeof(enumerator)); } state->itemsPtr = objects; state->mutationsPtr = &dummyMutations; for (i = 0; i < count; i++) { id object = [enumerator nextObject]; if (object == nil) return i; |
︙ | ︙ | |||
358 359 360 361 362 363 364 | for (id object in self) if ([set containsObject: object]) return true; return false; } | < < < < < < < < < < < < < < < < < < < < < < < < < | 432 433 434 435 436 437 438 439 440 441 442 443 444 445 | for (id object in self) if ([set containsObject: object]) return true; return false; } - (OFSet *)setByAddingObjectsFromSet: (OFSet *)set { OFMutableSet *new = [[self mutableCopy] autorelease]; [new unionSet: set]; [new makeImmutable]; return new; } |
︙ | ︙ |
Modified src/OFSettings.h from [372d44cad4] to [5abda221fb].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" OF_ASSUME_NONNULL_BEGIN @class OFString; @class OFArray OF_GENERIC(ObjectType); /** * @class OFSettings OFSettings.h ObjFW/OFSettings.h * * Paths are delimited by dots, for example `category.subcategory.key`. * * @note The behavior when accessing a path with a different type than it has * been accessed with before is undefined! If you want to change the type * for a path, remove it and then set it with the new type. * * @brief A class for storing and retrieving settings */ @interface OFSettings: OFObject { |
︙ | ︙ |
Modified src/OFSettings.m from [206814d076] to [ce7c592c1b].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFSettings.h" #import "OFINIFileSettings.h" #import "OFString.h" |
︙ | ︙ |
Deleted src/OFSizeValue.h version [d063d8cdb8].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/OFSizeValue.m version [86214acf8b].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Modified src/OFSocket+Private.h from [00458f91c6] to [85d93768ea].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include "unistd_wrapper.h" #ifdef HAVE_ARPA_INET_H # include <arpa/inet.h> #endif #ifdef HAVE_NETDB_H # include <netdb.h> #endif #import "OFSocket.h" #ifndef INADDR_NONE # define INADDR_NONE ((in_addr_t)-1) #endif #ifndef SOMAXCONN /* |
︙ | ︙ |
Modified src/OFSocket.h from [20d2252a0a] to [1c856b0040].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "objfw-defs.h" #ifndef OF_HAVE_SOCKETS # error No sockets available! #endif |
︙ | ︙ | |||
60 61 62 63 64 65 66 | # include <wsipx.h> # endif # ifdef OF_HAVE_APPLETALK # include <atalkwsh.h> # endif #endif | < < > > | 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | # include <wsipx.h> # endif # ifdef OF_HAVE_APPLETALK # include <atalkwsh.h> # endif #endif #ifdef OF_WII # include <network.h> #endif #ifdef OF_PSP # include <stdint.h> #endif #import "macros.h" OF_ASSUME_NONNULL_BEGIN /** @file */ #ifndef OF_WINDOWS typedef int OFSocketHandle; static const OFSocketHandle OFInvalidSocketHandle = -1; #else typedef SOCKET OFSocketHandle; static const OFSocketHandle OFInvalidSocketHandle = INVALID_SOCKET; |
︙ | ︙ | |||
135 136 137 138 139 140 141 | #if !defined(OF_HAVE_UNIX_SOCKETS) && !defined(OF_MORPHOS) && !defined(OF_MINT) struct sockaddr_un { sa_family_t sun_family; char sun_path[108]; }; #endif | | > > < | > > > < | | < | | | | | | > | > > > > > > > | 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | #if !defined(OF_HAVE_UNIX_SOCKETS) && !defined(OF_MORPHOS) && !defined(OF_MINT) struct sockaddr_un { sa_family_t sun_family; char sun_path[108]; }; #endif #ifndef IPX_NODE_LEN # define IPX_NODE_LEN 6 #endif #if !defined(OF_HAVE_IPX) struct sockaddr_ipx { sa_family_t sipx_family; uint32_t sipx_network; unsigned char sipx_node[IPX_NODE_LEN]; uint16_t sipx_port; uint8_t sipx_type; }; #elif defined(OF_WINDOWS) # define IPX_NODE_LEN 6 # define sipx_family sa_family # define sipx_network sa_netnum # define sipx_node sa_nodenum # define sipx_port sa_socket #elif defined(OF_FREEBSD) # define sipx_network sipx_addr.x_net.c_net # define sipx_node sipx_addr.x_host.c_host #endif #ifndef OF_HAVE_APPLETALK struct sockaddr_at { sa_family_t sat_family; uint8_t sat_port; uint16_t sat_net; uint8_t sat_node; }; #else # ifdef OF_WINDOWS # define sat_port sat_socket # else # define sat_net sat_addr.s_net # define sat_node sat_addr.s_node # endif #endif /** * @struct OFSocketAddress OFSocket.h ObjFW/OFSocket.h * * @brief A struct which represents a host / port pair for a socket. */ typedef struct OF_BOXABLE OFSocketAddress { OFSocketAddressFamily family; /* * We can't use struct sockaddr as it can contain variable length * arrays. */ union { struct sockaddr_in in; struct sockaddr_in6 in6; struct sockaddr_un un; struct sockaddr_ipx ipx; struct sockaddr_at at; #ifdef OF_HAVE_SOCKADDR_STORAGE /* * Required to make the ABI stable in case we want to add more * address types later. */ struct sockaddr_storage storage; #endif } sockaddr; socklen_t length; } OFSocketAddress; #ifdef __cplusplus extern "C" { #endif |
︙ | ︙ | |||
279 280 281 282 283 284 285 | extern unsigned long OFSocketAddressHash( const OFSocketAddress *_Nonnull address); /** * @brief Converts the specified @ref OFSocketAddress to a string. * * @param address The address to convert to a string | | > > > > > > > > > > > | 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | extern unsigned long OFSocketAddressHash( const OFSocketAddress *_Nonnull address); /** * @brief Converts the specified @ref OFSocketAddress to a string. * * @param address The address to convert to a string * @return The address as a string, without the port */ extern OFString *_Nonnull OFSocketAddressString( const OFSocketAddress *_Nonnull address); /** * @brief Returns a description for the specified @ref OFSocketAddress. * * This is similar to @ref OFSocketAddressString, but it also contains the port. * * @param address The address to return a description for * @return The address as an string, with the port */ extern OFString *_Nonnull OFSocketAddressDescription( const OFSocketAddress *_Nonnull address); /** * @brief Sets the IP port of the specified @ref OFSocketAddress. * * @param address The address on which to set the port * @param port The port to set on the address */ extern void OFSocketAddressSetIPPort(OFSocketAddress *_Nonnull address, |
︙ | ︙ | |||
307 308 309 310 311 312 313 | /** * @brief Gets the UNIX socket path of the specified @ref OFSocketAddress. * * @param address The address on which to get the UNIX socket path * @return The UNIX socket path */ | | | 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 | /** * @brief Gets the UNIX socket path of the specified @ref OFSocketAddress. * * @param address The address on which to get the UNIX socket path * @return The UNIX socket path */ extern OFString *OFSocketAddressUNIXPath( const OFSocketAddress *_Nonnull address); /** * @brief Sets the IPX network of the specified @ref OFSocketAddress. * * @param address The address on which to set the IPX network * @param network The IPX network to set on the address |
︙ | ︙ |
Modified src/OFSocket.m from [3facc57fe7] to [b9e69c4209].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #ifndef _XOPEN_SOURCE_EXTENDED # define _XOPEN_SOURCE_EXTENDED #endif |
︙ | ︙ | |||
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | #import "OFUnlockFailedException.h" #ifdef HAVE_NET_IF_H # include <net/if.h> #endif #ifdef OF_AMIGAOS # include <proto/exec.h> #endif #ifdef OF_NINTENDO_3DS # include <3ds/types.h> # include <3ds/services/soc.h> #endif | > > | 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | #import "OFUnlockFailedException.h" #ifdef HAVE_NET_IF_H # include <net/if.h> #endif #ifdef OF_AMIGAOS # define Class IntuitionClass # include <proto/exec.h> # undef Class #endif #ifdef OF_NINTENDO_3DS # include <3ds/types.h> # include <3ds/services/soc.h> #endif |
︙ | ︙ | |||
426 427 428 429 430 431 432 433 434 435 436 437 438 439 | number = [component unsignedLongLongValueWithBase: 16]; if (number > UINT16_MAX) @throw [OFInvalidFormatException exception]; return (uint16_t)number; } OFSocketAddress OFSocketAddressParseIPv6(OFString *IPv6, uint16_t port) { void *pool = objc_autoreleasePoolPush(); OFSocketAddress ret; struct sockaddr_in6 *addrIn6 = &ret.sockaddr.in6; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 | number = [component unsignedLongLongValueWithBase: 16]; if (number > UINT16_MAX) @throw [OFInvalidFormatException exception]; return (uint16_t)number; } static OFString * transformEmbeddedIPv4(OFString *IPv6) { size_t lastColon = [IPv6 rangeOfString: @":" options: OFStringSearchBackwards].location; OFString *IPv4; OFSocketAddress address; const struct sockaddr_in *addrIn; uint32_t addr; if (lastColon == OFNotFound) @throw [OFInvalidFormatException exception]; IPv4 = [IPv6 substringWithRange: OFMakeRange(lastColon + 1, IPv6.length - lastColon - 1)]; IPv6 = [IPv6 substringWithRange: OFMakeRange(0, lastColon + 1)]; address = OFSocketAddressParseIPv4(IPv4, 0); addrIn = &address.sockaddr.in; addr = OFFromBigEndian32(addrIn->sin_addr.s_addr); return [IPv6 stringByAppendingString: [OFString stringWithFormat: @"%x%02x:%x%02x", (addr & 0xFF000000) >> 24, (addr & 0x00FF0000) >> 16, (addr & 0x0000FF00) >> 8, addr & 0x000000FF]]; } OFSocketAddress OFSocketAddressParseIPv6(OFString *IPv6, uint16_t port) { void *pool = objc_autoreleasePoolPush(); OFSocketAddress ret; struct sockaddr_in6 *addrIn6 = &ret.sockaddr.in6; |
︙ | ︙ | |||
463 464 465 466 467 468 469 470 471 472 473 474 475 476 | cStringWithEncoding: [OFLocale encoding]]); #endif } if (addrIn6->sin6_scope_id == 0) @throw [OFInvalidArgumentException exception]; } doubleColon = [IPv6 rangeOfString: @"::"].location; if (doubleColon != OFNotFound) { OFString *left = [IPv6 substringToIndex: doubleColon]; OFString *right = [IPv6 substringFromIndex: doubleColon + 2]; OFArray OF_GENERIC(OFString *) *leftComponents; OFArray OF_GENERIC(OFString *) *rightComponents; | > > > | 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 | cStringWithEncoding: [OFLocale encoding]]); #endif } if (addrIn6->sin6_scope_id == 0) @throw [OFInvalidArgumentException exception]; } if ([IPv6 rangeOfString: @"."].location != OFNotFound) IPv6 = transformEmbeddedIPv4(IPv6); doubleColon = [IPv6 rangeOfString: @"::"].location; if (doubleColon != OFNotFound) { OFString *left = [IPv6 substringToIndex: doubleColon]; OFString *right = [IPv6 substringFromIndex: doubleColon + 2]; OFArray OF_GENERIC(OFString *) *leftComponents; OFArray OF_GENERIC(OFString *) *rightComponents; |
︙ | ︙ | |||
553 554 555 556 557 558 559 560 561 562 563 564 565 566 | @throw [OFOutOfRangeException exception]; memset(&ret, '\0', sizeof(ret)); ret.family = OFSocketAddressFamilyUNIX; ret.length = (socklen_t) (offsetof(struct sockaddr_un, sun_path) + length); #ifdef AF_UNIX ret.sockaddr.un.sun_family = AF_UNIX; #else ret.sockaddr.un.sun_family = AF_UNSPEC; #endif memcpy(ret.sockaddr.un.sun_path, [path cStringWithEncoding: encoding], length); | > > > | 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 | @throw [OFOutOfRangeException exception]; memset(&ret, '\0', sizeof(ret)); ret.family = OFSocketAddressFamilyUNIX; ret.length = (socklen_t) (offsetof(struct sockaddr_un, sun_path) + length); #ifdef HAVE_STRUCT_SOCKADDR_UN_SUN_LEN ret.sockaddr.un.sun_len = (uint8_t)length; #endif #ifdef AF_UNIX ret.sockaddr.un.sun_family = AF_UNIX; #else ret.sockaddr.un.sun_family = AF_UNSPEC; #endif memcpy(ret.sockaddr.un.sun_path, [path cStringWithEncoding: encoding], length); |
︙ | ︙ | |||
902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 | [string appendFormat: @"%%%u", addrIn6->sin6_scope_id]; } [string makeImmutable]; return string; } OFString * OFSocketAddressString(const OFSocketAddress *address) { switch (address->family) { case OFSocketAddressFamilyIPv4: return IPv4String(address); case OFSocketAddressFamilyIPv6: return IPv6String(address); default: @throw [OFInvalidArgumentException exception]; } } void OFSocketAddressSetIPPort(OFSocketAddress *address, uint16_t port) { switch (address->family) { | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 | [string appendFormat: @"%%%u", addrIn6->sin6_scope_id]; } [string makeImmutable]; return string; } static OFString * IPXString(const OFSocketAddress *address) { const struct sockaddr_ipx *addrIPX = &address->sockaddr.ipx; uint32_t network; uint64_t node; memcpy(&network, &addrIPX->sipx_network, sizeof(addrIPX->sipx_network)); node = ((uint64_t)addrIPX->sipx_node[0] << 40) | ((uint64_t)addrIPX->sipx_node[1] << 32) | ((uint64_t)addrIPX->sipx_node[2] << 24) | ((uint64_t)addrIPX->sipx_node[3] << 16) | ((uint64_t)addrIPX->sipx_node[4] << 8) | (uint64_t)addrIPX->sipx_node[5]; return [OFString stringWithFormat: @"%" PRIX32 ".%" PRIX64, OFFromBigEndian32(network), node]; } static OFString * appleTalkString(const OFSocketAddress *address) { const struct sockaddr_at *addrAT = &address->sockaddr.at; return [OFString stringWithFormat: @"%" PRIu8 ".%" PRIu8, OFFromBigEndian16(addrAT->sat_net), addrAT->sat_node]; } OFString * OFSocketAddressString(const OFSocketAddress *address) { switch (address->family) { case OFSocketAddressFamilyIPv4: return IPv4String(address); case OFSocketAddressFamilyIPv6: return IPv6String(address); case OFSocketAddressFamilyUNIX: return OFSocketAddressUNIXPath(address); case OFSocketAddressFamilyIPX: return IPXString(address); case OFSocketAddressFamilyAppleTalk: return appleTalkString(address); default: @throw [OFInvalidArgumentException exception]; } } OFString * OFSocketAddressDescription(const OFSocketAddress *address) { switch (address->family) { case OFSocketAddressFamilyIPv4: return [OFString stringWithFormat: @"%@:%" PRIu16, IPv4String(address), OFSocketAddressIPPort(address)]; case OFSocketAddressFamilyIPv6: return [OFString stringWithFormat: @"[%@]:%" PRIu16, IPv6String(address), OFSocketAddressIPPort(address)]; case OFSocketAddressFamilyIPX: return [OFString stringWithFormat: @"%@.%" PRIX16, IPXString(address), OFSocketAddressIPXPort(address)]; case OFSocketAddressFamilyAppleTalk: return [OFString stringWithFormat: @"%@." PRIu8, appleTalkString(address), OFSocketAddressAppleTalkPort(address)]; default: return OFSocketAddressString(address); } } void OFSocketAddressSetIPPort(OFSocketAddress *address, uint16_t port) { switch (address->family) { |
︙ | ︙ | |||
958 959 960 961 962 963 964 | length = address->length - offsetof(struct sockaddr_un, sun_path); for (socklen_t i = 0; i < length; i++) if (address->sockaddr.un.sun_path[i] == 0) length = i; | < < < | 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 | length = address->length - offsetof(struct sockaddr_un, sun_path); for (socklen_t i = 0; i < length; i++) if (address->sockaddr.un.sun_path[i] == 0) length = i; return [OFString stringWithCString: address->sockaddr.un.sun_path encoding: [OFLocale encoding] length: length]; } void OFSocketAddressSetIPXNetwork(OFSocketAddress *address, uint32_t network) |
︙ | ︙ |
Modified src/OFSortedList.h from [3a5eb28c9b] to [94c18eb14f].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFList.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/OFSortedList.m from [8d1674288f] to [3b668484e3].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFSortedList.h" @implementation OFSortedList |
︙ | ︙ |
Modified src/OFStdIOStream+Private.h from [9900a9e7b0] to [4b9b84e3bb].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFStdIOStream.h" OF_ASSUME_NONNULL_BEGIN OF_DIRECT_MEMBERS |
︙ | ︙ |
Modified src/OFStdIOStream.h from [2dc46172ae] to [b6911b0606].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFStream.h" #import "OFKernelEventObserver.h" #ifdef OF_AMIGAOS # include <dos/dos.h> |
︙ | ︙ |
Modified src/OFStdIOStream.m from [ef45e21ee6] to [2edbd17f16].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #include "unistd_wrapper.h" |
︙ | ︙ | |||
28 29 30 31 32 33 34 | #import "OFStdIOStream.h" #import "OFStdIOStream+Private.h" #import "OFColor.h" #import "OFDate.h" #import "OFApplication.h" #ifdef OF_WINDOWS | | > > > > > > | 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | #import "OFStdIOStream.h" #import "OFStdIOStream+Private.h" #import "OFColor.h" #import "OFDate.h" #import "OFApplication.h" #ifdef OF_WINDOWS # import "OFWin32ConsoleStdIOStream.h" #endif #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFNotOpenException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFWriteFailedException.h" #ifdef OF_IOS # undef HAVE_ISATTY #endif #ifdef OF_AMIGAOS # define Class IntuitionClass # include <proto/exec.h> # include <proto/dos.h> # undef Class # undef HAVE_ISATTY #endif #ifdef OF_MSDOS # include <conio.h> #endif #ifdef OF_WII_U # define BOOL WUT_BOOL # include <coreinit/debug.h> # undef BOOL #endif |
︙ | ︙ | |||
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | date = [OFDate date]; dateString = [date localDateStringWithFormat: @"%Y-%m-%d %H:%M:%S"]; #ifdef OF_HAVE_FILES me = [OFApplication programName].lastPathComponent; #else me = [OFApplication programName]; #endif msg = [[[OFString alloc] initWithFormat: format arguments: arguments] autorelease]; [OFStdErr writeFormat: @"[%@.%03d %@(%d)] %@\n", dateString, date.microsecond / 1000, me, getpid(), msg]; objc_autoreleasePoolPop(pool); } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > | | 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | date = [OFDate date]; dateString = [date localDateStringWithFormat: @"%Y-%m-%d %H:%M:%S"]; #ifdef OF_HAVE_FILES me = [OFApplication programName].lastPathComponent; #else me = [OFApplication programName]; #endif if (me == nil) me = @"?"; msg = [[[OFString alloc] initWithFormat: format arguments: arguments] autorelease]; [OFStdErr writeFormat: @"[%@.%03d %@(%d)] %@\n", dateString, date.microsecond / 1000, me, getpid(), msg]; objc_autoreleasePoolPop(pool); } #ifdef OF_MSDOS int colorToMSDOS(OFColor *color) { if ([color isEqual: [OFColor black]]) return BLACK; if ([color isEqual: [OFColor navy]]) return BLUE; if ([color isEqual: [OFColor green]]) return GREEN; if ([color isEqual: [OFColor teal]]) return CYAN; if ([color isEqual: [OFColor maroon]]) return RED; if ([color isEqual: [OFColor purple]]) return MAGENTA; if ([color isEqual: [OFColor olive]]) return BROWN; if ([color isEqual: [OFColor silver]]) return LIGHTGRAY; if ([color isEqual: [OFColor gray]]) return DARKGRAY; if ([color isEqual: [OFColor blue]]) return LIGHTBLUE; if ([color isEqual: [OFColor lime]]) return LIGHTGREEN; if ([color isEqual: [OFColor aqua]]) return LIGHTCYAN; if ([color isEqual: [OFColor red]]) return LIGHTRED; if ([color isEqual: [OFColor fuchsia]]) return LIGHTMAGENTA; if ([color isEqual: [OFColor yellow]]) return YELLOW; if ([color isEqual: [OFColor white]]) return WHITE; return -1; } #else static int colorToANSI(OFColor *color) { if ([color isEqual: [OFColor black]]) return 30; if ([color isEqual: [OFColor maroon]]) return 31; if ([color isEqual: [OFColor green]]) return 32; if ([color isEqual: [OFColor olive]]) return 33; if ([color isEqual: [OFColor navy]]) return 34; if ([color isEqual: [OFColor purple]]) return 35; if ([color isEqual: [OFColor teal]]) return 36; if ([color isEqual: [OFColor silver]]) return 37; if ([color isEqual: [OFColor gray]]) return 90; if ([color isEqual: [OFColor red]]) return 91; if ([color isEqual: [OFColor lime]]) return 92; if ([color isEqual: [OFColor yellow]]) return 93; |
︙ | ︙ | |||
331 332 333 334 335 336 337 338 339 340 341 342 343 344 | @throw [OFOutOfRangeException exception]; if ((bytesWritten = Write(_handle, (void *)buffer, length)) < 0) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length bytesWritten: 0 errNo: EIO]; return (size_t)bytesWritten; #elif defined(OF_WII_U) OSConsoleWrite(buffer, length); return length; #else | > > > > > > > > > > > > > > > > > > > > > > > > > > | 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 | @throw [OFOutOfRangeException exception]; if ((bytesWritten = Write(_handle, (void *)buffer, length)) < 0) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length bytesWritten: 0 errNo: EIO]; return (size_t)bytesWritten; #elif defined(OF_MSDOS) ssize_t bytesWritten; if (self.hasTerminal) { const char *buffer_ = buffer; for (size_t i = 0; i < length; i++) { if (buffer_[i] == '\n') putch('\r'); putch(buffer_[i]); } return length; } if (length > SSIZE_MAX) @throw [OFOutOfRangeException exception]; if ((bytesWritten = write(_fd, buffer, length)) < 0) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length bytesWritten: 0 errNo: errno]; return (size_t)bytesWritten; #elif defined(OF_WII_U) OSConsoleWrite(buffer, length); return length; #else |
︙ | ︙ | |||
423 424 425 426 427 428 429 | - (unsigned int)retainCount { return OFMaxRetainCount; } - (bool)hasTerminal { | > > > | > > > > > > | > > > > > > | < > > | > > > > < > > | > > > > < | > > > < | > > > < | > > > > > > > < | > > > < | > > > < | > > > | 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 | - (unsigned int)retainCount { return OFMaxRetainCount; } - (bool)hasTerminal { #if defined(OF_WII) || defined(OF_NINTENDO_DS) || defined(OF_NINTENDO_3DS) || \ defined(OF_NINTENDO_SWITCH) return true; #elif defined(HAVE_ISATTY) && !defined(OF_WII_U) return isatty(_fd); #else return false; #endif } - (int)columns { #if defined(OF_MSDOS) struct text_info ti; gettextinfo(&ti); return ti.screenwidth; #elif defined(HAVE_IOCTL) && defined(TIOCGWINSZ) && \ !defined(OF_AMIGAOS) && !defined(OF_WII_U) struct winsize ws; if (ioctl(_fd, TIOCGWINSZ, &ws) != 0) return -1; return ws.ws_col; #else return -1; #endif } - (int)rows { #if defined(OF_MSDOS) struct text_info ti; gettextinfo(&ti); return ti.screenwidth; #elif defined(HAVE_IOCTL) && defined(TIOCGWINSZ) && \ !defined(OF_AMIGAOS) && !defined(OF_WII_U) struct winsize ws; if (ioctl(_fd, TIOCGWINSZ, &ws) != 0) return -1; return ws.ws_row; #else return -1; #endif } - (void)setForegroundColor: (OFColor *)color { int code; if (!self.hasTerminal) return; #ifdef OF_MSDOS if ((code = colorToMSDOS(color)) == -1) return; textcolor(code); #else if ((code = colorToANSI(color)) == -1) return; [self writeFormat: @"\033[%um", code]; #endif } - (void)setBackgroundColor: (OFColor *)color { int code; if (!self.hasTerminal) return; #ifdef OF_MSDOS if ((code = colorToMSDOS(color)) == -1) return; textbackground(code); #else if ((code = colorToANSI(color)) == -1) return; [self writeFormat: @"\033[%um", code + 10]; #endif } - (void)reset { if (!self.hasTerminal) return; #ifdef OF_MSDOS normvideo(); #else [self writeString: @"\033[0m"]; #endif } - (void)clear { if (!self.hasTerminal) return; #ifdef OF_MSDOS clrscr(); #else [self writeString: @"\033[2J"]; #endif } - (void)eraseLine { if (!self.hasTerminal) return; #ifdef OF_MSDOS int column = wherex(); gotoxy(1, wherey()); clreol(); gotoxy(column, wherey()); #else [self writeString: @"\033[2K"]; #endif } - (void)setCursorColumn: (unsigned int)column { if (!self.hasTerminal) return; #ifdef OF_MSDOS gotoxy(column + 1, wherey()); #else [self writeFormat: @"\033[%uG", column + 1]; #endif } - (void)setCursorPosition: (OFPoint)position { if (position.x < 0 || position.y < 0) @throw [OFInvalidArgumentException exception]; if (!self.hasTerminal) return; #ifdef OF_MSDOS gotoxy(position.x + 1, position.y + 1); #else [self writeFormat: @"\033[%u;%uH", (unsigned)position.y + 1, (unsigned)position.x + 1]; #endif } - (void)setRelativeCursorPosition: (OFPoint)position { if (!self.hasTerminal) return; #ifdef OF_MSDOS gotoxy(wherex() + position.x, wherey() + position.y); #else if (position.x > 0) [self writeFormat: @"\033[%uC", (unsigned)position.x]; else if (position.x < 0) [self writeFormat: @"\033[%uD", (unsigned)-position.x]; if (position.y > 0) [self writeFormat: @"\033[%uB", (unsigned)position.y]; else if (position.y < 0) [self writeFormat: @"\033[%uA", (unsigned)-position.y]; #endif } @end |
Added src/OFStrFTime.h version [6360971f27].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS #endif #ifndef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS #endif #include <time.h> #import "macros.h" OF_ASSUME_NONNULL_BEGIN #ifdef __cplusplus extern "C" { #endif extern size_t OFStrFTime(char *buffer, size_t bufferLen, const char *format, struct tm *tm, short tz); #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END |
Added src/OFStrFTime.m version [c155cb6b03].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #include <time.h> #import "OFStrFTime.h" #import "macros.h" static const char weekDays[7][4] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; static const char monthNames[12][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; size_t OFStrFTime(char *buffer, size_t bufferLen, const char *format, struct tm *tm, short tz) { enum { stateSearchConversionSpecifier, stateInConversionSpecifier } state = stateSearchConversionSpecifier; size_t j, formatLen; if (bufferLen == 0) return 0; formatLen = strlen(format); j = 0; for (size_t i = 0; i < formatLen; i++) { switch (state) { case stateSearchConversionSpecifier: if (format[i] == '%') state = stateInConversionSpecifier; else { if (j >= bufferLen) return 0; buffer[j++] = format[i]; } break; case stateInConversionSpecifier:; const char *appendFormat; unsigned int value = 0; char append[5]; int appendLen; switch (format[i]) { case '%': appendFormat = "%%"; break; case 'a': if (tm->tm_wday > 6) return 0; appendFormat = weekDays[tm->tm_wday]; break; case 'b': if (tm->tm_mon > 11) return 0; appendFormat = monthNames[tm->tm_mon]; break; case 'd': appendFormat = "%02u"; value = tm->tm_mday; break; case 'e': appendFormat = "%2u"; value = tm->tm_mday; break; case 'H': appendFormat = "%02u"; value = tm->tm_hour; break; case 'M': appendFormat = "%02u"; value = tm->tm_min; break; case 'm': appendFormat = "%02u"; value = tm->tm_mon + 1; break; case 'n': appendFormat = "\n"; break; case 'S': appendFormat = "%02u"; value = tm->tm_sec; break; case 't': appendFormat = "\t"; break; case 'Y': appendFormat = "%4u"; value = tm->tm_year + 1900; break; case 'y': appendFormat = "%02u"; value = tm->tm_year; while (value > 100) value -= 100; break; case 'z': if (tz == 0) appendFormat = "Z"; else if (tz >= 0) { appendFormat = "+%04u"; value = tz; } else { appendFormat = "-%04u"; value = -tz; } value = (value / 60) * 100 + (value % 60); break; default: return 0; } appendLen = snprintf(append, sizeof(append), appendFormat, value); if (appendLen < 0 || (size_t)appendLen >= sizeof(append)) return 0; if (bufferLen - j < (size_t)appendLen) return 0; memcpy(buffer + j, append, appendLen); j += appendLen; state = stateSearchConversionSpecifier; } } if (j >= bufferLen) return 0; buffer[j] = 0; return j; } |
Modified src/OFStrPTime.h from [0432d594e4] to [8d156c2ae2].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS #endif #ifndef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS |
︙ | ︙ |
Modified src/OFStrPTime.m from [7afa230e7d] to [7d3b878a87].
1 | /* | | | | | | > > > > | < > | < | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "OFStrPTime.h" #import "macros.h" const char * OFStrPTime(const char *buffer, const char *format, struct tm *tm, short *tz) { enum { stateSearchConversionSpecifier, |
︙ | ︙ |
Modified src/OFStream+Private.h from [571ecdcdc3] to [eacc2661d1].
1 | /* | | | | | | > > > > | < > | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFStream.h" OF_ASSUME_NONNULL_BEGIN @interface OFStream () @property (readonly, nonatomic, getter=of_isWaitingForDelimiter) bool of_waitingForDelimiter; @end OF_ASSUME_NONNULL_END |
Modified src/OFStream.h from [a93512463b] to [bfdbdea6e5].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS #endif #ifndef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS |
︙ | ︙ | |||
214 215 216 217 218 219 220 221 222 223 224 225 226 227 | /** * @brief Whether the stream can block. * * By default, a stream can block. * On Win32, setting this currently only works for sockets! * * @throw OFSetOptionFailedException The option could not be set */ @property (nonatomic) bool canBlock; /** * @brief The delegate for asynchronous operations on the stream. * | > | 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | /** * @brief Whether the stream can block. * * By default, a stream can block. * On Win32, setting this currently only works for sockets! * * @throw OFGetOptionFailedException The option could not be retrieved * @throw OFSetOptionFailedException The option could not be set */ @property (nonatomic) bool canBlock; /** * @brief The delegate for asynchronous operations on the stream. * |
︙ | ︙ | |||
490 491 492 493 494 495 496 | /** * @brief Reads a uint16_t from the stream which is encoded in big endian. * * @warning Only call this when you know that enough data is available! * Otherwise you will get an exception! * | | | | | | | | | | | | 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 | /** * @brief Reads a uint16_t from the stream which is encoded in big endian. * * @warning Only call this when you know that enough data is available! * Otherwise you will get an exception! * * @return A uint16_t from the stream in big endian * @throw OFReadFailedException Reading failed * @throw OFTruncatedDataException The end of the stream was reached before * reading enough bytes * @throw OFNotOpenException The stream is not open */ - (uint16_t)readBigEndianInt16; /** * @brief Reads a uint32_t from the stream which is encoded in big endian. * * @warning Only call this when you know that enough data is available! * Otherwise you will get an exception! * * @return A uint32_t from the stream in big endian * @throw OFReadFailedException Reading failed * @throw OFTruncatedDataException The end of the stream was reached before * reading enough bytes * @throw OFNotOpenException The stream is not open */ - (uint32_t)readBigEndianInt32; /** * @brief Reads a uint64_t from the stream which is encoded in big endian. * * @warning Only call this when you know that enough data is available! * Otherwise you will get an exception! * * @return A uint64_t from the stream in big endian * @throw OFReadFailedException Reading failed * @throw OFTruncatedDataException The end of the stream was reached before * reading enough bytes * @throw OFNotOpenException The stream is not open */ - (uint64_t)readBigEndianInt64; /** * @brief Reads a float from the stream which is encoded in big endian. * * @warning Only call this when you know that enough data is available! * Otherwise you will get an exception! * * @return A float from the stream in big endian * @throw OFReadFailedException Reading failed * @throw OFTruncatedDataException The end of the stream was reached before * reading enough bytes * @throw OFNotOpenException The stream is not open */ - (float)readBigEndianFloat; /** * @brief Reads a double from the stream which is encoded in big endian. * * @warning Only call this when you know that enough data is available! * Otherwise you will get an exception! * * @return A double from the stream in big endian * @throw OFReadFailedException Reading failed * @throw OFTruncatedDataException The end of the stream was reached before * reading enough bytes * @throw OFNotOpenException The stream is not open */ - (double)readBigEndianDouble; /** * @brief Reads a uint16_t from the stream which is encoded in little endian. * * @warning Only call this when you know that enough data is available! * Otherwise you will get an exception! * * @return A uint16_t from the stream in little endian * @throw OFReadFailedException Reading failed * @throw OFTruncatedDataException The end of the stream was reached before * reading enough bytes * @throw OFNotOpenException The stream is not open */ - (uint16_t)readLittleEndianInt16; /** * @brief Reads a uint32_t from the stream which is encoded in little endian. * * @warning Only call this when you know that enough data is available! * Otherwise you will get an exception! * * @return A uint32_t from the stream in little endian * @throw OFReadFailedException Reading failed * @throw OFTruncatedDataException The end of the stream was reached before * reading enough bytes * @throw OFNotOpenException The stream is not open */ - (uint32_t)readLittleEndianInt32; /** * @brief Reads a uint64_t from the stream which is encoded in little endian. * * @warning Only call this when you know that enough data is available! * Otherwise you will get an exception! * * @return A uint64_t from the stream in little endian * @throw OFReadFailedException Reading failed * @throw OFTruncatedDataException The end of the stream was reached before * reading enough bytes * @throw OFNotOpenException The stream is not open */ - (uint64_t)readLittleEndianInt64; /** * @brief Reads a float from the stream which is encoded in little endian. * * @warning Only call this when you know that enough data is available! * Otherwise you will get an exception! * * @return A float from the stream in little endian * @throw OFReadFailedException Reading failed * @throw OFTruncatedDataException The end of the stream was reached before * reading enough bytes * @throw OFNotOpenException The stream is not open */ - (float)readLittleEndianFloat; /** * @brief Reads a double from the stream which is encoded in little endian. * * @warning Only call this when you know that enough data is available! * Otherwise you will get an exception! * * @return A double from the stream in little endian * @throw OFReadFailedException Reading failed * @throw OFTruncatedDataException The end of the stream was reached before * reading enough bytes * @throw OFNotOpenException The stream is not open */ - (double)readLittleEndianDouble; |
︙ | ︙ | |||
860 861 862 863 864 865 866 | - (nullable OFString *)tryReadLineWithEncoding: (OFStringEncoding)encoding; /** * @brief Reads until the specified string or `\0` is found or the end of * stream occurs. * * @param delimiter The delimiter | | | | | | 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 | - (nullable OFString *)tryReadLineWithEncoding: (OFStringEncoding)encoding; /** * @brief Reads until the specified string or `\0` is found or the end of * stream occurs. * * @param delimiter The delimiter * @return The string that was read, autoreleased, or `nil` if the end of the * stream has been reached. * @throw OFReadFailedException Reading failed * @throw OFInvalidEncodingException The string read from the stream has * invalid encoding * @throw OFNotOpenException The stream is not open */ - (nullable OFString *)readUntilDelimiter: (OFString *)delimiter; /** * @brief Reads until the specified string or `\0` is found or the end of * stream occurs. * * @param delimiter The delimiter * @param encoding The encoding used by the stream * @return The string that was read, autoreleased, or `nil` if the end of the * stream has been reached. * @throw OFReadFailedException Reading failed * @throw OFInvalidEncodingException The string read from the stream has * invalid encoding * @throw OFNotOpenException The stream is not open */ - (nullable OFString *)readUntilDelimiter: (OFString *)delimiter encoding: (OFStringEncoding)encoding; /** * @brief Tries to reads until the specified string or `\0` is found or the end * of stream (see @ref readUntilDelimiter:) and returns `nil` if not * enough data has been received yet. * * @param delimiter The delimiter * @return The string that was read, autoreleased, or `nil` if the end of the * stream has been reached. * @throw OFReadFailedException Reading failed * @throw OFInvalidEncodingException The string read from the stream has * invalid encoding * @throw OFNotOpenException The stream is not open */ - (nullable OFString *)tryReadUntilDelimiter: (OFString *)delimiter; /** * @brief Tries to read until the specified string or `\0` is found or the end * of stream occurs (see @ref readUntilDelimiter:encoding:) and returns * `nil` if not enough data has been received yet. * * @param delimiter The delimiter * @param encoding The encoding used by the stream * @return The string that was read, autoreleased, or `nil` if the end of the * stream has been reached. * @throw OFReadFailedException Reading failed * @throw OFInvalidEncodingException The string read from the stream has * invalid encoding * @throw OFNotOpenException The stream is not open */ - (nullable OFString *)tryReadUntilDelimiter: (OFString *)delimiter |
︙ | ︙ | |||
1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 | * * @note Override this method with your actual end of stream checking * implementation when subclassing! * * @return Whether the lowlevel is at the end of the stream */ - (bool)lowlevelIsAtEndOfStream; @end OF_ASSUME_NONNULL_END | > > > > > > > > > > > > > | 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 | * * @note Override this method with your actual end of stream checking * implementation when subclassing! * * @return Whether the lowlevel is at the end of the stream */ - (bool)lowlevelIsAtEndOfStream; /** * @brief Returns whether the lowlevel has data in the read buffer. * * @warning Do not call this directly! * * @note Override this method in case your stream can buffer data itself, such * as when implementing @ref OFTLSStream. If not overridden, it always * returns false. * * @return Whether the lowlevel has data in the read buffer */ - (bool)lowlevelHasDataInReadBuffer; @end OF_ASSUME_NONNULL_END |
Modified src/OFStream.m from [e660892e5a] to [4f4737a0de].
1 | /* | | | | | | > | < | < | > | > > < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #ifdef HAVE_FCNTL_H |
︙ | ︙ | |||
93 94 95 96 97 98 99 | { OFFreeMemory(_readBufferMemory); OFFreeMemory(_writeBuffer); [super dealloc]; } | < < < < < > > > > > > > > > > | 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | { OFFreeMemory(_readBufferMemory); OFFreeMemory(_writeBuffer); [super dealloc]; } - (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length { OF_UNRECOGNIZED_SELECTOR } - (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length { OF_UNRECOGNIZED_SELECTOR } - (bool)lowlevelIsAtEndOfStream { OF_UNRECOGNIZED_SELECTOR } - (bool)lowlevelHasDataInReadBuffer { return false; } - (id)copy { return [self retain]; } - (bool)isAtEndOfStream |
︙ | ︙ | |||
698 699 700 701 702 703 704 | if (j == delimiterLength || _readBuffer[i] == '\0') { if (_readBuffer[i] == '\0') delimiterLength = 1; ret = [OFString stringWithCString: _readBuffer encoding: encoding | | | 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 | if (j == delimiterLength || _readBuffer[i] == '\0') { if (_readBuffer[i] == '\0') delimiterLength = 1; ret = [OFString stringWithCString: _readBuffer encoding: encoding length: i + 1 - delimiterLength]; _readBuffer += i + 1; _readBufferLength -= i + 1; _waitingForDelimiter = false; return ret; } |
︙ | ︙ | |||
1183 1184 1185 1186 1187 1188 1189 | } @finally { free(UTF8String); } } - (bool)hasDataInReadBuffer { | | | 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 | } @finally { free(UTF8String); } } - (bool)hasDataInReadBuffer { return (_readBufferLength > 0 || [self lowlevelHasDataInReadBuffer]); } - (bool)canBlock { return _canBlock; } |
︙ | ︙ |
Modified src/OFStreamSocket+Private.h from [a23e5c50d7] to [024d1950a0].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFStreamSocket.h" OF_ASSUME_NONNULL_BEGIN @interface OFStreamSocket () |
︙ | ︙ |
Modified src/OFStreamSocket.h from [700ee89673] to [993a85dff6].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFStream.h" #import "OFSocket.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ | |||
62 63 64 65 66 67 68 69 70 71 72 73 74 75 | * * @brief A class which provides methods to create and use stream sockets. */ @interface OFStreamSocket: OFStream <OFReadyForReadingObserving, OFReadyForWritingObserving> { OFSocketHandle _socket; bool _atEndOfStream, _listening; OFSocketAddress _remoteAddress; OF_RESERVE_IVARS(OFStreamSocket, 4) } /** * @brief Whether the socket is a listening socket. | > > > > | 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | * * @brief A class which provides methods to create and use stream sockets. */ @interface OFStreamSocket: OFStream <OFReadyForReadingObserving, OFReadyForWritingObserving> { OFSocketHandle _socket; #ifdef OF_AMIGAOS LONG _socketID; int _family; /* unused, reserved for ABI stability */ #endif bool _atEndOfStream, _listening; OFSocketAddress _remoteAddress; OF_RESERVE_IVARS(OFStreamSocket, 4) } /** * @brief Whether the socket is a listening socket. |
︙ | ︙ | |||
157 158 159 160 161 162 163 164 165 166 | * @param block The block to execute when a new connection has been accepted. * Returns whether the next incoming connection should be accepted * by the specified block as well. */ - (void)asyncAcceptWithRunLoopMode: (OFRunLoopMode)runLoopMode block: (OFStreamSocketAsyncAcceptBlock)block; #endif @end OF_ASSUME_NONNULL_END | > > > > > > > > > > > > > > > > > > > > > > > > | 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | * @param block The block to execute when a new connection has been accepted. * Returns whether the next incoming connection should be accepted * by the specified block as well. */ - (void)asyncAcceptWithRunLoopMode: (OFRunLoopMode)runLoopMode block: (OFStreamSocketAsyncAcceptBlock)block; #endif /** * @brief Releases the socket from the current thread. * * This is necessary on some platforms in order to allow a different thread to * use the socket, e.g. on AmigaOS, but you should call it on all operating * systems before using the socket from a different thread. * * After calling this method, you must no longer use the socket until * @ref obtainSocketForCurrentThread has been called. */ - (void)releaseSocketFromCurrentThread; /** * @brief Obtains the socket for the current thread. * * This is necessary on some platforms in order to allow a different thread to * use the socket, e.g. on AmigaOS, but you should call it on all operating * systems before using the socket from a different thread. * * You must only call this method after @ref releaseSocketFromCurrentThread has * been called from a different thread. */ - (void)obtainSocketForCurrentThread; @end OF_ASSUME_NONNULL_END |
Modified src/OFStreamSocket.m from [efe4f02a49] to [a8d59e0323].
1 | /* | | | | | | > > > > | < > | < < > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #ifndef _XOPEN_SOURCE_EXTENDED # define _XOPEN_SOURCE_EXTENDED #endif #define _HPUX_ALT_XOPEN_SOCKET_API #include <errno.h> #include <string.h> #import "OFStreamSocket.h" #import "OFStreamSocket+Private.h" #import "OFRunLoop.h" #import "OFRunLoop+Private.h" #import "OFSocket+Private.h" #import "OFAcceptSocketFailedException.h" #import "OFAlreadyOpenException.h" #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFListenOnSocketFailedException.h" #import "OFNotImplementedException.h" #import "OFNotOpenException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFSetOptionFailedException.h" #import "OFWriteFailedException.h" #if defined(OF_AMIGAOS) && !defined(UNIQUE_ID) # define UNIQUE_ID -1 #endif @implementation OFStreamSocket @dynamic delegate; @synthesize listening = _listening; + (void)initialize { |
︙ | ︙ | |||
68 69 70 71 72 73 74 75 76 77 78 79 80 81 | @try { if (self.class == [OFStreamSocket class]) { [self doesNotRecognizeSelector: _cmd]; abort(); } _socket = OFInvalidSocketHandle; } @catch (id e) { [self release]; @throw e; } return self; } | > > > | 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | @try { if (self.class == [OFStreamSocket class]) { [self doesNotRecognizeSelector: _cmd]; abort(); } _socket = OFInvalidSocketHandle; #ifdef OF_AMIGAOS _socketID = -1; #endif } @catch (id e) { [self release]; @throw e; } return self; } |
︙ | ︙ | |||
239 240 241 242 243 244 245 | errNo: OFSocketErrNo()]; _listening = true; } - (instancetype)accept { | | > > > > | 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | errNo: OFSocketErrNo()]; _listening = true; } - (instancetype)accept { OFStreamSocket *client; #if (!defined(HAVE_PACCEPT) && !defined(HAVE_ACCEPT4)) || !defined(SOCK_CLOEXEC) # if defined(HAVE_FCNTL) && defined(FD_CLOEXEC) int flags; # endif #endif if (_socket == OFInvalidSocketHandle) @throw [OFNotOpenException exceptionWithObject: self]; client = [[[[self class] alloc] init] autorelease]; client->_remoteAddress.length = (socklen_t)sizeof(client->_remoteAddress.sockaddr); #if defined(HAVE_PACCEPT) && defined(SOCK_CLOEXEC) if ((client->_socket = paccept(_socket, (struct sockaddr *)&client->_remoteAddress.sockaddr, &client->_remoteAddress.length, NULL, SOCK_CLOEXEC)) == |
︙ | ︙ | |||
279 280 281 282 283 284 285 | # if defined(HAVE_FCNTL) && defined(FD_CLOEXEC) if ((flags = fcntl(client->_socket, F_GETFD, 0)) != -1) fcntl(client->_socket, F_SETFD, flags | FD_CLOEXEC); # endif #endif | | | 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | # if defined(HAVE_FCNTL) && defined(FD_CLOEXEC) if ((flags = fcntl(client->_socket, F_GETFD, 0)) != -1) fcntl(client->_socket, F_SETFD, flags | FD_CLOEXEC); # endif #endif OFAssert(client->_remoteAddress.length <= (socklen_t)sizeof(client->_remoteAddress.sockaddr)); switch (((struct sockaddr *)&client->_remoteAddress.sockaddr) ->sa_family) { case AF_INET: client->_remoteAddress.family = OFSocketAddressFamilyIPv4; break; |
︙ | ︙ | |||
352 353 354 355 356 357 358 359 360 361 362 363 364 365 | @throw [OFInvalidArgumentException exception]; if (_remoteAddress.length > (socklen_t)sizeof(_remoteAddress.sockaddr)) @throw [OFOutOfRangeException exception]; return &_remoteAddress; } - (void)close { if (_socket == OFInvalidSocketHandle) @throw [OFNotOpenException exceptionWithObject: self]; _listening = false; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 | @throw [OFInvalidArgumentException exception]; if (_remoteAddress.length > (socklen_t)sizeof(_remoteAddress.sockaddr)) @throw [OFOutOfRangeException exception]; return &_remoteAddress; } - (void)releaseSocketFromCurrentThread { #ifdef OF_AMIGAOS if (_socket == OFInvalidSocketHandle) @throw [OFNotOpenException exceptionWithObject: self]; if ((_socketID = ReleaseSocket(_socket, UNIQUE_ID)) == -1) { switch (Errno()) { case ENOMEM: @throw [OFOutOfMemoryException exceptionWithRequestedSize: 0]; case EBADF: @throw [OFNotOpenException exceptionWithObject: self]; default: OFEnsure(0); } } _socket = OFInvalidSocketHandle; #endif } - (void)obtainSocketForCurrentThread { #ifdef OF_AMIGAOS if (_socket != OFInvalidSocketHandle) @throw [OFAlreadyOpenException exceptionWithObject: self]; if (_socketID == -1) @throw [OFNotOpenException exceptionWithObject: self]; /* * FIXME: We should store these, but that requires changing all * subclasses. This only becomes a problem if IPv6 support ever * gets added. */ _socket = ObtainSocket(_socketID, AF_INET, SOCK_STREAM, 0); if (_socket == OFInvalidSocketHandle) @throw [OFInitializationFailedException exceptionWithClass: self.class]; _socketID = -1; #endif } - (void)close { if (_socket == OFInvalidSocketHandle) @throw [OFNotOpenException exceptionWithObject: self]; _listening = false; |
︙ | ︙ |
Modified src/OFString+CryptographicHashing.h from [63c51821ee] to [3d01f675bb].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFString.h" OF_ASSUME_NONNULL_BEGIN #ifdef __cplusplus |
︙ | ︙ |
Modified src/OFString+CryptographicHashing.m from [30b5bea6f8] to [7aa9e3ef54].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFString.h" #import "OFCryptographicHash.h" #import "OFMD5Hash.h" |
︙ | ︙ |
Modified src/OFString+JSONParsing.h from [77287ce8c5] to [eb9d46998c].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFString.h" OF_ASSUME_NONNULL_BEGIN #ifdef __cplusplus |
︙ | ︙ |
Modified src/OFString+JSONParsing.m from [5489126d7d] to [b1d14c6372].
1 | /* | | | | | | > > > > | < > | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdlib.h> #include <string.h> #include <math.h> #import "OFString+JSONParsing.h" #import "OFArray.h" #import "OFDictionary.h" #import "OFNumber.h" #import "OFNull.h" #import "OFInvalidJSONException.h" |
︙ | ︙ | |||
649 650 651 652 653 654 655 | { void *pool = objc_autoreleasePoolPush(); const char *pointer = self.UTF8String; const char *stop = pointer + self.UTF8StringLength; id object; size_t line = 1; | < < < < | 651 652 653 654 655 656 657 658 659 660 661 662 663 664 | { void *pool = objc_autoreleasePoolPush(); const char *pointer = self.UTF8String; const char *stop = pointer + self.UTF8StringLength; id object; size_t line = 1; object = nextObject(&pointer, stop, &line, depthLimit); skipWhitespacesAndComments(&pointer, stop, &line); if (pointer < stop || object == nil) @throw [OFInvalidJSONException exceptionWithString: self line: line]; |
︙ | ︙ |
Modified src/OFString+PathAdditions.h from [01351c2d45] to [da8b9e10be].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFString.h" OF_ASSUME_NONNULL_BEGIN #ifdef __cplusplus |
︙ | ︙ | |||
82 83 84 85 86 87 88 | * * @param extension The extension to append * @return A new, autoreleased OFString with the path extension appended */ - (OFString *)stringByAppendingPathExtension: (OFString *)extension; - (bool)of_isDirectoryPath; | | | | | 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | * * @param extension The extension to append * @return A new, autoreleased OFString with the path extension appended */ - (OFString *)stringByAppendingPathExtension: (OFString *)extension; - (bool)of_isDirectoryPath; - (OFString *)of_pathToIRIPathWithPercentEncodedHost: (OFString *__autoreleasing _Nullable *_Nonnull)percentEncodedHost; - (OFString *)of_IRIPathToPathWithPercentEncodedHost: (nullable OFString *)percentEncodedHost; - (OFString *)of_pathComponentToIRIPathComponent; @end OF_ASSUME_NONNULL_END |
Modified src/OFString+PathAdditions.m from [dfeb40c068] to [20d5832743].
1 | /* | | | | | | > > > > | < > | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include "platform.h" #if defined(OF_WINDOWS) || defined(OF_MSDOS) || defined(OF_MINT) # import "platform/Windows/OFString+PathAdditions.m" #elif defined(OF_AMIGAOS) # import "platform/AmigaOS/OFString+PathAdditions.m" #elif defined(OF_WII) || defined(OF_NINTENDO_DS) || \ defined(OF_NINTENDO_3DS) || defined(OF_NINTENDO_SWITCH) # import "platform/libfat/OFString+PathAdditions.m" #else # import "platform/POSIX/OFString+PathAdditions.m" #endif |
Modified src/OFString+PercentEncoding.h from [8762d6fc4c] to [31b4cb4844].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFString.h" OF_ASSUME_NONNULL_BEGIN @class OFCharacterSet; |
︙ | ︙ | |||
32 33 34 35 36 37 38 | * @brief The string with percent encoding removed. * * @throw OFInvalidFormatException The string is not in proper percent encoding */ @property (readonly, nonatomic) OFString *stringByRemovingPercentEncoding; /** | | | 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | * @brief The string with percent encoding removed. * * @throw OFInvalidFormatException The string is not in proper percent encoding */ @property (readonly, nonatomic) OFString *stringByRemovingPercentEncoding; /** * @brief Percent-encodes a string for use in an IRI, but does not escape the * specified allowed characters. * * @param allowedCharacters A character set of characters that should not be * escaped * * @return A new autoreleased string */ - (OFString *)stringByAddingPercentEncodingWithAllowedCharacters: (OFCharacterSet *)allowedCharacters; @end OF_ASSUME_NONNULL_END |
Modified src/OFString+PercentEncoding.m from [46a599b120] to [a22716408b].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdlib.h> #include <string.h> |
︙ | ︙ |
Modified src/OFString+PropertyListParsing.h from [6aa9059d9b] to [6464166de9].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFString.h" OF_ASSUME_NONNULL_BEGIN #ifdef __cplusplus |
︙ | ︙ |
Modified src/OFString+PropertyListParsing.m from [4a79f533f5] to [e82245ac9e].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFString+PropertyListParsing.h" #import "OFArray.h" #import "OFData.h" |
︙ | ︙ |
Deleted src/OFString+Serialization.h version [6689bf6870].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/OFString+Serialization.m version [a02a87cd97].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Modified src/OFString+XMLEscaping.h from [5e7ff84170] to [e61bc93090].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFString.h" OF_ASSUME_NONNULL_BEGIN #ifdef __cplusplus |
︙ | ︙ |
Modified src/OFString+XMLEscaping.m from [417a4985be] to [094cea903d].
1 | /* | | | | | | > > > > | < > | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdlib.h> #include <string.h> #import "OFString.h" #import "OFOutOfMemoryException.h" |
︙ | ︙ | |||
84 85 86 87 88 89 90 | retLength += appendLen - 1; memcpy(retCString + j, append, appendLen); j += appendLen; } else retCString[j++] = string[i]; } | | | 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | retLength += appendLen - 1; memcpy(retCString + j, append, appendLen); j += appendLen; } else retCString[j++] = string[i]; } OFAssert(j == retLength); objc_autoreleasePoolPop(pool); @try { ret = [OFString stringWithUTF8String: retCString length: retLength]; } @finally { OFFreeMemory(retCString); } return ret; } @end |
Modified src/OFString+XMLUnescaping.h from [5fc70e7ddb] to [5e3aafdb56].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFString.h" OF_ASSUME_NONNULL_BEGIN /** @file */ |
︙ | ︙ |
Modified src/OFString+XMLUnescaping.m from [dd8350c1c8] to [0faab389ff].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "OFString.h" |
︙ | ︙ |
Modified src/OFString.h from [780687227d] to [4b582c4c17].
1 | /* | | | | | | > | < | < | > | | > | < < | | < | > | < | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS #endif #ifndef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS #endif #include "objfw-defs.h" #ifdef OF_HAVE_SYS_TYPES_H # include <sys/types.h> #endif #include <stdarg.h> #include <stdint.h> #ifdef OF_HAVE_INTTYPES_H # include <inttypes.h> #endif #import "OFObject.h" #import "OFJSONRepresentation.h" #import "OFMessagePackRepresentation.h" OF_ASSUME_NONNULL_BEGIN /** @file */ @class OFArray OF_GENERIC(ObjectType); @class OFCharacterSet; @class OFConstantString; @class OFIRI; @class OFString; #if defined(__cplusplus) && __cplusplus >= 201103L typedef char16_t OFChar16; typedef char32_t OFChar32; #else typedef uint_least16_t OFChar16; typedef uint_least32_t OFChar32; |
︙ | ︙ | |||
82 83 84 85 86 87 88 | OFStringEncodingISO8859_3, /** ISO 8859-15 */ OFStringEncodingISO8859_15, /** Windows-1251 */ OFStringEncodingWindows1251, /** Windows-1252 */ OFStringEncodingWindows1252, | | | | | 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | OFStringEncodingISO8859_3, /** ISO 8859-15 */ OFStringEncodingISO8859_15, /** Windows-1251 */ OFStringEncodingWindows1251, /** Windows-1252 */ OFStringEncodingWindows1252, /** Code page 437 */ OFStringEncodingCodepage437, /** Code page 850 */ OFStringEncodingCodepage850, /** Code page 858 */ OFStringEncodingCodepage858, /** Mac OS Roman */ OFStringEncodingMacRoman, /** KOI8-R */ OFStringEncodingKOI8R, /** KOI8-U */ OFStringEncodingKOI8U, |
︙ | ︙ | |||
129 130 131 132 133 134 135 | * @param line The current line * @param stop A pointer to a variable that can be set to true to stop the * enumeration */ typedef void (^OFStringLineEnumerationBlock)(OFString *line, bool *stop); #endif | < < < < < | | | | 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | * @param line The current line * @param stop A pointer to a variable that can be set to true to stop the * enumeration */ typedef void (^OFStringLineEnumerationBlock)(OFString *line, bool *stop); #endif /** * @class OFString OFString.h ObjFW/OFString.h * * @brief A class for handling strings. */ @interface OFString: OFObject <OFCopying, OFMutableCopying, OFComparing, OFJSONRepresentation, OFMessagePackRepresentation> /** * @brief The length of the string in Unicode code points. */ @property (readonly, nonatomic) size_t length; /** * @brief The OFString as a UTF-8 encoded C string. * * The result is valid until the autorelease pool is released. If you want to * use the result outside the scope of the current autorelease pool, you have to * copy it. */ @property (readonly, nonatomic) const char *UTF8String; /** * @brief The number of bytes the string needs in UTF-8 encoding. */ @property (readonly, nonatomic) size_t UTF8StringLength; /** |
︙ | ︙ | |||
230 231 232 233 234 235 236 | * * The result is valid until the autorelease pool is released. If you want to * use the result outside the scope of the current autorelease pool, you have to * copy it. * * The returned string is *not* null-terminated. */ | | < | < | < < < < < < | < < < < < < < < | | 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | * * The result is valid until the autorelease pool is released. If you want to * use the result outside the scope of the current autorelease pool, you have to * copy it. * * The returned string is *not* null-terminated. */ @property (readonly, nonatomic) const OFUnichar *characters; /** * @brief The string in UTF-16 encoding with native byte order. * * The result is valid until the autorelease pool is released. If you want to * use the result outside the scope of the current autorelease pool, you have to * copy it. * * The returned string is null-terminated. */ @property (readonly, nonatomic) const OFChar16 *UTF16String; /** * @brief The length of the string in UTF-16 characters. */ @property (readonly, nonatomic) size_t UTF16StringLength; /** * @brief The string in UTF-32 encoding with native byte order. * * The result is valid until the autorelease pool is released. If you want to * use the result outside the scope of the current autorelease pool, you have to * copy it. * * The returned string is null-terminated. */ @property (readonly, nonatomic) const OFChar32 *UTF32String; /** * @brief The string with leading whitespaces deleted. */ @property (readonly, nonatomic) OFString *stringByDeletingLeadingWhitespaces; /** * @brief The string with trailing whitespaces deleted. */ @property (readonly, nonatomic) OFString *stringByDeletingTrailingWhitespaces; /** * @brief The string with leading and trailing whitespaces deleted. */ @property (readonly, nonatomic) OFString *stringByDeletingEnclosingWhitespaces; #if defined(OF_WINDOWS) || defined(DOXYGEN) /** * @brief The string with the Windows Environment Strings expanded. */ @property (readonly, nonatomic) OFString *stringByExpandingWindowsEnvironmentStrings; #endif /** * @brief Creates a new OFString. * * @return A new, autoreleased OFString */ + (instancetype)string; |
︙ | ︙ | |||
331 332 333 334 335 336 337 | length: (size_t)UTF8StringLength; /** * @brief Creates a new OFString from a UTF-8 encoded C string without copying * the string, if possible. * * If initialization fails for whatever reason, the passed C string is *not* | | | | 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 | length: (size_t)UTF8StringLength; /** * @brief Creates a new OFString from a UTF-8 encoded C string without copying * the string, if possible. * * If initialization fails for whatever reason, the passed C string is *not* * freed if `freeWhenDone` is true. * * @note OFMutableString always creates a copy! * * @param UTF8String A UTF-8 encoded C string to initialize the OFString with * @param freeWhenDone Whether to free the C string when the OFString gets * deallocated * @return A new autoreleased OFString * @throw OFInvalidEncodingException The string is not properly UTF-8-encoded */ + (instancetype)stringWithUTF8StringNoCopy: (char *)UTF8String freeWhenDone: (bool)freeWhenDone; /** * @brief Creates a new OFString from a UTF-8 encoded C string with the * specified length without copying the string, if possible. * * If initialization fails for whatever reason, the passed C string is *not* * freed if `freeWhenDone` is true. * * @note OFMutableString always creates a copy! * * @param UTF8String A UTF-8 encoded C string to initialize the OFString with * @param UTF8StringLength The length of the UTF-8 encoded C string * @param freeWhenDone Whether to free the C string when the OFString gets * deallocated |
︙ | ︙ | |||
526 527 528 529 530 531 532 | * @return A new autoreleased OFString * @throw OFInvalidFormatException The specified format is invalid * @throw OFInvalidEncodingException The resulting string is not in not in UTF-8 * encoding */ + (instancetype)stringWithFormat: (OFConstantString *)format, ...; | | | 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 | * @return A new autoreleased OFString * @throw OFInvalidFormatException The specified format is invalid * @throw OFInvalidEncodingException The resulting string is not in not in UTF-8 * encoding */ + (instancetype)stringWithFormat: (OFConstantString *)format, ...; #ifdef OF_HAVE_FILES /** * @brief Creates a new OFString with the contents of the specified UTF-8 * encoded file. * * @param path The path to the file * @return A new autoreleased OFString * @throw OFInvalidEncodingException The string is not properly UTF-8-encoded |
︙ | ︙ | |||
548 549 550 551 552 553 554 | * @param path The path to the file * @param encoding The encoding of the file * @return A new autoreleased OFString * @throw OFInvalidEncodingException The string is not in the specified encoding */ + (instancetype)stringWithContentsOfFile: (OFString *)path encoding: (OFStringEncoding)encoding; | | | | | | | | | | | | > > > > > > > | 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 | * @param path The path to the file * @param encoding The encoding of the file * @return A new autoreleased OFString * @throw OFInvalidEncodingException The string is not in the specified encoding */ + (instancetype)stringWithContentsOfFile: (OFString *)path encoding: (OFStringEncoding)encoding; #endif /** * @brief Creates a new OFString with the contents of the specified IRI. * * If the IRI's scheme is file, it tries UTF-8 encoding. * * If the IRI's scheme is `http` or `https`, it tries to detect the encoding * from the HTTP headers. If it could not detect the encoding using the HTTP * headers, it tries UTF-8. * * @param IRI The IRI to the contents for the string * @return A new autoreleased OFString * @throw OFInvalidEncodingException The string is not in the expected encoding */ + (instancetype)stringWithContentsOfIRI: (OFIRI *)IRI; /** * @brief Creates a new OFString with the contents of the specified IRI in the * specified encoding. * * @param IRI The IRI to the contents for the string * @param encoding The encoding to assume * @return A new autoreleased OFString * @throw OFInvalidEncodingException The string is not in the specified encoding */ + (instancetype)stringWithContentsOfIRI: (OFIRI *)IRI encoding: (OFStringEncoding)encoding; /** * @brief Initializes an already allocated OFString to be empty. * * @return An initialized OFString */ - (instancetype)init OF_DESIGNATED_INITIALIZER; /** * @brief Initializes an already allocated OFString from a UTF-8 encoded C * string. * * @param UTF8String A UTF-8 encoded C string to initialize the OFString with * @return An initialized OFString * @throw OFInvalidEncodingException The string is not properly UTF-8-encoded |
︙ | ︙ | |||
604 605 606 607 608 609 610 | length: (size_t)UTF8StringLength; /** * @brief Initializes an already allocated OFString from an UTF-8 encoded C * string without copying the string, if possible. * * If initialization fails for whatever reason, the passed C string is *not* | | | | 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 | length: (size_t)UTF8StringLength; /** * @brief Initializes an already allocated OFString from an UTF-8 encoded C * string without copying the string, if possible. * * If initialization fails for whatever reason, the passed C string is *not* * freed if `freeWhenDone` is true. * * @note OFMutableString always creates a copy! * * @param UTF8String A UTF-8 encoded C string to initialize the OFString with * @param freeWhenDone Whether to free the C string when it is not needed * anymore * @return An initialized OFString * @throw OFInvalidEncodingException The string is not properly UTF-8-encoded */ - (instancetype)initWithUTF8StringNoCopy: (char *)UTF8String freeWhenDone: (bool)freeWhenDone; /** * @brief Initializes an already allocated OFString from an UTF-8 encoded C * string with the specified length without copying the string, if * possible. * * If initialization fails for whatever reason, the passed C string is *not* * freed if `freeWhenDone` is true. * * @note OFMutableString always creates a copy! * * @param UTF8String A UTF-8 encoded C string to initialize the OFString with * @param UTF8StringLength The length of the UTF-8 encoded C string * @param freeWhenDone Whether to free the C string when it is not needed * anymore |
︙ | ︙ | |||
819 820 821 822 823 824 825 | * @throw OFInvalidFormatException The specified format is invalid * @throw OFInvalidEncodingException The resulting string is not in not in UTF-8 * encoding */ - (instancetype)initWithFormat: (OFConstantString *)format arguments: (va_list)arguments; | | | 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 | * @throw OFInvalidFormatException The specified format is invalid * @throw OFInvalidEncodingException The resulting string is not in not in UTF-8 * encoding */ - (instancetype)initWithFormat: (OFConstantString *)format arguments: (va_list)arguments; #ifdef OF_HAVE_FILES /** * @brief Initializes an already allocated OFString with the contents of the * specified file in the specified encoding. * * @param path The path to the file * @return An initialized OFString * @throw OFInvalidEncodingException The string is not properly UTF-8-encoded |
︙ | ︙ | |||
841 842 843 844 845 846 847 | * @param path The path to the file * @param encoding The encoding of the file * @return An initialized OFString * @throw OFInvalidEncodingException The string is not in the specified encoding */ - (instancetype)initWithContentsOfFile: (OFString *)path encoding: (OFStringEncoding)encoding; | | | | | | | | | | | | | 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 | * @param path The path to the file * @param encoding The encoding of the file * @return An initialized OFString * @throw OFInvalidEncodingException The string is not in the specified encoding */ - (instancetype)initWithContentsOfFile: (OFString *)path encoding: (OFStringEncoding)encoding; #endif /** * @brief Initializes an already allocated OFString with the contents of the * specified IRI. * * If the IRI's scheme is file, it tries UTF-8 encoding. * * If the IRI's scheme is `http` or `https`, it tries to detect the encoding * from the HTTP headers. If it could not detect the encoding using the HTTP * headers, it tries UTF-8. * * @param IRI The IRI to the contents for the string * @return An initialized OFString * @throw OFInvalidEncodingException The string is not in the expected encoding */ - (instancetype)initWithContentsOfIRI: (OFIRI *)IRI; /** * @brief Initializes an already allocated OFString with the contents of the * specified IRI in the specified encoding. * * @param IRI The IRI to the contents for the string * @param encoding The encoding to assume * @return An initialized OFString * @throw OFInvalidEncodingException The string is not in the specified encoding */ - (instancetype)initWithContentsOfIRI: (OFIRI *)IRI encoding: (OFStringEncoding)encoding; /** * @brief Writes the OFString into the specified C string with the specified * encoding. * * @param cString The C string to write into |
︙ | ︙ | |||
916 917 918 919 920 921 922 | * copy it. * * @param encoding The encoding for the C string * @return The OFString as a C string in the specified encoding * @throw OFInvalidEncodingException The string cannot be represented in the * specified encoding */ | | < | < | 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 | * copy it. * * @param encoding The encoding for the C string * @return The OFString as a C string in the specified encoding * @throw OFInvalidEncodingException The string cannot be represented in the * specified encoding */ - (const char *)cStringWithEncoding: (OFStringEncoding)encoding; /** * @brief Returns the OFString as a C string in the specified encoding, * replacing characters that cannot be represented in the specified * encoding with a question mark. * * The result is valid until the autorelease pool is released. If you want to * use the result outside the scope of the current autorelease pool, you have to * copy it. * * @param encoding The encoding for the C string * @return The OFString as a C string in the specified encoding */ - (const char *)lossyCStringWithEncoding: (OFStringEncoding)encoding; /** * @brief Returns the number of bytes the string needs in the specified * encoding. * * @param encoding The encoding for the string * @return The number of bytes the string needs in the specified encoding. |
︙ | ︙ | |||
1024 1025 1026 1027 1028 1029 1030 | */ - (size_t)indexOfCharacterFromSet: (OFCharacterSet *)characterSet; /** * @brief Returns the index of the first character from the set. * * @param characterSet The set of characters to search for | | | | 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 | */ - (size_t)indexOfCharacterFromSet: (OFCharacterSet *)characterSet; /** * @brief Returns the index of the first character from the set. * * @param characterSet The set of characters to search for * @param options Options modifying search behavior * @return The index of the first occurrence of a character from the set or * `OFNotFound` if it was not found */ - (size_t)indexOfCharacterFromSet: (OFCharacterSet *)characterSet options: (OFStringSearchOptions)options; /** * @brief Returns the index of the first character from the set. * * @param characterSet The set of characters to search for * @param options Options modifying search behavior * @param range The range in which to search * @return The index of the first occurrence of a character from the set or * `OFNotFound` if it was not found */ - (size_t)indexOfCharacterFromSet: (OFCharacterSet *)characterSet options: (OFStringSearchOptions)options range: (OFRange)range; |
︙ | ︙ | |||
1064 1065 1066 1067 1068 1069 1070 | */ - (OFString *)substringFromIndex: (size_t)idx; /** * @brief Creates a substring from the beginning to the specified index. * * @param idx The index at which the substring should end, exclusive | | | 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 | */ - (OFString *)substringFromIndex: (size_t)idx; /** * @brief Creates a substring from the beginning to the specified index. * * @param idx The index at which the substring should end, exclusive * @return The substring from the beginning to the specified index */ - (OFString *)substringToIndex: (size_t)idx; /** * @brief Creates a substring with the specified range. * * @param range The range of the substring |
︙ | ︙ | |||
1170 1171 1172 1173 1174 1175 1176 | /** * @brief Creates a new string by replacing the occurrences of the specified * string in the specified range with the specified replacement. * * @param string The string to replace * @param replacement The string with which it should be replaced | | | 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 | /** * @brief Creates a new string by replacing the occurrences of the specified * string in the specified range with the specified replacement. * * @param string The string to replace * @param replacement The string with which it should be replaced * @param options Options modifying search behavior. * Possible values are: * * None yet, pass 0 * @param range The range in which to replace the string * @return A new string with the occurrences of the specified string replaced */ - (OFString *)stringByReplacingOccurrencesOfString: (OFString *)string withString: (OFString *)replacement |
︙ | ︙ | |||
1254 1255 1256 1257 1258 1259 1260 | * * The returned string is null-terminated. * * @param byteOrder The byte order for the UTF-16 encoding * @return The string in UTF-16 encoding with the specified byte order * @throw OFInvalidEncodingException The string cannot be represented in UTF-16 */ | | < | < | | | | | | | | | | | < | 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 | * * The returned string is null-terminated. * * @param byteOrder The byte order for the UTF-16 encoding * @return The string in UTF-16 encoding with the specified byte order * @throw OFInvalidEncodingException The string cannot be represented in UTF-16 */ - (const OFChar16 *)UTF16StringWithByteOrder: (OFByteOrder)byteOrder; /** * @brief Returns the string in UTF-32 encoding with the specified byte order. * * The result is valid until the autorelease pool is released. If you want to * use the result outside the scope of the current autorelease pool, you have to * copy it. * * The returned string is null-terminated. * * @param byteOrder The byte order for the UTF-32 encoding * @return The string in UTF-32 encoding with the specified byte order */ - (const OFChar32 *)UTF32StringWithByteOrder: (OFByteOrder)byteOrder; /** * @brief Returns the string as OFData with the specified encoding. * * @param encoding The encoding to use for the returned OFData * @return The string as OFData with the specified encoding * @throw OFInvalidEncodingException The string cannot be represented in the * specified encoding */ - (OFData *)dataWithEncoding: (OFStringEncoding)encoding; #ifdef OF_HAVE_FILES /** * @brief Writes the string into the specified file using UTF-8 encoding. * * @param path The path of the file to write to */ - (void)writeToFile: (OFString *)path; /** * @brief Writes the string into the specified file using the specified * encoding. * * @param path The path of the file to write to * @param encoding The encoding to use to write the string into the file * @throw OFInvalidEncodingException The string cannot be represented in the * specified encoding */ - (void)writeToFile: (OFString *)path encoding: (OFStringEncoding)encoding; #endif /** * @brief Writes the string to the specified IRI using UTF-8 encoding. * * @param IRI The IRI to write to */ - (void)writeToIRI: (OFIRI *)IRI; /** * @brief Writes the string to the specified IRI using the specified encoding. * * @param IRI The IRI to write to * @param encoding The encoding to use to write the string to the IRI * @throw OFInvalidEncodingException The string cannot be represented in the * specified encoding */ - (void)writeToIRI: (OFIRI *)IRI encoding: (OFStringEncoding)encoding; #ifdef OF_HAVE_BLOCKS /** * Enumerates all lines in the receiver using the specified block. * * @brief block The block to call for each line */ - (void)enumerateLinesUsingBlock: (OFStringLineEnumerationBlock)block; #endif @end #ifdef __cplusplus extern "C" { #endif /** * @brief Parses the specified string encoding name and returns the * OFStringEncoding for it. |
︙ | ︙ | |||
1364 1365 1366 1367 1368 1369 1370 | extern size_t OFUTF32StringLength(const OFChar32 *); #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END | | | < | | | | | | | < | | < | < < | 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 | extern size_t OFUTF32StringLength(const OFChar32 *); #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END #import "OFConstantString.h" #import "OFMutableString.h" #import "OFString+CryptographicHashing.h" #import "OFString+JSONParsing.h" #ifdef OF_HAVE_FILES # import "OFString+PathAdditions.h" #endif #import "OFString+PercentEncoding.h" #import "OFString+PropertyListParsing.h" #import "OFString+XMLEscaping.h" #import "OFString+XMLUnescaping.h" #if !defined(NSINTEGER_DEFINED) && !__has_feature(modules) /* * Very *ugly* hack required for string boxing literals to work. * * This hack is needed in order to work with `@class NSString` from Apple's * objc/NSString.h - which is included when using modules - as * @compatibility_alias does not work if @class has been used before. * For some reason, this makes Clang refer to OFString for string box literals * and not to NSString (which would result in a linker error, but would be the * correct behavior). * * TODO: Submit a patch for Clang that makes the boxing classes configurable! */ @interface NSString: OFString @end #endif |
Modified src/OFString.m from [03372dc363] to [a5a923c44c].
1 | /* | | | | | | > > > > | < > | | > > < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <ctype.h> #include <errno.h> #include <math.h> #include <stdarg.h> #include <stdlib.h> #include <string.h> #if defined(HAVE_STRTOF_L) || defined(HAVE_STRTOD_L) || defined(HAVE_USELOCALE) # include <locale.h> #endif #ifdef HAVE_XLOCALE_H # include <xlocale.h> #endif #import "OFString.h" #import "OFASPrintF.h" #import "OFArray.h" #import "OFCharacterSet.h" #import "OFData.h" #import "OFDictionary.h" #ifdef OF_HAVE_FILES # import "OFFile.h" # import "OFFileManager.h" #endif #import "OFIRI.h" #import "OFIRIHandler.h" #import "OFLocale.h" #import "OFStream.h" #import "OFSystemInfo.h" #import "OFUTF8String.h" #import "OFUTF8String+Private.h" #import "OFGetItemAttributesFailedException.h" #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidEncodingException.h" #import "OFInvalidFormatException.h" #import "OFNotImplementedException.h" |
︙ | ︙ | |||
78 79 80 81 82 83 84 | # define INFINITY __builtin_inf() #endif static struct { Class isa; } placeholder; | | | | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | # define INFINITY __builtin_inf() #endif static struct { Class isa; } placeholder; #if defined(HAVE_STRTOF_L) || defined(HAVE_STRTOD_L) || defined(HAVE_USELOCALE) static locale_t cLocale; #endif @interface OFString () - (size_t)of_getCString: (char *)cString maxLength: (size_t)maxLength encoding: (OFStringEncoding)encoding lossy: (bool)lossy OF_DIRECT; - (const char *)of_cStringWithEncoding: (OFStringEncoding)encoding lossy: (bool)lossy OF_DIRECT; - (OFString *) of_JSONRepresentationWithOptions: (OFJSONRepresentationOptions)options depth: (size_t)depth; @end @interface OFPlaceholderString: OFString @end extern bool OFUnicodeToISO8859_2(const OFUnichar *, unsigned char *, size_t, bool); extern bool OFUnicodeToISO8859_3(const OFUnichar *, unsigned char *, size_t, bool); extern bool OFUnicodeToISO8859_15(const OFUnichar *, unsigned char *, |
︙ | ︙ | |||
131 132 133 134 135 136 137 | _OFString_CryptographicHashing_reference = 1; _OFString_JSONParsing_reference = 1; #ifdef OF_HAVE_FILES _OFString_PathAdditions_reference = 1; #endif _OFString_PercentEncoding_reference = 1; _OFString_PropertyListParsing_reference = 1; | < | 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | _OFString_CryptographicHashing_reference = 1; _OFString_JSONParsing_reference = 1; #ifdef OF_HAVE_FILES _OFString_PathAdditions_reference = 1; #endif _OFString_PercentEncoding_reference = 1; _OFString_PropertyListParsing_reference = 1; _OFString_XMLEscaping_reference = 1; _OFString_XMLUnescaping_reference = 1; } void _reference_to_OFConstantString(void) { |
︙ | ︙ | |||
344 345 346 347 348 349 350 | size_t length = strlen(string); char *copy = (char *)OFAllocMemory(1, length + 1); memcpy(copy, string, length + 1); return copy; } | < | < < < < < < | < < < | < < < < | < < < < < < | < | < < < < | 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 | size_t length = strlen(string); char *copy = (char *)OFAllocMemory(1, length + 1); memcpy(copy, string, length + 1); return copy; } @implementation OFPlaceholderString #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)init { return (id)[[OFUTF8String alloc] init]; } - (instancetype)initWithUTF8String: (const char *)UTF8String { |
︙ | ︙ | |||
578 579 580 581 582 583 584 | encoding: (OFStringEncoding)encoding { return (id)[[OFUTF8String alloc] initWithContentsOfFile: path encoding: encoding]; } #endif | | | | | | < < < < | < < < < | < | < < | < < < < < < < < | | | 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 | encoding: (OFStringEncoding)encoding { return (id)[[OFUTF8String alloc] initWithContentsOfFile: path encoding: encoding]; } #endif - (instancetype)initWithContentsOfIRI: (OFIRI *)IRI { return (id)[[OFUTF8String alloc] initWithContentsOfIRI: IRI]; } - (instancetype)initWithContentsOfIRI: (OFIRI *)IRI encoding: (OFStringEncoding)encoding { return (id)[[OFUTF8String alloc] initWithContentsOfIRI: IRI encoding: encoding]; } #ifdef __clang__ # pragma clang diagnostic pop #endif OF_SINGLETON_METHODS @end @implementation OFString + (void)initialize { if (self != [OFString class]) return; object_setClass((id)&placeholder, [OFPlaceholderString class]); #if defined(HAVE_STRTOF_L) || defined(HAVE_STRTOD_L) || defined(HAVE_USELOCALE) if ((cLocale = newlocale(LC_ALL_MASK, "C", NULL)) == NULL) @throw [OFInitializationFailedException exceptionWithClass: self]; #endif } + (instancetype)alloc |
︙ | ︙ | |||
792 793 794 795 796 797 798 | encoding: (OFStringEncoding)encoding { return [[[self alloc] initWithContentsOfFile: path encoding: encoding] autorelease]; } #endif | | | | | | > | 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 | encoding: (OFStringEncoding)encoding { return [[[self alloc] initWithContentsOfFile: path encoding: encoding] autorelease]; } #endif + (instancetype)stringWithContentsOfIRI: (OFIRI *)IRI { return [[[self alloc] initWithContentsOfIRI: IRI] autorelease]; } + (instancetype)stringWithContentsOfIRI: (OFIRI *)IRI encoding: (OFStringEncoding)encoding { return [[[self alloc] initWithContentsOfIRI: IRI encoding: encoding] autorelease]; } - (instancetype)init { if ([self isMemberOfClass: [OFString class]] || [self isMemberOfClass: [OFMutableString class]]) { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @throw e; } |
︙ | ︙ | |||
866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 | encoding: (OFStringEncoding)encoding { return [self initWithCString: cString encoding: encoding length: strlen(cString)]; } - (instancetype)initWithCString: (const char *)cString encoding: (OFStringEncoding)encoding length: (size_t)cStringLength { OF_INVALID_INIT_METHOD } - (instancetype)initWithData: (OFData *)data encoding: (OFStringEncoding)encoding { @try { if (data.itemSize != 1) @throw [OFInvalidArgumentException exception]; } @catch (id e) { [self release]; @throw e; } self = [self initWithCString: data.items encoding: encoding length: data.count]; return self; } - (instancetype)initWithString: (OFString *)string { OF_INVALID_INIT_METHOD } - (instancetype)initWithCharacters: (const OFUnichar *)string length: (size_t)length { OF_INVALID_INIT_METHOD } - (instancetype)initWithUTF16String: (const OFChar16 *)string { return [self initWithUTF16String: string length: OFUTF16StringLength(string) byteOrder: OFByteOrderNative]; } | > > > > > > > > > > > > > > > > > > | 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 | encoding: (OFStringEncoding)encoding { return [self initWithCString: cString encoding: encoding length: strlen(cString)]; } #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)initWithCString: (const char *)cString encoding: (OFStringEncoding)encoding length: (size_t)cStringLength { OF_INVALID_INIT_METHOD } #ifdef __clang__ # pragma clang diagnostic pop #endif - (instancetype)initWithData: (OFData *)data encoding: (OFStringEncoding)encoding { @try { if (data.itemSize != 1) @throw [OFInvalidArgumentException exception]; } @catch (id e) { [self release]; @throw e; } self = [self initWithCString: data.items encoding: encoding length: data.count]; return self; } #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)initWithString: (OFString *)string { OF_INVALID_INIT_METHOD } - (instancetype)initWithCharacters: (const OFUnichar *)string length: (size_t)length { OF_INVALID_INIT_METHOD } #ifdef __clang__ # pragma clang diagnostic pop #endif - (instancetype)initWithUTF16String: (const OFChar16 *)string { return [self initWithUTF16String: string length: OFUTF16StringLength(string) byteOrder: OFByteOrderNative]; } |
︙ | ︙ | |||
925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 | byteOrder: (OFByteOrder)byteOrder { return [self initWithUTF16String: string length: OFUTF16StringLength(string) byteOrder: byteOrder]; } - (instancetype)initWithUTF16String: (const OFChar16 *)string length: (size_t)length byteOrder: (OFByteOrder)byteOrder { OF_INVALID_INIT_METHOD } - (instancetype)initWithUTF32String: (const OFChar32 *)string { return [self initWithUTF32String: string length: OFUTF32StringLength(string) byteOrder: OFByteOrderNative]; } | > > > > > > > > > | 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 | byteOrder: (OFByteOrder)byteOrder { return [self initWithUTF16String: string length: OFUTF16StringLength(string) byteOrder: byteOrder]; } #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)initWithUTF16String: (const OFChar16 *)string length: (size_t)length byteOrder: (OFByteOrder)byteOrder { OF_INVALID_INIT_METHOD } #ifdef __clang__ # pragma clang diagnostic pop #endif - (instancetype)initWithUTF32String: (const OFChar32 *)string { return [self initWithUTF32String: string length: OFUTF32StringLength(string) byteOrder: OFByteOrderNative]; } |
︙ | ︙ | |||
955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 | byteOrder: (OFByteOrder)byteOrder { return [self initWithUTF32String: string length: OFUTF32StringLength(string) byteOrder: byteOrder]; } - (instancetype)initWithUTF32String: (const OFChar32 *)string length: (size_t)length byteOrder: (OFByteOrder)byteOrder { OF_INVALID_INIT_METHOD } - (instancetype)initWithFormat: (OFConstantString *)format, ... { id ret; va_list arguments; va_start(arguments, format); ret = [self initWithFormat: format arguments: arguments]; va_end(arguments); return ret; } - (instancetype)initWithFormat: (OFConstantString *)format arguments: (va_list)arguments { OF_INVALID_INIT_METHOD } #ifdef OF_HAVE_FILES - (instancetype)initWithContentsOfFile: (OFString *)path { return [self initWithContentsOfFile: path encoding: OFStringEncodingUTF8]; } - (instancetype)initWithContentsOfFile: (OFString *)path encoding: (OFStringEncoding)encoding { | > > > > > > > > > > > > > > > > > > < < < < | < < | < < < < < < < < | < | < < < < < < < < < < < < < < < < < < | < < < < | > | < | | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 | byteOrder: (OFByteOrder)byteOrder { return [self initWithUTF32String: string length: OFUTF32StringLength(string) byteOrder: byteOrder]; } #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)initWithUTF32String: (const OFChar32 *)string length: (size_t)length byteOrder: (OFByteOrder)byteOrder { OF_INVALID_INIT_METHOD } #ifdef __clang__ # pragma clang diagnostic pop #endif - (instancetype)initWithFormat: (OFConstantString *)format, ... { id ret; va_list arguments; va_start(arguments, format); ret = [self initWithFormat: format arguments: arguments]; va_end(arguments); return ret; } #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)initWithFormat: (OFConstantString *)format arguments: (va_list)arguments { OF_INVALID_INIT_METHOD } #ifdef __clang__ # pragma clang diagnostic pop #endif #ifdef OF_HAVE_FILES - (instancetype)initWithContentsOfFile: (OFString *)path { return [self initWithContentsOfFile: path encoding: OFStringEncodingUTF8]; } - (instancetype)initWithContentsOfFile: (OFString *)path encoding: (OFStringEncoding)encoding { void *pool = objc_autoreleasePoolPush(); OFIRI *IRI; @try { IRI = [OFIRI fileIRIWithPath: path isDirectory: false]; } @catch (id e) { [self release]; @throw e; } self = [self initWithContentsOfIRI: IRI encoding: encoding]; objc_autoreleasePoolPop(pool); return self; } #endif - (instancetype)initWithContentsOfIRI: (OFIRI *)IRI { return [self initWithContentsOfIRI: IRI encoding: OFStringEncodingAutodetect]; } - (instancetype)initWithContentsOfIRI: (OFIRI *)IRI encoding: (OFStringEncoding)encoding { void *pool = objc_autoreleasePoolPush(); OFData *data; @try { data = [OFData dataWithContentsOfIRI: IRI]; } @catch (id e) { [self release]; @throw e; } /* FIXME: Detect encoding where we can. */ if (encoding == OFStringEncodingAutodetect) encoding = OFStringEncodingUTF8; self = [self initWithCString: data.items encoding: encoding length: data.count * data.itemSize]; objc_autoreleasePoolPop(pool); return self; } - (size_t)of_getCString: (char *)cString maxLength: (size_t)maxLength |
︙ | ︙ | |||
1678 1679 1680 1681 1682 1683 1684 | } - (OFString *)description { return [[self copy] autorelease]; } | < < < < < < < < < < < < < < < < < < < < < < | 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 | } - (OFString *)description { return [[self copy] autorelease]; } - (OFString *)JSONRepresentation { return [self of_JSONRepresentationWithOptions: 0 depth: 0]; } - (OFString *)JSONRepresentationWithOptions: (OFJSONRepresentationOptions)options |
︙ | ︙ | |||
2422 2423 2424 2425 2426 2427 2428 | [stripped caseInsensitiveCompare: @"-INFINITY"] == OFOrderedSame) return -INFINITY; if ([stripped caseInsensitiveCompare: @"NAN"] == OFOrderedSame) return NAN; if ([stripped caseInsensitiveCompare: @"-NAN"] == OFOrderedSame) return -NAN; | | > > > > > > | | | > > | < | > > | | > | > > > > | 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 | [stripped caseInsensitiveCompare: @"-INFINITY"] == OFOrderedSame) return -INFINITY; if ([stripped caseInsensitiveCompare: @"NAN"] == OFOrderedSame) return NAN; if ([stripped caseInsensitiveCompare: @"-NAN"] == OFOrderedSame) return -NAN; #if defined(HAVE_STRTOF_L) || defined(HAVE_USELOCALE) const char *UTF8String = self.UTF8String; #else OFString *decimalSeparator = [OFLocale decimalSeparator]; const char *UTF8String; if ([decimalSeparator isEqual: @"."]) UTF8String = self.UTF8String; else /* * If we have no strtof_l, we have no other choice than to * replace the locale's decimal point with something that will * be rejected and replacing "." with the locale's decimal * point. */ UTF8String = [[self stringByReplacingOccurrencesOfString: decimalSeparator withString: @"!"] stringByReplacingOccurrencesOfString: @"." withString: decimalSeparator] .UTF8String; #endif char *endPtr = NULL; float value; errno = 0; #if defined(HAVE_STRTOF_L) value = strtof_l(UTF8String, &endPtr, cLocale); #elif defined(HAVE_USELOCALE) locale_t previousLocale = uselocale(cLocale); value = strtof(UTF8String, &endPtr); uselocale(previousLocale); #else value = strtof(UTF8String, &endPtr); #endif if (value == HUGE_VALF && errno == ERANGE) @throw [OFOutOfRangeException exception]; |
︙ | ︙ | |||
2475 2476 2477 2478 2479 2480 2481 | [stripped caseInsensitiveCompare: @"-INFINITY"] == OFOrderedSame) return -INFINITY; if ([stripped caseInsensitiveCompare: @"NAN"] == OFOrderedSame) return NAN; if ([stripped caseInsensitiveCompare: @"-NAN"] == OFOrderedSame) return -NAN; | | > > > > > > | | | > > | < | > > | | > | > > > > | 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 | [stripped caseInsensitiveCompare: @"-INFINITY"] == OFOrderedSame) return -INFINITY; if ([stripped caseInsensitiveCompare: @"NAN"] == OFOrderedSame) return NAN; if ([stripped caseInsensitiveCompare: @"-NAN"] == OFOrderedSame) return -NAN; #if defined(HAVE_STRTOD_L) || defined(HAVE_USELOCALE) const char *UTF8String = self.UTF8String; #else OFString *decimalSeparator = [OFLocale decimalSeparator]; const char *UTF8String; if ([decimalSeparator isEqual: @"."]) UTF8String = self.UTF8String; else /* * If we have no strtod_l, we have no other choice than to * replace the locale's decimal point with something that will * be rejected and replacing "." with the locale's decimal * point. */ UTF8String = [[self stringByReplacingOccurrencesOfString: decimalSeparator withString: @"!"] stringByReplacingOccurrencesOfString: @"." withString: decimalSeparator] .UTF8String; #endif char *endPtr = NULL; double value; errno = 0; #if defined(HAVE_STRTOD_L) value = strtod_l(UTF8String, &endPtr, cLocale); #elif defined(HAVE_USELOCALE) locale_t previousLocale = uselocale(cLocale); value = strtod(UTF8String, &endPtr); uselocale(previousLocale); #else value = strtod(UTF8String, &endPtr); #endif if (value == HUGE_VAL && errno == ERANGE) @throw [OFOutOfRangeException exception]; |
︙ | ︙ | |||
2661 2662 2663 2664 2665 2666 2667 | [data retain]; objc_autoreleasePoolPop(pool); return [data autorelease]; } | < < < < < < < < < < < < < < | 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 | [data retain]; objc_autoreleasePoolPop(pool); return [data autorelease]; } #ifdef OF_WINDOWS - (OFString *)stringByExpandingWindowsEnvironmentStrings { if ([OFSystemInfo isWindowsNT]) { wchar_t buffer[512]; size_t length; |
︙ | ︙ | |||
2720 2721 2722 2723 2724 2725 2726 | void *pool = objc_autoreleasePoolPush(); OFFile *file = [OFFile fileWithPath: path mode: @"w"]; [file writeString: self encoding: encoding]; objc_autoreleasePoolPop(pool); } #endif | | | | | | 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 | void *pool = objc_autoreleasePoolPush(); OFFile *file = [OFFile fileWithPath: path mode: @"w"]; [file writeString: self encoding: encoding]; objc_autoreleasePoolPop(pool); } #endif - (void)writeToIRI: (OFIRI *)IRI { [self writeToIRI: IRI encoding: OFStringEncodingUTF8]; } - (void)writeToIRI: (OFIRI *)IRI encoding: (OFStringEncoding)encoding { void *pool = objc_autoreleasePoolPush(); OFStream *stream; stream = [OFIRIHandler openItemAtIRI: IRI mode: @"w"]; [stream writeString: self encoding: encoding]; objc_autoreleasePoolPop(pool); } #ifdef OF_HAVE_BLOCKS - (void)enumerateLinesUsingBlock: (OFStringLineEnumerationBlock)block |
︙ | ︙ |
Modified src/OFSubarray.h from [06376fcb2e] to [6a6c1c997c].
1 | /* | | | | | | > > > > | < > | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFArray.h" OF_ASSUME_NONNULL_BEGIN @interface OFSubarray: OFArray { OFArray *_array; OFRange _range; } - (instancetype)initWithArray: (OFArray *)array range: (OFRange)range; @end OF_ASSUME_NONNULL_END |
Modified src/OFSubarray.m from [0aad1eac45] to [0da8c829e6].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFSubarray.h" #import "OFOutOfRangeException.h" |
︙ | ︙ |
Added src/OFSubdata.h version [a1bf6a50af].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFData.h" OF_ASSUME_NONNULL_BEGIN @interface OFSubdata: OFData { OFData *_data; OFRange _range; } - (instancetype)initWithData: (OFData *)data range: (OFRange)range; @end OF_ASSUME_NONNULL_END |
Added src/OFSubdata.m version [07f8cb39e3].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFSubdata.h" @implementation OFSubdata - (instancetype)initWithData: (OFData *)data range: (OFRange)range { self = [super init]; @try { /* Should usually be retain, as it's useless with a copy */ _data = [data copy]; _range = range; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_data release]; [super dealloc]; } - (size_t)count { return _range.length; } - (size_t)itemSize { return _data.itemSize; } - (const void *)items { return (const unsigned char *)_data.items + (_range.location * _data.itemSize); } @end |
Modified src/OFSubprocess.h from [1691c8fd4f] to [98efb56e8e].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS #endif #ifndef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS |
︙ | ︙ |
Modified src/OFSubprocess.m from [c37900d1dc] to [104b24bd0b].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include "platform.h" #ifdef OF_WINDOWS |
︙ | ︙ |
Added src/OFSystemInfo+NetworkInterfaces.h version [87c6d7ab80].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFSystemInfo.h" OF_ASSUME_NONNULL_BEGIN /** * @brief A dictionary describing a network interface, as returned by * @ref networkInterfaces. * * Keys are of type @ref OFNetworkInterfaceKey. */ typedef OFDictionary OF_GENERIC(OFString *, id) *OFNetworkInterface; /** * @brief A key of an @ref OFNetworkInterface. * * Possible values are: * * * @ref OFNetworkInterfaceIndex */ typedef OFConstantString *OFNetworkInterfaceKey; /** * @brief The index of a network interface. * * This maps to an @ref OFNumber. */ extern OFNetworkInterfaceKey OFNetworkInterfaceIndex; /** * @brief The hardware address of a network interface. * * This maps to an @ref OFData. */ extern OFNetworkInterfaceKey OFNetworkInterfaceHardwareAddress; /** * @brief The IPv4 addresses of a network interface. * * This maps to an @ref OFData of @ref OFSocketAddress. */ extern OFNetworkInterfaceKey OFNetworkInterfaceIPv4Addresses; #ifdef OF_HAVE_IPV6 /** * @brief The IPv6 addresses of a network interface. * * This maps to an @ref OFData of @ref OFSocketAddress. */ extern OFNetworkInterfaceKey OFNetworkInterfaceIPv6Addresses; #endif #ifdef OF_HAVE_IPX /** * @brief The IPX addresses of a network interface. * * This maps to an @ref OFData of @ref OFSocketAddress. */ extern OFNetworkInterfaceKey OFNetworkInterfaceIPXAddresses; #endif #ifdef OF_HAVE_APPLETALK /** * @brief The AppleTalk addresses of a network interface. * * This maps to an @ref OFData of @ref OFSocketAddress. */ extern OFNetworkInterfaceKey OFNetworkInterfaceAppleTalkAddresses; #endif @interface OFSystemInfo (NetworkInterfaces) #ifdef OF_HAVE_CLASS_PROPERTIES @property (class, readonly, nullable, nonatomic) OFDictionary OF_GENERIC(OFString *, OFNetworkInterface) *networkInterfaces; #endif /** * @brief Returns the available (though not necessarily configured) network * interfaces. * * @return The available network interfaces */ + (nullable OFDictionary OF_GENERIC(OFString *, OFNetworkInterface) *) networkInterfaces; @end OF_ASSUME_NONNULL_END |
Added src/OFSystemInfo+NetworkInterfaces.m version [6ea4e7c383].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFSystemInfo.h" OFNetworkInterfaceKey OFNetworkInterfaceIndex = @"OFNetworkInterfaceIndex"; OFNetworkInterfaceKey OFNetworkInterfaceHardwareAddress = @"OFNetworkInterfaceHardwareAddress"; OFNetworkInterfaceKey OFNetworkInterfaceIPv4Addresses = @"OFNetworkInterfaceIPv4Addresses"; #ifdef OF_HAVE_IPV6 OFNetworkInterfaceKey OFNetworkInterfaceIPv6Addresses = @"OFNetworkInterfaceIPv6Addresses"; #endif #ifdef OF_HAVE_IPX OFNetworkInterfaceKey OFNetworkInterfaceIPXAddresses = @"OFNetworkInterfaceIPXAddresses"; #endif #ifdef OF_HAVE_APPLETALK OFNetworkInterfaceKey OFNetworkInterfaceAppleTalkAddresses = @"OFNetworkInterfaceAppleTalkAddresses"; #endif #ifdef OF_WINDOWS # include "platform/Windows/OFSystemInfo+NetworkInterfaces.m" #else # include "platform/POSIX/OFSystemInfo+NetworkInterfaces.m" #endif |
Modified src/OFSystemInfo.h from [8b4f866788] to [55b98d503d].
1 | /* | | | | | | > > > > | < > | > | > | > | | > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFString.h" OF_ASSUME_NONNULL_BEGIN @class OFDictionary OF_GENERIC(KeyType, ObjectType); @class OFIRI; /** * @class OFSystemInfo OFSystemInfo.h ObjFW/OFSystemInfo.h * * @brief A class for querying information about the system. */ OF_SUBCLASSING_RESTRICTED @interface OFSystemInfo: OFObject #ifdef OF_HAVE_CLASS_PROPERTIES @property (class, readonly, nonatomic) size_t pageSize; @property (class, readonly, nonatomic) size_t numberOfCPUs; @property (class, readonly, nonatomic) OFString *ObjFWVersion; @property (class, readonly, nonatomic) unsigned short ObjFWVersionMajor; @property (class, readonly, nonatomic) unsigned short ObjFWVersionMinor; @property (class, readonly, nullable, nonatomic) OFString *operatingSystemName; @property (class, readonly, nullable, nonatomic) OFString *operatingSystemVersion; #if defined(OF_WINDOWS) || defined(DOXYGEN) @property (class, readonly, nullable, nonatomic) OFString *wineVersion; #endif @property (class, readonly, nullable, nonatomic) OFIRI *userDataIRI; @property (class, readonly, nullable, nonatomic) OFIRI *userConfigIRI; @property (class, readonly, nullable, nonatomic) OFIRI *temporaryDirectoryIRI; @property (class, readonly, nullable, nonatomic) OFString *CPUVendor; @property (class, readonly, nullable, nonatomic) OFString *CPUModel; # if defined(OF_AMD64) || defined(OF_X86) || defined(DOXYGEN) @property (class, readonly, nonatomic) bool supportsMMX; @property (class, readonly, nonatomic) bool supports3DNow; @property (class, readonly, nonatomic) bool supportsEnhanced3DNow; @property (class, readonly, nonatomic) bool supportsSSE; @property (class, readonly, nonatomic) bool supportsSSE2; @property (class, readonly, nonatomic) bool supportsSSE3; @property (class, readonly, nonatomic) bool supportsSSSE3; @property (class, readonly, nonatomic) bool supportsSSE41; @property (class, readonly, nonatomic) bool supportsSSE42; @property (class, readonly, nonatomic) bool supportsAVX; @property (class, readonly, nonatomic) bool supportsAVX2; @property (class, readonly, nonatomic) bool supportsAESNI; @property (class, readonly, nonatomic) bool supportsSHAExtensions; @property (class, readonly, nonatomic) bool supportsFusedMultiplyAdd; @property (class, readonly, nonatomic) bool supportsF16C; @property (class, readonly, nonatomic) bool supportsAVX512Foundation; @property (class, readonly, nonatomic) bool supportsAVX512ConflictDetectionInstructions; @property (class, readonly, nonatomic) bool supportsAVX512ExponentialAndReciprocalInstructions; @property (class, readonly, nonatomic) bool supportsAVX512PrefetchInstructions; @property (class, readonly, nonatomic) bool supportsAVX512VectorLengthExtensions; @property (class, readonly, nonatomic) bool supportsAVX512DoublewordAndQuadwordInstructions; @property (class, readonly, nonatomic) bool supportsAVX512ByteAndWordInstructions; @property (class, readonly, nonatomic) bool supportsAVX512IntegerFusedMultiplyAdd; @property (class, readonly, nonatomic) bool supportsAVX512VectorByteManipulationInstructions; @property (class, readonly, nonatomic) bool supportsAVX512VectorPopulationCountInstruction; @property (class, readonly, nonatomic) bool supportsAVX512VectorNeuralNetworkInstructions; @property (class, readonly, nonatomic) bool supportsAVX512VectorByteManipulationInstructions2; @property (class, readonly, nonatomic) bool supportsAVX512BitAlgorithms; @property (class, readonly, nonatomic) bool supportsAVX512Float16Instructions; @property (class, readonly, nonatomic) bool supportsAVX512BFloat16Instructions; # endif # if defined(OF_POWERPC) || defined(OF_POWERPC64) || defined(DOXYGEN) @property (class, readonly, nonatomic) bool supportsAltiVec; # endif # if defined(OF_WINDOWS) || defined(DOXYGEN) @property (class, readonly, nonatomic, getter=isWindowsNT) bool windowsNT; # endif #endif /** * @brief Returns the size of a page. * * @return The size of a page */ + (size_t)pageSize; /** * @brief Returns the number of CPUs installed in the system. * * A CPU with multiple cores counts as multiple CPUs. * * If the system has no CPU, the return value is undefined. * * @return The number of CPUs installed in the system */ + (size_t)numberOfCPUs; /** * @brief The version of ObjFW. |
︙ | ︙ | |||
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | * @brief Returns the version of the operating system the application is * running on. * * @return The version of the operating system the application is running on */ + (nullable OFString *)operatingSystemVersion; /** * @brief Returns the path where user data for the application can be stored. * * On UNIX systems, this adheres to the XDG Base Directory specification.@n * On macOS and iOS, it uses the `NSApplicationSupportDirectory` directory.@n * On Windows, it uses the `APPDATA` environment variable.@n * On Haiku, it uses the `B_USER_SETTINGS_DIRECTORY` directory.@n * On AmigaOS and MorphOS, it returns `PROGDIR:`. * * @return The path where user data for the application can be stored */ | > > > > > > > > > > > > > | | | | | > > > > > > > > > > > > > > > > > > < < | < < | < < | < < | < < | < < | | < < | | | < < | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | > > > > | 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 | * @brief Returns the version of the operating system the application is * running on. * * @return The version of the operating system the application is running on */ + (nullable OFString *)operatingSystemVersion; #if defined(OF_WINDOWS) || defined(DOXYGEN) /** * @brief Returns the version of Wine the application is running on, or `nil` * if not running on Wine (e.g. on Windows natively). * * @note This is only available on Windows. * * @return The version of Wine the application is running on, or `nil` if not * running on Wine (e.g. on Windows natively) */ + (nullable OFString *)wineVersion; #endif /** * @brief Returns the path where user data for the application can be stored. * * On UNIX systems, this adheres to the XDG Base Directory specification.@n * On macOS and iOS, it uses the `NSApplicationSupportDirectory` directory.@n * On Windows, it uses the `APPDATA` environment variable.@n * On Haiku, it uses the `B_USER_SETTINGS_DIRECTORY` directory.@n * On AmigaOS and MorphOS, it returns `PROGDIR:`. * * @return The path where user data for the application can be stored */ + (nullable OFIRI *)userDataIRI; /** * @brief Returns the path where user configuration for the application can be * stored. * * On UNIX systems, this adheres to the XDG Base Directory specification.@n * On macOS and iOS, it uses the `Preferences` directory inside of * `NSLibraryDirectory` directory.@n * On Windows, it uses the `APPDATA` environment variable.@n * On Haiku, it uses the `B_USER_SETTINGS_DIRECTORY` directory. * On AmigaOS and MorphOS, it returns `PROGDIR:`. * * @return The path where user configuration for the application can be stored */ + (nullable OFIRI *)userConfigIRI; /** * @brief Returns a path where temporary files for can be stored. * * If possible, returns a temporary directory for the user, otherwise returns a * global temporary directory. * * On UNIX systems, this adheres to the XDG Base Directory specification and * returns `/tmp` if `XDG_RUNTIME_DIR` is not set.@n * On macOS and iOS, this uses `_CS_DARWIN_USER_TEMP_DIR`, falling back to * `/tmp` if this fails.@n * On Windows, it uses `GetTempPath`.@n * On Haiku, it uses the `B_SYSTEM_TEMP_DIRECTORY` directory. * On AmigaOS and MorphOS, it returns `T:`. * * @return A path where temporary files can be stored */ + (nullable OFIRI *)temporaryDirectoryIRI; /** * @brief Returns the vendor of the CPU. * * If the vendor could not be determined, `nil` is returned instead. * * @return The vendor of the CPU */ + (nullable OFString *)CPUVendor; /** * @brief Returns the model of the CPU. * * If the model could not be determined, `nil` is returned instead. * * @return The model of the CPU */ + (nullable OFString *)CPUModel; #if defined(OF_AMD64) || defined(OF_X86) || defined(DOXYGEN) /** * @brief Returns whether the CPU supports MMX. * * @note This method is only available on AMD64 and x86. * * @return Whether the CPU supports MMX */ + (bool)supportsMMX; /** * @brief Returns whether the CPU supports 3DNow!. * * @note This method is only available on AMD64 and x86. * * @return Whether the CPU supports 3DNow! */ + (bool)supports3DNow; /** * @brief Returns whether the CPU supports enhanced 3DNow!. * * @note This method is only available on AMD64 and x86. * * @return Whether the CPU supports enhanced 3DNow! */ + (bool)supportsEnhanced3DNow; /** * @brief Returns whether the CPU supports SSE. * * @note This method is only available on AMD64 and x86. * * @return Whether the CPU supports SSE */ + (bool)supportsSSE; /** * @brief Returns whether the CPU supports SSE2. * * @note This method is only available on AMD64 and x86. * * @return Whether the CPU supports SSE2 */ + (bool)supportsSSE2; /** * @brief Returns whether the CPU supports SSE3. * * @note This method is only available on AMD64 and x86. * * @return Whether the CPU supports SSE3 */ + (bool)supportsSSE3; /** * @brief Returns whether the CPU supports SSSE3. * * @note This method is only available on AMD64 and x86. * * @return Whether the CPU supports SSSE3 */ + (bool)supportsSSSE3; /** * @brief Returns whether the CPU supports SSE4.1. * * @note This method is only available on AMD64 and x86. * * @return Whether the CPU supports SSE4.1 */ + (bool)supportsSSE41; /** * @brief Returns whether the CPU supports SSE4.2. * * @note This method is only available on AMD64 and x86. * * @return Whether the CPU supports SSE4.2 */ + (bool)supportsSSE42; /** * @brief Returns whether the CPU and OS support AVX. * * @note This method is only available on AMD64 and x86. * * @return Whether the CPU and OS support AVX */ + (bool)supportsAVX; /** * @brief Returns whether the CPU and OS support AVX2. * * @note This method is only available on AMD64 and x86. * * @return Whether the CPU and OS support AVX2 */ + (bool)supportsAVX2; /** * @brief Returns whether the CPU supports AES-NI. * * @note This method is only available on AMD64 and x86. * * @return Whether the CPU supports AES-NI */ + (bool)supportsAESNI; /** * @brief Returns whether the CPU supports Intel SHA Extensions. * * @note This method is only available on AMD64 and x86. * * @return Whether the CPU supports Intel SHA Extensions */ + (bool)supportsSHAExtensions; /** * @brief Returns whether the CPU supports fused multiply-add. * * @note This method is only available on AMD64 and x86. * * @return Whether the CPU supports fused multiply-add */ + (bool)supportsFusedMultiplyAdd; /** * @brief Returns whether the CPU supports F16C. * * @note This method is only available on AMD64 and x86. * * @return Whether the CPU supports F16C */ + (bool)supportsF16C; /** * @brief Returns whether the CPU and OS support AVX-512 Foundation. * * @note This method is only available on AMD64 and x86. * * @return Whether the CPU and OS support AVX-512 Foundation */ + (bool)supportsAVX512Foundation; /** * @brief Returns whether the CPU and OS support AVX-512 Conflict Detection * Instructions. * * @note This method is only available on AMD64 and x86. * * @return Whether the CPU and OS support AVX-512 Conflict Detection * Instructions */ + (bool)supportsAVX512ConflictDetectionInstructions; /** * @brief Returns whether the CPU and OS support AVX-512 Exponential and * Reciprocal Instructions. * * @note This method is only available on AMD64 and x86. * * @return Whether the CPU and OS support AVX-512 Exponential and Reciprocal * Instructions */ + (bool)supportsAVX512ExponentialAndReciprocalInstructions; /** * @brief Returns whether the CPU and OS support AVX-512 Prefetch Instructions. * * @note This method is only available on AMD64 and x86. * * @return Whether the CPU and OS support AVX-512 Prefetch Instructions */ + (bool)supportsAVX512PrefetchInstructions; /** * @brief Returns whether the CPU and OS support AVX-512 Vector Length * Extensions. * * @note This method is only available on AMD64 and x86. * * @return Whether the CPU and OS support AVX-512 Vector Length Extensions */ + (bool)supportsAVX512VectorLengthExtensions; /** * @brief Returns whether the CPU and OS support AVX-512 Doubleword and Quadword * Instructions. * * @note This method is only available on AMD64 and x86. * * @return Whether the CPU and OS support AVX-512 Doubleword and Quadword * Instructions */ + (bool)supportsAVX512DoublewordAndQuadwordInstructions; /** * @brief Returns whether the CPU and OS support AVX-512 Byte and Word * Instructions. * * @note This method is only available on AMD64 and x86. * * @return Whether the CPU and OS support AVX-512 Byte and Word Instructions */ + (bool)supportsAVX512ByteAndWordInstructions; /** * @brief Returns whether the CPU and OS support AVX-512 Integer Fused * Multiply-Add. * * @note This method is only available on AMD64 and x86. * * @return Whether the CPU and OS support AVX-512 Integer Fused Multiply-Add */ + (bool)supportsAVX512IntegerFusedMultiplyAdd; /** * @brief Returns whether the CPU and OS support AVX-512 Vector Byte * Manipulation Instructions. * * @note This method is only available on AMD64 and x86. * * @return Whether the CPU and OS support AVX-512 Vector Byte Manipulation * Instructions */ + (bool)supportsAVX512VectorByteManipulationInstructions; /** * @brief Returns whether the CPU and OS support the AVX-512 Vector Population * Count Instruction. * * @note This method is only available on AMD64 and x86. * * @return Whether the CPU and OS support AVX-512 the Vector Population Count * Instruction */ + (bool)supportsAVX512VectorPopulationCountInstruction; /** * @brief Returns whether the CPU and OS support AVX-512 Vector Neural Network * Instructions. * * @note This method is only available on AMD64 and x86. * * @return Whether the CPU and OS support AVX-512 Vector Neural Network * Instructions */ + (bool)supportsAVX512VectorNeuralNetworkInstructions; /** * @brief Returns whether the CPU and OS support AVX-512 Vector Byte * Manipulation Instructions 2. * * @note This method is only available on AMD64 and x86. * * @return Whether the CPU and OS support AVX-512 Vector Byte Manipulation * Instructions 2 */ + (bool)supportsAVX512VectorByteManipulationInstructions2; /** * @brief Returns whether the CPU and OS support AVX-512 Bit Algorithms. * * @note This method is only available on AMD64 and x86. * * @return Whether the CPU and OS support AVX-512 Bit Algorithms */ + (bool)supportsAVX512BitAlgorithms; /** * @brief Returns whether the CPU and OS support AVX-512 Float16 Instructions. * * @note This method is only available on AMD64 and x86. * * @return Whether the CPU and OS support AVX-512 Float16 Instructions */ + (bool)supportsAVX512Float16Instructions; /** * @brief Returns whether the CPU and OS support AVX-512 BFloat16 Instructions. * * @note This method is only available on AMD64 and x86. * * @return Whether the CPU and OS support AVX-512 BFloat16 Instructions */ + (bool)supportsAVX512BFloat16Instructions; #endif #if defined(OF_POWERPC) || defined(OF_POWERPC64) || defined(DOXYGEN) /** * @brief Returns whether the CPU and OS support AltiVec. * * @note This method is only available on PowerPC and PowerPC 64. * * @return Whether the CPU and OS support AltiVec */ + (bool)supportsAltiVec; #endif #if defined(OF_WINDOWS) || defined(DOXYGEN) /** * @brief Returns whether the application is running on Windows NT. * * @note This method is only available on Windows. * * @return Whether the application is running on Windows NT */ + (bool)isWindowsNT; #endif + (instancetype)alloc OF_UNAVAILABLE; - (instancetype)init OF_UNAVAILABLE; @end OF_ASSUME_NONNULL_END #ifdef OF_HAVE_SOCKETS # import "OFSystemInfo+NetworkInterfaces.h" #endif |
Modified src/OFSystemInfo.m from [9f095b0c1c] to [88de548cfa].
1 | /* | | | | | | > | < | < | > | > > > > > > > > > > > > > > > > > > | > < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <limits.h> /* include any libc header to get the libc defines */ #include <setjmp.h> #include <signal.h> #include "unistd_wrapper.h" #include "platform.h" #ifdef HAVE_SYS_UTSNAME_H # include <sys/utsname.h> #endif #if defined(OF_MACOS) || defined(OF_IOS) || defined(OF_NETBSD) # include <sys/sysctl.h> #endif #ifdef OF_AMIGAOS # define Class IntuitionClass # include <exec/execbase.h> # include <proto/exec.h> # undef Class #endif #if defined(OF_AMIGAOS4) # include <exec/exectags.h> #elif defined(OF_MORPHOS) # include <exec/system.h> #endif #ifdef OF_NINTENDO_SWITCH # define id nx_id # import <switch.h> # undef nx_id #endif #ifdef OF_DJGPP # include <dos.h> #endif #import "OFSystemInfo.h" #import "OFApplication.h" #import "OFArray.h" #import "OFData.h" #import "OFDictionary.h" #ifdef OF_HAVE_FILES # import "OFFile.h" # import "OFFileManager.h" #endif #import "OFIRI.h" #import "OFLocale.h" #import "OFNumber.h" #import "OFOnce.h" #import "OFString.h" #import "OFInvalidFormatException.h" #import "OFOpenItemFailedException.h" #if defined(OF_MACOS) || defined(OF_IOS) # ifdef HAVE_SYSDIR_H # include <sysdir.h> # endif #endif #ifdef OF_HAIKU # include <FindDirectory.h> #endif #ifdef OF_QNX # include <sys/syspage.h> #endif |
︙ | ︙ | |||
97 98 99 100 101 102 103 | extern NSSearchPathEnumerationState NSStartSearchPathEnumeration( NSSearchPathDirectory, NSSearchPathDomainMask); extern NSSearchPathEnumerationState NSGetNextSearchPathEnumeration( NSSearchPathEnumerationState, char *); #endif | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | > > | | | | 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | extern NSSearchPathEnumerationState NSStartSearchPathEnumeration( NSSearchPathDirectory, NSSearchPathDomainMask); extern NSSearchPathEnumerationState NSGetNextSearchPathEnumeration( NSSearchPathEnumerationState, char *); #endif #if defined(OF_AMD64) || defined(OF_X86) struct X86Regs { uint32_t eax, ebx, ecx, edx; }; static bool SSESupport; static jmp_buf SSETestEnv; static void SSETestSIGILLHandler(int signum) { longjmp(SSETestEnv, 1); } # ifndef __clang__ # pragma GCC push_options # pragma GCC target("sse") # endif static void SSETest(void) { void (*oldHandler)(int) = signal(SIGILL, SSETestSIGILLHandler); if (setjmp(SSETestEnv) == 0) { __asm__ __volatile__ ( "movaps %%xmm0, %%xmm0" ::: "xmm0" /* clang is unhappy if we don't clobber it */ ); SSESupport = true; } else SSESupport = false; signal(SIGILL, oldHandler); } # ifndef __clang__ # pragma GCC pop_options # endif #endif static size_t pageSize = 4096; static size_t numberOfCPUs = 1; static OFString *operatingSystemName = nil; static OFString *operatingSystemVersion = nil; #ifdef OF_WINDOWS static const char *(*wine_get_version)(void); #endif static void initOperatingSystemName(void) { #if defined(OF_IOS) operatingSystemName = @"iOS"; #elif defined(OF_MACOS) operatingSystemName = @"macOS"; #elif defined(OF_WINDOWS) operatingSystemName = @"Windows"; #elif defined(OF_ANDROID) operatingSystemName = @"Android"; #elif defined(OF_AMIGAOS_M68K) operatingSystemName = @"AmigaOS"; #elif defined(OF_MORPHOS) operatingSystemName = @"MorphOS"; #elif defined(OF_AMIGAOS4) operatingSystemName = @"AmigaOS 4"; #elif defined(OF_WII) operatingSystemName = @"Nintendo Wii"; #elif defined(OF_WII_U) operatingSystemName = @"Nintendo Wii U"; #elif defined(NINTENDO_3DS) operatingSystemName = @"Nintendo 3DS"; #elif defined(OF_NINTENDO_DS) operatingSystemName = @"Nintendo DS"; #elif defined(OF_NINTENDO_SWITCH) operatingSystemName = @"Nintendo Switch"; #elif defined(OF_PSP) operatingSystemName = @"PlayStation Portable"; #elif defined(OF_DJGPP) operatingSystemName = [[OFString alloc] initWithCString: _os_flavor encoding: OFStringEncodingASCII]; #elif defined(HAVE_SYS_UTSNAME_H) && defined(HAVE_UNAME) struct utsname name; if (uname(&name) == -1) return; operatingSystemName = [[OFString alloc] initWithCString: name.sysname encoding: [OFLocale encoding]]; #endif } static void initOperatingSystemVersion(void) { |
︙ | ︙ | |||
226 227 228 229 230 231 232 233 | # endif #elif defined(OF_ANDROID) /* TODO */ #elif defined(OF_AMIGAOS) operatingSystemVersion = [[OFString alloc] initWithFormat: @"Kickstart %u.%u", SysBase->LibNode.lib_Version, SysBase->SoftVer]; #elif defined(OF_WII) || defined(NINTENDO_3DS) || defined(OF_NINTENDO_DS) || \ | > > > | | | | | | | | > | > > > | > | > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | # endif #elif defined(OF_ANDROID) /* TODO */ #elif defined(OF_AMIGAOS) operatingSystemVersion = [[OFString alloc] initWithFormat: @"Kickstart %u.%u", SysBase->LibNode.lib_Version, SysBase->SoftVer]; #elif defined(OF_DJGPP) operatingSystemVersion = [[OFString alloc] initWithFormat: @"%u.%u", _osmajor, _osminor]; #elif defined(OF_WII) || defined(NINTENDO_3DS) || defined(OF_NINTENDO_DS) || \ defined(OF_PSP) /* Intentionally nothing */ #elif defined(HAVE_SYS_UTSNAME_H) && defined(HAVE_UNAME) struct utsname name; if (uname(&name) == -1) return; operatingSystemVersion = [[OFString alloc] initWithCString: name.release encoding: [OFLocale encoding]]; #endif } #ifdef OF_NINTENDO_SWITCH static OFIRI *tmpFSIRI = nil; static void mountTmpFS(void) { if (R_SUCCEEDED(fsdevMountTemporaryStorage("tmpfs"))) tmpFSIRI = [[OFIRI alloc] initFileIRIWithPath: @"tmpfs:/" isDirectory: true]; } #endif #if defined(OF_AMD64) || defined(OF_X86) static OF_INLINE struct X86Regs OF_CONST_FUNC x86CPUID(uint32_t eax, uint32_t ecx) { struct X86Regs regs; # if defined(OF_AMD64) && defined(__GNUC__) __asm__ ( "cpuid" : "=a" (regs.eax), "=b" (regs.ebx), "=c" (regs.ecx), "=d" (regs.edx) : "a" (eax), "c" (ecx) ); # elif defined(OF_X86) && defined(__GNUC__) /* * This workaround is required by older GCC versions when using -fPIC, * as ebx is a special register in PIC code. Yes, GCC is indeed not * able to just push a register onto the stack before the __asm__ block * and to pop it afterwards. */ __asm__ ( "xchgl %%ebx, %%edi\n\t" "cpuid\n\t" "xchgl %%edi, %%ebx" : "=a" (regs.eax), "=D" (regs.ebx), "=c" (regs.ecx), "=d" (regs.edx) : "a" (eax), "c" (ecx) ); # else memset(®s, 0, sizeof(regs)); # endif return regs; } static OF_INLINE struct X86Regs x86XCR(uint32_t ecx) { struct X86Regs regs = { 0 }; if (!(x86CPUID(1, 0).ecx & (1u << 27))) return regs; __asm__ ( "xgetbv" : "=a" (regs.eax), "=d" (regs.edx) : "c" (ecx) ); return regs; } #endif @implementation OFSystemInfo + (void)initialize { long tmp; if (self != [OFSystemInfo class]) return; #if defined(OF_AMD64) || defined(OF_X86) /* * Do this as early as possible, as it involves signals. * Required as cpuid can return SSE support while the OS has not * enabled it. */ SSETest(); #endif #if defined(OF_WINDOWS) HANDLE module; SYSTEM_INFO si; GetSystemInfo(&si); pageSize = si.dwPageSize; numberOfCPUs = si.dwNumberOfProcessors; if ((module = GetModuleHandle("ntdll.dll")) != NULL) wine_get_version = (const char *(*)(void)) GetProcAddress(module, "wine_get_version"); #elif defined(OF_QNX) if ((tmp = sysconf(_SC_PAGESIZE)) > 0) pageSize = tmp; numberOfCPUs = _syspage_ptr->num_cpu; #else # if defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE) if ((tmp = sysconf(_SC_PAGESIZE)) > 0) |
︙ | ︙ | |||
364 365 366 367 368 369 370 | { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, initOperatingSystemVersion); return operatingSystemVersion; } | > > > > > > > > > > > | | 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 | { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, initOperatingSystemVersion); return operatingSystemVersion; } #ifdef OF_WINDOWS + (OFString *)wineVersion { if (wine_get_version != NULL) return [OFString stringWithCString: wine_get_version() encoding: [OFLocale encoding]]; return nil; } #endif + (OFIRI *)userDataIRI { #ifdef OF_HAVE_FILES # if defined(OF_MACOS) || defined(OF_IOS) char pathC[PATH_MAX]; OFMutableString *path; # ifdef HAVE_SYSDIR_START_SEARCH_PATH_ENUMERATION |
︙ | ︙ | |||
406 407 408 409 410 411 412 | [path deleteCharactersInRange: OFMakeRange(0, 1)]; [path insertString: home atIndex: 0]; } [path makeImmutable]; | | | | | > > | | | | | | 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 | [path deleteCharactersInRange: OFMakeRange(0, 1)]; [path insertString: home atIndex: 0]; } [path makeImmutable]; return [OFIRI fileIRIWithPath: path isDirectory: true]; # elif defined(OF_WINDOWS) OFDictionary *env = [OFApplication environment]; OFString *appData; if ((appData = [env objectForKey: @"APPDATA"]) == nil) return nil; return [OFIRI fileIRIWithPath: appData isDirectory: true]; # elif defined(OF_HAIKU) char pathC[PATH_MAX]; if (find_directory(B_USER_SETTINGS_DIRECTORY, 0, false, pathC, PATH_MAX) != B_OK) return nil; return [OFIRI fileIRIWithPath: [OFString stringWithUTF8String: pathC] isDirectory: true]; # elif defined(OF_AMIGAOS) return [OFIRI fileIRIWithPath: @"PROGDIR:" isDirectory: true]; # elif defined(OF_WII) || defined(OF_NINTENDO_3DS) return [[OFFileManager defaultManager] currentDirectoryIRI]; # else OFDictionary *env = [OFApplication environment]; OFString *var; OFIRI *IRI; void *pool; if ((var = [env objectForKey: @"XDG_DATA_HOME"]) != nil && var.length > 0) return [OFIRI fileIRIWithPath: var isDirectory: true]; if ((var = [env objectForKey: @"HOME"]) == nil) return nil; pool = objc_autoreleasePoolPush(); var = [OFString pathWithComponents: [OFArray arrayWithObjects: var, @".local", @"share", nil]]; IRI = [[OFIRI alloc] initFileIRIWithPath: var isDirectory: true]; objc_autoreleasePoolPop(pool); return [IRI autorelease]; # endif #else return nil; #endif } + (OFIRI *)userConfigIRI { #ifdef OF_HAVE_FILES # if defined(OF_MACOS) || defined(OF_IOS) char pathC[PATH_MAX]; OFMutableString *path; # ifdef HAVE_SYSDIR_START_SEARCH_PATH_ENUMERATION |
︙ | ︙ | |||
496 497 498 499 500 501 502 | [path deleteCharactersInRange: OFMakeRange(0, 1)]; [path insertString: home atIndex: 0]; } [path appendString: @"/Preferences"]; [path makeImmutable]; | | | | | > > | | | | | | | | | | > > | | > | > > > | | | | 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 | [path deleteCharactersInRange: OFMakeRange(0, 1)]; [path insertString: home atIndex: 0]; } [path appendString: @"/Preferences"]; [path makeImmutable]; return [OFIRI fileIRIWithPath: path isDirectory: true]; # elif defined(OF_WINDOWS) OFDictionary *env = [OFApplication environment]; OFString *appData; if ((appData = [env objectForKey: @"APPDATA"]) == nil) return nil; return [OFIRI fileIRIWithPath: appData isDirectory: true]; # elif defined(OF_HAIKU) char pathC[PATH_MAX]; if (find_directory(B_USER_SETTINGS_DIRECTORY, 0, false, pathC, PATH_MAX) != B_OK) return nil; return [OFIRI fileIRIWithPath: [OFString stringWithUTF8String: pathC] isDirectory: true]; # elif defined(OF_AMIGAOS) return [OFIRI fileIRIWithPath: @"PROGDIR:" isDirectory: true]; # elif defined(OF_WII) || defined(OF_NINTENDO_3DS) return [[OFFileManager defaultManager] currentDirectoryIRI]; # else OFDictionary *env = [OFApplication environment]; OFString *var; if ((var = [env objectForKey: @"XDG_CONFIG_HOME"]) != nil && var.length > 0) return [OFIRI fileIRIWithPath: var isDirectory: true]; if ((var = [env objectForKey: @"HOME"]) == nil) return nil; var = [var stringByAppendingPathComponent: @".config"]; return [OFIRI fileIRIWithPath: var isDirectory: true]; # endif #else return nil; #endif } + (OFIRI *)temporaryDirectoryIRI { #ifdef OF_HAVE_FILES # if defined(OF_MACOS) || defined(OF_IOS) char buffer[PATH_MAX]; size_t length; OFString *path; if ((length = confstr(_CS_DARWIN_USER_TEMP_DIR, buffer, PATH_MAX)) == 0) return [OFIRI fileIRIWithPath: @"/tmp" isDirectory: true]; path = [OFString stringWithCString: buffer encoding: [OFLocale encoding] length: length - 1]; return [OFIRI fileIRIWithPath: path isDirectory: true]; # elif defined(OF_WINDOWS) OFString *path; if ([self isWindowsNT]) { wchar_t buffer[PATH_MAX]; if (!GetTempPathW(PATH_MAX, buffer)) return nil; path = [OFString stringWithUTF16String: buffer]; } else { char buffer[PATH_MAX]; if (!GetTempPathA(PATH_MAX, buffer)) return nil; path = [OFString stringWithCString: buffer encoding: [OFLocale encoding]]; } return [OFIRI fileIRIWithPath: path isDirectory: true]; # elif defined(OF_HAIKU) char pathC[PATH_MAX]; if (find_directory(B_SYSTEM_TEMP_DIRECTORY, 0, false, pathC, PATH_MAX) != B_OK) return nil; return [OFIRI fileIRIWithPath: [OFString stringWithUTF8String: pathC] isDirectory: true]; # elif defined(OF_AMIGAOS) return [OFIRI fileIRIWithPath: @"T:" isDirectory: true]; # elif defined(OF_MSDOS) OFString *path = [[OFApplication environment] objectForKey: @"TEMP"]; if (path == nil) return nil; return [OFIRI fileIRIWithPath: path isDirectory: true]; # elif defined(OF_MINT) return [OFIRI fileIRIWithPath: @"u:\\tmp" isDirectory: true]; # elif defined(OF_WII) || defined(OF_NINTENDO_3DS) return [[OFFileManager defaultManager] currentDirectoryIRI]; # elif defined(OF_NINTENDO_SWITCH) static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, mountTmpFS); return tmpFSIRI; # else OFString *path; path = [[OFApplication environment] objectForKey: @"XDG_RUNTIME_DIR"]; if (path != nil) return [OFIRI fileIRIWithPath: path isDirectory: true]; path = [[OFApplication environment] objectForKey: @"TMPDIR"]; if (path != nil) return [OFIRI fileIRIWithPath: path isDirectory: true]; return [OFIRI fileIRIWithPath: @"/tmp" isDirectory: true]; # endif #else return nil; #endif } + (OFString *)CPUVendor { #if (defined(OF_AMD64) || defined(OF_X86)) && defined(__GNUC__) struct X86Regs regs = x86CPUID(0, 0); uint32_t buffer[3]; if (regs.eax == 0) return nil; buffer[0] = regs.ebx; |
︙ | ︙ | |||
637 638 639 640 641 642 643 | #else return nil; #endif } + (OFString *)CPUModel { | | | 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 | #else return nil; #endif } + (OFString *)CPUModel { #if (defined(OF_AMD64) || defined(OF_X86)) && defined(__GNUC__) struct X86Regs regs = x86CPUID(0x80000000, 0); uint32_t buffer[12]; size_t i; if (regs.eax < 0x80000004) return nil; |
︙ | ︙ | |||
696 697 698 699 700 701 702 | else return @"68000"; #else return nil; #endif } | | > > > > > > | > > > > > > > | > | > | > | > | > | | > | > | > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 | else return @"68000"; #else return nil; #endif } #if defined(OF_AMD64) || defined(OF_X86) + (bool)supportsMMX { return (x86CPUID(0, 0).eax >= 1 && x86CPUID(1, 0).edx & (1u << 23)); } + (bool)supports3DNow { return (x86CPUID(0x80000000, 0).eax >= 0x80000001 && x86CPUID(0x80000001, 0).edx & (1u << 31)); } + (bool)supportsEnhanced3DNow { return (x86CPUID(0x80000000, 0).eax >= 0x80000001 && x86CPUID(0x80000001, 0).edx & (1u << 30)); } + (bool)supportsSSE { return SSESupport && (x86CPUID(0, 0).eax >= 1 && x86CPUID(1, 0).edx & (1u << 25)); } + (bool)supportsSSE2 { return SSESupport && (x86CPUID(0, 0).eax >= 1 && x86CPUID(1, 0).edx & (1u << 26)); } + (bool)supportsSSE3 { return SSESupport && (x86CPUID(0, 0).eax >= 1 && x86CPUID(1, 0).ecx & (1u << 0)); } + (bool)supportsSSSE3 { return SSESupport && (x86CPUID(0, 0).eax >= 1 && x86CPUID(1, 0).ecx & (1u << 9)); } + (bool)supportsSSE41 { return SSESupport && (x86CPUID(0, 0).eax >= 1 && x86CPUID(1, 0).ecx & (1u << 19)); } + (bool)supportsSSE42 { return SSESupport && (x86CPUID(0, 0).eax >= 1 && x86CPUID(1, 0).ecx & (1u << 20)); } + (bool)supportsAVX { return ((x86CPUID(0, 0).eax >= 1 && x86CPUID(1, 0).ecx & (1u << 28)) && (x86XCR(0).eax & 0x6) == 0x6); } + (bool)supportsAVX2 { return ((x86CPUID(0, 0).eax >= 7 && (x86CPUID(7, 0).ebx & (1u << 5))) && (x86XCR(0).eax & 0x6) == 0x6); } + (bool)supportsAESNI { return (x86CPUID(0, 0).eax >= 1 && x86CPUID(1, 0).ecx & (1u << 25)); } + (bool)supportsSHAExtensions { return (x86CPUID(0, 0).eax >= 7 && x86CPUID(7, 0).ebx & (1u << 29)); } + (bool)supportsFusedMultiplyAdd { return (x86CPUID(0, 0).eax >= 1 && x86CPUID(1, 0).ecx & (1u << 12)); } + (bool)supportsF16C { return (x86CPUID(0, 0).eax >= 1 && x86CPUID(1, 0).ecx & (1u << 29)); } + (bool)supportsAVX512Foundation { return ((x86CPUID(0, 0).eax >= 7 && x86CPUID(7, 0).ebx & (1u << 16)) && (x86XCR(0).eax & 0xE6) == 0xE6); } + (bool)supportsAVX512ConflictDetectionInstructions { return ((x86CPUID(0, 0).eax >= 7 && x86CPUID(7, 0).ebx & (1u << 28)) && (x86XCR(0).eax & 0xE6) == 0xE6); } + (bool)supportsAVX512ExponentialAndReciprocalInstructions { return ((x86CPUID(0, 0).eax >= 7 && x86CPUID(7, 0).ebx & (1u << 27)) && (x86XCR(0).eax & 0xE6) == 0xE6); } + (bool)supportsAVX512PrefetchInstructions { return ((x86CPUID(0, 0).eax >= 7 && x86CPUID(7, 0).ebx & (1u << 26)) && (x86XCR(0).eax & 0xE6) == 0xE6); } + (bool)supportsAVX512VectorLengthExtensions { return ((x86CPUID(0, 0).eax >= 7 && x86CPUID(7, 0).ebx & (1u << 31)) && (x86XCR(0).eax & 0xE6) == 0xE6); } + (bool)supportsAVX512DoublewordAndQuadwordInstructions { return ((x86CPUID(0, 0).eax >= 7 && x86CPUID(7, 0).ebx & (1u << 17)) && (x86XCR(0).eax & 0xE6) == 0xE6); } + (bool)supportsAVX512ByteAndWordInstructions { return ((x86CPUID(0, 0).eax >= 7 && x86CPUID(7, 0).ebx & (1u << 30)) && (x86XCR(0).eax & 0xE6) == 0xE6); } + (bool)supportsAVX512IntegerFusedMultiplyAdd { return ((x86CPUID(0, 0).eax >= 7 && x86CPUID(7, 0).ebx & (1u << 21)) && (x86XCR(0).eax & 0xE6) == 0xE6); } + (bool)supportsAVX512VectorByteManipulationInstructions { return ((x86CPUID(0, 0).eax >= 7 && x86CPUID(7, 0).ecx & (1u << 1)) && (x86XCR(0).eax & 0xE6) == 0xE6); } + (bool)supportsAVX512VectorPopulationCountInstruction { return ((x86CPUID(0, 0).eax >= 7 && x86CPUID(7, 0).ecx & (1u << 14)) && (x86XCR(0).eax & 0xE6) == 0xE6); } + (bool)supportsAVX512VectorNeuralNetworkInstructions { return ((x86CPUID(0, 0).eax >= 7 && x86CPUID(7, 0).ecx & (1u << 11)) && (x86XCR(0).eax & 0xE6) == 0xE6); } + (bool)supportsAVX512VectorByteManipulationInstructions2 { return ((x86CPUID(0, 0).eax >= 7 && x86CPUID(7, 0).ecx & (1u << 6)) && (x86XCR(0).eax & 0xE6) == 0xE6); } + (bool)supportsAVX512BitAlgorithms { return ((x86CPUID(0, 0).eax >= 7 && x86CPUID(7, 0).ecx & (1u << 12)) && (x86XCR(0).eax & 0xE6) == 0xE6); } + (bool)supportsAVX512Float16Instructions { return ((x86CPUID(0, 0).eax >= 7 && x86CPUID(7, 0).edx & (1u << 23)) && (x86XCR(0).eax & 0xE6) == 0xE6); } + (bool)supportsAVX512BFloat16Instructions { return ((x86CPUID(0, 0).eax >= 7 && x86CPUID(7, 1).eax & (1u << 5)) && (x86XCR(0).eax & 0xE6) == 0xE6); } #endif #if defined(OF_POWERPC) || defined(OF_POWERPC64) + (bool)supportsAltiVec { # if defined(OF_MACOS) |
︙ | ︙ |
Modified src/OFTCPSocket.h from [522e53453c] to [aafb477b2e].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFStreamSocket.h" #import "OFRunLoop.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ | |||
76 77 78 79 80 81 82 | #ifdef OF_HAVE_CLASS_PROPERTIES @property (class, nullable, copy, nonatomic) OFString *SOCKS5Host; @property (class, nonatomic) uint16_t SOCKS5Port; #endif #if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) /** | | | | | | | 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | #ifdef OF_HAVE_CLASS_PROPERTIES @property (class, nullable, copy, nonatomic) OFString *SOCKS5Host; @property (class, nonatomic) uint16_t SOCKS5Port; #endif #if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) /** * @brief Whether the socket sends keep-alives for the connection. * * @warning This is not available on the Wii or Nintendo 3DS! * * @throw OFGetOptionFailedException The option could not be retrieved * @throw OFSetOptionFailedException The option could not be set */ @property (nonatomic) bool sendsKeepAlives; #endif #ifndef OF_WII /** * @brief Whether sending segments can be delayed. Setting this to `false` sets * TCP_NODELAY on the socket. * * @warning This is not available on the Wii! * * @throw OFGetOptionFailedException The option could not be retrieved * @throw OFSetOptionFailedException The option could not be set */ @property (nonatomic) bool canDelaySendingSegments; #endif /** * @brief The host to use as a SOCKS5 proxy. */ |
︙ | ︙ | |||
153 154 155 156 157 158 159 | /** * @brief Connects the OFTCPSocket to the specified destination. * * @param host The host to connect to * @param port The port on the host to connect to * @throw OFConnectIPSocketFailedException Connecting failed | | | > | 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | /** * @brief Connects the OFTCPSocket to the specified destination. * * @param host The host to connect to * @param port The port on the host to connect to * @throw OFConnectIPSocketFailedException Connecting failed * @throw OFAlreadyOpenException The socket is already connected or bound */ - (void)connectToHost: (OFString *)host port: (uint16_t)port; /** * @brief Asynchronously connects the OFTCPSocket to the specified destination. * * @param host The host to connect to * @param port The port on the host to connect to */ - (void)asyncConnectToHost: (OFString *)host port: (uint16_t)port; /** * @brief Asynchronously connects the OFTCPSocket to the specified destination. * * @param host The host to connect to * @param port The port on the host to connect to * @param runLoopMode The run loop mode in which to perform the asynchronous * connect */ - (void)asyncConnectToHost: (OFString *)host port: (uint16_t)port runLoopMode: (OFRunLoopMode)runLoopMode; #ifdef OF_HAVE_BLOCKS /** |
︙ | ︙ | |||
193 194 195 196 197 198 199 | block: (OFTCPSocketAsyncConnectBlock)block; /** * @brief Asynchronously connects the OFTCPSocket to the specified destination. * * @param host The host to connect to * @param port The port on the host to connect to | | > | | | | 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | block: (OFTCPSocketAsyncConnectBlock)block; /** * @brief Asynchronously connects the OFTCPSocket to the specified destination. * * @param host The host to connect to * @param port The port on the host to connect to * @param runLoopMode The run loop mode in which to perform the asynchronous * connect * @param block The block to execute once the connection has been established */ - (void)asyncConnectToHost: (OFString *)host port: (uint16_t)port runLoopMode: (OFRunLoopMode)runLoopMode block: (OFTCPSocketAsyncConnectBlock)block; #endif /** * @brief Binds the socket to the specified host and port. * * @param host The host to bind to. Use `@"0.0.0.0"` for IPv4 or `@"::"` for * IPv6 to bind to all. * @param port The port to bind to. If the port is 0, an unused port will be * chosen, which can be obtained using the return value. * @return The address the socket was bound to * @throw OFBindIPSocketFailedException Binding failed * @throw OFAlreadyOpenException The socket is already connected or bound */ - (OFSocketAddress)bindToHost: (OFString *)host port: (uint16_t)port; @end OF_ASSUME_NONNULL_END |
Modified src/OFTCPSocket.m from [bab73573da] to [80e19ef290].
1 | /* | | | | | | > > > > | < > | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #ifndef _XOPEN_SOURCE_EXTENDED # define _XOPEN_SOURCE_EXTENDED #endif #define _HPUX_ALT_XOPEN_SOCKET_API #include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> |
︙ | ︙ | |||
39 40 41 42 43 44 45 | #import "OFRunLoop+Private.h" #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFString.h" #import "OFTCPSocketSOCKS5Connector.h" #import "OFThread.h" | | | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | #import "OFRunLoop+Private.h" #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFString.h" #import "OFTCPSocketSOCKS5Connector.h" #import "OFThread.h" #import "OFAlreadyOpenException.h" #import "OFBindIPSocketFailedException.h" #import "OFGetOptionFailedException.h" #import "OFNotImplementedException.h" #import "OFNotOpenException.h" #import "OFSetOptionFailedException.h" static const OFRunLoopMode connectRunLoopMode = |
︙ | ︙ | |||
137 138 139 140 141 142 143 | errNo: (int *)errNo { #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) int flags; #endif if (_socket != OFInvalidSocketHandle) | | | 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | errNo: (int *)errNo { #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) int flags; #endif if (_socket != OFInvalidSocketHandle) @throw [OFAlreadyOpenException exceptionWithObject: self]; if ((_socket = socket( ((struct sockaddr *)&address->sockaddr)->sa_family, SOCK_STREAM | SOCK_CLOEXEC, 0)) == OFInvalidSocketHandle) { *errNo = OFSocketErrNo(); return false; } |
︙ | ︙ | |||
285 286 287 288 289 290 291 | block: (delegate == nil ? block : NULL)] autorelease] startWithRunLoopMode: runLoopMode]; objc_autoreleasePoolPop(pool); } #endif | | | | 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | block: (delegate == nil ? block : NULL)] autorelease] startWithRunLoopMode: runLoopMode]; objc_autoreleasePoolPop(pool); } #endif - (OFSocketAddress)bindToHost: (OFString *)host port: (uint16_t)port { const int one = 1; void *pool = objc_autoreleasePoolPush(); OFData *socketAddresses; OFSocketAddress address; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) int flags; #endif if (_socket != OFInvalidSocketHandle) @throw [OFAlreadyOpenException exceptionWithObject: self]; if (_SOCKS5Host != nil) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; socketAddresses = [[OFThread DNSResolver] resolveAddressesForHost: host |
︙ | ︙ | |||
357 358 359 360 361 362 363 | while (rnd < 1024) rnd = (uint16_t)rand(); OFSocketAddressSetIPPort(&address, rnd); if ((ret = bind(_socket, (struct sockaddr *)&address.sockaddr, | | < < < < < < < | > | > | | | | < | < < | 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 | while (rnd < 1024) rnd = (uint16_t)rand(); OFSocketAddressSetIPPort(&address, rnd); if ((ret = bind(_socket, (struct sockaddr *)&address.sockaddr, address.length)) == 0) break; if (OFSocketErrNo() != EADDRINUSE) { int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPSocketFailedException exceptionWithHost: host port: port socket: self errNo: errNo]; } } } #endif #if !defined(OF_HPUX) && !defined(OF_WII) && !defined(OF_NINTENDO_3DS) memset(&address, 0, sizeof(address)); address.length = (socklen_t)sizeof(address.sockaddr); if (OFGetSockName(_socket, (struct sockaddr *)&address.sockaddr, &address.length) != 0) { int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPSocketFailedException exceptionWithHost: host port: port socket: self errNo: errNo]; } switch (((struct sockaddr *)&address.sockaddr)->sa_family) { case AF_INET: address.family = OFSocketAddressFamilyIPv4; break; # ifdef OF_HAVE_IPV6 case AF_INET6: address.family = OFSocketAddressFamilyIPv6; break; # endif default: closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPSocketFailedException exceptionWithHost: host port: port socket: self errNo: EAFNOSUPPORT]; } #endif objc_autoreleasePoolPop(pool); return address; } #if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) - (void)setSendsKeepAlives: (bool)sendsKeepAlives { int v = sendsKeepAlives; |
︙ | ︙ |
Modified src/OFTCPSocketSOCKS5Connector.h from [a83f3eec6d] to [3783ed72e5].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFTCPSocket.h" OF_ASSUME_NONNULL_BEGIN @class OFString; |
︙ | ︙ |
Modified src/OFTCPSocketSOCKS5Connector.m from [f6cfb53e62] to [c1282bd51e].
1 | /* | | | | | | > > > > | < > | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #import "OFTCPSocketSOCKS5Connector.h" #import "OFData.h" #import "OFRunLoop.h" #import "OFString.h" |
︙ | ︙ | |||
264 265 266 267 268 269 270 | _SOCKS5State = stateReadAddress; [_socket asyncReadIntoBuffer: _buffer exactLength: addressLength[0] + 2 runLoopMode: runLoopMode]; return false; default: | | | 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | _SOCKS5State = stateReadAddress; [_socket asyncReadIntoBuffer: _buffer exactLength: addressLength[0] + 2 runLoopMode: runLoopMode]; return false; default: OFAssert(0); return false; } } - (OFData *)stream: (OFStream *)sock didWriteData: (OFData *)data bytesWritten: (size_t)bytesWritten |
︙ | ︙ | |||
301 302 303 304 305 306 307 | _SOCKS5State = stateReadResponse; [_socket asyncReadIntoBuffer: _buffer exactLength: 4 runLoopMode: runLoopMode]; return nil; default: | | | 304 305 306 307 308 309 310 311 312 313 314 315 | _SOCKS5State = stateReadResponse; [_socket asyncReadIntoBuffer: _buffer exactLength: 4 runLoopMode: runLoopMode]; return nil; default: OFAssert(0); return nil; } } @end |
Modified src/OFTLSKey.h from [daee12b5cc] to [0f3980a25d].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "objfw-defs.h" #include <errno.h> #include "platform.h" |
︙ | ︙ |
Modified src/OFTLSKey.m from [e3604d121c] to [85bc215e23].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include "platform.h" #if defined(OF_HAVE_PTHREADS) |
︙ | ︙ |
Modified src/OFTLSStream.h from [8cbbbbbe33] to [8c96ff50b1].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFStream.h" #import "OFRunLoop.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ | |||
57 58 59 60 61 62 63 | * * @brief A class that provides Transport Layer Security on top of a stream. * * This class is a class cluster and returns a suitable OFTLSStream subclass, * if available. * * Subclasses need to override @ref lowlevelReadIntoBuffer:length:, | | > | < < < > | | | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | * * @brief A class that provides Transport Layer Security on top of a stream. * * This class is a class cluster and returns a suitable OFTLSStream subclass, * if available. * * Subclasses need to override @ref lowlevelReadIntoBuffer:length:, * @ref lowlevelWriteBuffer:length:, * @ref lowlevelHasDataInReadBuffer and * @ref asyncPerformClientHandshakeWithHost:runLoopMode:. * * In order to get access to the underlying stream, @ref underlyingStream can * be used. */ @interface OFTLSStream: OFStream <OFReadyForReadingObserving, OFReadyForWritingObserving> { OFStream <OFReadyForReadingObserving, OFReadyForWritingObserving> *_underlyingStream; bool _verifiesCertificates; |
︙ | ︙ | |||
105 106 107 108 109 110 111 | * stream. * * @param stream The stream to use as underlying stream. Must not be closed * before the TLS stream is closed. * @return A new, autoreleased TLS stream */ + (instancetype)streamWithStream: (OFStream <OFReadyForReadingObserving, | | > > > | | | | | 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | * stream. * * @param stream The stream to use as underlying stream. Must not be closed * before the TLS stream is closed. * @return A new, autoreleased TLS stream */ + (instancetype)streamWithStream: (OFStream <OFReadyForReadingObserving, OFReadyForWritingObserving> *)stream; /** * @brief Initializes the TLS stream with the specified stream as its * underlying stream. * * @note The delegate of the specified stream will be changed to the TLS * stream. You must not change this before the TLS session is completed. * * @param stream The stream to use as underlying stream. Must not be closed * before the TLS stream is closed. * @return An initialized TLS stream */ - (instancetype)initWithStream: (OFStream <OFReadyForReadingObserving, OFReadyForWritingObserving> *)stream OF_DESIGNATED_INITIALIZER; /** * @brief Asynchronously performs the TLS client handshake for the specified * host and calls the delegate afterwards. * * @param host The host to perform the handshake with * @throw OFTLSHandshakeFailedException The TLS handshake failed * @throw OFAlreadyOpenException The handshake was already performed */ - (void)asyncPerformClientHandshakeWithHost: (OFString *)host; /** * @brief Asynchronously performs the TLS client handshake for the specified * host and calls the delegate afterwards. * * @param host The host to perform the handshake with * @param runLoopMode The run loop mode in which to perform the async handshake * @throw OFTLSHandshakeFailedException The TLS handshake failed * @throw OFAlreadyOpenException The handshake was already performed */ - (void)asyncPerformClientHandshakeWithHost: (OFString *)host runLoopMode: (OFRunLoopMode)runLoopMode; /** * @brief Performs the TLS client handshake for the specified host. * * @param host The host to perform the handshake with * @throw OFTLSHandshakeFailedException The TLS handshake failed * @throw OFAlreadyOpenException The handshake was already performed */ - (void)performClientHandshakeWithHost: (OFString *)host; @end #ifdef __cplusplus extern "C" { #endif |
︙ | ︙ |
Modified src/OFTLSStream.m from [01bd29e506] to [cdc1005db6].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFTLSStream.h" #import "OFDate.h" |
︙ | ︙ | |||
137 138 139 140 141 142 143 | } - (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length { OF_UNRECOGNIZED_SELECTOR } | < < < < < < | 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | } - (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length { OF_UNRECOGNIZED_SELECTOR } - (bool)lowlevelIsAtEndOfStream { return _underlyingStream.atEndOfStream; } - (int)fileDescriptorForReading { |
︙ | ︙ |
Added src/OFTXTDNSResourceRecord.h version [c62102f948].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFDNSResourceRecord.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFTXTDNSResourceRecord \ * OFDNSResourceRecord.h ObjFW/OFDNSResourceRecord.h * * @brief A class representing a TXT DNS resource record. */ OF_SUBCLASSING_RESTRICTED @interface OFTXTDNSResourceRecord: OFDNSResourceRecord { OFArray OF_GENERIC(OFData *) *_textStrings; } /** * @brief The text of the resource record. */ @property (readonly, nonatomic) OFArray OF_GENERIC(OFData *) *textStrings; - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFTXTDNSResourceRecord with the * specified name, class, text data and time to live. * * @param name The name for the resource record * @param DNSClass The class code for the resource record * @param textStrings An array of text strings for the resource record * @param TTL The time to live for the resource record * @return An initialized OFTXTDNSResourceRecord */ - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass textStrings: (OFArray OF_GENERIC(OFData *) *)textStrings TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END |
Added src/OFTXTDNSResourceRecord.m version [1f785aa826].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFTXTDNSResourceRecord.h" #import "OFArray.h" #import "OFData.h" @implementation OFTXTDNSResourceRecord @synthesize textStrings = _textStrings; - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass textStrings: (OFArray OF_GENERIC(OFData *) *)textStrings TTL: (uint32_t)TTL { self = [super initWithName: name DNSClass: DNSClass recordType: OFDNSRecordTypeTXT TTL: TTL]; @try { _textStrings = [textStrings copy]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_textStrings release]; [super dealloc]; } - (bool)isEqual: (id)object { OFTXTDNSResourceRecord *record; if (object == self) return true; if (![object isKindOfClass: [OFTXTDNSResourceRecord class]]) return false; record = object; if (record->_name != _name && ![record->_name isEqual: _name]) return false; if (record->_DNSClass != _DNSClass) return false; if (record->_recordType != _recordType) return false; if (record->_textStrings != _textStrings && ![record->_textStrings isEqual: _textStrings]) return false; return true; } - (unsigned long)hash { unsigned long hash; OFHashInit(&hash); OFHashAddHash(&hash, _name.hash); OFHashAddByte(&hash, _DNSClass >> 8); OFHashAddByte(&hash, _DNSClass); OFHashAddByte(&hash, _recordType >> 8); OFHashAddByte(&hash, _recordType); OFHashAddHash(&hash, _textStrings.hash); OFHashFinalize(&hash); return hash; } - (OFString *)description { void *pool = objc_autoreleasePoolPush(); OFMutableString *text = [OFMutableString string]; bool first = true; OFString *ret; for (OFData *string in _textStrings) { const unsigned char *stringItems = string.items; size_t stringCount = string.count; if (first) { first = false; [text appendString: @"\""]; } else [text appendString: @" \""]; for (size_t i = 0; i < stringCount; i++) { if (stringItems[i] == '\\') [text appendString: @"\\\\"]; else if (stringItems[i] == '"') [text appendString: @"\\\""]; else if (stringItems[i] < 0x20) [text appendFormat: @"\\x%02X", stringItems[i]]; else if (stringItems[i] < 0x7F) [text appendFormat: @"%c", stringItems[i]]; else [text appendFormat: @"\\x%02X", stringItems[i]]; } [text appendString: @"\""]; } ret = [OFString stringWithFormat: @"<%@:\n" @"\tName = %@\n" @"\tClass = %@\n" @"\tText strings = %@\n" @"\tTTL = %" PRIu32 "\n" @">", self.className, _name, OFDNSClassName(_DNSClass), text, _TTL]; [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } @end |
Added src/OFTaggedPointerColor.h version [6af23aea62].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFColor.h" OF_ASSUME_NONNULL_BEGIN @interface OFTaggedPointerColor: OFColor + (OFTaggedPointerColor *)colorWithRed: (uint8_t)red green: (uint8_t)green blue: (uint8_t)blue; @end OF_ASSUME_NONNULL_END |
Added src/OFTaggedPointerColor.m version [0843e7004a].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFTaggedPointerColor.h" static int colorTag; @implementation OFTaggedPointerColor + (void)initialize { if (self == [OFTaggedPointerColor class]) colorTag = objc_registerTaggedPointerClass(self); } + (OFTaggedPointerColor *)colorWithRed: (uint8_t)red green: (uint8_t)green blue: (uint8_t)blue { return objc_createTaggedPointer(colorTag, (uintptr_t)red << 16 | (uintptr_t)green << 8 | (uintptr_t)blue); } - (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; } OF_SINGLETON_METHODS @end |
Added src/OFTaggedPointerDate.h version [ed9cd669e2].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFDate.h" OF_ASSUME_NONNULL_BEGIN #if UINTPTR_MAX == UINT64_MAX @interface OFTaggedPointerDate: OFDate + (OFTaggedPointerDate *)dateWithUInt64TimeIntervalSince1970: (uint64_t)value; @end #endif OF_ASSUME_NONNULL_END |
Added src/OFTaggedPointerDate.m version [3a7c65c57a].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFTaggedPointerDate.h" #if UINTPTR_MAX == UINT64_MAX static int dateTag; @implementation OFTaggedPointerDate + (void)initialize { if (self == [OFTaggedPointerDate class]) dateTag = objc_registerTaggedPointerClass(self); } + (OFTaggedPointerDate *)dateWithUInt64TimeIntervalSince1970: (uint64_t)value { return objc_createTaggedPointer(dateTag, value & ~(UINT64_C(4) << 60)); } - (OFTimeInterval)timeIntervalSince1970 { uint64_t value = (uint64_t)object_getTaggedPointerValue(self); value |= UINT64_C(4) << 60; return OFFromBigEndianDouble(OFRawUInt64ToDouble(OFToBigEndian64( value))); } OF_SINGLETON_METHODS @end #endif |
Added src/OFTaggedPointerNumber.h version [2b43e54876].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFNumber.h" OF_ASSUME_NONNULL_BEGIN #define OFTaggedPointerNumberTagBits 4 @interface OFTaggedPointerNumber: OFNumber @end OF_ASSUME_NONNULL_END |
Added src/OFTaggedPointerNumber.m version [95809f3856].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFTaggedPointerNumber.h" #import "OFInvalidFormatException.h" enum Tag { tagChar, tagShort, tagInt, tagLong, tagLongLong, tagUnsignedChar, tagUnsignedShort, tagUnsignedInt, tagUnsignedLong, tagUnsignedLongLong, }; static const uintptr_t tagMask = (1 << OFTaggedPointerNumberTagBits) - 1; static int numberTag; @implementation OFTaggedPointerNumber + (void)initialize { if (self == [OFTaggedPointerNumber class]) numberTag = objc_registerTaggedPointerClass(self); } + (OFTaggedPointerNumber *)numberWithChar: (signed char)value { return objc_createTaggedPointer(numberTag, ((uintptr_t)(unsigned char)value << OFTaggedPointerNumberTagBits) | tagChar); } + (OFTaggedPointerNumber *)numberWithShort: (short)value { return objc_createTaggedPointer(numberTag, ((uintptr_t)(unsigned short)value << OFTaggedPointerNumberTagBits) | tagShort); } + (OFTaggedPointerNumber *)numberWithInt: (int)value { return objc_createTaggedPointer(numberTag, ((uintptr_t)(unsigned int)value << OFTaggedPointerNumberTagBits) | tagInt); } + (OFTaggedPointerNumber *)numberWithLong: (long)value { return objc_createTaggedPointer(numberTag, ((uintptr_t)(unsigned long)value << OFTaggedPointerNumberTagBits) | tagLong); } + (OFTaggedPointerNumber *)numberWithLongLong: (long long)value { return objc_createTaggedPointer(numberTag, ((uintptr_t)(unsigned long long)value << OFTaggedPointerNumberTagBits) | tagLongLong); } + (OFTaggedPointerNumber *)numberWithUnsignedChar: (unsigned char)value { return objc_createTaggedPointer(numberTag, ((uintptr_t)value << OFTaggedPointerNumberTagBits) | tagUnsignedChar); } + (OFTaggedPointerNumber *)numberWithUnsignedShort: (unsigned short)value { return objc_createTaggedPointer(numberTag, ((uintptr_t)value << OFTaggedPointerNumberTagBits) | tagUnsignedShort); } + (OFTaggedPointerNumber *)numberWithUnsignedInt: (unsigned int)value { return objc_createTaggedPointer(numberTag, ((uintptr_t)value << OFTaggedPointerNumberTagBits) | tagUnsignedInt); } + (OFTaggedPointerNumber *)numberWithUnsignedLong: (unsigned long)value { return objc_createTaggedPointer(numberTag, ((uintptr_t)value << OFTaggedPointerNumberTagBits) | tagUnsignedLong); } + (OFTaggedPointerNumber *)numberWithUnsignedLongLong: (unsigned long long)value { return objc_createTaggedPointer(numberTag, ((uintptr_t)value << OFTaggedPointerNumberTagBits) | tagUnsignedLongLong); } - (const char *)objCType { uintptr_t value = object_getTaggedPointerValue(self); switch (value & tagMask) { case tagChar: return @encode(signed char); case tagShort: return @encode(short); case tagInt: return @encode(int); case tagLong: return @encode(long); case tagLongLong: return @encode(long long); case tagUnsignedChar: return @encode(unsigned char); case tagUnsignedShort: return @encode(unsigned short); case tagUnsignedInt: return @encode(unsigned int); case tagUnsignedLong: return @encode(unsigned long); case tagUnsignedLongLong: return @encode(unsigned long long); default: @throw [OFInvalidFormatException exception]; } } #define RETURN_VALUE \ uintptr_t value = object_getTaggedPointerValue(self); \ \ switch (value & tagMask) { \ case tagChar: \ return (signed char)(unsigned char) \ (value >> OFTaggedPointerNumberTagBits); \ case tagShort: \ return (short)(unsigned short) \ (value >> OFTaggedPointerNumberTagBits); \ case tagInt: \ return (int)(unsigned int) \ (value >> OFTaggedPointerNumberTagBits); \ case tagLong: \ return (long)(unsigned long) \ (value >> OFTaggedPointerNumberTagBits); \ case tagLongLong: \ return (long long)(unsigned long long) \ (value >> OFTaggedPointerNumberTagBits); \ case tagUnsignedChar: \ return (unsigned char) \ (value >> OFTaggedPointerNumberTagBits); \ case tagUnsignedShort: \ return (unsigned short) \ (value >> OFTaggedPointerNumberTagBits); \ case tagUnsignedInt: \ return (unsigned int) \ (value >> OFTaggedPointerNumberTagBits); \ case tagUnsignedLong: \ return (unsigned long) \ (value >> OFTaggedPointerNumberTagBits); \ case tagUnsignedLongLong: \ return (unsigned long long) \ (value >> OFTaggedPointerNumberTagBits); \ default: \ @throw [OFInvalidFormatException exception]; \ } - (long long)longLongValue { RETURN_VALUE } - (unsigned long long)unsignedLongLongValue { RETURN_VALUE } - (double)doubleValue { RETURN_VALUE } #undef RETURN_VALUE OF_SINGLETON_METHODS @end |
Modified src/OFTarArchive.h from [7f3061b033] to [da3916e731].
1 | /* | | | | | | > > > > | < > | < | | < < < < | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFString.h" #import "OFTarArchiveEntry.h" OF_ASSUME_NONNULL_BEGIN @class OFIRI; @class OFStream; /** * @class OFTarArchive OFTarArchive.h ObjFW/OFTarArchive.h * * @brief A class for accessing and manipulating tar archives. */ OF_SUBCLASSING_RESTRICTED @interface OFTarArchive: OFObject { OFStream *_stream; uint_least8_t _mode; OFStringEncoding _encoding; OFTarArchiveEntry *_Nullable _currentEntry; #ifdef OF_TAR_ARCHIVE_M @public #endif OFStream *_Nullable _lastReturnedStream; } |
︙ | ︙ | |||
64 65 66 67 68 69 70 | * failed */ + (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode; /** * @brief Creates a new OFTarArchive object with the specified file. * | | | | | | | | 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | * failed */ + (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode; /** * @brief Creates a new OFTarArchive object with the specified file. * * @param IRI The IRI to the tar archive * @param mode The mode for the tar file. Valid modes are "r" for reading, * "w" for creating a new file and "a" for appending to an existing * archive. * @return A new, autoreleased OFTarArchive * @throw OFInvalidFormatException The archive has an invalid format * @throw OFSeekFailedException The archive was open in append mode and seeking * failed */ + (instancetype)archiveWithIRI: (OFIRI *)IRI mode: (OFString *)mode; /** * @brief Creates an IRI for accessing the specified file within the specified * tar archive. * * @param path The path of the file within the archive * @param IRI The IRI of the archive * @return An IRI for accessing the specified file within the specified tar * archive */ + (OFIRI *)IRIForFilePath: (OFString *)path inArchiveWithIRI: (OFIRI *)IRI; - (instancetype)init OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFTarArchive object with the * specified stream. * |
︙ | ︙ | |||
109 110 111 112 113 114 115 | - (instancetype)initWithStream: (OFStream *)stream mode: (OFString *)mode OF_DESIGNATED_INITIALIZER; /** * @brief Initializes an already allocated OFTarArchive object with the * specified file. * | | | | 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | - (instancetype)initWithStream: (OFStream *)stream mode: (OFString *)mode OF_DESIGNATED_INITIALIZER; /** * @brief Initializes an already allocated OFTarArchive object with the * specified file. * * @param IRI The IRI to the tar archive * @param mode The mode for the tar file. Valid modes are "r" for reading, * "w" for creating a new file and "a" for appending to an existing * archive. * @return An initialized OFTarArchive * @throw OFInvalidFormatException The archive has an invalid format * @throw OFSeekFailedException The archive was open in append mode and seeking * failed */ - (instancetype)initWithIRI: (OFIRI *)IRI mode: (OFString *)mode; /** * @brief Returns the next entry from the tar archive or `nil` if all entries * have been read. * * @note This is only available in read mode. * |
︙ | ︙ | |||
158 159 160 161 162 163 164 | * @brief Returns a stream for writing the specified entry. * * @note This is only available in write and append mode. * * @note The returned stream conforms to @ref OFReadyForWritingObserving if the * underlying stream does so, too. * | | | | 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | * @brief Returns a stream for writing the specified entry. * * @note This is only available in write and append mode. * * @note The returned stream conforms to @ref OFReadyForWritingObserving if the * underlying stream does so, too. * * @warning Calling @ref streamForWritingEntry: will invalidate all streams * returned by @ref streamForReadingCurrentEntry or * @ref streamForWritingEntry:! Reading from or writing to an * invalidated stream will throw an @ref OFReadFailedException or * @ref OFWriteFailedException! * * @param entry The entry for which a stream for writing should be returned * @return A stream for writing the specified entry */ |
︙ | ︙ |
Modified src/OFTarArchive.m from [8086f04e85] to [67f03e487e].
1 | /* | | | | | | > > > > | < > | | | | > | | > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #define OF_TAR_ARCHIVE_M #include "config.h" #include <errno.h> #import "OFTarArchive.h" #import "OFTarArchiveEntry.h" #import "OFTarArchiveEntry+Private.h" #import "OFArchiveIRIHandler.h" #import "OFDate.h" #import "OFIRI.h" #import "OFIRIHandler.h" #import "OFKernelEventObserver.h" #import "OFSeekableStream.h" #import "OFStream.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFNotOpenException.h" #import "OFOutOfRangeException.h" #import "OFTruncatedDataException.h" #import "OFWriteFailedException.h" enum { modeRead, modeWrite, modeAppend }; OF_DIRECT_MEMBERS @interface OFTarArchiveFileReadStream: OFStream <OFReadyForReadingObserving> { OFTarArchive *_archive; OFTarArchiveEntry *_entry; OFStream *_stream; |
︙ | ︙ | |||
70 71 72 73 74 75 76 | @synthesize encoding = _encoding; + (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode { return [[[self alloc] initWithStream: stream mode: mode] autorelease]; } | | | | | | | | | | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | @synthesize encoding = _encoding; + (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode { return [[[self alloc] initWithStream: stream mode: mode] autorelease]; } + (instancetype)archiveWithIRI: (OFIRI *)IRI mode: (OFString *)mode { return [[[self alloc] initWithIRI: IRI mode: mode] autorelease]; } + (OFIRI *)IRIForFilePath: (OFString *)path inArchiveWithIRI: (OFIRI *)IRI { return OFArchiveIRIHandlerIRIForFileInArchive(@"tar", path, IRI); } - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithStream: (OFStream *)stream mode: (OFString *)mode { self = [super init]; @try { _stream = [stream retain]; if ([mode isEqual: @"r"]) _mode = modeRead; else if ([mode isEqual: @"w"]) _mode = modeWrite; else if ([mode isEqual: @"a"]) _mode = modeAppend; else @throw [OFInvalidArgumentException exception]; if (_mode == modeAppend) { uint32_t buffer[1024 / sizeof(uint32_t)]; bool empty = true; if (![_stream isKindOfClass: [OFSeekableStream class]]) @throw [OFInvalidArgumentException exception]; [(OFSeekableStream *)_stream seekToOffset: -1024 |
︙ | ︙ | |||
132 133 134 135 136 137 138 | [self release]; @throw e; } return self; } | | | | | 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | [self release]; @throw e; } return self; } - (instancetype)initWithIRI: (OFIRI *)IRI mode: (OFString *)mode { void *pool = objc_autoreleasePoolPush(); OFStream *stream; @try { if ([mode isEqual: @"a"]) stream = [OFIRIHandler openItemAtIRI: IRI mode: @"r+"]; else stream = [OFIRIHandler openItemAtIRI: IRI mode: mode]; } @catch (id e) { [self release]; @throw e; } self = [self initWithStream: stream mode: mode]; |
︙ | ︙ | |||
168 169 170 171 172 173 174 | } - (OFTarArchiveEntry *)nextEntry { uint32_t buffer[512 / sizeof(uint32_t)]; bool empty = true; | | > > > > > > > > > > > > > | 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | } - (OFTarArchiveEntry *)nextEntry { uint32_t buffer[512 / sizeof(uint32_t)]; bool empty = true; if (_mode != modeRead) @throw [OFInvalidArgumentException exception]; if (_currentEntry != nil && _lastReturnedStream == nil) { /* * No read stream was created since the last call to * -[nextEntry]. Create it so that we can properly skip the * data. */ void *pool = objc_autoreleasePoolPush(); [self streamForReadingCurrentEntry]; objc_autoreleasePoolPop(pool); } [_currentEntry release]; _currentEntry = nil; [(OFTarArchiveFileReadStream *)_lastReturnedStream of_skip]; @try { [_lastReturnedStream close]; |
︙ | ︙ | |||
210 211 212 213 214 215 216 | encoding: _encoding]; return _currentEntry; } - (OFStream *)streamForReadingCurrentEntry { | | | | 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | encoding: _encoding]; return _currentEntry; } - (OFStream *)streamForReadingCurrentEntry { if (_mode != modeRead) @throw [OFInvalidArgumentException exception]; if (_currentEntry == nil) @throw [OFInvalidArgumentException exception]; _lastReturnedStream = [[[OFTarArchiveFileReadStream alloc] of_initWithArchive: self stream: _stream entry: _currentEntry] autorelease]; [_currentEntry release]; _currentEntry = nil; return _lastReturnedStream; } - (OFStream *)streamForWritingEntry: (OFTarArchiveEntry *)entry { if (_mode != modeWrite && _mode != modeAppend) @throw [OFInvalidArgumentException exception]; @try { [_lastReturnedStream close]; } @catch (OFNotOpenException *e) { /* Might have already been closed by the user - that's fine. */ } |
︙ | ︙ | |||
260 261 262 263 264 265 266 | @try { [_lastReturnedStream close]; } @catch (OFNotOpenException *e) { /* Might have already been closed by the user - that's fine. */ } _lastReturnedStream = nil; | | | 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | @try { [_lastReturnedStream close]; } @catch (OFNotOpenException *e) { /* Might have already been closed by the user - that's fine. */ } _lastReturnedStream = nil; if (_mode == modeWrite || _mode == modeAppend) { char buffer[1024]; memset(buffer, '\0', 1024); [_stream writeBuffer: buffer length: 1024]; } [_stream release]; _stream = nil; |
︙ | ︙ | |||
301 302 303 304 305 306 307 308 309 310 311 312 313 314 | [self close]; [_entry release]; if (_archive->_lastReturnedStream == self) _archive->_lastReturnedStream = nil; [super dealloc]; } - (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length { size_t ret; | > > | 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | [self close]; [_entry release]; if (_archive->_lastReturnedStream == self) _archive->_lastReturnedStream = nil; [_archive release]; [super dealloc]; } - (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length { size_t ret; |
︙ | ︙ | |||
339 340 341 342 343 344 345 | { if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; return _atEndOfStream; } | | | | 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 | { if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; return _atEndOfStream; } - (bool)lowlevelHasDataInReadBuffer { return _stream.hasDataInReadBuffer; } - (int)fileDescriptorForReading { return ((id <OFReadyForReadingObserving>)_stream) .fileDescriptorForReading; } |
︙ | ︙ | |||
440 441 442 443 444 445 446 447 448 449 450 451 452 453 | if (_stream != nil) [self close]; [_entry release]; if (_archive->_lastReturnedStream == self) _archive->_lastReturnedStream = nil; [super dealloc]; } - (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length { if (_stream == nil) | > > | 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 | if (_stream != nil) [self close]; [_entry release]; if (_archive->_lastReturnedStream == self) _archive->_lastReturnedStream = nil; [_archive release]; [super dealloc]; } - (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length { if (_stream == nil) |
︙ | ︙ |
Modified src/OFTarArchiveEntry+Private.h from [d7e9114597] to [4bc32c1802].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFTarArchiveEntry.h" #import "OFString.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ |
Modified src/OFTarArchiveEntry.h from [a18b395a59] to [e46b8fd2a2].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFArchiveEntry.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ |
Modified src/OFTarArchiveEntry.m from [6add4508d8] to [a2ba8f365d].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFTarArchiveEntry.h" #import "OFTarArchiveEntry+Private.h" #import "OFDate.h" |
︙ | ︙ | |||
90 91 92 93 94 95 96 97 98 99 100 101 102 103 | { self = [super init]; @try { _type = OFTarArchiveEntryTypeFile; _POSIXPermissions = [[OFNumber alloc] initWithUnsignedShort: 0644]; } @catch (id e) { [self release]; @throw e; } return self; } | > | 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | { self = [super init]; @try { _type = OFTarArchiveEntryTypeFile; _POSIXPermissions = [[OFNumber alloc] initWithUnsignedShort: 0644]; _modificationDate = [[OFDate alloc] init]; } @catch (id e) { [self release]; @throw e; } return self; } |
︙ | ︙ |
Modified src/OFThread+Private.h from [b87af72459] to [30749a5317].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFThread.h" OF_ASSUME_NONNULL_BEGIN #ifdef OF_HAVE_THREADS |
︙ | ︙ |
Modified src/OFThread.h from [b1484db738] to [c158340505].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include <setjmp.h> #import "OFObject.h" #ifdef OF_HAVE_THREADS # import "OFPlainThread.h" |
︙ | ︙ | |||
291 292 293 294 295 296 297 | */ - (nullable id)main; /** * @brief This routine is executed when the thread's main method has finished * executing or terminate has been called. * | | | 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | */ - (nullable id)main; /** * @brief This routine is executed when the thread's main method has finished * executing or terminate has been called. * * @note Be sure to call `[super handleTermination]`! */ - (void)handleTermination OF_REQUIRES_SUPER; /** * @brief Starts the thread. * * @throw OFStartThreadFailedException Starting the thread failed |
︙ | ︙ |
Modified src/OFThread.m from [3012eaab1d] to [c590c3dc16].
1 | /* | | | | | | > > > > | < > | < > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #define _POSIX_TIMERS #include <errno.h> #include <stdlib.h> #include <math.h> #include <time.h> #ifdef OF_HAVE_SCHED_YIELD # include <sched.h> #endif #include "unistd_wrapper.h" #include "platform.h" #ifdef OF_AMIGAOS # define Class IntuitionClass # include <proto/exec.h> # include <proto/dos.h> # undef Class #endif #ifdef OF_WII # define nanosleep ogc_nanosleep # include <ogcsys.h> # undef nanosleep #endif |
︙ | ︙ |
Modified src/OFTimer+Private.h from [37a8d06411] to [355e148add].
1 | /* | | | | | | > > > > | < > | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFTimer.h" OF_ASSUME_NONNULL_BEGIN OF_DIRECT_MEMBERS @interface OFTimer () - (void)of_setInRunLoop: (nullable OFRunLoop *)runLoop mode: (nullable OFRunLoopMode)mode; - (void)of_reschedule; @end OF_ASSUME_NONNULL_END |
Modified src/OFTimer.h from [bedc280158] to [1d7548ccec].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFRunLoop.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ | |||
458 459 460 461 462 463 464 | * * @param timer The timer to compare the string to * @return The result of the comparison */ - (OFComparisonResult)compare: (OFTimer *)timer; /** | | < > > | 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 | * * @param timer The timer to compare the string to * @return The result of the comparison */ - (OFComparisonResult)compare: (OFTimer *)timer; /** * @brief Fires the timer without changing its regular schedule. * * A non-repeating timer will be invalidated after firing. */ - (void)fire; /** * @brief Invalidates the timer, preventing it from firing. */ - (void)invalidate; |
︙ | ︙ |
Modified src/OFTimer.m from [6b846b58a6] to [74cba96e39].
1 | /* | | | | | | > > > > | < > | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdlib.h> #import "OFTimer.h" #import "OFTimer+Private.h" #import "OFDate.h" #import "OFRunLoop.h" #import "OFRunLoop+Private.h" #ifdef OF_HAVE_THREADS # import "OFCondition.h" |
︙ | ︙ | |||
483 484 485 486 487 488 489 | - (void)dealloc { /* * The run loop references the timer, so it should never be deallocated * if it is still in a run loop. */ | | | | 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 | - (void)dealloc { /* * The run loop references the timer, so it should never be deallocated * if it is still in a run loop. */ OFAssert(_inRunLoop == nil); OFAssert(_inRunLoopMode == nil); [_fireDate release]; [_target release]; [_object1 release]; [_object2 release]; [_object3 release]; [_object4 release]; |
︙ | ︙ | |||
521 522 523 524 525 526 527 528 | _inRunLoop = [runLoop retain]; [oldInRunLoop release]; _inRunLoopMode = [mode copy]; [oldInRunLoopMode release]; } | | | | | < < < | > < < | < < | | | | | | > | | | | > | > > > | > > | | > | | | | | | | | | | | | > > > < < | 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 | _inRunLoop = [runLoop retain]; [oldInRunLoop release]; _inRunLoopMode = [mode copy]; [oldInRunLoopMode release]; } - (void)of_reschedule { long long missedIntervals; OFTimeInterval newFireDate; OFRunLoop *runLoop; if (!_repeats || !_valid) return; missedIntervals = -_fireDate.timeIntervalSinceNow / _interval; /* In case the clock was changed backwards */ if (missedIntervals < 0) missedIntervals = 0; newFireDate = _fireDate.timeIntervalSince1970 + (missedIntervals + 1) * _interval; [_fireDate release]; _fireDate = nil; _fireDate = [[OFDate alloc] initWithTimeIntervalSince1970: newFireDate]; runLoop = [OFRunLoop currentRunLoop]; [runLoop addTimer: self forMode: runLoop.currentMode]; } - (void)fire { OFEnsure(_arguments <= 4); if (!_valid) return; #ifdef OF_HAVE_BLOCKS if (_block != NULL) _block(self); else { #endif switch (_arguments) { case 0: [_target performSelector: _selector]; break; case 1: [_target performSelector: _selector withObject: _object1]; break; case 2: [_target performSelector: _selector withObject: _object1 withObject: _object2]; break; case 3: [_target performSelector: _selector withObject: _object1 withObject: _object2 withObject: _object3]; break; case 4: [_target performSelector: _selector withObject: _object1 withObject: _object2 withObject: _object3 withObject: _object4]; break; } #ifdef OF_HAVE_BLOCKS } #endif if (!_repeats) [self invalidate]; #ifdef OF_HAVE_THREADS [_condition lock]; @try { _done = true; [_condition signal]; } @finally { [_condition unlock]; } #endif } - (OFDate *)fireDate { return _fireDate; } |
︙ | ︙ | |||
633 634 635 636 637 638 639 640 641 642 643 644 645 646 | } } - (void)invalidate { _valid = false; [_target release]; [_object1 release]; [_object2 release]; [_object3 release]; [_object4 release]; _target = nil; | > > > | 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 | } } - (void)invalidate { _valid = false; #ifdef OF_HAVE_BLOCKS [_block release]; #endif [_target release]; [_object1 release]; [_object2 release]; [_object3 release]; [_object4 release]; _target = nil; |
︙ | ︙ |
Modified src/OFTriple.h from [190f8c3dbc] to [cecff833a5].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/OFTriple.m from [51ba3c68c4] to [b97fd777b5].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFTriple.h" #import "OFString.h" |
︙ | ︙ |
Modified src/OFUDPSocket+Private.h from [4a674f5731] to [85a544f238].
1 | /* | | | | | | > > > > | < > | | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFUDPSocket.h" OF_ASSUME_NONNULL_BEGIN OF_DIRECT_MEMBERS @interface OFUDPSocket () - (void)of_bindToAddress: (OFSocketAddress *)address extraType: (int)extraType; @end OF_ASSUME_NONNULL_END |
Modified src/OFUDPSocket.h from [9190ffdfc0] to [7037259922].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFDatagramSocket.h" OF_ASSUME_NONNULL_BEGIN @class OFString; |
︙ | ︙ | |||
67 68 69 70 71 72 73 | /** * @brief Binds the socket to the specified host and port. * * @param host The host to bind to. Use `@"0.0.0.0"` for IPv4 or `@"::"` for * IPv6 to bind to all. * @param port The port to bind to. If the port is 0, an unused port will be * chosen, which can be obtained using the return value. | | | | | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | /** * @brief Binds the socket to the specified host and port. * * @param host The host to bind to. Use `@"0.0.0.0"` for IPv4 or `@"::"` for * IPv6 to bind to all. * @param port The port to bind to. If the port is 0, an unused port will be * chosen, which can be obtained using the return value. * @return The address the socket was bound to * @throw OFBindIPSocketFailedException Binding failed * @throw OFAlreadyOpenException The socket is already bound */ - (OFSocketAddress)bindToHost: (OFString *)host port: (uint16_t)port; @end OF_ASSUME_NONNULL_END |
Modified src/OFUDPSocket.m from [67c55bc52f] to [d9b5e328f7].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #ifndef _XOPEN_SOURCE_EXTENDED # define _XOPEN_SOURCE_EXTENDED #endif |
︙ | ︙ | |||
30 31 32 33 34 35 36 | #import "OFUDPSocket+Private.h" #import "OFDNSResolver.h" #import "OFData.h" #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFThread.h" | | | | < < > > > > | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | #import "OFUDPSocket+Private.h" #import "OFDNSResolver.h" #import "OFData.h" #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFThread.h" #import "OFAlreadyOpenException.h" #import "OFBindIPSocketFailedException.h" @implementation OFUDPSocket @dynamic delegate; - (void)of_bindToAddress: (OFSocketAddress *)address extraType: (int)extraType OF_DIRECT { #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) int flags; #endif #if !defined(OF_HPUX) && !defined(OF_WII) && !defined(OF_NINTENDO_3DS) OFString *host; uint16_t port; #endif if ((_socket = socket( ((struct sockaddr *)&address->sockaddr)->sa_family, SOCK_DGRAM | SOCK_CLOEXEC | extraType, 0)) == OFInvalidSocketHandle) @throw [OFBindIPSocketFailedException exceptionWithHost: OFSocketAddressString(address) |
︙ | ︙ | |||
98 99 100 101 102 103 104 | (struct sockaddr *)&address->sockaddr, address->length)) == 0) break; if (OFSocketErrNo() != EADDRINUSE) { int errNo = OFSocketErrNo(); OFString *host = OFSocketAddressString(address); | | | | | < < | < | | | | > | > | | < < < < < < < < < | | | | | 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | (struct sockaddr *)&address->sockaddr, address->length)) == 0) break; if (OFSocketErrNo() != EADDRINUSE) { int errNo = OFSocketErrNo(); OFString *host = OFSocketAddressString(address); uint16_t port = OFSocketAddressIPPort(address); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPSocketFailedException exceptionWithHost: host port: port socket: self errNo: errNo]; } } } #endif #if !defined(OF_HPUX) && !defined(OF_WII) && !defined(OF_NINTENDO_3DS) host = OFSocketAddressString(address); port = OFSocketAddressIPPort(address); memset(address, 0, sizeof(*address)); address->length = (socklen_t)sizeof(address->sockaddr); if (OFGetSockName(_socket, (struct sockaddr *)&address->sockaddr, &address->length) != 0) { int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPSocketFailedException exceptionWithHost: host port: port socket: self errNo: errNo]; } switch (((struct sockaddr *)&address->sockaddr)->sa_family) { case AF_INET: address->family = OFSocketAddressFamilyIPv4; break; # ifdef OF_HAVE_IPV6 case AF_INET6: address->family = OFSocketAddressFamilyIPv6; break; # endif default: closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindIPSocketFailedException exceptionWithHost: host port: port socket: self errNo: EAFNOSUPPORT]; } #endif } - (OFSocketAddress)bindToHost: (OFString *)host port: (uint16_t)port { void *pool = objc_autoreleasePoolPush(); OFData *socketAddresses; OFSocketAddress address; if (_socket != OFInvalidSocketHandle) @throw [OFAlreadyOpenException exceptionWithObject: self]; socketAddresses = [[OFThread DNSResolver] resolveAddressesForHost: host addressFamily: OFSocketAddressFamilyAny]; address = *(OFSocketAddress *)[socketAddresses itemAtIndex: 0]; OFSocketAddressSetIPPort(&address, port); [self of_bindToAddress: &address extraType: 0]; objc_autoreleasePoolPop(pool); return address; } @end |
Modified src/OFUNIXDatagramSocket.h from [0a3ec7f2ad] to [421a59ea80].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFDatagramSocket.h" OF_ASSUME_NONNULL_BEGIN @class OFString; |
︙ | ︙ | |||
59 60 61 62 63 64 65 | */ @property OF_NULLABLE_PROPERTY (assign, nonatomic) id <OFUNIXDatagramSocketDelegate> delegate; /** * @brief Bind the socket to the specified path. * | | | > | | | 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | */ @property OF_NULLABLE_PROPERTY (assign, nonatomic) id <OFUNIXDatagramSocketDelegate> delegate; /** * @brief Bind the socket to the specified path. * * @param path The path to bind to or `nil` for an anonymous socket * @return The address on which this socket can be reached, if a path was * specified * @throw OFBindUNIXSocketFailedException Binding failed * @throw OFAlreadyOpenException The socket is already bound */ - (OFSocketAddress)bindToPath: (nullable OFString *)path; @end OF_ASSUME_NONNULL_END |
Modified src/OFUNIXDatagramSocket.m from [7203060d9a] to [2627547b65].
1 | /* | | | | | | > > > > | < > | | | > | > > > | > | | > | | | | | | | | | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #ifdef HAVE_FCNTL_H # include <fcntl.h> #endif #import "OFUNIXDatagramSocket.h" #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFString.h" #import "OFAlreadyOpenException.h" #import "OFBindUNIXSocketFailedException.h" @implementation OFUNIXDatagramSocket @dynamic delegate; - (OFSocketAddress)bindToPath: (OFString *)path { OFSocketAddress address; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC) int flags; #endif if (_socket != OFInvalidSocketHandle) @throw [OFAlreadyOpenException exceptionWithObject: self]; if (path != nil) address = OFSocketAddressMakeUNIX(path); else { address.family = OFSocketAddressFamilyUnknown; address.length = 0; } if ((_socket = socket(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC, 0)) == OFInvalidSocketHandle) @throw [OFBindUNIXSocketFailedException exceptionWithPath: path socket: self errNo: OFSocketErrNo()]; _canBlock = true; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC) if ((flags = fcntl(_socket, F_GETFD, 0)) != -1) fcntl(_socket, F_SETFD, flags | FD_CLOEXEC); #endif if (path != nil) { if (bind(_socket, (struct sockaddr *)&address.sockaddr, address.length) != 0) { int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindUNIXSocketFailedException exceptionWithPath: path socket: self errNo: errNo]; } } return address; } @end |
Modified src/OFUNIXStreamSocket.h from [3d105f3c9b] to [776de44552].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFStreamSocket.h" OF_ASSUME_NONNULL_BEGIN @class OFString; |
︙ | ︙ | |||
51 52 53 54 55 56 57 | id <OFUNIXStreamSocketDelegate> delegate; /** * @brief Connects the OFUNIXStreamSocket to the specified destination. * * @param path The path to connect to * @throw OFConnectUNIXSocketFailedException Connecting failed | | | | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | id <OFUNIXStreamSocketDelegate> delegate; /** * @brief Connects the OFUNIXStreamSocket to the specified destination. * * @param path The path to connect to * @throw OFConnectUNIXSocketFailedException Connecting failed * @throw OFAlreadyOpenException The socket is already connected or bound */ - (void)connectToPath: (OFString *)path; /** * @brief Binds the socket to the specified host and port. * * @param path The path to bind to * @throw OFBindUNIXSocketFailedException Binding failed * @throw OFAlreadyOpenException The socket is already connected or bound */ - (void)bindToPath: (OFString *)path; @end OF_ASSUME_NONNULL_END |
Modified src/OFUNIXStreamSocket.m from [ff26304fa1] to [3bba9beb8b].
1 | /* | | | | | | > > > > | < > | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #ifdef HAVE_FCNTL_H # include <fcntl.h> #endif #import "OFUNIXStreamSocket.h" #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFString.h" #import "OFAlreadyOpenException.h" #import "OFBindUNIXSocketFailedException.h" #import "OFConnectUNIXSocketFailedException.h" @implementation OFUNIXStreamSocket @dynamic delegate; - (void)connectToPath: (OFString *)path { OFSocketAddress address; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) int flags; #endif if (_socket != OFInvalidSocketHandle) @throw [OFAlreadyOpenException exceptionWithObject: self]; address = OFSocketAddressMakeUNIX(path); if ((_socket = socket(address.sockaddr.un.sun_family, SOCK_STREAM | SOCK_CLOEXEC, 0)) == OFInvalidSocketHandle) @throw [OFConnectUNIXSocketFailedException exceptionWithPath: path |
︙ | ︙ | |||
75 76 77 78 79 80 81 | { OFSocketAddress address; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) int flags; #endif if (_socket != OFInvalidSocketHandle) | | | 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | { OFSocketAddress address; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) int flags; #endif if (_socket != OFInvalidSocketHandle) @throw [OFAlreadyOpenException exceptionWithObject: self]; address = OFSocketAddressMakeUNIX(path); if ((_socket = socket(address.sockaddr.un.sun_family, SOCK_STREAM | SOCK_CLOEXEC, 0)) == OFInvalidSocketHandle) @throw [OFBindUNIXSocketFailedException exceptionWithPath: path |
︙ | ︙ |
Added src/OFURIDNSResourceRecord.h version [8d69f9e234].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFDNSResourceRecord.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFURIDNSResourceRecord \ * OFDNSResourceRecord.h ObjFW/OFDNSResourceRecord.h * * @brief A class representing an URI DNS resource record. */ OF_SUBCLASSING_RESTRICTED @interface OFURIDNSResourceRecord: OFDNSResourceRecord { uint16_t _priority, _weight; OFString *_target; } /** * @brief The priority of the resource record. */ @property (readonly, nonatomic) uint16_t priority; /** * @brief The weight of the resource record. */ @property (readonly, nonatomic) uint16_t weight; /** * @brief The target of the resource record. */ @property (readonly, nonatomic) OFString *target; - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFURIDNSResourceRecord with the * specified name, class, priority, weight, target and time to live. * * @param name The name for the resource record * @param DNSClass The class code for the resource record * @param priority The priority for the resource record * @param weight The weight for the resource record * @param target The target for the resource record * @param TTL The time to live for the resource record * @return An initialized OFURIDNSResourceRecord */ - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass priority: (uint16_t)priority weight: (uint16_t)weight target: (OFString *)target TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END |
Added src/OFURIDNSResourceRecord.m version [32426e06ba].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFURIDNSResourceRecord.h" @implementation OFURIDNSResourceRecord @synthesize priority = _priority, weight = _weight, target = _target; - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass priority: (uint16_t)priority weight: (uint16_t)weight target: (OFString *)target TTL: (uint32_t)TTL { self = [super initWithName: name DNSClass: DNSClass recordType: OFDNSRecordTypeURI TTL: TTL]; @try { _priority = priority; _weight = weight; _target = [target copy]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_target release]; [super dealloc]; } - (bool)isEqual: (id)object { OFURIDNSResourceRecord *record; if (object == self) return true; if (![object isKindOfClass: [OFURIDNSResourceRecord class]]) return false; record = object; if (record->_name != _name && ![record->_name isEqual: _name]) return false; if (record->_DNSClass != _DNSClass) return false; if (record->_recordType != _recordType) return false; if (record->_priority != _priority) return false; if (record->_weight != _weight) return false; if (record->_target != _target && ![record->_target isEqual: _target]) return false; return true; } - (unsigned long)hash { unsigned long hash; OFHashInit(&hash); OFHashAddHash(&hash, _name.hash); OFHashAddByte(&hash, _DNSClass >> 8); OFHashAddByte(&hash, _DNSClass); OFHashAddByte(&hash, _recordType >> 8); OFHashAddByte(&hash, _recordType); OFHashAddByte(&hash, _priority >> 8); OFHashAddByte(&hash, _priority); OFHashAddByte(&hash, _weight >> 8); OFHashAddByte(&hash, _weight); OFHashAddHash(&hash, _target.hash); OFHashFinalize(&hash); return hash; } - (OFString *)description { return [OFString stringWithFormat: @"<%@:\n" @"\tName = %@\n" @"\tClass = %@\n" @"\tPriority = %" PRIu16 "\n" @"\tWeight = %" PRIu16 "\n" @"\tTarget = %@\n" @"\tTTL = %" PRIu32 "\n" @">", self.className, _name, OFDNSClassName(_DNSClass), _priority, _weight, _target, _TTL]; } @end |
Modified src/OFUTF8String+Private.h from [a7a276ddae] to [adc117632b].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFUTF8String.h" OF_ASSUME_NONNULL_BEGIN OF_DIRECT_MEMBERS |
︙ | ︙ |
Modified src/OFUTF8String.h from [d381d1f2a1] to [cef941820b].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFString.h" OF_ASSUME_NONNULL_BEGIN @interface OFUTF8String: OFString |
︙ | ︙ |
Modified src/OFUTF8String.m from [c76e8c2ef7] to [720c0708e2].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdarg.h> #include <stdlib.h> #include <string.h> |
︙ | ︙ |
Modified src/OFUUID.h from [e73d2af113] to [a75e13db2a].
1 | /* | | | | | | > > > > | < > | < | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" OF_ASSUME_NONNULL_BEGIN @class OFString; /** * @class OFUUID OFUUID.h ObjFW/OFUUID.h * * @brief A UUID conforming to RFC 4122. */ OF_SUBCLASSING_RESTRICTED @interface OFUUID: OFObject <OFCopying, OFComparing> { unsigned char _bytes[16]; } /** * @brief The UUID as a string. */ |
︙ | ︙ |
Modified src/OFUUID.m from [3edaa624cf] to [4cbeefa774].
1 | /* | | | | | | > > > > | < > | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFUUID.h" #import "OFArray.h" #import "OFString.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFOutOfRangeException.h" #define bytesSize 16 |
︙ | ︙ | |||
141 142 143 144 145 146 147 | [self release]; @throw e; } return self; } | < < < < < < < < < < < < < < < < < < < < < < < | 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | [self release]; @throw e; } return self; } - (bool)isEqual: (id)object { OFUUID *UUID; if (![object isKindOfClass: [OFUUID class]]) return false; |
︙ | ︙ | |||
231 232 233 234 235 236 237 | _bytes[12], _bytes[13], _bytes[14], _bytes[15]]; } - (OFString *)description { return self.UUIDString; } | < < < < < < < < < < < < < < | 211 212 213 214 215 216 217 218 | _bytes[12], _bytes[13], _bytes[14], _bytes[15]]; } - (OFString *)description { return self.UUIDString; } @end |
Modified src/OFValue.h from [94dd083371] to [2ba29e2c97].
1 | /* | | | | | | > > > > | < > | < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFValue OFValue.h ObjFW/OFValue.h * * @brief A class for storing arbitrary values in an object. */ @interface OFValue: OFObject <OFCopying> /** * @brief The ObjC type encoding of the value. */ @property (readonly, nonatomic) const char *objCType; /** * @brief The value as a pointer to void. |
︙ | ︙ | |||
64 65 66 67 68 69 70 | * @brief The value as an OFSize. * * @throw OFOutOfRangeException The value is not OFSize-sized */ @property (readonly, nonatomic) OFSize sizeValue; /** | | > > > > > > > > > > > > > > | 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | * @brief The value as an OFSize. * * @throw OFOutOfRangeException The value is not OFSize-sized */ @property (readonly, nonatomic) OFSize sizeValue; /** * @brief The value as an OFRect. * * @throw OFOutOfRangeException The value is not OFRect-sized */ @property (readonly, nonatomic) OFRect rectValue; /** * @brief The value as an OFVector3D. * * @throw OFOutOfRangeException The value is not OFVector3D-sized */ @property (readonly, nonatomic) OFVector3D vector3DValue; /** * @brief The value as an OFVector4D. * * @throw OFOutOfRangeException The value is not OFVector4D-sized */ @property (readonly, nonatomic) OFVector4D vector4DValue; /** * @brief Creates a new, autorelease OFValue with the specified bytes of the * specified type. * * @param bytes The bytes containing the value * @param objCType The ObjC type encoding for the value * @return A new, autoreleased OFValue |
︙ | ︙ | |||
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | * rectangle. * * @param rect The rectangle the OFValue should contain * @return A new, autoreleased OFValue */ + (instancetype)valueWithRect: (OFRect)rect; /** * @brief Initializes an already allocated OFValue with the specified bytes of * the specified type. * * @param bytes The bytes containing the value * @param objCType The ObjC type encoding for the value * @return An initialized OFValue */ - (instancetype)initWithBytes: (const void *)bytes | > > > > > > > > > > > > > > > > > > | > > | 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | * rectangle. * * @param rect The rectangle the OFValue should contain * @return A new, autoreleased OFValue */ + (instancetype)valueWithRect: (OFRect)rect; /** * @brief Creates a new, autoreleased OFValue containing the specified * 3D vector. * * @param vector3D The 3D vector the OFValue should contain * @return A new, autoreleased OFValue */ + (instancetype)valueWithVector3D: (OFVector3D)vector3D; /** * @brief Creates a new, autoreleased OFValue containing the specified * 4D vector. * * @param vector4D The 4D vector the OFValue should contain * @return A new, autoreleased OFValue */ + (instancetype)valueWithVector4D: (OFVector4D)vector4D; /** * @brief Initializes an already allocated OFValue with the specified bytes of * the specified type. * * @param bytes The bytes containing the value * @param objCType The ObjC type encoding for the value * @return An initialized OFValue */ - (instancetype)initWithBytes: (const void *)bytes objCType: (const char *)objCType OF_DESIGNATED_INITIALIZER; - (instancetype)init OF_UNAVAILABLE; /** * @brief Gets the value. * * @param value The buffer to copy the value into * @param size The size of the value * @throw OFOutOfRangeException The specified size does not match the value |
︙ | ︙ |
Modified src/OFValue.m from [d37e008646] to [595e450f93].
1 | /* | | | | | | > > > > | < > | | < | | | | > > > | > > | > > > > > > > > > | > > > > > > | > > > > > > > > | | | | > > | | | > | > | > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFValue.h" #import "OFConcreteValue.h" #import "OFMethodSignature.h" #import "OFString.h" #import "OFOutOfMemoryException.h" static struct { Class isa; } placeholder; @interface OFPlaceholderValue: OFValue @end @implementation OFPlaceholderValue #ifdef __clang__ /* We intentionally don't call into super, so silence the warning. */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wobjc-designated-initializers" #endif - (instancetype)initWithBytes: (const void *)bytes objCType: (const char *)objCType { return (id)[[OFConcreteValue alloc] initWithBytes: bytes objCType: objCType]; } #ifdef __clang__ # pragma clang diagnostic pop #endif OF_SINGLETON_METHODS @end @implementation OFValue + (void)initialize { if (self == [OFValue class]) object_setClass((id)&placeholder, [OFPlaceholderValue class]); } + (instancetype)alloc { if (self == [OFValue class]) return (id)&placeholder; return [super alloc]; } + (instancetype)valueWithBytes: (const void *)bytes objCType: (const char *)objCType { return [[[OFValue alloc] initWithBytes: bytes objCType: objCType] autorelease]; } + (instancetype)valueWithPointer: (const void *)pointer { return [[[OFValue alloc] initWithBytes: &pointer objCType: @encode(const void *)] autorelease]; } + (instancetype)valueWithNonretainedObject: (id)object { return [[[OFValue alloc] initWithBytes: &object objCType: @encode(id)] autorelease]; } + (instancetype)valueWithRange: (OFRange)range { return [[[OFValue alloc] initWithBytes: &range objCType: @encode(OFRange)] autorelease]; } + (instancetype)valueWithPoint: (OFPoint)point { return [[[OFValue alloc] initWithBytes: &point objCType: @encode(OFPoint)] autorelease]; } + (instancetype)valueWithSize: (OFSize)size { return [[[OFValue alloc] initWithBytes: &size objCType: @encode(OFSize)] autorelease]; } + (instancetype)valueWithRect: (OFRect)rect { return [[[OFValue alloc] initWithBytes: &rect objCType: @encode(OFRect)] autorelease]; } + (instancetype)valueWithVector3D: (OFVector3D)vector3D { return [[[OFValue alloc] initWithBytes: &vector3D objCType: @encode(OFVector3D)] autorelease]; } + (instancetype)valueWithVector4D: (OFVector4D)vector4D { return [[[OFValue alloc] initWithBytes: &vector4D objCType: @encode(OFVector4D)] autorelease]; } - (instancetype)initWithBytes: (const void *)bytes objCType: (const char *)objCType { if ([self isMemberOfClass: [OFValue class]]) { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @throw e; } abort(); } return [super init]; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (bool)isEqual: (id)object { const char *objCType; |
︙ | ︙ | |||
196 197 198 199 200 201 202 203 204 205 | - (OFRect)rectValue { OFRect ret; [self getValue: &ret size: sizeof(ret)]; return ret; } - (OFString *)description { | > > > > > > > > > > > > > > > | < | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 | - (OFRect)rectValue { OFRect ret; [self getValue: &ret size: sizeof(ret)]; return ret; } - (OFVector3D)vector3DValue { OFVector3D ret; [self getValue: &ret size: sizeof(ret)]; return ret; } - (OFVector4D)vector4DValue { OFVector4D ret; [self getValue: &ret size: sizeof(ret)]; return ret; } - (OFString *)description { const char *objCType = self.objCType; OFMutableString *ret; size_t size; unsigned char *value; if (strcmp(objCType, @encode(OFRange)) == 0 || strcmp(objCType, @encode(const OFRange)) == 0) { OFRange rangeValue; [self getValue: &rangeValue size: sizeof(rangeValue)]; return [OFString stringWithFormat: @"<OFValue: OFRange { %zd, %zd }>", rangeValue.location, rangeValue.length]; } else if (strcmp(objCType, @encode(OFPoint)) == 0 || strcmp(objCType, @encode(const OFPoint)) == 0) { OFPoint pointValue; [self getValue: &pointValue size: sizeof(pointValue)]; return [OFString stringWithFormat: @"<OFValue: OFPoint { %g, %g }>", pointValue.x, pointValue.y]; } else if (strcmp(objCType, @encode(OFSize)) == 0 || strcmp(objCType, @encode(const OFSize)) == 0) { OFSize sizeValue; [self getValue: &sizeValue size: sizeof(sizeValue)]; return [OFString stringWithFormat: @"<OFValue: OFSize { %g, %g }>", sizeValue.width, sizeValue.height]; } else if (strcmp(objCType, @encode(OFRect)) == 0 || strcmp(objCType, @encode(const OFRect)) == 0) { OFRect rectValue; [self getValue: &rectValue size: sizeof(rectValue)]; return [OFString stringWithFormat: @"<OFValue: OFRect { %g, %g, %g, %g }>", rectValue.origin.x, rectValue.origin.y, rectValue.size.width, rectValue.size.height]; } else if (strcmp(objCType, @encode(OFVector3D)) == 0 || strcmp(objCType, @encode(const OFVector3D)) == 0) { OFVector3D vector3DValue; [self getValue: &vector3DValue size: sizeof(vector3DValue)]; return [OFString stringWithFormat: @"<OFValue: OFVector3D { %g, %g, %g }>", vector3DValue.x, vector3DValue.y, vector3DValue.z]; } else if (strcmp(objCType, @encode(OFVector4D)) == 0 || strcmp(objCType, @encode(const OFVector4D)) == 0) { OFVector4D vector4DValue; [self getValue: &vector4DValue size: sizeof(vector4DValue)]; return [OFString stringWithFormat: @"<OFValue: OFVector4D { %g, %g, %g, %g }>", vector4DValue.x, vector4DValue.y, vector4DValue.z, vector4DValue.w]; } ret = [OFMutableString stringWithString: @"<OFValue: "]; size = OFSizeOfTypeEncoding(objCType); value = OFAllocMemory(1, size); @try { [self getValue: value size: size]; for (size_t i = 0; i < size; i++) { if (i > 0) [ret appendString: @" "]; |
︙ | ︙ |
Modified src/OFWin32ConsoleStdIOStream.h from [d9940ccf28] to [8971522c66].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFStdIOStream.h" OF_ASSUME_NONNULL_BEGIN @interface OFWin32ConsoleStdIOStream: OFStdIOStream |
︙ | ︙ |
Modified src/OFWindowsRegistryKey.h from [6b1a582030] to [60c1ddafa8].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFString.h" #include <windows.h> |
︙ | ︙ |
Modified src/OFWindowsRegistryKey.m from [bf1674ca4d] to [35635da07e].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFWindowsRegistryKey.h" #import "OFData.h" #import "OFLocale.h" |
︙ | ︙ |
Modified src/OFXMLAttribute.h from [f37ed8f3fd] to [300b21f249].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFXMLNode.h" OF_ASSUME_NONNULL_BEGIN @class OFString; |
︙ | ︙ | |||
88 89 90 91 92 93 94 | * @param nameSpace The namespace of the attribute * @param stringValue The string value of the attribute * @return An initialized OFXMLAttribute with the specified parameters */ - (instancetype)initWithName: (OFString *)name namespace: (nullable OFString *)nameSpace stringValue: (OFString *)stringValue OF_DESIGNATED_INITIALIZER; | < < | 92 93 94 95 96 97 98 99 100 101 | * @param nameSpace The namespace of the attribute * @param stringValue The string value of the attribute * @return An initialized OFXMLAttribute with the specified parameters */ - (instancetype)initWithName: (OFString *)name namespace: (nullable OFString *)nameSpace stringValue: (OFString *)stringValue OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END |
Modified src/OFXMLAttribute.m from [fef93ca0aa] to [d69d481a36].
1 | /* | | | | | | > > > > | < > | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFXMLAttribute.h" #import "OFXMLNode+Private.h" #import "OFString.h" #import "OFDictionary.h" #import "OFInvalidArgumentException.h" @implementation OFXMLAttribute @synthesize name = _name, namespace = _namespace; + (instancetype)attributeWithName: (OFString *)name |
︙ | ︙ | |||
61 62 63 64 65 66 67 | _namespace = [namespace copy]; _stringValue = [stringValue copy]; } @catch (id e) { [self release]; @throw e; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | _namespace = [namespace copy]; _stringValue = [stringValue copy]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_name release]; [_namespace release]; |
︙ | ︙ | |||
159 160 161 162 163 164 165 | OFHashAddHash(&hash, _stringValue.hash); OFHashFinalize(&hash); return hash; } | < < < < < < < < < < < < < < < < < < < < < < < | 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | OFHashAddHash(&hash, _stringValue.hash); OFHashFinalize(&hash); return hash; } - (OFString *)description { return [OFString stringWithFormat: @"<%@: name=%@, namespace=%@, " @"stringValue=%@>", self.class, _name, _namespace, _stringValue]; } @end |
Modified src/OFXMLCDATA.h from [45c442f70d] to [9d9a0b0c03].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFXMLNode.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ | |||
39 40 41 42 43 44 45 | /** * @brief Initializes an already allocated OFXMLCDATA with the specified string. * * @param string The string value for the CDATA * @return An initialized OFXMLCDATA */ - (instancetype)initWithString: (OFString *)string; | < < | 43 44 45 46 47 48 49 50 51 52 | /** * @brief Initializes an already allocated OFXMLCDATA with the specified string. * * @param string The string value for the CDATA * @return An initialized OFXMLCDATA */ - (instancetype)initWithString: (OFString *)string; @end OF_ASSUME_NONNULL_END |
Modified src/OFXMLCDATA.m from [268b8de778] to [f517f47c58].
1 | /* | | | | | | > > > > | < > | < < < < < < < < < < < < < < < < < < < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFXMLCDATA.h" #import "OFXMLNode+Private.h" #import "OFString.h" #import "OFInvalidArgumentException.h" @implementation OFXMLCDATA + (instancetype)CDATAWithString: (OFString *)string { return [[[self alloc] initWithString: string] autorelease]; } - (instancetype)initWithString: (OFString *)string { self = [super of_init]; @try { _CDATA = [string copy]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_CDATA release]; |
︙ | ︙ | |||
116 117 118 119 120 121 122 | return [ret autorelease]; } - (OFString *)description { return self.XMLString; } | < < < < < < < < < < | 97 98 99 100 101 102 103 104 | return [ret autorelease]; } - (OFString *)description { return self.XMLString; } @end |
Modified src/OFXMLCharacters.h from [50ac8d5a7f] to [50dc937f26].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFXMLNode.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ | |||
40 41 42 43 44 45 46 | * @brief Initializes an already allocated OFXMLCharacters with the specified * string. * * @param string The string value for the characters * @return An initialized OFXMLCharacters */ - (instancetype)initWithString: (OFString *)string; | < < | 44 45 46 47 48 49 50 51 52 53 | * @brief Initializes an already allocated OFXMLCharacters with the specified * string. * * @param string The string value for the characters * @return An initialized OFXMLCharacters */ - (instancetype)initWithString: (OFString *)string; @end OF_ASSUME_NONNULL_END |
Modified src/OFXMLCharacters.m from [53e16f06bf] to [cf7bf29ded].
1 | /* | | | | | | > > > > | < > | < < < < < < < < < < < < < < < < < < < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFXMLCharacters.h" #import "OFXMLNode+Private.h" #import "OFString.h" #import "OFInvalidArgumentException.h" @implementation OFXMLCharacters + (instancetype)charactersWithString: (OFString *)string { return [[[self alloc] initWithString: string] autorelease]; } - (instancetype)initWithString: (OFString *)string { self = [super of_init]; @try { _characters = [string copy]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_characters release]; |
︙ | ︙ | |||
108 109 110 111 112 113 114 | return _characters.stringByXMLEscaping; } - (OFString *)description { return self.XMLString; } | < < < < < < < | 89 90 91 92 93 94 95 96 | return _characters.stringByXMLEscaping; } - (OFString *)description { return self.XMLString; } @end |
Modified src/OFXMLComment.h from [566c15f0b8] to [8ae3b4a96b].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFXMLNode.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ | |||
45 46 47 48 49 50 51 | * @brief Initializes an already allocated OFXMLComment with the specified * text. * * @param text The text for the comment * @return An initialized OFXMLComment */ - (instancetype)initWithText: (OFString *)text; | < < | 49 50 51 52 53 54 55 56 57 58 | * @brief Initializes an already allocated OFXMLComment with the specified * text. * * @param text The text for the comment * @return An initialized OFXMLComment */ - (instancetype)initWithText: (OFString *)text; @end OF_ASSUME_NONNULL_END |
Modified src/OFXMLComment.m from [9e48182a96] to [1e1070f991].
1 | /* | | | | | | > > > > | < > | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "OFXMLComment.h" #import "OFXMLNode+Private.h" #import "OFString.h" #import "OFInvalidArgumentException.h" @implementation OFXMLComment @synthesize text = _text; + (instancetype)commentWithText: (OFString *)text |
︙ | ︙ | |||
39 40 41 42 43 44 45 | @try { _text = [text copy]; } @catch (id e) { [self release]; @throw e; } | < < < < < < < < < < < < < < < < < < < < < < | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | @try { _text = [text copy]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_text release]; |
︙ | ︙ | |||
105 106 107 108 109 110 111 | return [OFString stringWithFormat: @"<!--%@-->", _text]; } - (OFString *)description { return self.XMLString; } | < < < < < < < | 86 87 88 89 90 91 92 93 | return [OFString stringWithFormat: @"<!--%@-->", _text]; } - (OFString *)description { return self.XMLString; } @end |
Deleted src/OFXMLElement+Serialization.h version [fdd03ade73].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/OFXMLElement+Serialization.m version [c71645309e].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Modified src/OFXMLElement.h from [0fc969c160] to [5421a8a6d2].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFXMLNode.h" OF_ASSUME_NONNULL_BEGIN @class OFArray OF_GENERIC(ObjectType); |
︙ | ︙ | |||
58 59 60 61 62 63 64 | /** * @brief An array with the attributes of the element. */ @property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFArray OF_GENERIC(OFXMLAttribute *) *attributes; /** | | | 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | /** * @brief An array with the attributes of the element. */ @property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFArray OF_GENERIC(OFXMLAttribute *) *attributes; /** * @brief An array of @ref OFXMLNode with all children of the element. */ @property OF_NULLABLE_PROPERTY (nonatomic, copy) OFArray OF_GENERIC(OFXMLNode *) *children; /** * @brief All children that are elements. */ |
︙ | ︙ | |||
317 318 319 320 321 322 323 | * @param index The index where the child is added */ - (void)insertChild: (OFXMLNode *)child atIndex: (size_t)index; /** * @brief Inserts the specified children at the specified index. * | | | 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 | * @param index The index where the child is added */ - (void)insertChild: (OFXMLNode *)child atIndex: (size_t)index; /** * @brief Inserts the specified children at the specified index. * * @param children An array of @ref OFXMLNode which are added as children * @param index The index where the child is added */ - (void)insertChildren: (OFArray OF_GENERIC(OFXMLNode *) *)children atIndex: (size_t)index; /** * @brief Removes the first child that is equal to the specified OFXMLNode. |
︙ | ︙ | |||
430 431 432 433 434 435 436 | * needs a prefix */ - (OFString *)XMLStringWithDefaultNamespace: (OFString *)defaultNS indentation: (unsigned int)indentation; @end OF_ASSUME_NONNULL_END | < < | 434 435 436 437 438 439 440 | * needs a prefix */ - (OFString *)XMLStringWithDefaultNamespace: (OFString *)defaultNS indentation: (unsigned int)indentation; @end OF_ASSUME_NONNULL_END |
Modified src/OFXMLElement.m from [ada192cadd] to [f201f9c925].
1 | /* | | | | | | > > > > | < > | < < < < < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #define OF_XML_ELEMENT_M #include <stdlib.h> #include <string.h> #import "OFXMLElement.h" #import "OFArray.h" #import "OFData.h" #import "OFDictionary.h" #import "OFStream.h" #import "OFString.h" #import "OFXMLAttribute.h" #import "OFXMLCDATA.h" #import "OFXMLCharacters.h" #import "OFXMLElementBuilder.h" #import "OFXMLNode+Private.h" #import "OFXMLParser.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFMalformedXMLException.h" #import "OFUnboundNamespaceException.h" @interface OFXMLElementElementBuilderDelegate: OFObject <OFXMLElementBuilderDelegate> { @public OFXMLElement *_element; } @end |
︙ | ︙ | |||
265 266 267 268 269 270 271 | [_attributes release]; _attributes = [element->_attributes retain]; [_namespaces release]; _namespaces = [element->_namespaces retain]; [_children release]; _children = [element->_children retain]; | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | [_attributes release]; _attributes = [element->_attributes retain]; [_namespaces release]; _namespaces = [element->_namespaces retain]; [_children release]; _children = [element->_children retain]; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; } return self; |
︙ | ︙ | |||
629 630 631 632 633 634 635 | memcpy(cString + i, _name.UTF8String, _name.UTF8StringLength); i += _name.UTF8StringLength; } else cString[i++] = '/'; cString[i++] = '>'; | | | 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 | memcpy(cString + i, _name.UTF8String, _name.UTF8StringLength); i += _name.UTF8StringLength; } else cString[i++] = '/'; cString[i++] = '>'; OFAssert(i == length); objc_autoreleasePoolPop(pool); ret = [OFString stringWithUTF8String: cString length: length]; } @finally { OFFreeMemory(cString); |
︙ | ︙ | |||
666 667 668 669 670 671 672 | { return [self of_XMLStringWithDefaultNS: defaultNS namespaces: nil indentation: indentation level: 0]; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 563 564 565 566 567 568 569 570 571 572 573 574 575 576 | { return [self of_XMLStringWithDefaultNS: defaultNS namespaces: nil indentation: indentation level: 0]; } - (void)addAttribute: (OFXMLAttribute *)attribute { if (![attribute isKindOfClass: [OFXMLAttribute class]]) @throw [OFInvalidArgumentException exception]; if (_attributes == nil) _attributes = [[OFMutableArray alloc] init]; |
︙ | ︙ |
Modified src/OFXMLElementBuilder.h from [db177baac1] to [98da05e815].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFXMLParser.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ |
Modified src/OFXMLElementBuilder.m from [87c5fa2116] to [71d2c3adcd].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFXMLElementBuilder.h" #import "OFArray.h" #import "OFXMLAttribute.h" |
︙ | ︙ |
Modified src/OFXMLNode+Private.h from [fcadbb17a0] to [2d5bdd7220].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFXMLNode.h" OF_ASSUME_NONNULL_BEGIN @interface OFXMLNode () |
︙ | ︙ |
Modified src/OFXMLNode.h from [5f2e542386] to [7a1414d4b6].
1 | /* | | | | | | > > > > | < > | < < < | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFXMLNode OFXMLNode.h ObjFW/OFXMLNode.h * * @brief A class which stores an XML element. */ @interface OFXMLNode: OFObject <OFCopying> { OF_RESERVE_IVARS(OFXMLNode, 4) } /** * @brief The contents of the node as a string value. * |
︙ | ︙ | |||
73 74 75 76 77 78 79 | * @throw OFUnboundNamespaceException The node uses a namespace that was not * bound to a prefix in a context where it * needs a prefix */ @property (readonly, nonatomic) OFString *XMLString; - (instancetype)init OF_UNAVAILABLE; | < | 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | * @throw OFUnboundNamespaceException The node uses a namespace that was not * bound to a prefix in a context where it * needs a prefix */ @property (readonly, nonatomic) OFString *XMLString; - (instancetype)init OF_UNAVAILABLE; /** * @brief The contents of the receiver as a `long long` value in the specified * base. * * @param base The base to use. If the base is 0, base 16 is assumed if the * string starts with 0x (after stripping white spaces). If the |
︙ | ︙ |
Modified src/OFXMLNode.m from [ae31a5d0f3] to [b97a6d6e13].
1 | /* | | | | | | > > > > | < > | < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFXMLNode.h" #import "OFString.h" @implementation OFXMLNode - (instancetype)of_init { return [super init]; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (OFString *)stringValue { OF_UNRECOGNIZED_SELECTOR } |
︙ | ︙ | |||
80 81 82 83 84 85 86 | } - (OFString *)description { return self.XMLString; } | < < < < < | 79 80 81 82 83 84 85 86 87 88 89 90 | } - (OFString *)description { return self.XMLString; } - (id)copy { return [self retain]; } @end |
Modified src/OFXMLParser.h from [89f07c26d5] to [c32cb7610c].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFString.h" #import "OFXMLAttribute.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ | |||
39 40 41 42 43 44 45 | * * @param parser The parser which found a processing instruction * @param target The target of the processing instruction * @param text The text of the processing instruction */ - (void)parser: (OFXMLParser *)parser foundProcessingInstructionWithTarget: (OFString *)target | | | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | * * @param parser The parser which found a processing instruction * @param target The target of the processing instruction * @param text The text of the processing instruction */ - (void)parser: (OFXMLParser *)parser foundProcessingInstructionWithTarget: (OFString *)target text: (nullable OFString *)text; /** * @brief This callback is called when the XML parser found the start of a new * tag. * * @param parser The parser which found a new tag * @param name The name of the tag which just started |
︙ | ︙ |
Modified src/OFXMLParser.m from [7be6fc7234] to [28790f1d96].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #define OF_XML_PARSER_M #include <string.h> |
︙ | ︙ |
Modified src/OFXMLProcessingInstruction.h from [2e0c868afb] to [f992e98a30].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFXMLNode.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ | |||
56 57 58 59 60 61 62 | * * @param target The target for the processing instruction * @param text The text for the processing instruction * @return An initialized OFXMLProcessingInstruction */ - (instancetype)initWithTarget: (OFString *)target text: (OFString *)text OF_DESIGNATED_INITIALIZER; | < < | 60 61 62 63 64 65 66 67 68 69 | * * @param target The target for the processing instruction * @param text The text for the processing instruction * @return An initialized OFXMLProcessingInstruction */ - (instancetype)initWithTarget: (OFString *)target text: (OFString *)text OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END |
Modified src/OFXMLProcessingInstruction.m from [98f7922e9f] to [38168076f8].
1 | /* | | | | | | > > > > | < > | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "OFXMLProcessingInstruction.h" #import "OFString.h" #import "OFXMLAttribute.h" #import "OFXMLNode+Private.h" #import "OFInvalidArgumentException.h" @implementation OFXMLProcessingInstruction @synthesize target = _target, text = _text; |
︙ | ︙ | |||
44 45 46 47 48 49 50 | _target = [target copy]; _text = [text copy]; } @catch (id e) { [self release]; @throw e; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < | 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | _target = [target copy]; _text = [text copy]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_target release]; [_text release]; |
︙ | ︙ | |||
134 135 136 137 138 139 140 | return [OFString stringWithFormat: @"<?%@?>", _target]; } - (OFString *)description { return self.XMLString; } | < < < < < < < < < < < < < < < | 110 111 112 113 114 115 116 117 | return [OFString stringWithFormat: @"<?%@?>", _target]; } - (OFString *)description { return self.XMLString; } @end |
Modified src/OFZIPArchive.h from [b8f3f259b0] to [f4b92af793].
1 | /* | | | | | | > > > > | < > | > > > > > > > > > > > > > > > > > > > > > > > < > > < | > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFString.h" #import "OFZIPArchiveEntry.h" OF_ASSUME_NONNULL_BEGIN @class OFArray OF_GENERIC(ObjectType); @class OFMutableArray OF_GENERIC(ObjectType); @class OFMutableDictionary OF_GENERIC(KeyType, ObjectType); @class OFSeekableStream; @class OFStream; @class OFZIPArchive; /** * @protocol OFZIPArchiveDelegate OFZIPArchive.h ObjFW/OFZIPArchive.h * * @brief A delegate for OFZIPArchive. */ @protocol OFZIPArchiveDelegate <OFObject> @optional /** * @brief A callback that is called when an @ref OFZIPArchive wants to read a * different archive part. * * @param archive The archive that wants to read another part * @param partNumber The number of the part the archive wants to read * @param lastPartNumber The number of the last archive part * @return The stream to read the needed part, or `nil` if no such part exists */ - (nullable OFSeekableStream *)archive: (OFZIPArchive *)archive wantsPartNumbered: (unsigned int)partNumber lastPartNumber: (unsigned int)lastPartNumber; @end /** * @class OFZIPArchive OFZIPArchive.h ObjFW/OFZIPArchive.h * * @brief A class for accessing and manipulating ZIP files. */ OF_SUBCLASSING_RESTRICTED @interface OFZIPArchive: OFObject { #ifdef OF_ZIP_ARCHIVE_M @public #endif OFObject <OFZIPArchiveDelegate> *_Nullable _delegate; OF_KINDOF(OFStream *) _stream; int64_t _offset; uint_least8_t _mode; uint32_t _diskNumber, _lastDiskNumber; @protected uint32_t _centralDirectoryDisk; uint64_t _centralDirectoryEntriesInDisk, _centralDirectoryEntries; uint64_t _centralDirectorySize; int64_t _centralDirectoryOffset; OFString *_Nullable _archiveComment; #ifdef OF_ZIP_ARCHIVE_M @public #endif OFMutableArray OF_GENERIC(OFZIPArchiveEntry *) *_entries; OFMutableDictionary OF_GENERIC(OFString *, OFZIPArchiveEntry *) *_pathToEntryMap; OFStream *_Nullable _lastReturnedStream; } /** * @brief The delegate of the ZIP archive. */ @property OF_NULLABLE_PROPERTY (assign, nonatomic) OFObject <OFZIPArchiveDelegate> *delegate; /** * @brief The archive comment. */ @property OF_NULLABLE_PROPERTY (copy, nonatomic) OFString *archiveComment; /** * @brief The entries in the central directory of the archive as an array of |
︙ | ︙ | |||
81 82 83 84 85 86 87 | * @throw OFInvalidFormatException The format is not that of a valid ZIP archive */ + (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode; /** * @brief Creates a new OFZIPArchive object with the specified file. * | | | | | | | | 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | * @throw OFInvalidFormatException The format is not that of a valid ZIP archive */ + (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode; /** * @brief Creates a new OFZIPArchive object with the specified file. * * @param IRI The IRI to the ZIP file * @param mode The mode for the ZIP file. Valid modes are "r" for reading, * "w" for creating a new file and "a" for appending to an existing * archive. * @return A new, autoreleased OFZIPArchive * @throw OFInvalidFormatException The format is not that of a valid ZIP archive */ + (instancetype)archiveWithIRI: (OFIRI *)IRI mode: (OFString *)mode; /** * @brief Creates an IRI for accessing the specified file within the specified * ZIP archive. * * @param path The path of the file within the archive * @param IRI The IRI of the archive * @return An IRI for accessing the specified file within the specified ZIP * archive */ + (OFIRI *)IRIForFilePath: (OFString *)path inArchiveWithIRI: (OFIRI *)IRI; - (instancetype)init OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFZIPArchive object with the * specified stream. * |
︙ | ︙ | |||
122 123 124 125 126 127 128 | - (instancetype)initWithStream: (OFStream *)stream mode: (OFString *)mode OF_DESIGNATED_INITIALIZER; /** * @brief Initializes an already allocated OFZIPArchive object with the * specified file. * | | | | 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | - (instancetype)initWithStream: (OFStream *)stream mode: (OFString *)mode OF_DESIGNATED_INITIALIZER; /** * @brief Initializes an already allocated OFZIPArchive object with the * specified file. * * @param IRI The IRI to the ZIP file * @param mode The mode for the ZIP file. Valid modes are "r" for reading, * "w" for creating a new file and "a" for appending to an existing * archive. * @return An initialized OFZIPArchive * @throw OFInvalidFormatException The format is not that of a valid ZIP archive */ - (instancetype)initWithIRI: (OFIRI *)IRI mode: (OFString *)mode; /** * @brief Returns a stream for reading the specified file from the archive. * * @note This method is only available in read mode. * * @note The returned stream conforms to @ref OFReadyForReadingObserving if the |
︙ | ︙ | |||
184 185 186 187 188 189 190 | * * The uncompressed size. * * The CRC32. * * Bit 3 and 11 of the general purpose bit flag. * @return A stream for writing the specified entry to the archive * @throw OFNotOpenException The archive is not open * @throw OFInvalidArgumentException The archive is not in write mode * @throw OFOpenItemFailedException Opening the specified file within the | | > > | | | 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | * * The uncompressed size. * * The CRC32. * * Bit 3 and 11 of the general purpose bit flag. * @return A stream for writing the specified entry to the archive * @throw OFNotOpenException The archive is not open * @throw OFInvalidArgumentException The archive is not in write mode * @throw OFOpenItemFailedException Opening the specified file within the * archive failed. If * @ref OFOpenItemFailedException#errNo is * `EEXIST`, it failed because there is * already a file with the same name in the * archive. * @throw OFNotImplementedException The desired compression method is not * implemented */ - (OFStream *)streamForWritingEntry: (OFZIPArchiveEntry *)entry; /** * @brief Closes the OFZIPArchive. |
︙ | ︙ |
Modified src/OFZIPArchive.m from [3d9576934f] to [7c50e25802].
1 | /* | | | | | | > > > > | < > | | > > < < | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #define OF_ZIP_ARCHIVE_M #include "config.h" #include <errno.h> #import "OFZIPArchive.h" #import "OFZIPArchiveEntry.h" #import "OFZIPArchiveEntry+Private.h" #import "OFArchiveIRIHandler.h" #import "OFArray.h" #import "OFCRC32.h" #import "OFData.h" #import "OFDictionary.h" #import "OFIRI.h" #import "OFIRIHandler.h" #import "OFInflate64Stream.h" #import "OFInflateStream.h" #import "OFSeekableStream.h" #import "OFStream.h" #import "OFChecksumMismatchException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFNotImplementedException.h" #import "OFNotOpenException.h" #import "OFOpenItemFailedException.h" #import "OFOutOfRangeException.h" #import "OFSeekFailedException.h" #import "OFTruncatedDataException.h" #import "OFUnsupportedVersionException.h" #import "OFWriteFailedException.h" /* * TODO: Current limitations: * - Encrypted files cannot be read. */ enum { modeRead, modeWrite, modeAppend |
︙ | ︙ | |||
81 82 83 84 85 86 87 | - (bool)matchesEntry: (OFZIPArchiveEntry *)entry; @end OF_DIRECT_MEMBERS @interface OFZIPArchiveFileReadStream: OFStream { OFZIPArchive *_archive; | > | | > | > > | 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | - (bool)matchesEntry: (OFZIPArchiveEntry *)entry; @end OF_DIRECT_MEMBERS @interface OFZIPArchiveFileReadStream: OFStream { OFZIPArchive *_archive; OFZIPArchiveEntryCompressionMethod _compressionMethod; OF_KINDOF(OFStream *) _decompressedStream; OFZIPArchiveEntry *_entry; unsigned long long _toRead; uint32_t _CRC32; bool _atEndOfStream; } - (instancetype)of_initWithArchive: (OFZIPArchive *)archive stream: (OFStream *)stream entry: (OFZIPArchiveEntry *)entry; @end OF_DIRECT_MEMBERS @interface OFZIPArchiveFileWriteStream: OFStream { OFZIPArchive *_archive; OF_KINDOF(OFStream *) _stream; uint32_t _CRC32; OFStreamOffset _CRC32Offset, _size64Offset; @public unsigned long long _bytesWritten; OFMutableZIPArchiveEntry *_entry; } - (instancetype)of_initWithArchive: (OFZIPArchive *)archive stream: (OFStream *)stream entry: (OFMutableZIPArchiveEntry *)entry CRC32Offset: (OFStreamOffset)CRC32Offset size64Offset: (OFStreamOffset)size64Offset; @end uint32_t OFZIPArchiveReadField32(const uint8_t **data, uint16_t *size) { uint32_t field = 0; |
︙ | ︙ | |||
143 144 145 146 147 148 149 150 | *data += 8; *size -= 8; return field; } static void | > > > | > > > > > > > > > > > > > > > > > > > > | < < < | | | | | 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | *data += 8; *size -= 8; return field; } @implementation OFZIPArchive @synthesize delegate = _delegate, archiveComment = _archiveComment; static void seekOrThrowInvalidFormat(OFZIPArchive *archive, const uint32_t *diskNumber, OFStreamOffset offset, OFSeekWhence whence) { if (diskNumber != NULL && *diskNumber != archive->_diskNumber) { OFStream *oldStream = archive->_stream; OFSeekableStream *stream; if (archive->_mode != modeRead || *diskNumber > archive->_lastDiskNumber) @throw [OFInvalidFormatException exception]; stream = [archive->_delegate archive: archive wantsPartNumbered: *diskNumber lastPartNumber: archive->_lastDiskNumber]; if (stream == nil) @throw [OFInvalidFormatException exception]; archive->_diskNumber = *diskNumber; archive->_stream = [stream retain]; [oldStream release]; } @try { [archive->_stream seekToOffset: offset whence: whence]; } @catch (OFSeekFailedException *e) { if (e.errNo == EINVAL) @throw [OFInvalidFormatException exception]; @throw e; } } + (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode { return [[[self alloc] initWithStream: stream mode: mode] autorelease]; } + (instancetype)archiveWithIRI: (OFIRI *)IRI mode: (OFString *)mode { return [[[self alloc] initWithIRI: IRI mode: mode] autorelease]; } + (OFIRI *)IRIForFilePath: (OFString *)path inArchiveWithIRI: (OFIRI *)IRI { return OFArchiveIRIHandlerIRIForFileInArchive(@"zip", path, IRI); } - (instancetype)init { OF_INVALID_INIT_METHOD } |
︙ | ︙ | |||
208 209 210 211 212 213 214 | [self of_readZIPInfo]; [self of_readEntries]; } if (_mode == modeAppend) { _offset = _centralDirectoryOffset; | | | | | | 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | [self of_readZIPInfo]; [self of_readEntries]; } if (_mode == modeAppend) { _offset = _centralDirectoryOffset; seekOrThrowInvalidFormat(self, NULL, (OFStreamOffset)_offset, OFSeekSet); } } @catch (id e) { /* * If we are in write or append mode, we do not want -[close] * to write anything to it on error - after all, it might not * be a ZIP file which we would destroy otherwise. */ [_stream release]; _stream = nil; [self release]; @throw e; } return self; } - (instancetype)initWithIRI: (OFIRI *)IRI mode: (OFString *)mode { void *pool = objc_autoreleasePoolPush(); OFStream *stream; @try { if ([mode isEqual: @"a"]) stream = [OFIRIHandler openItemAtIRI: IRI mode: @"r+"]; else stream = [OFIRIHandler openItemAtIRI: IRI mode: mode]; } @catch (id e) { [self release]; @throw e; } self = [self initWithStream: stream mode: mode]; |
︙ | ︙ | |||
270 271 272 273 274 275 276 | { void *pool = objc_autoreleasePoolPush(); uint16_t commentLength; OFStreamOffset offset = -22; bool valid = false; do { | < | | | > < | | > | | > > > | 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 | { void *pool = objc_autoreleasePoolPush(); uint16_t commentLength; OFStreamOffset offset = -22; bool valid = false; do { seekOrThrowInvalidFormat(self, NULL, offset, OFSeekEnd); if ([_stream readLittleEndianInt32] == 0x06054B50) { valid = true; break; } } while (--offset >= -65557); if (!valid) @throw [OFInvalidFormatException exception]; _diskNumber = _lastDiskNumber = [_stream readLittleEndianInt16]; _centralDirectoryDisk = [_stream readLittleEndianInt16]; _centralDirectoryEntriesInDisk = [_stream readLittleEndianInt16]; _centralDirectoryEntries = [_stream readLittleEndianInt16]; _centralDirectorySize = [_stream readLittleEndianInt32]; _centralDirectoryOffset = [_stream readLittleEndianInt32]; commentLength = [_stream readLittleEndianInt16]; _archiveComment = [[_stream readStringWithLength: commentLength encoding: OFStringEncodingCodepage437] copy]; if (_lastDiskNumber == 0xFFFF || _centralDirectoryDisk == 0xFFFF || _centralDirectoryEntriesInDisk == 0xFFFF || _centralDirectoryEntries == 0xFFFF || _centralDirectorySize == 0xFFFFFFFF || _centralDirectoryOffset == 0xFFFFFFFF) { uint32_t diskNumber; int64_t offset64; uint64_t size; seekOrThrowInvalidFormat(self, NULL, offset - 20, OFSeekEnd); if ([_stream readLittleEndianInt32] != 0x07064B50) { objc_autoreleasePoolPop(pool); return; } /* * FIXME: Handle number of the disk containing ZIP64 end of * central directory record. */ diskNumber = [_stream readLittleEndianInt32]; offset64 = [_stream readLittleEndianInt64]; _diskNumber = _lastDiskNumber = [_stream readLittleEndianInt32]; if (offset64 < 0 || (OFStreamOffset)offset64 != offset64) @throw [OFOutOfRangeException exception]; seekOrThrowInvalidFormat(self, &diskNumber, (OFStreamOffset)offset64, OFSeekSet); if ([_stream readLittleEndianInt32] != 0x06064B50) @throw [OFInvalidFormatException exception]; size = [_stream readLittleEndianInt64]; if (size < 44) @throw [OFInvalidFormatException exception]; /* version made by */ [_stream readLittleEndianInt16]; /* version needed to extract */ [_stream readLittleEndianInt16]; diskNumber = [_stream readLittleEndianInt32]; if (diskNumber != _diskNumber) @throw [OFInvalidFormatException exception]; _centralDirectoryDisk = [_stream readLittleEndianInt32]; _centralDirectoryEntriesInDisk = [_stream readLittleEndianInt64]; _centralDirectoryEntries = [_stream readLittleEndianInt64]; _centralDirectorySize = [_stream readLittleEndianInt64]; _centralDirectoryOffset = [_stream readLittleEndianInt64]; |
︙ | ︙ | |||
361 362 363 364 365 366 367 | { void *pool = objc_autoreleasePoolPush(); if (_centralDirectoryOffset < 0 || (OFStreamOffset)_centralDirectoryOffset != _centralDirectoryOffset) @throw [OFOutOfRangeException exception]; | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 | { void *pool = objc_autoreleasePoolPush(); if (_centralDirectoryOffset < 0 || (OFStreamOffset)_centralDirectoryOffset != _centralDirectoryOffset) @throw [OFOutOfRangeException exception]; seekOrThrowInvalidFormat(self, &_centralDirectoryDisk, (OFStreamOffset)_centralDirectoryOffset, OFSeekSet); for (size_t i = 0; i < _centralDirectoryEntries; i++) { OFZIPArchiveEntry *entry; char buffer; /* * The stream might have 0 bytes left to read, but might not * realize that before a read is attempted, where it will then * return a length of 0. But OFZIPArchiveEntry expects to be * able to read the entire entry and will then throw an * OFTruncatedDataException. Therefore, try to peek one byte to * make sure the stream realizes that it's at the end. */ if ([_stream readIntoBuffer: &buffer length: 1] == 1) [_stream unreadFromBuffer: &buffer length: 1]; if ([_stream isAtEndOfStream]) { OFStream *oldStream = _stream; OFSeekableStream *stream; if (_diskNumber >= _lastDiskNumber) @throw [OFTruncatedDataException exception]; stream = [_delegate archive: self wantsPartNumbered: _diskNumber + 1 lastPartNumber: _lastDiskNumber]; if (stream == nil) @throw [OFInvalidFormatException exception]; _diskNumber++; _stream = [stream retain]; [oldStream release]; } entry = [[[OFZIPArchiveEntry alloc] of_initWithStream: _stream] autorelease]; if ([_pathToEntryMap objectForKey: entry.fileName] != nil) @throw [OFInvalidFormatException exception]; [_entries addObject: entry]; [_pathToEntryMap setObject: entry forKey: entry.fileName]; |
︙ | ︙ | |||
408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 | } - (OFStream *)streamForReadingFile: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFZIPArchiveEntry *entry; OFZIPArchiveLocalFileHeader *localFileHeader; int64_t offset64; if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; if (_mode != modeRead) @throw [OFInvalidArgumentException exception]; if ((entry = [_pathToEntryMap objectForKey: path]) == nil) @throw [OFOpenItemFailedException exceptionWithPath: path mode: @"r" errNo: ENOENT]; @try { [_lastReturnedStream close]; } @catch (OFNotOpenException *e) { /* Might have already been closed by the user - that's fine. */ } _lastReturnedStream = nil; offset64 = entry.of_localFileHeaderOffset; if (offset64 < 0 || (OFStreamOffset)offset64 != offset64) @throw [OFOutOfRangeException exception]; | > > | | 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 | } - (OFStream *)streamForReadingFile: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFZIPArchiveEntry *entry; OFZIPArchiveLocalFileHeader *localFileHeader; uint32_t startDiskNumber; int64_t offset64; if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; if (_mode != modeRead) @throw [OFInvalidArgumentException exception]; if ((entry = [_pathToEntryMap objectForKey: path]) == nil) @throw [OFOpenItemFailedException exceptionWithPath: path mode: @"r" errNo: ENOENT]; @try { [_lastReturnedStream close]; } @catch (OFNotOpenException *e) { /* Might have already been closed by the user - that's fine. */ } _lastReturnedStream = nil; startDiskNumber = entry.of_startDiskNumber; offset64 = entry.of_localFileHeaderOffset; if (offset64 < 0 || (OFStreamOffset)offset64 != offset64) @throw [OFOutOfRangeException exception]; seekOrThrowInvalidFormat(self, &startDiskNumber, (OFStreamOffset)offset64, OFSeekSet); localFileHeader = [[[OFZIPArchiveLocalFileHeader alloc] initWithStream: _stream] autorelease]; if (![localFileHeader matchesEntry: entry]) @throw [OFInvalidFormatException exception]; |
︙ | ︙ | |||
461 462 463 464 465 466 467 | entry: entry] autorelease]; return _lastReturnedStream; } - (OFStream *)streamForWritingEntry: (OFZIPArchiveEntry *)entry_ { | < > > | 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 | entry: entry] autorelease]; return _lastReturnedStream; } - (OFStream *)streamForWritingEntry: (OFZIPArchiveEntry *)entry_ { int64_t offsetAdd = 0; void *pool; OFMutableZIPArchiveEntry *entry; OFString *fileName; bool seekable; OFStreamOffset CRC32Offset = 0, size64Offset = 0; OFData *extraField; uint16_t fileNameLength, extraFieldLength; if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; if (_mode != modeWrite && _mode != modeAppend) |
︙ | ︙ | |||
503 504 505 506 507 508 509 510 511 512 513 514 | fileNameLength = fileName.UTF8StringLength; extraField = entry.extraField; extraFieldLength = extraField.count; if (UINT16_MAX - extraFieldLength < 20) @throw [OFOutOfRangeException exception]; entry.versionMadeBy = (entry.versionMadeBy & 0xFF00) | 45; entry.minVersionNeeded = (entry.minVersionNeeded & 0xFF00) | 45; entry.compressedSize = 0; entry.uncompressedSize = 0; entry.CRC32 = 0; | > > | > | > > | > > | > > | 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 | fileNameLength = fileName.UTF8StringLength; extraField = entry.extraField; extraFieldLength = extraField.count; if (UINT16_MAX - extraFieldLength < 20) @throw [OFOutOfRangeException exception]; seekable = [_stream isKindOfClass: [OFSeekableStream class]]; entry.versionMadeBy = (entry.versionMadeBy & 0xFF00) | 45; entry.minVersionNeeded = (entry.minVersionNeeded & 0xFF00) | 45; entry.compressedSize = 0; entry.uncompressedSize = 0; entry.CRC32 = 0; entry.generalPurposeBitFlag |= (seekable ? 0 : (1u << 3)) | (1u << 11); entry.of_startDiskNumber = _diskNumber; entry.of_localFileHeaderOffset = _offset; [_stream writeLittleEndianInt32: 0x04034B50]; [_stream writeLittleEndianInt16: entry.minVersionNeeded]; [_stream writeLittleEndianInt16: entry.generalPurposeBitFlag]; [_stream writeLittleEndianInt16: entry.compressionMethod]; [_stream writeLittleEndianInt16: entry.of_lastModifiedFileTime]; [_stream writeLittleEndianInt16: entry.of_lastModifiedFileDate]; /* Written later or data descriptor used instead */ if (seekable) CRC32Offset = [_stream seekToOffset: 0 whence: OFSeekCurrent]; [_stream writeLittleEndianInt32: 0]; /* We use ZIP64 */ [_stream writeLittleEndianInt32: 0xFFFFFFFF]; [_stream writeLittleEndianInt32: 0xFFFFFFFF]; [_stream writeLittleEndianInt16: fileNameLength]; [_stream writeLittleEndianInt16: extraFieldLength + 20]; offsetAdd += 4 + (5 * 2) + (3 * 4) + (2 * 2); [_stream writeString: fileName]; offsetAdd += fileNameLength; [_stream writeLittleEndianInt16: OFZIPArchiveEntryExtraFieldTagZIP64]; [_stream writeLittleEndianInt16: 16]; /* Written later or data descriptor used instead */ if (seekable) size64Offset = [_stream seekToOffset: 0 whence: OFSeekCurrent]; [_stream writeLittleEndianInt64: 0]; [_stream writeLittleEndianInt64: 0]; offsetAdd += (2 * 2) + (2 * 8); if (extraField != nil) [_stream writeData: extraField]; offsetAdd += extraFieldLength; if (INT64_MAX - _offset < offsetAdd) @throw [OFOutOfRangeException exception]; _offset += offsetAdd; _lastReturnedStream = [[OFZIPArchiveFileWriteStream alloc] of_initWithArchive: self stream: _stream entry: entry CRC32Offset: CRC32Offset size64Offset: size64Offset]; objc_autoreleasePoolPop(pool); return [_lastReturnedStream autorelease]; } - (void)of_writeCentralDirectory |
︙ | ︙ | |||
587 588 589 590 591 592 593 | [_stream writeLittleEndianInt64: _centralDirectoryOffset]; /* ZIP64 end of central directory locator */ [_stream writeLittleEndianInt32: 0x07064B50]; [_stream writeLittleEndianInt32: _diskNumber]; [_stream writeLittleEndianInt64: _centralDirectoryOffset + _centralDirectorySize]; | | | 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 | [_stream writeLittleEndianInt64: _centralDirectoryOffset]; /* ZIP64 end of central directory locator */ [_stream writeLittleEndianInt32: 0x07064B50]; [_stream writeLittleEndianInt32: _diskNumber]; [_stream writeLittleEndianInt64: _centralDirectoryOffset + _centralDirectorySize]; [_stream writeLittleEndianInt32: 0]; /* Total number of disks */ /* End of central directory */ [_stream writeLittleEndianInt32: 0x06054B50]; [_stream writeLittleEndianInt16: 0xFFFF]; /* Disk number */ [_stream writeLittleEndianInt16: 0xFFFF]; /* CD disk */ [_stream writeLittleEndianInt16: 0xFFFF]; /* CD entries in disk */ [_stream writeLittleEndianInt16: 0xFFFF]; /* CD entries */ |
︙ | ︙ | |||
732 733 734 735 736 737 738 | stream: (OFStream *)stream entry: (OFZIPArchiveEntry *)entry { self = [super init]; @try { _archive = [archive retain]; | | | | | | | | | > | > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 | stream: (OFStream *)stream entry: (OFZIPArchiveEntry *)entry { self = [super init]; @try { _archive = [archive retain]; _compressionMethod = entry.compressionMethod; switch (_compressionMethod) { case OFZIPArchiveEntryCompressionMethodNone: _decompressedStream = [_archive->_stream retain]; break; case OFZIPArchiveEntryCompressionMethodDeflate: _decompressedStream = [[OFInflateStream alloc] initWithStream: _archive->_stream]; break; case OFZIPArchiveEntryCompressionMethodDeflate64: _decompressedStream = [[OFInflate64Stream alloc] initWithStream: _archive->_stream]; break; default: @throw [OFNotImplementedException exceptionWithSelector: _cmd object: nil]; } _entry = [entry copy]; _toRead = entry.uncompressedSize; _CRC32 = ~0; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { if (_decompressedStream != nil) [self close]; [_entry release]; if (_archive->_lastReturnedStream == self) _archive->_lastReturnedStream = nil; [_archive release]; [super dealloc]; } - (bool)lowlevelIsAtEndOfStream { if (_decompressedStream == nil) @throw [OFNotOpenException exceptionWithObject: self]; return _atEndOfStream; } - (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length { size_t ret; if (_decompressedStream == nil) @throw [OFNotOpenException exceptionWithObject: self]; if (_atEndOfStream) return 0; if ([_archive->_stream isAtEndOfStream] && ![_decompressedStream hasDataInReadBuffer]) { OFStream *oldStream = _archive->_stream, *oldDecompressedStream; OFSeekableStream *stream; if (_archive->_diskNumber >= _archive->_lastDiskNumber) @throw [OFTruncatedDataException exception]; stream = [_archive->_delegate archive: _archive wantsPartNumbered: _archive->_diskNumber + 1 lastPartNumber: _archive->_lastDiskNumber]; if (stream == nil) @throw [OFInvalidFormatException exception]; _archive->_diskNumber++; _archive->_stream = [stream retain]; [oldStream release]; switch (_compressionMethod) { case OFZIPArchiveEntryCompressionMethodNone: oldDecompressedStream = _decompressedStream; _decompressedStream = [_archive->_stream retain]; [oldDecompressedStream release]; break; case OFZIPArchiveEntryCompressionMethodDeflate: case OFZIPArchiveEntryCompressionMethodDeflate64: [_decompressedStream setUnderlyingStream: _archive->_stream]; break; default: @throw [OFNotImplementedException exceptionWithSelector: _cmd object: nil]; } } #if SIZE_MAX >= UINT64_MAX if (length > UINT64_MAX) @throw [OFOutOfRangeException exception]; #endif if (length > _toRead) |
︙ | ︙ | |||
830 831 832 833 834 835 836 | expectedChecksum: expectedChecksum]; } } return ret; } | | | < | < < < > > > > | 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 | expectedChecksum: expectedChecksum]; } } return ret; } - (bool)lowlevelHasDataInReadBuffer { return ((OFStream *)_decompressedStream).hasDataInReadBuffer; } - (int)fileDescriptorForReading { return ((id <OFReadyForReadingObserving>)_decompressedStream) .fileDescriptorForReading; } - (void)close { if (_decompressedStream == nil) @throw [OFNotOpenException exceptionWithObject: self]; [_decompressedStream release]; _decompressedStream = nil; [super close]; } @end @implementation OFZIPArchiveFileWriteStream - (instancetype)of_initWithArchive: (OFZIPArchive *)archive stream: (OFStream *)stream entry: (OFMutableZIPArchiveEntry *)entry CRC32Offset: (OFStreamOffset)CRC32Offset size64Offset: (OFStreamOffset)size64Offset { self = [super init]; _archive = [archive retain]; _stream = [stream retain]; _entry = [entry retain]; _CRC32 = ~0; _CRC32Offset = CRC32Offset; _size64Offset = size64Offset; return self; } - (void)dealloc { if (_stream != nil) |
︙ | ︙ | |||
919 920 921 922 923 924 925 926 927 928 929 930 931 | _CRC32 = OFCRC32(_CRC32, buffer, length); return length; } - (void)close { if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; if (_bytesWritten > UINT64_MAX) @throw [OFOutOfRangeException exception]; | > > > > > > > > > > > > > > > > | | | | > > | | 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 | _CRC32 = OFCRC32(_CRC32, buffer, length); return length; } - (void)close { bool seekable; if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; if (_bytesWritten > UINT64_MAX) @throw [OFOutOfRangeException exception]; seekable = [_stream isKindOfClass: [OFSeekableStream class]]; if (seekable) { OFStreamOffset offset = [_stream seekToOffset: 0 whence: OFSeekCurrent]; [_stream seekToOffset: _CRC32Offset whence: OFSeekSet]; [_stream writeLittleEndianInt32: ~_CRC32]; [_stream seekToOffset: _size64Offset whence: OFSeekSet]; [_stream writeLittleEndianInt64: (uint64_t)_bytesWritten]; [_stream writeLittleEndianInt64: (uint64_t)_bytesWritten]; [_stream seekToOffset: offset whence: OFSeekSet]; } else { [_stream writeLittleEndianInt32: 0x08074B50]; [_stream writeLittleEndianInt32: ~_CRC32]; [_stream writeLittleEndianInt64: (uint64_t)_bytesWritten]; [_stream writeLittleEndianInt64: (uint64_t)_bytesWritten]; } [_stream release]; _stream = nil; _entry.CRC32 = ~_CRC32; _entry.compressedSize = _bytesWritten; _entry.uncompressedSize = _bytesWritten; [_entry makeImmutable]; if (!seekable) _bytesWritten += (2 * 4 + 2 * 8); [_archive->_entries addObject: _entry]; [_archive->_pathToEntryMap setObject: _entry forKey: _entry.fileName]; if (ULLONG_MAX - _archive->_offset < _bytesWritten) @throw [OFOutOfRangeException exception]; _archive->_offset += _bytesWritten; [super close]; } @end |
Modified src/OFZIPArchiveEntry+Private.h from [1ac3d985fc] to [52a463b789].
1 | /* | | | | | | > > > > | < > | > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFZIPArchive.h" OF_ASSUME_NONNULL_BEGIN @interface OFZIPArchiveEntry () @property (readonly, nonatomic) uint16_t of_lastModifiedFileTime, of_lastModifiedFileDate; @property (readonly, nonatomic) uint32_t of_startDiskNumber; @property (readonly, nonatomic) int64_t of_localFileHeaderOffset; - (instancetype)of_init OF_METHOD_FAMILY(init); - (instancetype)of_initWithStream: (OFStream *)stream OF_METHOD_FAMILY(init) OF_DIRECT; - (uint64_t)of_writeToStream: (OFStream *)stream OF_DIRECT; @end @interface OFMutableZIPArchiveEntry () @property (readwrite, nonatomic, setter=of_setStartDiskNumber:) uint32_t of_startDiskNumber; @property (readwrite, nonatomic, setter=of_setLocalFileHeaderOffset:) int64_t of_localFileHeaderOffset; @end OF_ASSUME_NONNULL_END |
Modified src/OFZIPArchiveEntry.h from [463b0f575c] to [dca61b5f88].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFArchiveEntry.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ | |||
194 195 196 197 198 199 200 | * * @param version The ZIP entry version to convert to a string * @return The ZIP entry version as a string */ extern OFString *OFZIPArchiveEntryVersionToString(uint16_t version); /** | | | 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | * * @param version The ZIP entry version to convert to a string * @return The ZIP entry version as a string */ extern OFString *OFZIPArchiveEntryVersionToString(uint16_t version); /** * @brief Converts the ZIP entry compression method to a string. * * @param compressionMethod The ZIP entry compression method to convert to a * string * @return The ZIP entry compression method as a string */ extern OFString *OFZIPArchiveEntryCompressionMethodName( OFZIPArchiveEntryCompressionMethod compressionMethod); |
︙ | ︙ |
Modified src/OFZIPArchiveEntry.m from [87dd5a9fa3] to [ff7db8bf1d].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFZIPArchiveEntry.h" #import "OFZIPArchiveEntry+Private.h" #import "OFData.h" |
︙ | ︙ | |||
403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 | return _lastModifiedFileTime; } - (uint16_t)of_lastModifiedFileDate { return _lastModifiedFileDate; } - (int64_t)of_localFileHeaderOffset { return _localFileHeaderOffset; } - (OFString *)description { void *pool = objc_autoreleasePoolPush(); OFString *compressionMethod = OFZIPArchiveEntryCompressionMethodName(_compressionMethod); OFString *ret = [OFString stringWithFormat: @"<%@:\n" @"\tFile name = %@\n" @"\tFile comment = %@\n" @"\tGeneral purpose bit flag = %u\n" | > > > > > | | | 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 | return _lastModifiedFileTime; } - (uint16_t)of_lastModifiedFileDate { return _lastModifiedFileDate; } - (uint32_t)of_startDiskNumber { return _startDiskNumber; } - (int64_t)of_localFileHeaderOffset { return _localFileHeaderOffset; } - (OFString *)description { void *pool = objc_autoreleasePoolPush(); OFString *compressionMethod = OFZIPArchiveEntryCompressionMethodName(_compressionMethod); OFString *ret = [OFString stringWithFormat: @"<%@:\n" @"\tFile name = %@\n" @"\tFile comment = %@\n" @"\tGeneral purpose bit flag = %u\n" @"\tCompressed size = %llu\n" @"\tUncompressed size = %llu\n" @"\tCompression method = %@\n" @"\tModification date = %@\n" @"\tCRC32 = %08" @PRIX32 @"\n" @"\tExtra field = %@\n" @">", self.class, _fileName, _fileComment, _generalPurposeBitFlag, _compressedSize, _uncompressedSize, compressionMethod, |
︙ | ︙ |
Added src/OFZooArchive.h version [a8baa8f5b7].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFSeekableStream.h" #import "OFString.h" #import "OFZooArchiveEntry.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFZooArchive OFZooArchive.h ObjFW/OFZooArchive.h * * @brief A class for accessing and manipulating Zoo files. */ OF_SUBCLASSING_RESTRICTED @interface OFZooArchive: OFObject { OF_KINDOF(OFStream *) _stream; uint_least8_t _mode; OFStringEncoding _encoding; uint16_t _minVersionNeeded; uint8_t _headerType; OFString *_Nullable _archiveComment; OFZooArchiveEntry *_Nullable _currentEntry; #ifdef OF_ZOO_ARCHIVE_M @public #endif OFStream *_Nullable _lastReturnedStream; @protected OFStreamOffset _lastHeaderOffset; size_t _lastHeaderLength; } /** * @brief The encoding to use for the archive. Defaults to UTF-8. */ @property (nonatomic) OFStringEncoding encoding; /** * @brief The archive comment. */ @property OF_NULLABLE_PROPERTY (copy, nonatomic) OFString *archiveComment; /** * @brief Creates a new OFZooArchive object with the specified stream. * * @param stream A stream from which the Zoo archive will be read. * This needs to be an OFSeekableStream. For writing, the stream * needs to support both reading and writing at the same time. * @param mode The mode for the Zoo file. Valid modes are "r" for reading and * "w" for creating a new file. * @return A new, autoreleased OFZooArchive */ + (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode; /** * @brief Creates a new OFZooArchive object with the specified file. * * @param IRI The IRI to the Zoo file * @param mode The mode for the Zoo file. Valid modes are "r" for reading and * "w" for creating a new file. * @return A new, autoreleased OFZooArchive */ + (instancetype)archiveWithIRI: (OFIRI *)IRI mode: (OFString *)mode; /** * @brief Creates an IRI for accessing the specified file within the specified * Zoo archive. * * @param path The path of the file within the archive * @param IRI The IRI of the archive * @return An IRI for accessing the specified file within the specified Zoo * archive */ + (OFIRI *)IRIForFilePath: (OFString *)path inArchiveWithIRI: (OFIRI *)IRI; - (instancetype)init OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFZooArchive object with the * specified stream. * * @param stream A stream from which the Zoo archive will be read. * This needs to be an OFSeekableStream. For writing, the stream * needs to support both reading and writing at the same time. * @param mode The mode for the Zoo file. Valid modes are "r" for reading and * "w" for creating a new file. * @return An initialized OFZooArchive */ - (instancetype)initWithStream: (OFStream *)stream mode: (OFString *)mode OF_DESIGNATED_INITIALIZER; /** * @brief Initializes an already allocated OFZooArchive object with the * specified file. * * @param IRI The IRI to the Zoo file * @param mode The mode for the Zoo file. Valid modes is "r" for reading and * "w" for creating a new file. * @return An initialized OFZooArchive */ - (instancetype)initWithIRI: (OFIRI *)IRI mode: (OFString *)mode; /** * @brief Returns the next entry from the Zoo archive or `nil` if all entries * have been read. * * @note This is only available in read mode. * * @warning Calling @ref nextEntry will invalidate all streams returned by * @ref streamForReadingCurrentEntry or * @ref streamForWritingEntry:! Reading from or writing to an * invalidated stream will throw an @ref OFReadFailedException or * @ref OFWriteFailedException! * * @return The next entry from the Zoo archive or `nil` if all entries have * been read * @throw OFInvalidFormatException The archive's format is invalid * @throw OFUnsupportedVersionException The archive's format is of an * unsupported version * @throw OFTruncatedDataException The archive was truncated */ - (nullable OFZooArchiveEntry *)nextEntry; /** * @brief Returns a stream for reading the current entry. * * @note This is only available in read mode. * * @note The returned stream conforms to @ref OFReadyForReadingObserving if the * underlying stream does so, too. * * @return A stream for reading the current entry * @throw OFSeekFailedException Seeking to the data in the archive failed */ - (OFStream *)streamForReadingCurrentEntry; /** * @brief Returns a stream for writing the specified entry. * * @note This is only available in write and append mode. * * @note The returned stream conforms to @ref OFReadyForWritingObserving if the * underlying stream does so, too. * * @warning Calling @ref streamForWritingEntry: will invalidate all streams * returned by @ref streamForReadingCurrentEntry or * @ref streamForWritingEntry:! Reading from or writing to an * invalidated stream will throw an @ref OFReadFailedException or * @ref OFWriteFailedException! * * @param entry The entry for which a stream for writing should be returned.@n * The following parts of the specified entry will be ignored: * * The header type. * * The minimum version needed. * * The compressed size. * * The uncompressed size. * * The CRC16. * @return A stream for writing the specified entry */ - (OFStream *)streamForWritingEntry: (OFZooArchiveEntry *)entry; /** * @brief Closes the OFZooArchive. * * @throw OFNotOpenException The archive is not open */ - (void)close; @end OF_ASSUME_NONNULL_END |
Added src/OFZooArchive.m version [5083c851c9].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #define OF_ZOO_ARCHIVE_M #include "config.h" #include <errno.h> #import "OFZooArchive.h" #import "OFZooArchiveEntry.h" #import "OFZooArchiveEntry+Private.h" #import "OFArchiveIRIHandler.h" #import "OFCRC16.h" #import "OFIRI.h" #import "OFIRIHandler.h" #import "OFKernelEventObserver.h" #import "OFLHADecompressingStream.h" #import "OFSeekableStream.h" #import "OFStream.h" #import "OFString.h" #import "OFChecksumMismatchException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFNotImplementedException.h" #import "OFNotOpenException.h" #import "OFOutOfRangeException.h" #import "OFTruncatedDataException.h" #import "OFUnsupportedVersionException.h" #import "OFWriteFailedException.h" enum { modeRead, modeWrite }; OF_DIRECT_MEMBERS @interface OFZooArchive () - (void)of_readArchiveHeader; @end OF_DIRECT_MEMBERS @interface OFZooArchiveFileReadStream: OFStream <OFReadyForReadingObserving> { OFZooArchive *_archive; OF_KINDOF(OFStream *) _stream; OFStream *_decompressedStream; OFZooArchiveEntry *_entry; unsigned long long _toRead; uint16_t _CRC16; bool _atEndOfStream; } - (instancetype)of_initWithArchive: (OFZooArchive *)archive stream: (OFStream *)stream entry: (OFZooArchiveEntry *)entry; @end OF_DIRECT_MEMBERS @interface OFZooArchiveFileWriteStream: OFStream <OFReadyForWritingObserving> { OFZooArchive *_archive; OFMutableZooArchiveEntry *_entry; OFStringEncoding _encoding; OFSeekableStream *_stream; OFStreamOffset *_lastHeaderOffset; size_t *_lastHeaderLength; uint32_t _bytesWritten; uint16_t _CRC16; } - (instancetype)of_initWithArchive: (OFZooArchive *)archive stream: (OFSeekableStream *)stream entry: (OFZooArchiveEntry *)entry encoding: (OFStringEncoding)encoding lastHeaderOffset: (OFStreamOffset *)lastHeaderOffset lastHeaderLength: (size_t *)lastHeaderLength; @end @implementation OFZooArchive @synthesize encoding = _encoding; + (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode { return [[[self alloc] initWithStream: stream mode: mode] autorelease]; } + (instancetype)archiveWithIRI: (OFIRI *)IRI mode: (OFString *)mode { return [[[self alloc] initWithIRI: IRI mode: mode] autorelease]; } + (OFIRI *)IRIForFilePath: (OFString *)path inArchiveWithIRI: (OFIRI *)IRI { return OFArchiveIRIHandlerIRIForFileInArchive(@"zoo", path, IRI); } - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithStream: (OFStream *)stream mode: (OFString *)mode { self = [super init]; @try { if ([mode isEqual: @"r"]) _mode = modeRead; else if ([mode isEqual: @"w"]) _mode = modeWrite; else if ([mode isEqual: @"a"]) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: nil]; else @throw [OFInvalidArgumentException exception]; if (![stream isKindOfClass: [OFSeekableStream class]]) @throw [OFInvalidArgumentException exception]; _stream = [stream retain]; _encoding = OFStringEncodingUTF8; if (_mode == modeRead) [self of_readArchiveHeader]; } @catch (id e) { [self release]; @throw e; } return self; } - (instancetype)initWithIRI: (OFIRI *)IRI mode: (OFString *)mode { void *pool = objc_autoreleasePoolPush(); OFStream *stream; @try { if ([mode isEqual: @"w"]) stream = [OFIRIHandler openItemAtIRI: IRI mode: @"w+"]; else stream = [OFIRIHandler openItemAtIRI: IRI mode: mode]; } @catch (id e) { [self release]; @throw e; } self = [self initWithStream: stream mode: mode]; objc_autoreleasePoolPop(pool); return self; } - (void)dealloc { if (_stream != nil) [self close]; [_archiveComment release]; [_currentEntry release]; [super dealloc]; } - (void)of_readArchiveHeader { char headerText[20]; uint32_t firstFileOffset, commentOffset; uint16_t commentLength; [_stream readIntoBuffer: headerText exactLength: 20]; if ([_stream readLittleEndianInt32] != 0xFDC4A7DC) @throw [OFInvalidFormatException exception]; firstFileOffset = [_stream readLittleEndianInt32]; if ([_stream readLittleEndianInt32] != ~(uint32_t)(firstFileOffset - 1)) @throw [OFInvalidFormatException exception]; if ((_minVersionNeeded = [_stream readBigEndianInt16]) > 0x201) @throw [OFUnsupportedVersionException exceptionWithVersion: [OFString stringWithFormat: @"%" PRIu8 @".%" PRIu8, _minVersionNeeded >> 8, _minVersionNeeded & 0xFF]]; if ((_headerType = [_stream readInt8]) > 1) @throw [OFUnsupportedVersionException exceptionWithVersion: [OFString stringWithFormat: @"%" PRIu8, _headerType]]; commentOffset = [_stream readLittleEndianInt32]; commentLength = [_stream readLittleEndianInt16]; if (commentOffset > 0) { [_stream seekToOffset: commentOffset whence: OFSeekSet]; _archiveComment = [_stream readStringWithLength: commentLength encoding: _encoding]; } [_stream seekToOffset: firstFileOffset whence: OFSeekSet]; } - (OFString *)archiveComment { return _archiveComment; } - (void)setArchiveComment: (OFString *)comment { void *pool = objc_autoreleasePoolPush(); OFString *old; if ([comment cStringLengthWithEncoding: _encoding] > UINT16_MAX) @throw [OFOutOfRangeException exception]; old = _archiveComment; _archiveComment = [comment copy]; [old release]; objc_autoreleasePoolPop(pool); } - (OFZooArchiveEntry *)nextEntry { if (_mode != modeRead) @throw [OFInvalidArgumentException exception]; if (_currentEntry != nil) [_stream seekToOffset: _currentEntry->_nextHeaderOffset whence: OFSeekSet]; [_currentEntry release]; _currentEntry = nil; @try { [_lastReturnedStream close]; } @catch (OFNotOpenException *e) { /* Might have already been closed by the user - that's fine. */ } _lastReturnedStream = nil; _currentEntry = [[OFZooArchiveEntry alloc] of_initWithStream: _stream encoding: _encoding]; return _currentEntry; } - (OFStream *)streamForReadingCurrentEntry { if (_mode != modeRead) @throw [OFInvalidArgumentException exception]; if (_currentEntry == nil) @throw [OFInvalidArgumentException exception]; _lastReturnedStream = [[[OFZooArchiveFileReadStream alloc] of_initWithArchive: self stream: _stream entry: _currentEntry] autorelease]; return _lastReturnedStream; } - (void)of_fixUpLastHeader { OFStreamOffset offset; unsigned char *buffer; if (_lastHeaderOffset == 0) return; offset = [_stream seekToOffset: 0 whence: OFSeekCurrent]; if (offset < 0 || (unsigned long long)offset > UINT32_MAX) @throw [OFOutOfRangeException exception]; OFEnsure(_lastHeaderLength >= 56); [_stream seekToOffset: _lastHeaderOffset whence: OFSeekSet]; buffer = OFAllocMemory(1, _lastHeaderLength); @try { uint16_t tmp16; uint32_t tmp32; [_stream readIntoBuffer: buffer exactLength: _lastHeaderLength]; tmp32 = OFToLittleEndian32((uint32_t)offset); memcpy(buffer + 6, &tmp32, 4); tmp16 = OFToLittleEndian16( OFCRC16(0, buffer, _lastHeaderLength)); memcpy(buffer + 54, &tmp16, 2); [_stream seekToOffset: _lastHeaderOffset whence: OFSeekSet]; [_stream writeBuffer: buffer length: _lastHeaderLength]; [_stream seekToOffset: offset whence: OFSeekSet]; } @finally { OFFreeMemory(buffer); } } - (OFStream *)streamForWritingEntry: (OFZooArchiveEntry *)entry { if (_mode != modeWrite) @throw [OFInvalidArgumentException exception]; if (entry.compressionMethod != 0) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; if (_lastHeaderOffset == 0) { uint16_t commentLength = [_archiveComment cStringLengthWithEncoding: _encoding]; /* First file - write header. */ [_stream writeBuffer: "ObjFW Zoo Archive.\x1F" length: 20]; [_stream writeLittleEndianInt32: 0xFDC4A7DC]; [_stream writeLittleEndianInt32: 42 + commentLength]; [_stream writeLittleEndianInt32: -(42 + commentLength)]; /* TODO: Increase to 0x201 once we add compressed files. */ [_stream writeBigEndianInt16: 0x200]; /* Header type */ [_stream writeInt8: 1]; if (_archiveComment != nil) { [_stream writeLittleEndianInt32: 42]; [_stream writeLittleEndianInt16: commentLength]; } else { [_stream writeLittleEndianInt32: 0]; [_stream writeLittleEndianInt16: 0]; } /* Version flag */ [_stream writeInt8: 0]; if (_archiveComment != nil) [_stream writeString: _archiveComment encoding: _encoding]; } else [self of_fixUpLastHeader]; @try { [_lastReturnedStream close]; } @catch (OFNotOpenException *e) { /* Might have already been closed by the user - that's fine. */ } _lastReturnedStream = nil; _lastReturnedStream = [[[OFZooArchiveFileWriteStream alloc] of_initWithArchive: self stream: _stream entry: entry encoding: _encoding lastHeaderOffset: &_lastHeaderOffset lastHeaderLength: &_lastHeaderLength] autorelease]; return _lastReturnedStream; } - (void)close { if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; @try { [_lastReturnedStream close]; } @catch (OFNotOpenException *e) { /* Might have already been closed by the user - that's fine. */ } _lastReturnedStream = nil; /* * Zoo archives should be terminated with an entry that has a next * header offset of 0. */ if (_mode == modeWrite) { static const unsigned char header[56] = { 0xDC, 0xA7, 0xC4, 0xFD, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFC, 0x83 }; [self of_fixUpLastHeader]; [_stream writeBuffer: header length: sizeof(header)]; } [_stream release]; _stream = nil; } @end @implementation OFZooArchiveFileReadStream - (instancetype)of_initWithArchive: (OFZooArchive *)archive stream: (OFStream *)stream entry: (OFZooArchiveEntry *)entry { self = [super init]; @try { _archive = [archive retain]; _stream = [stream retain]; switch (entry.compressionMethod) { case 0: _decompressedStream = [stream retain]; break; case 2: _decompressedStream = [[OFLHADecompressingStream alloc] of_initWithStream: stream distanceBits: 4 dictionaryBits: 14]; break; default: @throw [OFUnsupportedVersionException exceptionWithVersion: [OFString stringWithFormat: @"%u", entry.compressionMethod]]; } _entry = [entry copy]; _toRead = entry.uncompressedSize; [_stream seekToOffset: entry->_dataOffset whence: OFSeekSet]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { if (_stream != nil && _decompressedStream != nil) [self close]; [_entry release]; if (_archive->_lastReturnedStream == self) _archive->_lastReturnedStream = nil; [_archive release]; [super dealloc]; } - (bool)lowlevelIsAtEndOfStream { if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; return _atEndOfStream; } - (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length { size_t ret; if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; if (_atEndOfStream) return 0; if ([_stream isAtEndOfStream] && !_decompressedStream.hasDataInReadBuffer) @throw [OFTruncatedDataException exception]; if (length > _toRead) length = (size_t)_toRead; ret = [_decompressedStream readIntoBuffer: buffer length: length]; _toRead -= ret; _CRC16 = OFCRC16(_CRC16, buffer, ret); if (_toRead == 0) { _atEndOfStream = true; if (_CRC16 != _entry.CRC16) { OFString *actualChecksum = [OFString stringWithFormat: @"%04" @PRIX16, _CRC16]; OFString *expectedChecksum = [OFString stringWithFormat: @"%04" @PRIX16, _entry.CRC16]; @throw [OFChecksumMismatchException exceptionWithActualChecksum: actualChecksum expectedChecksum: expectedChecksum]; } } return ret; } - (bool)hasDataInReadBuffer { return (super.hasDataInReadBuffer || _decompressedStream.hasDataInReadBuffer); } - (int)fileDescriptorForReading { return ((id <OFReadyForReadingObserving>)_decompressedStream) .fileDescriptorForReading; } - (void)close { if (_stream == nil || _decompressedStream == nil) @throw [OFNotOpenException exceptionWithObject: self]; [_stream release]; _stream = nil; [_decompressedStream release]; _decompressedStream = nil; [super close]; } @end @implementation OFZooArchiveFileWriteStream - (instancetype)of_initWithArchive: (OFZooArchive *)archive stream: (OFSeekableStream *)stream entry: (OFZooArchiveEntry *)entry encoding: (OFStringEncoding)encoding lastHeaderOffset: (OFStreamOffset *)lastHeaderOffset lastHeaderLength: (size_t *)lastHeaderLength { self = [super init]; @try { _archive = [archive retain]; _entry = [entry mutableCopy]; _encoding = encoding; _lastHeaderOffset = lastHeaderOffset; _lastHeaderLength = lastHeaderLength; *_lastHeaderOffset = [stream seekToOffset: 0 whence: OFSeekCurrent]; *_lastHeaderLength = [_entry of_writeToStream: stream encoding: _encoding]; /* * Retain stream last, so that -[close] called by -[dealloc] * doesn't write in case of error. */ _stream = [stream retain]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { if (_stream != nil) [self close]; [_entry release]; if (_archive->_lastReturnedStream == self) _archive->_lastReturnedStream = nil; [_archive release]; [super dealloc]; } - (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length { if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; if (UINT32_MAX - _bytesWritten < length) @throw [OFOutOfRangeException exception]; @try { [_stream writeBuffer: buffer length: length]; } @catch (OFWriteFailedException *e) { OFEnsure(e.bytesWritten <= length); _bytesWritten += (uint32_t)e.bytesWritten; _CRC16 = OFCRC16(_CRC16, buffer, e.bytesWritten); if (e.errNo == EWOULDBLOCK || e.errNo == EAGAIN) return e.bytesWritten; @throw e; } _bytesWritten += (uint32_t)length; _CRC16 = OFCRC16(_CRC16, buffer, length); return length; } - (bool)lowlevelIsAtEndOfStream { if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; return _stream.atEndOfStream; } - (int)fileDescriptorForWriting { return ((id <OFReadyForWritingObserving>)_stream) .fileDescriptorForWriting; } - (void)close { OFStreamOffset offset; if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; _entry.uncompressedSize = _bytesWritten; _entry.compressedSize = _bytesWritten; _entry.CRC16 = _CRC16; offset = [_stream seekToOffset: 0 whence: OFSeekCurrent]; if ((unsigned long long)offset > UINT32_MAX) @throw [OFOutOfRangeException exception]; [_stream seekToOffset: *_lastHeaderOffset whence: OFSeekSet]; _entry->_dataOffset = (uint32_t)offset; OFEnsure([_entry of_writeToStream: _stream encoding: _encoding] == *_lastHeaderLength); [_stream seekToOffset: offset whence: OFSeekSet]; [_stream release]; _stream = nil; [super close]; } @end |
Added src/OFZooArchiveEntry+Private.h version [be49b89dc6].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFZooArchive.h" #import "OFSeekableStream.h" OF_ASSUME_NONNULL_BEGIN @interface OFZooArchiveEntry () - (instancetype)of_init OF_METHOD_FAMILY(init); - (nullable instancetype)of_initWithStream: (OFSeekableStream *)stream encoding: (OFStringEncoding)encoding OF_METHOD_FAMILY(init) OF_DIRECT; - (size_t)of_writeToStream: (OFSeekableStream *)stream encoding: (OFStringEncoding)encoding; @end OF_ASSUME_NONNULL_END |
Added src/OFZooArchiveEntry.h version [e8ceedc161].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFArchiveEntry.h" OF_ASSUME_NONNULL_BEGIN @class OFDate; @class OFNumber; @class OFString; /** * @class OFZooArchiveEntry OFZooArchiveEntry.h ObjFW/OFZooArchiveEntry.h * * @brief A class which represents an entry in a Zoo archive. */ @interface OFZooArchiveEntry: OFObject <OFArchiveEntry, OFCopying, OFMutableCopying> { uint8_t _headerType, _compressionMethod; #ifdef OF_ZOO_ARCHIVE_M @public #endif unsigned long long _nextHeaderOffset, _dataOffset; @protected uint16_t _lastModifiedFileDate, _lastModifiedFileTime; uint16_t _CRC16; unsigned long long _uncompressedSize, _compressedSize; uint16_t _minVersionNeeded; bool _deleted; OFString *_Nullable _fileComment; OFString *_fileName, *_Nullable _directoryName; uint16_t _operatingSystemIdentifier; OFNumber *_Nullable _POSIXPermissions; int8_t _timeZone; OF_RESERVE_IVARS(OFZooArchiveEntry, 4) } /** * @brief The header type of the entry. */ @property (readonly, nonatomic) uint8_t headerType; /** * @brief The compression method of the entry. */ @property (readonly, nonatomic) uint8_t compressionMethod; /** * @brief The CRC16 of the file. */ @property (readonly, nonatomic) uint16_t CRC16; /** * @brief The minimum version required to extract the file. * * The upper 8 bits are the major version and the lower 8 bits the minor * version. */ @property (readonly, nonatomic) uint16_t minVersionNeeded; /** * @brief Whether the file was deleted. */ @property (readonly, nonatomic, getter=isDeleted) bool deleted; /** * @brief The operating system identifier of the file. */ @property (readonly, nonatomic) uint16_t operatingSystemIdentifier; /** * @brief The time zone in which the file was stored, as an offset in hours * from UTC (as a float). */ @property OF_NULLABLE_PROPERTY (readonly, retain, nonatomic) OFNumber *timeZone; - (instancetype)init OF_UNAVAILABLE; @end OF_ASSUME_NONNULL_END #import "OFMutableZooArchiveEntry.h" |
Added src/OFZooArchiveEntry.m version [a378fc2c96].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFZooArchiveEntry.h" #import "OFZooArchiveEntry+Private.h" #import "OFData.h" #import "OFDate.h" #import "OFNumber.h" #import "OFSeekableStream.h" #import "OFString.h" #import "OFInvalidFormatException.h" #import "OFOutOfRangeException.h" #import "OFUnsupportedVersionException.h" @implementation OFZooArchiveEntry /* * The following properties are not implemented, but old Apple GCC requries * @dynamic for @optional properties. */ @dynamic ownerAccountID, groupOwnerAccountID, ownerAccountName; @dynamic groupOwnerAccountName; - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)of_init { self = [super init]; @try { _headerType = 2; _minVersionNeeded = 0x100; } @catch (id e) { [self release]; @throw e; } return self; } - (instancetype)of_initWithStream: (OFSeekableStream *)stream encoding: (OFStringEncoding)encoding { self = [super init]; @try { void *pool = objc_autoreleasePoolPush(); char fileNameBuffer[13]; uint32_t commentOffset; uint16_t commentLength; if ([stream readLittleEndianInt32] != 0xFDC4A7DC) @throw [OFInvalidFormatException exception]; if ((_headerType = [stream readInt8]) > 2) @throw [OFUnsupportedVersionException exceptionWithVersion: [OFString stringWithFormat: @"%" PRIu8, _headerType]]; _compressionMethod = [stream readInt8]; _nextHeaderOffset = [stream readLittleEndianInt32]; if (_nextHeaderOffset == 0) { [self release]; return nil; } _dataOffset = [stream readLittleEndianInt32]; _lastModifiedFileDate = [stream readLittleEndianInt16]; _lastModifiedFileTime = [stream readLittleEndianInt16]; _CRC16 = [stream readLittleEndianInt16]; _uncompressedSize = [stream readLittleEndianInt32]; _compressedSize = [stream readLittleEndianInt32]; if ((_minVersionNeeded = [stream readBigEndianInt16]) > 0x201) @throw [OFUnsupportedVersionException exceptionWithVersion: [OFString stringWithFormat: @"%" PRIu8 @".%" PRIu8, _minVersionNeeded >> 8, _minVersionNeeded & 0xFF]]; _deleted = [stream readInt8]; /* * File structure, whatever that is meant to be. Seems to * always be 0. */ [stream readInt8]; commentOffset = [stream readLittleEndianInt32]; commentLength = [stream readLittleEndianInt16]; [stream readIntoBuffer: fileNameBuffer exactLength: 13]; if (fileNameBuffer[12] != '\0') fileNameBuffer[12] = '\0'; if (_headerType >= 2) { uint16_t extraLength = [stream readLittleEndianInt16]; uint8_t fileNameLength = 0, directoryNameLength = 0; _timeZone = [stream readInt8]; /* CRC16 of the header */ [stream readLittleEndianInt16]; if (extraLength >= 2) { fileNameLength = [stream readInt8]; directoryNameLength = [stream readInt8]; extraLength -= 2; } if (fileNameLength > 0) { if (extraLength < fileNameLength) @throw [OFInvalidFormatException exception]; _fileName = [[stream readStringWithLength: fileNameLength encoding: encoding] copy]; extraLength -= fileNameLength; } else _fileName = [[OFString alloc] initWithCString: fileNameBuffer encoding: encoding]; if (directoryNameLength > 0) { if (extraLength < directoryNameLength) @throw [OFInvalidFormatException exception]; _directoryName = [[stream readStringWithLength: directoryNameLength encoding: encoding] copy]; extraLength -= directoryNameLength; } if (extraLength >= 2) { _operatingSystemIdentifier = [stream readLittleEndianInt16]; extraLength -= 2; } if (extraLength >= 3) { uint8_t attributes[3]; [stream readIntoBuffer: attributes exactLength: 3]; if (attributes[2] & (1 << 6)) { uint16_t mode = (attributes[0] | (attributes[1] << 8)) & 0777; _POSIXPermissions = [[OFNumber alloc] initWithUnsignedShort: mode]; } extraLength -= 3; } } else { _fileName = [[OFString alloc] initWithCString: fileNameBuffer encoding: encoding]; _timeZone = 0x7F; } if (commentOffset != 0) { [stream seekToOffset: commentOffset whence: OFSeekSet]; _fileComment = [[stream readStringWithLength: commentLength encoding: encoding] retain]; } objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_fileComment release]; [_fileName release]; [_directoryName release]; [_POSIXPermissions release]; [super dealloc]; } - (id)copy { return [self retain]; } - (id)mutableCopy { OFZooArchiveEntry *copy = [[OFMutableZooArchiveEntry alloc] initWithFileName: self.fileName]; @try { copy->_headerType = _headerType; copy->_compressionMethod = _compressionMethod; copy->_nextHeaderOffset = _nextHeaderOffset; copy->_dataOffset = _dataOffset; copy->_lastModifiedFileDate = _lastModifiedFileDate; copy->_lastModifiedFileTime = _lastModifiedFileTime; copy->_CRC16 = _CRC16; copy->_uncompressedSize = _uncompressedSize; copy->_compressedSize = _compressedSize; copy->_minVersionNeeded = _minVersionNeeded; copy->_deleted = _deleted; copy->_fileComment = [_fileComment copy]; copy->_operatingSystemIdentifier = _operatingSystemIdentifier; copy->_POSIXPermissions = [_POSIXPermissions retain]; copy->_timeZone = _timeZone; } @catch (id e) { [self release]; @throw e; } return copy; } - (uint8_t)headerType { return _headerType; } - (uint8_t)compressionMethod { return _compressionMethod; } - (OFDate *)modificationDate { void *pool = objc_autoreleasePoolPush(); uint16_t year = ((_lastModifiedFileDate & 0xFE00) >> 9) + 1980; uint8_t month = (_lastModifiedFileDate & 0x1E0) >> 5; uint8_t day = (_lastModifiedFileDate & 0x1F); uint8_t hour = (_lastModifiedFileTime & 0xF800) >> 11; uint8_t minute = (_lastModifiedFileTime & 0x7E0) >> 5; uint8_t second = (_lastModifiedFileTime & 0x1F) << 1; OFDate *date; OFString *dateString; dateString = [OFString stringWithFormat: @"%04u-%02u-%02u %02u:%02u:%02u", year, month, day, hour, minute, second]; if (_timeZone == 0x7F) date = [[OFDate alloc] initWithLocalDateString: dateString format: @"%Y-%m-%d %H:%M:%S"]; else { date = [OFDate dateWithDateString: dateString format: @"%Y-%m-%d %H:%M:%S"]; date = [[date dateByAddingTimeInterval: (OFTimeInterval)_timeZone * 900] retain]; } objc_autoreleasePoolPop(pool); return [date autorelease]; } - (uint16_t)CRC16 { return _CRC16; } - (unsigned long long)uncompressedSize { return _uncompressedSize; } - (unsigned long long)compressedSize { return _compressedSize; } - (uint16_t)minVersionNeeded { return _minVersionNeeded; } - (bool)isDeleted { return _deleted; } - (OFString *)fileComment { return _fileComment; } - (OFString *)fileName { if (_directoryName == nil) return _fileName; return [OFString stringWithFormat: @"%@/%@", _directoryName, _fileName]; } - (uint16_t)operatingSystemIdentifier { return _operatingSystemIdentifier; } - (OFNumber *)POSIXPermissions { return _POSIXPermissions; } - (OFNumber *)timeZone { if (_timeZone == 0x7F) return nil; return [OFNumber numberWithFloat: -(float)_timeZone / 4]; } - (size_t)of_writeToStream: (OFSeekableStream *)stream encoding: (OFStringEncoding)encoding { void *pool = objc_autoreleasePoolPush(); OFMutableData *data = [OFMutableData dataWithCapacity: 56]; OFStreamOffset offset = [stream seekToOffset: 0 whence: OFSeekCurrent]; size_t dataOffsetIndex, commentOffsetIndex; char fileNameBuffer[13] = { 0 }; uint8_t tmp8; uint16_t tmp16; uint32_t tmp32; size_t commentLength, fileNameLength, directoryNameLength, length; if (_uncompressedSize > UINT32_MAX || _compressedSize > UINT32_MAX) @throw [OFOutOfRangeException exception]; commentLength = [_fileComment cStringLengthWithEncoding: encoding]; if (commentLength > UINT16_MAX) @throw [OFOutOfRangeException exception]; fileNameLength = [_fileName cStringLengthWithEncoding: encoding]; if (fileNameLength > UINT8_MAX - 1) @throw [OFOutOfRangeException exception]; directoryNameLength = [_directoryName cStringLengthWithEncoding: encoding]; if (directoryNameLength > UINT8_MAX - 1) @throw [OFOutOfRangeException exception]; [data addItems: "\xDC\xA7\xC4\xFD" count: 4]; /* Header type */ [data addItem: "\x02"]; [data addItem: &_compressionMethod]; /* Next header offset filled when writing the next header */ [data increaseCountBy: 4]; /* Data offset is filled after generating the header */ dataOffsetIndex = data.count; [data increaseCountBy: 4]; tmp16 = OFToLittleEndian16(_lastModifiedFileDate); [data addItems: &tmp16 count: 2]; tmp16 = OFToLittleEndian16(_lastModifiedFileTime); [data addItems: &tmp16 count: 2]; tmp16 = OFToLittleEndian16(_CRC16); [data addItems: &tmp16 count: 2]; tmp32 = OFToLittleEndian32((uint32_t)_uncompressedSize); [data addItems: &tmp32 count: 4]; tmp32 = OFToLittleEndian32((uint32_t)_compressedSize); [data addItems: &tmp32 count: 4]; /* Min version needed */ /* TODO: Increase to 2.1 once we add compression. */ [data addItems: "\x02\x00" count: 2]; [data addItem: (_deleted ? "\x01" : "")]; /* * File structure, whatever that is meant to be. * Seems to always be 0. */ [data addItem: ""]; /* Comment offset is filled after generating the header */ commentOffsetIndex = data.count; [data increaseCountBy: 4]; tmp16 = OFToLittleEndian16((uint16_t)commentLength); [data addItems: &tmp16 count: 2]; strncpy(fileNameBuffer, [_fileName cStringWithEncoding: encoding], 12); [data addItems: fileNameBuffer count: 13]; /* Variable length. */ tmp16 = OFToLittleEndian16(fileNameLength + directoryNameLength + 4 + (_POSIXPermissions != nil ? 3 : 0)); [data addItems: &tmp16 count: 2]; [data addItem: &_timeZone]; /* * CRC16 is filled when writing the next header, as the CRC needs to * include the next header offset. */ [data increaseCountBy: 2]; /* Include \0 */ if (fileNameLength > 0) fileNameLength++; if (directoryNameLength > 0) directoryNameLength++; tmp8 = (uint8_t)fileNameLength; [data addItem: &tmp8]; tmp8 = (uint8_t)directoryNameLength; [data addItem: &tmp8]; [data addItems: [_fileName cStringWithEncoding: encoding] count: fileNameLength]; [data addItems: [_directoryName cStringWithEncoding: encoding] count: directoryNameLength]; tmp16 = OFToLittleEndian16((uint16_t)_operatingSystemIdentifier); [data addItems: &tmp16 count: 2]; if (_POSIXPermissions != nil) { unsigned short mode = _POSIXPermissions.unsignedShortValue; uint8_t attributes[3]; attributes[0] = mode & 0xFF; attributes[1] = mode >> 8; attributes[2] = (1 << 6); [data addItems: attributes count: sizeof(attributes)]; } /* Now that we have the entire header, we know where the data starts. */ if (SIZE_MAX - data.count < commentLength) @throw [OFOutOfRangeException exception]; if (offset < 0 || UINT32_MAX - (unsigned long long)offset < data.count + commentLength) @throw [OFOutOfRangeException exception]; tmp32 = OFToLittleEndian32( (uint32_t)offset + (uint32_t)data.count + (uint32_t)commentLength); memcpy([data mutableItemAtIndex: dataOffsetIndex], &tmp32, 4); tmp32 = OFToLittleEndian32((uint32_t)offset + (uint32_t)data.count); memcpy([data mutableItemAtIndex: commentOffsetIndex], &tmp32, 4); [stream writeData: data]; length = data.count; if (commentLength > 0) [stream writeString: _fileComment encoding: encoding]; objc_autoreleasePoolPop(pool); return length; } - (OFString *)description { void *pool = objc_autoreleasePoolPush(); OFString *ret = [OFString stringWithFormat: @"<%@:\n" @"\tFile name = %@\n" @"\tFile comment = %@\n" @"\tCompressed size = %llu\n" @"\tUncompressed size = %llu\n" @"\tCompression method = %u\n" @"\tModification date = %@\n" @"\tCRC16 = %04" @PRIX16 @"\n" @"\tDeleted = %u\n" @">", self.class, _fileName, _fileComment, _compressedSize, _uncompressedSize, _compressionMethod, self.modificationDate, _CRC16, _deleted]; [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } @end |
Modified src/ObjFW.h from [b44721112f] to [11ffe4203c].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFBlock.h" #import "OFString.h" #import "OFCharacterSet.h" |
︙ | ︙ | |||
41 42 43 44 45 46 47 | #import "OFNull.h" #import "OFMethodSignature.h" #import "OFInvocation.h" #import "OFNumber.h" #import "OFDate.h" | | | | > > | 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | #import "OFNull.h" #import "OFMethodSignature.h" #import "OFInvocation.h" #import "OFNumber.h" #import "OFDate.h" #import "OFIRI.h" #import "OFIRIHandler.h" #import "OFUUID.h" #import "OFColor.h" #import "OFNotification.h" #import "OFNotificationCenter.h" #import "OFStream.h" #import "OFSeekableStream.h" #import "OFMemoryStream.h" #import "OFStdIOStream.h" #import "OFInflateStream.h" #import "OFInflate64Stream.h" #import "OFGZIPStream.h" #import "OFLHAArchive.h" #import "OFLHAArchiveEntry.h" #import "OFTarArchive.h" #import "OFTarArchiveEntry.h" #import "OFZIPArchive.h" #import "OFZIPArchiveEntry.h" #import "OFZooArchive.h" #import "OFZooArchiveEntry.h" #import "OFFileManager.h" #ifdef OF_HAVE_FILES # import "OFFile.h" #endif #import "OFINIFile.h" #import "OFSettings.h" #ifdef OF_HAVE_SOCKETS |
︙ | ︙ | |||
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | #import "OFApplication.h" #import "OFSystemInfo.h" #import "OFLocale.h" #import "OFOptionsParser.h" #import "OFTimer.h" #import "OFRunLoop.h" #ifdef OF_WINDOWS # import "OFWindowsRegistryKey.h" #endif #import "OFAllocFailedException.h" #import "OFException.h" #import "OFChangeCurrentDirectoryFailedException.h" #import "OFChecksumMismatchException.h" #import "OFCopyItemFailedException.h" #import "OFCreateDirectoryFailedException.h" #import "OFCreateSymbolicLinkFailedException.h" #import "OFEnumerationMutationException.h" | > > > | 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | #import "OFApplication.h" #import "OFSystemInfo.h" #import "OFLocale.h" #import "OFOptionsParser.h" #import "OFTimer.h" #import "OFRunLoop.h" #import "OFMatrix4x4.h" #ifdef OF_WINDOWS # import "OFWindowsRegistryKey.h" #endif #import "OFAllocFailedException.h" #import "OFAlreadyOpenException.h" #import "OFException.h" #import "OFChangeCurrentDirectoryFailedException.h" #import "OFChecksumMismatchException.h" #import "OFCopyItemFailedException.h" #import "OFCreateDirectoryFailedException.h" #import "OFCreateSymbolicLinkFailedException.h" #import "OFEnumerationMutationException.h" |
︙ | ︙ | |||
192 193 194 195 196 197 198 | #import "OFUnknownXMLEntityException.h" #import "OFUnlockFailedException.h" #import "OFUnsupportedProtocolException.h" #import "OFUnsupportedVersionException.h" #import "OFWriteFailedException.h" #ifdef OF_HAVE_SOCKETS # import "OFAcceptSocketFailedException.h" | < | 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | #import "OFUnknownXMLEntityException.h" #import "OFUnlockFailedException.h" #import "OFUnsupportedProtocolException.h" #import "OFUnsupportedVersionException.h" #import "OFWriteFailedException.h" #ifdef OF_HAVE_SOCKETS # import "OFAcceptSocketFailedException.h" # import "OFBindIPSocketFailedException.h" # import "OFBindSocketFailedException.h" # import "OFConnectIPSocketFailedException.h" # import "OFConnectSocketFailedException.h" # import "OFDNSQueryFailedException.h" # import "OFHTTPRequestFailedException.h" # import "OFListenOnSocketFailedException.h" |
︙ | ︙ |
Modified src/bridge/Makefile from [5a2e1acbf4] to [c6f229ec08].
1 2 3 4 5 6 7 | include ../../extra.mk DISTCLEAN = Info.plist SHARED_LIB = ${OBJFWBRIDGE_SHARED_LIB} STATIC_LIB = ${OBJFWBRIDGE_STATIC_LIB} FRAMEWORK = ${OBJFWBRIDGE_FRAMEWORK} | | | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | include ../../extra.mk DISTCLEAN = Info.plist SHARED_LIB = ${OBJFWBRIDGE_SHARED_LIB} STATIC_LIB = ${OBJFWBRIDGE_STATIC_LIB} FRAMEWORK = ${OBJFWBRIDGE_FRAMEWORK} LIB_MAJOR = ${OBJFWBRIDGE_LIB_MAJOR} LIB_MINOR = ${OBJFWBRIDGE_LIB_MINOR} LIB_PATCH = ${OBJFWBRIDGE_LIB_PATCH} SRCS = OFArray+NSObject.m \ OFEnumerator+NSObject.m \ OFException+Swift.m \ OFDictionary+NSObject.m \ OFNumber+NSObject.m \ OFSet+NSObject.m \ |
︙ | ︙ | |||
36 37 38 39 40 41 42 | OFNSEnumerator.m \ OFNSSet.m includesubdir = ObjFWBridge include ../../buildsys.mk | > > > > > > > > > > > > > > > > > > > > > | | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | OFNSEnumerator.m \ OFNSSet.m includesubdir = ObjFWBridge include ../../buildsys.mk install-extra: i=ObjFWBridge.oc; \ ${INSTALL_STATUS}; \ if ${MKDIR_P} ${DESTDIR}${libdir}/objfw-config && \ ${INSTALL} -m 644 $$i ${DESTDIR}${libdir}/objfw-config/$$i; then \ ${INSTALL_OK}; \ else \ ${INSTALL_FAILED}; \ fi uninstall-extra: i=ObjFWBridge.oc; \ if test -f ${DESTDIR}${libdir}/objfw-config/$$i; then \ if rm -f ${DESTDIR}${libdir}/objfw-config/$$i; then \ ${DELETE_OK}; \ else \ ${DELETE_FAILED}; \ fi \ fi rmdir ${DESTDIR}${libdir}/objfw-config >/dev/null 2>&1 || true CPPFLAGS += -I. -I.. -I../.. -I../exceptions -DOBJFWBRIDGE_LOCAL_INCLUDES LD = ${OBJC} FRAMEWORK_LIBS := -framework Foundation -F.. -framework ObjFW ${LIBS} LIBS := -framework Foundation -L.. -lobjfw ${LIBS} |
Modified src/bridge/NSArray+OFObject.h from [4b59b82d97] to [7e0f2d7704].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import <Foundation/NSArray.h> #import "NSBridging.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ |
Modified src/bridge/NSArray+OFObject.m from [a7c2336812] to [3a10326b29].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "NSArray+OFObject.h" #import "OFNSArray.h" int _NSArray_OFObject_reference; |
︙ | ︙ |
Modified src/bridge/NSBridging.h from [1aa6518645] to [d120707115].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #ifdef OBJFWBRIDGE_LOCAL_INCLUDES # import "macros.h" #else # if defined(__has_feature) && __has_feature(modules) @import ObjFW; # else # import <ObjFW/macros.h> # endif |
︙ | ︙ |
Modified src/bridge/NSDictionary+OFObject.h from [1dcde481c6] to [cbb576e980].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import <Foundation/NSDictionary.h> #import "NSBridging.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ |
Modified src/bridge/NSDictionary+OFObject.m from [3bee09377c] to [bd5afd2c67].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "NSDictionary+OFObject.h" #import "OFNSDictionary.h" int _NSDictionary_OFObject_reference; |
︙ | ︙ |
Modified src/bridge/NSEnumerator+OFObject.h from [5e37d187b7] to [ab538c58f1].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import <Foundation/NSEnumerator.h> #import "NSBridging.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ |
Modified src/bridge/NSEnumerator+OFObject.m from [dd0762c949] to [fc7040ae37].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "NSEnumerator+OFObject.h" #import "OFNSEnumerator.h" int _NSEnumerator_OFObject_reference; |
︙ | ︙ |
Modified src/bridge/NSNumber+OFObject.h from [bd31c0c3cd] to [40720010ad].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import <Foundation/NSValue.h> #import "NSBridging.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ |
Modified src/bridge/NSNumber+OFObject.m from [18f7ec56ae] to [b87ab57940].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "NSNumber+OFObject.h" #import "OFNumber.h" #import "OFInvalidArgumentException.h" |
︙ | ︙ |
Modified src/bridge/NSOFArray.h from [cd8e3e0488] to [9e6a229da7].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import <Foundation/NSArray.h> #import "macros.h" @class OFArray; |
︙ | ︙ |
Modified src/bridge/NSOFArray.m from [41ea305080] to [d11a869889].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "NSOFArray.h" #import "OFArray.h" #import "OFBridging.h" #import "OFOutOfRangeException.h" |
︙ | ︙ |
Modified src/bridge/NSOFDictionary.h from [b628e7e6a3] to [0f07018dfd].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import <Foundation/NSDictionary.h> #import "macros.h" @class OFDictionary; |
︙ | ︙ |
Modified src/bridge/NSOFDictionary.m from [e47773ee01] to [a3c8d3360d].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "NSOFDictionary.h" #import "OFDictionary.h" #import "OFEnumerator+NSObject.h" #import "NSBridging.h" |
︙ | ︙ |
Modified src/bridge/NSOFEnumerator.h from [fcb10c08ed] to [7543c8339f].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import <Foundation/NSEnumerator.h> #import "macros.h" @class OFEnumerator; |
︙ | ︙ |
Modified src/bridge/NSOFEnumerator.m from [ebbed84f33] to [cdef8ef9ba].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "NSOFEnumerator.h" #import "OFEnumerator.h" #import "NSBridging.h" #import "OFBridging.h" |
︙ | ︙ |
Modified src/bridge/NSOFSet.h from [33948f6157] to [99a1948c56].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import <Foundation/NSSet.h> #import "macros.h" @class OFSet; |
︙ | ︙ |
Modified src/bridge/NSOFSet.m from [e7387e2762] to [b3ba2768e1].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "NSOFSet.h" #import "OFEnumerator+NSObject.h" #import "OFSet.h" #import "OFBridging.h" |
︙ | ︙ |
Modified src/bridge/NSSet+OFObject.h from [68cb6c5ccf] to [34c28f8121].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import <Foundation/NSSet.h> #import "NSBridging.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ |
Modified src/bridge/NSSet+OFObject.m from [5daeb1bac4] to [96348f9cbd].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "NSSet+OFObject.h" #import "OFNSSet.h" int _NSSet_OFObject_reference; |
︙ | ︙ |
Modified src/bridge/NSString+OFObject.h from [a30f21642d] to [80a6874084].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import <Foundation/NSString.h> #import "NSBridging.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ |
Modified src/bridge/NSString+OFObject.m from [f6fbd9f898] to [9be812abed].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "NSString+OFObject.h" #import "OFString.h" int _NSString_OFObject_reference; |
︙ | ︙ |
Modified src/bridge/OFArray+NSObject.h from [f258ecab9a] to [3b8ba1cd06].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #ifdef OBJFWBRIDGE_LOCAL_INCLUDES # import "OFArray.h" #else # if defined(__has_feature) && __has_feature(modules) @import ObjFW; # else # import <ObjFW/OFArray.h> # endif |
︙ | ︙ |
Modified src/bridge/OFArray+NSObject.m from [ee4c5a25af] to [def3817a79].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "NSOFArray.h" #import "OFArray+NSObject.h" int _OFArray_NSObject_reference; |
︙ | ︙ |
Modified src/bridge/OFBridging.h from [abe87031bc] to [c020ff62a4].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #ifdef OBJFWBRIDGE_LOCAL_INCLUDES # import "macros.h" #else # if defined(__has_feature) && __has_feature(modules) @import ObjFW; # else # import <ObjFW/macros.h> # endif |
︙ | ︙ |
Modified src/bridge/OFDictionary+NSObject.h from [27bfd0d589] to [bebeef9986].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #ifdef OBJFWBRIDGE_LOCAL_INCLUDES # import "OFDictionary.h" #else # if defined(__has_feature) && __has_feature(modules) @import ObjFW; # else # import <ObjFW/OFDictionary.h> # endif |
︙ | ︙ |
Modified src/bridge/OFDictionary+NSObject.m from [6df9e22408] to [0ab2f1193b].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "NSOFDictionary.h" #import "OFDictionary+NSObject.h" int _OFDictionary_NSObject_reference; |
︙ | ︙ |
Modified src/bridge/OFEnumerator+NSObject.h from [cb0752d99c] to [731ca967a3].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #ifdef OBJFWBRIDGE_LOCAL_INCLUDES # import "OFEnumerator.h" #else # if defined(__has_feature) && __has_feature(modules) @import ObjFW; # else # import <ObjFW/OFEnumerator.h> # endif |
︙ | ︙ |
Modified src/bridge/OFEnumerator+NSObject.m from [a3ee1dfe29] to [0fdb5a7a78].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "NSOFEnumerator.h" #import "OFEnumerator+NSObject.h" int _OFEnumerator_NSObject_reference; |
︙ | ︙ |
Modified src/bridge/OFException+Swift.h from [da5307c0ad] to [a87137db31].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #ifdef OBJFWBRIDGE_LOCAL_INCLUDES # import "OFException.h" #else # if defined(__has_feature) && __has_feature(modules) @import ObjFW; # else # import <ObjFW/OFException.h> # endif |
︙ | ︙ |
Modified src/bridge/OFException+Swift.m from [69103747b4] to [6c0ab68c00].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException+Swift.h" @implementation OFException (NSError) #ifdef OF_HAVE_BLOCKS + (void)try: (void (^)(void))try |
︙ | ︙ |
Modified src/bridge/OFNSArray.h from [1c05dea53b] to [a142b25042].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #ifdef OBJFWBRIDGE_LOCAL_INCLUDES # import "OFArray.h" #else # if defined(__has_feature) && __has_feature(modules) @import ObjFW; # else # import <ObjFW/OFArray.h> # endif |
︙ | ︙ |
Modified src/bridge/OFNSArray.m from [511fcf77df] to [0b10996e7e].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import <Foundation/NSArray.h> #import "OFNSArray.h" #import "NSBridging.h" |
︙ | ︙ |
Modified src/bridge/OFNSDictionary.h from [3699212d07] to [100ee64941].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #ifdef OBJFWBRIDGE_LOCAL_INCLUDES # import "OFDictionary.h" #else # if defined(__has_feature) && __has_feature(modules) @import ObjFW; # else # import <ObjFW/OFDictionary.h> # endif |
︙ | ︙ |
Modified src/bridge/OFNSDictionary.m from [3228b094f1] to [5135c7c3a5].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import <Foundation/NSDictionary.h> #import "OFNSDictionary.h" #import "NSEnumerator+OFObject.h" |
︙ | ︙ |
Modified src/bridge/OFNSEnumerator.h from [f60938ebf6] to [808f5694e5].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #ifdef OBJFWBRIDGE_LOCAL_INCLUDES # import "OFEnumerator.h" #else # if defined(__has_feature) && __has_feature(modules) @import ObjFW; # else # import <ObjFW/OFEnumerator.h> # endif |
︙ | ︙ |
Modified src/bridge/OFNSEnumerator.m from [9f5d7028e9] to [4b51dd451d].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import <Foundation/NSEnumerator.h> #import "OFNSEnumerator.h" #import "NSBridging.h" |
︙ | ︙ |
Modified src/bridge/OFNSSet.h from [7b3370ed57] to [ae9196c6ab].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #ifdef OBJFWBRIDGE_LOCAL_INCLUDES # import "OFSet.h" #else # if defined(__has_feature) && __has_feature(modules) @import ObjFW; # else # import <ObjFW/OFSet.h> # endif |
︙ | ︙ |
Modified src/bridge/OFNSSet.m from [151a52ad4b] to [2282439721].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import <Foundation/NSSet.h> #import "OFNSSet.h" #import "NSEnumerator+OFObject.h" |
︙ | ︙ |
Modified src/bridge/OFNumber+NSObject.h from [955839af4e] to [fadb7d7a45].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #ifdef OBJFWBRIDGE_LOCAL_INCLUDES # import "OFNumber.h" #else # if defined(__has_feature) && __has_feature(modules) @import ObjFW; # else # import <ObjFW/OFNumber.h> # endif |
︙ | ︙ |
Modified src/bridge/OFNumber+NSObject.m from [f73968ae16] to [114772d941].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import <Foundation/NSValue.h> #import "OFNumber+NSObject.h" #import "OFInvalidArgumentException.h" |
︙ | ︙ |
Modified src/bridge/OFSet+NSObject.h from [9214bbd006] to [5726564da5].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #ifdef OBJFWBRIDGE_LOCAL_INCLUDES # import "OFSet.h" #else # if defined(__has_feature) && __has_feature(modules) @import ObjFW; # else # import <ObjFW/OFSet.h> # endif |
︙ | ︙ |
Modified src/bridge/OFSet+NSObject.m from [e5bc663707] to [f06866bdcf].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "NSOFSet.h" #import "OFSet+NSObject.h" int _OFSet_NSObject_reference; |
︙ | ︙ |
Modified src/bridge/OFString+NSObject.h from [375ab3a6b5] to [cb39a1ef91].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #ifdef OBJFWBRIDGE_LOCAL_INCLUDES # import "OFString.h" #else # if defined(__has_feature) && __has_feature(modules) @import ObjFW; # else # import <ObjFW/OFString.h> # endif |
︙ | ︙ |
Modified src/bridge/OFString+NSObject.m from [bf4d082579] to [a7d46d6fdc].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import <Foundation/NSString.h> #import "OFString+NSObject.h" #import "OFInitializationFailedException.h" |
︙ | ︙ |
Modified src/bridge/ObjFWBridge.h from [1fbb08ae27] to [277bc05263].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "NSArray+OFObject.h" #import "NSDictionary+OFObject.h" #import "NSEnumerator+OFObject.h" #import "NSNumber+OFObject.h" #import "NSSet+OFObject.h" |
︙ | ︙ |
Added src/bridge/ObjFWBridge.oc version [f2b4038f23].
> > > > | 1 2 3 4 | package_format 1 LIBS="-lobjfwbridge $LIBS" FRAMEWORK_LIBS="-framework ObjFWBridge $FRAMEWORK_LIBS" STATIC_LIBS="${libdir}/libobjfwbridge.a $STATIC_LIBS" |
Modified src/encodings/codepage-437.m from [1cc88f79fe] to [9f118a4c02].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFString.h" #import "common.h" |
︙ | ︙ |
Modified src/encodings/codepage-850.m from [d9cdb5c58f] to [1d1a09a45c].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFString.h" #import "common.h" |
︙ | ︙ |
Modified src/encodings/codepage-858.m from [402e5b0a14] to [4aa1a82036].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFString.h" #import "common.h" |
︙ | ︙ |
Modified src/encodings/common.h from [a9b82f31be] to [2d2c203547].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #define CASE_MISSING_IS_KEEP(nr) \ case nr: \ if OF_UNLIKELY ((c & 0xFF) < page##nr##Start) { \ output[i] = (unsigned char)c; \ continue; \ |
︙ | ︙ |
Modified src/encodings/iso-8859-15.m from [8197488f98] to [21daaed653].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFString.h" #import "common.h" |
︙ | ︙ |
Modified src/encodings/iso-8859-2.m from [b10a788d3d] to [8986e3bb39].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFString.h" #import "common.h" |
︙ | ︙ |
Modified src/encodings/iso-8859-3.m from [57543aa317] to [2126ec415a].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFString.h" #import "common.h" |
︙ | ︙ |
Modified src/encodings/koi8-r.m from [e29e1b888f] to [2c4f09a0dd].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFString.h" #import "common.h" |
︙ | ︙ |
Modified src/encodings/koi8-u.m from [10ad0de57d] to [9252bda863].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFString.h" #import "common.h" |
︙ | ︙ |
Modified src/encodings/mac-roman.m from [5811cbe352] to [d6ebb30db7].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFString.h" #import "common.h" |
︙ | ︙ |
Modified src/encodings/windows-1251.m from [b8c4870fa7] to [902244b996].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFString.h" #import "common.h" |
︙ | ︙ |
Modified src/encodings/windows-1252.m from [f9fc8b9676] to [3f257f7d9d].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFString.h" #import "common.h" |
︙ | ︙ |
Modified src/exceptions/Makefile from [0588e3b54e] to [c441977bfd].
1 2 3 4 5 6 7 8 9 10 11 12 13 | include ../../extra.mk STATIC_PIC_LIB_NOINST = ${EXCEPTIONS_LIB_A} STATIC_LIB_NOINST = ${EXCEPTIONS_A} SRCS = OFAllocFailedException.m \ OFChecksumMismatchException.m \ OFCopyItemFailedException.m \ OFCreateDirectoryFailedException.m \ OFCreateSymbolicLinkFailedException.m \ OFEnumerationMutationException.m \ OFException.m \ OFGetItemAttributesFailedException.m \ | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | include ../../extra.mk STATIC_PIC_LIB_NOINST = ${EXCEPTIONS_LIB_A} STATIC_LIB_NOINST = ${EXCEPTIONS_A} SRCS = OFAllocFailedException.m \ OFAlreadyOpenException.m \ OFChecksumMismatchException.m \ OFCopyItemFailedException.m \ OFCreateDirectoryFailedException.m \ OFCreateSymbolicLinkFailedException.m \ OFEnumerationMutationException.m \ OFException.m \ OFGetItemAttributesFailedException.m \ |
︙ | ︙ | |||
50 51 52 53 54 55 56 | ${USE_SRCS_SOCKETS} \ ${USE_SRCS_THREADS} \ ${USE_SRCS_WINDOWS} SRCS_FILES = OFChangeCurrentDirectoryFailedException.m \ OFGetCurrentDirectoryFailedException.m SRCS_PLUGINS = OFLoadPluginFailedException.m SRCS_SOCKETS = OFAcceptSocketFailedException.m \ | < | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | ${USE_SRCS_SOCKETS} \ ${USE_SRCS_THREADS} \ ${USE_SRCS_WINDOWS} SRCS_FILES = OFChangeCurrentDirectoryFailedException.m \ OFGetCurrentDirectoryFailedException.m SRCS_PLUGINS = OFLoadPluginFailedException.m SRCS_SOCKETS = OFAcceptSocketFailedException.m \ OFBindIPSocketFailedException.m \ OFBindSocketFailedException.m \ OFConnectIPSocketFailedException.m \ OFConnectSocketFailedException.m \ OFDNSQueryFailedException.m \ OFHTTPRequestFailedException.m \ OFListenOnSocketFailedException.m \ |
︙ | ︙ |
Modified src/exceptions/OFAcceptSocketFailedException.h from [e062558833] to [8ef75cb390].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" #ifndef OF_HAVE_SOCKETS # error No sockets available! #endif |
︙ | ︙ |
Modified src/exceptions/OFAcceptSocketFailedException.m from [701680e6d7] to [d7e15e3f11].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFAcceptSocketFailedException.h" #import "OFString.h" |
︙ | ︙ |
Modified src/exceptions/OFActivateSandboxFailedException.h from [97726da76a] to [c9f567cc26].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN @class OFSandbox; |
︙ | ︙ |
Modified src/exceptions/OFActivateSandboxFailedException.m from [5dc1486ad8] to [22e88defaa].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFActivateSandboxFailedException.h" #import "OFString.h" #import "OFSandbox.h" |
︙ | ︙ |
Modified src/exceptions/OFAllocFailedException.h from [01cde7dcb3] to [d5e27ebe68].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" OF_ASSUME_NONNULL_BEGIN @class OFString; |
︙ | ︙ |
Modified src/exceptions/OFAllocFailedException.m from [845ed2917e] to [89b5d90d38].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFAllocFailedException.h" #import "OFString.h" |
︙ | ︙ | |||
30 31 32 33 34 35 36 | } - (instancetype)init { OF_INVALID_INIT_METHOD } | < < < < | < < < < < < < < < < < < < < < < < < | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | } - (instancetype)init { OF_INVALID_INIT_METHOD } OF_SINGLETON_METHODS - (OFString *)description { return @"Allocating an object failed!"; } @end |
Renamed and modified src/exceptions/OFAlreadyConnectedException.h [ac208c2ef2] to src/exceptions/OFAlreadyOpenException.h [c5e78ef424].
1 | /* | | | | | | > > > > | < > | < < < < | | | | | | | | | | | | | > > | | | > > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFAlreadyOpenException \ * OFAlreadyOpenException.h ObjFW/OFAlreadyOpenException.h * * @brief An exception indicating that an object is already open and thus * cannot be opened again. */ @interface OFAlreadyOpenException: OFException { id _object; OF_RESERVE_IVARS(OFAlreadyOpenException, 4) } /** * @brief The object which is already open. */ @property (readonly, nonatomic) id object; /** * @brief Creates a new, autoreleased already open exception. * * @param object The object which is already open * @return A new, autoreleased already open exception */ + (instancetype)exceptionWithObject: (id)object; + (instancetype)exception OF_UNAVAILABLE; /** * @brief Initializes an already allocated already open exception. * * @param object The object which is already open * @return An initialized already open exception */ - (instancetype)initWithObject: (id)object OF_DESIGNATED_INITIALIZER; - (instancetype)init OF_UNAVAILABLE; @end OF_ASSUME_NONNULL_END |
Renamed and modified src/exceptions/OFAlreadyConnectedException.m [9abd285501] to src/exceptions/OFAlreadyOpenException.m [648c8fe72a].
1 | /* | | | | | | > > > > | < > | | | | | | | | | | > > > > > | < | | | | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFAlreadyOpenException.h" #import "OFString.h" @implementation OFAlreadyOpenException @synthesize object = _object; + (instancetype)exceptionWithObject: (id)object { return [[[self alloc] initWithObject: object] autorelease]; } + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } - (instancetype)initWithObject: (id)object { self = [super init]; _object = [object retain]; return self; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (void)dealloc { [_object release]; [super dealloc]; } - (OFString *)description { return [OFString stringWithFormat: @"An object of type %@ is already open and thus cannot be opened " @"again!", [_object class]]; } @end |
Modified src/exceptions/OFBindDDPSocketFailedException.h from [5a5edecbc3] to [72bb41ea6b].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFBindSocketFailedException.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/exceptions/OFBindDDPSocketFailedException.m from [10cafd22cd] to [8212165840].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFBindDDPSocketFailedException.h" #import "OFData.h" #import "OFString.h" |
︙ | ︙ | |||
70 71 72 73 74 75 76 | return self; } - (OFString *)description { return [OFString stringWithFormat: @"Binding to port %" @PRIx8 @" of node %" @PRIx8 @" on network " | | | | 74 75 76 77 78 79 80 81 82 83 84 85 86 | return self; } - (OFString *)description { return [OFString stringWithFormat: @"Binding to port %" @PRIx8 @" of node %" @PRIx8 @" on network " @"%" PRIx16 @" with protocol type 0x%" @PRIX8 @" failed in socket " @"of type %@: %@", _port, _node, _network, _protocolType, [_socket class], OFStrError(_errNo)]; } @end |
Modified src/exceptions/OFBindIPSocketFailedException.h from [5e1e83771b] to [3402501d32].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFBindSocketFailedException.h" #ifndef OF_HAVE_SOCKETS # error No sockets available! #endif |
︙ | ︙ |
Modified src/exceptions/OFBindIPSocketFailedException.m from [f9eddfdc09] to [ba5ea71932].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFBindIPSocketFailedException.h" #import "OFString.h" |
︙ | ︙ |
Modified src/exceptions/OFBindIPXSocketFailedException.h from [348112e28c] to [5818777235].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFBindSocketFailedException.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/exceptions/OFBindIPXSocketFailedException.m from [ae7cdae06b] to [ad1ef2c59d].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "OFBindIPXSocketFailedException.h" |
︙ | ︙ | |||
76 77 78 79 80 81 82 | - (void)getNode: (unsigned char [IPX_NODE_LEN])node { memcpy(node, _node, sizeof(_node)); } - (OFString *)description { | < < | > | | | | 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | - (void)getNode: (unsigned char [IPX_NODE_LEN])node { memcpy(node, _node, sizeof(_node)); } - (OFString *)description { return [OFString stringWithFormat: @"Binding to network %" @PRIx16 " on node " @"%02X:%02X:%02X:%02X:%02X:%02X with port %" @PRIx16 @" failed for " @"packet type %" @PRIx8 " in socket of type %@: %@", _network, _node[0], _node[1], _node[2], _node[3], _node[4], _node[5], _port, _packetType, [_socket class], OFStrError(_errNo)]; } @end |
Modified src/exceptions/OFBindSocketFailedException.h from [36c8977d2e] to [2803ff7582].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" #ifndef OF_HAVE_SOCKETS # error No sockets available! #endif |
︙ | ︙ |
Modified src/exceptions/OFBindSocketFailedException.m from [6491b695d4] to [fc70288c89].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFBindSocketFailedException.h" #import "OFString.h" |
︙ | ︙ |
Modified src/exceptions/OFBindUNIXSocketFailedException.h from [8dc7fd786c] to [31ed831a71].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFBindSocketFailedException.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ | |||
39 40 41 42 43 44 45 | * @brief Creates a new, autoreleased bind UNIX socket failed exception. * * @param path The path on which binding failed * @param socket The socket which could not be bound * @param errNo The errno of the error that occurred * @return A new, autoreleased bind UNIX socket failed exception */ | | | | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | * @brief Creates a new, autoreleased bind UNIX socket failed exception. * * @param path The path on which binding failed * @param socket The socket which could not be bound * @param errNo The errno of the error that occurred * @return A new, autoreleased bind UNIX socket failed exception */ + (instancetype)exceptionWithPath: (nullable OFString *)path socket: (id)socket errNo: (int)errNo; + (instancetype)exceptionWithSocket: (id)socket errNo: (int)errNo OF_UNAVAILABLE; /** * @brief Initializes an already allocated bind UNIX socket failed exception. * * @param path The path on which binding failed * @param socket The socket which could not be bound * @param errNo The errno of the error that occurred * @return An initialized bind UNIX socket failed exception */ - (instancetype)initWithPath: (nullable OFString *)path socket: (id)socket errNo: (int)errNo OF_DESIGNATED_INITIALIZER; - (instancetype)initWithSocket: (id)socket errNo: (int)errNo OF_UNAVAILABLE; @end OF_ASSUME_NONNULL_END |
Modified src/exceptions/OFBindUNIXSocketFailedException.m from [e85a3193a3] to [6b2cd74356].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFBindUNIXSocketFailedException.h" #import "OFString.h" |
︙ | ︙ |
Modified src/exceptions/OFBroadcastConditionFailedException.h from [b5c55a5caf] to [c26850a055].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" #ifndef OF_HAVE_THREADS # error No threads available! #endif |
︙ | ︙ |
Modified src/exceptions/OFBroadcastConditionFailedException.m from [aeec33aa4e] to [e50d09f750].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "OFBroadcastConditionFailedException.h" |
︙ | ︙ |
Modified src/exceptions/OFChangeCurrentDirectoryFailedException.h from [c93252d4da] to [c328d99e4a].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/exceptions/OFChangeCurrentDirectoryFailedException.m from [7267a7e220] to [56e09d3f73].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFChangeCurrentDirectoryFailedException.h" #import "OFString.h" |
︙ | ︙ |
Modified src/exceptions/OFChecksumMismatchException.h from [5d6d269610] to [170ededd43].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/exceptions/OFChecksumMismatchException.m from [194677cc27] to [7f336fd028].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFChecksumMismatchException.h" #import "OFString.h" |
︙ | ︙ |
Modified src/exceptions/OFConditionStillWaitingException.h from [6424437193] to [2e667ffa9d].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" #ifndef OF_HAVE_THREADS # error No threads available! #endif |
︙ | ︙ |
Modified src/exceptions/OFConditionStillWaitingException.m from [28d38d170f] to [0cf691b9bc].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFConditionStillWaitingException.h" #import "OFString.h" #import "OFCondition.h" |
︙ | ︙ |
Modified src/exceptions/OFConnectIPSocketFailedException.h from [f85ab38f4c] to [9f6425a098].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFConnectSocketFailedException.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/exceptions/OFConnectIPSocketFailedException.m from [b9f4e412ce] to [b6ce24dfdf].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFConnectIPSocketFailedException.h" #import "OFString.h" |
︙ | ︙ |
Modified src/exceptions/OFConnectSPXSocketFailedException.h from [acdfa9213b] to [af88840c2b].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFConnectSocketFailedException.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/exceptions/OFConnectSPXSocketFailedException.m from [35220eec8e] to [970836f21c].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "OFConnectSPXSocketFailedException.h" |
︙ | ︙ | |||
70 71 72 73 74 75 76 | - (void)getNode: (unsigned char [IPX_NODE_LEN])node { memcpy(node, _node, sizeof(_node)); } - (OFString *)description { | < < | | > > | | 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | - (void)getNode: (unsigned char [IPX_NODE_LEN])node { memcpy(node, _node, sizeof(_node)); } - (OFString *)description { return [OFString stringWithFormat: @"A connection to %02X:%02X:%02X:%02X:%02X:%02X port %" @PRIu16 @" on network %" @PRIX32 " could not be established in socket of " @"type %@: %@", _node[0], _node[1], _node[2], _node[3], _node[4], _node[5], _port, _network, [_socket class], OFStrError(_errNo)]; } @end |
Modified src/exceptions/OFConnectSocketFailedException.h from [8f2d911f53] to [d6218faacc].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" #ifndef OF_HAVE_SOCKETS # error No sockets available! #endif |
︙ | ︙ |
Modified src/exceptions/OFConnectSocketFailedException.m from [cadbcb9d65] to [5402d2e897].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFConnectSocketFailedException.h" #import "OFString.h" |
︙ | ︙ |
Modified src/exceptions/OFConnectUNIXSocketFailedException.h from [9ffd06e788] to [32648dfd41].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFConnectSocketFailedException.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/exceptions/OFConnectUNIXSocketFailedException.m from [f1376977d4] to [0a5390e256].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFConnectUNIXSocketFailedException.h" #import "OFString.h" |
︙ | ︙ |
Modified src/exceptions/OFCopyItemFailedException.h from [123bfde77a] to [0cb2c83584].
1 | /* | | | | | | > > > > | < > | | | | | | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN @class OFIRI; /** * @class OFCopyItemFailedException \ * OFCopyItemFailedException.h ObjFW/OFCopyItemFailedException.h * * @brief An exception indicating that copying a item failed. */ @interface OFCopyItemFailedException: OFException { OFIRI *_sourceIRI, *_destinationIRI; int _errNo; OF_RESERVE_IVARS(OFCopyItemFailedException, 4) } /** * @brief The IRI of the source item. */ @property (readonly, nonatomic) OFIRI *sourceIRI; /** * @brief The destination IRI. */ @property (readonly, nonatomic) OFIRI *destinationIRI; /** * @brief The errno of the error that occurred. */ @property (readonly, nonatomic) int errNo; /** * @brief Creates a new, autoreleased copy item failed exception. * * @param sourceIRI The IRI of the source item * @param destinationIRI The destination IRI * @param errNo The errno of the error that occurred * @return A new, autoreleased copy item failed exception */ + (instancetype)exceptionWithSourceIRI: (OFIRI *)sourceIRI destinationIRI: (OFIRI *)destinationIRI errNo: (int)errNo; + (instancetype)exception OF_UNAVAILABLE; /** * @brief Initializes an already allocated copy item failed exception. * * @param sourceIRI The IRI of the source item * @param destinationIRI The destination IRI * @param errNo The errno of the error that occurred * @return An initialized copy item failed exception */ - (instancetype)initWithSourceIRI: (OFIRI *)sourceIRI destinationIRI: (OFIRI *)destinationIRI errNo: (int)errNo OF_DESIGNATED_INITIALIZER; - (instancetype)init OF_UNAVAILABLE; @end OF_ASSUME_NONNULL_END |
Modified src/exceptions/OFCopyItemFailedException.m from [86e24afee9] to [edb5a19d4c].
1 | /* | | | | | | > > > > | < > | | | | | | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFCopyItemFailedException.h" #import "OFIRI.h" #import "OFString.h" @implementation OFCopyItemFailedException @synthesize sourceIRI = _sourceIRI, destinationIRI = _destinationIRI; @synthesize errNo = _errNo; + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } + (instancetype)exceptionWithSourceIRI: (OFIRI *)sourceIRI destinationIRI: (OFIRI *)destinationIRI errNo: (int)errNo { return [[[self alloc] initWithSourceIRI: sourceIRI destinationIRI: destinationIRI errNo: errNo] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithSourceIRI: (OFIRI *)sourceIRI destinationIRI: (OFIRI *)destinationIRI errNo: (int)errNo { self = [super init]; @try { _sourceIRI = [sourceIRI copy]; _destinationIRI = [destinationIRI copy]; _errNo = errNo; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_sourceIRI release]; [_destinationIRI release]; [super dealloc]; } - (OFString *)description { return [OFString stringWithFormat: @"Failed to copy item %@ to %@: %@", _sourceIRI, _destinationIRI, OFStrError(_errNo)]; } @end |
Modified src/exceptions/OFCreateDirectoryFailedException.h from [e16c672401] to [42f7e4d166].
1 | /* | | | | | | > > > > | < > | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN @class OFIRI; /** * @class OFCreateDirectoryFailedException \ * OFCreateDirectoryFailedException.h \ * ObjFW/OFCreateDirectoryFailedException.h * * @brief An exception indicating a directory couldn't be created. */ @interface OFCreateDirectoryFailedException: OFException { OFIRI *_IRI; int _errNo; OF_RESERVE_IVARS(OFCreateDirectoryFailedException, 4) } /** * @brief The IRI of the directory which couldn't be created. */ @property (readonly, nonatomic) OFIRI *IRI; /** * @brief The errno of the error that occurred. */ @property (readonly, nonatomic) int errNo; /** * @brief Creates a new, autoreleased create directory failed exception. * * @param IRI The IRI of the directory which could not be created * @param errNo The errno of the error that occurred * @return A new, autoreleased create directory failed exception */ + (instancetype)exceptionWithIRI: (OFIRI *)IRI errNo: (int)errNo; + (instancetype)exception OF_UNAVAILABLE; /** * @brief Initializes an already allocated create directory failed exception. * * @param IRI The IRI of the directory which could not be created * @param errNo The errno of the error that occurred * @return An initialized create directory failed exception */ - (instancetype)initWithIRI: (OFIRI *)IRI errNo: (int)errNo OF_DESIGNATED_INITIALIZER; - (instancetype)init OF_UNAVAILABLE; @end OF_ASSUME_NONNULL_END |
Modified src/exceptions/OFCreateDirectoryFailedException.m from [cd0b53b912] to [ee3d3dd3ba].
1 | /* | | | | | | > > > > | < > | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFCreateDirectoryFailedException.h" #import "OFIRI.h" #import "OFString.h" @implementation OFCreateDirectoryFailedException @synthesize IRI = _IRI, errNo = _errNo; + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } + (instancetype)exceptionWithIRI: (OFIRI *)IRI errNo: (int)errNo { return [[[self alloc] initWithIRI: IRI errNo: errNo] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithIRI: (OFIRI *)IRI errNo: (int)errNo { self = [super init]; @try { _IRI = [IRI copy]; _errNo = errNo; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_IRI release]; [super dealloc]; } - (OFString *)description { return [OFString stringWithFormat: @"Failed to create directory %@: %@", _IRI, OFStrError(_errNo)]; } @end |
Modified src/exceptions/OFCreateSymbolicLinkFailedException.h from [79c2f6b7ee] to [728c2c7d81].
1 | /* | | | | | | > > > > | < > | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN @class OFIRI; /** * @class OFCreateSymbolicLinkFailedException \ * OFCreateSymbolicLinkFailedException.h \ * ObjFW/OFCreateSymbolicLinkFailedException.h * * @brief An exception indicating that creating a symbolic link failed. */ @interface OFCreateSymbolicLinkFailedException: OFException { OFIRI *_IRI; OFString *_target; int _errNo; OF_RESERVE_IVARS(OFCreateSymbolicLinkFailedException, 4) } /** * @brief The IRI at which the symbolic link should have been created. */ @property (readonly, nonatomic) OFIRI *IRI; /** * @brief The target for the symbolic link. */ @property (readonly, nonatomic) OFString *target; /** * @brief The errno of the error that occurred. */ @property (readonly, nonatomic) int errNo; /** * @brief Creates a new, autoreleased create symbolic link failed exception. * * @param IRI The IRI where the symbolic link should have been created * @param target The target for the symbolic link * @param errNo The errno of the error that occurred * @return A new, autoreleased create symbolic link failed exception */ + (instancetype)exceptionWithIRI: (OFIRI *)IRI target: (OFString *)target errNo: (int)errNo; + (instancetype)exception OF_UNAVAILABLE; /** * @brief Initializes an already allocated create symbolic link failed * exception. * * @param IRI The IRI where the symbolic link should have been created * @param target The target for the symbolic link * @param errNo The errno of the error that occurred * @return An initialized create symbolic link failed exception */ - (instancetype)initWithIRI: (OFIRI *)IRI target: (OFString *)target errNo: (int)errNo OF_DESIGNATED_INITIALIZER; - (instancetype)init OF_UNAVAILABLE; @end OF_ASSUME_NONNULL_END |
Modified src/exceptions/OFCreateSymbolicLinkFailedException.m from [c5e085b246] to [3036e6ab28].
1 | /* | | | | | | > > > > | < > | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFCreateSymbolicLinkFailedException.h" #import "OFIRI.h" #import "OFString.h" @implementation OFCreateSymbolicLinkFailedException @synthesize IRI = _IRI, target = _target, errNo = _errNo; + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } + (instancetype)exceptionWithIRI: (OFIRI *)IRI target: (OFString *)target errNo: (int)errNo { return [[[self alloc] initWithIRI: IRI target: target errNo: errNo] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithIRI: (OFIRI *)IRI target: (OFString *)target errNo: (int)errNo { self = [super init]; @try { _IRI = [IRI copy]; _target = [target copy]; _errNo = errNo; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_IRI release]; [_target release]; [super dealloc]; } - (OFString *)description { return [OFString stringWithFormat: @"Failed to create symbolic link %@ with target %@: %@", _IRI, _target, OFStrError(_errNo)]; } @end |
Modified src/exceptions/OFCreateWindowsRegistryKeyFailedException.h from [3739e39dc2] to [6c0d331562].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" #import "OFWindowsRegistryKey.h" #include <windows.h> |
︙ | ︙ |
Modified src/exceptions/OFCreateWindowsRegistryKeyFailedException.m from [3f8a5e58b7] to [6808748419].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFCreateWindowsRegistryKeyFailedException.h" @implementation OFCreateWindowsRegistryKeyFailedException |
︙ | ︙ |
Modified src/exceptions/OFDNSQueryFailedException.h from [e0cf12b730] to [ba6bf4fd32].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" #import "OFDNSQuery.h" #import "OFDNSResolver.h" #import "OFDNSResourceRecord.h" |
︙ | ︙ |
Modified src/exceptions/OFDNSQueryFailedException.m from [d34eb3c9de] to [cbd992d3b3].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFDNSQueryFailedException.h" #import "OFString.h" |
︙ | ︙ |
Modified src/exceptions/OFDeleteWindowsRegistryKeyFailedException.h from [7a006ec7b5] to [800bc906f1].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" #import "OFWindowsRegistryKey.h" #include <windows.h> |
︙ | ︙ |
Modified src/exceptions/OFDeleteWindowsRegistryKeyFailedException.m from [123f06f5d8] to [334a748840].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFDeleteWindowsRegistryKeyFailedException.h" #import "OFData.h" |
︙ | ︙ |
Modified src/exceptions/OFDeleteWindowsRegistryValueFailedException.h from [0a7f480a16] to [eb520d9a0e].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" #import "OFWindowsRegistryKey.h" #include <windows.h> |
︙ | ︙ |
Modified src/exceptions/OFDeleteWindowsRegistryValueFailedException.m from [efa255c388] to [0e23fc3fee].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFDeleteWindowsRegistryValueFailedException.h" #import "OFData.h" |
︙ | ︙ |
Modified src/exceptions/OFEnumerationMutationException.h from [1a130e7399] to [c8d8107910].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/exceptions/OFEnumerationMutationException.m from [f408c0df64] to [98380ed15f].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFEnumerationMutationException.h" #import "OFString.h" |
︙ | ︙ |
Modified src/exceptions/OFException.h from [e7c0836484] to [b676d6c459].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #ifdef OF_WINDOWS # include <windows.h> #endif |
︙ | ︙ |
Modified src/exceptions/OFException.m from [700714ee53] to [816a02d4da].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #include <stdio.h> #include <stdlib.h> |
︙ | ︙ |
Modified src/exceptions/OFGetCurrentDirectoryFailedException.h from [60ae2d8910] to [c86c2ee31f].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/exceptions/OFGetCurrentDirectoryFailedException.m from [b29d0ac295] to [7af5414d74].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFGetCurrentDirectoryFailedException.h" #import "OFString.h" |
︙ | ︙ |
Modified src/exceptions/OFGetItemAttributesFailedException.h from [354af07fb2] to [1816ac19d2].
1 | /* | | | | | | > > > > | < > | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN @class OFIRI; /** * @class OFGetItemAttributesFailedException \ * OFGetItemAttributesFailedException.h \ * ObjFW/OFGetItemAttributesFailedException.h * * @brief An exception indicating an item's attributes could not be retrieved. */ @interface OFGetItemAttributesFailedException: OFException { OFIRI *_IRI; int _errNo; OF_RESERVE_IVARS(OFGetItemAttributesFailedException, 4) } /** * @brief The IRI of the item whose attributes could not be retrieved. */ @property (readonly, nonatomic) OFIRI *IRI; /** * @brief The errno of the error that occurred. */ @property (readonly, nonatomic) int errNo; /** * @brief Creates a new, autoreleased retrieve item attributes failed exception. * * @param IRI The IRI of the item whose attributes could not be retrieved * @param errNo The errno of the error that occurred * @return A new, autoreleased retrieve item attributes failed exception */ + (instancetype)exceptionWithIRI: (OFIRI *)IRI errNo: (int)errNo; + (instancetype)exception OF_UNAVAILABLE; /** * @brief Initializes an already allocated retrieve item attributes failed * exception. * * @param IRI The IRI of the item whose attributes could not be retrieved * @param errNo The errno of the error that occurred * @return An initialized retrieve item attributes failed exception */ - (instancetype)initWithIRI: (OFIRI *)IRI errNo: (int)errNo OF_DESIGNATED_INITIALIZER; - (instancetype)init OF_UNAVAILABLE; @end OF_ASSUME_NONNULL_END |
Modified src/exceptions/OFGetItemAttributesFailedException.m from [db212ce8f9] to [a951871d92].
1 | /* | | | | | | > > > > | < > | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFGetItemAttributesFailedException.h" #import "OFIRI.h" #import "OFString.h" @implementation OFGetItemAttributesFailedException @synthesize IRI = _IRI, errNo = _errNo; + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } + (instancetype)exceptionWithIRI: (OFIRI *)IRI errNo: (int)errNo { return [[[self alloc] initWithIRI: IRI errNo: errNo] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithIRI: (OFIRI *)IRI errNo: (int)errNo { self = [super init]; @try { _IRI = [IRI copy]; _errNo = errNo; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_IRI release]; [super dealloc]; } - (OFString *)description { return [OFString stringWithFormat: @"Failed to get attributes for item %@: %@", _IRI, OFStrError(_errNo)]; } @end |
Modified src/exceptions/OFGetOptionFailedException.h from [a8c8d533b3] to [eb77faa3f3].
1 | /* | | | | | | > > > > | < > | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFGetOptionFailedException \ * OFGetOptionFailedException.h ObjFW/OFGetOptionFailedException.h * * @brief An exception indicating that getting an option for an object failed. */ @interface OFGetOptionFailedException: OFException { id _Nullable _object; int _errNo; OF_RESERVE_IVARS(OFGetOptionFailedException, 4) } /** * @brief The object for which the option could not be retrieved. */ @property OF_NULLABLE_PROPERTY (readonly, nonatomic) id object; /** * @brief The errno of the error that occurred. */ @property (readonly, nonatomic) int errNo; /** * @brief Creates a new, autoreleased get option failed exception. * * @param object The object for which the option could not be retrieved * @param errNo The errno of the error that occurred * @return A new, autoreleased get option failed exception */ + (instancetype)exceptionWithObject: (nullable id)object errNo: (int)errNo; + (instancetype)exception OF_UNAVAILABLE; /** * @brief Initializes an already allocated get option failed exception. * * @param object The object for which the option could not be retrieved * @param errNo The errno of the error that occurred * @return An initialized get option failed exception */ - (instancetype)initWithObject: (nullable id)object errNo: (int)errNo OF_DESIGNATED_INITIALIZER; - (instancetype)init OF_UNAVAILABLE; @end OF_ASSUME_NONNULL_END |
Modified src/exceptions/OFGetOptionFailedException.m from [aeeadc602d] to [564b6f9031].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFGetOptionFailedException.h" #import "OFString.h" |
︙ | ︙ | |||
51 52 53 54 55 56 57 | [_object release]; [super dealloc]; } - (OFString *)description { | > | | | > > > | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | [_object release]; [super dealloc]; } - (OFString *)description { if (_object != nil) return [OFString stringWithFormat: @"Getting an option in an object of type %@ failed: %@", [_object class], OFStrError(_errNo)]; else return [OFString stringWithFormat: @"Getting an option failed: %@", OFStrError(_errNo)]; } @end |
Modified src/exceptions/OFGetWindowsRegistryValueFailedException.h from [1bae299028] to [6ce55a16b8].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" #import "OFWindowsRegistryKey.h" #include <windows.h> |
︙ | ︙ |
Modified src/exceptions/OFGetWindowsRegistryValueFailedException.m from [57087b05b3] to [fb4c183eca].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFGetWindowsRegistryValueFailedException.h" @implementation OFGetWindowsRegistryValueFailedException |
︙ | ︙ |
Modified src/exceptions/OFHTTPRequestFailedException.h from [d5947528d2] to [21a13ebd9f].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" #ifndef OF_HAVE_SOCKETS # error No sockets available! #endif |
︙ | ︙ |
Modified src/exceptions/OFHTTPRequestFailedException.m from [f93ff97e23] to [027087333a].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFHTTPRequestFailedException.h" #import "OFString.h" #import "OFHTTPRequest.h" |
︙ | ︙ | |||
57 58 59 60 61 62 63 | [_response release]; [super dealloc]; } - (OFString *)description { | | | | | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | [_response release]; [super dealloc]; } - (OFString *)description { OFString *method = OFHTTPRequestMethodString(_request.method); return [OFString stringWithFormat: @"An HTTP %@ request with IRI %@ failed with code %hd!", method, _request.IRI, _response.statusCode]; } @end |
Modified src/exceptions/OFHashAlreadyCalculatedException.h from [0455e7b89e] to [9e9a34d437].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/exceptions/OFHashAlreadyCalculatedException.m from [cf2d8e44b5] to [360089d06d].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFHashAlreadyCalculatedException.h" #import "OFString.h" |
︙ | ︙ |
Modified src/exceptions/OFHashNotCalculatedException.h from [e76b9886eb] to [ee1e269435].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/exceptions/OFHashNotCalculatedException.m from [3e84cb3642] to [3a421d5a19].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFHashNotCalculatedException.h" #import "OFString.h" |
︙ | ︙ |
Modified src/exceptions/OFInitializationFailedException.h from [280997dfe1] to [0b990aec38].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/exceptions/OFInitializationFailedException.m from [cfa23bb7fe] to [b08c6880cd].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFInitializationFailedException.h" #import "OFString.h" |
︙ | ︙ |
Modified src/exceptions/OFInvalidArgumentException.h from [835c000126] to [500da824bb].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/exceptions/OFInvalidArgumentException.m from [70957802ed] to [63bef8eff1].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFInvalidArgumentException.h" #import "OFString.h" |
︙ | ︙ |
Modified src/exceptions/OFInvalidEncodingException.h from [36e737e07d] to [7c1237f23c].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/exceptions/OFInvalidEncodingException.m from [7e85cac169] to [d1a4795648].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFInvalidEncodingException.h" #import "OFString.h" |
︙ | ︙ |
Modified src/exceptions/OFInvalidFormatException.h from [7bd0078c9f] to [fad7869605].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/exceptions/OFInvalidFormatException.m from [f3d13d03ab] to [b2ae4cb591].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFInvalidFormatException.h" #import "OFString.h" |
︙ | ︙ |
Modified src/exceptions/OFInvalidJSONException.h from [a9bef800fe] to [bf2638d8da].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/exceptions/OFInvalidJSONException.m from [973f5127bd] to [2b9327625c].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFInvalidJSONException.h" #import "OFString.h" |
︙ | ︙ |
Modified src/exceptions/OFInvalidServerResponseException.h from [8680d9915b] to [3d14df9888].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/exceptions/OFInvalidServerResponseException.m from [8436f85f3d] to [d70081805b].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFInvalidServerResponseException.h" #import "OFString.h" |
︙ | ︙ |
Modified src/exceptions/OFJoinThreadFailedException.h from [b841fb7f6d] to [95354adcf9].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" #ifndef OF_HAVE_THREADS # error No threads available! #endif |
︙ | ︙ |
Modified src/exceptions/OFJoinThreadFailedException.m from [7e2f0f00c7] to [0f92c93dee].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "OFJoinThreadFailedException.h" |
︙ | ︙ |
Modified src/exceptions/OFLinkItemFailedException.h from [bc4e6321e5] to [df6f0e446c].
1 | /* | | | | | | > > > > | < > | | | | | | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN @class OFIRI; /** * @class OFLinkItemFailedException \ * OFLinkItemFailedException.h ObjFW/OFLinkItemFailedException.h * * @brief An exception indicating that creating a link failed. */ @interface OFLinkItemFailedException: OFException { OFIRI *_sourceIRI, *_destinationIRI; int _errNo; OF_RESERVE_IVARS(OFLinkItemFailedException, 4) } /** * @brief An IRI with the source for the link. */ @property (readonly, nonatomic) OFIRI *sourceIRI; /** * @brief An IRI with the destination for the link. */ @property (readonly, nonatomic) OFIRI *destinationIRI; /** * @brief The errno of the error that occurred. */ @property (readonly, nonatomic) int errNo; /** * @brief Creates a new, autoreleased link failed exception. * * @param sourceIRI The source for the link * @param destinationIRI The destination for the link * @param errNo The errno of the error that occurred * @return A new, autoreleased link failed exception */ + (instancetype)exceptionWithSourceIRI: (OFIRI *)sourceIRI destinationIRI: (OFIRI *)destinationIRI errNo: (int)errNo; + (instancetype)exception OF_UNAVAILABLE; /** * @brief Initializes an already allocated link failed exception. * * @param sourceIRI The source for the link * @param destinationIRI The destination for the link * @param errNo The errno of the error that occurred * @return An initialized link failed exception */ - (instancetype)initWithSourceIRI: (OFIRI*)sourceIRI destinationIRI: (OFIRI *)destinationIRI errNo: (int)errNo OF_DESIGNATED_INITIALIZER; - (instancetype)init OF_UNAVAILABLE; @end OF_ASSUME_NONNULL_END |
Modified src/exceptions/OFLinkItemFailedException.m from [3033895110] to [531e3bb795].
1 | /* | | | | | | > > > > | < > | | | | | | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFLinkItemFailedException.h" #import "OFIRI.h" #import "OFString.h" @implementation OFLinkItemFailedException @synthesize sourceIRI = _sourceIRI, destinationIRI = _destinationIRI; @synthesize errNo = _errNo; + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } + (instancetype)exceptionWithSourceIRI: (OFIRI *)sourceIRI destinationIRI: (OFIRI *)destinationIRI errNo: (int)errNo { return [[[self alloc] initWithSourceIRI: sourceIRI destinationIRI: destinationIRI errNo: errNo] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithSourceIRI: (OFIRI *)sourceIRI destinationIRI: (OFIRI *)destinationIRI errNo: (int)errNo { self = [super init]; @try { _sourceIRI = [sourceIRI copy]; _destinationIRI = [destinationIRI copy]; _errNo = errNo; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_sourceIRI release]; [_destinationIRI release]; [super dealloc]; } - (OFString *)description { return [OFString stringWithFormat: @"Failed to link file %@ to %@: %@", _sourceIRI, _destinationIRI, OFStrError(_errNo)]; } @end |
Modified src/exceptions/OFListenOnSocketFailedException.h from [98d11c8685] to [5b74e45810].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" #ifndef OF_HAVE_SOCKETS # error No sockets available! #endif |
︙ | ︙ |
Modified src/exceptions/OFListenOnSocketFailedException.m from [5b45bde80b] to [f144dd8a0f].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFListenOnSocketFailedException.h" #import "OFString.h" |
︙ | ︙ |
Modified src/exceptions/OFLoadPluginFailedException.h from [bb70233a5c] to [3034ab655b].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/exceptions/OFLoadPluginFailedException.m from [73caeab9c3] to [75b1e38324].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFLoadPluginFailedException.h" #import "OFString.h" |
︙ | ︙ |
Modified src/exceptions/OFLockFailedException.h from [58545dfa42] to [54f0d561f0].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" #import "OFLocking.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ |
Modified src/exceptions/OFLockFailedException.m from [77b32492ca] to [6c13e2bd2f].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "OFLockFailedException.h" |
︙ | ︙ |
Modified src/exceptions/OFMalformedXMLException.h from [d319798b44] to [63cf356fb7].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" @class OFXMLParser; OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ |
Modified src/exceptions/OFMalformedXMLException.m from [f5ceb7c800] to [69093b3dfb].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFMalformedXMLException.h" #import "OFString.h" #import "OFXMLParser.h" |
︙ | ︙ |
Modified src/exceptions/OFMoveItemFailedException.h from [f2cc0cdf02] to [86beb99f9c].
1 | /* | | | | | | > > > > | < > | | | | | | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN @class OFIRI; /** * @class OFMoveItemFailedException \ * OFMoveItemFailedException.h ObjFW/OFMoveItemFailedException.h * * @brief An exception indicating that moving an item failed. */ @interface OFMoveItemFailedException: OFException { OFIRI *_sourceIRI, *_destinationIRI; int _errNo; OF_RESERVE_IVARS(OFMoveItemFailedException, 4) } /** * @brief The original IRI. */ @property (readonly, nonatomic) OFIRI *sourceIRI; /** * @brief The new IRI. */ @property (readonly, nonatomic) OFIRI *destinationIRI; /** * @brief The errno of the error that occurred. */ @property (readonly, nonatomic) int errNo; /** * @brief Creates a new, autoreleased move item failed exception. * * @param sourceIRI The original IRI * @param destinationIRI The new IRI * @param errNo The errno of the error that occurred * @return A new, autoreleased move item failed exception */ + (instancetype)exceptionWithSourceIRI: (OFIRI *)sourceIRI destinationIRI: (OFIRI *)destinationIRI errNo: (int)errNo; + (instancetype)exception OF_UNAVAILABLE; /** * @brief Initializes an already allocated move item failed exception. * * @param sourceIRI The original IRI * @param destinationIRI The new IRI * @param errNo The errno of the error that occurred * @return An initialized move item failed exception */ - (instancetype)initWithSourceIRI: (OFIRI *)sourceIRI destinationIRI: (OFIRI *)destinationIRI errNo: (int)errNo OF_DESIGNATED_INITIALIZER; - (instancetype)init OF_UNAVAILABLE; @end OF_ASSUME_NONNULL_END |
Modified src/exceptions/OFMoveItemFailedException.m from [7df7241c06] to [3a981a62c1].
1 | /* | | | | | | > > > > | < > | | | | | | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFMoveItemFailedException.h" #import "OFIRI.h" #import "OFString.h" @implementation OFMoveItemFailedException @synthesize sourceIRI = _sourceIRI, destinationIRI = _destinationIRI; @synthesize errNo = _errNo; + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } + (instancetype)exceptionWithSourceIRI: (OFIRI *)sourceIRI destinationIRI: (OFIRI *)destinationIRI errNo: (int)errNo { return [[[self alloc] initWithSourceIRI: sourceIRI destinationIRI: destinationIRI errNo: errNo] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithSourceIRI: (OFIRI *)sourceIRI destinationIRI: (OFIRI *)destinationIRI errNo: (int)errNo { self = [super init]; @try { _sourceIRI = [sourceIRI copy]; _destinationIRI = [destinationIRI copy]; _errNo = errNo; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_sourceIRI release]; [_destinationIRI release]; [super dealloc]; } - (OFString *)description { return [OFString stringWithFormat: @"Failed to move item at %@ to %@: %@", _sourceIRI, _destinationIRI, OFStrError(_errNo)]; } @end |
Modified src/exceptions/OFNotImplementedException.h from [f0426204c4] to [4e70675837].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/exceptions/OFNotImplementedException.m from [c04e46d7c8] to [29bfa7fb1b].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFNotImplementedException.h" #import "OFString.h" |
︙ | ︙ |
Modified src/exceptions/OFNotOpenException.h from [5a826ad61e] to [9c6f26ee07].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/exceptions/OFNotOpenException.m from [b0a200e662] to [62bfabbdb1].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFNotOpenException.h" #import "OFString.h" |
︙ | ︙ |
Modified src/exceptions/OFObserveKernelEventsFailedException.h from [a11562c534] to [c1dd2f02b6].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN @class OFKernelEventObserver; |
︙ | ︙ |
Modified src/exceptions/OFObserveKernelEventsFailedException.m from [1f89b66175] to [3cea937102].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFObserveKernelEventsFailedException.h" #import "OFString.h" #import "OFKernelEventObserver.h" |
︙ | ︙ |
Modified src/exceptions/OFOpenItemFailedException.h from [fe988003bf] to [799f3d0715].
1 | /* | | | | | | > > > > | < > | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN @class OFIRI; /** * @class OFOpenItemFailedException \ * OFOpenItemFailedException.h ObjFW/OFOpenItemFailedException.h * * @brief An exception indicating an item could not be opened. */ @interface OFOpenItemFailedException: OFException { OFIRI *_Nullable _IRI; OFString *_Nullable _path; OFString *_mode; int _errNo; OF_RESERVE_IVARS(OFOpenItemFailedException, 4) } /** * @brief The IRI of the item which could not be opened. */ @property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFIRI *IRI; /** * @brief The path of the item which could not be opened. */ @property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *path; /** * @brief The mode in which the item should have been opened. */ @property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *mode; /** * @brief The errno of the error that occurred. */ @property (readonly, nonatomic) int errNo; /** * @brief Creates a new, autoreleased open item failed exception. * * @param IRI The IRI of the item which could not be opened * @param mode A string with the mode in which the item should have been opened * @param errNo The errno of the error that occurred * @return A new, autoreleased open item failed exception */ + (instancetype)exceptionWithIRI: (OFIRI *)IRI mode: (nullable OFString *)mode errNo: (int)errNo; /** * @brief Creates a new, autoreleased open item failed exception. * * @param path The path of the item which could not be opened * @param mode A string with the mode in which the item should have been opened * @param errNo The errno of the error that occurred * @return A new, autoreleased open item failed exception */ + (instancetype)exceptionWithPath: (OFString *)path mode: (nullable OFString *)mode errNo: (int)errNo; + (instancetype)exception OF_UNAVAILABLE; /** * @brief Initializes an already allocated open item failed exception. * * @param IRI The IRI of the item which could not be opened * @param mode A string with the mode in which the item should have been opened * @param errNo The errno of the error that occurred * @return An initialized open item failed exception */ - (instancetype)initWithIRI: (OFIRI *)IRI mode: (nullable OFString *)mode errNo: (int)errNo; /** * @brief Initializes an already allocated open item failed exception. * * @param path The path of the item which could not be opened |
︙ | ︙ |
Modified src/exceptions/OFOpenItemFailedException.m from [7129cdf836] to [c093bc70eb].
1 | /* | | | | | | > > > > | < > | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFOpenItemFailedException.h" #import "OFIRI.h" #import "OFString.h" @implementation OFOpenItemFailedException @synthesize IRI = _IRI, path = _path, mode = _mode, errNo = _errNo; + (instancetype)exceptionWithIRI: (OFIRI *)IRI mode: (OFString *)mode errNo: (int)errNo { return [[[self alloc] initWithIRI: IRI mode: mode errNo: errNo] autorelease]; } + (instancetype)exceptionWithPath: (OFString *)path mode: (OFString *)mode errNo: (int)errNo { return [[[self alloc] initWithPath: path mode: mode errNo: errNo] autorelease]; } + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } - (instancetype)initWithIRI: (OFIRI *)IRI mode: (OFString *)mode errNo: (int)errNo { self = [super init]; @try { _IRI = [IRI copy]; _mode = [mode copy]; _errNo = errNo; } @catch (id e) { [self release]; @throw e; } |
︙ | ︙ | |||
84 85 86 87 88 89 90 | - (instancetype)init { OF_INVALID_INIT_METHOD } - (void)dealloc { | | | | | 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | - (instancetype)init { OF_INVALID_INIT_METHOD } - (void)dealloc { [_IRI release]; [_path release]; [_mode release]; [super dealloc]; } - (OFString *)description { id item = nil; if (_IRI != nil) item = _IRI; else if (_path != nil) item = _path; if (_mode != nil) return [OFString stringWithFormat: @"Failed to open file %@ with mode %@: %@", item, _mode, OFStrError(_errNo)]; else return [OFString stringWithFormat: @"Failed to open item %@: %@", item, OFStrError(_errNo)]; } @end |
Modified src/exceptions/OFOpenWindowsRegistryKeyFailedException.h from [36fb64cf1a] to [03f680e59b].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" #import "OFWindowsRegistryKey.h" #include <windows.h> |
︙ | ︙ |
Modified src/exceptions/OFOpenWindowsRegistryKeyFailedException.m from [64b24e1261] to [3030425341].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFOpenWindowsRegistryKeyFailedException.h" @implementation OFOpenWindowsRegistryKeyFailedException |
︙ | ︙ |
Modified src/exceptions/OFOutOfMemoryException.h from [f5654732f6] to [75604a2e4e].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/exceptions/OFOutOfMemoryException.m from [f0195e5a54] to [aa2a685889].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFOutOfMemoryException.h" #import "OFString.h" |
︙ | ︙ |
Modified src/exceptions/OFOutOfRangeException.h from [f8a5e124cb] to [deaaf10f37].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/exceptions/OFOutOfRangeException.m from [42dae12fbe] to [7c97ee14f2].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFOutOfRangeException.h" #import "OFString.h" |
︙ | ︙ |
Modified src/exceptions/OFReadFailedException.h from [1ab276c5fd] to [83e9039cae].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFReadOrWriteFailedException.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/exceptions/OFReadFailedException.m from [0a38835e23] to [0ee8e224e9].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFReadFailedException.h" #import "OFString.h" |
︙ | ︙ |
Modified src/exceptions/OFReadOrWriteFailedException.h from [2c37db7aa0] to [8a693dea2f].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/exceptions/OFReadOrWriteFailedException.m from [02ef4afd0b] to [112c386c33].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFReadOrWriteFailedException.h" #import "OFString.h" |
︙ | ︙ |
Modified src/exceptions/OFRemoveItemFailedException.h from [18b7b9ee6b] to [b75f625594].
1 | /* | | | | | | > > > > | < > | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN @class OFIRI; /** * @class OFRemoveItemFailedException \ * OFRemoveItemFailedException.h ObjFW/OFRemoveItemFailedException.h * * @brief An exception indicating that removing an item failed. */ @interface OFRemoveItemFailedException: OFException { OFIRI *_IRI; int _errNo; OF_RESERVE_IVARS(OFRemoveItemFailedException, 4) } /** * @brief The IRI of the item which could not be removed. */ @property (readonly, nonatomic) OFIRI *IRI; /** * @brief The errno of the error that occurred. */ @property (readonly, nonatomic) int errNo; /** * @brief Creates a new, autoreleased remove failed exception. * * @param IRI The IRI of the item which could not be removed * @param errNo The errno of the error that occurred * @return A new, autoreleased remove item failed exception */ + (instancetype)exceptionWithIRI: (OFIRI *)IRI errNo: (int)errNo; + (instancetype)exception OF_UNAVAILABLE; /** * @brief Initializes an already allocated remove failed exception. * * @param IRI The IRI of the item which could not be removed * @param errNo The errno of the error that occurred * @return An initialized remove item failed exception */ - (instancetype)initWithIRI: (OFIRI *)IRI errNo: (int)errNo OF_DESIGNATED_INITIALIZER; - (instancetype)init OF_UNAVAILABLE; @end OF_ASSUME_NONNULL_END |
Modified src/exceptions/OFRemoveItemFailedException.m from [790fd92540] to [11cff1a845].
1 | /* | | | | | | > > > > | < > | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFRemoveItemFailedException.h" #import "OFIRI.h" #import "OFString.h" @implementation OFRemoveItemFailedException @synthesize IRI = _IRI, errNo = _errNo; + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } + (instancetype)exceptionWithIRI: (OFIRI *)IRI errNo: (int)errNo { return [[[self alloc] initWithIRI: IRI errNo: errNo] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithIRI: (OFIRI *)IRI errNo: (int)errNo { self = [super init]; @try { _IRI = [IRI copy]; _errNo = errNo; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_IRI release]; [super dealloc]; } - (OFString *)description { return [OFString stringWithFormat: @"Failed to remove item at IRI %@: %@", _IRI, OFStrError(_errNo)]; } @end |
Modified src/exceptions/OFResolveHostFailedException.h from [983add21d8] to [0f8b4c79cc].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" #import "OFDNSResolver.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ |
Modified src/exceptions/OFResolveHostFailedException.m from [a81a110c2f] to [fe448762f6].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFResolveHostFailedException.h" #import "OFDNSQueryFailedException.h" #import "OFString.h" |
︙ | ︙ |
Modified src/exceptions/OFSeekFailedException.h from [2132111c3a] to [f914973116].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" #import "OFSeekableStream.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ |
Modified src/exceptions/OFSeekFailedException.m from [20812553c7] to [0c11c0c6c4].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFSeekFailedException.h" #import "OFString.h" #import "OFSeekableStream.h" |
︙ | ︙ |
Modified src/exceptions/OFSetItemAttributesFailedException.h from [4b245f8a54] to [fe898bbe99].
1 | /* | | | | | | > > > > | < > | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" #import "OFIRIHandler.h" OF_ASSUME_NONNULL_BEGIN @class OFIRI; /** * @class OFSetItemAttributesFailedException \ * OFSetItemAttributesFailedException.h \ * ObjFW/OFSetItemAttributesFailedException.h * * @brief An exception indicating an item's attributes could not be set. */ @interface OFSetItemAttributesFailedException: OFException { OFIRI *_IRI; OFFileAttributes _attributes; OFFileAttributeKey _failedAttribute; int _errNo; OF_RESERVE_IVARS(OFSetItemAttributesFailedException, 4) } /** * @brief The IRI of the item whose attributes could not be set. */ @property (readonly, nonatomic) OFIRI *IRI; /** * @brief The errno of the error that occurred. */ @property (readonly, nonatomic) int errNo; /** * @brief The attributes that should have been set. */ @property (readonly, nonatomic) OFFileAttributes attributes; /** * @brief The first attribute that could not be set. */ @property (readonly, nonatomic) OFFileAttributeKey failedAttribute; /** * @brief Creates a new, autoreleased set item attributes failed exception. * * @param IRI The IRI of the item whose attributes could not be set * @param attributes The attributes that should have been set for the specified * item. * @param failedAttribute The first attribute that could not be set * @param errNo The errno of the error that occurred * @return A new, autoreleased set item attributes failed exception */ + (instancetype)exceptionWithIRI: (OFIRI *)IRI attributes: (OFFileAttributes)attributes failedAttribute: (OFFileAttributeKey)failedAttribute errNo: (int)errNo; + (instancetype)exception OF_UNAVAILABLE; /** * @brief Initializes an already allocated set item attributes failed exception. * * @param IRI The IRI of the item whose attributes could not be set * @param attributes The attributes that should have been set for the specified * item. * @param failedAttribute The first attribute that could not be set * @param errNo The errno of the error that occurred * @return An initialized set item attributes failed exception */ - (instancetype)initWithIRI: (OFIRI *)IRI attributes: (OFFileAttributes)attributes failedAttribute: (OFFileAttributeKey)failedAttribute errNo: (int)errNo OF_DESIGNATED_INITIALIZER; - (instancetype)init OF_UNAVAILABLE; @end OF_ASSUME_NONNULL_END |
Modified src/exceptions/OFSetItemAttributesFailedException.m from [419b3c1aff] to [a0d16a03af].
1 | /* | | | | | | > > > > | < > | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFSetItemAttributesFailedException.h" #import "OFIRI.h" #import "OFString.h" @implementation OFSetItemAttributesFailedException @synthesize IRI = _IRI, attributes = _attributes; @synthesize failedAttribute = _failedAttribute, errNo = _errNo; + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } + (instancetype)exceptionWithIRI: (OFIRI *)IRI attributes: (OFFileAttributes)attributes failedAttribute: (OFFileAttributeKey)failedAttribute errNo: (int)errNo { return [[[self alloc] initWithIRI: IRI attributes: attributes failedAttribute: failedAttribute errNo: errNo] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithIRI: (OFIRI *)IRI attributes: (OFFileAttributes)attributes failedAttribute: (OFFileAttributeKey)failedAttribute errNo: (int)errNo { self = [super init]; @try { _IRI = [IRI copy]; _attributes = [attributes copy]; _failedAttribute = [failedAttribute copy]; _errNo = errNo; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_IRI release]; [_attributes release]; [_failedAttribute release]; [super dealloc]; } - (OFString *)description { return [OFString stringWithFormat: @"Failed to set attribute %@ for item %@: %@", _failedAttribute, _IRI, OFStrError(_errNo)]; } @end |
Modified src/exceptions/OFSetOptionFailedException.h from [2fa10041b9] to [870751d1fe].
1 | /* | | | | | | > > > > | < > | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFSetOptionFailedException \ * OFSetOptionFailedException.h ObjFW/OFSetOptionFailedException.h * * @brief An exception indicating that setting an option for an object failed. */ @interface OFSetOptionFailedException: OFException { id _Nullable _object; int _errNo; OF_RESERVE_IVARS(OFSetOptionFailedException, 4) } /** * @brief The object for which the option could not be set. */ @property OF_NULLABLE_PROPERTY (readonly, nonatomic) id object; /** * @brief The errno of the error that occurred. */ @property (readonly, nonatomic) int errNo; /** * @brief Creates a new, autoreleased set option failed exception. * * @param object The object for which the option could not be set * @param errNo The errno of the error that occurred * @return A new, autoreleased set option failed exception */ + (instancetype)exceptionWithObject: (nullable id)object errNo: (int)errNo; + (instancetype)exception OF_UNAVAILABLE; /** * @brief Initializes an already allocated set option failed exception. * * @param object The object for which the option could not be set * @param errNo The errno of the error that occurred * @return An initialized set option failed exception */ - (instancetype)initWithObject: (nullable id)object errNo: (int)errNo OF_DESIGNATED_INITIALIZER; - (instancetype)init OF_UNAVAILABLE; @end OF_ASSUME_NONNULL_END |
Modified src/exceptions/OFSetOptionFailedException.m from [8f19f7dfbc] to [4fb20ff987].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFSetOptionFailedException.h" #import "OFString.h" |
︙ | ︙ | |||
51 52 53 54 55 56 57 | [_object release]; [super dealloc]; } - (OFString *)description { | > | | | > > > | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | [_object release]; [super dealloc]; } - (OFString *)description { if (_object != nil) return [OFString stringWithFormat: @"Setting an option in an object of type %@ failed: %@", [_object class], OFStrError(_errNo)]; else return [OFString stringWithFormat: @"Setting an option failed: %@", OFStrError(_errNo)]; } @end |
Modified src/exceptions/OFSetWindowsRegistryValueFailedException.h from [88eed12b7b] to [6b27112c5f].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" #import "OFWindowsRegistryKey.h" #include <windows.h> |
︙ | ︙ |
Modified src/exceptions/OFSetWindowsRegistryValueFailedException.m from [e6d28eef78] to [f10d7b695a].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFSetWindowsRegistryValueFailedException.h" #import "OFData.h" |
︙ | ︙ |
Modified src/exceptions/OFSignalConditionFailedException.h from [abb9bfa0ca] to [a082522599].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" #ifndef OF_HAVE_THREADS # error No threads available! #endif |
︙ | ︙ |
Modified src/exceptions/OFSignalConditionFailedException.m from [f5f3ff967a] to [bdbca68645].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "OFSignalConditionFailedException.h" |
︙ | ︙ |
Modified src/exceptions/OFStartThreadFailedException.h from [e0e650ae0d] to [1b4246265c].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" #ifndef OF_HAVE_THREADS # error No threads available! #endif |
︙ | ︙ |
Modified src/exceptions/OFStartThreadFailedException.m from [9dcf5912d6] to [1274e3ec22].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "OFStartThreadFailedException.h" |
︙ | ︙ |
Modified src/exceptions/OFStillLockedException.h from [da104224a4] to [903dee91ba].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" #import "OFLocking.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ |
Modified src/exceptions/OFStillLockedException.m from [3bdcf688e2] to [644d58b342].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFStillLockedException.h" #import "OFString.h" |
︙ | ︙ |
Modified src/exceptions/OFTLSHandshakeFailedException.h from [f9e2ae9630] to [6262e58801].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" #ifndef OF_HAVE_SOCKETS # error No sockets available! #endif |
︙ | ︙ |
Modified src/exceptions/OFTLSHandshakeFailedException.m from [9f825e73f8] to [51cb4e9de1].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFTLSHandshakeFailedException.h" #import "OFString.h" |
︙ | ︙ |
Modified src/exceptions/OFThreadStillRunningException.h from [8cadaadd37] to [8dfdd9b1a8].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" #ifndef OF_HAVE_THREADS # error No threads available! #endif |
︙ | ︙ |
Modified src/exceptions/OFThreadStillRunningException.m from [08b6a2fa91] to [f283802a40].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFThreadStillRunningException.h" #import "OFString.h" #import "OFThread.h" |
︙ | ︙ |
Modified src/exceptions/OFTruncatedDataException.h from [c355984cb5] to [c8283b573a].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/exceptions/OFTruncatedDataException.m from [d3465afc55] to [8072299056].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFTruncatedDataException.h" #import "OFString.h" |
︙ | ︙ |
Modified src/exceptions/OFUnboundNamespaceException.h from [782770074b] to [462b49aadb].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN @class OFXMLElement; |
︙ | ︙ |
Modified src/exceptions/OFUnboundNamespaceException.m from [8d26c2cfa6] to [4d9a15431c].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFUnboundNamespaceException.h" #import "OFString.h" #import "OFXMLElement.h" |
︙ | ︙ |
Modified src/exceptions/OFUnboundPrefixException.h from [c1eaadb13e] to [731b4f4217].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN @class OFXMLParser; |
︙ | ︙ |
Modified src/exceptions/OFUnboundPrefixException.m from [09d3302162] to [c8af8e22c8].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFUnboundPrefixException.h" #import "OFString.h" #import "OFXMLParser.h" |
︙ | ︙ |
Modified src/exceptions/OFUndefinedKeyException.h from [1b1bc72e6f] to [fdbbdafcc0].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/exceptions/OFUndefinedKeyException.m from [fa0cc877cd] to [ff83a76dd8].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFUndefinedKeyException.h" #import "OFString.h" |
︙ | ︙ |
Modified src/exceptions/OFUnknownXMLEntityException.h from [effb41465b] to [5a8aee85ce].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/exceptions/OFUnknownXMLEntityException.m from [87056195a2] to [a788184930].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFUnknownXMLEntityException.h" #import "OFString.h" |
︙ | ︙ |
Modified src/exceptions/OFUnlockFailedException.h from [2273de4dc6] to [7a71b7bc5c].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" #import "OFLocking.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ |
Modified src/exceptions/OFUnlockFailedException.m from [68e65cd613] to [3bab1d5b47].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "OFUnlockFailedException.h" |
︙ | ︙ |
Modified src/exceptions/OFUnsupportedProtocolException.h from [229fefef5c] to [5adfc1a786].
1 | /* | | | | | | > > > > | < > | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN @class OFIRI; /** * @class OFUnsupportedProtocolException \ * OFUnsupportedProtocolException.h \ * ObjFW/OFUnsupportedProtocolException.h * * @brief An exception indicating that the protocol specified by the IRI is not * supported. */ @interface OFUnsupportedProtocolException: OFException { OFIRI *_Nullable _IRI; OF_RESERVE_IVARS(OFUnsupportedProtocolException, 4) } /** * @brief The IRI whose protocol is unsupported. */ @property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFIRI *IRI; /** * @brief Creates a new, autoreleased unsupported protocol exception. * * @param IRI The IRI whose protocol is unsupported * @return A new, autoreleased unsupported protocol exception */ + (instancetype)exceptionWithIRI: (nullable OFIRI*)IRI; /** * @brief Initializes an already allocated unsupported protocol exception * * @param IRI The IRI whose protocol is unsupported * @return An initialized unsupported protocol exception */ - (instancetype)initWithIRI: (nullable OFIRI*)IRI OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END |
Modified src/exceptions/OFUnsupportedProtocolException.m from [a391485837] to [15f0462155].
1 | /* | | | | | | > > > > | < > | | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFUnsupportedProtocolException.h" #import "OFIRI.h" #import "OFString.h" @implementation OFUnsupportedProtocolException @synthesize IRI = _IRI; + (instancetype)exceptionWithIRI: (OFIRI *)IRI { return [[[self alloc] initWithIRI: IRI] autorelease]; } - (instancetype)initWithIRI: (OFIRI *)IRI { self = [super init]; _IRI = [IRI retain]; return self; } - (void)dealloc { [_IRI release]; [super dealloc]; } - (OFString *)description { if (_IRI != nil) return [OFString stringWithFormat: @"The protocol of IRI %@ is not supported!", _IRI]; else return @"The requested protocol is unsupported!"; } @end |
Modified src/exceptions/OFUnsupportedVersionException.h from [2da3b1eaf2] to [6d54eb29ac].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/exceptions/OFUnsupportedVersionException.m from [ae8969b353] to [9b50e2d581].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFUnsupportedVersionException.h" #import "OFString.h" |
︙ | ︙ |
Modified src/exceptions/OFWaitForConditionFailedException.h from [a1e587c621] to [e52a7ec3ad].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" #ifndef OF_HAVE_THREADS # error No threads available! #endif |
︙ | ︙ |
Modified src/exceptions/OFWaitForConditionFailedException.m from [e419f3f9dc] to [8431e1c216].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "OFWaitForConditionFailedException.h" |
︙ | ︙ |
Modified src/exceptions/OFWriteFailedException.h from [6dee61073a] to [ed38079529].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFReadOrWriteFailedException.h" OF_ASSUME_NONNULL_BEGIN /** |
︙ | ︙ |
Modified src/exceptions/OFWriteFailedException.m from [1eca55cb4e] to [445aff5c74].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFWriteFailedException.h" #import "OFString.h" |
︙ | ︙ |
Renamed and modified src/forwarding/apple-forwarding-x86_64.S [1324ab08b0] to src/forwarding/apple-forwarding-amd64.S [8c1bdd0d6b].
1 | /* | | | | | | > > > > | < > | > > > > > > | > | | | > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #ifdef HAVE_CET_H # include <cet.h> #else # define _CET_ENDBR #endif .globl _OFForward .globl _OFForward_stret .section __TEXT, __objc_methname, cstring_literals Lstr_forwardingTargetForSelector_: .asciz "forwardingTargetForSelector:" .section __DATA, __objc_selrefs, literal_pointers, no_dead_strip .p2align 3 Lsel_forwardingTargetForSelector_: .quad Lstr_forwardingTargetForSelector_ .section __DATA, __objc_imageinfo, regular, no_dead_strip .long 0, 0x40 .section __TEXT, __text, regular, pure_instructions _OFForward: _CET_ENDBR pushq %rbp movq %rsp, %rbp /* Save all arguments */ subq $0xC0, %rsp /* 16-byte alignment */ movq %rax, -0x8(%rbp) movq %rdi, -0x10(%rbp) |
︙ | ︙ | |||
51 52 53 54 55 56 57 | movaps %xmm5, -0xA0(%rbp) movaps %xmm6, -0xB0(%rbp) movaps %xmm7, -0xC0(%rbp) call _object_getClass movq %rax, %rdi | | | | 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | movaps %xmm5, -0xA0(%rbp) movaps %xmm6, -0xB0(%rbp) movaps %xmm7, -0xC0(%rbp) call _object_getClass movq %rax, %rdi movq Lsel_forwardingTargetForSelector_(%rip), %rsi call _class_respondsToSelector testq %rax, %rax jz 0f movq -0x10(%rbp), %rdi movq Lsel_forwardingTargetForSelector_(%rip), %rsi movq -0x18(%rbp), %rdx call _objc_msgSend testq %rax, %rax jz 0f cmpq -0x10(%rbp), %rax je 0f |
︙ | ︙ | |||
100 101 102 103 104 105 106 107 108 109 110 111 112 113 | movq %rbp, %rsp popq %rbp jmp _OFMethodNotFound _OFForward_stret: pushq %rbp movq %rsp, %rbp /* Save all arguments */ subq $0xC0, %rsp /* 16-byte alignment */ movq %rax, -0x8(%rbp) movq %rdi, -0x10(%rbp) | > > | 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | movq %rbp, %rsp popq %rbp jmp _OFMethodNotFound _OFForward_stret: _CET_ENDBR pushq %rbp movq %rsp, %rbp /* Save all arguments */ subq $0xC0, %rsp /* 16-byte alignment */ movq %rax, -0x8(%rbp) movq %rdi, -0x10(%rbp) |
︙ | ︙ | |||
125 126 127 128 129 130 131 | movaps %xmm6, -0xB0(%rbp) movaps %xmm7, -0xC0(%rbp) movq %rsi, %rdi call _object_getClass movq %rax, %rdi | | | | 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | movaps %xmm6, -0xB0(%rbp) movaps %xmm7, -0xC0(%rbp) movq %rsi, %rdi call _object_getClass movq %rax, %rdi movq Lsel_forwardingTargetForSelector_(%rip), %rsi call _class_respondsToSelector testq %rax, %rax jz 0f movq -0x18(%rbp), %rdi movq Lsel_forwardingTargetForSelector_(%rip), %rsi movq -0x20(%rbp), %rdx call _objc_msgSend testq %rax, %rax jz 0f cmpq -0x18(%rbp), %rax je 0f |
︙ | ︙ |
Modified src/forwarding/apple-forwarding-arm.S from [638359a9cd] to [7c4fc4928f].
1 | /* | | | | | | > > > > | < > | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" .globl _OFForward .globl _OFForward_stret .section __TEXT, __objc_methname, cstring_literals Lstr_forwardingTargetForSelector_: .asciz "forwardingTargetForSelector:" .section __DATA, __objc_selrefs, literal_pointers, no_dead_strip Lsel_forwardingTargetForSelector_: .long str_forwardingTargetForSelector_ .section __DATA, __objc_imageinfo, regular, no_dead_strip .long 0, 0 .section __TEXT, __text, regular, pure_instructions .arm .align 2 _OFForward: stmfd sp!, {r0-r4, lr} vstmdb sp!, {d0-d7} ldr r4, Lsel_forwardingTargetForSelector_$indirect_L0 L0: ldr r4, [pc, r4] blx _object_getClass mov r1, r4 blx _class_respondsToSelector |
︙ | ︙ | |||
67 68 69 70 71 72 73 | 0: vldmia sp!, {d0-d7} ldmfd sp!, {r0-r4, lr} b _OFMethodNotFound .data_region | | | | | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | 0: vldmia sp!, {d0-d7} ldmfd sp!, {r0-r4, lr} b _OFMethodNotFound .data_region Lsel_forwardingTargetForSelector_$indirect_L0: .long Lsel_forwardingTargetForSelector_-(L0+8) .end_data_region .align 2 _OFForward_stret: stmfd sp!, {r0-r4, lr} vstmdb sp!, {d0-d7} ldr r4, Lsel_forwardingTargetForSelector_$indirect_L1 L1: ldr r4, [pc, r4] mov r0, r1 blx _object_getClass mov r1, r4 |
︙ | ︙ | |||
115 116 117 118 119 120 121 | 0: vldmia sp!, {d0-d7} ldmfd sp!, {r0-r4, lr} b _OFMethodNotFound_stret .data_region | | | | 119 120 121 122 123 124 125 126 127 128 | 0: vldmia sp!, {d0-d7} ldmfd sp!, {r0-r4, lr} b _OFMethodNotFound_stret .data_region Lsel_forwardingTargetForSelector_$indirect_L1: .long Lsel_forwardingTargetForSelector_-(L1+8) .end_data_region |
Modified src/forwarding/apple-forwarding-arm64.S from [d2adf305f5] to [35dbd1e27e].
1 | /* | | | | | | > > > > | < > | | > | | | > > > > | < | | | | | | | | | | | | | | | | | | | | | | < | < | | < | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" .globl _OFForward .globl _OFForward_stret .section __TEXT, __objc_methname, cstring_literals Lstr_forwardingTargetForSelector_: .asciz "forwardingTargetForSelector:" .section __DATA, __objc_selrefs, literal_pointers, no_dead_strip .p2align 3 Lsel_forwardingTargetForSelector_: .quad Lstr_forwardingTargetForSelector_ .section __DATA, __objc_imageinfo, regular, no_dead_strip .long 0, 0x40 .section __TEXT, __text, regular, pure_instructions .align 2 _OFForward: _OFForward_stret: #ifdef HAVE_BTI bti c #endif stp fp, lr, [sp, #-224]! mov fp, sp /* Save all arguments, x8 and x19 */ stp x0, x1, [sp, #16] stp x2, x3, [sp, #32] stp x4, x5, [sp, #48] stp x6, x7, [sp, #64] stp x8, x19, [sp, #80] /* Save all foating point arguments */ stp q0, q1, [sp, #96] stp q2, q3, [sp, #128] stp q4, q5, [sp, #160] stp q6, q7, [sp, #192] bl _object_getClass adrp x19, Lsel_forwardingTargetForSelector_@PAGE add x19, x19, Lsel_forwardingTargetForSelector_@PAGEOFF ldr x19, [x19] mov x1, x19 bl _class_respondsToSelector cbz x0, 0f ldp x0, x2, [sp, #16] mov x1, x19 bl _objc_msgSend cbz x0, 0f ldr x1, [sp, #16] cmp x0, x1 b.eq 0f /* Restore all arguments, x8 and x19, but not x0 */ ldr x1, [sp, #24] ldp x2, x3, [sp, #32] ldp x4, x5, [sp, #48] ldp x6, x7, [sp, #64] ldp x8, x19, [sp, #80] /* Restore all foating point arguments */ ldp q0, q1, [sp, #96] ldp q2, q3, [sp, #128] ldp q4, q5, [sp, #160] ldp q6, q7, [sp, #192] ldp fp, lr, [sp], #224 b _objc_msgSend 0: ldp x0, x1, [sp, #16] ldr x19, [sp, #88] ldp fp, lr, [sp], #224 b _OFMethodNotFound |
Modified src/forwarding/apple-forwarding-powerpc.S from [8f7b914664] to [7deaa2c59b].
1 | /* | | | | | | > > > > | < > | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" .globl _OFForward .globl _OFForward_stret .section __TEXT, __cstring, cstring_literals Lstr_forwardingTargetForSelector_: .asciz "forwardingTargetForSelector:" .section __OBJC, __message_refs Lsel_forwardingTargetForSelector_: .long Lstr_forwardingTargetForSelector_ .section __OBJC, __image_info .long 0, 0 .section __TEXT, __text, regular, pure_instructions _OFForward: mflr r0 |
︙ | ︙ | |||
67 68 69 70 71 72 73 | stfd f13, 184(r1) bl _object_getClass bl 0f 0: mflr r13 | | | | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | stfd f13, 184(r1) bl _object_getClass bl 0f 0: mflr r13 addis r13, r13, ha16(Lsel_forwardingTargetForSelector_-0b) lwz r13, lo16(Lsel_forwardingTargetForSelector_-0b)(r13) mr r4, r13 bl _class_respondsToSelector cmpwi r3, 0 beq- 0f |
︙ | ︙ | |||
170 171 172 173 174 175 176 | mr r3, r4 bl _object_getClass bl 0f 0: mflr r13 | | | | 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | mr r3, r4 bl _object_getClass bl 0f 0: mflr r13 addis r13, r13, ha16(Lsel_forwardingTargetForSelector_-0b) lwz r13, lo16(Lsel_forwardingTargetForSelector_-0b)(r13) mr r4, r13 bl _class_respondsToSelector cmpwi r3, 0 beq- 0f |
︙ | ︙ |
Renamed and modified src/forwarding/apple-forwarding-i386.S [11f716a457] to src/forwarding/apple-forwarding-x86.S [6e736e22a0].
1 | /* | | | | | | > > > > | < > | > > > > > > | | | > > | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #ifdef HAVE_CET_H # include <cet.h> #else # define _CET_ENDBR #endif .globl _OFForward .globl _OFForward_stret .section __TEXT, __cstring, cstring_literals Lstr_forwardingTargetForSelector_: .asciz "forwardingTargetForSelector:" .section __OBJC, __message_refs, literal_pointers, no_dead_strip Lsel_forwardingTargetForSelector_: .long Lstr_forwardingTargetForSelector_ .section __OBJC, __image_info .long 0, 0 .section __TEXT, __text, regular, pure_instructions _OFForward: _CET_ENDBR pushl %ebp movl %esp, %ebp pushl %ebx subl $20, %esp call LgetEIP 0: movl 8(%ebp), %eax movl %eax, (%esp) call _object_getClass movl %eax, (%esp) movl Lsel_forwardingTargetForSelector_-0b(%ebx), %eax movl %eax, 4(%esp) call _class_respondsToSelector testl %eax, %eax jz 0f movl 8(%ebp), %eax movl %eax, (%esp) movl Lsel_forwardingTargetForSelector_-0b(%ebx), %eax movl %eax, 4(%esp) movl 12(%ebp), %eax movl %eax, 8(%esp) call _objc_msgSend testl %eax, %eax jz 0f |
︙ | ︙ | |||
77 78 79 80 81 82 83 84 85 86 87 88 89 | addl $20, %esp popl %ebx popl %ebp jmp _OFMethodNotFound _OFForward_stret: pushl %ebp movl %esp, %ebp pushl %ebx subl $20, %esp | > > | | | | 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | addl $20, %esp popl %ebx popl %ebp jmp _OFMethodNotFound _OFForward_stret: _CET_ENDBR pushl %ebp movl %esp, %ebp pushl %ebx subl $20, %esp call LgetEIP 0: movl 12(%ebp), %eax movl %eax, (%esp) call _object_getClass movl %eax, (%esp) movl Lsel_forwardingTargetForSelector_-0b(%ebx), %eax movl %eax, 4(%esp) call _class_respondsToSelector testl %eax, %eax jz 0f movl 12(%ebp), %eax movl %eax, (%esp) movl Lsel_forwardingTargetForSelector_-0b(%ebx), %eax movl %eax, 4(%esp) movl 16(%ebp), %eax movl %eax, 8(%esp) call _objc_msgSend testl %eax, %eax jz 0f |
︙ | ︙ | |||
126 127 128 129 130 131 132 | 0: addl $20, %esp popl %ebx popl %ebp jmp _OFMethodNotFound_stret | | | 140 141 142 143 144 145 146 147 148 149 | 0: addl $20, %esp popl %ebx popl %ebp jmp _OFMethodNotFound_stret LgetEIP: movl (%esp), %ebx ret |
Renamed and modified src/forwarding/forwarding-x86_64-elf.S [9ea0cb41b3] to src/forwarding/forwarding-amd64-elf.S [00eff4acff].
1 | /* | | | | | | > > > > | < > | > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include "platform.h" #ifdef HAVE_CET_H # include <cet.h> #else # define _CET_ENDBR #endif .globl OFForward .globl OFForward_stret .section .text OFForward: _CET_ENDBR pushq %rbp movq %rsp, %rbp /* Save all arguments */ subq $0xC0, %rsp /* 16-byte alignment */ movq %rax, -0x8(%rbp) movq %rdi, -0x10(%rbp) |
︙ | ︙ | |||
42 43 44 45 46 47 48 | movaps %xmm5, -0xA0(%rbp) movaps %xmm6, -0xB0(%rbp) movaps %xmm7, -0xC0(%rbp) call object_getClass@PLT movq %rax, %rdi | | | | | 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | movaps %xmm5, -0xA0(%rbp) movaps %xmm6, -0xB0(%rbp) movaps %xmm7, -0xC0(%rbp) call object_getClass@PLT movq %rax, %rdi leaq .Lsel_forwardingTargetForSelector_(%rip), %rsi call class_respondsToSelector@PLT testq %rax, %rax jz 0f movq -0x10(%rbp), %rdi leaq .Lsel_forwardingTargetForSelector_(%rip), %rsi call objc_msg_lookup@PLT movq -0x10(%rbp), %rdi leaq .Lsel_forwardingTargetForSelector_(%rip), %rsi movq -0x18(%rbp), %rdx call *%rax testq %rax, %rax jz 0f cmpq -0x10(%rbp), %rax je 0f |
︙ | ︙ | |||
103 104 105 106 107 108 109 110 111 112 113 114 115 116 | popq %rbp jmp OFMethodNotFound@PLT .type OFForward, %function .size OFForward, .-OFForward OFForward_stret: pushq %rbp movq %rsp, %rbp /* Save all arguments */ subq $0xC0, %rsp /* 16-byte alignment */ movq %rax, -0x8(%rbp) movq %rdi, -0x10(%rbp) | > > | 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | popq %rbp jmp OFMethodNotFound@PLT .type OFForward, %function .size OFForward, .-OFForward OFForward_stret: _CET_ENDBR pushq %rbp movq %rsp, %rbp /* Save all arguments */ subq $0xC0, %rsp /* 16-byte alignment */ movq %rax, -0x8(%rbp) movq %rdi, -0x10(%rbp) |
︙ | ︙ | |||
128 129 130 131 132 133 134 | movaps %xmm6, -0xB0(%rbp) movaps %xmm7, -0xC0(%rbp) movq %rsi, %rdi call object_getClass@PLT movq %rax, %rdi | | | | | 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | movaps %xmm6, -0xB0(%rbp) movaps %xmm7, -0xC0(%rbp) movq %rsi, %rdi call object_getClass@PLT movq %rax, %rdi leaq .Lsel_forwardingTargetForSelector_(%rip), %rsi call class_respondsToSelector@PLT testq %rax, %rax jz 0f movq -0x18(%rbp), %rdi leaq .Lsel_forwardingTargetForSelector_(%rip), %rsi call objc_msg_lookup@PLT movq -0x18(%rbp), %rdi leaq .Lsel_forwardingTargetForSelector_(%rip), %rsi movq -0x20(%rbp), %rdx call *%rax testq %rax, %rax jz 0f cmpq -0x18(%rbp), %rax je 0f |
︙ | ︙ | |||
189 190 191 192 193 194 195 | movq %rbp, %rsp popq %rbp jmp OFMethodNotFound_stret@PLT .type OFForward_stret, %function .size OFForward_stret, .-OFForward_stret | | > > | | | | | | | | | | | 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | movq %rbp, %rsp popq %rbp jmp OFMethodNotFound_stret@PLT .type OFForward_stret, %function .size OFForward_stret, .-OFForward_stret .Linit: _CET_ENDBR leaq .Lmodule(%rip), %rdi jmp __objc_exec_class@PLT #ifdef OF_SOLARIS .section .init_array, "aw" #else .section .ctors, "aw", %progbits #endif .quad .Linit .section .rodata .Lstr_forwardingTargetForSelector_: .asciz "forwardingTargetForSelector:" .section .data .Lsel_forwardingTargetForSelector_: .quad .Lstr_forwardingTargetForSelector_, 0 .quad 0, 0 .Lsymtab: .quad 0, .Lsel_forwardingTargetForSelector_ .short 0, 0 .long 0 .quad 0 .Lmodule: .quad 8, 32, 0, .Lsymtab #if defined(OF_LINUX) || defined(OF_HAIKU) || defined(OF_HURD) .section .note.GNU-stack, "", %progbits #endif |
Renamed and modified src/forwarding/forwarding-x86_64-macho.S [0e975fcfd2] to src/forwarding/forwarding-amd64-macho.S [21288ad673].
1 | /* | | | | | | > > > > | < > | > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include "platform.h" #ifdef HAVE_CET_H # include <cet.h> #else # define _CET_ENDBR #endif .globl _OFForward .globl _OFForward_stret .section __TEXT, __text, regular, pure_instructions _OFForward: _CET_ENDBR pushq %rbp movq %rsp, %rbp /* Save all arguments */ subq $0xC0, %rsp /* 16-byte alignment */ movq %rax, -0x8(%rbp) movq %rdi, -0x10(%rbp) |
︙ | ︙ | |||
42 43 44 45 46 47 48 | movaps %xmm5, -0xA0(%rbp) movaps %xmm6, -0xB0(%rbp) movaps %xmm7, -0xC0(%rbp) call _object_getClass movq %rax, %rdi | | | | | 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | movaps %xmm5, -0xA0(%rbp) movaps %xmm6, -0xB0(%rbp) movaps %xmm7, -0xC0(%rbp) call _object_getClass movq %rax, %rdi leaq Lsel_forwardingTargetForSelector_(%rip), %rsi call _class_respondsToSelector testq %rax, %rax jz 0f movq -0x10(%rbp), %rdi leaq Lsel_forwardingTargetForSelector_(%rip), %rsi call _objc_msg_lookup movq -0x10(%rbp), %rdi leaq Lsel_forwardingTargetForSelector_(%rip), %rsi movq -0x18(%rbp), %rdx call *%rax testq %rax, %rax jz 0f cmpq -0x10(%rbp), %rax je 0f |
︙ | ︙ | |||
101 102 103 104 105 106 107 108 109 110 111 112 113 114 | movq %rbp, %rsp popq %rbp jmp _OFMethodNotFound _OFForward_stret: pushq %rbp movq %rsp, %rbp /* Save all arguments */ subq $0xC0, %rsp /* 16-byte alignment */ movq %rax, -0x8(%rbp) movq %rdi, -0x10(%rbp) | > > | 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | movq %rbp, %rsp popq %rbp jmp _OFMethodNotFound _OFForward_stret: _CET_ENDBR pushq %rbp movq %rsp, %rbp /* Save all arguments */ subq $0xC0, %rsp /* 16-byte alignment */ movq %rax, -0x8(%rbp) movq %rdi, -0x10(%rbp) |
︙ | ︙ | |||
126 127 128 129 130 131 132 | movaps %xmm6, -0xB0(%rbp) movaps %xmm7, -0xC0(%rbp) movq %rsi, %rdi call _object_getClass movq %rax, %rdi | | | | | 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | movaps %xmm6, -0xB0(%rbp) movaps %xmm7, -0xC0(%rbp) movq %rsi, %rdi call _object_getClass movq %rax, %rdi leaq Lsel_forwardingTargetForSelector_(%rip), %rsi call _class_respondsToSelector testq %rax, %rax jz 0f movq -0x18(%rbp), %rdi leaq Lsel_forwardingTargetForSelector_(%rip), %rsi call _objc_msg_lookup movq -0x18(%rbp), %rdi leaq Lsel_forwardingTargetForSelector_(%rip), %rsi movq -0x20(%rbp), %rdx call *%rax testq %rax, %rax jz 0f cmpq -0x18(%rbp), %rax je 0f |
︙ | ︙ | |||
185 186 187 188 189 190 191 | movq -0x20(%rbp), %rdx movq %rbp, %rsp popq %rbp jmp _OFMethodNotFound_stret | | > > | | | | | | | | | | 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | movq -0x20(%rbp), %rdx movq %rbp, %rsp popq %rbp jmp _OFMethodNotFound_stret Linit: _CET_ENDBR leaq Lmodule(%rip), %rdi jmp ___objc_exec_class .section __DATA, __mod_init_func, mod_init_funcs .quad Linit .section __TEXT, __cstring, cstring_literals Lstr_forwardingTargetForSelector_: .asciz "forwardingTargetForSelector:" .section __DATA, __data Lsel_forwardingTargetForSelector_: .quad Lstr_forwardingTargetForSelector_, 0 .quad 0, 0 Lsymtab: .quad 0, Lsel_forwardingTargetForSelector_ .short 0, 0 .long 0 .quad 0 Lmodule: .quad 8, 32, 0, Lsymtab |
Renamed and modified src/forwarding/forwarding-x86_64-win64.S [74c1db404c] to src/forwarding/forwarding-amd64-win64.S [09ac17f8c9].
1 | /* | | | | | | > > > > | < > | > > > > > > > > | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #ifdef HAVE_CET_H # include <cet.h> #else # define _CET_ENDBR #endif .globl OFForward .globl OFForward_stret .section .text OFForward: _CET_ENDBR pushq %rbp movq %rsp, %rbp /* Save all arguments */ subq $0x90, %rsp /* 16-byte alignment */ movq %rax, -0x28(%rbp) movq %rcx, -0x30(%rbp) movq %rdx, -0x38(%rbp) movq %r8, -0x40(%rbp) movq %r9, -0x48(%rbp) movaps %xmm0, -0x60(%rbp) movaps %xmm1, -0x70(%rbp) movaps %xmm2, -0x80(%rbp) movaps %xmm3, -0x90(%rbp) call object_getClass movq %rax, %rcx leaq .Lsel_forwardingTargetForSelector_(%rip), %rdx call class_respondsToSelector testq %rax, %rax jz 0f movq -0x30(%rbp), %rcx leaq .Lsel_forwardingTargetForSelector_(%rip), %rdx call objc_msg_lookup movq -0x30(%rbp), %rcx leaq .Lsel_forwardingTargetForSelector_(%rip), %rdx movq -0x38(%rbp), %r8 call *%rax testq %rax, %rax jz 0f cmpq -0x30(%rbp), %rax je 0f |
︙ | ︙ | |||
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | jmp OFMethodNotFound .def OFForward .scl 2 .type 32 .endef OFForward_stret: pushq %rbp movq %rsp, %rbp /* Save all arguments */ subq $0x90, %rsp /* 16-byte alignment */ movq %rax, -0x28(%rbp) movq %rcx, -0x30(%rbp) movq %rdx, -0x38(%rbp) movq %r8, -0x40(%rbp) movq %r9, -0x48(%rbp) movaps %xmm0, -0x60(%rbp) movaps %xmm1, -0x70(%rbp) movaps %xmm2, -0x80(%rbp) movaps %xmm3, -0x90(%rbp) movq %rdx, %rcx call object_getClass movq %rax, %rcx | > > | | | | 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | jmp OFMethodNotFound .def OFForward .scl 2 .type 32 .endef OFForward_stret: _CET_ENDBR pushq %rbp movq %rsp, %rbp /* Save all arguments */ subq $0x90, %rsp /* 16-byte alignment */ movq %rax, -0x28(%rbp) movq %rcx, -0x30(%rbp) movq %rdx, -0x38(%rbp) movq %r8, -0x40(%rbp) movq %r9, -0x48(%rbp) movaps %xmm0, -0x60(%rbp) movaps %xmm1, -0x70(%rbp) movaps %xmm2, -0x80(%rbp) movaps %xmm3, -0x90(%rbp) movq %rdx, %rcx call object_getClass movq %rax, %rcx leaq .Lsel_forwardingTargetForSelector_(%rip), %rdx call class_respondsToSelector testq %rax, %rax jz 0f movq -0x38(%rbp), %rcx leaq .Lsel_forwardingTargetForSelector_(%rip), %rdx call objc_msg_lookup movq -0x38(%rbp), %rcx leaq .Lsel_forwardingTargetForSelector_(%rip), %rdx movq -0x40(%rbp), %r8 call *%rax testq %rax, %rax jz 0f cmpq -0x38(%rbp), %rax je 0f |
︙ | ︙ | |||
167 168 169 170 171 172 173 | jmp OFMethodNotFound_stret .def OFForward_stret .scl 2 .type 32 .endef | | > > | | | | | | | | | | 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | jmp OFMethodNotFound_stret .def OFForward_stret .scl 2 .type 32 .endef .Linit: _CET_ENDBR leaq .Lmodule(%rip), %rcx jmp __objc_exec_class .section .ctors, "aw" .quad .Linit .section .rodata .Lstr_forwardingTargetForSelector_: .asciz "forwardingTargetForSelector:" .section .data .Lsel_forwardingTargetForSelector_: .quad .Lstr_forwardingTargetForSelector_, 0 .quad 0, 0 .Lsymtab: .long 0, 0 .quad .Lsel_forwardingTargetForSelector_ .short 0, 0 .long 0 .quad 0 .Lmodule: .long 8, 32 .quad 0, .Lsymtab |
Modified src/forwarding/forwarding-arm-elf.S from [ebb3f926fa] to [6672c7d1bd].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include "platform.h" #ifdef HAVE_VFP2 .fpu vfp #endif .globl OFForward .globl OFForward_stret .section .text OFForward: #ifdef HAVE_VFP2 vstmdb sp!, {d0-d7} #endif stmfd sp!, {r0-r4, lr} ldr r4, .Lsel_forwardingTargetForSelector_$indirect_.L0 .L0: add r4, pc bl object_getClass(PLT) mov r1, r4 bl class_respondsToSelector(PLT) |
︙ | ︙ | |||
82 83 84 85 86 87 88 | OFForward_stret: #ifdef HAVE_VFP2 vstmdb sp!, {d0-d7} #endif stmfd sp!, {r0-r4, lr} | | | 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | OFForward_stret: #ifdef HAVE_VFP2 vstmdb sp!, {d0-d7} #endif stmfd sp!, {r0-r4, lr} ldr r4, .Lsel_forwardingTargetForSelector_$indirect_.L1 .L1: add r4, pc mov r0, r1 bl object_getClass(PLT) mov r1, r4 |
︙ | ︙ | |||
132 133 134 135 136 137 138 | #ifdef HAVE_VFP2 vldmia sp!, {d0-d7} #endif b OFMethodNotFound_stret(PLT) .type OFForward_stret, %function .size OFForward_stret, .-OFForward_stret | | | | | | | | | | | | | | | | | | | 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | #ifdef HAVE_VFP2 vldmia sp!, {d0-d7} #endif b OFMethodNotFound_stret(PLT) .type OFForward_stret, %function .size OFForward_stret, .-OFForward_stret .Linit: ldr r0, .Lmodule$indirect_.L2 .L2: add r0, pc b __objc_exec_class(PLT) .Lsel_forwardingTargetForSelector_$indirect_.L0: .long .Lsel_forwardingTargetForSelector_-(.L0+8) .Lsel_forwardingTargetForSelector_$indirect_.L1: .long .Lsel_forwardingTargetForSelector_-(.L1+8) .Lmodule$indirect_.L2: .long .Lmodule-(.L2+8) .section .init_array, "aw", %init_array .long .Linit .section .rodata .Lstr_forwardingTargetForSelector_: .asciz "forwardingTargetForSelector:" .section .data .Lsel_forwardingTargetForSelector_: .long .Lstr_forwardingTargetForSelector_, 0 .long 0, 0 .Lsymtab: .long 0, .Lsel_forwardingTargetForSelector_ .short 0, 0 .long 0 .long 0 .Lmodule: .long 8, 16, 0, .Lsymtab #if defined(OF_LINUX) || defined(OF_HAIKU) || defined(OF_HURD) .section .note.GNU-stack, "", %progbits #endif |
Modified src/forwarding/forwarding-arm64-elf.S from [81775de57c] to [8e71cd30e4].
1 | /* | | | | | | > > > > | < > | > > > > | < | | | | | | | | | | | | | | | | | | | | | | | | < | < | | < | < | > > > > | | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include "platform.h" .globl OFForward .globl OFForward_stret .section .text OFForward: OFForward_stret: #ifdef HAVE_BTI bti c #endif stp fp, lr, [sp, #-224]! mov fp, sp /* Save all arguments, x8 and x19 */ stp x0, x1, [sp, #16] stp x2, x3, [sp, #32] stp x4, x5, [sp, #48] stp x6, x7, [sp, #64] stp x8, x19, [sp, #80] /* Save all foating point arguments */ stp q0, q1, [sp, #96] stp q2, q3, [sp, #128] stp q4, q5, [sp, #160] stp q6, q7, [sp, #192] bl object_getClass adrp x19, .Lsel_forwardingTargetForSelector_ add x19, x19, :lo12:.Lsel_forwardingTargetForSelector_ mov x1, x19 bl class_respondsToSelector cbz x0, 0f ldr x0, [sp, #16] mov x1, x19 bl objc_msg_lookup mov x1, x19 mov x19, x0 ldp x0, x2, [sp, #16] blr x19 cbz x0, 0f ldr x1, [sp, #16] cmp x0, x1 b.eq 0f mov x19, x0 ldr x1, [sp, #24] bl objc_msg_lookup mov x16, x0 mov x0, x19 /* Restore all arguments, x8 and x19, but not x0 */ ldr x1, [sp, #24] ldp x2, x3, [sp, #32] ldp x4, x5, [sp, #48] ldp x6, x7, [sp, #64] ldp x8, x19, [sp, #80] /* Restore all foating point arguments */ ldp q0, q1, [sp, #96] ldp q2, q3, [sp, #128] ldp q4, q5, [sp, #160] ldp q6, q7, [sp, #192] ldp fp, lr, [sp], #224 br x16 0: ldp x0, x1, [sp, #16] ldr x19, [sp, #88] ldp fp, lr, [sp], #224 b OFMethodNotFound .type OFForward, %function .size OFForward, .-OFForward .type OFForward_stret, %function .size OFForward_stret, .-OFForward_stret .Linit: #ifdef HAVE_BTI bti c #endif adrp x0, .Lmodule add x0, x0, :lo12:.Lmodule b __objc_exec_class .section .init_array, "aw", %init_array .xword .Linit .section .rodata .Lstr_forwardingTargetForSelector_: .asciz "forwardingTargetForSelector:" .section .data .Lsel_forwardingTargetForSelector_: .xword .Lstr_forwardingTargetForSelector_, 0 .xword 0, 0 .Lsymtab: .xword 0, .Lsel_forwardingTargetForSelector_ .short 0, 0 .long 4 .xword 0 .Lmodule: .xword 8, 32, 0, .Lsymtab #if defined(OF_LINUX) || defined(OF_HAIKU) || defined(OF_HURD) .section .note.GNU-stack, "", %progbits #endif |
Modified src/forwarding/forwarding-mips-elf.S from [e03d5d5039] to [e0859d6585].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include "platform.h" .globl OFForward |
︙ | ︙ | |||
78 79 80 81 82 83 84 | swc1 $f17, 80($sp) swc1 $f18, 84($sp) swc1 $f19, 88($sp) #endif move $s0, $gp #ifdef OF_PIC | | | | | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | swc1 $f17, 80($sp) swc1 $f18, 84($sp) swc1 $f19, 88($sp) #endif move $s0, $gp #ifdef OF_PIC lw $s1, %got(.Lsel_forwardingTargetForSelector_)($gp) #else lui $s1, %hi(.Lsel_forwardingTargetForSelector_) #endif addiu $s1, $s1, %lo(.Lsel_forwardingTargetForSelector_) jal_pic object_getClass move $gp, $s0 move $a0, $v0 move $a1, $s1 jal_pic class_respondsToSelector |
︙ | ︙ | |||
202 203 204 205 206 207 208 | swc1 $f17, 80($sp) swc1 $f18, 84($sp) swc1 $f19, 88($sp) #endif move $s0, $gp #ifdef OF_PIC | | | | | 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | swc1 $f17, 80($sp) swc1 $f18, 84($sp) swc1 $f19, 88($sp) #endif move $s0, $gp #ifdef OF_PIC lw $s1, %got(.Lsel_forwardingTargetForSelector_)($gp) #else lui $s1, %hi(.Lsel_forwardingTargetForSelector_) #endif addiu $s1, $s1, %lo(.Lsel_forwardingTargetForSelector_) move $a0, $a1 jal_pic object_getClass move $gp, $s0 move $a0, $v0 move $a1, $s1 |
︙ | ︙ | |||
285 286 287 288 289 290 291 | addiu $sp, $sp, 96 j_pic of_method_not_found_stret .type OFForward_stret, %function .size OFForward_stret, .-OFForward_stret | | | | | | | | | | | | | | | | 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | addiu $sp, $sp, 96 j_pic of_method_not_found_stret .type OFForward_stret, %function .size OFForward_stret, .-OFForward_stret .Linit: #ifdef OF_PIC lui $gp, %hi(_gp_disp) addiu $gp, $gp, %lo(_gp_disp) addu $gp, $gp, $t9 lw $a0, %got(.Lmodule)($gp) addiu $a0, $a0, %lo(.Lmodule) lw $t9, %call16(__objc_exec_class)($gp) jr $t9 #else lui $a0, %hi(.Lmodule) addiu $a0, $a0, %lo(.Lmodule) j __objc_exec_class #endif .section .ctors, "aw", %progbits .long .Linit .section .rodata .Lstr_forwardingTargetForSelector_: .asciz "forwardingTargetForSelector:" .section .data .Lsel_forwardingTargetForSelector_: .long .Lstr_forwardingTargetForSelector_, 0 .long 0, 0 .Lsymtab: .long 0, .Lsel_forwardingTargetForSelector_ .short 0, 0 .long 0 .long 0 .Lmodule: .long 8, 16, 0, .Lsymtab #if defined(OF_LINUX) || defined(OF_HAIKU) || defined(OF_HURD) .section .note.GNU-stack, "", %progbits #endif |
Modified src/forwarding/forwarding-powerpc-elf.S from [65258e67de] to [31f5128de3].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include "platform.h" .globl OFForward |
︙ | ︙ | |||
59 60 61 62 63 64 65 | bl object_getClass+0x8000@plt lwz %r4, .Lgot_sel_forwardingTargetForSelector_-.Lbiased_got2(%r30) bl class_respondsToSelector+0x8000@plt #else bl object_getClass | | | | | | | | 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | bl object_getClass+0x8000@plt lwz %r4, .Lgot_sel_forwardingTargetForSelector_-.Lbiased_got2(%r30) bl class_respondsToSelector+0x8000@plt #else bl object_getClass lis %r4, .Lsel_forwardingTargetForSelector_@ha la %r4, .Lsel_forwardingTargetForSelector_@l(%r4) bl class_respondsToSelector #endif cmpwi %r3, 0 beq- 0f lwz %r3, 8(%r1) #ifdef OF_PIC lwz %r4, .Lgot_sel_forwardingTargetForSelector_-.Lbiased_got2(%r30) bl objc_msg_lookup+0x8000@plt #else lis %r4, .Lsel_forwardingTargetForSelector_@ha la %r4, .Lsel_forwardingTargetForSelector_@l(%r4) bl objc_msg_lookup #endif mtctr %r3 lwz %r3, 8(%r1) #ifdef OF_PIC lwz %r4, .Lgot_sel_forwardingTargetForSelector_-.Lbiased_got2(%r30) #else lis %r4, .Lsel_forwardingTargetForSelector_@ha la %r4, .Lsel_forwardingTargetForSelector_@l(%r4) #endif lwz %r5, 12(%r1) bctrl cmpwi %r3, 0 beq- 0f lwz %r4, 8(%r1) |
︙ | ︙ | |||
197 198 199 200 201 202 203 | bl object_getClass+0x8000@plt lwz %r4, .Lgot_sel_forwardingTargetForSelector_-.Lbiased_got2(%r30) bl class_respondsToSelector+0x8000@plt #else bl object_getClass | | | | | | | | 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | bl object_getClass+0x8000@plt lwz %r4, .Lgot_sel_forwardingTargetForSelector_-.Lbiased_got2(%r30) bl class_respondsToSelector+0x8000@plt #else bl object_getClass lis %r4, .Lsel_forwardingTargetForSelector_@ha la %r4, .Lsel_forwardingTargetForSelector_@l(%r4) bl class_respondsToSelector #endif cmpwi %r3, 0 beq- 0f lwz %r3, 12(%r1) #ifdef OF_PIC lwz %r4, .Lgot_sel_forwardingTargetForSelector_-.Lbiased_got2(%r30) bl objc_msg_lookup+0x8000@plt #else lis %r4, .Lsel_forwardingTargetForSelector_@ha la %r4, .Lsel_forwardingTargetForSelector_@l(%r4) bl objc_msg_lookup #endif mtctr %r3 lwz %r3, 12(%r1) #ifdef OF_PIC lwz %r4, .Lgot_sel_forwardingTargetForSelector_-.Lbiased_got2(%r30) #else lis %r4, .Lsel_forwardingTargetForSelector_@ha la %r4, .Lsel_forwardingTargetForSelector_@l(%r4) #endif lwz %r5, 16(%r1) bctrl cmpwi %r3, 0 beq- 0f lwz %r4, 12(%r1) |
︙ | ︙ | |||
293 294 295 296 297 298 299 | bctr #else b OFMethodNotFound_stret #endif .type OFForward_stret, @function .size OFForward_stret, .-OFForward_stret | | | | | | | | | | | | | | | | 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 | bctr #else b OFMethodNotFound_stret #endif .type OFForward_stret, @function .size OFForward_stret, .-OFForward_stret .Linit: stwu %r1, -16(%r1) mflr %r0 stw %r0, 20(%r1) #ifdef OF_PIC stw %r30, 8(%r1) bl 0f 0: mflr %r30 addis %r30, %r30, .Lbiased_got2-0b@ha addi %r30, %r30, .Lbiased_got2-0b@l lwz %r3, .Lgot_module-.Lbiased_got2(%r30) bl __objc_exec_class+0x8000@plt lwz %r30, 8(%r1) #else lis %r3, .Lmodule@ha la %r3, .Lmodule@l(%r3) bl __objc_exec_class #endif lwz %r0, 20(%r1) addi %r1, %r1, 16 mtlr %r0 blr .section .ctors, "aw", @progbits .long .Linit .section .rodata .Lstr_forwardingTargetForSelector_: .asciz "forwardingTargetForSelector:" .section .data .Lsel_forwardingTargetForSelector_: .long .Lstr_forwardingTargetForSelector_, 0 .long 0, 0 .Lsymtab: .long 0, .Lsel_forwardingTargetForSelector_ .short 0, 0 .long 0 .long 0 .Lmodule: .long 8, 16, 0, .Lsymtab #ifdef OF_PIC .section .got2, "aw" .Lbiased_got2 = .+0x8000 .Lgot_module: .long .Lmodule .Lgot_sel_forwardingTargetForSelector_: .long .Lsel_forwardingTargetForSelector_ .Lgot_OFMethodNotFound: .long OFMethodNotFound .Lgot_OFMethodNotFound_stret: .long OFMethodNotFound_stret #endif #if defined(OF_LINUX) || defined(OF_HAIKU) || defined(OF_HURD) .section .note.GNU-stack, "", @progbits #endif |
Modified src/forwarding/forwarding-sparc-elf.S from [8ec3e64b89] to [a177e8a435].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include "platform.h" .globl OFForward |
︙ | ︙ | |||
30 31 32 33 34 35 36 | add %l7, %lo(_GLOBAL_OFFSET_TABLE_ + 4), %l7 #endif mov %i0, %o0 call object_getClass nop | | | | | | | | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | add %l7, %lo(_GLOBAL_OFFSET_TABLE_ + 4), %l7 #endif mov %i0, %o0 call object_getClass nop sethi %hi(.Lsel_forwardingTargetForSelector_), %o1 or %o1, %lo(.Lsel_forwardingTargetForSelector_), %o1 #ifdef OF_PIC ld [%l7 + %o1], %o1 #endif call class_respondsToSelector nop cmp %o0, 0 be 0f mov %i0, %o0 sethi %hi(.Lsel_forwardingTargetForSelector_), %o1 or %o1, %lo(.Lsel_forwardingTargetForSelector_), %o1 #ifdef OF_PIC ld [%l7 + %o1], %o1 #endif call objc_msg_lookup nop mov %o0, %l0 mov %i0, %o0 sethi %hi(.Lsel_forwardingTargetForSelector_), %o1 or %o1, %lo(.Lsel_forwardingTargetForSelector_), %o1 #ifdef OF_PIC ld [%l7 + %o1], %o1 #endif jmpl %l0, %o7 mov %i1, %o2 cmp %o0, 0 |
︙ | ︙ | |||
91 92 93 94 95 96 97 | add %l7, %lo(_GLOBAL_OFFSET_TABLE_ + 4), %l7 #endif mov %i1, %o0 call object_getClass nop | | | | | | | | 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | add %l7, %lo(_GLOBAL_OFFSET_TABLE_ + 4), %l7 #endif mov %i1, %o0 call object_getClass nop sethi %hi(.Lsel_forwardingTargetForSelector_), %o1 or %o1, %lo(.Lsel_forwardingTargetForSelector_), %o1 #ifdef OF_PIC ld [%l7 + %o1], %o1 #endif call class_respondsToSelector nop cmp %o0, 0 be 0f mov %i1, %o0 sethi %hi(.Lsel_forwardingTargetForSelector_), %o1 or %o1, %lo(.Lsel_forwardingTargetForSelector_), %o1 #ifdef OF_PIC ld [%l7 + %o1], %o1 #endif call objc_msg_lookup nop mov %o0, %l0 mov %i1, %o0 sethi %hi(.Lsel_forwardingTargetForSelector_), %o1 or %o1, %lo(.Lsel_forwardingTargetForSelector_), %o1 #ifdef OF_PIC ld [%l7 + %o1], %o1 #endif jmpl %l0, %o7 mov %i2, %o2 cmp %o0, 0 |
︙ | ︙ | |||
139 140 141 142 143 144 145 | 0: call OFMethodNotFound_stret restore .type OFForward_stret, %function .size OFForward_stret, .-OFForward_stret | | | | | | | | | | | | | | 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | 0: call OFMethodNotFound_stret restore .type OFForward_stret, %function .size OFForward_stret, .-OFForward_stret .Linit: save %sp, -96, %sp #ifdef OF_PIC sethi %hi(_GLOBAL_OFFSET_TABLE_ - 4), %l7 call add_pc add %l7, %lo(_GLOBAL_OFFSET_TABLE_ + 4), %l7 #endif sethi %hi(.Lmodule), %i0 or %i0, %lo(.Lmodule), %i0 #ifdef OF_PIC ld [%l7 + %i0], %i0 #endif call __objc_exec_class restore #ifdef OF_PIC add_pc: jmp %o7 + 8 add %l7, %o7, %l7 #endif #ifdef OF_SOLARIS .section .init_array, "aw" #else .section .ctors, "aw", %progbits #endif .word .Linit .section .rodata .Lstr_forwardingTargetForSelector_: .asciz "forwardingTargetForSelector:" .section .data .Lsel_forwardingTargetForSelector_: .word .Lstr_forwardingTargetForSelector_, 0 .word 0, 0 .Lsymtab: .word 0, .Lsel_forwardingTargetForSelector_ .half 0, 0 .word 0 .word 0 .Lmodule: .word 8, 16, 0, .Lsymtab #if defined(OF_LINUX) || defined(OF_HAIKU) || defined(OF_HURD) .section .note.GNU-stack, "", %progbits #endif |
Modified src/forwarding/forwarding-sparc64-elf.S from [5ae72e6aac] to [f05e3cb3c1].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include "platform.h" .globl OFForward |
︙ | ︙ | |||
44 45 46 47 48 49 50 | std %f22, [%sp + BIAS + 264] std %f24, [%sp + BIAS + 272] std %f26, [%sp + BIAS + 280] std %f28, [%sp + BIAS + 288] std %f30, [%sp + BIAS + 296] sethi %hi(_GLOBAL_OFFSET_TABLE_ - 4), %l7 | | | | | | | | | 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | std %f22, [%sp + BIAS + 264] std %f24, [%sp + BIAS + 272] std %f26, [%sp + BIAS + 280] std %f28, [%sp + BIAS + 288] std %f30, [%sp + BIAS + 296] sethi %hi(_GLOBAL_OFFSET_TABLE_ - 4), %l7 call .LaddPC add %l7, %lo(_GLOBAL_OFFSET_TABLE_ + 4), %l7 mov %i0, %o0 call object_getClass nop sethi %hi(.Lsel_forwardingTargetForSelector_), %o1 or %o1, %lo(.Lsel_forwardingTargetForSelector_), %o1 ldx [%l7 + %o1], %o1 call class_respondsToSelector nop brz,pn %o0, 0f mov %i0, %o0 sethi %hi(.Lsel_forwardingTargetForSelector_), %o1 or %o1, %lo(.Lsel_forwardingTargetForSelector_), %o1 ldx [%l7 + %o1], %o1 call objc_msg_lookup nop mov %o0, %l0 mov %i0, %o0 sethi %hi(.Lsel_forwardingTargetForSelector_), %o1 or %o1, %lo(.Lsel_forwardingTargetForSelector_), %o1 ldx [%l7 + %o1], %o1 jmpl %l0, %o7 mov %i1, %o2 brz,pn %o0, 0f cmp %o0, %i0 be,pn %xcc, 0f |
︙ | ︙ | |||
137 138 139 140 141 142 143 | std %f22, [%sp + BIAS + 264] std %f24, [%sp + BIAS + 272] std %f26, [%sp + BIAS + 280] std %f28, [%sp + BIAS + 288] std %f30, [%sp + BIAS + 296] sethi %hi(_GLOBAL_OFFSET_TABLE_ - 4), %l7 | | | | | | | | | 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | std %f22, [%sp + BIAS + 264] std %f24, [%sp + BIAS + 272] std %f26, [%sp + BIAS + 280] std %f28, [%sp + BIAS + 288] std %f30, [%sp + BIAS + 296] sethi %hi(_GLOBAL_OFFSET_TABLE_ - 4), %l7 call .LaddPC add %l7, %lo(_GLOBAL_OFFSET_TABLE_ + 4), %l7 mov %i1, %o0 call object_getClass nop sethi %hi(.Lsel_forwardingTargetForSelector_), %o1 or %o1, %lo(.Lsel_forwardingTargetForSelector_), %o1 ldx [%l7 + %o1], %o1 call class_respondsToSelector nop brz,pn %o0, 0f mov %i1, %o0 sethi %hi(.Lsel_forwardingTargetForSelector_), %o1 or %o1, %lo(.Lsel_forwardingTargetForSelector_), %o1 ldx [%l7 + %o1], %o1 call objc_msg_lookup nop mov %o0, %l0 mov %i1, %o0 sethi %hi(.Lsel_forwardingTargetForSelector_), %o1 or %o1, %lo(.Lsel_forwardingTargetForSelector_), %o1 ldx [%l7 + %o1], %o1 jmpl %l0, %o7 mov %i2, %o2 brz,pn %o0, 0f cmp %o0, %i1 be,pn %xcc, 0f |
︙ | ︙ | |||
205 206 207 208 209 210 211 | 0: call OFMethodNotFound_stret restore .type OFForward_stret, %function .size OFForward_stret, .-OFForward_stret | | | | | | | | | | | | | | | | 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | 0: call OFMethodNotFound_stret restore .type OFForward_stret, %function .size OFForward_stret, .-OFForward_stret .Linit: save %sp, -176, %sp sethi %hi(_GLOBAL_OFFSET_TABLE_ - 4), %l7 call .LaddPC add %l7, %lo(_GLOBAL_OFFSET_TABLE_ + 4), %l7 sethi %hi(.Lmodule), %i0 or %i0, %lo(.Lmodule), %i0 ldx [%l7 + %i0], %i0 call __objc_exec_class restore .LaddPC: jmp %o7 + 8 add %l7, %o7, %l7 #ifdef OF_SOLARIS .section .init_array, "aw" #else .section .ctors, "aw", %progbits #endif .xword .Linit .section .rodata .Lstr_forwardingTargetForSelector_: .asciz "forwardingTargetForSelector:" .section .data .Lsel_forwardingTargetForSelector_: .xword .Lstr_forwardingTargetForSelector_, 0 .xword 0, 0 .Lsymtab: .xword 0, .Lsel_forwardingTargetForSelector_ .half 0, 0 .word 0 .xword 0 .Lmodule: .xword 8, 32, 0, .Lsymtab #if defined(OF_LINUX) || defined(OF_HAIKU) || defined(OF_HURD) .section .note.GNU-stack, "", %progbits #endif |
Modified src/forwarding/forwarding-x86-elf.S from [a55d3f40d7] to [99d3c58617].
1 | /* | | | | | | > > > > | < > | > > > > > > > > | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include "platform.h" #ifdef HAVE_CET_H # include <cet.h> #else # define _CET_ENDBR #endif .globl OFForward .globl OFForward_stret .section .text OFForward: _CET_ENDBR pushl %ebp movl %esp, %ebp pushl %ebx subl $20, %esp call .LgetEIP addl $_GLOBAL_OFFSET_TABLE_, %ebx movl 8(%ebp), %eax movl %eax, (%esp) call object_getClass@PLT movl %eax, (%esp) leal .Lsel_forwardingTargetForSelector_@GOTOFF(%ebx), %eax movl %eax, 4(%esp) call class_respondsToSelector@PLT testl %eax, %eax jz 0f movl 8(%ebp), %eax movl %eax, (%esp) leal .Lsel_forwardingTargetForSelector_@GOTOFF(%ebx), %eax movl %eax, 4(%esp) call objc_msg_lookup@PLT movl 8(%ebp), %edx movl %edx, (%esp) leal .Lsel_forwardingTargetForSelector_@GOTOFF(%ebx), %edx movl %edx, 4(%esp) movl 12(%ebp), %edx movl %edx, 8(%esp) call *%eax testl %eax, %eax jz 0f |
︙ | ︙ | |||
71 72 73 74 75 76 77 | addl $20, %esp popl %ebx popl %ebp jmp *%eax 0: | | > > | | | | | 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | addl $20, %esp popl %ebx popl %ebp jmp *%eax 0: movl OFMethodNotFound@GOT(%ebx), %eax addl $20, %esp popl %ebx popl %ebp jmp *%eax .type OFForward, %function .size OFForward, .-OFForward OFForward_stret: _CET_ENDBR pushl %ebp movl %esp, %ebp pushl %ebx subl $20, %esp call .LgetEIP addl $_GLOBAL_OFFSET_TABLE_, %ebx movl 12(%ebp), %eax movl %eax, (%esp) call object_getClass@PLT movl %eax, (%esp) leal .Lsel_forwardingTargetForSelector_@GOTOFF(%ebx), %eax movl %eax, 4(%esp) call class_respondsToSelector@PLT testl %eax, %eax jz 0f movl 12(%ebp), %eax movl %eax, (%esp) leal .Lsel_forwardingTargetForSelector_@GOTOFF(%ebx), %eax movl %eax, 4(%esp) call objc_msg_lookup@PLT movl 12(%ebp), %edx movl %edx, (%esp) leal .Lsel_forwardingTargetForSelector_@GOTOFF(%ebx), %edx movl %edx, 4(%esp) movl 16(%ebp), %edx movl %edx, 8(%esp) call *%eax testl %eax, %eax jz 0f |
︙ | ︙ | |||
135 136 137 138 139 140 141 | addl $20, %esp popl %ebx popl %ebp jmp *%eax 0: | | | > > | | | | | | | | | | | | | 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | addl $20, %esp popl %ebx popl %ebp jmp *%eax 0: movl OFMethodNotFound_stret@GOT(%ebx), %eax addl $20, %esp popl %ebx popl %ebp jmp *%eax .type OFForward_stret, %function .size OFForward_stret, .-OFForward_stret .Linit: _CET_ENDBR pushl %ebp movl %esp, %ebp pushl %ebx subl $4, %esp call .LgetEIP addl $_GLOBAL_OFFSET_TABLE_, %ebx leal .Lmodule@GOTOFF(%ebx), %eax movl %eax, (%esp) call __objc_exec_class@PLT addl $4, %esp popl %ebx popl %ebp ret .LgetEIP: movl (%esp), %ebx ret #ifdef OF_SOLARIS .section .init_array, "aw" #else .section .ctors, "aw", %progbits #endif .long .Linit .section .rodata .Lstr_forwardingTargetForSelector_: .asciz "forwardingTargetForSelector:" .section .data .Lsel_forwardingTargetForSelector_: .long .Lstr_forwardingTargetForSelector_, 0 .long 0, 0 .Lsymtab: .long 0, .Lsel_forwardingTargetForSelector_ .short 0, 0 .long 0 .long 0 .Lmodule: .long 8, 16, 0, .Lsymtab #if defined(OF_LINUX) || defined(OF_HAIKU) || defined(OF_HURD) .section .note.GNU-stack, "", %progbits #endif |
Modified src/forwarding/forwarding-x86-win32.S from [7c90db9737] to [cadaa3564e].
1 | /* | | | | | | > > > > | < > | > > > > > > > > | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" .globl _OFForward .globl _OFForward_stret #ifdef HAVE_CET_H # include <cet.h> #else # define _CET_ENDBR #endif .section .text _OFForward: _CET_ENDBR pushl %ebp movl %esp, %ebp pushl %ebx subl $20, %esp movl 8(%ebp), %eax movl %eax, (%esp) call _object_getClass movl %eax, (%esp) movl $.Lsel_forwardingTargetForSelector_, %eax movl %eax, 4(%esp) call _class_respondsToSelector testl %eax, %eax jz 0f movl 8(%ebp), %eax movl %eax, (%esp) movl $.Lsel_forwardingTargetForSelector_, %eax movl %eax, 4(%esp) call _objc_msg_lookup movl 8(%ebp), %edx movl %edx, (%esp) movl $.Lsel_forwardingTargetForSelector_, %edx movl %edx, 4(%esp) movl 12(%ebp), %edx movl %edx, 8(%esp) call *%eax testl %eax, %eax jz 0f |
︙ | ︙ | |||
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | jmp _OFMethodNotFound .def _OFForward .scl 2 .type 32 .endef _OFForward_stret: pushl %ebp movl %esp, %ebp pushl %ebx subl $20, %esp movl 12(%ebp), %eax movl %eax, (%esp) call _object_getClass movl %eax, (%esp) | > > | | | | 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | jmp _OFMethodNotFound .def _OFForward .scl 2 .type 32 .endef _OFForward_stret: _CET_ENDBR pushl %ebp movl %esp, %ebp pushl %ebx subl $20, %esp movl 12(%ebp), %eax movl %eax, (%esp) call _object_getClass movl %eax, (%esp) movl $.Lsel_forwardingTargetForSelector_, %eax movl %eax, 4(%esp) call _class_respondsToSelector testl %eax, %eax jz 0f movl 12(%ebp), %eax movl %eax, (%esp) movl $.Lsel_forwardingTargetForSelector_, %eax movl %eax, 4(%esp) call _objc_msg_lookup movl 12(%ebp), %edx movl %edx, (%esp) movl $.Lsel_forwardingTargetForSelector_, %edx movl %edx, 4(%esp) movl 16(%ebp), %edx movl %edx, 8(%esp) call *%eax testl %eax, %eax jz 0f |
︙ | ︙ | |||
137 138 139 140 141 142 143 | jmp _OFMethodNotFound_stret .def _OFForward_stret .scl 2 .type 32 .endef | | > > | | | | | | | | | | 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | jmp _OFMethodNotFound_stret .def _OFForward_stret .scl 2 .type 32 .endef .Linit: _CET_ENDBR pushl %ebp movl %esp, %ebp pushl %ebx subl $4, %esp movl $.Lmodule, %eax movl %eax, (%esp) call ___objc_exec_class addl $4, %esp popl %ebx popl %ebp ret .section .ctors, "aw" .long .Linit .section .rodata .Lstr_forwardingTargetForSelector_: .asciz "forwardingTargetForSelector:" .section .data .Lsel_forwardingTargetForSelector_: .long .Lstr_forwardingTargetForSelector_, 0 .long 0, 0 .Lsymtab: .long 0, .Lsel_forwardingTargetForSelector_ .short 0, 0 .long 0 .long 0 .Lmodule: .long 8, 16, 0, .Lsymtab |
Modified src/forwarding/forwarding.S from [0a5e45dea8] to [90b59c1fef].
1 | /* | | | | | | > > > > | < > | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include "platform.h" #ifdef OF_APPLE_RUNTIME # if defined(OF_AMD64) # include "apple-forwarding-amd64.S" # elif defined(OF_X86) # include "apple-forwarding-x86.S" # elif defined(OF_ARM64) # include "apple-forwarding-arm64.S" # elif defined(OF_ARM) # include "apple-forwarding-arm.S" # elif defined(OF_POWERPC) # include "apple-forwarding-powerpc.S" # endif #else # if defined(OF_ELF) # if defined(OF_AMD64) # include "forwarding-amd64-elf.S" # elif defined(OF_X86) # include "forwarding-x86-elf.S" # elif defined(OF_ARM64) # include "forwarding-arm64-elf.S" # elif defined(OF_ARM) # include "forwarding-arm-elf.S" # elif defined(OF_POWERPC) # include "forwarding-powerpc-elf.S" # elif defined(OF_MIPS) # include "forwarding-mips-elf.S" # elif defined(OF_SPARC64) # include "forwarding-sparc64-elf.S" # elif defined(OF_SPARC) # include "forwarding-sparc-elf.S" # endif # elif defined(OF_MACH_O) # if defined(OF_AMD64) # include "forwarding-amd64-macho.S" # endif # elif defined(OF_WINDOWS) # if defined(OF_AMD64) # include "forwarding-amd64-win64.S" # elif defined(OF_X86) # include "forwarding-x86-win32.S" # endif # endif #endif |
Modified src/libbases.m from [952ca43ba1] to [f3261ea1ff].
1 | /* | | | | | | > > > > | < > | > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #define Class IntuitionClass #include <proto/exec.h> #undef Class #import "OFInitializationFailedException.h" #import "macros.h" #ifdef OF_AMIGAOS4 extern struct Library *DOSBase; |
︙ | ︙ |
Modified src/macros.h from [4ca2ebbb7b] to [7e3d0a019b].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #ifndef OBJFW_MACROS_H #define OBJFW_MACROS_H #include "objfw-defs.h" |
︙ | ︙ | |||
99 100 101 102 103 104 105 106 107 108 109 | # define OF_UNLIKELY(cond) (cond) # define OF_CONST_FUNC # define OF_NO_RETURN_FUNC # define OF_WEAK_REF(sym) #endif #if __STDC_VERSION__ >= 201112L # define OF_ALIGNOF(type) _Alignof(type) # define OF_ALIGNAS(type) _Alignas(type) #else # define OF_ALIGNOF(type) __alignof__(type) | > > | < < < | | | | | | > > > > > > > | 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | # define OF_UNLIKELY(cond) (cond) # define OF_CONST_FUNC # define OF_NO_RETURN_FUNC # define OF_WEAK_REF(sym) #endif #if __STDC_VERSION__ >= 201112L # define OF_ALIGN(size) _Alignas(size) # define OF_ALIGNOF(type) _Alignof(type) # define OF_ALIGNAS(type) _Alignas(type) #else # define OF_ALIGN(size) __attribute__((__aligned__(size))) # define OF_ALIGNOF(type) __alignof__(type) # define OF_ALIGNAS(type) OF_ALIGN(OF_ALIGNOF(type)) #endif #ifdef __BIGGEST_ALIGNMENT__ # define OF_BIGGEST_ALIGNMENT __BIGGEST_ALIGNMENT__ #else /* Hopefully no arch needs more than 16 byte alignment */ # define OF_BIGGEST_ALIGNMENT 16 #endif /* * We use SSE inline assembly on AMD64 and x86, so it must never be smaller * than 16. */ #if (defined(OF_AMD64) || defined(OF_X86)) && OF_BIGGEST_ALIGNMENT < 16 # undef OF_BIGGEST_ALIGNMENT # define OF_BIGGEST_ALIGNMENT 16 #endif #define OF_PREPROCESSOR_CONCAT2(a, b) a##b #define OF_PREPROCESSOR_CONCAT(a, b) OF_PREPROCESSOR_CONCAT2(a, b) #if __OBJFW_RUNTIME_ABI__ || (defined(OF_APPLE_RUNTIME) && defined(__OBJC2__)) # define OF_HAVE_NONFRAGILE_IVARS |
︙ | ︙ | |||
287 288 289 290 291 292 293 294 295 296 297 298 299 300 | #if __has_attribute(__objc_designated_initializer__) # define OF_DESIGNATED_INITIALIZER \ __attribute__((__objc_designated_initializer__)) #else # define OF_DESIGNATED_INITIALIZER #endif #if __has_attribute(__objc_boxable__) # define OF_BOXABLE __attribute__((__objc_boxable__)) #else # define OF_BOXABLE #endif | > > > > > > > > > > > | 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | #if __has_attribute(__objc_designated_initializer__) # define OF_DESIGNATED_INITIALIZER \ __attribute__((__objc_designated_initializer__)) #else # define OF_DESIGNATED_INITIALIZER #endif #if defined(__clang__) || OF_GCC_VERSION >= 405 # define OF_DEPRECATED(project, major, minor, msg) \ __attribute__((__deprecated__("Deprecated in " #project " " \ #major "." #minor ": " msg))) #elif defined(__GNUC__) # define OF_DEPRECATED(project, major, minor, msg) \ __attribute__((__deprecated__)) #else # define OF_DEPRECATED(project, major, minor, msg) #endif #if __has_attribute(__objc_boxable__) # define OF_BOXABLE __attribute__((__objc_boxable__)) #else # define OF_BOXABLE #endif |
︙ | ︙ | |||
312 313 314 315 316 317 318 | #if __has_attribute(__objc_direct_members__) && defined(OF_APPLE_RUNTIME) # define OF_DIRECT_MEMBERS __attribute__((__objc_direct_members__)) #else # define OF_DIRECT_MEMBERS #endif #ifdef OF_APPLE_RUNTIME | | | | | > > > > > > > > | | < > > > > > > | 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 | #if __has_attribute(__objc_direct_members__) && defined(OF_APPLE_RUNTIME) # define OF_DIRECT_MEMBERS __attribute__((__objc_direct_members__)) #else # define OF_DIRECT_MEMBERS #endif #ifdef OF_APPLE_RUNTIME # if defined(OF_AMD64) || defined(OF_X86) || defined(OF_ARM64) || \ defined(OF_ARM) || defined(OF_POWERPC) # define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR # define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR_STRET # endif #else # if defined(OF_ELF) # if defined(OF_AMD64) || defined(OF_X86) || \ defined(OF_ARM64) || defined(OF_ARM) || defined(OF_POWERPC) || \ defined(OF_MIPS) || defined(OF_SPARC64) || defined(OF_SPARC) # define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR # if __OBJFW_RUNTIME_ABI__ >= 800 # define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR_STRET # endif # endif # elif defined(OF_MACH_O) # if defined(OF_AMD64) # define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR # if __OBJFW_RUNTIME_ABI__ >= 800 # define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR_STRET # endif # endif # elif defined(OF_WINDOWS) # if defined(OF_AMD64) || defined(OF_X86) # define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR # if __OBJFW_RUNTIME_ABI__ >= 800 # define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR_STRET # endif # endif # endif #endif #define OFMaxRetainCount UINT_MAX #ifdef OBJC_COMPILING_RUNTIME # define OFEnsure(cond) \ do { \ if OF_UNLIKELY (!(cond)) \ objc_error("ObjFWRT @ " __FILE__ ":" \ OF_STRINGIFY(__LINE__), \ "Failed to ensure condition:\n" #cond); \ } while(0) #else @class OFConstantString; # ifdef __cplusplus extern "C" { # endif extern void OFLog(OFConstantString *_Nonnull, ...); # ifdef __cplusplus } # endif # define OFEnsure(cond) \ do { \ if OF_UNLIKELY (!(cond)) { \ OFLog(@"Failed to ensure condition in " \ @__FILE__ ":%d: " @#cond, __LINE__); \ abort(); \ } \ } while (0) #endif #ifndef NDEBUG # define OFAssert(...) OFEnsure(__VA_ARGS__) #else # define OFAssert(...) #endif #define OF_UNRECOGNIZED_SELECTOR OFMethodNotFound(self, _cmd); #if __has_feature(objc_arc) # define OF_INVALID_INIT_METHOD OFMethodNotFound(self, _cmd); #else # define OF_INVALID_INIT_METHOD \ @try { \ |
︙ | ︙ | |||
398 399 400 401 402 403 404 405 406 407 408 409 410 411 | # define OF_DEALLOC_UNSUPPORTED \ [self doesNotRecognizeSelector: _cmd]; \ \ abort(); \ \ [super dealloc]; /* Get rid of a stupid warning */ #endif #define OF_CONSTRUCTOR(prio) \ static void __attribute__((__constructor__(prio))) \ OF_PREPROCESSOR_CONCAT(constructor, __LINE__)(void) #define OF_DESTRUCTOR(prio) \ static void __attribute__((__destructor__(prio))) \ OF_PREPROCESSOR_CONCAT(destructor, __LINE__)(void) | > > > > > > > > > > > > > > > > > > > > > > > > | 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 | # define OF_DEALLOC_UNSUPPORTED \ [self doesNotRecognizeSelector: _cmd]; \ \ abort(); \ \ [super dealloc]; /* Get rid of a stupid warning */ #endif #define OF_SINGLETON_METHODS \ - (instancetype)autorelease \ { \ return self; \ } \ \ - (instancetype)retain \ { \ return self; \ } \ \ - (void)release \ { \ } \ \ - (unsigned int)retainCount \ { \ return OFMaxRetainCount; \ } \ \ - (void)dealloc \ { \ OF_DEALLOC_UNSUPPORTED \ } #define OF_CONSTRUCTOR(prio) \ static void __attribute__((__constructor__(prio))) \ OF_PREPROCESSOR_CONCAT(constructor, __LINE__)(void) #define OF_DESTRUCTOR(prio) \ static void __attribute__((__destructor__(prio))) \ OF_PREPROCESSOR_CONCAT(destructor, __LINE__)(void) |
︙ | ︙ | |||
439 440 441 442 443 444 445 | } static OF_INLINE uint16_t OF_CONST_FUNC OFByteSwap16NonConst(uint16_t i) { #if defined(OF_HAVE_BUILTIN_BSWAP16) return __builtin_bswap16(i); | | | | | | | > | | | | | | | > | | | | | | | | | | | 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 | } static OF_INLINE uint16_t OF_CONST_FUNC OFByteSwap16NonConst(uint16_t i) { #if defined(OF_HAVE_BUILTIN_BSWAP16) return __builtin_bswap16(i); #elif (defined(OF_AMD64) || defined(OF_X86)) && defined(__GNUC__) __asm__ ( "xchg{b} { %h0, %b0 | %b0, %h0 }" : "=Q" (i) : "0" (i) ); #elif defined(OF_POWERPC) && defined(__GNUC__) __asm__ ( "lhbrx %0, 0, %1" : "=r" (i) : "r" (&i), "m" (i) ); #elif defined(OF_ARMV6) && defined(__GNUC__) __asm__ ( "rev16 %0, %0" : "=r" (i) : "0" (i) ); #else i = (i & UINT16_C(0xFF00)) >> 8 | (i & UINT16_C(0x00FF)) << 8; #endif return i; } static OF_INLINE uint32_t OF_CONST_FUNC OFByteSwap32NonConst(uint32_t i) { #if defined(OF_HAVE_BUILTIN_BSWAP32) return __builtin_bswap32(i); #elif (defined(OF_AMD64) || defined(OF_X86)) && defined(__GNUC__) __asm__ ( "bswap %0" : "=q" (i) : "0" (i) ); #elif defined(OF_POWERPC) && defined(__GNUC__) __asm__ ( "lwbrx %0, 0, %1" : "=r" (i) : "r" (&i), "m" (i) ); #elif defined(OF_ARMV6) && defined(__GNUC__) __asm__ ( "rev %0, %0" : "=r" (i) : "0" (i) ); #else i = (i & UINT32_C(0xFF000000)) >> 24 | (i & UINT32_C(0x00FF0000)) >> 8 | (i & UINT32_C(0x0000FF00)) << 8 | (i & UINT32_C(0x000000FF)) << 24; #endif return i; } static OF_INLINE uint64_t OF_CONST_FUNC OFByteSwap64NonConst(uint64_t i) { #if defined(OF_HAVE_BUILTIN_BSWAP64) return __builtin_bswap64(i); #elif defined(OF_AMD64) && defined(__GNUC__) __asm__ ( "bswap %0" : "=r" (i) : "0" (i) ); #elif defined(OF_X86) && defined(__GNUC__) __asm__ ( "bswap {%%}eax\n\t" "bswap {%%}edx\n\t" "xchg{l} { %%eax, %%edx | edx, eax }" : "=A" (i) : "0" (i) ); #else i = (uint64_t)OFByteSwap32NonConst( (uint32_t)(i & UINT32_C(0xFFFFFFFF))) << 32 | OFByteSwap32NonConst((uint32_t)(i >> 32)); #endif return i; |
︙ | ︙ |
Modified src/objfw-defs.h.in from [2685faa746] to [d61e321f94].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #undef OF_APPLE_RUNTIME #undef OF_BIG_ENDIAN #undef OF_FLOAT_BIG_ENDIAN #undef OF_HAVE_AFUNIX_H #undef OF_HAVE_APPLETALK #undef OF_HAVE_ATOMIC_BUILTINS #undef OF_HAVE_ATOMIC_OPS #undef OF_HAVE_BUILTIN_BSWAP16 #undef OF_HAVE_BUILTIN_BSWAP32 #undef OF_HAVE_BUILTIN_BSWAP64 #undef OF_HAVE_CHMOD #undef OF_HAVE_CHOWN #undef OF_HAVE_FILES #undef OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR #undef OF_HAVE_IPV6 #undef OF_HAVE_IPX #undef OF_HAVE_LIMITS_H #undef OF_HAVE_LINK | > < > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | #undef OF_APPLE_RUNTIME #undef OF_BIG_ENDIAN #undef OF_CLASSIC_MACOS #undef OF_FLOAT_BIG_ENDIAN #undef OF_HAVE_AFUNIX_H #undef OF_HAVE_APPLETALK #undef OF_HAVE_ATOMIC_BUILTINS #undef OF_HAVE_ATOMIC_OPS #undef OF_HAVE_BUILTIN_BSWAP16 #undef OF_HAVE_BUILTIN_BSWAP32 #undef OF_HAVE_BUILTIN_BSWAP64 #undef OF_HAVE_CHMOD #undef OF_HAVE_CHOWN #undef OF_HAVE_FILES #undef OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR #undef OF_HAVE_IPV6 #undef OF_HAVE_IPX #undef OF_HAVE_LIMITS_H #undef OF_HAVE_LINK #undef OF_HAVE_NETATALK_AT_H #undef OF_HAVE_NETAT_APPLETALK_H #undef OF_HAVE_NETINET_IN_H #undef OF_HAVE_NETINET_SCTP_H #undef OF_HAVE_NETINET_TCP_H #undef OF_HAVE_NETIPX_IPX_H #undef OF_HAVE_OSATOMIC #undef OF_HAVE_OSATOMIC_64 #undef OF_HAVE_PIPE #undef OF_HAVE_PLEDGE #undef OF_HAVE_PLUGINS #undef OF_HAVE_PTHREADS #undef OF_HAVE_PTHREAD_SPINLOCKS #undef OF_HAVE_RECURSIVE_PTHREAD_MUTEXES #undef OF_HAVE_SCHED_YIELD #undef OF_HAVE_SOCKADDR_STORAGE #undef OF_HAVE_SOCKETS #undef OF_HAVE_STDNORETURN #undef OF_HAVE_SUBPROCESSES #undef OF_HAVE_SYMLINK #undef OF_HAVE_SYNC_BUILTINS #undef OF_HAVE_SYS_SOCKET_H #undef OF_HAVE_SYS_TYPES_H |
︙ | ︙ |
Modified src/platform.h from [927be68827] to [37d4dfa836].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "objfw-defs.h" /* Required to build universal binaries on OS X */ #ifdef OF_UNIVERSAL # if __BIG_ENDIAN__ # define OF_BIG_ENDIAN # define OF_FLOAT_BIG_ENDIAN # elif !__LITTLE_ENDIAN__ # error OF_UNIVERSAL defined, but neither __BIG_ENDIAN__ nor __LITTLE_ENDIAN__! # endif #endif #if defined(__x86_64__) || defined(__amd64__) # define OF_AMD64 #elif defined(__i386__) # define OF_X86 #elif defined(__powerpc64__) || defined(__ppc64__) || defined(__PPC64__) # define OF_POWERPC64 #elif defined(__powerpc__) || defined(__ppc__) || defined(__PPC__) # define OF_POWERPC #elif defined(__arm64__) || defined(__aarch64__) || defined(__ARM64_ARCH_8__) |
︙ | ︙ | |||
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | #elif defined(__DJGPP__) # define OF_DJGPP # define OF_MSDOS #elif defined(__riscos__) # define OF_ACORN_RISC_OS #elif defined(__MINT__) # define OF_MINT #endif #if defined(__ELF__) # define OF_ELF #elif defined(__MACH__) # define OF_MACH_O #endif #if defined(__PIC__) || defined(__pic__) # define OF_PIC #endif | > > > > > > > > | 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | #elif defined(__DJGPP__) # define OF_DJGPP # define OF_MSDOS #elif defined(__riscos__) # define OF_ACORN_RISC_OS #elif defined(__MINT__) # define OF_MINT #elif defined(__gnu_hurd__) # define OF_HURD #elif defined(__serenity__) # define OF_SERENITYOS #endif #ifdef __GLIBC__ # define OF_GLIBC #endif #if defined(__ELF__) # define OF_ELF #elif defined(__MACH__) # define OF_MACH_O #endif #if defined(__PIC__) || defined(__pic__) # define OF_PIC #endif |
Modified src/platform/AmigaOS/OFPlainCondition.m from [b17297ed32] to [c2df0315e9].
1 | /* | | | | | | > > > > | < > | > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #import "OFPlainCondition.h" #define Class IntuitionClass #include <proto/exec.h> #include <devices/timer.h> #ifndef OF_AMIGAOS4 # include <clib/alib_protos.h> #endif #undef Class int OFPlainConditionNew(OFPlainCondition *condition) { condition->waitingTasks = NULL; return 0; |
︙ | ︙ |
Modified src/platform/AmigaOS/OFPlainMutex.m from [635aa59c59] to [6c82c9eb62].
1 | /* | | | | | | > > > > | < > | > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #import "OFPlainMutex.h" #define Class IntuitionClass #include <proto/exec.h> #undef Class int OFPlainMutexNew(OFPlainMutex *mutex) { InitSemaphore(mutex); return 0; |
︙ | ︙ |
Modified src/platform/AmigaOS/OFPlainThread.m from [70ea6c25e9] to [a070f010e3].
1 | /* | | | | | | > > > > | < > | < > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #import "OFPlainThread.h" #import "OFData.h" #import "OFString.h" #import "OFTLSKey.h" #define Class IntuitionClass #include <dos/dostags.h> #include <proto/dos.h> #include <proto/exec.h> #undef Class #ifndef OF_MORPHOS extern void OFTLSKeyThreadExited(void); #endif static OFTLSKey threadKey; OF_CONSTRUCTOR() |
︙ | ︙ | |||
189 190 191 192 193 194 195 | } @finally { ReleaseSemaphore(&thread->semaphore); } Wait(1ul << thread->joinSigBit); FreeSignal(thread->joinSigBit); | | | 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | } @finally { ReleaseSemaphore(&thread->semaphore); } Wait(1ul << thread->joinSigBit); FreeSignal(thread->joinSigBit); OFAssert(thread->done); free(thread); return 0; } int OFPlainThreadDetach(OFPlainThread thread) |
︙ | ︙ |
Modified src/platform/AmigaOS/OFString+PathAdditions.m from [60752aa5d1] to [1cb2438986].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFString+PathAdditions.h" #import "OFArray.h" #import "OFFileIRIHandler.h" #import "OFOutOfRangeException.h" int _OFString_PathAdditions_reference; @implementation OFString (PathAdditions) + (OFString *)pathWithComponents: (OFArray *)components |
︙ | ︙ | |||
251 252 253 254 255 256 257 258 259 260 261 262 263 264 | [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } - (OFString *)stringByAppendingPathComponent: (OFString *)component { if ([self hasSuffix: @"/"] || [self hasSuffix: @":"]) return [self stringByAppendingString: component]; else { OFMutableString *ret = [[self mutableCopy] autorelease]; [ret appendString: @"/"]; [ret appendString: component]; | > > > | 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } - (OFString *)stringByAppendingPathComponent: (OFString *)component { if (self.length == 0) return component; if ([self hasSuffix: @"/"] || [self hasSuffix: @":"]) return [self stringByAppendingString: component]; else { OFMutableString *ret = [[self mutableCopy] autorelease]; [ret appendString: @"/"]; [ret appendString: component]; |
︙ | ︙ | |||
289 290 291 292 293 294 295 | } else return [self stringByAppendingFormat: @".%@", extension]; } - (bool)of_isDirectoryPath { return ([self hasSuffix: @"/"] || [self hasSuffix: @":"] || | | | | 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | } else return [self stringByAppendingFormat: @".%@", extension]; } - (bool)of_isDirectoryPath { return ([self hasSuffix: @"/"] || [self hasSuffix: @":"] || [OFFileIRIHandler of_directoryExistsAtPath: self]); } - (OFString *)of_pathToIRIPathWithPercentEncodedHost: (OFString **)percentEncodedHost { OFArray OF_GENERIC(OFString *) *components = self.pathComponents; OFMutableString *ret = [OFMutableString string]; for (OFString *component in components) { if (component.length == 0) |
︙ | ︙ | |||
315 316 317 318 319 320 321 | } [ret makeImmutable]; return ret; } | | | 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 | } [ret makeImmutable]; return ret; } - (OFString *)of_IRIPathToPathWithPercentEncodedHost: (OFString *)percentEncodedHost { OFString *path = self; if (path.length > 1 && [path hasSuffix: @"/"]) path = [path substringToIndex: path.length - 1]; |
︙ | ︙ | |||
349 350 351 352 353 354 355 | if ([component isEqual: @".."]) [components replaceObjectAtIndex: i withObject: @"/"]; } return [OFString pathWithComponents: components]; } | | | 356 357 358 359 360 361 362 363 364 365 366 367 | if ([component isEqual: @".."]) [components replaceObjectAtIndex: i withObject: @"/"]; } return [OFString pathWithComponents: components]; } - (OFString *)of_pathComponentToIRIPathComponent { return self; } @end |
Modified src/platform/AmigaOS/OFTLSKey.m from [7115be10da] to [a247db4e0a].
1 | /* | | | | | | > > > > | < > | > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFTLSKey.h" #define Class IntuitionClass #include <exec/semaphores.h> #include <proto/exec.h> #undef Class /* * As we use this file in both the runtime and ObjFW, and since AmigaOS always * has the runtime, use the hashtable from the runtime. */ #import "runtime/private.h" |
︙ | ︙ |
Modified src/platform/GCC4.7/OFAtomic.h from [3a2198950d] to [3630f2c37c].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ static OF_INLINE int OFAtomicIntAdd(volatile int *_Nonnull p, int i) { return __atomic_add_fetch(p, i, __ATOMIC_RELAXED); } |
︙ | ︙ |
Modified src/platform/GCC4/OFAtomic.h from [46ae36c82b] to [db656cd0ac].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ static OF_INLINE int OFAtomicIntAdd(volatile int *_Nonnull p, int i) { return __sync_add_and_fetch(p, i); } |
︙ | ︙ |
Modified src/platform/MorphOS/OFTLSKey.m from [f46c8d88c6] to [4cdbdc816e].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFTLSKey.h" int |
︙ | ︙ |
Modified src/platform/POSIX/OFPlainCondition.m from [d0abcf1839] to [5a7f2a038a].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFPlainCondition.h" int |
︙ | ︙ |
Modified src/platform/POSIX/OFPlainMutex.m from [bcf658e6be] to [743f1e114a].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFPlainMutex.h" int |
︙ | ︙ |
Modified src/platform/POSIX/OFPlainThread.m from [7bbb313eb6] to [f47c0a4651].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #ifdef HAVE_PTHREAD_NP_H |
︙ | ︙ |
Modified src/platform/POSIX/OFString+PathAdditions.m from [d1f51523cf] to [1b0cd1cdad].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFString+PathAdditions.h" #import "OFArray.h" #import "OFFileIRIHandler.h" #import "OFOutOfRangeException.h" int _OFString_PathAdditions_reference; @implementation OFString (PathAdditions) + (OFString *)pathWithComponents: (OFArray *)components |
︙ | ︙ | |||
296 297 298 299 300 301 302 303 304 305 306 307 308 309 | objc_autoreleasePoolPop(pool); return [ret autorelease]; } - (OFString *)stringByAppendingPathComponent: (OFString *)component { if ([self hasSuffix: @"/"]) return [self stringByAppendingString: component]; else { OFMutableString *ret = [[self mutableCopy] autorelease]; [ret appendString: @"/"]; [ret appendString: component]; | > > > | 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 | objc_autoreleasePoolPop(pool); return [ret autorelease]; } - (OFString *)stringByAppendingPathComponent: (OFString *)component { if (self.length == 0) return component; if ([self hasSuffix: @"/"]) return [self stringByAppendingString: component]; else { OFMutableString *ret = [[self mutableCopy] autorelease]; [ret appendString: @"/"]; [ret appendString: component]; |
︙ | ︙ | |||
334 335 336 337 338 339 340 | } else return [self stringByAppendingFormat: @".%@", extension]; } - (bool)of_isDirectoryPath { return ([self hasSuffix: @"/"] || | | | | | | 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | } else return [self stringByAppendingFormat: @".%@", extension]; } - (bool)of_isDirectoryPath { return ([self hasSuffix: @"/"] || [OFFileIRIHandler of_directoryExistsAtPath: self]); } - (OFString *)of_pathToIRIPathWithPercentEncodedHost: (OFString **)percentEncodedHost { return self; } - (OFString *)of_IRIPathToPathWithPercentEncodedHost: (OFString *)percentEncodedHost { OFString *path = self; if (path.length > 1 && [path hasSuffix: @"/"]) path = [path substringToIndex: path.length - 1]; return path; } - (OFString *)of_pathComponentToIRIPathComponent { return self; } @end |
Modified src/platform/POSIX/OFSubprocess.m from [9ff417c581] to [81cb1904cd].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #include <string.h> |
︙ | ︙ | |||
37 38 39 40 41 42 43 | #import "OFInitializationFailedException.h" #import "OFNotOpenException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFWriteFailedException.h" | | > > > | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | #import "OFInitializationFailedException.h" #import "OFNotOpenException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFWriteFailedException.h" #ifndef OF_MACOS extern char **environ; #else # include <crt_externs.h> # define environ (*_NSGetEnviron()) #endif @interface OFSubprocess () - (void)of_getArgv: (char ***)argv forProgramName: (OFString *)programName andArguments: (OFArray *)arguments; - (char **)of_environmentForDictionary: (OFDictionary *)dictionary; |
︙ | ︙ | |||
139 140 141 142 143 144 145 | path = [program cStringWithEncoding: [OFLocale encoding]]; [self of_getArgv: &argv forProgramName: programName andArguments: arguments]; @try { env = [self of_environmentForDictionary: environment]; | | | 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | path = [program cStringWithEncoding: [OFLocale encoding]]; [self of_getArgv: &argv forProgramName: programName andArguments: arguments]; @try { env = [self of_environmentForDictionary: environment]; #if defined(HAVE_POSIX_SPAWNP) && defined(HAVE_SPAWN_H) posix_spawn_file_actions_t actions; posix_spawnattr_t attr; if (posix_spawn_file_actions_init(&actions) != 0) @throw [OFInitializationFailedException exceptionWithClass: self.class]; |
︙ | ︙ | |||
174 175 176 177 178 179 180 | if (posix_spawnattr_setflags(&attr, POSIX_SPAWN_CLOEXEC_DEFAULT) != 0) @throw [OFInitializationFailedException exceptionWithClass: self.class]; # endif if (posix_spawnp(&_pid, path, &actions, &attr, | | > | | 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | if (posix_spawnattr_setflags(&attr, POSIX_SPAWN_CLOEXEC_DEFAULT) != 0) @throw [OFInitializationFailedException exceptionWithClass: self.class]; # endif if (posix_spawnp(&_pid, path, &actions, &attr, argv, (env != NULL ? env : environ)) != 0) @throw [OFInitializationFailedException exceptionWithClass: self.class]; } @finally { posix_spawn_file_actions_destroy(&actions); posix_spawnattr_destroy(&attr); } #else if ((_pid = vfork()) == 0) { if (env != NULL) environ = env; close(_readPipe[0]); close(_writePipe[1]); dup2(_writePipe[0], 0); dup2(_readPipe[1], 1); execvp(path, argv); |
︙ | ︙ | |||
372 373 374 375 376 377 378 | } - (void)close { if (_readPipe[0] == -1) @throw [OFNotOpenException exceptionWithObject: self]; | > | > | 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 | } - (void)close { if (_readPipe[0] == -1) @throw [OFNotOpenException exceptionWithObject: self]; if (_writePipe[1] != -1) [self closeForWriting]; close(_readPipe[0]); if (_pid != -1) { kill(_pid, SIGTERM); waitpid(_pid, &_status, WNOHANG); } |
︙ | ︙ |
Added src/platform/POSIX/OFSystemInfo+NetworkInterfaces.m version [d2c08c8ec3].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #ifdef HAVE_SYS_IOCTL_H # include <sys/ioctl.h> #endif #ifdef OF_HAVE_SYS_SOCKET_H # include <sys/socket.h> #endif #ifdef HAVE_SYS_SOCKIO_H # include <sys/sockio.h> #endif #ifdef HAVE_NET_IF_H # include <net/if.h> #endif #ifdef HAVE_NET_IF_ARP_H # include <net/if_arp.h> #endif #ifdef HAVE_NET_IF_DL_H # include <net/if_dl.h> #endif #ifdef HAVE_NET_IF_TYPES_H # include <net/if_types.h> #endif #import "OFSystemInfo.h" #import "OFSystemInfo+NetworkInterfaces.h" #import "OFArray.h" #import "OFData.h" #import "OFDictionary.h" #ifdef OF_HAVE_FILES #import "OFFile.h" #endif #import "OFLocale.h" #import "OFNumber.h" #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFString.h" #import "OFInvalidFormatException.h" #import "OFOpenItemFailedException.h" @implementation OFSystemInfo (NetworkInterfaces) static bool queryNetworkInterfaceIndices(OFMutableDictionary *ret) { #ifdef HAVE_IF_NAMEINDEX OFStringEncoding encoding = [OFLocale encoding]; struct if_nameindex *nameindex = if_nameindex(); if (nameindex == NULL) return false; @try { for (size_t i = 0; nameindex[i].if_index != 0; i++) { OFString *name = [OFString stringWithCString: nameindex[i].if_name encoding: encoding]; OFNumber *idx = [OFNumber numberWithUnsignedInt: nameindex[i].if_index]; OFMutableDictionary *interface = [ret objectForKey: name]; if (interface == nil) { interface = [OFMutableDictionary dictionary]; [ret setObject: interface forKey: name]; } [interface setObject: idx forKey: OFNetworkInterfaceIndex]; } } @finally { if_freenameindex(nameindex); } return true; #else return false; #endif } #if defined(HAVE_IOCTL) && defined(HAVE_NET_IF_H) static bool queryNetworkInterfaceAddresses(OFMutableDictionary *ret, OFNetworkInterfaceKey key, OFSocketAddressFamily addressFamily, int family, size_t sockaddrSize) { OFStringEncoding encoding = [OFLocale encoding]; int sock = socket(family, SOCK_DGRAM, 0); OFMutableDictionary *interface; OFEnumerator *enumerator; if (sock < 0) return false; # if defined(HAVE_STRUCT_LIFCONF) && defined(SIOCGLIFCONF) struct lifconf lifc; struct lifreq *lifrs; if ((lifrs = malloc(128 * sizeof(struct lifreq))) == NULL) { closesocket(sock); return false; } @try { char *buffer; memset(&lifc, 0, sizeof(lifc)); lifc.lifc_buf = (void *)lifrs; lifc.lifc_len = 128 * sizeof(struct lifreq); if (ioctl(sock, SIOCGLIFCONF, &lifc) < 0) return false; for (buffer = lifc.lifc_buf; buffer < (char *)lifc.lifc_buf + lifc.lifc_len; buffer += sizeof(struct lifreq)) { struct lifreq *current = (struct lifreq *)(void *)buffer; OFString *name; OFMutableData *addresses; OFSocketAddress address; if (current->lifr_addr.ss_family != family) continue; name = [OFString stringWithCString: current->lifr_name encoding: encoding]; if ((interface = [ret objectForKey: name]) == nil) { interface = [OFMutableDictionary dictionary]; [ret setObject: interface forKey: name]; } addresses = [interface objectForKey: key]; if (addresses == nil) { addresses = [OFMutableData dataWithItemSize: sizeof(OFSocketAddress)]; [interface setObject: addresses forKey: key]; } memset(&address, 0, sizeof(address)); address.family = addressFamily; memcpy(&address.sockaddr.in, ¤t->lifr_addr, sockaddrSize); # if defined(OF_HAVE_IPV6) && defined(HAVE_IF_NAMETOINDEX) if (address.sockaddr.in6.sin6_family == AF_INET6 && address.sockaddr.in6.sin6_addr.s6_addr[0] == 0xFE && (address.sockaddr.in6.sin6_addr.s6_addr[1] & 0xC0) == 0x80) address.sockaddr.in6.sin6_scope_id = if_nametoindex( [name cStringWithEncoding: encoding]); # endif [addresses addItem: &address]; } } @finally { free(lifrs); closesocket(sock); } # else struct ifconf ifc; struct ifreq *ifrs; if (sock < 0) return false; if ((ifrs = malloc(128 * sizeof(struct ifreq))) == NULL) { closesocket(sock); return false; } @try { char *buffer; memset(&ifc, 0, sizeof(ifc)); ifc.ifc_buf = (void *)ifrs; ifc.ifc_len = 128 * sizeof(struct ifreq); if (ioctl(sock, SIOCGIFCONF, &ifc) < 0) return false; buffer = ifc.ifc_buf; while (buffer < (char *)ifc.ifc_buf + ifc.ifc_len) { struct ifreq *current = (struct ifreq *)(void *)buffer; OFString *name; OFMutableData *addresses; OFSocketAddress address; if (current->ifr_addr.sa_family != family) goto next; name = [OFString stringWithCString: current->ifr_name encoding: encoding]; if ((interface = [ret objectForKey: name]) == nil) { interface = [OFMutableDictionary dictionary]; [ret setObject: interface forKey: name]; } addresses = [interface objectForKey: key]; if (addresses == nil) { addresses = [OFMutableData dataWithItemSize: sizeof(OFSocketAddress)]; [interface setObject: addresses forKey: key]; } memset(&address, 0, sizeof(address)); address.family = addressFamily; memcpy(&address.sockaddr.in, ¤t->ifr_addr, sockaddrSize); # if defined(OF_HAVE_IPV6) && defined(HAVE_IF_NAMETOINDEX) if (address.sockaddr.in6.sin6_family == AF_INET6 && address.sockaddr.in6.sin6_addr.s6_addr[0] == 0xFE && (address.sockaddr.in6.sin6_addr.s6_addr[1] & 0xC0) == 0x80) { # if defined(__KAME__) # define addr6 address.sockaddr.in6.sin6_addr.s6_addr address.sockaddr.in6.sin6_scope_id = (addr6[2] << 8) | addr6[3]; addr6[2] = addr6[3] = 0; # undef addr6 # elif defined(HAVE_IF_NAMETOINDEX) address.sockaddr.in6.sin6_scope_id = if_nametoindex( [name cStringWithEncoding: encoding]); # endif } # endif [addresses addItem: &address]; next: # ifdef HAVE_STRUCT_SOCKADDR_SA_LEN if (current->ifr_addr.sa_len > sizeof(struct sockaddr)) buffer += sizeof(struct ifreq) - sizeof(struct sockaddr) + current->ifr_addr.sa_len; else # endif buffer += sizeof(struct ifreq); } } @finally { free(ifrs); closesocket(sock); } # endif enumerator = [ret objectEnumerator]; while ((interface = [enumerator nextObject]) != nil) [[interface objectForKey: key] makeImmutable]; return true; } #endif static bool queryNetworkInterfaceIPv4Addresses(OFMutableDictionary *ret) { #if defined(HAVE_IOCTL) && defined(HAVE_NET_IF_H) return queryNetworkInterfaceAddresses(ret, OFNetworkInterfaceIPv4Addresses, OFSocketAddressFamilyIPv4, AF_INET, sizeof(struct sockaddr_in)); #else return false; #endif } #ifdef OF_HAVE_IPV6 static bool queryNetworkInterfaceIPv6Addresses(OFMutableDictionary *ret) { # if defined(OF_LINUX) && defined(OF_HAVE_FILES) # ifdef HAVE_IF_NAMETOINDEX OFStringEncoding encoding = [OFLocale encoding]; # endif OFFile *file; OFString *line; OFMutableDictionary *interface; OFEnumerator *enumerator; @try { file = [OFFile fileWithPath: @"/proc/net/if_inet6" mode: @"r"]; } @catch (OFOpenItemFailedException *e) { return false; } while ((line = [file readLine]) != nil) { OFArray *components = [line componentsSeparatedByString: @" " options: OFStringSkipEmptyComponents]; OFString *addressString, *name; OFSocketAddress address; OFMutableData *addresses; if (components.count < 6) continue; addressString = [components objectAtIndex: 0]; name = [components objectAtIndex: 5]; if (addressString.length != 32) continue; if ((interface = [ret objectForKey: name]) == nil) { interface = [OFMutableDictionary dictionary]; [ret setObject: interface forKey: name]; } memset(&address, 0, sizeof(address)); address.family = OFSocketAddressFamilyIPv6; address.sockaddr.in6.sin6_family = AF_INET6; for (size_t i = 0; i < 32; i += 2) { unsigned long long byte; @try { byte = [[addressString substringWithRange: OFMakeRange(i, 2)] unsignedLongLongValueWithBase: 16]; } @catch (OFInvalidFormatException *e) { goto next_line; } if (byte > 0xFF) goto next_line; address.sockaddr.in6.sin6_addr.s6_addr[i / 2] = (unsigned char)byte; } # ifdef HAVE_IF_NAMETOINDEX if (address.sockaddr.in6.sin6_addr.s6_addr[0] == 0xFE && (address.sockaddr.in6.sin6_addr.s6_addr[1] & 0xC0) == 0x80) address.sockaddr.in6.sin6_scope_id = if_nametoindex( [name cStringWithEncoding: encoding]); # endif if ((addresses = [interface objectForKey: OFNetworkInterfaceIPv6Addresses]) == nil) { addresses = [OFMutableData dataWithItemSize: sizeof(OFSocketAddress)]; [interface setObject: addresses forKey: OFNetworkInterfaceIPv6Addresses]; } [addresses addItem: &address]; next_line: continue; } enumerator = [ret objectEnumerator]; while ((interface = [enumerator nextObject]) != nil) [[interface objectForKey: OFNetworkInterfaceIPv6Addresses] makeImmutable]; return false; # elif defined(HAVE_IOCTL) && defined(HAVE_NET_IF_H) return queryNetworkInterfaceAddresses(ret, OFNetworkInterfaceIPv6Addresses, OFSocketAddressFamilyIPv6, AF_INET6, sizeof(struct sockaddr_in6)); # else return false; # endif } #endif #ifdef OF_HAVE_IPX static bool queryNetworkInterfaceIPXAddresses(OFMutableDictionary *ret) { # if defined(OF_LINUX) && defined(OF_HAVE_FILES) OFFile *file; OFString *line; OFMutableDictionary *interface; OFEnumerator *enumerator; @try { file = [OFFile fileWithPath: @"/proc/net/ipx/interface" mode: @"r"]; } @catch (OFOpenItemFailedException *e) { return false; } /* First line is "Network Node_Address Primary Device Frame_Type" */ if (![[file readLine] hasPrefix: @"Network "]) return false; while ((line = [file readLine]) != nil) { OFArray *components = [line componentsSeparatedByString: @" " options: OFStringSkipEmptyComponents]; OFString *name; unsigned long long network, nodeLong; unsigned char node[IPX_NODE_LEN]; OFSocketAddress address; OFMutableData *addresses; if (components.count < 5) continue; name = [components objectAtIndex: 3]; if ((interface = [ret objectForKey: name]) == nil) { interface = [OFMutableDictionary dictionary]; [ret setObject: interface forKey: name]; } @try { network = [[components objectAtIndex: 0] unsignedLongLongValueWithBase: 16]; nodeLong = [[components objectAtIndex: 1] unsignedLongLongValueWithBase: 16]; } @catch (OFInvalidFormatException *e) { continue; } if (network > 0xFFFFFFFF || nodeLong > 0xFFFFFFFFFFFF) continue; node[0] = (nodeLong >> 40) & 0xFF; node[1] = (nodeLong >> 32) & 0xFF; node[2] = (nodeLong >> 24) & 0xFF; node[3] = (nodeLong >> 16) & 0xFF; node[4] = (nodeLong >> 8) & 0xFF; node[5] = nodeLong & 0xFF; address = OFSocketAddressMakeIPX((uint32_t)network, node, 0); if ((addresses = [interface objectForKey: OFNetworkInterfaceIPXAddresses]) == nil) { addresses = [OFMutableData dataWithItemSize: sizeof(OFSocketAddress)]; [interface setObject: addresses forKey: OFNetworkInterfaceIPXAddresses]; } [addresses addItem: &address]; } enumerator = [ret objectEnumerator]; while ((interface = [enumerator nextObject]) != nil) [[interface objectForKey: OFNetworkInterfaceIPXAddresses] makeImmutable]; return false; # elif defined(HAVE_IOCTL) && defined(HAVE_NET_IF_H) return queryNetworkInterfaceAddresses(ret, OFNetworkInterfaceIPXAddresses, OFSocketAddressFamilyIPX, AF_IPX, sizeof(struct sockaddr_ipx)); # else return false; # endif } #endif #ifdef OF_HAVE_APPLETALK static bool queryNetworkInterfaceAppleTalkAddresses(OFMutableDictionary *ret) { # if defined(OF_LINUX) && defined(OF_HAVE_FILES) OFFile *file; OFString *line; OFMutableDictionary *interface; OFEnumerator *enumerator; @try { file = [OFFile fileWithPath: @"/proc/net/atalk/interface" mode: @"r"]; } @catch (OFOpenItemFailedException *e) { return false; } /* First line is "Interface Address Networks Status" */ if (![[file readLine] hasPrefix: @"Interface "]) return false; while ((line = [file readLine]) != nil) { OFArray *components = [line componentsSeparatedByString: @" " options: OFStringSkipEmptyComponents]; OFString *addressString, *name; unsigned long long network, node; OFSocketAddress address; OFMutableData *addresses; if (components.count < 4) continue; name = [components objectAtIndex: 0]; addressString = [components objectAtIndex: 1]; if (addressString.length != 7 || [addressString characterAtIndex: 4] != ':') continue; if ((interface = [ret objectForKey: name]) == nil) { interface = [OFMutableDictionary dictionary]; [ret setObject: interface forKey: name]; } @try { network = [[addressString substringWithRange: OFMakeRange(0, 4)] unsignedLongLongValueWithBase: 16]; node = [[addressString substringWithRange: OFMakeRange(5, 2)] unsignedLongLongValueWithBase: 16]; } @catch (OFInvalidFormatException *e) { continue; } if (network > 0xFFFF || node > 0xFF) continue; address = OFSocketAddressMakeAppleTalk( (uint16_t)network, (uint8_t)node, 0); if ((addresses = [interface objectForKey: OFNetworkInterfaceAppleTalkAddresses]) == nil) { addresses = [OFMutableData dataWithItemSize: sizeof(OFSocketAddress)]; [interface setObject: addresses forKey: OFNetworkInterfaceAppleTalkAddresses]; } [addresses addItem: &address]; } enumerator = [ret objectEnumerator]; while ((interface = [enumerator nextObject]) != nil) [[interface objectForKey: OFNetworkInterfaceAppleTalkAddresses] makeImmutable]; return false; # elif defined(HAVE_IOCTL) && defined(HAVE_NET_IF_H) return queryNetworkInterfaceAddresses(ret, OFNetworkInterfaceAppleTalkAddresses, OFSocketAddressFamilyAppleTalk, AF_APPLETALK, sizeof(struct sockaddr_at)); # else return false; # endif } #endif static bool queryNetworkInterfaceHardwareAddress(OFMutableDictionary *ret) { #if defined(HAVE_IOCTL) && defined(HAVE_NET_IF_H) && defined(SIOCGLIFHWADDR) OFStringEncoding encoding = [OFLocale encoding]; int sock = socket(AF_INET, SOCK_DGRAM, 0); if (sock < 0) return false; for (OFString *name in ret) { size_t nameLength = [name cStringLengthWithEncoding: encoding]; struct lifreq lifr; struct sockaddr_dl *sdl; OFData *hardwareAddress; if (nameLength > IFNAMSIZ) continue; memset(&lifr, 0, sizeof(lifr)); memcpy(&lifr.lifr_name, [name cStringWithEncoding: encoding], nameLength); if (ioctl(sock, SIOCGLIFHWADDR, &lifr) < 0) continue; if (lifr.lifr_addr.ss_family != AF_LINK) continue; sdl = (struct sockaddr_dl *)(void *)&lifr.lifr_addr; hardwareAddress = [OFData dataWithItems: LLADDR(sdl) count: sdl->sdl_alen]; [[ret objectForKey: name] setObject: hardwareAddress forKey: OFNetworkInterfaceHardwareAddress]; } return true; #elif defined(HAVE_IOCTL) && defined(HAVE_NET_IF_H) && \ defined(SIOCGIFHWADDR) && defined(HAVE_STRUCT_IFREQ_IFR_HWADDR) OFStringEncoding encoding = [OFLocale encoding]; int sock = socket(AF_INET, SOCK_DGRAM, 0); if (sock < 0) return false; for (OFString *name in ret) { size_t nameLength = [name cStringLengthWithEncoding: encoding]; struct ifreq ifr; OFData *hardwareAddress; if (nameLength > IFNAMSIZ) continue; memset(&ifr, 0, sizeof(ifr)); memcpy(&ifr.ifr_name, [name cStringWithEncoding: encoding], nameLength); if (ioctl(sock, SIOCGIFHWADDR, &ifr) < 0) continue; if (ifr.ifr_hwaddr.sa_family != ARPHRD_ETHER) continue; hardwareAddress = [OFData dataWithItems: ifr.ifr_hwaddr.sa_data count: 6]; [[ret objectForKey: name] setObject: hardwareAddress forKey: OFNetworkInterfaceHardwareAddress]; } return true; #elif defined(HAVE_IOCTL) && defined(HAVE_NET_IF_H) && \ defined(HAVE_STRUCT_SOCKADDR_DL) && defined(IFT_ETHER) OFStringEncoding encoding = [OFLocale encoding]; int sock = socket(AF_INET, SOCK_DGRAM, 0); struct ifconf ifc; struct ifreq *ifrs; if (sock < 0) return false; ifrs = malloc(128 * sizeof(struct ifreq)); if (ifrs == NULL) { closesocket(sock); return false; } @try { char *buffer; memset(&ifc, 0, sizeof(ifc)); ifc.ifc_buf = (void *)ifrs; ifc.ifc_len = 128 * sizeof(struct ifreq); if (ioctl(sock, SIOCGIFCONF, &ifc) < 0) return false; buffer = ifc.ifc_buf; while (buffer < (char *)ifc.ifc_buf + ifc.ifc_len) { struct ifreq *current = (struct ifreq *)(void *)buffer; struct sockaddr_dl *sdl; OFString *name; OFMutableDictionary *interface; OFData *hardwareAddress; if (current->ifr_addr.sa_family != AF_LINK) goto next; sdl = (struct sockaddr_dl *)(void *)¤t->ifr_addr; if (sdl->sdl_type != IFT_ETHER) goto next; name = [OFString stringWithCString: current->ifr_name encoding: encoding]; if ((interface = [ret objectForKey: name]) == nil) { interface = [OFMutableDictionary dictionary]; [ret setObject: interface forKey: name]; } hardwareAddress = [OFData dataWithItems: LLADDR(sdl) count: sdl->sdl_alen]; [interface setObject: hardwareAddress forKey: OFNetworkInterfaceHardwareAddress]; next: # ifdef _SIZEOF_ADDR_IFREQ buffer += _SIZEOF_ADDR_IFREQ(*current); # else buffer += sizeof(struct ifreq); # endif } } @finally { free(ifrs); closesocket(sock); } return true; #else return false; #endif } + (OFDictionary OF_GENERIC(OFString *, OFNetworkInterface) *)networkInterfaces { void *pool = objc_autoreleasePoolPush(); OFMutableDictionary *ret = [OFMutableDictionary dictionary]; bool success = false; OFEnumerator *enumerator; OFMutableDictionary *interface; success |= queryNetworkInterfaceIndices(ret); success |= queryNetworkInterfaceIPv4Addresses(ret); #ifdef OF_HAVE_IPV6 success |= queryNetworkInterfaceIPv6Addresses(ret); #endif #ifdef OF_HAVE_IPX success |= queryNetworkInterfaceIPXAddresses(ret); #endif #ifdef OF_HAVE_APPLETALK success |= queryNetworkInterfaceAppleTalkAddresses(ret); #endif success |= queryNetworkInterfaceHardwareAddress(ret); if (!success) { objc_autoreleasePoolPop(pool); return nil; } enumerator = [ret objectEnumerator]; while ((interface = [enumerator nextObject]) != nil) [interface makeImmutable]; [ret makeImmutable]; [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } @end |
Modified src/platform/POSIX/OFTLSKey.m from [e854931fa2] to [3493369f5c].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFTLSKey.h" int |
︙ | ︙ |
Modified src/platform/PowerPC/OFAtomic.h from [d8964b5a28] to [479e192b76].
1 | /* | | | | | | > > > > | < > | | | > | | > | | > | | > | | > | | > | | | | | | | | | | > | | > | | > | | > | | > | | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ static OF_INLINE int OFAtomicIntAdd(volatile int *_Nonnull p, int i) { __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %2\n\t" "add %0, %0, %1\n\t" "stwcx. %0, 0, %2\n\t" "bne- 0b" : "=&r" (i) : "r" (i), "r" (p) : "cc", "memory" ); return i; } static OF_INLINE int32_t OFAtomicInt32Add(volatile int32_t *_Nonnull p, int32_t i) { __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %2\n\t" "add %0, %0, %1\n\t" "stwcx. %0, 0, %2\n\t" "bne- 0b" : "=&r" (i) : "r" (i), "r" (p) : "cc", "memory" ); return i; } static OF_INLINE void *_Nullable OFAtomicPointerAdd(void *volatile _Nullable *_Nonnull p, intptr_t i) { __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %2\n\t" "add %0, %0, %1\n\t" "stwcx. %0, 0, %2\n\t" "bne- 0b" : "=&r" (i) : "r" (i), "r" (p) : "cc", "memory" ); return (void *)i; } static OF_INLINE int OFAtomicIntSubtract(volatile int *_Nonnull p, int i) { __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %2\n\t" "sub %0, %0, %1\n\t" "stwcx. %0, 0, %2\n\t" "bne- 0b" : "=&r" (i) : "r" (i), "r" (p) : "cc", "memory" ); return i; } static OF_INLINE int32_t OFAtomicInt32Subtract(volatile int32_t *_Nonnull p, int32_t i) { __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %2\n\t" "sub %0, %0, %1\n\t" "stwcx. %0, 0, %2\n\t" "bne- 0b" : "=&r" (i) : "r" (i), "r" (p) : "cc", "memory" ); return i; } static OF_INLINE void *_Nullable OFAtomicPointerSubtract(void *volatile _Nullable *_Nonnull p, intptr_t i) { __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %2\n\t" "sub %0, %0, %1\n\t" "stwcx. %0, 0, %2\n\t" "bne- 0b" : "=&r" (i) : "r" (i), "r" (p) : "cc", "memory" ); return (void *)i; } static OF_INLINE int OFAtomicIntIncrease(volatile int *_Nonnull p) { int i; __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %1\n\t" "addi %0, %0, 1\n\t" "stwcx. %0, 0, %1\n\t" "bne- 0b" : "=&r" (i) : "r" (p) : "cc", "memory" ); return i; } static OF_INLINE int32_t OFAtomicInt32Increase(volatile int32_t *_Nonnull p) { int32_t i; __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %1\n\t" "addi %0, %0, 1\n\t" "stwcx. %0, 0, %1\n\t" "bne- 0b" : "=&r" (i) : "r" (p) : "cc", "memory" ); return i; } static OF_INLINE int OFAtomicIntDecrease(volatile int *_Nonnull p) { int i; __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %1\n\t" "subi %0, %0, 1\n\t" "stwcx. %0, 0, %1\n\t" "bne- 0b" : "=&r" (i) : "r" (p) : "cc", "memory" ); return i; } static OF_INLINE int32_t OFAtomicInt32Decrease(volatile int32_t *_Nonnull p) { int32_t i; __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %1\n\t" "subi %0, %0, 1\n\t" "stwcx. %0, 0, %1\n\t" "bne- 0b" : "=&r" (i) : "r" (p) : "cc", "memory" ); return i; } static OF_INLINE unsigned int OFAtomicIntOr(volatile unsigned int *_Nonnull p, unsigned int i) { __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %2\n\t" "or %0, %0, %1\n\t" "stwcx. %0, 0, %2\n\t" "bne- 0b" : "=&r" (i) : "r" (i), "r" (p) : "cc", "memory" ); return i; } static OF_INLINE uint32_t OFAtomicInt32Or(volatile uint32_t *_Nonnull p, uint32_t i) { __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %2\n\t" "or %0, %0, %1\n\t" "stwcx. %0, 0, %2\n\t" "bne- 0b" : "=&r" (i) : "r" (i), "r" (p) : "cc", "memory" ); return i; } static OF_INLINE unsigned int OFAtomicIntAnd(volatile unsigned int *_Nonnull p, unsigned int i) { __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %2\n\t" "and %0, %0, %1\n\t" "stwcx. %0, 0, %2\n\t" "bne- 0b" : "=&r" (i) : "r" (i), "r" (p) : "cc", "memory" ); return i; } static OF_INLINE uint32_t OFAtomicInt32And(volatile uint32_t *_Nonnull p, uint32_t i) { __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %2\n\t" "and %0, %0, %1\n\t" "stwcx. %0, 0, %2\n\t" "bne- 0b" : "=&r" (i) : "r" (i), "r" (p) : "cc", "memory" ); return i; } static OF_INLINE unsigned int OFAtomicIntXor(volatile unsigned int *_Nonnull p, unsigned int i) { __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %2\n\t" "xor %0, %0, %1\n\t" "stwcx. %0, 0, %2\n\t" "bne- 0b" : "=&r" (i) : "r" (i), "r" (p) : "cc", "memory" ); return i; } static OF_INLINE uint32_t OFAtomicInt32Xor(volatile uint32_t *_Nonnull p, uint32_t i) { __asm__ __volatile__ ( "0:\n\t" "lwarx %0, 0, %2\n\t" "xor %0, %0, %1\n\t" "stwcx. %0, 0, %2\n\t" "bne- 0b" : "=&r" (i) : "r" (i), "r" (p) : "cc", "memory" ); return i; } static OF_INLINE bool |
︙ | ︙ | |||
307 308 309 310 311 312 313 | "bne- 0b\n\t" "li %0, 1\n\t" "b 2f\n\t" "1:\n\t" "stwcx. %0, 0, %3\n\t" "li %0, 0\n\t" "2:" | | | > > | 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | "bne- 0b\n\t" "li %0, 1\n\t" "b 2f\n\t" "1:\n\t" "stwcx. %0, 0, %3\n\t" "li %0, 0\n\t" "2:" : "=&r" (r) : "r" (o), "r" (n), "r" (p) : "cc", "memory" ); return r; } static OF_INLINE bool |
︙ | ︙ | |||
333 334 335 336 337 338 339 | "bne- 0b\n\t" "li %0, 1\n\t" "b 2f\n\t" "1:\n\t" "stwcx. %0, 0, %3\n\t" "li %0, 0\n\t" "2:" | | | > > | 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 | "bne- 0b\n\t" "li %0, 1\n\t" "b 2f\n\t" "1:\n\t" "stwcx. %0, 0, %3\n\t" "li %0, 0\n\t" "2:" : "=&r" (r) : "r" (o), "r" (n), "r" (p) : "cc", "memory" ); return r; } static OF_INLINE bool |
︙ | ︙ | |||
360 361 362 363 364 365 366 | "bne- 0b\n\t" "li %0, 1\n\t" "b 2f\n\t" "1:\n\t" "stwcx. %0, 0, %3\n\t" "li %0, 0\n\t" "2:" | | | > > | 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 | "bne- 0b\n\t" "li %0, 1\n\t" "b 2f\n\t" "1:\n\t" "stwcx. %0, 0, %3\n\t" "li %0, 0\n\t" "2:" : "=&r" (r) : "r" (o), "r" (n), "r" (p) : "cc", "memory" ); return r; } static OF_INLINE void |
︙ | ︙ |
Modified src/platform/Windows/OFPlainCondition.m from [cd952f15d7] to [f7d1dbe9d0].
1 | /* | | | | | | > > > > | < > | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #import "OFPlainCondition.h" #import "OFConstantString.h" #include <windows.h> int OFPlainConditionNew(OFPlainCondition *condition) { condition->count = 0; |
︙ | ︙ |
Modified src/platform/Windows/OFPlainMutex.m from [f924adddc3] to [4912aad5bc].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #import "OFPlainMutex.h" |
︙ | ︙ |
Modified src/platform/Windows/OFPlainThread.m from [d2bc6a9806] to [2ecb1d0001].
1 | /* | | | | | | > > > > | < > | < | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #import "OFPlainThread.h" #import "OFConstantString.h" #include <windows.h> struct ThreadContext { void (*function)(id); id object; }; |
︙ | ︙ |
Modified src/platform/Windows/OFString+PathAdditions.m from [ec08b34f89] to [f70d14f528].
1 | /* | | | | | | > > > > | < > | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ /* * This file is also used for MS-DOS and MiNT! Don't forget to #ifdef * Windows-specific parts! */ #include "config.h" #import "OFString+PathAdditions.h" #import "OFArray.h" #import "OFFileIRIHandler.h" #import "OFIRI.h" #import "OFInvalidFormatException.h" #import "OFOutOfRangeException.h" int _OFString_PathAdditions_reference; @implementation OFString (PathAdditions) |
︙ | ︙ | |||
301 302 303 304 305 306 307 308 309 310 311 312 313 314 | objc_autoreleasePoolPop(pool); return [ret autorelease]; } - (OFString *)stringByAppendingPathComponent: (OFString *)component { if ([self hasSuffix: @"\\"] || [self hasSuffix: @"/"]) return [self stringByAppendingString: component]; else { OFMutableString *ret = [[self mutableCopy] autorelease]; [ret appendString: @"\\"]; [ret appendString: component]; | > > > | 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | objc_autoreleasePoolPop(pool); return [ret autorelease]; } - (OFString *)stringByAppendingPathComponent: (OFString *)component { if (self.length == 0) return component; if ([self hasSuffix: @"\\"] || [self hasSuffix: @"/"]) return [self stringByAppendingString: component]; else { OFMutableString *ret = [[self mutableCopy] autorelease]; [ret appendString: @"\\"]; [ret appendString: component]; |
︙ | ︙ | |||
339 340 341 342 343 344 345 | } else return [self stringByAppendingFormat: @".%@", extension]; } - (bool)of_isDirectoryPath { return ([self hasSuffix: @"\\"] || [self hasSuffix: @"/"] || | | | | | | 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 | } else return [self stringByAppendingFormat: @".%@", extension]; } - (bool)of_isDirectoryPath { return ([self hasSuffix: @"\\"] || [self hasSuffix: @"/"] || [OFFileIRIHandler of_directoryExistsAtPath: self]); } - (OFString *)of_pathToIRIPathWithPercentEncodedHost: (OFString **)percentEncodedHost { OFString *path = self; if ([path hasPrefix: @"\\\\"]) { OFArray *components = path.pathComponents; if (components.count < 2) @throw [OFInvalidFormatException exception]; *percentEncodedHost = [[components objectAtIndex: 1] stringByAddingPercentEncodingWithAllowedCharacters: [OFCharacterSet IRIHostAllowedCharacterSet]]; path = [OFString pathWithComponents: [components objectsInRange: OFMakeRange(2, components.count - 2)]]; } path = [path stringByReplacingOccurrencesOfString: @"\\" withString: @"/"]; path = [@"/" stringByAppendingString: path]; return path; } - (OFString *)of_IRIPathToPathWithPercentEncodedHost: (OFString *)percentEncodedHost { OFString *path = self; if (path.length > 1 && [path hasSuffix: @"/"] && ![path hasSuffix: @":/"]) path = [path substringToIndex: path.length - 1]; |
︙ | ︙ | |||
394 395 396 397 398 399 400 | path = [OFString stringWithFormat: @"\\\\%@\\%@", host, path]; } return path; } | | | 401 402 403 404 405 406 407 408 409 410 411 412 413 | path = [OFString stringWithFormat: @"\\\\%@\\%@", host, path]; } return path; } - (OFString *)of_pathComponentToIRIPathComponent { return [self stringByReplacingOccurrencesOfString: @"\\" withString: @"/"]; } @end |
Modified src/platform/Windows/OFSubprocess.m from [bef5ba2521] to [eef05a7c89].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #include <string.h> |
︙ | ︙ | |||
379 380 381 382 383 384 385 | } - (void)close { if (_readPipe[0] == NULL) @throw [OFNotOpenException exceptionWithObject: self]; | > | > | 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 | } - (void)close { if (_readPipe[0] == NULL) @throw [OFNotOpenException exceptionWithObject: self]; if (_writePipe[1] != NULL) [self closeForWriting]; CloseHandle(_readPipe[0]); if (_handle != INVALID_HANDLE_VALUE) { TerminateProcess(_handle, 0); CloseHandle(_handle); } |
︙ | ︙ |
Added src/platform/Windows/OFSystemInfo+NetworkInterfaces.m version [2f7e13725d].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFSystemInfo.h" #import "OFSystemInfo+NetworkInterfaces.h" #import "OFData.h" #import "OFDictionary.h" #import "OFLocale.h" #import "OFNumber.h" #import "OFOnce.h" #import "OFSocket.h" #import "OFString.h" #include <windows.h> #define interface struct #include <iphlpapi.h> #undef interface static WINAPI ULONG (*GetAdaptersAddressesFuncPtr)(ULONG, ULONG, PVOID, PIP_ADAPTER_ADDRESSES, PULONG); static void init(void) { HMODULE module; if ((module = GetModuleHandle("iphlpapi.dll")) != NULL) GetAdaptersAddressesFuncPtr = (WINAPI ULONG (*)(ULONG, ULONG, PVOID, PIP_ADAPTER_ADDRESSES, PULONG)) GetProcAddress(module, "GetAdaptersAddresses"); } static OFMutableDictionary OF_GENERIC(OFString *, OFNetworkInterface) * networkInterfacesFromGetAdaptersAddresses(void) { OFMutableDictionary *ret = [OFMutableDictionary dictionary]; ULONG adapterAddressesSize = sizeof(IP_ADAPTER_ADDRESSES); PIP_ADAPTER_ADDRESSES adapterAddresses; if ((adapterAddresses = malloc(adapterAddressesSize)) == NULL) return nil; @try { OFStringEncoding encoding = [OFLocale encoding]; ULONG error = GetAdaptersAddressesFuncPtr(AF_UNSPEC, 0, NULL, adapterAddresses, &adapterAddressesSize); if (error == ERROR_BUFFER_OVERFLOW) { PIP_ADAPTER_ADDRESSES newAdapterAddresses = realloc(adapterAddresses, adapterAddressesSize); if (newAdapterAddresses == NULL) return nil; adapterAddresses = newAdapterAddresses; error = GetAdaptersAddressesFuncPtr(AF_UNSPEC, 0, NULL, adapterAddresses, &adapterAddressesSize); } if (error != ERROR_SUCCESS) return nil; for (PIP_ADAPTER_ADDRESSES iter = adapterAddresses; iter != NULL; iter = iter->Next) { OFString *name; OFMutableDictionary *interface; OFNumber *index; name = [OFString stringWithCString: iter->AdapterName encoding: encoding]; if ((interface = [ret objectForKey: name]) == nil) { interface = [OFMutableDictionary dictionary]; [ret setObject: interface forKey: name]; } index = [OFNumber numberWithUnsignedInt: iter->IfIndex]; [interface setObject: index forKey: OFNetworkInterfaceIndex]; if (iter->PhysicalAddressLength > 0) { const OFNetworkInterfaceKey key = OFNetworkInterfaceHardwareAddress; OFData *address = [OFData dataWithItems: iter->PhysicalAddress count: iter->PhysicalAddressLength]; [interface setObject: address forKey: key]; } for (__typeof__(iter->FirstUnicastAddress) addrIter = iter->FirstUnicastAddress; addrIter != NULL; addrIter = addrIter->Next) { OFSocketAddress address; int length; OFNetworkInterfaceKey key; OFMutableData *addresses; length = (int)sizeof(address.sockaddr); if (length > addrIter->Address.iSockaddrLength) length = addrIter->Address.iSockaddrLength; memset(&address, 0, sizeof(OFSocketAddress)); memcpy(&address.sockaddr, addrIter->Address.lpSockaddr, (size_t)length); switch (address.sockaddr.in.sin_family) { case AF_INET: address.family = OFSocketAddressFamilyIPv4; key = OFNetworkInterfaceIPv4Addresses; break; case AF_INET6: address.family = OFSocketAddressFamilyIPv6; key = OFNetworkInterfaceIPv6Addresses; break; default: continue; } addresses = [interface objectForKey: key]; if (addresses == nil) { addresses = [OFMutableData dataWithItemSize: sizeof(OFSocketAddress)]; [interface setObject: addresses forKey: key]; } [addresses addItem: &address]; } [[interface objectForKey: OFNetworkInterfaceIPv4Addresses] makeImmutable]; [[interface objectForKey: OFNetworkInterfaceIPv6Addresses] makeImmutable]; } } @finally { free(adapterAddresses); } return ret; } static OFMutableDictionary OF_GENERIC(OFString *, OFNetworkInterface) * networkInterfacesFromGetAdaptersInfo(void) { OFMutableDictionary *ret = [OFMutableDictionary dictionary]; OFStringEncoding encoding = [OFLocale encoding]; ULONG adapterInfoSize = sizeof(IP_ADAPTER_INFO); PIP_ADAPTER_INFO adapterInfo; if ((adapterInfo = malloc(adapterInfoSize)) == NULL) return nil; @try { ULONG error = GetAdaptersInfo(adapterInfo, &adapterInfoSize); if (error == ERROR_BUFFER_OVERFLOW) { PIP_ADAPTER_INFO newAdapterInfo = realloc(adapterInfo, adapterInfoSize); if (newAdapterInfo == NULL) return nil; adapterInfo = newAdapterInfo; error = GetAdaptersInfo(adapterInfo, &adapterInfoSize); } if (error != ERROR_SUCCESS) return nil; for (PIP_ADAPTER_INFO iter = adapterInfo; iter != NULL; iter = iter->Next) { OFMutableDictionary *interface; OFString *name, *IPString; OFNumber *index; OFSocketAddress IPv4Address; OFData *addresses; name = [OFString stringWithFormat: @"%u", iter->Index]; if ((interface = [ret objectForKey: name]) == nil) { interface = [OFMutableDictionary dictionary]; [ret setObject: interface forKey: name]; } index = [OFNumber numberWithUnsignedInt: iter->Index]; [interface setObject: index forKey: OFNetworkInterfaceIndex]; if (iter->AddressLength > 0) { const OFNetworkInterfaceKey key = OFNetworkInterfaceHardwareAddress; OFData *address = [OFData dataWithItems: iter->Address count: iter->AddressLength]; [interface setObject: address forKey: key]; } IPString = [OFString stringWithCString: iter->IpAddressList.IpAddress .String encoding: encoding]; if ([IPString isEqual: @"0.0.0.0"]) continue; IPv4Address = OFSocketAddressParseIPv4(IPString, 0); addresses = [OFData dataWithItems: &IPv4Address count: 1 itemSize: sizeof(IPv4Address)]; [interface setObject: addresses forKey: OFNetworkInterfaceIPv4Addresses]; } } @finally { free(adapterInfo); } return ret; } @implementation OFSystemInfo (NetworkInterfaces) + (OFDictionary OF_GENERIC(OFString *, OFNetworkInterface) *)networkInterfaces { static OFOnceControl onceControl = OFOnceControlInitValue; void *pool = objc_autoreleasePoolPush(); OFMutableDictionary *ret; OFEnumerator *enumerator; OFMutableDictionary *interface; OFOnce(&onceControl, init); if (GetAdaptersAddressesFuncPtr != NULL) ret = networkInterfacesFromGetAdaptersAddresses(); else ret = networkInterfacesFromGetAdaptersInfo(); enumerator = [ret objectEnumerator]; while ((interface = [enumerator nextObject]) != nil) [interface makeImmutable]; [ret makeImmutable]; [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } @end |
Modified src/platform/Windows/OFTLSKey.m from [819b78979d] to [b23500fef4].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFTLSKey.h" int |
︙ | ︙ |
Modified src/platform/Windows/OFWin32ConsoleStdIOStream.m from [8c3f9ce8af] to [ab386bcc83].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ /* * This file tries to make writing UTF-8 strings to the console "just work" on * Windows. * * While Windows does provide a way to change the codepage of the console to |
︙ | ︙ | |||
35 36 37 38 39 40 41 | * In order to not do this when redirecting input / output to a file (as the * file would then be read / written in the wrong encoding and break reading / * writing binary), it checks that the handle is indeed a console. */ #include "config.h" | < | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | * In order to not do this when redirecting input / output to a file (as the * file would then be read / written in the wrong encoding and break reading / * writing binary), it checks that the handle is indeed a console. */ #include "config.h" #include <errno.h> #include <io.h> #import "OFWin32ConsoleStdIOStream.h" #import "OFColor.h" #import "OFData.h" #import "OFStdIOStream+Private.h" |
︙ | ︙ | |||
291 292 293 294 295 296 297 | if (_incompleteUTF8SurrogateLen < (size_t)UTF8Len) return 0; UTF8Len = OFUTF8StringDecode( _incompleteUTF8Surrogate, _incompleteUTF8SurrogateLen, &c); if (UTF8Len <= 0 || c > 0x10FFFF) { | | | 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | if (_incompleteUTF8SurrogateLen < (size_t)UTF8Len) return 0; UTF8Len = OFUTF8StringDecode( _incompleteUTF8Surrogate, _incompleteUTF8SurrogateLen, &c); if (UTF8Len <= 0 || c > 0x10FFFF) { OFAssert(UTF8Len == 0 || UTF8Len < -4); UTF16[0] = 0xFFFD; UTF16Len = 1; } else { if (c > 0xFFFF) { c -= 0x10000; UTF16[0] = 0xD800 | (c >> 10); |
︙ | ︙ |
Modified src/platform/libfat/OFString+PathAdditions.m from [6647377f7a] to [32f039ac67].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFString+PathAdditions.h" #import "OFArray.h" #import "OFFileIRIHandler.h" #import "OFOutOfRangeException.h" int _OFString_PathAdditions_reference; @implementation OFString (PathAdditions) + (OFString *)pathWithComponents: (OFArray *)components |
︙ | ︙ | |||
297 298 299 300 301 302 303 304 305 306 307 308 309 310 | objc_autoreleasePoolPop(pool); return [ret autorelease]; } - (OFString *)stringByAppendingPathComponent: (OFString *)component { if ([self hasSuffix: @"/"]) return [self stringByAppendingString: component]; else { OFMutableString *ret = [[self mutableCopy] autorelease]; [ret appendString: @"/"]; [ret appendString: component]; | > > > | 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | objc_autoreleasePoolPop(pool); return [ret autorelease]; } - (OFString *)stringByAppendingPathComponent: (OFString *)component { if (self.length == 0) return component; if ([self hasSuffix: @"/"]) return [self stringByAppendingString: component]; else { OFMutableString *ret = [[self mutableCopy] autorelease]; [ret appendString: @"/"]; [ret appendString: component]; |
︙ | ︙ | |||
335 336 337 338 339 340 341 | } else return [self stringByAppendingFormat: @".%@", extension]; } - (bool)of_isDirectoryPath { return ([self hasSuffix: @"/"] || | | | | | | 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | } else return [self stringByAppendingFormat: @".%@", extension]; } - (bool)of_isDirectoryPath { return ([self hasSuffix: @"/"] || [OFFileIRIHandler of_directoryExistsAtPath: self]); } - (OFString *)of_pathToIRIPathWithPercentEncodedHost: (OFString **)percentEncodedHost { return [@"/" stringByAppendingString: self]; } - (OFString *)of_IRIPathToPathWithPercentEncodedHost: (OFString *)percentEncodedHost { OFString *path = self; if (path.length > 1 && [path hasSuffix: @"/"]) path = [path substringToIndex: path.length - 1]; return [path substringFromIndex: 1]; } - (OFString *)of_pathComponentToIRIPathComponent { return self; } @end |
Modified src/platform/macOS/OFAtomic.h from [af25398c26] to [75832039de].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include <libkern/OSAtomic.h> static OF_INLINE int OFAtomicIntAdd(volatile int *_Nonnull p, int i) { |
︙ | ︙ |
Modified src/platform/x86/OFAtomic.h from [db489edc3a] to [c8b853985d].
1 | /* | | | | | | > > > > | < > | < < < < < < < < < < < < < < < < < < < < < < < < < < < > > > > > > | > > | > > > > > > > > > > > | | > | > > > | | | | | > | | | | > > > > > > > > > > > > > > > > > < < < < < < < | | | | | | | > < < < < < < < < < < < < < < < | | | | | | > | | | | | > > > > > > > > > > > > > > > > > > > < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | | | | | | | | | | | | | | > > < < < < < < < < < < < | | < | < | | | | | < | | | | | | > | < < < < < < < < < < < | | | | | | | | > | | | | | | > | < < < < < < < < < < < | | | | | | | | > | | | | | | > | | | | > > | > > > > | | | < | | > | | > > > | | > > > > > > > | > > > > > > > > > > > > > | > | > | | | > | > > | > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ OF_ASSUME_NONNULL_BEGIN static OF_INLINE int32_t OFAtomicInt32Add(volatile int32_t *_Nonnull p, int32_t i) { __asm__ __volatile__ ( "lock\n\t" "xadd{l} { %0, %2 | %2, %0 }\n\t" "add{l} { %1, %0 | %0, %1 }" : "+&r" (i) : "r" (i), "m" (*p) ); return i; } static OF_INLINE int OFAtomicIntAdd(volatile int *_Nonnull p, int i) { if (sizeof(int) == 4) return OFAtomicInt32Add(p, i); #ifdef OF_AMD64 else if (sizeof(int) == 8) __asm__ __volatile__ ( "lock\n\t" "xadd{q} { %0, %2 | %2, %0 }\n\t" "add{q} { %1, %0 | %0, %1 }" : "+&r" (i) : "r" (i), "m" (*p) ); #endif else abort(); return i; } static OF_INLINE void *_Nullable OFAtomicPointerAdd(void *volatile _Nullable *_Nonnull p, intptr_t i) { #if defined(OF_AMD64) __asm__ __volatile__ ( "lock\n\t" "xadd{q} { %0, %2 | %2, %0 }\n\t" "add{q} { %1, %0 | %0, %1 }" : "+&r" (i) : "r" (i), "m" (*p) ); return (void *)i; #elif defined(OF_X86) __asm__ __volatile__ ( "lock\n\t" "xadd{l} { %0, %2 | %2, %0 }\n\t" "add{l} { %1, %0 | %0, %1 }" : "+&r" (i) : "r" (i), "m" (*p) ); return (void *)i; #endif } static OF_INLINE int32_t OFAtomicInt32Subtract(volatile int32_t *_Nonnull p, int32_t i) { __asm__ __volatile__ ( "neg{l} %0\n\t" "lock\n\t" "xadd{l} { %0, %2 | %2, %0 }\n\t" "sub{l} { %1, %0 | %0, %1 }" : "+&r" (i) : "r" (i), "m" (*p) ); return i; } static OF_INLINE int OFAtomicIntSubtract(volatile int *_Nonnull p, int i) { if (sizeof(int) == 4) return OFAtomicInt32Subtract(p, i); #ifdef OF_AMD64 else if (sizeof(int) == 8) __asm__ __volatile__ ( "neg{q} %0\n\t" "lock\n\t" "xadd{q} { %0, %2 | %2, %0 }\n\t" "sub{q} { %1, %0 | %0, %1 }" : "+&r" (i) : "r" (i), "m" (*p) ); #endif else abort(); return i; } static OF_INLINE void *_Nullable OFAtomicPointerSubtract(void *volatile _Nullable *_Nonnull p, intptr_t i) { #if defined(OF_AMD64) __asm__ __volatile__ ( "neg{q} %0\n\t" "lock\n\t" "xadd{q} { %0, %2 | %2, %0 }\n\t" "sub{q} { %1, %0 | %0, %1 }" : "+&r" (i) : "r" (i), "m" (*p) ); return (void *)i; #elif defined(OF_X86) __asm__ __volatile__ ( "neg{l} %0\n\t" "lock\n\t" "xadd{l} { %0, %2 | %2, %0 }\n\t" "sub{l} { %1, %0 | %0, %1 }" : "+&r" (i) : "r" (i), "m" (*p) ); return (void *)i; #endif } static OF_INLINE int32_t OFAtomicInt32Increase(volatile int32_t *_Nonnull p) { int32_t i; __asm__ __volatile__ ( "xor{l} %0, %0\n\t" "inc{l} %0\n\t" "lock\n\t" "xadd{l} { %0, %1 | %1, %0 }\n\t" "inc{l} %0" : "=&r" (i) : "m" (*p) ); return i; } static OF_INLINE int OFAtomicIntIncrease(volatile int *_Nonnull p) { int i; if (sizeof(int) == 4) return OFAtomicInt32Increase(p); #ifdef OF_AMD64 else if (sizeof(int) == 8) __asm__ __volatile__ ( "xor{q} %0, %0\n\t" "inc{q} %0\n\t" "lock\n\t" "xadd{q} { %0, %1 | %1, %0 }\n\t" "inc{q} %0" : "=&r" (i) : "m" (*p) ); #endif else abort(); return i; } static OF_INLINE int32_t OFAtomicInt32Decrease(volatile int32_t *_Nonnull p) { int32_t i; __asm__ __volatile__ ( "xor{l} %0, %0\n\t" "dec{l} %0\n\t" "lock\n\t" "xadd{l} { %0, %1 | %1, %0 }\n\t" "dec{l} %0" : "=&r" (i) : "m" (*p) ); return i; } static OF_INLINE int OFAtomicIntDecrease(volatile int *_Nonnull p) { int i; if (sizeof(int) == 4) return OFAtomicInt32Decrease(p); #ifdef OF_AMD64 else if (sizeof(int) == 8) __asm__ __volatile__ ( "xor{q} %0, %0\n\t" "dec{q} %0\n\t" "lock\n\t" "xadd{q} { %0, %1 | %1, %0 }\n\t" "dec{q} %0" : "=&r" (i) : "m" (*p) ); #endif else abort(); return i; } static OF_INLINE uint32_t OFAtomicInt32Or(volatile uint32_t *_Nonnull p, uint32_t i) { __asm__ __volatile__ ( "0:\n\t" "mov{l} { %2, %0 | %0, %2 }\n\t" "mov{l} { %0, %%eax | eax, %0 }\n\t" "or{l} { %1, %0 | %0, %1 }\n\t" "lock\n\t" "cmpxchg{l} { %0, %2 | %2, %0 }\n\t" "jne 0b" : "=&r" (i) : "r" (i), "m" (*p) : "eax", "cc" ); return i; } static OF_INLINE unsigned int OFAtomicIntOr(volatile unsigned int *_Nonnull p, unsigned int i) { if (sizeof(int) == 4) return OFAtomicInt32Or(p, i); #ifdef OF_AMD64 else if (sizeof(int) == 8) __asm__ __volatile__ ( "0:\n\t" "mov{q} { %2, %0 | %0, %2 }\n\t" "mov{q} { %0, %%rax | rax, %0 }\n\t" "or{q} { %1, %0 | %0, %1 }\n\t" "lock\n\t" "cmpxchg{q} { %0, %2 | %2, %0 }\n\t" "jne 0b" : "=&r" (i) : "r" (i), "m" (*p) : "rax", "cc" ); #endif else abort(); return i; } static OF_INLINE uint32_t OFAtomicInt32And(volatile uint32_t *_Nonnull p, uint32_t i) { __asm__ __volatile__ ( "0:\n\t" "mov{l} { %2, %0 | %0, %2 }\n\t" "mov{l} { %0, %%eax | eax, %0 }\n\t" "and{l} { %1, %0 | %0, %1 }\n\t" "lock\n\t" "cmpxchg{l} { %0, %2 | %2, %0 }\n\t" "jne 0b" : "=&r" (i) : "r" (i), "m" (*p) : "eax", "cc" ); return i; } static OF_INLINE unsigned int OFAtomicIntAnd(volatile unsigned int *_Nonnull p, unsigned int i) { if (sizeof(int) == 4) return OFAtomicInt32And(p, i); #ifdef OF_AMD64 else if (sizeof(int) == 8) __asm__ __volatile__ ( "0:\n\t" "mov{q} { %2, %0 | %0, %2 }\n\t" "mov{q} { %0, %%rax | rax, %0 }\n\t" "and{q} { %1, %0 | %0, %1 }\n\t" "lock\n\t" "cmpxchg{q} { %0, %2 | %2, %0 }\n\t" "jne 0b" : "=&r" (i) : "r" (i), "m" (*p) : "rax", "cc" ); #endif else abort(); return i; } static OF_INLINE uint32_t OFAtomicInt32Xor(volatile uint32_t *_Nonnull p, uint32_t i) { __asm__ __volatile__ ( "0:\n\t" "mov{l} { %2, %0 | %0, %2 }\n\t" "mov{l} { %0, %%eax | eax, %0 }\n\t" "xor{l} { %1, %0 | %0, %1 }\n\t" "lock\n\t" "cmpxchg{l} { %0, %2 | %2, %0 }\n\t" "jne 0b" : "=&r" (i) : "r" (i), "m" (*p) : "eax", "cc" ); return i; } static OF_INLINE unsigned int OFAtomicIntXor(volatile unsigned int *_Nonnull p, unsigned int i) { if (sizeof(int) == 4) return OFAtomicInt32Xor(p, i); #ifdef OF_AMD64 else if (sizeof(int) == 8) __asm__ __volatile__ ( "0:\n\t" "mov{q} { %2, %0 | %0, %2 }\n\t" "mov{q} { %0, %%rax | rax, %0 }\n\t" "xor{q} { %1, %0 | %0, %1 }\n\t" "lock\n\t" "cmpxchg{q} { %0, %2 | %2, %0 }\n\t" "jne 0b" : "=&r" (i) : "r" (i), "m" (*p) : "rax", "cc" ); #endif else abort(); return i; } static OF_INLINE bool OFAtomicInt32CompareAndSwap(volatile int32_t *_Nonnull p, int32_t o, int32_t n) { int r; __asm__ __volatile__ ( "lock\n\t" "cmpxchg{l} { %2, %3 | %3, %2 }\n\t" "sete %b0\n\t" "movz{bl|x} { %b0, %0 | %0, %b0 }" : "=&d" (r), /* use d instead of r to avoid a gcc bug */ "+a" (o) : "r" (n), "m" (*p) : "cc" ); return r; } static OF_INLINE bool OFAtomicIntCompareAndSwap(volatile int *_Nonnull p, int o, int n) { int r; __asm__ __volatile__ ( "lock\n\t" "cmpxchg { %2, %3 | %3, %2 }\n\t" "sete %b0\n\t" "movz{bl|x} { %b0, %0 | %0, %b0 }" : "=&d" (r), /* use d instead of r to avoid a gcc bug */ "+a" (o) : "r" (n), "m" (*p) : "cc" ); return r; } static OF_INLINE bool OFAtomicPointerCompareAndSwap(void *volatile _Nullable *_Nonnull p, void *_Nullable o, void *_Nullable n) { int r; __asm__ __volatile__ ( "lock\n\t" "cmpxchg { %2, %3 | %3, %2 }\n\t" "sete %b0\n\t" "movz{bl|x} { %b0, %0 | %0, %b0 }" : "=&d" (r), /* use d instead of r to avoid a gcc bug */ "+a" (o) : "r" (n), "m" (*p) : "cc" ); return r; } static OF_INLINE void OFMemoryBarrier(void) { #ifdef OF_AMD64 __asm__ __volatile__ ( "lock or{q} { $0, (%%rsp) | [rsp], 0 }" ::: "memory", "cc" ); #else __asm__ __volatile__ ( "lock or{l} { $0, (%%esp) | [esp], 0 }" ::: "memory", "cc" ); #endif } static OF_INLINE void OFAcquireMemoryBarrier(void) { __asm__ __volatile__ ("" ::: "memory"); } |
︙ | ︙ |
Modified src/runtime/Makefile from [23dfac9b53] to [692471a52e].
1 2 3 | include ../../extra.mk SUBDIRS = lookup-asm | < < > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | include ../../extra.mk SUBDIRS = lookup-asm DISTCLEAN = Info.plist SHARED_LIB = ${OBJFWRT_SHARED_LIB} STATIC_LIB = ${OBJFWRT_STATIC_LIB} FRAMEWORK = ${OBJFWRT_FRAMEWORK} LIB_MAJOR = ${OBJFWRT_LIB_MAJOR} LIB_MINOR = ${OBJFWRT_LIB_MINOR} LIB_PATCH = ${OBJFWRT_LIB_PATCH} SRCS = arc.m \ association.m \ autorelease.m \ category.m \ class.m \ dtable.m \ exception.m \ hashtable.m \ init.m \ |
︙ | ︙ | |||
39 40 41 42 43 44 45 | threading.m SRCS_WINDOWS = versioninfo.rc INCLUDES = ObjFWRT.h includesubdir = ObjFWRT OBJS_EXTRA = lookup-asm/lookup-asm.a LIB_OBJS_EXTRA = lookup-asm/lookup-asm.lib.a | < < < < < < | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | threading.m SRCS_WINDOWS = versioninfo.rc INCLUDES = ObjFWRT.h includesubdir = ObjFWRT OBJS_EXTRA = lookup-asm/lookup-asm.a LIB_OBJS_EXTRA = lookup-asm/lookup-asm.lib.a include ../../buildsys.mk CPPFLAGS += -I. -I.. -I../.. \ -DOBJC_COMPILING_RUNTIME \ -DOBJFWRT_LIB_MAJOR=${OBJFWRT_LIB_MAJOR} \ -DOBJFWRT_LIB_MINOR=${OBJFWRT_LIB_MINOR} LD = ${OBJC} FRAMEWORK_LIBS = ${LIBS} RCFLAGS = --use-temp-file \ -DOBJFWRT_LIB_MAJOR=${OBJFWRT_LIB_MAJOR} \ -DOBJFWRT_LIB_MINOR=${OBJFWRT_LIB_MINOR} \ -DOBJFWRT_LIB_VERSION=\"${OBJFWRT_LIB_MAJOR}.${OBJFWRT_LIB_MINOR}\" \ -DOBJFWRT_SHARED_LIB=\"${OBJFWRT_SHARED_LIB}\" |
Modified src/runtime/OFOnce.m from [9cc54fa246] to [4cc1e7e57e].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFWRT.h" #import "private.h" |
︙ | ︙ |
Modified src/runtime/OFPlainMutex.m from [1b4abcc3c8] to [bc6887b3cd].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFWRT.h" #import "private.h" |
︙ | ︙ |
Modified src/runtime/OFTLSKey.m from [c512b1fdd8] to [854846019d].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFWRT.h" #import "private.h" |
︙ | ︙ |
Modified src/runtime/ObjFWRT.h from [87156bda73] to [94db01f911].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #ifndef OBJFWRT_OBJFWRT_H #define OBJFWRT_OBJFWRT_H #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS |
︙ | ︙ | |||
130 131 132 133 134 135 136 | * @note This is a legacy from before C had a boolean type. Prefer the standard * C99 bool instead! */ typedef bool BOOL; #endif /** | | | 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | * @note This is a legacy from before C had a boolean type. Prefer the standard * C99 bool instead! */ typedef bool BOOL; #endif /** * @brief A method implementation. * * @param object The messaged object * @param selector The selector sent */ typedef id _Nullable (*IMP)(id _Nonnull object, SEL _Nonnull selector, ...); /** |
︙ | ︙ | |||
169 170 171 172 173 174 175 176 177 178 179 180 181 182 | #ifdef __cplusplus Class _Nonnull class_; #else Class _Nonnull class; #endif }; #ifdef __cplusplus extern "C" { #endif /** * @brief Registers a selector with the specified name with the runtime. * | > > > > > > > > > > > > > > > > | 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | #ifdef __cplusplus Class _Nonnull class_; #else Class _Nonnull class; #endif }; /** * @brief A policy for object association, see @ref objc_setAssociatedObject. */ typedef enum objc_associationPolicy { /** @brief Associate the object like an assigned property. */ OBJC_ASSOCIATION_ASSIGN = 0, /** @brief Associate the object like a retained, nonatomic property. */ OBJC_ASSOCIATION_RETAIN_NONATOMIC = 1, /** @brief Associate the object like a retained property. */ OBJC_ASSOCIATION_RETAIN = OBJC_ASSOCIATION_RETAIN_NONATOMIC | 0x300, /** @brief Associate the object like a copied, nonatomic property. */ OBJC_ASSOCIATION_COPY_NONATOMIC = 3, /** @brief Associate the object like a copied property. */ OBJC_ASSOCIATION_COPY = OBJC_ASSOCIATION_COPY_NONATOMIC | 0x300 } objc_associationPolicy; #ifdef __cplusplus extern "C" { #endif /** * @brief Registers a selector with the specified name with the runtime. * |
︙ | ︙ | |||
308 309 310 311 312 313 314 | * @warning If the method uses the struct return ABI, you need to use * @ref class_getMethodImplementation_stret instead! Depending on the * ABI, small structs might not use the struct return ABI. * * @param class_ The class whose method implementation should be returned * @param selector The selector for the method whose implementation should be * returned | | | | 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | * @warning If the method uses the struct return ABI, you need to use * @ref class_getMethodImplementation_stret instead! Depending on the * ABI, small structs might not use the struct return ABI. * * @param class_ The class whose method implementation should be returned * @param selector The selector for the method whose implementation should be * returned * @return The class's method implementation for the specified selector */ extern IMP _Nullable class_getMethodImplementation(Class _Nullable class_, SEL _Nonnull selector); /** * @brief Returns the class's method implementation for the specified selector. * * @warning If the method does not use use the struct return ABI, you need to * use @ref class_getMethodImplementation instead! Depending on the * ABI, small structs might not use the struct return ABI. * * @param class_ The class whose method implementation should be returned * @param selector The selector for the method whose implementation should be * returned * @return The class's method implementation for the specified selector */ extern IMP _Nullable class_getMethodImplementation_stret(Class _Nullable class_, SEL _Nonnull selector); /** * @brief Returns the class's instance method for the specified selector * |
︙ | ︙ | |||
612 613 614 615 616 617 618 | * pointers with */ extern void objc_setTaggedPointerSecret(uintptr_t secret); /** * @brief Registers a class for tagged pointers. * | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 | * pointers with */ extern void objc_setTaggedPointerSecret(uintptr_t secret); /** * @brief Registers a class for tagged pointers. * * @param class_ The class to register for tagged pointers * @return The tagged pointer ID for the registered class */ extern int objc_registerTaggedPointerClass(Class _Nonnull class_); /** * @brief Returns whether the specified object is a tagged pointer. * * @param object The object to inspect * @return Whether the specified object is a tagged pointer */ extern bool object_isTaggedPointer(id _Nullable object); /** * @brief Returns the value of the specified tagged pointer. * * @param object The object whose tagged pointer value should be returned * @return The tagged pointer value of the object */ extern uintptr_t object_getTaggedPointerValue(id _Nonnull object); /** * @brief Creates a new tagged pointer. * * @param class_ The tag ID for the tagged pointer class to use * @param value The value the tagged pointer should have * @return A tagged pointer, or `nil` if it could not be created */ extern id _Nullable objc_createTaggedPointer(int class_, uintptr_t value); /** * @brief Sets an associated object on the specified object for the specified * key. * * @param object The object on which to set an associated object * @param key A unique pointer to use as the key for the association * @param value The object to associate with the specified object * @param policy The association policy, see @ref objc_associationPolicy */ extern void objc_setAssociatedObject(id _Nonnull object, const void *_Nonnull key, id _Nullable value, objc_associationPolicy policy); /** * @brief Returns the associated object on the specified object for the * specified key. * * @param object The object on which to get the associated object * @param key The key of the association * @return The associated object on the specified object for the specified key */ extern id _Nullable objc_getAssociatedObject(id _Nonnull object, const void *_Nonnull key); /** * @brief Removes all associated objects for the specified object. * * @param object The object on which to remove all associated objects */ extern void objc_removeAssociatedObjects(id _Nonnull object); /* * Used by the compiler, but can also be called manually. * * These declarations are also required to prevent Clang's implicit * declarations which include __declspec(dllimport) on Windows. */ |
︙ | ︙ |
Deleted src/runtime/amiga-end.m version [0cdcd50b7f].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/runtime/amiga-funcarray.inc version [820bef97bb].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/runtime/amiga-glue.h version [dc66f09f8a].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/runtime/amiga-glue.m version [8e4bfceffc].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/runtime/amiga-library.m version [db6b5f4a82].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/runtime/amiga-library.xml version [f6565586a9].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Modified src/runtime/arc.m from [262fd1b7bb] to [9a69477815].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFWRT.h" #import "private.h" |
︙ | ︙ | |||
184 185 186 187 188 189 190 | return value; } id objc_loadWeakRetained(id *object) { id value = nil; | < | < | 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | return value; } id objc_loadWeakRetained(id *object) { id value = nil; #ifdef OF_HAVE_THREADS if (OFSpinlockLock(&spinlock) != 0) OBJC_ERROR("Failed to lock spinlock!"); #endif if (*object != nil && objc_hashtable_get(hashtable, *object) != NULL) value = *object; #ifdef OF_HAVE_THREADS if (OFSpinlockUnlock(&spinlock) != 0) OBJC_ERROR("Failed to unlock spinlock!"); #endif |
︙ | ︙ |
Added src/runtime/association.m version [bd088abb65].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #ifdef OF_OBJFW_RUNTIME # import "ObjFWRT.h" # import "private.h" #else # import "OFObject.h" # import "OFMapTable.h" #endif struct Association { id object; objc_associationPolicy policy; }; #ifdef OF_OBJFW_RUNTIME typedef struct objc_hashtable objc_hashtable; #else typedef OFMapTable objc_hashtable; static const OFMapTableFunctions defaultFunctions = { NULL }; static objc_hashtable * objc_hashtable_new(uint32_t (*hash)(const void *key), bool (*equal)(const void *key1, const void *key2), uint32_t size) { return [[OFMapTable alloc] initWithKeyFunctions: defaultFunctions objectFunctions: defaultFunctions]; } static void objc_hashtable_set(objc_hashtable *hashtable, const void *key, const void *object) { return [hashtable setObject: (void *)object forKey: (void *)key]; } static void * objc_hashtable_get(objc_hashtable *hashtable, const void *key) { return [hashtable objectForKey: (void *)key]; } static void objc_hashtable_delete(objc_hashtable *hashtable, const void *key) { [hashtable removeObjectForKey: (void *)key]; } static void objc_hashtable_free(objc_hashtable *hashtable) { [hashtable release]; } # define OBJC_ERROR(...) abort() #endif #ifdef OF_HAVE_THREADS # define numSlots 8 /* needs to be a power of 2 */ # import "OFPlainMutex.h" static OFSpinlock spinlocks[numSlots]; #else # define numSlots 1 #endif static objc_hashtable *hashtables[numSlots]; static OF_INLINE size_t slotForObject(id object) { return ((size_t)((uintptr_t)object >> 4) & (numSlots - 1)); } static uint32_t hash(const void *object) { return (uint32_t)(uintptr_t)object; } static bool equal(const void *object1, const void *object2) { return (object1 == object2); } OF_CONSTRUCTOR() { for (size_t i = 0; i < numSlots; i++) { hashtables[i] = objc_hashtable_new(hash, equal, 2); #ifdef OF_HAVE_THREADS if (OFSpinlockNew(&spinlocks[i]) != 0) OBJC_ERROR("Failed to create spinlocks!"); #endif } } void objc_setAssociatedObject(id object, const void *key, id value, objc_associationPolicy policy) { size_t slot; switch (policy) { case OBJC_ASSOCIATION_ASSIGN: break; case OBJC_ASSOCIATION_RETAIN: case OBJC_ASSOCIATION_RETAIN_NONATOMIC: value = [value retain]; break; case OBJC_ASSOCIATION_COPY: case OBJC_ASSOCIATION_COPY_NONATOMIC: value = [value copy]; break; default: /* Don't know what to do, so do nothing. */ return; } slot = slotForObject(object); #ifdef OF_HAVE_THREADS if (OFSpinlockLock(&spinlocks[slot]) != 0) OBJC_ERROR("Failed to lock spinlock!"); @try { #endif objc_hashtable *objectHashtable; struct Association *association; objectHashtable = objc_hashtable_get(hashtables[slot], object); if (objectHashtable == NULL) { objectHashtable = objc_hashtable_new(hash, equal, 2); objc_hashtable_set(hashtables[slot], object, objectHashtable); } association = objc_hashtable_get(objectHashtable, key); if (association != NULL) { switch (association->policy) { case OBJC_ASSOCIATION_RETAIN: case OBJC_ASSOCIATION_RETAIN_NONATOMIC: case OBJC_ASSOCIATION_COPY: case OBJC_ASSOCIATION_COPY_NONATOMIC: [association->object release]; break; default: break; } } else { association = malloc(sizeof(*association)); if (association == NULL) OBJC_ERROR("Failed to allocate association!"); objc_hashtable_set(objectHashtable, key, association); } association->policy = policy; association->object = value; #ifdef OF_HAVE_THREADS } @finally { if (OFSpinlockUnlock(&spinlocks[slot]) != 0) OBJC_ERROR("Failed to unlock spinlock!"); } #endif } id objc_getAssociatedObject(id object, const void *key) { size_t slot = slotForObject(object); id ret; #ifdef OF_HAVE_THREADS if (OFSpinlockLock(&spinlocks[slot]) != 0) OBJC_ERROR("Failed to lock spinlock!"); @try { #endif objc_hashtable *objectHashtable; struct Association *association; objectHashtable = objc_hashtable_get(hashtables[slot], object); if (objectHashtable == NULL) return nil; association = objc_hashtable_get(objectHashtable, key); if (association == NULL) return nil; switch (association->policy) { case OBJC_ASSOCIATION_RETAIN: case OBJC_ASSOCIATION_COPY: ret = [[association->object retain] autorelease]; break; default: ret = association->object; break; } #ifdef OF_HAVE_THREADS } @finally { if (OFSpinlockUnlock(&spinlocks[slot]) != 0) OBJC_ERROR("Failed to unlock spinlock!"); } #endif return ret; } void objc_removeAssociatedObjects(id object) { size_t slot = slotForObject(object); #ifdef OF_HAVE_THREADS if (OFSpinlockLock(&spinlocks[slot]) != 0) OBJC_ERROR("Failed to lock spinlock!"); @try { #endif objc_hashtable *objectHashtable; objectHashtable = objc_hashtable_get(hashtables[slot], object); if (objectHashtable == NULL) return; #ifdef OF_OBJFW_RUNTIME for (uint32_t i = 0; i < objectHashtable->size; i++) { struct Association *association; if (objectHashtable->data[i] == NULL || objectHashtable->data[i] == &objc_deletedBucket) continue; association = (struct Association *) objectHashtable->data[i]->object; #else OFMapTableEnumerator *enumerator = [objectHashtable objectEnumerator]; void **iter; while ((iter = [enumerator nextObject]) != NULL) { struct Association *association = *iter; #endif switch (association->policy) { case OBJC_ASSOCIATION_RETAIN: case OBJC_ASSOCIATION_RETAIN_NONATOMIC: case OBJC_ASSOCIATION_COPY: case OBJC_ASSOCIATION_COPY_NONATOMIC: [association->object release]; break; default: break; } free(association); } objc_hashtable_delete(hashtables[slot], object); objc_hashtable_free(objectHashtable); #ifdef OF_HAVE_THREADS } @finally { if (OFSpinlockUnlock(&spinlocks[slot]) != 0) OBJC_ERROR("Failed to unlock spinlock!"); } #endif } |
Modified src/runtime/autorelease.m from [a652114a4e] to [ba740929be].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdio.h> #include <stdlib.h> |
︙ | ︙ |
Modified src/runtime/category.m from [7faaa519d3] to [8492941cb5].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdio.h> #include <stdlib.h> #include <string.h> |
︙ | ︙ |
Modified src/runtime/class.m from [4cb79aa414] to [f20174e5c5].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdio.h> #include <stdlib.h> #include <string.h> |
︙ | ︙ | |||
54 55 56 57 58 59 60 | class_registerAlias_np(Class class, const char *name) { objc_globalMutex_lock(); if (classes == NULL) { objc_globalMutex_unlock(); | | | | 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | class_registerAlias_np(Class class, const char *name) { objc_globalMutex_lock(); if (classes == NULL) { objc_globalMutex_unlock(); return false; } objc_hashtable_set(classes, name, (Class)((uintptr_t)class | 1)); objc_globalMutex_unlock(); return true; } static void registerSelectors(Class class) { struct objc_method_list *iter; unsigned int i; |
︙ | ︙ | |||
88 89 90 91 92 93 94 | return Nil; /* * Fast path * * Instead of looking up the string in a dictionary, which needs * locking, we use a sparse array to look up the pointer. If | | | | | | | | 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | return Nil; /* * Fast path * * Instead of looking up the string in a dictionary, which needs * locking, we use a sparse array to look up the pointer. If * objc_classnameToClass() gets called a lot, it is most likely that * the GCC ABI is used, which always calls into objc_lookup_class(), or * that it is used in a loop by the user. In both cases, it is very * likely that the same string pointer is passed again and again. * * This is not used before objc_classnameToClass() has been called a * certain amount of times, so that no memory is wasted if it is only * used rarely, for example if the ObjFW ABI is used and the user does * not call it in a loop. * * Runtime internal usage does not use the fast path and does not count * as a call into objc_classnameToClass(). The reason for this is that * if the runtime calls into objc_classnameToClass(), it already has * the lock and thus the performance gain would be small, but it would * waste memory. */ if (cache && fastPath != NULL) { class = objc_sparsearray_get(fastPath, (uintptr_t)name); if (class != Nil) return class; } |
︙ | ︙ | |||
584 585 586 587 588 589 590 | unsigned int objc_getClassList(Class *buffer, unsigned int count) { unsigned int j; objc_globalMutex_lock(); | | > > > > | > | > | 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 | unsigned int objc_getClassList(Class *buffer, unsigned int count) { unsigned int j; objc_globalMutex_lock(); if (buffer == NULL) { count = classesCount; objc_globalMutex_unlock(); return count; } if (classesCount < count) count = classesCount; j = 0; for (uint32_t i = 0; i < classes->size; i++) { void *class; if (j >= count) { objc_globalMutex_unlock(); return j; } if (classes->data[i] == NULL || classes->data[i] == &objc_deletedBucket) continue; if (strcmp(classes->data[i]->key, "Protocol") == 0) continue; class = (Class)classes->data[i]->object; |
︙ | ︙ | |||
776 777 778 779 780 781 782 | class->methodList = methodList; objc_updateDTable(class); } Method | > | | 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 | class->methodList = methodList; objc_updateDTable(class); } Method #if defined(__clang__) && __has_attribute(__optnone__) && \ __clang_major__ == 3 && __clang_minor__ <= 7 /* Work around an ICE in Clang 3.7.0 on Windows/x86 */ __attribute__((__optnone__)) #endif class_getInstanceMethod(Class class, SEL selector) { Method method; Class superclass; |
︙ | ︙ |
Modified src/runtime/dtable.m from [f0602aa5e2] to [3faaf1dc6a].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdio.h> #include <stdlib.h> |
︙ | ︙ |
Modified src/runtime/exception.m from [ba2a43d17f] to [a631c06b73].
1 | /* | | | | | | > > > > | < > | | | | | < | < < < > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #define OBJC_NO_PERSONALITY_DECLARATION #include <stdio.h> #include <stdlib.h> #include <string.h> #import "ObjFWRT.h" #import "private.h" #import "macros.h" #ifdef OF_HAVE_THREADS # import "OFPlainMutex.h" #endif #ifdef __SEH__ # include <windows.h> #endif #if defined(__SEH__) # define PERSONALITY gnu_objc_personality #elif defined(__USING_SJLJ_EXCEPTIONS__) # define PERSONALITY __gnu_objc_personality_sj0 # define CXX_PERSONALITY_STR "__gxx_personality_sj0" # define _Unwind_RaiseException _Unwind_SjLj_RaiseException # define __builtin_eh_return_data_regno(i) (i) #else # define PERSONALITY __gnu_objc_personality_v0 # define CXX_PERSONALITY_STR "__gxx_personality_v0" #endif #if defined(OF_ARM) && !defined(__ARM_DWARF_EH__) # define HAVE_ARM_EHABI_EXCEPTIONS #endif #ifndef HAVE_ARM_EHABI_EXCEPTIONS |
︙ | ︙ | |||
122 123 124 125 126 127 128 | struct objc_exception { struct _Unwind_Exception { uint64_t class; void (*cleanup)( _Unwind_Reason_Code, struct _Unwind_Exception *); #ifndef HAVE_ARM_EHABI_EXCEPTIONS | | | 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | struct objc_exception { struct _Unwind_Exception { uint64_t class; void (*cleanup)( _Unwind_Reason_Code, struct _Unwind_Exception *); #ifndef HAVE_ARM_EHABI_EXCEPTIONS # ifndef __SEH__ /* * The Itanium Exception ABI says to have those and never touch * them. */ uint64_t private1, private2; # else uint64_t private[6]; |
︙ | ︙ | |||
235 236 237 238 239 240 241 | } #endif #ifdef CXX_PERSONALITY static PERSONALITY_FUNC(cxx_personality) OF_WEAK_REF(CXX_PERSONALITY_STR); #endif | | | 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | } #endif #ifdef CXX_PERSONALITY static PERSONALITY_FUNC(cxx_personality) OF_WEAK_REF(CXX_PERSONALITY_STR); #endif #ifdef __SEH__ extern EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD, void *, PCONTEXT, PDISPATCHER_CONTEXT, _Unwind_Reason_Code (*)(int, int, uint64_t, struct _Unwind_Exception *, struct _Unwind_Context *)); #endif static objc_uncaught_exception_handler uncaughtExceptionHandler; static struct objc_exception emergencyExceptions[numEmergencyExceptions]; |
︙ | ︙ | |||
438 439 440 441 442 443 444 | { uintptr_t IP = _Unwind_GetIP(ctx); const uint8_t *ptr = LSDA->callsites; *landingpad = 0; *actionRecords = NULL; | | | 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 | { uintptr_t IP = _Unwind_GetIP(ctx); const uint8_t *ptr = LSDA->callsites; *landingpad = 0; *actionRecords = NULL; #ifndef __USING_SJLJ_EXCEPTIONS__ while (ptr < LSDA->actionTable) { uintptr_t callsiteStart, callsiteLength, callsiteLandingpad; uintptr_t callsiteAction; callsiteStart = LSDA->regionStart + (uintptr_t)readValue(LSDA->callsitesEnc, &ptr); callsiteLength = (uintptr_t)readValue(LSDA->callsitesEnc, &ptr); |
︙ | ︙ | |||
572 573 574 575 576 577 578 | else if (filter < 0) OBJC_ERROR("Invalid filter!"); } while (displacement != 0); return 0; } | | | 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 | else if (filter < 0) OBJC_ERROR("Invalid filter!"); } while (displacement != 0); return 0; } #ifdef __SEH__ static #endif PERSONALITY_FUNC(PERSONALITY) { #ifdef HAVE_ARM_EHABI_EXCEPTIONS int version = 1; uint64_t exClass = ex->class; |
︙ | ︙ | |||
778 779 780 781 782 783 784 | { objc_uncaught_exception_handler old = uncaughtExceptionHandler; uncaughtExceptionHandler = handler; return old; } | | | 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 | { objc_uncaught_exception_handler old = uncaughtExceptionHandler; uncaughtExceptionHandler = handler; return old; } #ifdef __SEH__ typedef EXCEPTION_DISPOSITION (*seh_personality_fn)(PEXCEPTION_RECORD, void *, PCONTEXT, PDISPATCHER_CONTEXT); static seh_personality_fn __gxx_personality_seh0; OF_CONSTRUCTOR() { /* |
︙ | ︙ |
Modified src/runtime/hashtable.m from [4617c1e6d6] to [b2d827cd57].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <limits.h> #include <stdint.h> #include <stdio.h> |
︙ | ︙ |
Modified src/runtime/init.m from [bad26900aa] to [c3e6c635c2].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFWRT.h" #import "private.h" |
︙ | ︙ |
Modified src/runtime/instance.m from [bb4ce37e30] to [a395386aeb].
1 | /* | | | | | | > > > > | < > | > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdbool.h> #ifdef OF_OBJFW_RUNTIME # import "ObjFWRT.h" # import "private.h" #else # import <objc/runtime.h> #endif #ifndef OF_OBJFW_RUNTIME extern void objc_removeAssociatedObjects(id object); #endif static SEL constructSelector = NULL; static SEL destructSelector = NULL; static bool callConstructors(Class class, id object) { |
︙ | ︙ | |||
97 98 99 100 101 102 103 104 105 106 | destructSelector)) != last) destruct(object, destructSelector); last = destruct; } else break; } return object; } | > > | 105 106 107 108 109 110 111 112 113 114 115 116 | destructSelector)) != last) destruct(object, destructSelector); last = destruct; } else break; } objc_removeAssociatedObjects(object); return object; } |
Modified src/runtime/ivar.m from [9c027bf0b1] to [9830cde896].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFWRT.h" #import "private.h" |
︙ | ︙ |
Deleted src/runtime/linklib/Makefile version [dc27346920].
|
| < < < < < < < < < < < < < |
Deleted src/runtime/linklib/init.m version [6ddafedf04].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/runtime/linklib/linklib.m version [0c00bc31d2].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Modified src/runtime/lookup-asm/Makefile from [3c7b7f7fc1] to [a8b7579307].
1 2 3 | include ../../../extra.mk STATIC_PIC_LIB_NOINST = ${LOOKUP_ASM_LIB_A} | < < | 1 2 3 4 5 6 7 8 9 10 | include ../../../extra.mk STATIC_PIC_LIB_NOINST = ${LOOKUP_ASM_LIB_A} STATIC_LIB_NOINST = ${LOOKUP_ASM_A} SRCS = lookup-asm.S include ../../../buildsys.mk ASFLAGS += -I../../.. -I../.. |
Renamed and modified src/runtime/lookup-asm/lookup-asm-x86_64-elf.S [63daf9ee68] to src/runtime/lookup-asm/lookup-asm-amd64-elf.S [cc9692563a].
1 | /* | | | | | | > > > > | < > | > > > > > > > > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include "platform.h" #ifdef HAVE_CET_H # include <cet.h> #else # define _CET_ENDBR #endif .globl objc_msg_lookup .globl objc_msg_lookup_stret .globl objc_msg_lookup_super .globl objc_msg_lookup_super_stret .section .text .macro GENERATE_LOOKUP name notFound \name: _CET_ENDBR testq %rdi, %rdi jz .LreturnNilMethod testb $1, %dil jnz .LtaggedPointer_\name movq (%rdi), %r8 movq 64(%r8), %r8 |
︙ | ︙ | |||
64 65 66 67 68 69 70 71 72 73 | jmp .Lmain_\name .type \name, %function .size \name, .-\name .endm .macro GENERATE_LOOKUP_SUPER name lookup \name: movq %rdi, %r8 movq (%rdi), %rdi testq %rdi, %rdi | > > | | | | > > | | 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | jmp .Lmain_\name .type \name, %function .size \name, .-\name .endm .macro GENERATE_LOOKUP_SUPER name lookup \name: _CET_ENDBR movq %rdi, %r8 movq (%rdi), %rdi testq %rdi, %rdi jz .LreturnNilMethod movq 8(%r8), %r8 movq 64(%r8), %r8 jmp .Lmain_\lookup .type \name, %function .size \name, .-\name .endm GENERATE_LOOKUP objc_msg_lookup objc_methodNotFound GENERATE_LOOKUP objc_msg_lookup_stret objc_methodNotFound_stret GENERATE_LOOKUP_SUPER objc_msg_lookup_super objc_msg_lookup GENERATE_LOOKUP_SUPER objc_msg_lookup_super_stret objc_msg_lookup_stret .LreturnNilMethod: leaq .LnilMethod(%rip), %rax ret .LnilMethod: _CET_ENDBR xorq %rax, %rax ret #if defined(OF_LINUX) || defined(OF_HAIKU) || defined(OF_HURD) .section .note.GNU-stack, "", %progbits #endif |
Renamed and modified src/runtime/lookup-asm/lookup-asm-x86_64-macho.S [1e72bfb083] to src/runtime/lookup-asm/lookup-asm-amd64-macho.S [c59284e5c0].
1 | /* | | | | | | > > > > | < > | > > > > > > > > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #ifdef HAVE_CET_H # include <cet.h> #else # define _CET_ENDBR #endif .globl _objc_msg_lookup .globl _objc_msg_lookup_stret .globl _objc_msg_lookup_super .globl _objc_msg_lookup_super_stret .section __TEXT, __text, regular, pure_instructions .macro GENERATE_LOOKUP $0: _CET_ENDBR testq %rdi, %rdi jz LreturnNilMethod testb $$1, %dil jnz LtaggedPointer_$0 movq (%rdi), %r8 movq 64(%r8), %r8 |
︙ | ︙ | |||
60 61 62 63 64 65 66 67 68 69 | movq 64(%r8), %r8 jmp Lmain_$0 .endmacro .macro GENERATE_LOOKUP_SUPER $0: movq %rdi, %r8 movq (%rdi), %rdi testq %rdi, %rdi | > > | | | | > > | 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | movq 64(%r8), %r8 jmp Lmain_$0 .endmacro .macro GENERATE_LOOKUP_SUPER $0: _CET_ENDBR movq %rdi, %r8 movq (%rdi), %rdi testq %rdi, %rdi jz LreturnNilMethod movq 8(%r8), %r8 movq 64(%r8), %r8 jmp Lmain_$1 .endmacro GENERATE_LOOKUP _objc_msg_lookup, _objc_methodNotFound GENERATE_LOOKUP _objc_msg_lookup_stret, _objc_methodNotFound_stret GENERATE_LOOKUP_SUPER _objc_msg_lookup_super, _objc_msg_lookup GENERATE_LOOKUP_SUPER _objc_msg_lookup_super_stret, _objc_msg_lookup_stret LreturnNilMethod: leaq LnilMethod(%rip), %rax ret LnilMethod: _CET_ENDBR xorq %rax, %rax ret |
Renamed and modified src/runtime/lookup-asm/lookup-asm-x86_64-win64.S [bb874856c9] to src/runtime/lookup-asm/lookup-asm-amd64-win64.S [09a5df3763].
1 | /* | | | | | | > > > > | < > | > > > > > > > > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #ifdef HAVE_CET_H # include <cet.h> #else # define _CET_ENDBR #endif .globl objc_msg_lookup .globl objc_msg_lookup_stret .globl objc_msg_lookup_super .globl objc_msg_lookup_super_stret .section .text .macro GENERATE_LOOKUP name notFound \name: _CET_ENDBR testq %rcx, %rcx jz .LreturnNilMethod testb $1, %cl jnz .LtaggedPointer_\name movq (%rcx), %r8 movq 56(%r8), %r8 |
︙ | ︙ | |||
71 72 73 74 75 76 77 78 79 80 | .scl 2 .type 32 .endef .endm .macro GENERATE_LOOKUP_SUPER name lookup \name: movq %rcx, %r8 movq (%rcx), %rcx testq %rcx, %rcx | > > | | | | > > | 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | .scl 2 .type 32 .endef .endm .macro GENERATE_LOOKUP_SUPER name lookup \name: _CET_ENDBR movq %rcx, %r8 movq (%rcx), %rcx testq %rcx, %rcx jz .LreturnNilMethod movq 8(%r8), %r8 movq 56(%r8), %r8 jmp .Lmain_\lookup .def \name .scl 2 .type 32 .endef .endm GENERATE_LOOKUP objc_msg_lookup objc_methodNotFound GENERATE_LOOKUP objc_msg_lookup_stret objc_methodNotFound_stret GENERATE_LOOKUP_SUPER objc_msg_lookup_super objc_msg_lookup GENERATE_LOOKUP_SUPER objc_msg_lookup_super_stret objc_msg_lookup_stret .LreturnNilMethod: leaq .LnilMethod(%rip), %rax ret .LnilMethod: _CET_ENDBR xorq %rax, %rax ret |
Modified src/runtime/lookup-asm/lookup-asm-arm-elf.S from [f0e5b05f4e] to [05bf0c4b80].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include "platform.h" .globl objc_msg_lookup .globl objc_msg_lookup_stret .globl objc_msg_lookup_super .globl objc_msg_lookup_super_stret .section .text .macro GENERATE_LOOKUP name notFound \name: cmp r0, #0 beq .LreturnNilMethod tst r0, #1 bne .LtaggedPointer_\name ldr r2, [r0, #0] ldr r2, [r2, #32] |
︙ | ︙ | |||
88 89 90 91 92 93 94 | .endm .macro GENERATE_LOOKUP_SUPER name lookup \name: mov r2, r0 ldr r0, [r0, #0] cmp r0, #0 | | | | | | | 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | .endm .macro GENERATE_LOOKUP_SUPER name lookup \name: mov r2, r0 ldr r0, [r0, #0] cmp r0, #0 beq .LreturnNilMethod ldr r2, [r2, #4] ldr r2, [r2, #32] b .Lmain_\lookup .type \name, %function .size \name, .-\name .endm GENERATE_LOOKUP objc_msg_lookup objc_methodNotFound GENERATE_LOOKUP objc_msg_lookup_stret objc_methodNotFound_stret GENERATE_LOOKUP_SUPER objc_msg_lookup_super objc_msg_lookup GENERATE_LOOKUP_SUPER objc_msg_lookup_super_stret objc_msg_lookup_stret .LreturnNilMethod: adr r0, .LnilMethod bx lr .LnilMethod: mov r0, #0 bx lr #if defined(OF_LINUX) || defined(OF_HAIKU) || defined(OF_HURD) .section .note.GNU-stack, "", %progbits #endif |
Modified src/runtime/lookup-asm/lookup-asm-arm64-elf.S from [ad3c36fa42] to [8493d6b132].
1 | /* | | | | | | > > > > | < > | > > > > | < | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include "platform.h" .globl objc_msg_lookup .globl objc_msg_lookup_stret .globl objc_msg_lookup_super .globl objc_msg_lookup_super_stret .section .text .macro GENERATE_LOOKUP name notFound \name: #ifdef HAVE_BTI bti c #endif cbz x0, .LreturnNilMethod tbnz x0, #0, .LtaggedPointer_\name ldr x2, [x0] ldr x2, [x2, #64] .Lmain_\name: #ifdef OF_SELUID24 ldrb w3, [x1, #2] |
︙ | ︙ | |||
64 65 66 67 68 69 70 71 72 | b .Lmain_\name .type \name, %function .size \name, .-\name .endm .macro GENERATE_LOOKUP_SUPER name lookup \name: mov x2, x0 ldr x0, [x0] | > > > > | | | | > > > > | | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | b .Lmain_\name .type \name, %function .size \name, .-\name .endm .macro GENERATE_LOOKUP_SUPER name lookup \name: #ifdef HAVE_BTI bti c #endif mov x2, x0 ldr x0, [x0] cbz x0, .LreturnNilMethod ldr x2, [x2, #8] ldr x2, [x2, #64] b .Lmain_\lookup .type \name, %function .size \name, .-\name .endm GENERATE_LOOKUP objc_msg_lookup objc_methodNotFound GENERATE_LOOKUP objc_msg_lookup_stret objc_methodNotFound_stret GENERATE_LOOKUP_SUPER objc_msg_lookup_super objc_msg_lookup GENERATE_LOOKUP_SUPER objc_msg_lookup_super_stret objc_msg_lookup_stret .LreturnNilMethod: adr x0, .LnilMethod ret .LnilMethod: #ifdef HAVE_BTI bti c #endif mov x0, #0 ret #if defined(OF_LINUX) || defined(OF_HAIKU) || defined(OF_HURD) .section .note.GNU-stack, "", %progbits #endif |
Modified src/runtime/lookup-asm/lookup-asm-mips-elf.S from [c727ce9d5a] to [ac4cc7b70e].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include "platform.h" .globl objc_msg_lookup |
︙ | ︙ | |||
70 71 72 73 74 75 76 | #endif move $v0, $t0 jr $ra 0: #ifdef OF_PIC | | | | 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | #endif move $v0, $t0 jr $ra 0: #ifdef OF_PIC addiu $v0, $t9, .LnilMethod-\name #else la $v0, .LnilMethod #endif jr $ra #ifdef OF_PIC 1: lui $gp, %hi(_gp_disp) addiu $gp, $gp, %lo(_gp_disp) |
︙ | ︙ | |||
132 133 134 135 136 137 138 | lw $t0, 32($t0) addiu $t9, $t9, \lookup-\name b .Lmain_\lookup 0: #ifdef OF_PIC | | | | | | 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | lw $t0, 32($t0) addiu $t9, $t9, \lookup-\name b .Lmain_\lookup 0: #ifdef OF_PIC addiu $v0, $t9, .LnilMethod-\name #else la $v0, .LnilMethod #endif jr $ra .type \name, %function .size \name, .-\name .endm GENERATE_LOOKUP objc_msg_lookup objc_methodNotFound GENERATE_LOOKUP objc_msg_lookup_stret objc_methodNotFound_stret GENERATE_LOOKUP_SUPER objc_msg_lookup_super objc_msg_lookup GENERATE_LOOKUP_SUPER objc_msg_lookup_super_stret objc_msg_lookup_stret .LnilMethod: move $v0, $zero jr $ra #if defined(OF_LINUX) || defined(OF_HAIKU) || defined(OF_HURD) .section .note.GNU-stack, "", %progbits #endif |
Modified src/runtime/lookup-asm/lookup-asm-mips64-n64-elf.S from [53637868a6] to [beb8665281].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include "platform.h" .globl objc_msg_lookup |
︙ | ︙ | |||
68 69 70 71 72 73 74 | move $v0, $t0 jr $ra 0: lui $v0, %hi(%neg(%gp_rel(\name))) daddiu $v0, $v0, %lo(%neg(%gp_rel(\name))) daddu $v0, $v0, $t9 | | | 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | move $v0, $t0 jr $ra 0: lui $v0, %hi(%neg(%gp_rel(\name))) daddiu $v0, $v0, %lo(%neg(%gp_rel(\name))) daddu $v0, $v0, $t9 ld $v0, %got_disp(.LnilMethod)($v0) jr $ra 1: lui $t0, %hi(%neg(%gp_rel(\name))) daddiu $t0, $t0, %lo(%neg(%gp_rel(\name))) daddu $t0, $t0, $t9 ld $t9, %got_disp(\notFound)($t0) |
︙ | ︙ | |||
115 116 117 118 119 120 121 | daddiu $t9, $t9, \lookup-\name b .Lmain_\lookup 0: lui $v0, %hi(%neg(%gp_rel(\name))) daddiu $v0, $v0, %lo(%neg(%gp_rel(\name))) daddu $v0, $v0, $t9 | | | | | 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | daddiu $t9, $t9, \lookup-\name b .Lmain_\lookup 0: lui $v0, %hi(%neg(%gp_rel(\name))) daddiu $v0, $v0, %lo(%neg(%gp_rel(\name))) daddu $v0, $v0, $t9 ld $v0, %got_disp(.LnilMethod)($v0) jr $ra .type \name, %function .size \name, .-\name .endm GENERATE_LOOKUP objc_msg_lookup objc_methodNotFound GENERATE_LOOKUP objc_msg_lookup_stret objc_methodNotFound_stret GENERATE_LOOKUP_SUPER objc_msg_lookup_super objc_msg_lookup GENERATE_LOOKUP_SUPER objc_msg_lookup_super_stret objc_msg_lookup_stret .LnilMethod: move $v0, $zero jr $ra #if defined(OF_LINUX) || defined(OF_HAIKU) || defined(OF_HURD) .section .note.GNU-stack, "", %progbits #endif |
Modified src/runtime/lookup-asm/lookup-asm-powerpc-elf.S from [134bfef460] to [8d46e8e4e6].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include "platform.h" .globl objc_msg_lookup .globl objc_msg_lookup_stret .globl objc_msg_lookup_super .globl objc_msg_lookup_super_stret .section .text .macro GENERATE_LOOKUP name notFound \name: cmpwi %r3, 0 beq- .LreturnNilMethod andi. %r0, %r3, 1 bne- .LtaggedPointer_\name lwz %r5, 0(%r3) lwz %r5, 32(%r5) |
︙ | ︙ | |||
120 121 122 123 124 125 126 | .endm .macro GENERATE_LOOKUP_SUPER name lookup \name: mr %r5, %r3 lwz %r3, 0(%r3) cmpwi %r3, 0 | | | | | | | | | 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | .endm .macro GENERATE_LOOKUP_SUPER name lookup \name: mr %r5, %r3 lwz %r3, 0(%r3) cmpwi %r3, 0 beq- .LreturnNilMethod lwz %r5, 4(%r5) lwz %r5, 32(%r5) b .Lmain_\lookup .type \name, @function .size \name, .-\name .endm GENERATE_LOOKUP objc_msg_lookup objc_methodNotFound GENERATE_LOOKUP objc_msg_lookup_stret objc_methodNotFound_stret GENERATE_LOOKUP_SUPER objc_msg_lookup_super objc_msg_lookup GENERATE_LOOKUP_SUPER objc_msg_lookup_super_stret objc_msg_lookup_stret .LreturnNilMethod: mflr %r0 bl .LgetPC mtlr %r0 0: addi %r3, %r3, .LnilMethod-0b blr .LnilMethod: li %r3, 0 blr .LgetPC: mflr %r3 blr #ifdef OF_PIC .section .got2, "aw" .Lbiased_got2 = .+0x8000 .Lgot_objc_methodNotFound: .long objc_methodNotFound .Lgot_objc_methodNotFound_stret: .long objc_methodNotFound_stret .Lgot_objc_taggedPointerSecret: .long objc_taggedPointerSecret .Lgot_objc_taggedPointerClasses: .long objc_taggedPointerClasses #endif #if defined(OF_LINUX) || defined(OF_HAIKU) || defined(OF_HURD) .section .note.GNU-stack, "", @progbits #endif |
Modified src/runtime/lookup-asm/lookup-asm-powerpc64-elf.S from [8516ac090f] to [b56b04edc7].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include "platform.h" #if defined(_CALL_ELF) && _CALL_ELF == 2 |
︙ | ︙ | |||
130 131 132 133 134 135 136 | GENERATE_LOOKUP objc_msg_lookup objc_methodNotFound GENERATE_LOOKUP objc_msg_lookup_stret objc_methodNotFound_stret GENERATE_LOOKUP_SUPER objc_msg_lookup_super objc_msg_lookup GENERATE_LOOKUP_SUPER objc_msg_lookup_super_stret objc_msg_lookup_stret .LreturnNilMethod: | | | | | | | | | | | | 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | GENERATE_LOOKUP objc_msg_lookup objc_methodNotFound GENERATE_LOOKUP objc_msg_lookup_stret objc_methodNotFound_stret GENERATE_LOOKUP_SUPER objc_msg_lookup_super objc_msg_lookup GENERATE_LOOKUP_SUPER objc_msg_lookup_super_stret objc_msg_lookup_stret .LreturnNilMethod: addis %r3, %r2, .LnilMethod@toc@ha addi %r3, %r3, .LnilMethod@toc@l blr #if defined(_CALL_ELF) && _CALL_ELF == 2 .LnilMethod: addis %r2, %r12, .TOC.-.LnilMethod@ha addi %r2, %r2, .TOC.-.LnilMethod@l .localentry .LnilMethod, .-.LnilMethod #else .section .opd, "aw", @progbits .LnilMethod: .p2align 3 .quad .Lbegin_nilMethod .quad .TOC.@tocbase .quad 0 .section .text #endif .Lbegin_nilMethod: li %r3, 0 blr .type .LnilMethod, @function .size .LnilMethod, .-.Lbegin_nilMethod #if defined(OF_LINUX) || defined(OF_HAIKU) || defined(OF_HURD) .section .note.GNU-stack, "", @progbits #endif |
Modified src/runtime/lookup-asm/lookup-asm-sparc-elf.S from [52b9093b5b] to [cf87cc2c7b].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include "platform.h" .globl objc_msg_lookup .globl objc_msg_lookup_stret .globl objc_msg_lookup_super .globl objc_msg_lookup_super_stret .section .text .macro GENERATE_LOOKUP name notFound \name: tst %o0 bz .LreturnNilMethod btst 1, %o0 bnz .LtaggedPointer_\name nop ld [%o0], %o2 ld [%o2 + 32], %o2 |
︙ | ︙ | |||
100 101 102 103 104 105 106 | .endm .macro GENERATE_LOOKUP_SUPER name lookup \name: mov %o0, %o2 ld [%o0], %o0 cmp %o0, 0 | | | | | | | | | | 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | .endm .macro GENERATE_LOOKUP_SUPER name lookup \name: mov %o0, %o2 ld [%o0], %o0 cmp %o0, 0 be .LreturnNilMethod nop ld [%o2 + 4], %o2 ba .Lmain_\lookup ld [%o2 + 32], %o2 .type \name, %function .size \name, .-\name .endm GENERATE_LOOKUP objc_msg_lookup objc_methodNotFound GENERATE_LOOKUP objc_msg_lookup_stret objc_methodNotFound_stret GENERATE_LOOKUP_SUPER objc_msg_lookup_super objc_msg_lookup GENERATE_LOOKUP_SUPER objc_msg_lookup_super_stret objc_msg_lookup_stret .LreturnNilMethod: #ifdef OF_PIC mov %o7, %g1 sethi %hi(_GLOBAL_OFFSET_TABLE_ - 4), %o1 call 0f add %o1, %lo(_GLOBAL_OFFSET_TABLE_ + 4), %o1 0: add %o7, %o1, %o1 sethi %hi(.LnilMethod), %o0 or %o0, %lo(.LnilMethod), %o0 jmpl %g1 + 8, %g0 ld [%o1 + %o0], %o0 #else sethi %hi(.LnilMethod), %o0 retl or %o0, %lo(.LnilMethod), %o0 #endif .LnilMethod: retl clr %o0 #if defined(OF_LINUX) || defined(OF_HAIKU) || defined(OF_HURD) .section .note.GNU-stack, "", %progbits #endif |
Modified src/runtime/lookup-asm/lookup-asm-sparc64-elf.S from [1e61b50ef6] to [a7f8328072].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include "platform.h" .globl objc_msg_lookup .globl objc_msg_lookup_stret .globl objc_msg_lookup_super .globl objc_msg_lookup_super_stret .section .text .macro GENERATE_LOOKUP name notFound \name: brz,pn %o0, .LreturnNilMethod and %o0, 1, %o2 brnz,pn %o2, .LtaggedPointer_\name nop ldx [%o0], %o2 ldx [%o2 + 64], %o2 |
︙ | ︙ | |||
97 98 99 100 101 102 103 | .size \name, .-\name .endm .macro GENERATE_LOOKUP_SUPER name lookup \name: mov %o0, %o2 ldx [%o0], %o0 | | | | | | | | | | 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | .size \name, .-\name .endm .macro GENERATE_LOOKUP_SUPER name lookup \name: mov %o0, %o2 ldx [%o0], %o0 brz,pn %o0, .LreturnNilMethod nop ldx [%o2 + 8], %o2 ba .Lmain_\lookup ldx [%o2 + 64], %o2 .type \name, %function .size \name, .-\name .endm GENERATE_LOOKUP objc_msg_lookup objc_methodNotFound GENERATE_LOOKUP objc_msg_lookup_stret objc_methodNotFound_stret GENERATE_LOOKUP_SUPER objc_msg_lookup_super objc_msg_lookup GENERATE_LOOKUP_SUPER objc_msg_lookup_super_stret objc_msg_lookup_stret .LreturnNilMethod: #ifdef OF_PIC mov %o7, %g1 sethi %hi(_GLOBAL_OFFSET_TABLE_ - 4), %o1 call 0f or %o1, %lo(_GLOBAL_OFFSET_TABLE_ + 4), %o1 0: add %o7, %o1, %o1 sethi %hi(.LnilMethod), %o0 or %o0, %lo(.LnilMethod), %o0 jmpl %g1 + 8, %g0 ldx [%o1 + %o0], %o0 #else sethi %hi(.LnilMethod), %o0 retl or %o0, %lo(.LnilMethod), %o0 #endif .LnilMethod: retl clr %o0 #if defined(OF_LINUX) || defined(OF_HAIKU) || defined(OF_HURD) .section .note.GNU-stack, "", %progbits #endif |
Modified src/runtime/lookup-asm/lookup-asm-x86-elf.S from [fe04c47c7f] to [51eaca73d3].
1 | /* | | | | | | > > > > | < > | > > > > > > > > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include "platform.h" #ifdef HAVE_CET_H # include <cet.h> #else # define _CET_ENDBR #endif .globl objc_msg_lookup .globl objc_msg_lookup_stret .globl objc_msg_lookup_super .globl objc_msg_lookup_super_stret .section .text .macro GENERATE_LOOKUP name notFound \name: _CET_ENDBR movl 4(%esp), %edx testl %edx, %edx jz .LreturnNilMethod testb $1, %dl jnz .LtaggedPointer_\name movl (%edx), %edx movl 32(%edx), %edx |
︙ | ︙ | |||
49 50 51 52 53 54 55 | testl %eax, %eax jz 0f ret 0: | | | | | | > > | | | | | > > | | | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | testl %eax, %eax jz 0f ret 0: call .LgetEIP addl $_GLOBAL_OFFSET_TABLE_, %eax movl \notFound@GOT(%eax), %eax jmp *%eax .LtaggedPointer_\name: call .LgetEIP addl $_GLOBAL_OFFSET_TABLE_, %eax movl objc_taggedPointerSecret@GOT(%eax), %ecx xorl (%ecx), %edx andb $0xE, %dl movzbl %dl, %edx movl objc_taggedPointerClasses@GOT(%eax), %eax movl (%eax,%edx,2), %edx movl 32(%edx), %edx jmp .Lmain_\name .type \name, %function .size \name, .-\name .endm .macro GENERATE_LOOKUP_SUPER name lookup \name: _CET_ENDBR movl 4(%esp), %edx movl (%edx), %eax testl %eax, %eax jz .LreturnNilMethod movl %eax, 4(%esp) mov 4(%edx), %edx mov 32(%edx), %edx jmp .Lmain_\lookup .type \name, %function .size \name, .-\name .endm GENERATE_LOOKUP objc_msg_lookup objc_methodNotFound GENERATE_LOOKUP objc_msg_lookup_stret objc_methodNotFound_stret GENERATE_LOOKUP_SUPER objc_msg_lookup_super objc_msg_lookup GENERATE_LOOKUP_SUPER objc_msg_lookup_super_stret objc_msg_lookup_stret .LreturnNilMethod: call .LgetEIP addl $_GLOBAL_OFFSET_TABLE_, %eax leal .LnilMethod@GOTOFF(%eax), %eax ret .LnilMethod: _CET_ENDBR xorl %eax, %eax ret .LgetEIP: movl (%esp), %eax ret #if defined(OF_LINUX) || defined(OF_HAIKU) || defined(OF_HURD) .section .note.GNU-stack, "", %progbits #endif |
Modified src/runtime/lookup-asm/lookup-asm-x86-win32.S from [0d663a9140] to [60ea15786d].
1 | /* | | | | | | > > > > | < > | > > > > > > > > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #ifdef HAVE_CET_H # include <cet.h> #else # define _CET_ENDBR #endif .globl _objc_msg_lookup .globl _objc_msg_lookup_stret .globl _objc_msg_lookup_super .globl _objc_msg_lookup_super_stret .section .text .macro GENERATE_LOOKUP name notFound \name: _CET_ENDBR movl 4(%esp), %edx testl %edx, %edx jz .LreturnNilMethod testb $1, %dl jnz .LtaggedPointer_\name movl (%edx), %edx movl 32(%edx), %edx |
︙ | ︙ | |||
63 64 65 66 67 68 69 70 71 72 | .scl 2 .type 32 .endef .endm .macro GENERATE_LOOKUP_SUPER name lookup \name: movl 4(%esp), %edx movl (%edx), %eax test %eax, %eax | > > | | | | > > | 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | .scl 2 .type 32 .endef .endm .macro GENERATE_LOOKUP_SUPER name lookup \name: _CET_ENDBR movl 4(%esp), %edx movl (%edx), %eax test %eax, %eax jz .LreturnNilMethod movl %eax, 4(%esp) movl 4(%edx), %edx movl 32(%edx), %edx jmp .Lmain_\lookup .def \name .scl 2 .type 32 .endef .endm GENERATE_LOOKUP _objc_msg_lookup _objc_methodNotFound GENERATE_LOOKUP _objc_msg_lookup_stret _objc_methodNotFound_stret GENERATE_LOOKUP_SUPER _objc_msg_lookup_super _objc_msg_lookup GENERATE_LOOKUP_SUPER _objc_msg_lookup_super_stret _objc_msg_lookup_stret .LreturnNilMethod: movl $.LnilMethod, %eax ret .LnilMethod: _CET_ENDBR xorl %eax, %eax ret |
Modified src/runtime/lookup-asm/lookup-asm.S from [31f647ad96] to [f7a3f67111].
1 | /* | | | | | | > > > > | < > | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include "platform.h" #if defined(OF_ELF) # if defined(OF_AMD64) # include "lookup-asm-amd64-elf.S" # elif defined(OF_X86) # include "lookup-asm-x86-elf.S" # elif defined(OF_ARM64) # include "lookup-asm-arm64-elf.S" # elif defined(OF_ARM) # include "lookup-asm-arm-elf.S" # elif defined(OF_POWERPC64) # include "lookup-asm-powerpc64-elf.S" # elif defined(OF_POWERPC) # include "lookup-asm-powerpc-elf.S" # elif defined(OF_MIPS64_N64) # include "lookup-asm-mips64-n64-elf.S" # elif defined(OF_MIPS) # include "lookup-asm-mips-elf.S" # elif defined(OF_SPARC64) # include "lookup-asm-sparc64-elf.S" # elif defined(OF_SPARC) # include "lookup-asm-sparc-elf.S" # endif #elif defined(OF_MACH_O) # if defined(OF_AMD64) # include "lookup-asm-amd64-macho.S" # endif #elif defined(OF_WINDOWS) # if defined(OF_AMD64) # include "lookup-asm-amd64-win64.S" # elif defined(OF_X86) # include "lookup-asm-x86-win32.S" # endif #endif |
Modified src/runtime/lookup.m from [620b9cc132] to [fba665cbdb].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdio.h> #include <stdlib.h> |
︙ | ︙ |
Modified src/runtime/method.m from [82646e77ef] to [fd6bf1bc75].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFWRT.h" #import "private.h" |
︙ | ︙ |
Modified src/runtime/misc.m from [6b0956b061] to [78ab401c4a].
1 | /* | | | | | | > > > > | < > | > < | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include "ObjFWRT.h" #include "private.h" #ifdef OF_WINDOWS # include <windows.h> #endif #ifdef OF_AMIGAOS # define Class IntuitionClass # define USE_INLINE_STDARG # include <proto/exec.h> # include <clib/debug_protos.h> # define __NOLIBBASE__ # include <proto/intuition.h> # undef __NOLIBBASE__ # undef Class #endif static objc_enumeration_mutation_handler enumerationMutationHandler = NULL; void objc_enumerationMutation(id object) { |
︙ | ︙ |
Modified src/runtime/private.h from [aebd8619bf] to [3b94bd139a].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "macros.h" #if !defined(__has_feature) || !__has_feature(nullability) |
︙ | ︙ | |||
35 36 37 38 39 40 41 | Class _Nullable superclass; const char *_Nonnull name; unsigned long version; unsigned long info; long instanceSize; struct objc_ivar_list *_Nullable ivars; struct objc_method_list *_Nullable methodList; | | | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | Class _Nullable superclass; const char *_Nonnull name; unsigned long version; unsigned long info; long instanceSize; struct objc_ivar_list *_Nullable ivars; struct objc_method_list *_Nullable methodList; struct objc_dtable *_Nullable dTable; Class _Nullable *_Nullable subclassList; void *_Nullable siblingClass; struct objc_protocol_list *_Nullable protocols; void *_Nullable GCObjectType; unsigned long ABIVersion; int32_t *_Nonnull *_Nullable ivarOffsets; struct objc_property_list *_Nullable propertyList; |
︙ | ︙ | |||
211 212 213 214 215 216 217 | } *_Nonnull buckets[256]; #else IMP _Nullable buckets[256]; #endif } *_Nonnull buckets[256]; }; | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | } *_Nonnull buckets[256]; #else IMP _Nullable buckets[256]; #endif } *_Nonnull buckets[256]; }; extern void objc_registerAllCategories(struct objc_symtab *_Nonnull); extern struct objc_category *_Nullable *_Nullable objc_categoriesForClass(Class _Nonnull); extern void objc_unregisterAllCategories(void); extern void objc_initializeClass(Class _Nonnull); extern void objc_updateDTable(Class _Nonnull); extern void objc_registerAllClasses(struct objc_symtab *_Nonnull); |
︙ | ︙ | |||
353 354 355 356 357 358 359 | extern void OF_NO_RETURN_FUNC objc_error(const char *_Nonnull title, const char *_Nonnull format, ...); #define OBJC_ERROR(...) \ objc_error("ObjFWRT @ " __FILE__ ":" OF_STRINGIFY(__LINE__), \ __VA_ARGS__) #if defined(OF_ELF) | | | | | 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | extern void OF_NO_RETURN_FUNC objc_error(const char *_Nonnull title, const char *_Nonnull format, ...); #define OBJC_ERROR(...) \ objc_error("ObjFWRT @ " __FILE__ ":" OF_STRINGIFY(__LINE__), \ __VA_ARGS__) #if defined(OF_ELF) # if defined(OF_AMD64) || defined(OF_X86) || \ defined(OF_POWERPC64) || defined(OF_POWERPC) || \ defined(OF_ARM64) || defined(OF_ARM) || \ defined(OF_MIPS64_N64) || defined(OF_MIPS) || \ defined(OF_SPARC64) || defined(OF_SPARC) # define OF_ASM_LOOKUP # endif #elif defined(OF_MACH_O) # if defined(OF_AMD64) # define OF_ASM_LOOKUP # endif #elif defined(OF_WINDOWS) # if defined(OF_AMD64) || defined(OF_X86) # define OF_ASM_LOOKUP # endif #endif @interface DummyObject { Class _Nonnull isa; |
︙ | ︙ |
Modified src/runtime/property.m from [822a1641e1] to [914db938d2].
1 | /* | | | | | | > > > > | < > | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "ObjFWRT.h" #import "private.h" #ifdef OF_HAVE_THREADS # import "OFPlainMutex.h" # define numSpinlocks 8 /* needs to be a power of 2 */ static OFSpinlock spinlocks[numSpinlocks]; static OF_INLINE size_t spinlockSlot(const void *ptr) { return ((size_t)((uintptr_t)ptr >> 4) & (numSpinlocks - 1)); } OF_CONSTRUCTOR() { for (size_t i = 0; i < numSpinlocks; i++) if (OFSpinlockNew(&spinlocks[i]) != 0) OBJC_ERROR("Failed to create spinlocks!"); } #endif |
︙ | ︙ |
Modified src/runtime/protocol.m from [30a1ffceef] to [7e85030132].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "ObjFWRT.h" |
︙ | ︙ |
Modified src/runtime/selector.m from [9a44ebdc88] to [2639ab65b4].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdio.h> #include <stdlib.h> #include <string.h> |
︙ | ︙ |
Modified src/runtime/sparsearray.m from [5acb08c6c8] to [98fd1c0a09].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdio.h> #include <stdlib.h> |
︙ | ︙ |
Modified src/runtime/static-instances.m from [7d72566e27] to [1dcac2483b].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdio.h> #include <stdlib.h> |
︙ | ︙ |
Modified src/runtime/synchronized.m from [2eb69df2c4] to [4d6010edbe].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdio.h> #include <stdlib.h> |
︙ | ︙ |
Modified src/runtime/tagged-pointer.m from [747427397b] to [3400b6adc5].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "ObjFWRT.h" #import "private.h" #define numTaggedPointerBits 4 |
︙ | ︙ |
Modified src/runtime/threading.m from [f4000ae0f7] to [55d11ffcc0].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdio.h> #include <stdlib.h> |
︙ | ︙ |
Modified src/runtime/versioninfo.rc from [6986fc8cab] to [6ae207e79a].
︙ | ︙ | |||
10 11 12 13 14 15 16 | BLOCK "StringFileInfo" { BLOCK "040904E4" { VALUE "ProductName", "ObjFW Runtime" VALUE "ProductVersion", PACKAGE_VERSION VALUE "FileVersion", OBJFWRT_LIB_VERSION VALUE "FileDescription", "Objective-C runtime" VALUE "LegalCopyright", | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | BLOCK "StringFileInfo" { BLOCK "040904E4" { VALUE "ProductName", "ObjFW Runtime" VALUE "ProductVersion", PACKAGE_VERSION VALUE "FileVersion", OBJFWRT_LIB_VERSION VALUE "FileDescription", "Objective-C runtime" VALUE "LegalCopyright", "(c) 2008-2024 Jonathan Schleifer" VALUE "InternalName", "ObjFWRT" VALUE "OriginalFilename", OBJFWRT_SHARED_LIB } } BLOCK "VarFileInfo" { |
︙ | ︙ |
Added src/test/Makefile version [aab1b7aacf].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | include ../../extra.mk DISTCLEAN = Info.plist STATIC_LIB = libobjfwtest.a SRCS = OTAssert.m \ OTOrderedDictionary.m \ OTTestCase.m INCLUDES := ${SRCS:.m=.h} \ ObjFWTest.h SRCS += OTAppDelegate.m \ OTAssertionFailedException.m \ OTTestSkippedException.m includesubdir = ObjFWTest include ../../buildsys.mk CPPFLAGS += -I. \ -I.. \ -I../.. \ -I../exceptions \ -I../runtime \ -DOBJFWTEST_LOCAL_INCLUDES LD = ${OBJC} FRAMEWORK_LIBS := -F.. \ -framework ObjFW \ -F../runtime \ ${RUNTIME_FRAMEWORK_LIBS} \ ${LIBS} LIBS := -L.. -lobjfw -L../runtime ${RUNTIME_LIBS} ${LIBS} install-extra: i=ObjFWTest.oc; \ ${INSTALL_STATUS}; \ if ${MKDIR_P} ${DESTDIR}${libdir}/objfw-config && \ ${INSTALL} -m 644 $$i ${DESTDIR}${libdir}/objfw-config/$$i; then \ ${INSTALL_OK}; \ else \ ${INSTALL_FAILED}; \ fi uninstall-extra: i=ObjFWTest.oc; \ if test -f ${DESTDIR}${libdir}/objfw-config/$$i; then \ if rm -f ${DESTDIR}${libdir}/objfw-config/$$i; then \ ${DELETE_OK}; \ else \ ${DELETE_FAILED}; \ fi \ fi rmdir ${DESTDIR}${libdir}/objfw-config >/dev/null 2>&1 || true |
Added src/test/OTAppDelegate.m version [c99ef75558].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFApplication.h" #import "OFColor.h" #import "OFDictionary.h" #import "OFMethodSignature.h" #import "OFSet.h" #import "OFStdIOStream.h" #import "OFValue.h" #import "OTTestCase.h" #import "OTAssertionFailedException.h" #import "OTTestSkippedException.h" #ifdef OF_IOS # include <CoreFoundation/CoreFoundation.h> #endif #ifdef OF_WII # define asm __asm__ # include <gccore.h> # include <wiiuse/wpad.h> # undef asm #endif #ifdef OF_NINTENDO_DS # define asm __asm__ # include <nds.h> # undef asm #endif #ifdef OF_NINTENDO_3DS /* Newer versions of libctru started using id as a parameter name. */ # define id id_3ds # include <3ds.h> # undef id #endif #ifdef OF_NINTENDO_SWITCH # define id nx_id # include <switch.h> # undef id static OFDate *lastConsoleUpdate; static void updateConsole(bool force) { if (force || lastConsoleUpdate.timeIntervalSinceNow <= -1.0 / 60) { consoleUpdate(NULL); [lastConsoleUpdate release]; lastConsoleUpdate = [[OFDate alloc] init]; } } #endif @interface OTAppDelegate: OFObject <OFApplicationDelegate> @end enum Status { StatusRunning, StatusOk, StatusFailed, StatusSkipped }; OF_APPLICATION_DELEGATE(OTAppDelegate) static bool isSubclassOfClass(Class class, Class superclass) { for (Class iter = class; iter != Nil; iter = class_getSuperclass(iter)) if (iter == superclass) return true; return false; } @implementation OTAppDelegate + (void)initialize { if (self != [OTAppDelegate class]) return; #if defined(OF_IOS) CFBundleRef mainBundle = CFBundleGetMainBundle(); CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle); UInt8 resourcesPath[PATH_MAX]; if (!CFURLGetFileSystemRepresentation(resourcesURL, true, resourcesPath, PATH_MAX)) { [OFStdErr writeLine: @"Failed to locate resources!"]; [OFApplication terminateWithStatus: 1]; } [[OFFileManager defaultManager] changeCurrentDirectoryPath: [OFString stringWithUTF8String: (const char *)resourcesPath]]; CFRelease(resourcesURL); #elif defined(OF_WII) GXRModeObj *mode; void *nextFB; VIDEO_Init(); WPAD_Init(); mode = VIDEO_GetPreferredMode(NULL); nextFB = MEM_K0_TO_K1(SYS_AllocateFramebuffer(mode)); VIDEO_Configure(mode); VIDEO_SetNextFramebuffer(nextFB); VIDEO_SetBlack(FALSE); VIDEO_Flush(); VIDEO_WaitVSync(); if (mode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync(); CON_InitEx(mode, 2, 2, mode->fbWidth - 4, mode->xfbHeight - 4); VIDEO_ClearFrameBuffer(mode, nextFB, COLOR_BLACK); #elif defined(OF_NINTENDO_DS) consoleDemoInit(); #elif defined(OF_NINTENDO_3DS) gfxInitDefault(); atexit(gfxExit); consoleInit(GFX_TOP, NULL); #elif defined(OF_NINTENDO_SWITCH) consoleInit(NULL); padConfigureInput(1, HidNpadStyleSet_NpadStandard); updateConsole(true); #endif } - (OFMutableSet OF_GENERIC(Class) *)testClasses { Class *classes; int classesCount; OFMutableSet *testClasses; classesCount = objc_getClassList(NULL, 0); if (classesCount < 1) return nil; classes = OFAllocMemory(classesCount, sizeof(Class)); @try { if ((int)objc_getClassList(classes, classesCount) != classesCount) return nil; testClasses = [OFMutableSet set]; for (int i = 0; i < classesCount; i++) { /* * Make sure the class is initialized. * Required for the ObjFW runtime, as otherwise * class_getSuperclass() crashes. */ #ifdef OF_OBJFW_RUNTIME [classes[i] class]; #endif /* * Don't use +[isSubclassOfClass:], as the Apple runtime * can return (presumably internal?) classes that don't * implement it, resulting in a crash. */ if (isSubclassOfClass(classes[i], [OTTestCase class])) [testClasses addObject: classes[i]]; } } @finally { OFFreeMemory(classes); } [testClasses removeObject: [OTTestCase class]]; return testClasses; } - (OFSet OF_GENERIC(OFValue *) *)testsInClass: (Class)class { Method *methods = class_copyMethodList(class, NULL); OFMutableSet *tests; if (methods == NULL) return nil; @try { tests = [OFMutableSet set]; for (Method *iter = methods; *iter != NULL; iter++) { SEL selector = method_getName(*iter); void *pool; OFMethodSignature *sig; if (selector == NULL) continue; if (strncmp(sel_getName(selector), "test", 4) != 0) continue; pool = objc_autoreleasePoolPush(); sig = [OFMethodSignature signatureWithObjCTypes: method_getTypeEncoding(*iter)]; if (strcmp(sig.methodReturnType, "v") == 0 && sig.numberOfArguments == 2 && strcmp([sig argumentTypeAtIndex: 0], "@") == 0 && strcmp([sig argumentTypeAtIndex: 1], ":") == 0) [tests addObject: [OFValue valueWithPointer: selector]]; objc_autoreleasePoolPop(pool); } } @finally { OFFreeMemory(methods); } if (class_getSuperclass(class) != Nil) [tests unionSet: [self testsInClass: class_getSuperclass(class)]]; [tests makeImmutable]; return tests; } - (void)printStatusForTest: (SEL)test inClass: (Class)class status: (enum Status)status description: (OFString *)description { switch (status) { case StatusRunning: if (OFStdOut.hasTerminal) { [OFStdOut setForegroundColor: [OFColor olive]]; [OFStdOut writeFormat: @"-[%@ ", class]; [OFStdOut setForegroundColor: [OFColor yellow]]; [OFStdOut writeFormat: @"%s", sel_getName(test)]; [OFStdOut setForegroundColor: [OFColor olive]]; [OFStdOut writeString: @"]: "]; } else [OFStdOut writeFormat: @"-[%@ %s]: ", class, sel_getName(test)]; break; case StatusOk: if (OFStdOut.hasTerminal) { [OFStdOut setCursorColumn: 0]; [OFStdOut eraseLine]; [OFStdOut setForegroundColor: [OFColor green]]; [OFStdOut writeFormat: @"-[%@ ", class]; [OFStdOut setForegroundColor: [OFColor lime]]; [OFStdOut writeFormat: @"%s", sel_getName(test)]; [OFStdOut setForegroundColor: [OFColor green]]; [OFStdOut writeLine: @"]: ok"]; } else [OFStdOut writeLine: @"ok"]; break; case StatusFailed: if (OFStdOut.hasTerminal) { [OFStdOut setCursorColumn: 0]; [OFStdOut eraseLine]; [OFStdOut setForegroundColor: [OFColor maroon]]; [OFStdOut writeFormat: @"-[%@ ", class]; [OFStdOut setForegroundColor: [OFColor red]]; [OFStdOut writeFormat: @"%s", sel_getName(test)]; [OFStdOut setForegroundColor: [OFColor maroon]]; [OFStdOut writeLine: @"]: failed"]; } else [OFStdOut writeLine: @"failed"]; if (description != nil) [OFStdOut writeLine: description]; break; case StatusSkipped: if (OFStdOut.hasTerminal) { [OFStdOut setCursorColumn: 0]; [OFStdOut eraseLine]; [OFStdOut setForegroundColor: [OFColor gray]]; [OFStdOut writeFormat: @"-[%@ ", class]; [OFStdOut setForegroundColor: [OFColor silver]]; [OFStdOut writeFormat: @"%s", sel_getName(test)]; [OFStdOut setForegroundColor: [OFColor gray]]; [OFStdOut writeLine: @"]: skipped"]; } else [OFStdOut writeLine: @"skipped"]; if (description != nil) [OFStdOut writeLine: description]; break; } if (status == StatusFailed) { #if defined(OF_WII) [OFStdOut setForegroundColor: [OFColor silver]]; [OFStdOut writeLine: @"Press A to continue"]; for (;;) { WPAD_ScanPads(); if (WPAD_ButtonsDown(0) & WPAD_BUTTON_A) break; VIDEO_WaitVSync(); } #elif defined(OF_NINTENDO_DS) [OFStdOut setForegroundColor: [OFColor silver]]; [OFStdOut writeLine: @"Press A to continue"]; for (;;) { swiWaitForVBlank(); scanKeys(); if (keysDown() & KEY_A) break; } #elif defined(OF_NINTENDO_3DS) [OFStdOut setForegroundColor: [OFColor silver]]; [OFStdOut writeLine: @"Press A to continue"]; for (;;) { hidScanInput(); if (hidKeysDown() & KEY_A) break; gspWaitForVBlank(); } #elif defined(OF_NINTENDO_SWITCH) [OFStdOut setForegroundColor: [OFColor silver]]; [OFStdOut writeLine: @"Press A to continue"]; while (appletMainLoop()) { PadState pad; padUpdate(&pad); updateConsole(true); if (padGetButtonsDown(&pad) & HidNpadButton_A) break; } #endif } } - (OFString *)descriptionForException: (id)exception { OFMutableString *description = [OFMutableString stringWithFormat: @"Unhandled exception: %@", exception]; OFArray OF_GENERIC(OFValue *) *stackTraceAddresses = nil; OFArray OF_GENERIC(OFString *) *stackTraceSymbols = nil; OFStringEncoding encoding = [OFLocale encoding]; if ([exception respondsToSelector: @selector(stackTraceAddresses)]) stackTraceAddresses = [exception stackTraceAddresses]; if (stackTraceAddresses != nil) { size_t count = stackTraceAddresses.count; if ([exception respondsToSelector: @selector(stackTraceSymbols)]) stackTraceSymbols = [exception stackTraceSymbols]; if (stackTraceSymbols.count != count) stackTraceSymbols = nil; [description appendString: @"\n\nStack trace:"]; if (stackTraceSymbols != nil) { for (size_t i = 0; i < count; i++) { void *address = [[stackTraceAddresses objectAtIndex: i] pointerValue]; const char *symbol = [[stackTraceSymbols objectAtIndex: i] cStringWithEncoding: encoding]; [description appendFormat: @"\n %p %s", address, symbol]; } } else { for (size_t i = 0; i < count; i++) { void *address = [[stackTraceAddresses objectAtIndex: i] pointerValue]; [description appendFormat: @"\n %p", address]; } } } [description makeImmutable]; return description; } - (void)applicationDidFinishLaunching: (OFNotification *)notification { OFMutableSet OF_GENERIC(Class) *testClasses; size_t numSucceeded = 0, numFailed = 0, numSkipped = 0; OFMutableDictionary *summaries = [OFMutableDictionary dictionary]; if ([OFApplication arguments].count > 0) { testClasses = [OFMutableSet set]; for (OFString *className in [OFApplication arguments]) { Class class = objc_lookUpClass([className cStringWithEncoding: OFStringEncodingASCII]); if (class == Nil || !isSubclassOfClass(class, [OTTestCase class])) { [OFStdErr writeFormat: @"%@ is not a valid " @"test case!\n", className]; [OFApplication terminateWithStatus: 1]; } [testClasses addObject: class]; } } else testClasses = [self testClasses]; [OFStdOut setForegroundColor: [OFColor purple]]; [OFStdOut writeString: @"Running "]; #if !defined(OF_WII) && !defined(OF_NINTENDO_DS) && \ !defined(OF_NINTENDO_3DS) && !defined(OF_NINTENDO_SWITCH) [OFStdOut setForegroundColor: [OFColor fuchsia]]; #endif [OFStdOut writeFormat: @"%zu", testClasses.count]; [OFStdOut setForegroundColor: [OFColor purple]]; [OFStdOut writeFormat: @" test case%s\n", (testClasses.count != 1 ? "s" : "")]; for (Class class in testClasses) { OFArray *summary; [OFStdOut setForegroundColor: [OFColor teal]]; [OFStdOut writeFormat: @"Running ", class]; [OFStdOut setForegroundColor: [OFColor aqua]]; [OFStdOut writeFormat: @"%@\n", class]; for (OFValue *test in [self testsInClass: class]) { void *pool = objc_autoreleasePoolPush(); bool failed = false, skipped = false; OTTestCase *instance; [self printStatusForTest: test.pointerValue inClass: class status: StatusRunning description: nil]; instance = [[[class alloc] init] autorelease]; @try { [instance setUp]; [instance performSelector: test.pointerValue]; } @catch (OTAssertionFailedException *e) { /* * If an assertion fails during -[setUp], don't * run the test. * If an assertion fails during a test, abort * the test. */ [self printStatusForTest: test.pointerValue inClass: class status: StatusFailed description: e.description]; failed = true; } @catch (OTTestSkippedException *e) { [self printStatusForTest: test.pointerValue inClass: class status: StatusSkipped description: e.description]; skipped = true; } @catch (id e) { OFString *description = [self descriptionForException: e]; [self printStatusForTest: test.pointerValue inClass: class status: StatusFailed description: description]; failed = true; } @try { [instance tearDown]; } @catch (OTAssertionFailedException *e) { /* * If an assertion fails during -[tearDown], * abort the tear down. */ if (!failed) { SEL selector = test.pointerValue; OFString *description = e.description; [self printStatusForTest: selector inClass: class status: StatusFailed description: description]; failed = true; } } @catch (id e) { OFString *description = [self descriptionForException: e]; [self printStatusForTest: test.pointerValue inClass: class status: StatusFailed description: description]; failed = true; } if (failed) numFailed++; else if (skipped) numSkipped++; else { [self printStatusForTest: test.pointerValue inClass: class status: StatusOk description: nil]; numSucceeded++; } objc_autoreleasePoolPop(pool); } summary = [class summary]; if (summary != nil) [summaries setObject: summary forKey: class]; } for (Class class in summaries) { OFArray *summary = [summaries objectForKey: class]; [OFStdOut setForegroundColor: [OFColor teal]]; [OFStdOut writeString: @"Summary for "]; [OFStdOut setForegroundColor: [OFColor aqua]]; [OFStdOut writeFormat: @"%@\n", class]; for (OFPair *line in summary) { [OFStdOut setForegroundColor: [OFColor navy]]; [OFStdOut writeFormat: @"%@: ", line.firstObject]; [OFStdOut setForegroundColor: [OFColor blue]]; [OFStdOut writeFormat: @"%@\n", line.secondObject]; } } #if !defined(OF_WII) && !defined(OF_NINTENDO_DS) && \ !defined(OF_NINTENDO_3DS) && !defined(OF_NINTENDO_SWITCH) [OFStdOut setForegroundColor: [OFColor fuchsia]]; #else [OFStdOut setForegroundColor: [OFColor purple]]; #endif [OFStdOut writeFormat: @"%zu", numSucceeded]; [OFStdOut setForegroundColor: [OFColor purple]]; [OFStdOut writeFormat: @" test%s succeeded, ", (numSucceeded != 1 ? "s" : "")]; #if !defined(OF_WII) && !defined(OF_NINTENDO_DS) && \ !defined(OF_NINTENDO_3DS) && !defined(OF_NINTENDO_SWITCH) [OFStdOut setForegroundColor: [OFColor fuchsia]]; #endif [OFStdOut writeFormat: @"%zu", numFailed]; [OFStdOut setForegroundColor: [OFColor purple]]; [OFStdOut writeFormat: @" test%s failed, ", (numFailed != 1 ? "s" : "")]; #if !defined(OF_WII) && !defined(OF_NINTENDO_DS) && \ !defined(OF_NINTENDO_3DS) && !defined(OF_NINTENDO_SWITCH) [OFStdOut setForegroundColor: [OFColor fuchsia]]; #endif [OFStdOut writeFormat: @"%zu", numSkipped]; [OFStdOut setForegroundColor: [OFColor purple]]; [OFStdOut writeFormat: @" test%s skipped\n", (numSkipped != 1 ? "s" : "")]; [OFStdOut reset]; #if defined(OF_WII) [OFStdOut setForegroundColor: [OFColor silver]]; [OFStdOut writeLine: @"Press home button to exit"]; for (;;) { WPAD_ScanPads(); if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) break; VIDEO_WaitVSync(); } #elif defined(OF_NINTENDO_DS) [OFStdOut setForegroundColor: [OFColor silver]]; [OFStdOut writeLine: @"Press start button to exit"]; for (;;) { swiWaitForVBlank(); scanKeys(); if (keysDown() & KEY_START) break; } #elif defined(OF_NINTENDO_3DS) [OFStdOut setForegroundColor: [OFColor silver]]; [OFStdOut writeLine: @"Press start button to exit"]; for (;;) { hidScanInput(); if (hidKeysDown() & KEY_START) break; gspWaitForVBlank(); } #elif defined(OF_NINTENDO_SWITCH) while (appletMainLoop()) updateConsole(true); consoleExit(NULL); #endif [OFApplication terminateWithStatus: (int)numFailed]; } @end |
Added src/test/OTAssert.h version [8bd6d8696c].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ /* * Unfortunately, that's the only way to make all compilers happy with the GNU * extensions for variadic macros that are being used here. */ #pragma GCC system_header /** @file */ /** * @brief Asserts that the specified condition condition holds. * * @param condition The condition to check * @param ... An optional format string to print if the assertion failed, * followed by optional arguments */ #define OTAssert(condition, ...) \ OTAssertImpl(self, _cmd, condition, @#condition, \ @__FILE__, __LINE__, ## __VA_ARGS__, nil) /** * @brief Asserts that the specified condition is true. * * @param condition The condition to check * @param ... An optional format string to print if the assertion failed, * followed by optional arguments */ #define OTAssertTrue(condition, ...) \ OTAssert(condition == true, ## __VA_ARGS__) /** * @brief Asserts that the specified condition is false. * * @param condition The condition to check * @param ... An optional format string to print if the assertion failed, * followed by optional arguments */ #define OTAssertFalse(condition, ...) \ OTAssert(condition == false, ## __VA_ARGS__) /** * @brief Asserts that the two values are equal. * * @param a The value to check * @param b The expected value * @param ... An optional format string to print if the assertion failed, * followed by optional arguments */ #define OTAssertEqual(a, b, ...) OTAssert(a == b, ## __VA_ARGS__) /** * @brief Asserts that the two values are not equal. * * @param a The value to check * @param b The value `a` should not have * @param ... An optional format string to print if the assertion failed, * followed by optional arguments */ #define OTAssertNotEqual(a, b, ...) OTAssert(a != b, ## __VA_ARGS__) /** * @brief Asserts that the value is less than another value. * * @param a The value to check * @param b The value `a` should be less than * @param ... An optional format string to print if the assertion failed, * followed by optional arguments */ #define OTAssertLessThan(a, b, ...) OTAssert(a < b, ## __VA_ARGS__) /** * @brief Asserts that the value is less than or equal to another value. * * @param a The value to check * @param b The value `a` should be less than or equal to * @param ... An optional format string to print if the assertion failed, * followed by optional arguments */ #define OTAssertLessThanOrEqual(a, b, ...) OTAssert(a <= b, ## __VA_ARGS__) /** * @brief Asserts that the value is greater than another value. * * @param a The value to check * @param b The value `a` should be greater than * @param ... An optional format string to print if the assertion failed, * followed by optional arguments */ #define OTAssertGreaterThan(a, b, ...) OTAssert(a > b, ## __VA_ARGS__) /** * @brief Asserts that the value is greater than or equal to another value. * * @param a The value to check * @param b The value `a` should be greater than or equal to * @param ... An optional format string to print if the assertion failed, * followed by optional arguments */ #define OTAssertGreaterThanOrEqual(a, b, ...) OTAssert(a >= b, ## __VA_ARGS__) /** * @brief Asserts that the two objects are equal. * * @param a The object to check * @param b The object `a` is expected to be equal to * @param ... An optional format string to print if the assertion failed, * followed by optional arguments */ #define OTAssertEqualObjects(a, b, ...) OTAssert([a isEqual: b], ## __VA_ARGS__) /** * @brief Asserts that the two objects are not equal. * * @param a The object to check * @param b The object `a` is expected to be not equal to * @param ... An optional format string to print if the assertion failed, * followed by optional arguments */ #define OTAssertNotEqualObjects(a, b, ...) \ OTAssert(![a isEqual: b], ## __VA_ARGS__) /** * @brief Asserts that the specified object is `nil`. * * @param object The object to should be `nil` * @param ... An optional format string to print if the assertion failed, * followed by optional arguments */ #define OTAssertNil(object, ...) OTAssert(object == nil, ## __VA_ARGS__) /** * @brief Asserts that the specified object is not `nil`. * * @param object The object to should not be `nil` * @param ... An optional format string to print if the assertion failed, * followed by optional arguments */ #define OTAssertNotNil(object, ...) OTAssert(object != nil, ## __VA_ARGS__) /** * @brief Asserts that the specified expression throws an exception. * * @param expression The expression that should throw * @param ... An optional format string to print if the assertion failed, * followed by optional arguments */ #define OTAssertThrows(expression, ...) \ { \ bool OTThrown = false; \ @try { \ expression; \ } @catch (id e) { \ OTThrown = true; \ } \ OTAssert(OTThrown, ## __VA_ARGS__); \ } /** * @brief Asserts that the specified expression throws a specific exception. * * @param expression The expression that should throw * @param exception The exception the expression should throw (as just the * class name, without quotes) * @param ... An optional format string to print if the assertion failed, * followed by optional arguments */ #define OTAssertThrowsSpecific(expression, exception, ...) \ { \ bool OTThrown = false; \ @try { \ expression; \ } @catch (exception *e) { \ OTThrown = true; \ } \ OTAssert(OTThrown, ## __VA_ARGS__); \ } /** * @brief Skips the current test, making it neither fail nor succeeed. * * @param ... An optional format string to print why the test was skipped, * followed by optional arguments */ #define OTSkip(...) \ OTSkipImpl(self, _cmd, @__FILE__, __LINE__, ## __VA_ARGS__, nil) #ifdef __cplusplus extern "C" { #endif extern void OTAssertImpl(id testCase, SEL test, bool condition, OFString *check, OFString *file, size_t line, ...); extern void OTSkipImpl(id testCase, SEL test, OFString *file, size_t line, ...); #ifdef __cplusplus } #endif |
Added src/test/OTAssert.m version [fa56e52ecc].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFString.h" #import "OTAssertionFailedException.h" #import "OTTestSkippedException.h" void OTAssertImpl(id testCase, SEL test, bool condition, OFString *check, OFString *file, size_t line, ...) { va_list arguments; OFConstantString *format; OFString *message = nil; if (condition) return; va_start(arguments, line); format = va_arg(arguments, OFConstantString *); if (format != nil) message = [[[OFString alloc] initWithFormat: format arguments: arguments] autorelease]; va_end(arguments); @throw [OTAssertionFailedException exceptionWithCondition: check message: message]; } void OTSkipImpl(id testCase, SEL test, OFString *file, size_t line, ...) { va_list arguments; OFConstantString *format; OFString *message = nil; va_start(arguments, line); format = va_arg(arguments, OFConstantString *); if (format != nil) message = [[[OFString alloc] initWithFormat: format arguments: arguments] autorelease]; va_end(arguments); @throw [OTTestSkippedException exceptionWithMessage: message]; } |
Added src/test/OTAssertionFailedException.h version [a426a27580].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" #import "OFString.h" OF_ASSUME_NONNULL_BEGIN @interface OTAssertionFailedException: OFException { OFString *_condition; OFString *_Nullable _message; } @property (readonly, nonatomic) OFString *condition; @property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *message; + (instancetype)exceptionWithCondition: (OFString *)condition message: (nullable OFString *)message; + (instancetype)exception OF_UNAVAILABLE; - (instancetype)initWithCondition: (OFString *)condition message: (nullable OFString *)message; - (instancetype)init OF_UNAVAILABLE; @end OF_ASSUME_NONNULL_END |
Added src/test/OTAssertionFailedException.m version [8275923ef8].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OTAssertionFailedException.h" @implementation OTAssertionFailedException @synthesize condition = _condition, message = _message; + (instancetype)exceptionWithCondition: (OFString *)condition message: (OFString *)message { return [[[self alloc] initWithCondition: condition message: message] autorelease]; } + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } - (instancetype)initWithCondition: (OFString *)condition message: (OFString *)message { self = [super init]; @try { _condition = [condition copy]; _message = [message copy]; } @catch (id e) { [self release]; @throw e; } return self; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (void)dealloc { [_condition release]; [_message release]; [super dealloc]; } - (OFString *)description { if (_message != nil) return [OFString stringWithFormat: @"Assertion failed: %@: %@", _condition, _message]; else return [OFString stringWithFormat: @"Assertion failed: %@", _condition]; } @end |
Added src/test/OTOrderedDictionary.h version [b58c686a8a].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #ifdef OBJFWTEST_LOCAL_INCLUDES # import "ObjFW.h" #else # import <ObjFW/ObjFW.h> #endif OF_ASSUME_NONNULL_BEGIN /** * @brief A dictionary that enumerates keys and objects in the same order they * were specified during initialization. * * @warning This class is only for testing! It is slow and only to be used to * test extensions of OFDictionary, for example serializations such as * JSON, where it is desirable to compare to an expected output. * * @note ABI stability for this and all other classes in ObjFWTest is not * guaranteed! The assumption is that you recompile your tests after * updating ObjFWTest. */ @interface OTOrderedDictionary: OFDictionary { OFArray *_keys; OFArray *_objects; } @end OF_ASSUME_NONNULL_END |
Added src/test/OTOrderedDictionary.m version [2b5e38180e].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OTOrderedDictionary.h" @implementation OTOrderedDictionary - (instancetype)initWithObjects: (id const *)objects forKeys: (id const *)keys count: (size_t)count { self = [super init]; @try { OFMutableArray *mutableKeys, *mutableObjects; mutableKeys = [[OFMutableArray alloc] initWithCapacity: count]; _keys = mutableKeys; mutableObjects = [[OFMutableArray alloc] initWithCapacity: count]; _objects = mutableObjects; for (size_t i = 0; i < count; i++) { [mutableKeys addObject: keys[i]]; [mutableObjects addObject: objects[i]]; } [mutableKeys makeImmutable]; [mutableObjects makeImmutable]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_keys release]; [_objects release]; [super dealloc]; } - (id)objectForKey: (id)key { size_t i = 0; for (id iter in _keys) { if ([iter isEqual: key]) return [_objects objectAtIndex: i]; i++; } return nil; } - (size_t)count { return _keys.count; } - (OFEnumerator *)keyEnumerator { return [_keys objectEnumerator]; } - (OFEnumerator *)objectEnumerator { return [_objects objectEnumerator]; } @end |
Added src/test/OTTestCase.h version [9387d889a7].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #ifdef OBJFWTEST_LOCAL_INCLUDES # import "ObjFW.h" #else # import <ObjFW/ObjFW.h> #endif OF_ASSUME_NONNULL_BEGIN /** * @brief A class meant for subclassing to create a test case, consisting of * one or more tests. * * All methods with the prefix `test` that take no arguments of all classes * that subclass this class are automatically executed by ObjFWTest. * * @note ABI stability for this and all other classes in ObjFWTest is not * guaranteed! The assumption is that you recompile your tests after * updating ObjFWTest. */ @interface OTTestCase: OFObject #ifdef OF_HAVE_CLASS_PROPERTIES @property (class, readonly, nullable, nonatomic) OFArray OF_GENERIC(OFPair OF_GENERIC(OFString *, id) *) *summary; #endif /** * @brief Returns a summary for the test case that should be printed once all * tests in all test cases were run. * * This is mostly useful to print something at the end of all tests that needs * manual verification. */ + (nullable OFArray OF_GENERIC(OFPair OF_GENERIC(OFString *, id) *) *)summary; /** * @brief Set up method that is run before every test in the test case. */ - (void)setUp; /** * @brief Tear down method that is run after every test in the test case. */ - (void)tearDown; @end OF_ASSUME_NONNULL_END |
Added src/test/OTTestCase.m version [b5276549e5].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OTTestCase.h" @implementation OTTestCase: OFObject + (OFArray OF_GENERIC(OFPair OF_GENERIC(OFString *, id) *) *)summary { return nil; } - (void)setUp { } - (void)tearDown { } @end |
Added src/test/OTTestSkippedException.h version [ace1ca919d].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFException.h" #import "OFString.h" OF_ASSUME_NONNULL_BEGIN @interface OTTestSkippedException: OFException { OFString *_Nullable _message; } @property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *message; + (instancetype)exceptionWithMessage: (nullable OFString *)message; + (instancetype)exception OF_UNAVAILABLE; - (instancetype)initWithMessage: (nullable OFString *)message; - (instancetype)init OF_UNAVAILABLE; @end OF_ASSUME_NONNULL_END |
Added src/test/OTTestSkippedException.m version [8fb2dceb24].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OTTestSkippedException.h" @implementation OTTestSkippedException @synthesize message = _message; + (instancetype)exceptionWithMessage: (OFString *)message { return [[[self alloc] initWithMessage: message] autorelease]; } + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } - (instancetype)initWithMessage: (OFString *)message { self = [super init]; @try { _message = [message copy]; } @catch (id e) { [self release]; @throw e; } return self; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (void)dealloc { [_message release]; [super dealloc]; } - (OFString *)description { if (_message != nil) return [OFString stringWithFormat: @"Test skipped: %@", _message]; else return nil; } @end |
Added src/test/ObjFWTest.h version [830f4d3559].
> > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OTTestCase.h" #import "OTAssert.h" #import "OTOrderedDictionary.h" |
Added src/test/ObjFWTest.oc version [01fc34b47c].
> > > > | 1 2 3 4 | package_format 1 LIBS="-lobjfwtest $LIBS" FRAMEWORK_LIBS="-lobjfwtest $FRAMEWORK_LIBS" STATIC_LIBS="${libdir}/libobjfwtest.a $STATIC_LIBS" |
Modified src/tls/Makefile from [a6c2c67827] to [1c286ab06b].
1 2 3 4 5 6 7 | include ../../extra.mk DISTCLEAN = Info.plist SHARED_LIB = ${OBJFWTLS_SHARED_LIB} STATIC_LIB = ${OBJFWTLS_STATIC_LIB} FRAMEWORK = ${OBJFWTLS_FRAMEWORK} | | | > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | include ../../extra.mk DISTCLEAN = Info.plist SHARED_LIB = ${OBJFWTLS_SHARED_LIB} STATIC_LIB = ${OBJFWTLS_STATIC_LIB} FRAMEWORK = ${OBJFWTLS_FRAMEWORK} LIB_MAJOR = ${OBJFWTLS_LIB_MAJOR} LIB_MINOR = ${OBJFWTLS_LIB_MINOR} LIB_PATCH = ${OBJFWTLS_LIB_PATCH} INCLUDES := ObjFWTLS.h SRCS = ${OF_GNUTLS_TLS_STREAM_M} \ ${OF_MBEDTLS_TLS_STREAM_M} \ ${OF_OPENSSL_TLS_STREAM_M} \ ${OF_SECURE_TRANSPORT_TLS_STREAM_M} includesubdir = ObjFWTLS include ../../buildsys.mk install-extra: i=ObjFWTLS.oc; \ ${INSTALL_STATUS}; \ if ${MKDIR_P} ${DESTDIR}${libdir}/objfw-config && \ ${INSTALL} -m 644 $$i ${DESTDIR}${libdir}/objfw-config/$$i; then \ ${INSTALL_OK}; \ else \ ${INSTALL_FAILED}; \ fi uninstall-extra: i=ObjFWTLS.oc; \ if test -f ${DESTDIR}${libdir}/objfw-config/$$i; then \ if rm -f ${DESTDIR}${libdir}/objfw-config/$$i; then \ ${DELETE_OK}; \ else \ ${DELETE_FAILED}; \ fi \ fi rmdir ${DESTDIR}${libdir}/objfw-config >/dev/null 2>&1 || true CPPFLAGS += -I. -I.. -I../.. -I../exceptions -I../runtime ${TLS_CPPFLAGS} LD = ${OBJC} FRAMEWORK_LIBS := ${TLS_LIBS} -F.. -framework ObjFW ${LIBS} LIBS := ${TLS_LIBS} -L.. -lobjfw -L../runtime ${RUNTIME_LIBS} ${LIBS} |
Modified src/tls/OFGnuTLSTLSStream.h from [d33b11b9cb] to [ad70118309].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFTLSStream.h" #include <gnutls/gnutls.h> OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ |
Modified src/tls/OFGnuTLSTLSStream.m from [fad8797bf6] to [5ff0b3f552].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #import "OFGnuTLSTLSStream.h" #import "OFData.h" #import "OFAlreadyOpenException.h" #import "OFInitializationFailedException.h" #import "OFNotOpenException.h" #import "OFReadFailedException.h" #import "OFTLSHandshakeFailedException.h" #import "OFWriteFailedException.h" int _ObjFWTLS_reference; |
︙ | ︙ | |||
123 124 125 126 127 128 129 | if (!_initialized) @throw [OFNotOpenException exceptionWithObject: self]; if (_handshakeDone) gnutls_bye(_session, GNUTLS_SHUT_WR); gnutls_deinit(_session); | | | 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | if (!_initialized) @throw [OFNotOpenException exceptionWithObject: self]; if (_handshakeDone) gnutls_bye(_session, GNUTLS_SHUT_WR); gnutls_deinit(_session); _initialized = _handshakeDone = false; [_host release]; _host = nil; [super close]; } |
︙ | ︙ | |||
181 182 183 184 185 186 187 | bytesWritten: ret errNo: 0]; } return ret; } | | > | < < < > | | 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | bytesWritten: ret errNo: 0]; } return ret; } - (bool)lowlevelHasDataInReadBuffer { return (_underlyingStream.hasDataInReadBuffer || gnutls_record_check_pending(_session) > 0); } - (void)asyncPerformClientHandshakeWithHost: (OFString *)host runLoopMode: (OFRunLoopMode)runLoopMode { static const OFTLSStreamErrorCode initFailedErrorCode = OFTLSStreamErrorCodeInitializationFailed; void *pool = objc_autoreleasePoolPush(); id exception = nil; int status; if (_initialized) @throw [OFAlreadyOpenException exceptionWithObject: self]; if (gnutls_init(&_session, GNUTLS_CLIENT | GNUTLS_NONBLOCK | GNUTLS_SAFE_PADDING_CHECK) != GNUTLS_E_SUCCESS) @throw [OFTLSHandshakeFailedException exceptionWithStream: self host: host errorCode: initFailedErrorCode]; |
︙ | ︙ | |||
237 238 239 240 241 242 243 | if (_verifiesCertificates) gnutls_session_set_verify_cert(_session, _host.UTF8String, 0); status = gnutls_handshake(_session); if (status == GNUTLS_E_INTERRUPTED || status == GNUTLS_E_AGAIN) { if (gnutls_record_get_direction(_session) == 1) | | < | > > > | < < | | 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | if (_verifiesCertificates) gnutls_session_set_verify_cert(_session, _host.UTF8String, 0); status = gnutls_handshake(_session); if (status == GNUTLS_E_INTERRUPTED || status == GNUTLS_E_AGAIN) { if (gnutls_record_get_direction(_session) == 1) [_underlyingStream asyncWriteData: [OFData data] runLoopMode: runLoopMode]; else [_underlyingStream asyncReadIntoBuffer: (void *)"" length: 0 runLoopMode: runLoopMode]; [_delegate retain]; objc_autoreleasePoolPop(pool); return; } if (status == GNUTLS_E_SUCCESS) _handshakeDone = true; else /* FIXME: Map to better errors */ exception = [OFTLSHandshakeFailedException exceptionWithStream: self host: host errorCode: OFTLSStreamErrorCodeUnknown]; if ([_delegate respondsToSelector: @selector(stream:didPerformClientHandshakeWithHost:exception:)]) [_delegate stream: self didPerformClientHandshakeWithHost: host exception: exception]; objc_autoreleasePoolPop(pool); } - (bool)stream: (OFStream *)stream didReadIntoBuffer: (void *)buffer length: (size_t)length exception: (id)exception { if (exception == nil) { int status = gnutls_handshake(_session); if (status == GNUTLS_E_INTERRUPTED || status == GNUTLS_E_AGAIN) { if (gnutls_record_get_direction(_session) == 1) { OFRunLoopMode runLoopMode = [OFRunLoop currentRunLoop].currentMode; [_underlyingStream asyncWriteData: [OFData data] runLoopMode: runLoopMode]; return false; } else return true; } if (status == GNUTLS_E_SUCCESS) |
︙ | ︙ |
Added src/tls/OFMbedTLSTLSStream.h version [0cedeb4d4c].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFTLSStream.h" #include <mbedtls/ssl.h> OF_ASSUME_NONNULL_BEGIN @interface OFMbedTLSTLSStream: OFTLSStream <OFStreamDelegate> { bool _initialized, _handshakeDone; mbedtls_ssl_config _config; mbedtls_ssl_context _SSL; mbedtls_x509_crt _CAChain; OFString *_host; } @end OF_ASSUME_NONNULL_END |
Added src/tls/OFMbedTLSTLSStream.m version [85da4c8b35].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #import "OFMbedTLSTLSStream.h" #import "OFApplication.h" #import "OFData.h" #import "OFDictionary.h" #import "OFLocale.h" #import "OFAlreadyOpenException.h" #import "OFInitializationFailedException.h" #import "OFNotOpenException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFTLSHandshakeFailedException.h" #import "OFWriteFailedException.h" #include <mbedtls/ctr_drbg.h> #include <mbedtls/entropy.h> int _ObjFWTLS_reference; static mbedtls_entropy_context entropy; static mbedtls_ctr_drbg_context CTRDRBG; @implementation OFMbedTLSTLSStream static int readFunc(void *ctx, unsigned char *buffer, size_t length) { OFMbedTLSTLSStream *stream = (OFMbedTLSTLSStream *)ctx; @try { length = [stream.underlyingStream readIntoBuffer: buffer length: length]; } @catch (OFReadFailedException *e) { return -1; } if (length == 0 && !stream.underlyingStream.atEndOfStream) return MBEDTLS_ERR_SSL_WANT_READ; if (length > INT_MAX) @throw [OFOutOfRangeException exception]; return (int)length; } static int writeFunc(void *ctx, const unsigned char *buffer, size_t length) { OFMbedTLSTLSStream *stream = (OFMbedTLSTLSStream *)ctx; @try { [stream.underlyingStream writeBuffer: buffer length: length]; } @catch (OFWriteFailedException *e) { if (e.errNo == EWOULDBLOCK || e.errNo == EAGAIN) { size_t bytesWritten = e.bytesWritten; if (bytesWritten > INT_MAX) @throw [OFOutOfRangeException exception]; return (bytesWritten > 0 ? (int)bytesWritten : MBEDTLS_ERR_SSL_WANT_WRITE); } return -1; } if (length > INT_MAX) @throw [OFOutOfRangeException exception]; return (int)length; } + (void)load { if (OFTLSStreamImplementation == Nil) OFTLSStreamImplementation = self; } + (void)initialize { if (self != [OFMbedTLSTLSStream class]) return; mbedtls_entropy_init(&entropy); if (mbedtls_ctr_drbg_seed(&CTRDRBG, mbedtls_entropy_func, &entropy, NULL, 0) != 0) @throw [OFInitializationFailedException exceptionWithClass: self]; } - (instancetype)initWithStream: (OFStream <OFReadyForReadingObserving, OFReadyForWritingObserving> *)stream { self = [super initWithStream: stream]; @try { _underlyingStream.delegate = self; mbedtls_x509_crt_init(&_CAChain); } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { if (_initialized) [self close]; [_host release]; mbedtls_x509_crt_free(&_CAChain); [super dealloc]; } - (void)close { if (!_initialized) @throw [OFNotOpenException exceptionWithObject: self]; if (_handshakeDone) mbedtls_ssl_close_notify(&_SSL); mbedtls_ssl_free(&_SSL); mbedtls_ssl_config_free(&_config); _initialized = _handshakeDone = false; [_host release]; _host = nil; [super close]; } - (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length { int ret; if (!_handshakeDone) @throw [OFNotOpenException exceptionWithObject: self]; if ((ret = mbedtls_ssl_read(&_SSL, buffer, length)) < 0) { /* * The underlying stream might have had data ready, but not * enough for MbedTLS to return decrypted data. This means the * caller might have observed the TLS stream for reading, got a * ready signal and read - and expects the read to succeed, not * to fail with EWOULDBLOCK/EAGAIN, as it was signaled ready. * Therefore, return 0, as we could read 0 decrypted bytes, but * cleared the ready signal of the underlying stream. */ if (ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE) return 0; /* FIXME: Translate error to errNo */ @throw [OFReadFailedException exceptionWithObject: self requestedLength: length errNo: 0]; } return ret; } - (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length { int ret; if (!_handshakeDone) @throw [OFNotOpenException exceptionWithObject: self]; if ((ret = mbedtls_ssl_write(&_SSL, buffer, length)) < 0) { if (ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE) return 0; /* FIXME: Translate error to errNo */ @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length bytesWritten: ret errNo: 0]; } return ret; } - (bool)lowlevelHasDataInReadBuffer { return (_underlyingStream.hasDataInReadBuffer || mbedtls_ssl_get_bytes_avail(&_SSL)); } - (void)asyncPerformClientHandshakeWithHost: (OFString *)host runLoopMode: (OFRunLoopMode)runLoopMode { static const OFTLSStreamErrorCode initFailedErrorCode = OFTLSStreamErrorCodeInitializationFailed; void *pool = objc_autoreleasePoolPush(); OFString *CAFilePath; id exception = nil; int status; if (_initialized) @throw [OFAlreadyOpenException exceptionWithObject: self]; if (mbedtls_ssl_config_defaults(&_config, MBEDTLS_SSL_IS_CLIENT, MBEDTLS_SSL_TRANSPORT_STREAM, MBEDTLS_SSL_PRESET_DEFAULT) != 0) @throw [OFTLSHandshakeFailedException exceptionWithStream: self host: host errorCode: initFailedErrorCode]; mbedtls_ssl_conf_rng(&_config, mbedtls_ctr_drbg_random, &CTRDRBG); mbedtls_ssl_conf_authmode(&_config, (_verifiesCertificates ? MBEDTLS_SSL_VERIFY_REQUIRED : MBEDTLS_SSL_VERIFY_NONE)); /* TODO: Add other ways to add a CA chain */ CAFilePath = [[OFApplication environment] objectForKey: @"OBJFW_MBEDTLS_CA_PATH"]; if (CAFilePath != nil) { if (mbedtls_x509_crt_parse_file(&_CAChain, [CAFilePath cStringWithEncoding: [OFLocale encoding]]) != 0) @throw [OFTLSHandshakeFailedException exceptionWithStream: self host: host errorCode: initFailedErrorCode]; } mbedtls_ssl_conf_ca_chain(&_config, &_CAChain, NULL); mbedtls_ssl_init(&_SSL); if (mbedtls_ssl_setup(&_SSL, &_config) != 0) @throw [OFTLSHandshakeFailedException exceptionWithStream: self host: host errorCode: initFailedErrorCode]; mbedtls_ssl_set_bio(&_SSL, self, writeFunc, readFunc, NULL); _host = [host copy]; if (mbedtls_ssl_set_hostname(&_SSL, _host.UTF8String) != 0) @throw [OFTLSHandshakeFailedException exceptionWithStream: self host: host errorCode: initFailedErrorCode]; status = mbedtls_ssl_handshake(&_SSL); if (status == MBEDTLS_ERR_SSL_WANT_READ) { [_underlyingStream asyncReadIntoBuffer: (void *)"" length: 0 runLoopMode: runLoopMode]; [_delegate retain]; objc_autoreleasePoolPop(pool); return; } else if (status == MBEDTLS_ERR_SSL_WANT_WRITE) { [_underlyingStream asyncWriteData: [OFData data] runLoopMode: runLoopMode]; [_delegate retain]; objc_autoreleasePoolPop(pool); return; } if (status == 0) _handshakeDone = true; else /* FIXME: Map to better errors */ exception = [OFTLSHandshakeFailedException exceptionWithStream: self host: host errorCode: OFTLSStreamErrorCodeUnknown]; if ([_delegate respondsToSelector: @selector(stream:didPerformClientHandshakeWithHost:exception:)]) [_delegate stream: self didPerformClientHandshakeWithHost: host exception: exception]; objc_autoreleasePoolPop(pool); } - (bool)stream: (OFStream *)stream didReadIntoBuffer: (void *)buffer length: (size_t)length exception: (id)exception { if (exception == nil) { int status = mbedtls_ssl_handshake_step(&_SSL); if (status == MBEDTLS_ERR_SSL_WANT_READ) return true; else if (status == MBEDTLS_ERR_SSL_WANT_WRITE) { OFRunLoopMode runLoopMode = [OFRunLoop currentRunLoop].currentMode; [_underlyingStream asyncWriteData: [OFData data] runLoopMode: runLoopMode]; return false; } if (status == 0) _handshakeDone = true; else exception = [OFTLSHandshakeFailedException exceptionWithStream: self host: _host errorCode: OFTLSStreamErrorCodeUnknown]; } if ([_delegate respondsToSelector: @selector(stream:didPerformClientHandshakeWithHost:exception:)]) [_delegate stream: self didPerformClientHandshakeWithHost: _host exception: exception]; [_delegate release]; return false; } - (OFData *)stream: (OFStream *)stream didWriteData: (OFData *)data bytesWritten: (size_t)bytesWritten exception: (id)exception { if (exception == nil) { int status = mbedtls_ssl_handshake_step(&_SSL); if (status == MBEDTLS_ERR_SSL_WANT_WRITE) return data; else if (status == MBEDTLS_ERR_SSL_WANT_READ) { OFRunLoopMode runLoopMode = [OFRunLoop currentRunLoop].currentMode; [_underlyingStream asyncReadIntoBuffer: (void *)"" length: 0 runLoopMode: runLoopMode]; return nil; } if (status == 0) _handshakeDone = true; else exception = [OFTLSHandshakeFailedException exceptionWithStream: self host: _host errorCode: OFTLSStreamErrorCodeUnknown]; } if ([_delegate respondsToSelector: @selector(stream:didPerformClientHandshakeWithHost:exception:)]) [_delegate stream: self didPerformClientHandshakeWithHost: _host exception: exception]; [_delegate release]; return nil; } @end |
Modified src/tls/OFOpenSSLTLSStream.h from [5bdb0a26b6] to [4327ec3147].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFTLSStream.h" #include <openssl/bio.h> #include <openssl/ssl.h> |
︙ | ︙ |
Modified src/tls/OFOpenSSLTLSStream.m from [faf6205c5a] to [b63cbb4514].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #import "OFOpenSSLTLSStream.h" #import "OFData.h" #import "OFAlreadyOpenException.h" #import "OFInitializationFailedException.h" #import "OFNotOpenException.h" #import "OFReadFailedException.h" #import "OFTLSHandshakeFailedException.h" #import "OFWriteFailedException.h" #define bufferSize OFOpenSSLTLSStreamBufferSize |
︙ | ︙ | |||
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | if (_handshakeDone) SSL_shutdown(_SSL); SSL_free(_SSL); _SSL = NULL; [_host release]; _host = nil; [super close]; } - (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length { int ret; size_t bytesRead; if (!_handshakeDone) @throw [OFNotOpenException exceptionWithObject: self]; | > > < < < < < < < < < < < < < < < < | > | > > > | > > | > > > > > > > > > | > | > > | > | > > > | > > | | > | | | | < < < | 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | if (_handshakeDone) SSL_shutdown(_SSL); SSL_free(_SSL); _SSL = NULL; _handshakeDone = false; [_host release]; _host = nil; [super close]; } - (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length { int ret; size_t bytesRead; if (!_handshakeDone) @throw [OFNotOpenException exceptionWithObject: self]; ret = SSL_read_ex(_SSL, buffer, length, &bytesRead); while (BIO_ctrl_pending(_writeBIO) > 0) { int tmp = BIO_read(_writeBIO, _buffer, bufferSize); OFEnsure(tmp >= 0); [_underlyingStream writeBuffer: _buffer length: tmp]; [_underlyingStream flushWriteBuffer]; } if (ret == 1) return bytesRead; if (SSL_get_error(_SSL, ret) == SSL_ERROR_WANT_READ) { if (BIO_ctrl_pending(_readBIO) < 1) { @try { size_t tmp = [_underlyingStream readIntoBuffer: _buffer length: bufferSize]; OFEnsure(tmp <= INT_MAX); /* Writing to a memory BIO must never fail. */ OFEnsure(BIO_write(_readBIO, _buffer, (int)tmp) == (int)tmp); } @catch (OFReadFailedException *e) { if (e.errNo == EWOULDBLOCK || e.errNo != EAGAIN) return 0; } } ret = SSL_read_ex(_SSL, buffer, length, &bytesRead); while (BIO_ctrl_pending(_writeBIO) > 0) { int tmp = BIO_read(_writeBIO, _buffer, bufferSize); OFEnsure(tmp >= 0); [_underlyingStream writeBuffer: _buffer length: tmp]; [_underlyingStream flushWriteBuffer]; } if (ret == 1) return bytesRead; if (SSL_get_error(_SSL, ret) == SSL_ERROR_WANT_READ) return 0; } /* FIXME: Translate error to errNo */ @throw [OFReadFailedException exceptionWithObject: self requestedLength: length errNo: 0]; } - (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length { int ret; size_t bytesWritten; |
︙ | ︙ | |||
186 187 188 189 190 191 192 | [_underlyingStream writeBuffer: _buffer length: tmp]; [_underlyingStream flushWriteBuffer]; } return bytesWritten; } | | > > | < | | > > > | | 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | [_underlyingStream writeBuffer: _buffer length: tmp]; [_underlyingStream flushWriteBuffer]; } return bytesWritten; } - (bool)lowlevelHasDataInReadBuffer { #ifdef HAVE_SSL_HAS_PENDING return (_underlyingStream.hasDataInReadBuffer || SSL_has_pending(_SSL) || BIO_ctrl_pending(_readBIO) > 0); #else return (_underlyingStream.hasDataInReadBuffer || SSL_pending(_SSL) > 0 || BIO_ctrl_pending(_readBIO) > 0); #endif } - (void)asyncPerformClientHandshakeWithHost: (OFString *)host runLoopMode: (OFRunLoopMode)runLoopMode { static const OFTLSStreamErrorCode initFailedErrorCode = OFTLSStreamErrorCodeInitializationFailed; void *pool = objc_autoreleasePoolPush(); id exception = nil; int status; if (_SSL != NULL) @throw [OFAlreadyOpenException exceptionWithObject: self]; if ((_readBIO = BIO_new(BIO_s_mem())) == NULL) @throw [OFTLSHandshakeFailedException exceptionWithStream: self host: host errorCode: initFailedErrorCode]; |
︙ | ︙ | |||
272 273 274 275 276 277 278 279 280 | else { switch (SSL_get_error(_SSL, status)) { case SSL_ERROR_WANT_READ: [_underlyingStream asyncReadIntoBuffer: _buffer length: bufferSize runLoopMode: runLoopMode]; [_delegate retain]; return; case SSL_ERROR_WANT_WRITE: | > | < | > > > < | 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | else { switch (SSL_get_error(_SSL, status)) { case SSL_ERROR_WANT_READ: [_underlyingStream asyncReadIntoBuffer: _buffer length: bufferSize runLoopMode: runLoopMode]; [_delegate retain]; objc_autoreleasePoolPop(pool); return; case SSL_ERROR_WANT_WRITE: [_underlyingStream asyncWriteData: [OFData data] runLoopMode: runLoopMode]; [_delegate retain]; objc_autoreleasePoolPop(pool); return; default: /* FIXME: Map to better errors */ exception = [OFTLSHandshakeFailedException exceptionWithStream: self host: host errorCode: OFTLSStreamErrorCodeUnknown]; break; } } if ([_delegate respondsToSelector: @selector(stream:didPerformClientHandshakeWithHost:exception:)]) [_delegate stream: self didPerformClientHandshakeWithHost: host exception: exception]; objc_autoreleasePoolPop(pool); } - (bool)stream: (OFStream *)stream didReadIntoBuffer: (void *)buffer length: (size_t)length exception: (nullable id)exception { if (exception == nil) { static const OFTLSStreamErrorCode unknownErrorCode = OFTLSStreamErrorCodeUnknown; int status; OFEnsure(length <= INT_MAX); OFEnsure(BIO_write(_readBIO, buffer, (int)length) == (int)length); status = SSL_do_handshake(_SSL); |
︙ | ︙ | |||
328 329 330 331 332 333 334 | if (status == 1) _handshakeDone = true; else { switch (SSL_get_error(_SSL, status)) { case SSL_ERROR_WANT_READ: return true; | | < | | 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | if (status == 1) _handshakeDone = true; else { switch (SSL_get_error(_SSL, status)) { case SSL_ERROR_WANT_READ: return true; case SSL_ERROR_WANT_WRITE:; OFRunLoopMode runLoopMode = [OFRunLoop currentRunLoop].currentMode; [_underlyingStream asyncWriteData: [OFData data] runLoopMode: runLoopMode]; return false; default: exception = [OFTLSHandshakeFailedException exceptionWithStream: self host: _host errorCode: unknownErrorCode]; |
︙ | ︙ |
Modified src/tls/OFSecureTransportTLSStream.h from [6f1a3f10c3] to [7f7ce4f626].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFTLSStream.h" #include <Security/SecureTransport.h> OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ |
Modified src/tls/OFSecureTransportTLSStream.m from [d93ffbbd51] to [3c26a85d20].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #import "OFSecureTransportTLSStream.h" #import "OFAlreadyOpenException.h" #import "OFNotOpenException.h" #import "OFReadFailedException.h" #import "OFTLSHandshakeFailedException.h" #import "OFWriteFailedException.h" int _ObjFWTLS_reference; |
︙ | ︙ | |||
164 165 166 167 168 169 170 | requestedLength: length bytesWritten: bytesWritten errNo: 0]; return bytesWritten; } | | > | | < < < > | | 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | requestedLength: length bytesWritten: bytesWritten errNo: 0]; return bytesWritten; } - (bool)lowlevelHasDataInReadBuffer { size_t bufferSize; return (_underlyingStream.hasDataInReadBuffer || (SSLGetBufferedReadSize(_context, &bufferSize) == noErr && bufferSize > 0)); } - (void)asyncPerformClientHandshakeWithHost: (OFString *)host runLoopMode: (OFRunLoopMode)runLoopMode { static const OFTLSStreamErrorCode initFailedErrorCode = OFTLSStreamErrorCodeInitializationFailed; void *pool = objc_autoreleasePoolPush(); id exception = nil; OSStatus status; if (_context != NULL) @throw [OFAlreadyOpenException exceptionWithObject: self]; #ifdef HAVE_SSLCREATECONTEXT if ((_context = SSLCreateContext(kCFAllocatorDefault, kSSLClientSide, kSSLStreamType)) == NULL) #else if (SSLNewContext(false, &_context) != noErr) #endif |
︙ | ︙ | |||
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | * readable or writable doesn't work either, as the stream is * almost always at least ready for one of the two. */ [_underlyingStream asyncReadIntoBuffer: (void *)"" length: 0 runLoopMode: runLoopMode]; [_delegate retain]; return; } if (status != noErr) /* FIXME: Map to better errors */ exception = [OFTLSHandshakeFailedException exceptionWithStream: self host: _host errorCode: OFTLSStreamErrorCodeUnknown]; if ([_delegate respondsToSelector: @selector(stream:didPerformClientHandshakeWithHost:exception:)]) [_delegate stream: self didPerformClientHandshakeWithHost: _host exception: exception]; } - (bool)stream: (OFStream *)stream didReadIntoBuffer: (void *)buffer length: (size_t)length exception: (nullable id)exception { | > > > | 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | * readable or writable doesn't work either, as the stream is * almost always at least ready for one of the two. */ [_underlyingStream asyncReadIntoBuffer: (void *)"" length: 0 runLoopMode: runLoopMode]; [_delegate retain]; objc_autoreleasePoolPop(pool); return; } if (status != noErr) /* FIXME: Map to better errors */ exception = [OFTLSHandshakeFailedException exceptionWithStream: self host: _host errorCode: OFTLSStreamErrorCodeUnknown]; if ([_delegate respondsToSelector: @selector(stream:didPerformClientHandshakeWithHost:exception:)]) [_delegate stream: self didPerformClientHandshakeWithHost: _host exception: exception]; objc_autoreleasePoolPop(pool); } - (bool)stream: (OFStream *)stream didReadIntoBuffer: (void *)buffer length: (size_t)length exception: (nullable id)exception { |
︙ | ︙ |
Modified src/tls/ObjFWTLS.h from [498108c5a2] to [ee1b068c51].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "macros.h" #ifdef __cplusplus extern "C" { #endif |
︙ | ︙ |
Added src/tls/ObjFWTLS.oc version [99b1fbc751].
> > > > | 1 2 3 4 | package_format 1 LIBS="-lobjfwtls $LIBS" FRAMEWORK_LIBS="-framework ObjFWTLS $FRAMEWORK_LIBS" STATIC_LIBS="${libdir}/libobjfwtls.a $STATIC_LIBS" |
Modified src/unicode.h from [2eea427f38] to [1b0487bb05].
1 | /* | | | | | | > > > > | < > | < < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFString.h" #define OFUnicodeUppercaseTableSize 0x1EA #define OFUnicodeLowercaseTableSize 0x1EA #define OFUnicodeTitlecaseTableSize 0x1EA #define OFUnicodeCaseFoldingTableSize 0x1EA #ifdef __cplusplus extern "C" { #endif extern const OFUnichar *const _Nonnull OFUnicodeUppercaseTable[OFUnicodeUppercaseTableSize]; extern const OFUnichar *const _Nonnull OFUnicodeLowercaseTable[OFUnicodeLowercaseTableSize]; extern const OFUnichar *const _Nonnull OFUnicodeTitlecaseTable[OFUnicodeTitlecaseTableSize]; extern const OFUnichar *const _Nonnull OFUnicodeCaseFoldingTable[OFUnicodeCaseFoldingTableSize]; #ifdef __cplusplus } #endif |
Modified src/unicode.m from [1934fadafb] to [f5c16fee83].
more than 10,000 changes
Modified src/unistd_wrapper.h from [10576ea4f7] to [aec23c16cd].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdlib.h> /* Make sure we have any libc include */ #ifdef HAVE_UNISTD_H |
︙ | ︙ |
Modified src/versioninfo.rc from [ec5c3868fe] to [b00925a4c5].
︙ | ︙ | |||
10 11 12 13 14 15 16 | BLOCK "StringFileInfo" { BLOCK "040904E4" { VALUE "ProductName", "ObjFW" VALUE "ProductVersion", PACKAGE_VERSION VALUE "FileVersion", OBJFW_LIB_VERSION VALUE "FileDescription", "Objective-C framework" VALUE "LegalCopyright", | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | BLOCK "StringFileInfo" { BLOCK "040904E4" { VALUE "ProductName", "ObjFW" VALUE "ProductVersion", PACKAGE_VERSION VALUE "FileVersion", OBJFW_LIB_VERSION VALUE "FileDescription", "Objective-C framework" VALUE "LegalCopyright", "(c) 2008-2024 Jonathan Schleifer" VALUE "InternalName", "ObjFW" VALUE "OriginalFilename", OBJFW_SHARED_LIB } } BLOCK "VarFileInfo" { |
︙ | ︙ |
Modified tests/ForwardingTests.m from [de62832427] to [35c1560c35].
1 | /* | | | | | | > > > > | < > | | > > > | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "ObjFW.h" #import "ObjFWTest.h" #define FORMAT @"%@ %@ %@ %@ %@ %@ %@ %@ %@ %g %g %g %g %g %g %g %g %g" #define ARGS @"a", @"b", @"c", @"d", @"e", @"f", @"g", @"h", @"i", \ 1.5, 2.25, 3.125, 4.0625, 5.03125, 6.5, 7.25, 8.0, 9.0 #define RESULT @"a b c d e f g h i 1.5 2.25 3.125 4.0625 5.03125 6.5 7.25 8 9" @interface ForwardingTests: OTTestCase @end static size_t forwardingsCount = 0; static bool success = false; static id target = nil; struct StretTest { char buffer[1024]; }; @interface ForwardingTestObject: OFObject @end @interface ForwardingTestObject (NonExistentMethods) + (void)test; - (void)test; - (uint32_t)forwardingTargetTest: (intptr_t)a0 : (intptr_t)a1 : (double)a2 : (double)a3; - (OFString *)forwardingTargetVarArgTest: (OFConstantString *)format, ...; |
︙ | ︙ | |||
57 58 59 60 61 62 63 | static void test(id self, SEL _cmd) { success = true; } | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | static void test(id self, SEL _cmd) { success = true; } @implementation ForwardingTests - (void)setUp { [super setUp]; forwardingsCount = 0; success = false; target = nil; } - (void)testForwardingMessageAndAddingClassMethod { [ForwardingTestObject test]; OTAssertTrue(success); OTAssertEqual(forwardingsCount, 1); [ForwardingTestObject test]; OTAssertEqual(forwardingsCount, 1); } - (void)forwardingMessageAndAddingInstanceMethod { ForwardingTestObject *testObject = [[[ForwardingTestObject alloc] init] autorelease]; [testObject test]; OTAssertTrue(success); OTAssertEqual(forwardingsCount, 1); [testObject test]; OTAssertEqual(forwardingsCount, 1); } #ifdef OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR - (void)testForwardingTargetForSelector { ForwardingTestObject *testObject = [[[ForwardingTestObject alloc] init] autorelease]; target = [[[ForwardingTarget alloc] init] autorelease]; OTAssertEqual( [testObject forwardingTargetTest: 0xDEADBEEF : -1 : 1.25 : 2.75], 0x12345678); } - (void)testForwardingTargetForSelectorWithVariableArguments { ForwardingTestObject *testObject = [[[ForwardingTestObject alloc] init] autorelease]; target = [[[ForwardingTarget alloc] init] autorelease]; OTAssertEqualObjects( ([testObject forwardingTargetVarArgTest: FORMAT, ARGS]), RESULT); } /* * Don't try fpret on Win64 if we don't have stret forwarding, as long double * is handled as a struct there. */ # if !defined(OF_WINDOWS) || !defined(OF_AMD64) || \ defined(OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR_STRET) - (void)testForwardingTargetForSelectorFPRet { ForwardingTestObject *testObject = [[[ForwardingTestObject alloc] init] autorelease]; target = [[[ForwardingTarget alloc] init] autorelease]; OTAssertEqual([testObject forwardingTargetFPRetTest], 12345678.00006103515625); } # endif # ifdef OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR_STRET - (void)testForwardingTargetForSelectorStRet { ForwardingTestObject *testObject = [[[ForwardingTestObject alloc] init] autorelease]; target = [[[ForwardingTarget alloc] init] autorelease]; OTAssertEqual(memcmp([testObject forwardingTargetStRetTest].buffer, "abcdefghijklmnopqrstuvwxyz", 27), 0); } # endif - (void)testForwardingTargetForSelectorReturningNilThrows { ForwardingTestObject *testObject = [[[ForwardingTestObject alloc] init] autorelease]; target = [[[ForwardingTarget alloc] init] autorelease]; OTAssertThrowsSpecific([testObject forwardingTargetNilTest], OFNotImplementedException); } - (void)testForwardingTargetForSelectorReturningSelfThrows { ForwardingTestObject *testObject = [[[ForwardingTestObject alloc] init] autorelease]; target = [[[ForwardingTarget alloc] init] autorelease]; OTAssertThrowsSpecific([testObject forwardingTargetSelfTest], OFNotImplementedException); } # ifdef OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR_STRET - (void)testForwardingTargetForSelectorStRetReturningNilThrows { ForwardingTestObject *testObject = [[[ForwardingTestObject alloc] init] autorelease]; target = [[[ForwardingTarget alloc] init] autorelease]; OTAssertThrowsSpecific([testObject forwardingTargetNilStRetTest], OFNotImplementedException); } - (void)testForwardingTargetForSelectorStRetReturningSelfThrows { ForwardingTestObject *testObject = [[[ForwardingTestObject alloc] init] autorelease]; target = [[[ForwardingTarget alloc] init] autorelease]; OTAssertThrowsSpecific([testObject forwardingTargetSelfStRetTest], OFNotImplementedException); } # endif #endif @end @implementation ForwardingTestObject + (bool)resolveClassMethod: (SEL)selector { forwardingsCount++; if (sel_isEqual(selector, @selector(test))) { class_replaceMethod(object_getClass(self), @selector(test), (IMP)test, "v#:"); |
︙ | ︙ | |||
169 170 171 172 173 174 175 176 | OFEnsure(self == target); memcpy(ret.buffer, "abcdefghijklmnopqrstuvwxyz", 27); return ret; } @end | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 314 315 316 317 318 319 320 321 | OFEnsure(self == target); memcpy(ret.buffer, "abcdefghijklmnopqrstuvwxyz", 27); return ret; } @end |
Modified tests/ImportTest.m from [50763ee365] to [114beb539d].
1 | /* | | | | | | > > > > | < > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ @import ObjFW; |
Modified tests/Makefile from [ede68f8aed] to [551dea54d6].
1 2 3 4 5 6 | include ../extra.mk SUBDIRS = ${TESTPLUGIN} \ ${OBJC_SYNC} \ terminal | > | | | | | | | | | | | | > > > > > > > > | | | | | > | | > | | | | > | < | | < < < | < < < < < < > > > > > > > > > | | | | > | | | | | | > | | | | | > | | | | > | | > < < < < > | | | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | include ../extra.mk SUBDIRS = ${TESTPLUGIN} \ ${SUBPROCESS} \ ${OBJC_SYNC} \ terminal CLEAN = EBOOT.PBP \ boot.dol \ ${PROG_NOINST}.arm9 \ ${PROG_NOINST}.nds \ ${PROG_NOINST}.nro \ ${PROG_NOINST}.rpx \ big_dictionary_msgpack.m \ testfile_bin.m \ testfile_ini.m DISTCLEAN = Info.plist PROG_NOINST = tests${PROG_SUFFIX} STATIC_LIB_NOINST = ${TESTS_STATIC_LIB} SRCS = ForwardingTests.m \ OFArrayTests.m \ ${OF_BLOCK_TESTS_M} \ OFCharacterSetTests.m \ OFColorTests.m \ OFConcreteArrayTests.m \ OFConcreteDictionaryTests.m \ OFConcreteMutableArrayTests.m \ OFConcreteMutableDictionaryTests.m \ OFConcreteMutableSetTests.m \ OFConcreteSetTests.m \ OFCryptographicHashTests.m \ OFDataTests.m \ OFDateTests.m \ OFDictionaryTests.m \ OFHMACTests.m \ OFINIFileTests.m \ OFIRITests.m \ OFInvocationTests.m \ OFJSONTests.m \ OFLHAArchiveTests.m \ OFListTests.m \ OFLocaleTests.m \ OFMatrix4x4Tests.m \ OFMemoryStreamTests.m \ OFMessagePackTests.m \ OFMethodSignatureTests.m \ OFMutableArrayTests.m \ OFMutableDataTests.m \ OFMutableDictionaryTests.m \ OFMutableSetTests.m \ OFMutableStringTests.m \ OFMutableUTF8StringTests.m \ OFNotificationCenterTests.m \ OFNumberTests.m \ OFObjectTests.m \ OFPBKDF2Tests.m \ OFPropertyListTests.m \ OFScryptTests.m \ OFSetTests.m \ OFStreamTests.m \ OFStringTests.m \ OFSystemInfoTests.m \ OFTarArchiveTests.m \ OFUTF8StringTests.m \ OFValueTests.m \ OFXMLElementBuilderTests.m \ OFXMLNodeTests.m \ OFXMLParserTests.m \ OFZIPArchiveTests.m \ OFZooArchiveTests.m \ ${RUNTIME_ARC_TESTS_M} \ RuntimeTests.m \ ${USE_SRCS_FILES} \ ${USE_SRCS_PLUGINS} \ ${USE_SRCS_SOCKETS} \ ${USE_SRCS_SUBPROCESSES} \ ${USE_SRCS_THREADS} \ ${USE_SRCS_WINDOWS} \ big_dictionary_msgpack.m \ testfile_bin.m \ testfile_ini.m SRCS_FILES = OFFileManagerTests.m SRCS_PLUGINS = OFPluginTests.m SRCS_SOCKETS = OFDNSResolverTests.m \ ${OF_HTTP_CLIENT_TESTS_M} \ OFHTTPCookieManagerTests.m \ OFHTTPCookieTests.m \ OFKernelEventObserverTests.m \ OFSocketTests.m \ OFTCPSocketTests.m \ OFUDPSocketTests.m \ ${USE_SRCS_APPLETALK} \ ${USE_SRCS_IPX} \ ${USE_SRCS_SCTP} \ ${USE_SRCS_UNIX_SOCKETS} SRCS_APPLETALK = OFDDPSocketTests.m SRCS_IPX = OFIPXSocketTests.m \ OFSPXSocketTests.m \ OFSPXStreamSocketTests.m SRCS_SCTP = OFSCTPSocketTests.m SRCS_UNIX_SOCKETS = OFUNIXDatagramSocketTests.m \ OFUNIXStreamSocketTests.m SRCS_SUBPROCESSES = OFSubprocessTests.m SRCS_THREADS = OFThreadTests.m SRCS_WINDOWS = OFWindowsRegistryKeyTests.m include ../buildsys.mk big_dictionary_msgpack.m: big_dictionary.msgpack ../utils/objfw-embed $? $? $@ testfile_bin.m: testfile.bin ../utils/objfw-embed $? $? $@ testfile_ini.m: testfile.ini ../utils/objfw-embed $? $? $@ .PHONY: run run-on-ios run-on-android run: rm -f libobjfw.so.${OBJFW_LIB_MAJOR} rm -f libobjfw.so.${OBJFW_LIB_MAJOR_MINOR} rm -f objfw${OBJFW_LIB_MAJOR}.dll libobjfw.${OBJFW_LIB_MAJOR}.dylib rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR} rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR} rm -f objfwrt${OBJFWRT_LIB_MAJOR}.dll rm -f libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib if test -f ../src/libobjfw.so; then \ ${LN_S} ../src/libobjfw.so libobjfw.so.${OBJFW_LIB_MAJOR}; \ ${LN_S} ../src/libobjfw.so \ libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \ elif test -f ../src/libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; then \ ${LN_S} ../src/libobjfw.so.${OBJFW_LIB_MAJOR_MINOR} \ libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \ |
︙ | ︙ | |||
139 140 141 142 143 144 145 | ${LN_S} ../src/runtime/objfwrt${OBJFWRT_LIB_MAJOR}.dll \ objfwrt${OBJFWRT_LIB_MAJOR}.dll; \ fi if test -f ../src/runtime/libobjfwrt.dylib; then \ ${LN_S} ../src/runtime/libobjfwrt.dylib \ libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib; \ fi | < < < < | < < < < < < < < < < < < < < < < < < | 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | ${LN_S} ../src/runtime/objfwrt${OBJFWRT_LIB_MAJOR}.dll \ objfwrt${OBJFWRT_LIB_MAJOR}.dll; \ fi if test -f ../src/runtime/libobjfwrt.dylib; then \ ${LN_S} ../src/runtime/libobjfwrt.dylib \ libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib; \ fi LD_LIBRARY_PATH=.$${LD_LIBRARY_PATH+:}$$LD_LIBRARY_PATH \ DYLD_FRAMEWORK_PATH=../src:../src/runtime$${DYLD_FRAMEWORK_PATH+:}$$DYLD_FRAMEWORK_PATH \ DYLD_LIBRARY_PATH=.$${DYLD_LIBRARY_PATH+:}$$DYLD_LIBRARY_PATH \ LIBRARY_PATH=.$${LIBRARY_PATH+:}$$LIBRARY_PATH \ ASAN_OPTIONS=allocator_may_return_null=1 \ ${WRAPPER} ./${PROG_NOINST} ${TESTCASES}; EXIT=$$?; \ rm -f libobjfw.so.${OBJFW_LIB_MAJOR}; \ rm -f libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \ rm -f objfw${OBJFW_LIB_MAJOR}.dll; \ rm -f libobjfw.${OBJFW_LIB_MAJOR}.dylib; \ rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR}; \ rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}; \ rm -f objfwrt${OBJFWRT_LIB_MAJOR}.dll; \ rm -f libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib; \ exit $$EXIT run-on-android: all echo "Uploading files to Android device..." if test -f ../src/libobjfw.so; then \ adb push ../src/libobjfw.so \ /data/local/tmp/objfw/libobjfw.so.${OBJFW_LIB_MAJOR}; \ fi if test -f ../src/runtime/libobjfwrt.so; then \ |
︙ | ︙ | |||
205 206 207 208 209 210 211 | mksfo "ObjFW Tests" PARAM.SFO psp-strip ${PROG_NOINST} pack-pbp $@ PARAM.SFO NULL NULL NULL NULL NULL ${PROG_NOINST} NULL boot.dol: ${PROG_NOINST} elf2dol ${PROG_NOINST} $@ | | | 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | mksfo "ObjFW Tests" PARAM.SFO psp-strip ${PROG_NOINST} pack-pbp $@ PARAM.SFO NULL NULL NULL NULL NULL ${PROG_NOINST} NULL boot.dol: ${PROG_NOINST} elf2dol ${PROG_NOINST} $@ ${PROG_NOINST}: ${LIBOBJFW_DEP} ${LIBOBJFWRT_DEP} ../src/test/libobjfwtest.a ${PROG_NOINST}.3dsx: ${PROG_NOINST} 3dsxtool $< $@ ${PROG_NOINST}.arm9: ${PROG_NOINST} arm-none-eabi-objcopy -O binary $< $@ |
︙ | ︙ | |||
232 233 234 235 236 237 238 | "${PACKAGE_VERSION}" tests.nacp elf2nro ${PROG_NOINST} $@ --nacp=tests.nacp --romfsdir=romfs rm -fr romfs tests.nacp ${PROG_NOINST}.rpx: ${PROG_NOINST} elf2rpl $< $@ | | > > > > > > > > > > > > > | > > | 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | "${PACKAGE_VERSION}" tests.nacp elf2nro ${PROG_NOINST} $@ --nacp=tests.nacp --romfsdir=romfs rm -fr romfs tests.nacp ${PROG_NOINST}.rpx: ${PROG_NOINST} elf2rpl $< $@ CPPFLAGS += -I../src \ -I../src/exceptions \ -I../src/runtime \ -I../src/test \ -I.. \ -DOBJFWTEST_LOCAL_INCLUDES \ -DPROG_SUFFIX=\"${PROG_SUFFIX}\" OBJCFLAGS_RuntimeARCTests.m = -fobjc-arc -fobjc-arc-exceptions # Repetition of libraries is required for Wii U, as otherwise it cannot find # main. Just moving -lobjfwtest later doesn't work either, as then the linker # cannot find ObjFW symbols. So the only solution is to list everything twice, # but hide it behind a variable because listing it twice causes a warning on # macOS. LIBS := -L../src/test \ -lobjfwtest \ ${TESTS_LIBS} \ ${LIBS} \ ${WII_U_TESTS_LIBS} LDFLAGS += ${MAP_LDFLAGS} LD = ${OBJC} |
Added tests/OFArrayTests.h version [6fd937eb51].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "ObjFW.h" #import "ObjFWTest.h" @interface OFArrayTests: OTTestCase { OFArray *_array; } @property (readonly, nonatomic) Class arrayClass; @end |
Modified tests/OFArrayTests.m from [cc2ce2f7d0] to [13dbe45147].
1 | /* | | | | | | > > > > | < > | | > > > > > | > > > > > | > > | > > > | > | > | > > | > > > | > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | > > > | > > > | > > > > | > | > > | > > > > > > | > > > > > | > > > > > | > > > > > > | > > > > | > > > > > > > > > > > > > > > > | > | > > > > > > > | > > > > > | > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > | > > > > | > > | > > > > | > > > > > | > > > > | > > > > > > > | | > > > > > > > > | > > > > > > > > > > > > > > > > > > > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFArrayTests.h" @interface CustomArray: OFArray { OFArray *_array; } @end static OFString *const cArray[] = { @"Foo", @"Bar", @"Baz" }; @implementation OFArrayTests - (Class)arrayClass { return [CustomArray class]; } - (void)setUp { [super setUp]; _array = [[self.arrayClass alloc] initWithObjects: cArray count: sizeof(cArray) / sizeof(*cArray)]; } - (void)dealloc { [_array release]; [super dealloc]; } - (void)testArray { OFArray *array = [self.arrayClass array]; OTAssertNotNil(array); OTAssertEqual(array.count, 0); } - (void)testArrayWithObjects { OFArray *array = [self.arrayClass arrayWithObjects: @"Foo", @"Bar", @"Baz", nil]; OTAssertNotNil(array); OTAssertEqual(array.count, 3); OTAssertEqualObjects([array objectAtIndex: 0], @"Foo"); OTAssertEqualObjects([array objectAtIndex: 1], @"Bar"); OTAssertEqualObjects([array objectAtIndex: 2], @"Baz"); } - (void)testArrayWithObjectsCount { OFArray *array1 = [self.arrayClass arrayWithObjects: @"Foo", @"Bar", @"Baz", nil]; OFArray *array2 = [self.arrayClass arrayWithObjects: cArray count: 3]; OTAssertEqualObjects(array1, array2); } - (void)testDescription { OTAssertEqualObjects(_array.description, @"(\n\tFoo,\n\tBar,\n\tBaz\n)"); } - (void)testCount { OTAssertEqual(_array.count, 3); } - (void)testIsEqual { OFArray *array = [self.arrayClass arrayWithObjects: cArray count: 3]; OTAssertEqualObjects(array, _array); OTAssertNotEqual(array, _array); } - (void)testHash { OFArray *array = [self.arrayClass arrayWithObjects: cArray count: 3]; OTAssertEqual(array.hash, _array.hash); OTAssertNotEqual(array.hash, [[OFArray array] hash]); } - (void)testCopy { OTAssertEqualObjects([[_array copy] autorelease], _array); } - (void)testMutableCopy { OTAssertEqualObjects([[_array mutableCopy] autorelease], _array); } - (void)testObjectAtIndex { OTAssertEqualObjects([_array objectAtIndex: 0], cArray[0]); OTAssertEqualObjects([_array objectAtIndex: 1], cArray[1]); OTAssertEqualObjects([_array objectAtIndex: 2], cArray[2]); } - (void)testObjectAtIndexFailsWhenOutOfRange { OTAssertThrowsSpecific([_array objectAtIndex: _array.count], OFOutOfRangeException); } - (void)testContainsObject { OTAssertTrue([_array containsObject: cArray[1]]); OTAssertFalse([_array containsObject: @"nonexistent"]); } - (void)testContainsObjectIdenticalTo { OTAssertTrue([_array containsObjectIdenticalTo: cArray[1]]); OTAssertFalse([_array containsObjectIdenticalTo: [OFString stringWithString: cArray[1]]]); } - (void)testIndexOfObject { OTAssertEqual([_array indexOfObject: cArray[1]], 1); OTAssertEqual([_array indexOfObject: @"nonexistent"], OFNotFound); } - (void)testIndexOfObjectIdenticalTo { OTAssertEqual([_array indexOfObjectIdenticalTo: cArray[1]], 1); OTAssertEqual([_array indexOfObjectIdenticalTo: [OFString stringWithString: cArray[1]]], OFNotFound); } - (void)objectsInRange { OTAssertEqualObjects([_array objectsInRange: OFMakeRange(1, 2)], ([self.arrayClass arrayWithObjects: cArray[1], cArray[2], nil])); } - (void)testEnumerator { OFEnumerator *enumerator = [_array objectEnumerator]; OTAssertEqualObjects([enumerator nextObject], cArray[0]); OTAssertEqualObjects([enumerator nextObject], cArray[1]); OTAssertEqualObjects([enumerator nextObject], cArray[2]); OTAssertNil([enumerator nextObject]); } - (void)testFastEnumeration { size_t i = 0; for (OFString *object in _array) { OTAssertLessThan(i, 3); OTAssertEqualObjects(object, cArray[i++]); } } - (void)testComponentsJoinedByString { OFArray *array; array = [self.arrayClass arrayWithObjects: @"", @"a", @"b", @"c", nil]; OTAssertEqualObjects([array componentsJoinedByString: @" "], @" a b c"); array = [self.arrayClass arrayWithObject: @"foo"]; OTAssertEqualObjects([array componentsJoinedByString: @" "], @"foo"); } - (void)testComponentsJoinedByStringOptions { OFArray *array; array = [self.arrayClass arrayWithObjects: @"", @"foo", @"", @"", @"bar", @"", nil]; OTAssertEqualObjects( [array componentsJoinedByString: @" " options: OFArraySkipEmptyComponents], @"foo bar"); } - (void)testSortedArray { OFArray *array = [_array arrayByAddingObjectsFromArray: [OFArray arrayWithObjects: @"0", @"z", nil]]; OTAssertEqualObjects([array sortedArray], ([OFArray arrayWithObjects: @"0", @"Bar", @"Baz", @"Foo", @"z", nil])); OTAssertEqualObjects( [array sortedArrayUsingSelector: @selector(compare:) options: OFArraySortDescending], ([OFArray arrayWithObjects: @"z", @"Foo", @"Baz", @"Bar", @"0", nil])); } - (void)testReversedArray { OTAssertEqualObjects(_array.reversedArray, ([OFArray arrayWithObjects: cArray[2], cArray[1], cArray[0], nil])); } #ifdef OF_HAVE_BLOCKS - (void)testEnumerateObjectsUsingBlock { __block size_t i = 0; [_array enumerateObjectsUsingBlock: ^ (id object, size_t idx, bool *stop) { OTAssertEqualObjects(object, [_array objectAtIndex: i++]); }]; OTAssertEqual(i, _array.count); } - (void)testMappedArrayUsingBlock { OTAssertEqualObjects( [_array mappedArrayUsingBlock: ^ id (id object, size_t idx) { switch (idx) { case 0: return @"foobar"; case 1: return @"qux"; } return @""; }].description, @"(\n\tfoobar,\n\tqux,\n\t\n)"); } - (void)testFilteredArrayUsingBlock { OTAssertEqualObjects( [_array filteredArrayUsingBlock: ^ bool (id object, size_t idx) { return [object isEqual: @"Foo"]; }].description, @"(\n\tFoo\n)"); } - (void)testFoldUsingBlock { OTAssertEqualObjects( [([self.arrayClass arrayWithObjects: [OFMutableString string], @"foo", @"bar", @"baz", nil]) foldUsingBlock: ^ id (id left, id right) { [left appendString: right]; return left; }], @"foobarbaz"); } #endif - (void)testValueForKey { OTAssertEqualObjects( [([self.arrayClass arrayWithObjects: @"foo", @"bar", @"quxqux", nil]) valueForKey: @"length"], ([self.arrayClass arrayWithObjects: [OFNumber numberWithInt: 3], [OFNumber numberWithInt: 3], [OFNumber numberWithInt: 6], nil])); OTAssertEqualObjects( [([self.arrayClass arrayWithObjects: @"1", @"2", nil]) valueForKey: @"@count"], [OFNumber numberWithInt: 2]); } @end @implementation CustomArray - (instancetype)initWithObjects: (id const *)objects count: (size_t)count { self = [super init]; @try { _array = [[OFArray alloc] initWithObjects: objects count: count]; } @catch (id e) { [self release]; @throw e; } return self; } |
︙ | ︙ | |||
93 94 95 96 97 98 99 100 | return [_array objectAtIndex: idx]; } - (size_t)count { return [_array count]; } @end | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 328 329 330 331 332 333 334 335 | return [_array objectAtIndex: idx]; } - (size_t)count { return [_array count]; } @end |
Modified tests/OFBlockTests.m from [d2cc5b8a58] to [aa23dfdff2].
1 | /* | | | | | | > > > > | < > | | > | > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFW.h" #import "ObjFWTest.h" @interface OFBlockTests: OTTestCase @end #if defined(OF_OBJFW_RUNTIME) extern struct objc_class _NSConcreteStackBlock; extern struct objc_class _NSConcreteGlobalBlock; extern struct objc_class _NSConcreteMallocBlock; #elif defined(OF_APPLE_RUNTIME) extern void *_NSConcreteStackBlock; extern void *_NSConcreteGlobalBlock; extern void *_NSConcreteMallocBlock; #endif /* Clang on Win32 generates broken code that crashes for global blocks. */ #if !defined(OF_WINDOWS) || !defined(__clang__) static void (^globalBlock)(void) = ^ {}; #endif static int (^returnStackBlock(void))(void) { __block int i = 42; return [Block_copy(^ int { return ++i; }) autorelease]; |
︙ | ︙ | |||
49 50 51 52 53 54 55 | block(); Block_release(block); return d; } | | > > > > > | > | > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < | < < < < | < | < < < < < < < < < < | 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | block(); Block_release(block); return d; } @implementation OFBlockTests - (void)testClassOfStackBlock { __block int x; void (^stackBlock)(void) = ^ { x = 0; (void)x; }; OTAssertEqual((Class)&_NSConcreteStackBlock, objc_getClass("OFStackBlock")); OTAssertTrue([stackBlock isKindOfClass: [OFBlock class]]); } #if !defined(OF_WINDOWS) || !defined(__clang__) - (void)testClassOfGlobalBlock { OTAssertEqual((Class)&_NSConcreteGlobalBlock, objc_getClass("OFGlobalBlock")); OTAssertTrue([globalBlock isKindOfClass: [OFBlock class]]); } #endif - (void)testClassOfMallocBlock { OTAssertEqual((Class)&_NSConcreteMallocBlock, objc_getClass("OFMallocBlock")); } - (void)testCopyStackBlock { __block int x; void (^stackBlock)(void) = ^ { x = 0; (void)x; }; void (^mallocBlock)(void); mallocBlock = [[stackBlock copy] autorelease]; OTAssertEqual([mallocBlock class], objc_getClass("OFMallocBlock")); OTAssertTrue([mallocBlock isKindOfClass: [OFBlock class]]); } - (void)testCopyStackBlockAndReferenceVariable { OTAssertEqual(forwardTest(), 5); } - (void)testCopyStackBlockAndReferenceCopiedVariable { int (^voidBlock)(void) = returnStackBlock(); OTAssertEqual(voidBlock(), 43); OTAssertEqual(voidBlock(), 44); OTAssertEqual(voidBlock(), 45); } #if !defined(OF_WINDOWS) || !defined(__clang__) - (void)testCopyGlobalBlock { OTAssertEqual([[globalBlock copy] autorelease], (id)globalBlock); } #endif - (void)testCopyMallocBlock { __block int x; void (^stackBlock)(void) = ^ { x = 0; (void)x; }; void (^mallocBlock)(void); mallocBlock = [[stackBlock copy] autorelease]; OTAssertEqual([[mallocBlock copy] autorelease], (id)mallocBlock); OTAssertEqual([mallocBlock retainCount], 2); } @end |
Modified tests/OFCharacterSetTests.m from [9bcb0257c8] to [855b750a34].
1 | /* | | | | | | > > > > | < > | | > | > | | | | < | < < < < | < | | | | | < | < | | | | | > | < | | | < | > > | > > > > | < | < < < < < | < | | | | | < | | > | | > | | | | | | < | | > | < | > < > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFW.h" #import "ObjFWTest.h" #import "OFCharacterSet.h" #import "OFBitSetCharacterSet.h" #import "OFRangeCharacterSet.h" @interface OFCharacterSetTests: OTTestCase @end @interface CustomCharacterSet: OFCharacterSet @end @implementation CustomCharacterSet - (bool)characterIsMember: (OFUnichar)character { return (character % 2 == 0); } @end @implementation OFCharacterSetTests - (void)testCustomCharacterSet { OFCharacterSet *characterSet = [[[CustomCharacterSet alloc] init] autorelease]; for (OFUnichar c = 0; c < 65536; c++) if (c % 2 == 0) OTAssertTrue([characterSet characterIsMember: c]); else OTAssertFalse([characterSet characterIsMember: c]); } - (void)testBitSetCharacterSet { OFCharacterSet *characterSet = [OFCharacterSet characterSetWithCharactersInString: @"0123456789"]; OTAssertTrue( [characterSet isKindOfClass: [OFBitSetCharacterSet class]]); for (OFUnichar c = 0; c < 65536; c++) if (c >= '0' && c <= '9') OTAssertTrue([characterSet characterIsMember: c]); else if ([characterSet characterIsMember: c]) OTAssertFalse([characterSet characterIsMember: c]); } - (void)testRangeCharacterSet { OFCharacterSet *characterSet = [OFCharacterSet characterSetWithRange: OFMakeRange('0', 10)]; OTAssertTrue( [characterSet isKindOfClass: [OFRangeCharacterSet class]]); for (OFUnichar c = 0; c < 65536; c++) if (c >= '0' && c <= '9') OTAssertTrue([characterSet characterIsMember: c]); else OTAssertFalse([characterSet characterIsMember: c]); } - (void)testInvertedCharacterSet { OFCharacterSet *characterSet = [[OFCharacterSet characterSetWithRange: OFMakeRange('0', 10)] invertedSet]; for (OFUnichar c = 0; c < 65536; c++) if (c >= '0' && c <= '9') OTAssertFalse([characterSet characterIsMember: c]); else OTAssertTrue([characterSet characterIsMember: c]); } - (void)testInvertingInvertedSetReturnsOriginal { OFCharacterSet *characterSet = [OFCharacterSet characterSetWithRange: OFMakeRange('0', 10)]; OTAssertEqual(characterSet, characterSet.invertedSet.invertedSet); } @end |
Added tests/OFColorTests.m version [aba50c70b8].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFW.h" #import "ObjFWTest.h" @interface OFColorTests: OTTestCase { OFColor *_color; } @end @implementation OFColorTests - (void)setUp { [super setUp]; _color = [[OFColor alloc] initWithRed: 63.f / 255 green: 127.f / 255 blue: 1 alpha: 1]; } - (void)dealloc { [_color release]; [super dealloc]; } #ifdef OF_OBJFW_RUNTIME - (void)testReturnsTaggedPointer { OTAssertTrue(object_isTaggedPointer(_color)); } #endif - (void)testGetRedGreenBlueAlpha { float red, green, blue, alpha; [_color getRed: &red green: &green blue: &blue alpha: &alpha]; OTAssertEqual(red, 63.f / 255); OTAssertEqual(green, 127.f / 255); OTAssertEqual(blue, 1); OTAssertEqual(alpha, 1); } @end |
Added tests/OFConcreteArrayTests.m version [e575422c8d].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFArrayTests.h" #import "OFConcreteArray.h" @interface OFConcreteArrayTests: OFArrayTests @end @implementation OFConcreteArrayTests - (Class)arrayClass { return [OFConcreteArray class]; } @end |
Added tests/OFConcreteDictionaryTests.m version [6b28e3186e].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFDictionaryTests.h" #import "OFConcreteDictionary.h" @interface OFConcreteDictionaryTests: OFDictionaryTests @end @implementation OFConcreteDictionaryTests - (Class)dictionaryClass { return [OFConcreteDictionary class]; } @end |
Added tests/OFConcreteMutableArrayTests.m version [6d754c1f11].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFMutableArrayTests.h" #import "OFConcreteMutableArray.h" @interface OFConcreteMutableArrayTests: OFMutableArrayTests @end static OFString *const cArray[] = { @"Foo", @"Bar", @"Baz" }; @implementation OFConcreteMutableArrayTests - (Class)arrayClass { return [OFConcreteMutableArray class]; } - (void)testDetectMutationDuringEnumeration { OFEnumerator *enumerator = [_mutableArray objectEnumerator]; OFString *object; size_t i; i = 0; while ((object = [enumerator nextObject]) != nil) { OTAssertEqualObjects(object, cArray[i]); [_mutableArray replaceObjectAtIndex: i withObject: @""]; i++; } OTAssertEqual(i, _mutableArray.count); [_mutableArray removeObjectAtIndex: 0]; OTAssertThrowsSpecific([enumerator nextObject], OFEnumerationMutationException); } - (void)testDetectMutationDuringFastEnumeration { bool detected = false; size_t i; i = 0; for (OFString *object in _mutableArray) { OTAssertEqualObjects(object, cArray[i]); [_mutableArray replaceObjectAtIndex: i withObject: @""]; i++; } OTAssertEqual(i, _mutableArray.count); @try { for (OFString *object in _mutableArray) { (void)object; [_mutableArray removeObjectAtIndex: 0]; } } @catch (OFEnumerationMutationException *e) { detected = true; } OTAssertTrue(detected); } #ifdef OF_HAVE_BLOCKS - (void)testDetectMutationDuringEnumerateObjectsUsingBlock { __block size_t i; i = 0; [_mutableArray enumerateObjectsUsingBlock: ^ (id object, size_t idx, bool *stop) { OTAssertEqualObjects(object, cArray[idx]); [_mutableArray replaceObjectAtIndex: idx withObject: @""]; i++; }]; OTAssertEqual(i, _mutableArray.count); OTAssertThrowsSpecific( [_mutableArray enumerateObjectsUsingBlock: ^ (id object, size_t idx, bool *stop) { [_mutableArray removeObjectAtIndex: 0]; }], OFEnumerationMutationException); } #endif @end |
Added tests/OFConcreteMutableDictionaryTests.m version [39dbe3b7b2].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFMutableDictionaryTests.h" #import "OFConcreteMutableDictionary.h" @interface OFConcreteMutableDictionaryTests: OFMutableDictionaryTests @end @implementation OFConcreteMutableDictionaryTests - (Class)dictionaryClass { return [OFConcreteMutableDictionary class]; } - (void)testDetectMutationDuringEnumeration { OFMutableDictionary *mutableDictionary = [[_dictionary mutableCopy] autorelease]; OFEnumerator *keyEnumerator = [mutableDictionary keyEnumerator]; OFEnumerator *objectEnumerator = [mutableDictionary objectEnumerator]; OFString *key; size_t i; i = 0; while ((key = [keyEnumerator nextObject]) != nil) { [mutableDictionary setObject: @"test" forKey: key]; i++; } OTAssertEqual(i, mutableDictionary.count); [mutableDictionary removeObjectForKey: @"key2"]; OTAssertThrowsSpecific([keyEnumerator nextObject], OFEnumerationMutationException); OTAssertThrowsSpecific([objectEnumerator nextObject], OFEnumerationMutationException); } - (void)testDetectMutationDuringFastEnumeration { OFMutableDictionary *mutableDictionary = [[_dictionary mutableCopy] autorelease]; bool detected = false; size_t i; i = 0; for (OFString *key in mutableDictionary) { [mutableDictionary setObject: @"test" forKey: key]; i++; } OTAssertEqual(i, mutableDictionary.count); @try { for (OFString *key in mutableDictionary) [mutableDictionary removeObjectForKey: key]; } @catch (OFEnumerationMutationException *e) { detected = true; } OTAssertTrue(detected); } #ifdef OF_HAVE_BLOCKS - (void)testDetectMutationDuringEnumerateObjectsUsingBlock { OFMutableDictionary *mutableDictionary = [[_dictionary mutableCopy] autorelease]; __block size_t i; i = 0; [mutableDictionary enumerateKeysAndObjectsUsingBlock: ^ (id key, id object, bool *stop) { [mutableDictionary setObject: @"test" forKey: key]; i++; }]; OTAssertEqual(i, mutableDictionary.count); OTAssertThrowsSpecific( [mutableDictionary enumerateKeysAndObjectsUsingBlock: ^ (id key, id object, bool *stop) { [mutableDictionary removeObjectForKey: key]; }], OFEnumerationMutationException); } #endif @end |
Added tests/OFConcreteMutableSetTests.m version [1381cb61cf].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFMutableSetTests.h" #import "OFConcreteMutableSet.h" @interface OFConcreteMutableSetTests: OFMutableSetTests @end @implementation OFConcreteMutableSetTests - (Class)setClass { return [OFConcreteMutableSet class]; } - (void)testDetectMutationDuringEnumeration { OFEnumerator *enumerator = [_mutableSet objectEnumerator]; [_mutableSet removeObject: @"foo"]; OTAssertThrowsSpecific([enumerator nextObject], OFEnumerationMutationException); } - (void)testDetectMutationDuringFastEnumeration { bool detected = false; @try { for (OFString *object in _mutableSet) [_mutableSet removeObject: object]; } @catch (OFEnumerationMutationException *e) { detected = true; } OTAssertTrue(detected); } #ifdef OF_HAVE_BLOCKS - (void)testDetectMutationDuringEnumerateObjectsUsingBlock { OTAssertThrowsSpecific( [_mutableSet enumerateObjectsUsingBlock: ^ (id object, bool *stop) { [_mutableSet removeObject: object]; }], OFEnumerationMutationException); } #endif @end |
Added tests/OFConcreteSetTests.m version [9eaadac18c].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFSetTests.h" #import "OFConcreteSet.h" @interface OFConcreteSetTests: OFSetTests @end @implementation OFConcreteSetTests - (Class)setClass { return [OFConcreteSet class]; } @end |
Added tests/OFCryptographicHashTests.m version [cdb3a06be9].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "ObjFW.h" #import "ObjFWTest.h" @interface OFCryptographicHashTests: OTTestCase { OFStream *_stream; } @end const unsigned char testFileMD5[16] = "\x00\x8B\x9D\x1B\x58\xDF\xF8\xFE\xEE\xF3\xAE\x8D\xBB\x68\x2D\x38"; const unsigned char testFileRIPEMD160[20] = "\x46\x02\x97\xF5\x85\xDF\xB9\x21\x00\xC8\xF9\x87\xC6\xEC\x84\x0D" "\xCE\xE6\x08\x8B"; const unsigned char testFileSHA1[20] = "\xC9\x9A\xB8\x7E\x1E\xC8\xEC\x65\xD5\xEB\xE4\x2E\x0D\xA6\x80\x96" "\xF5\x94\xE7\x17"; const unsigned char testFileSHA224[28] = "\x27\x69\xD8\x04\x2D\x0F\xCA\x84\x6C\xF1\x62\x44\xBA\x0C\xBD\x46" "\x64\x5F\x4F\x20\x02\x4D\x15\xED\x1C\x61\x1F\xF7"; const unsigned char testFileSHA256[32] = "\x1A\x02\xD6\x46\xF5\xA6\xBA\xAA\xFF\x7F\xD5\x87\xBA\xC3\xF6\xC6" "\xB5\x67\x93\x8F\x0F\x44\x90\xB8\xF5\x35\x89\xF0\x5A\x23\x7F\x69"; const unsigned char testFileSHA384[48] = "\x7E\xDE\x62\xE2\x10\xA5\x1E\x18\x8A\x11\x7F\x78\xD7\xC7\x55\xB6" "\x43\x94\x1B\xD2\x78\x5C\xCF\xF3\x8A\xB8\x98\x22\xC7\x0E\xFE\xF1" "\xEC\x53\xE9\x1A\xB3\x51\x70\x8C\x1F\x3F\x56\x12\x44\x01\x91\x54"; const unsigned char testFileSHA512[64] = "\x8F\x36\x6E\x3C\x19\x4B\xBB\xC7\x82\xAA\xCD\x7D\x55\xA2\xD3\x29" "\x29\x97\x6A\x3F\xEB\x9B\xB2\xCB\x75\xC9\xEC\xC8\x10\x07\xD6\x07" "\x31\x4A\xB1\x30\x97\x82\x58\xA5\x1F\x71\x42\xE6\x56\x07\x99\x57" "\xB2\xB8\x3B\xA1\x8A\x41\x64\x33\x69\x21\x8C\x2A\x44\x6D\xF2\xA0"; @implementation OFCryptographicHashTests - (void)setUp { OFIRI *IRI; [super setUp]; IRI = [OFIRI IRIWithString: @"embedded:testfile.bin"]; _stream = [[OFIRIHandler openItemAtIRI: IRI mode: @"r"] retain]; } - (void)tearDown { [_stream close]; [super tearDown]; } - (void)dealloc { [_stream release]; [super dealloc]; } - (void)testHash: (Class)hashClass expectedDigest: (const unsigned char *)expectedDigest { id <OFCryptographicHash> hash = [hashClass hashWithAllowsSwappableMemory: true]; id <OFCryptographicHash> copy; OTAssertNotNil(hash); while (!_stream.atEndOfStream) { char buffer[64]; size_t length = [_stream readIntoBuffer: buffer length: 64]; [hash updateWithBuffer: buffer length: length]; } copy = [[hash copy] autorelease]; [hash calculate]; [copy calculate]; OTAssertEqual(memcmp(hash.digest, expectedDigest, hash.digestSize), 0); OTAssertEqual(memcmp(hash.digest, expectedDigest, hash.digestSize), 0); OTAssertThrowsSpecific([hash updateWithBuffer: "" length: 1], OFHashAlreadyCalculatedException); } - (void)testMD5 { [self testHash: [OFMD5Hash class] expectedDigest: testFileMD5]; } - (void)testRIPEMD160 { [self testHash: [OFRIPEMD160Hash class] expectedDigest: testFileRIPEMD160]; } - (void)testSHA1 { [self testHash: [OFSHA1Hash class] expectedDigest: testFileSHA1]; } - (void)testSHA224 { [self testHash: [OFSHA224Hash class] expectedDigest: testFileSHA224]; } - (void)testSHA256 { [self testHash: [OFSHA256Hash class] expectedDigest: testFileSHA256]; } - (void)testSHA384 { [self testHash: [OFSHA384Hash class] expectedDigest: testFileSHA384]; } - (void)testSHA512 { [self testHash: [OFSHA512Hash class] expectedDigest: testFileSHA512]; } @end |
Modified tests/OFDDPSocketTests.m from [7798ad31e7] to [925c37b669].
1 | /* | | | | | | > > > > | < > | > | > | > | | < | < | | | | | < < | < < < < < | < < | < < | < < | | > | | | > | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #include <string.h> #import "ObjFW.h" #import "ObjFWTest.h" @interface OFDDPSocketTests: OTTestCase @end @implementation OFDDPSocketTests - (void)testDDPSocket { OFDDPSocket *sock; OFSocketAddress address1, address2; char buffer[5]; sock = [OFDDPSocket socket]; @try { address1 = [sock bindToNetwork: 0 node: 0 port: 0 protocolType: 11]; } @catch (OFBindSocketFailedException *e) { switch (e.errNo) { case EAFNOSUPPORT: case EPROTONOSUPPORT: OTSkip(@"AppleTalk unsupported"); case EADDRNOTAVAIL: OTSkip(@"AppleTalk not configured"); default: @throw e; } } [sock sendBuffer: "Hello" length: 5 receiver: &address1]; OTAssertEqual([sock receiveIntoBuffer: buffer length: 5 sender: &address2], 5); OTAssertEqual(memcmp(buffer, "Hello", 5), 0); OTAssertTrue(OFSocketAddressEqual(&address1, &address2)); OTAssertEqual(OFSocketAddressHash(&address1), OFSocketAddressHash(&address2)); } @end |
Modified tests/OFDNSResolverTests.m from [b7997ffc05] to [6fe16b4fbd].
1 | /* | | | | | | > > > > | < > | | > | > > | > < > > | > > > > > > > | < | | < < | | < | < | < < | < < | | | < | < < < > > > > < > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFW.h" #import "ObjFWTest.h" @interface OFDNSResolverTests: OTTestCase @end @implementation OFDNSResolverTests + (OFArray OF_GENERIC(OFPair OF_GENERIC(OFString *, id) *) *)summary { OFMutableArray *summary = [OFMutableArray array]; OFDNSResolver *resolver = [OFDNSResolver resolver]; OFMutableString *staticHosts = [OFMutableString string]; #define ADD(name, value) \ [summary addObject: [OFPair pairWithFirstObject: name \ secondObject: value]]; #define ADD_DOUBLE(name, value) \ ADD(name, [OFNumber numberWithDouble: value]) #define ADD_UINT(name, value) \ ADD(name, [OFNumber numberWithUnsignedInt: value]); #define ADD_BOOL(name, value) \ ADD(name, [OFNumber numberWithBool: value]); for (OFString *host in resolver.staticHosts) { OFString *IPs; if (staticHosts.length > 0) [staticHosts appendString: @"; "]; IPs = [[resolver.staticHosts objectForKey: host] componentsJoinedByString: @", "]; [staticHosts appendFormat: @"%@=(%@)", host, IPs]; } ADD(@"Static hosts", staticHosts) ADD(@"Name servers", [resolver.nameServers componentsJoinedByString: @", "]); ADD(@"Local domain", resolver.localDomain); ADD(@"Search domains", [resolver.searchDomains componentsJoinedByString: @", "]); ADD_DOUBLE(@"Timeout", resolver.timeout); ADD_UINT(@"Max attempts", resolver.maxAttempts); ADD_UINT(@"Min number of dots in absolute name", resolver.minNumberOfDotsInAbsoluteName); ADD_BOOL(@"Forces TCP", resolver.forcesTCP); ADD_DOUBLE(@"Config reload interval", resolver.configReloadInterval); #undef ADD #undef ADD_DOUBLE #undef ADD_UINT #undef ADD_BOOL return summary; } @end |
Added tests/OFDataTests.h version [b8a645ee68].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "ObjFW.h" #import "ObjFWTest.h" @interface OFDataTests: OTTestCase { OFData *_data; unsigned char _items[2][4096]; } @property (readonly, nonatomic) Class dataClass; @end |
Modified tests/OFDataTests.m from [ffac8c7aa2] to [858a29b47f].
1 | /* | | | | | | > > > > | < > | | > > > | | | | < < < | | > > | > | | | | > > | > > | > | > > | | | < | > | > | | | | > | | < < | > | | | > > > | < > > | | | | > > > | < > > > | > | | | > | > | > > | | < < > | | > > | < > > > > > | | < < < > | > > | > | | > > > > > | | | | | | | | | | | | | | | | | < | > < | | | | | | > | | | | | | | > > > > | > | > > > > > | < < | | > < | < | | | > | > | > > > > > > > | | > > | | | | | > | > > > | | > > > > | > | > | > | < > | > | > | < > | > | > | < > | | | < < | < | < < > | | | < < | | | | < < | | | | > > | | < | | < < < > | > > > | | | | | < | > | < < | | < > | > > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "OFDataTests.h" @implementation OFDataTests - (Class)dataClass { return [OFData class]; } - (void)setUp { [super setUp]; memset(&_items[0], 0xFF, 4096); memset(&_items[1], 0x42, 4096); _data = [[self.dataClass alloc] initWithItems: _items count: 2 itemSize: 4096]; } - (void)dealloc { [_data release]; [super dealloc]; } - (void)testCount { OTAssertEqual(_data.count, 2); } - (void)testItemSize { OTAssertEqual(_data.itemSize, 4096); } - (void)testItems { OTAssertEqual(memcmp(_data.items, _items, 2 * _data.itemSize), 0); } - (void)testItemAtIndex { OTAssertEqual( memcmp([_data itemAtIndex: 1], &_items[1], _data.itemSize), 0); } - (void)testItemAtIndexThrowsOnOutOfRangeIndex { OTAssertThrowsSpecific([_data itemAtIndex: _data.count], OFOutOfRangeException); } - (void)testFirstItem { OTAssertEqual(memcmp(_data.firstItem, &_items[0], _data.itemSize), 0); } - (void)testLastItem { OTAssertEqual(memcmp(_data.lastItem, &_items[1], _data.itemSize), 0); } - (void)testIsEqual { OTAssertEqualObjects( _data, [OFData dataWithItems: _items count: 2 itemSize: 4096]); OTAssertNotEqualObjects( _data, [OFData dataWithItems: _items count: 1 itemSize: 4096]); } - (void)testHash { OTAssertEqual(_data.hash, [[OFData dataWithItems: _items count: 2 itemSize: 4096] hash]); OTAssertNotEqual(_data.hash, [[OFData dataWithItems: _items count: 1 itemSize: 4096] hash]); } - (void)testCompare { OFData *data1 = [self.dataClass dataWithItems: "aa" count: 2]; OFData *data2 = [self.dataClass dataWithItems: "ab" count: 2]; OFData *data3 = [self.dataClass dataWithItems: "aaa" count: 3]; OTAssertEqual([data1 compare: data2], OFOrderedAscending); OTAssertEqual([data2 compare: data1], OFOrderedDescending); OTAssertEqual([data1 compare: data1], OFOrderedSame); OTAssertEqual([data1 compare: data3], OFOrderedAscending); OTAssertEqual([data2 compare: data3], OFOrderedDescending); } - (void)testCopy { OTAssertEqualObjects([[_data copy] autorelease], _data); } - (void)testRangeOfDataOptionsRange { OFData *data = [self.dataClass dataWithItems: "aaabaccdacaabb" count: 7 itemSize: 2]; OFRange range; range = [data rangeOfData: [self.dataClass dataWithItems: "aa" count: 1 itemSize: 2] options: 0 range: OFMakeRange(0, 7)]; OTAssertEqual(range.location, 0); OTAssertEqual(range.length, 1); range = [data rangeOfData: [self.dataClass dataWithItems: "aa" count: 1 itemSize: 2] options: OFDataSearchBackwards range: OFMakeRange(0, 7)]; OTAssertEqual(range.location, 5); OTAssertEqual(range.length, 1); range = [data rangeOfData: [self.dataClass dataWithItems: "ac" count: 1 itemSize: 2] options: 0 range: OFMakeRange(0, 7)]; OTAssertEqual(range.location, 2); OTAssertEqual(range.length, 1); range = [data rangeOfData: [self.dataClass dataWithItems: "aabb" count: 2 itemSize: 2] options: 0 range: OFMakeRange(0, 7)]; OTAssertEqual(range.location, 5); OTAssertEqual(range.length, 2); range = [data rangeOfData: [self.dataClass dataWithItems: "aa" count: 1 itemSize: 2] options: 0 range: OFMakeRange(1, 6)]; OTAssertEqual(range.location, 5); OTAssertEqual(range.length, 1); range = [data rangeOfData: [self.dataClass dataWithItems: "aa" count: 1 itemSize: 2] options: OFDataSearchBackwards range: OFMakeRange(0, 5)]; OTAssertEqual(range.location, 0); OTAssertEqual(range.length, 1); } - (void)testRangeOfDataOptionsRangeThrowsOnDifferentItemSize { OTAssertThrowsSpecific( [_data rangeOfData: [OFData dataWithItems: "a" count: 1] options: 0 range: OFMakeRange(0, 1)], OFInvalidArgumentException); } - (void)testRangeOfDataOptionsRangeThrowsOnOutOfRangeRange { OTAssertThrowsSpecific( [_data rangeOfData: [OFData dataWithItemSize: 4096] options: 0 range: OFMakeRange(1, 2)], OFOutOfRangeException); OTAssertThrowsSpecific( [_data rangeOfData: [OFData dataWithItemSize: 4096] options: 0 range: OFMakeRange(2, 1)], OFOutOfRangeException); } - (void)testSubdataWithRange { OFData *data1 = [self.dataClass dataWithItems: "aaabaccdacaabb" count: 7 itemSize: 2]; OFData *data2 = [self.dataClass dataWithItems: "abcde" count: 5]; OTAssertEqualObjects( [data1 subdataWithRange: OFMakeRange(2, 4)], [OFData dataWithItems: "accdacaa" count: 4 itemSize: 2]); OTAssertEqualObjects( [data2 subdataWithRange: OFMakeRange(2, 3)], [OFData dataWithItems: "cde" count: 3]); } - (void)testSubdataWithRangeThrowsOnOutOfRangeRange { OFData *data1 = [self.dataClass dataWithItems: "aaabaccdacaabb" count: 7 itemSize: 2]; OFData *data2 = [self.dataClass dataWithItems: "abcde" count: 5]; OTAssertThrowsSpecific([data1 subdataWithRange: OFMakeRange(7, 1)], OFOutOfRangeException); OTAssertThrowsSpecific([data1 subdataWithRange: OFMakeRange(8, 0)], OFOutOfRangeException); OTAssertThrowsSpecific([data2 subdataWithRange: OFMakeRange(6, 1)], OFOutOfRangeException); } - (void)testStringByMD5Hashing { OTAssertEqualObjects(_data.stringByMD5Hashing, @"37d65c8816008d58175b1d71ee892de3"); } - (void)testStringByRIPEMD160Hashing { OTAssertEqualObjects(_data.stringByRIPEMD160Hashing, @"ab33a6a725f9fcec6299054dc604c0eb650cd889"); } - (void)testStringBySHA1Hashing { OTAssertEqualObjects(_data.stringBySHA1Hashing, @"eb50cfcc29d0bed96b3bafe03e99110bcf6663b3"); } - (void)testStringBySHA224Hashing { OTAssertEqualObjects(_data.stringBySHA224Hashing, @"204f8418a914a6828f8eb27871e01f74366f6d8fac8936029ebf0041"); } - (void)testStringBySHA256Hashing { OTAssertEqualObjects(_data.stringBySHA256Hashing, @"27c521859f6f5b10aeac4e210a6d005c" @"85e382c594e2622af9c46c6da8906821"); } - (void)testStringBySHA384Hashing { OTAssertEqualObjects(_data.stringBySHA384Hashing, @"af99a52c26c00f01fe649dcc53d7c7a0" @"a9ee0150b971955be2af395708966120" @"5f2634f70df083ef63b232d5b8549db4"); } - (void)testStringBySHA512Hashing { OTAssertEqualObjects(_data.stringBySHA512Hashing, @"1cbd53bf8bed9b45a63edda645ee1217" @"24d2f0323c865e1039ba13320bc6c66e" @"c79b6cdf6d08395c612b7decb1e59ad1" @"e72bfa007c2f76a823d10204d47d2e2d"); } - (void)testStringByBase64Encoding { OTAssertEqualObjects([[self.dataClass dataWithItems: "abcde" count: 5] stringByBase64Encoding], @"YWJjZGU="); } - (void)testDataWithBase64EncodedString { OTAssertEqualObjects( [self.dataClass dataWithBase64EncodedString: @"YWJjZGU="], [OFData dataWithItems: "abcde" count: 5]); } @end |
Modified tests/OFDateTests.m from [f110295df2] to [1b655b92f3].
1 | /* | | | | | | > > > > | < > | | > > > > | | > > | > > > > > > > > > | > > | > > | > | | | | | > | > > | > | < < | > > | > | > | > | | | > | > > | | | | | | > > | > | > | > > | | | | < > | | > | | | | > > | > < < > | > | | > > > | > > | | | > | > > | > | > > > > | > | > | | > | > > > | > > > > | | > | > > > > | > | > | | > | > > > | > | | > | | > | > > > | > | > > | > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <time.h> #import "ObjFW.h" #import "ObjFWTest.h" #import "OFStrPTime.h" @interface OFDateTests: OTTestCase { OFDate *_date[2]; } @end @implementation OFDateTests - (void)setUp { [super setUp]; _date[0] = [[OFDate alloc] initWithTimeIntervalSince1970: 0]; _date[1] = [[OFDate alloc] initWithTimeIntervalSince1970: 3600 * 25 + 5.000002]; } - (void)dealloc { [_date[0] release]; [_date[1] release]; [super dealloc]; } - (void)testStrPTime { struct tm tm; int16_t timeZone; const char *dateString = "Wed, 09 Jun 2021 +0200x"; OTAssertEqual(OFStrPTime(dateString, "%a, %d %b %Y %z", &tm, &timeZone), dateString + 22); OTAssertEqual(tm.tm_wday, 3); OTAssertEqual(tm.tm_mday, 9); OTAssertEqual(tm.tm_mon, 5); OTAssertEqual(tm.tm_year, 2021 - 1900); OTAssertEqual(timeZone, 2 * 60); } - (void)testDateByAddingTimeInterval { OTAssertEqualObjects( [_date[0] dateByAddingTimeInterval: 3600 * 25 + 5.000002], _date[1]); } - (void)testDescription { OTAssertEqualObjects(_date[0].description, @"1970-01-01T00:00:00Z"); OTAssertEqualObjects(_date[1].description, @"1970-01-02T01:00:05Z"); } - (void)testDateWithDateStringFormat { OTAssertEqualObjects( [[OFDate dateWithDateString: @"2000-06-20T12:34:56+0200" format: @"%Y-%m-%dT%H:%M:%S%z"] description], @"2000-06-20T10:34:56Z"); } - (void)testDateWithDateStringFormatFailsWithTrailingCharacters { OTAssertThrowsSpecific( [OFDate dateWithDateString: @"2000-06-20T12:34:56+0200x" format: @"%Y-%m-%dT%H:%M:%S%z"], OFInvalidFormatException); } - (void)testDateWithLocalDateStringFormatFormat { OTAssertEqualObjects( [[OFDate dateWithLocalDateString: @"2000-06-20T12:34:56" format: @"%Y-%m-%dT%H:%M:%S"] localDateStringWithFormat: @"%Y-%m-%dT%H:%M:%S"], @"2000-06-20T12:34:56"); OTAssertEqualObjects( [[OFDate dateWithLocalDateString: @"2000-06-20T12:34:56-0200" format: @"%Y-%m-%dT%H:%M:%S%z"] description], @"2000-06-20T14:34:56Z"); } - (void)testDateWithLocalDateStringFormatFailsWithTrailingCharacters { OTAssertThrowsSpecific( [OFDate dateWithLocalDateString: @"2000-06-20T12:34:56x" format: @"%Y-%m-%dT%H:%M:%S"], OFInvalidFormatException); OTAssertThrowsSpecific( [OFDate dateWithLocalDateString: @"2000-06-20T12:34:56+0200x" format: @"%Y-%m-%dT%H:%M:%S%z"], OFInvalidFormatException); } - (void)testIsEqual { OTAssertEqualObjects(_date[0], [OFDate dateWithTimeIntervalSince1970: 0]); OTAssertNotEqualObjects(_date[0], [OFDate dateWithTimeIntervalSince1970: 0.0000001]); } - (void)testCompare { OTAssertEqual([_date[0] compare: _date[1]], OFOrderedAscending); } - (void)testSecond { OTAssertEqual(_date[0].second, 0); OTAssertEqual(_date[1].second, 5); } - (void)testMicrosecond { OTAssertEqual(_date[0].microsecond, 0); OTAssertEqual(_date[1].microsecond, 2); } - (void)testMinute { OTAssertEqual(_date[0].minute, 0); OTAssertEqual(_date[1].minute, 0); } - (void)testHour { OTAssertEqual(_date[0].hour, 0); OTAssertEqual(_date[1].hour, 1); } - (void)testDayOfMonth { OTAssertEqual(_date[0].dayOfMonth, 1); OTAssertEqual(_date[1].dayOfMonth, 2); } - (void)testMonthOfYear { OTAssertEqual(_date[0].monthOfYear, 1); OTAssertEqual(_date[1].monthOfYear, 1); } - (void)testYear { OTAssertEqual(_date[0].year, 1970); OTAssertEqual(_date[1].year, 1970); } - (void)testDayOfWeek { OTAssertEqual(_date[0].dayOfWeek, 4); OTAssertEqual(_date[1].dayOfWeek, 5); } - (void)testDayOfYear { OTAssertEqual(_date[0].dayOfYear, 1); OTAssertEqual(_date[1].dayOfYear, 2); } - (void)testEarlierDate { OTAssertEqualObjects([_date[0] earlierDate: _date[1]], _date[0]); } - (void)testLaterDate { OTAssertEqualObjects([_date[0] laterDate: _date[1]], _date[1]); } @end |
Added tests/OFDictionaryTests.h version [60fe2b2f20].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "ObjFW.h" #import "ObjFWTest.h" @interface OFDictionaryTests: OTTestCase { OFDictionary *_dictionary; } @property (readonly, nonatomic) Class dictionaryClass; @end |
Modified tests/OFDictionaryTests.m from [856ca278b2] to [372c2ea411].
1 | /* | | | | | | > > > > | < > | | < | | | > > > > > | > > > > > > > > > > | | > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | > > > > | > > > > | > | > > > > > | > > > > > | > > > > > | > > > > > > | > > > > > > > > | > > > > > > > > | > | > > > > > > | > > > > | > > > > > > > | > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | > > > > > | > | > | | | > > > > > > > | > > > > | > > > > > > > > > | > > > > > > > > > > > > > > > > | < | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFDictionaryTests.h" static OFString *keys[] = { @"key1", @"key2" }; static OFString *objects[] = { @"value1", @"value2" }; @interface CustomDictionary: OFDictionary { OFDictionary *_dictionary; } @end @implementation OFDictionaryTests - (Class)dictionaryClass { return [CustomDictionary class]; } - (void)setUp { [super setUp]; _dictionary = [[self.dictionaryClass alloc] initWithObjects: objects forKeys: keys count: 2]; } - (void)dealloc { [_dictionary release]; [super dealloc]; } - (void)testObjectForKey { OTAssertEqualObjects([_dictionary objectForKey: keys[0]], objects[0]); OTAssertEqualObjects([_dictionary objectForKey: keys[1]], objects[1]); } - (void)testCount { OTAssertEqual(_dictionary.count, 2); } - (void)testIsEqual { OTAssertEqualObjects(_dictionary, [OFDictionary dictionaryWithObjects: objects forKeys: keys count: 2]); OTAssertNotEqualObjects(_dictionary, [OFDictionary dictionaryWithObjects: keys forKeys: objects count: 2]); } - (void)testHash { OTAssertEqual(_dictionary.hash, [[OFDictionary dictionaryWithObjects: objects forKeys: keys count: 2] hash]); OTAssertNotEqual(_dictionary.hash, [[OFDictionary dictionaryWithObject: objects[0] forKey: keys[0]] hash]); } - (void)testCopy { OTAssertEqualObjects([[_dictionary copy] autorelease], _dictionary); } - (void)testMutableCopy { OTAssertEqualObjects( [[_dictionary mutableCopy] autorelease], _dictionary); } - (void)testValueForKey { OTAssertEqualObjects([_dictionary valueForKey: keys[0]], objects[0]); OTAssertEqualObjects([_dictionary valueForKey: keys[1]], objects[1]); OTAssertEqualObjects( [_dictionary valueForKey: @"@count"], [OFNumber numberWithInt: 2]); } - (void)testSetValueForKey { OTAssertThrowsSpecific([_dictionary setValue: @"x" forKey: @"x"], OFUndefinedKeyException); } - (void)testContainsObject { OTAssertTrue([_dictionary containsObject: objects[0]]); OTAssertFalse([_dictionary containsObject: @"nonexistent"]); } - (void)testContainsObjectIdenticalTo { OTAssertTrue([_dictionary containsObjectIdenticalTo: objects[0]]); OTAssertFalse([_dictionary containsObjectIdenticalTo: [[objects[0] mutableCopy] autorelease]]); } - (void)testDescription { OTAssert( [_dictionary.description isEqual: @"{\n\tkey1 = value1;\n\tkey2 = value2;\n}"] || [_dictionary.description isEqual: @"{\n\tkey2 = value2;\n\tkey1 = value1;\n}"]); } - (void)testAllKeys { OTAssert( [_dictionary.allKeys isEqual: ([OFArray arrayWithObjects: keys[0], keys[1], nil])] || [_dictionary.allKeys isEqual: ([OFArray arrayWithObjects: keys[1], keys[0], nil])]); } - (void)testAllObjects { OTAssert( [_dictionary.allObjects isEqual: ([OFArray arrayWithObjects: objects[0], objects[1], nil])] || [_dictionary.allObjects isEqual: ([OFArray arrayWithObjects: objects[1], objects[0], nil])]); } - (void)testKeyEnumerator { OFEnumerator *enumerator = [_dictionary keyEnumerator]; OFString *first, *second; first = [enumerator nextObject]; second = [enumerator nextObject]; OTAssertNil([enumerator nextObject]); OTAssert( ([first isEqual: keys[0]] && [second isEqual: keys[1]]) || ([first isEqual: keys[1]] && [second isEqual: keys[0]])); } - (void)testObjectEnumerator { OFEnumerator *enumerator = [_dictionary objectEnumerator]; OFString *first, *second; first = [enumerator nextObject]; second = [enumerator nextObject]; OTAssertNil([enumerator nextObject]); OTAssert( ([first isEqual: objects[0]] && [second isEqual: objects[1]]) || ([first isEqual: objects[1]] && [second isEqual: objects[0]])); } - (void)testFastEnumeration { size_t i = 0; OFString *first = nil, *second = nil; for (OFString *key in _dictionary) { OTAssertLessThan(i, 2); switch (i++) { case 0: first = key; break; case 1: second = key; break; } } OTAssertEqual(i, 2); OTAssert( ([first isEqual: keys[0]] && [second isEqual: keys[1]]) || ([first isEqual: keys[1]] && [second isEqual: keys[0]])); } #ifdef OF_HAVE_BLOCKS - (void)testEnumerateKeysAndObjectsUsingBlock { __block size_t i = 0; __block OFString *first = nil, *second = nil; [_dictionary enumerateKeysAndObjectsUsingBlock: ^ (id key, id object, bool *stop) { OTAssertLessThan(i, 2); switch (i++) { case 0: first = key; break; case 1: second = key; break; } }]; OTAssertEqual(i, 2); OTAssert( ([first isEqual: keys[0]] && [second isEqual: keys[1]]) || ([first isEqual: keys[1]] && [second isEqual: keys[0]])); } - (void)testMappedDictionaryUsingBlock { OTAssertEqualObjects([_dictionary mappedDictionaryUsingBlock: ^ id (id key, id object) { if ([key isEqual: keys[0]]) return @"val1"; if ([key isEqual: keys[1]]) return @"val2"; return nil; }], ([OFDictionary dictionaryWithKeysAndObjects: @"key1", @"val1", @"key2", @"val2", nil])); } - (void)testFilteredDictionaryUsingBlock { OTAssertEqualObjects([_dictionary filteredDictionaryUsingBlock: ^ bool (id key, id object) { return [key isEqual: keys[0]]; }], [OFDictionary dictionaryWithObject: objects[0] forKey: keys[0]]); } #endif @end @implementation CustomDictionary - (instancetype)initWithObjects: (const id *)objects_ forKeys: (const id *)keys_ count: (size_t)count { self = [super init]; @try { _dictionary = [[OFDictionary alloc] initWithObjects: objects_ forKeys: keys_ count: count]; } @catch (id e) { [self release]; @throw e; } return self; } |
︙ | ︙ | |||
107 108 109 110 111 112 113 114 | return _dictionary.count; } - (OFEnumerator *)keyEnumerator { return [_dictionary keyEnumerator]; } @end | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 298 299 300 301 302 303 304 305 | return _dictionary.count; } - (OFEnumerator *)keyEnumerator { return [_dictionary keyEnumerator]; } @end |
Added tests/OFFileManagerTests.m version [08e4ea3058].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #import "ObjFW.h" #import "ObjFWTest.h" @interface OFFileManagerTests: OTTestCase { OFFileManager *_fileManager; OFIRI *_testsDirectoryIRI, *_testFileIRI; } @end @implementation OFFileManagerTests - (void)setUp { _fileManager = [[OFFileManager defaultManager] retain]; _testsDirectoryIRI = [[[OFSystemInfo temporaryDirectoryIRI] IRIByAppendingPathComponent: @"objfw-tests"] retain]; _testFileIRI = [[_testsDirectoryIRI IRIByAppendingPathComponent: @"test.txt"] retain]; /* In case a previous test run failed and left things. */ if ([_fileManager directoryExistsAtIRI: _testsDirectoryIRI]) [_fileManager removeItemAtIRI: _testsDirectoryIRI]; [_fileManager createDirectoryAtIRI: _testsDirectoryIRI]; [@"test" writeToIRI: _testFileIRI]; } - (void)tearDown { [_fileManager removeItemAtIRI: _testsDirectoryIRI]; } - (void)dealloc { [_fileManager release]; [_testsDirectoryIRI release]; [_testFileIRI release]; [super dealloc]; } - (void)testCurrentDirectoryPath { OTAssertEqualObjects( _fileManager.currentDirectoryPath.lastPathComponent, @"tests"); } - (void)testAttributesOfItemAtPath { OFFileAttributes attributes; attributes = [_fileManager attributesOfItemAtPath: _testsDirectoryIRI.fileSystemRepresentation]; OTAssertEqual(attributes.fileType, OFFileTypeDirectory); attributes = [_fileManager attributesOfItemAtPath: _testFileIRI.fileSystemRepresentation]; OTAssertEqual(attributes.fileType, OFFileTypeRegular); OTAssertEqual(attributes.fileSize, 4); } - (void)testSetAttributesOfItemAtPath { OFDate *date = [OFDate dateWithTimeIntervalSince1970: 946681200]; OFFileAttributes attributes; attributes = [OFDictionary dictionaryWithObject: date forKey: OFFileModificationDate]; [_fileManager setAttributes: attributes ofItemAtPath: _testFileIRI.fileSystemRepresentation]; attributes = [_fileManager attributesOfItemAtPath: _testFileIRI.fileSystemRepresentation]; OTAssertEqual(attributes.fileType, OFFileTypeRegular); OTAssertEqual(attributes.fileSize, 4); OTAssertEqualObjects(attributes.fileModificationDate, date); } - (void)testFileExistsAtPath { OTAssertTrue([_fileManager fileExistsAtPath: _testsDirectoryIRI.fileSystemRepresentation]); OTAssertTrue([_fileManager fileExistsAtPath: _testFileIRI.fileSystemRepresentation]); } - (void)testDirectoryExistsAtPath { OTAssertTrue([_fileManager directoryExistsAtPath: _testsDirectoryIRI.fileSystemRepresentation]); OTAssertFalse([_fileManager directoryExistsAtPath: _testFileIRI.fileSystemRepresentation]); } - (void)testDirectoryAtPathCreateParents { OFIRI *nestedDirectoryIRI = [_testsDirectoryIRI IRIByAppendingPathComponent: @"0/1/2/3/4/5"]; [_fileManager createDirectoryAtPath: nestedDirectoryIRI.fileSystemRepresentation createParents: true]; OTAssertTrue([_fileManager directoryExistsAtPath: nestedDirectoryIRI.fileSystemRepresentation]); } - (void)testContentsOfDirectoryAtPath { OFIRI *file1IRI = [_testsDirectoryIRI IRIByAppendingPathComponent: @"1.txt"]; OFIRI *file2IRI = [_testsDirectoryIRI IRIByAppendingPathComponent: @"2.txt"]; [@"1" writeToIRI: file1IRI]; [@"2" writeToIRI: file2IRI]; OTAssertEqualObjects([_fileManager contentsOfDirectoryAtPath: _testsDirectoryIRI.fileSystemRepresentation].sortedArray, ([OFArray arrayWithObjects: @"1.txt", @"2.txt", @"test.txt", nil])); } - (void)testSubpathsOfDirectoryAtPath { OFIRI *subdirectory1IRI = [_testsDirectoryIRI IRIByAppendingPathComponent: @"a"]; OFIRI *subdirectory2IRI = [_testsDirectoryIRI IRIByAppendingPathComponent: @"b"]; OFIRI *file1IRI = [subdirectory1IRI IRIByAppendingPathComponent: @"1.txt"]; OFIRI *file2IRI = [subdirectory2IRI IRIByAppendingPathComponent: @"2.txt"]; [_fileManager createDirectoryAtIRI: subdirectory1IRI]; [_fileManager createDirectoryAtIRI: subdirectory2IRI]; [@"1" writeToIRI: file1IRI]; [@"2" writeToIRI: file2IRI]; OTAssertEqualObjects([_fileManager subpathsOfDirectoryAtPath: _testsDirectoryIRI.fileSystemRepresentation].sortedArray, ([OFArray arrayWithObjects: _testsDirectoryIRI.fileSystemRepresentation, subdirectory1IRI.fileSystemRepresentation, file1IRI.fileSystemRepresentation, subdirectory2IRI.fileSystemRepresentation, file2IRI.fileSystemRepresentation, _testFileIRI.fileSystemRepresentation, nil])); } - (void)testChangeCurrentDirectoryPath { OFString *oldDirectoryPath = _fileManager.currentDirectoryPath; OTAssertFalse([_fileManager fileExistsAtPath: @"test.txt"]); [_fileManager changeCurrentDirectoryPath: _testsDirectoryIRI.fileSystemRepresentation]; @try { /* * We can't check whether currentDirectoryPath is * _testsDirectoryIRI.fileSystemRepresentation because they * could be different due to symlinks. Therefore check for * presence of test.txt instead. */ OTAssertTrue([_fileManager fileExistsAtPath: @"test.txt"]); } @finally { [_fileManager changeCurrentDirectoryPath: oldDirectoryPath]; } } - (void)testCopyItemAtPathToPath { OFIRI *sourceIRI = [_testsDirectoryIRI IRIByAppendingPathComponent: @"source"]; OFIRI *destinationIRI = [_testsDirectoryIRI IRIByAppendingPathComponent: @"destination"]; OFIRI *subdirectory1IRI = [sourceIRI IRIByAppendingPathComponent: @"a"]; OFIRI *subdirectory2IRI = [sourceIRI IRIByAppendingPathComponent: @"b"]; OFIRI *file1IRI = [subdirectory1IRI IRIByAppendingPathComponent: @"1.txt"]; OFIRI *file2IRI = [subdirectory2IRI IRIByAppendingPathComponent: @"2.txt"]; [_fileManager createDirectoryAtIRI: subdirectory1IRI createParents: true]; [_fileManager createDirectoryAtIRI: subdirectory2IRI createParents: true]; [@"1" writeToIRI: file1IRI]; [@"2" writeToIRI: file2IRI]; subdirectory1IRI = [destinationIRI IRIByAppendingPathComponent: @"a"]; subdirectory2IRI = [destinationIRI IRIByAppendingPathComponent: @"b"]; file1IRI = [subdirectory1IRI IRIByAppendingPathComponent: @"1.txt"]; file2IRI = [subdirectory2IRI IRIByAppendingPathComponent: @"2.txt"]; OTAssertFalse([_fileManager directoryExistsAtIRI: subdirectory1IRI]); OTAssertFalse([_fileManager directoryExistsAtIRI: subdirectory2IRI]); OTAssertFalse([_fileManager fileExistsAtIRI: file1IRI]); OTAssertFalse([_fileManager fileExistsAtIRI: file2IRI]); [_fileManager copyItemAtPath: sourceIRI.fileSystemRepresentation toPath: destinationIRI.fileSystemRepresentation]; OTAssertTrue([_fileManager directoryExistsAtIRI: subdirectory1IRI]); OTAssertTrue([_fileManager directoryExistsAtIRI: subdirectory2IRI]); OTAssertEqualObjects([OFString stringWithContentsOfIRI: file1IRI], @"1"); OTAssertEqualObjects([OFString stringWithContentsOfIRI: file2IRI], @"2"); } - (void)testMoveItemAtPathToPath { OFIRI *sourceIRI = [_testsDirectoryIRI IRIByAppendingPathComponent: @"source"]; OFIRI *destinationIRI = [_testsDirectoryIRI IRIByAppendingPathComponent: @"destination"]; OFIRI *subdirectory1IRI = [sourceIRI IRIByAppendingPathComponent: @"a"]; OFIRI *subdirectory2IRI = [sourceIRI IRIByAppendingPathComponent: @"b"]; OFIRI *file1IRI = [subdirectory1IRI IRIByAppendingPathComponent: @"1.txt"]; OFIRI *file2IRI = [subdirectory2IRI IRIByAppendingPathComponent: @"2.txt"]; [_fileManager createDirectoryAtIRI: subdirectory1IRI createParents: true]; [_fileManager createDirectoryAtIRI: subdirectory2IRI createParents: true]; [@"1" writeToIRI: file1IRI]; [@"2" writeToIRI: file2IRI]; [_fileManager moveItemAtPath: sourceIRI.fileSystemRepresentation toPath: destinationIRI.fileSystemRepresentation]; OTAssertFalse([_fileManager directoryExistsAtIRI: subdirectory1IRI]); OTAssertFalse([_fileManager directoryExistsAtIRI: subdirectory2IRI]); OTAssertFalse([_fileManager fileExistsAtIRI: file1IRI]); OTAssertFalse([_fileManager fileExistsAtIRI: file2IRI]); subdirectory1IRI = [destinationIRI IRIByAppendingPathComponent: @"a"]; subdirectory2IRI = [destinationIRI IRIByAppendingPathComponent: @"b"]; file1IRI = [subdirectory1IRI IRIByAppendingPathComponent: @"1.txt"]; file2IRI = [subdirectory2IRI IRIByAppendingPathComponent: @"2.txt"]; OTAssertTrue([_fileManager directoryExistsAtIRI: subdirectory1IRI]); OTAssertTrue([_fileManager directoryExistsAtIRI: subdirectory2IRI]); OTAssertEqualObjects([OFString stringWithContentsOfIRI: file1IRI], @"1"); OTAssertEqualObjects([OFString stringWithContentsOfIRI: file2IRI], @"2"); } - (void)testRemoveItemAtPath { OFIRI *subdirectoryIRI = [_testsDirectoryIRI IRIByAppendingPathComponent: @"dir"]; OFIRI *fileIRI = [subdirectoryIRI IRIByAppendingPathComponent: @"file.txt"]; [_fileManager createDirectoryAtIRI: subdirectoryIRI]; [@"file" writeToIRI: fileIRI]; OTAssertTrue([_fileManager directoryExistsAtIRI: subdirectoryIRI]); OTAssertTrue([_fileManager fileExistsAtIRI: fileIRI]); [_fileManager removeItemAtPath: subdirectoryIRI.fileSystemRepresentation]; OTAssertFalse([_fileManager fileExistsAtIRI: fileIRI]); OTAssertFalse([_fileManager directoryExistsAtIRI: subdirectoryIRI]); } #ifdef OF_FILE_MANAGER_SUPPORTS_LINKS - (void)testLinkItemAtPathToPath { OFIRI *sourceIRI = [_testsDirectoryIRI IRIByAppendingPathComponent: @"source"]; OFIRI *destinationIRI = [_testsDirectoryIRI IRIByAppendingPathComponent: @"destination"]; OFFileAttributes attributes; [@"test" writeToIRI: sourceIRI]; @try { [_fileManager linkItemAtPath: sourceIRI.fileSystemRepresentation toPath: destinationIRI.fileSystemRepresentation]; } @catch (OFNotImplementedException *e) { OTSkip(@"Links not supported"); } attributes = [_fileManager attributesOfItemAtIRI: destinationIRI]; OTAssertEqual(attributes.fileType, OFFileTypeRegular); OTAssertEqual(attributes.fileSize, 4); OTAssertEqualObjects([OFString stringWithContentsOfIRI: destinationIRI], @"test"); } #endif #ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS - (void)testCreateSymbolicLinkAtPathWithDestinationPath { OFIRI *sourceIRI, *destinationIRI; OFFileAttributes attributes; # ifdef OF_WINDOWS if ([OFSystemInfo wineVersion] != nil) OTSkip(@"Wine creates broken symlinks"); # endif sourceIRI = [_testsDirectoryIRI IRIByAppendingPathComponent: @"source"]; destinationIRI = [_testsDirectoryIRI IRIByAppendingPathComponent: @"destination"]; [@"test" writeToIRI: sourceIRI]; @try { OFString *sourcePath = sourceIRI.fileSystemRepresentation; OFString *destinationPath = destinationIRI.fileSystemRepresentation; [_fileManager createSymbolicLinkAtPath: destinationPath withDestinationPath: sourcePath]; } @catch (OFCreateSymbolicLinkFailedException *e) { if (e.errNo != EPERM) @throw e; OTSkip(@"No permission to create symlink.\n" @"On Windows, only the administrator can create symbolic " @"links."); } @catch (OFNotImplementedException *e) { OTSkip(@"Symlinks not supported"); } attributes = [_fileManager attributesOfItemAtIRI: destinationIRI]; OTAssertEqual(attributes.fileType, OFFileTypeSymbolicLink); OTAssertEqualObjects([OFString stringWithContentsOfIRI: destinationIRI], @"test"); } #endif #ifdef OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES - (void)testExtendedAttributes { OFData *data = [OFData dataWithItems: "test" count: 4]; OFString *testFilePath = _testFileIRI.fileSystemRepresentation; OFFileAttributes attributes; OFArray *extendedAttributeNames; @try { [_fileManager setExtendedAttributeData: data forName: @"user.test" ofItemAtPath: testFilePath]; } @catch (OFSetItemAttributesFailedException *e) { if (e.errNo != ENOTSUP && e.errNo != EOPNOTSUPP) @throw e; OTSkip(@"Extended attributes are not supported"); } attributes = [_fileManager attributesOfItemAtIRI: _testFileIRI]; extendedAttributeNames = [attributes objectForKey: OFFileExtendedAttributesNames]; OTAssertNotNil(extendedAttributeNames); OTAssertTrue([extendedAttributeNames containsObject: @"user.test"]); OTAssertEqualObjects( [_fileManager extendedAttributeDataForName: @"user.test" ofItemAtPath: testFilePath], data); [_fileManager removeExtendedAttributeForName: @"user.test" ofItemAtPath: testFilePath]; attributes = [_fileManager attributesOfItemAtIRI: _testFileIRI]; extendedAttributeNames = [attributes objectForKey: OFFileExtendedAttributesNames]; OTAssertNotNil(extendedAttributeNames); OTAssertFalse([extendedAttributeNames containsObject: @"user.test"]); OTAssertThrowsSpecific( [_fileManager extendedAttributeDataForName: @"user.test" ofItemAtPath: testFilePath], OFGetItemAttributesFailedException); } #endif #ifdef OF_HAIKU - (void)testGetExtendedAttributeDataAndTypeForNameOfItemAtPath { OFData *data; id type; [_fileManager getExtendedAttributeData: &data andType: &type forName: @"BEOS:TYPE" ofItemAtPath: @"/boot/system/lib/libbe.so"]; OTAssertEqualObjects(type, [OFNumber numberWithUnsignedLong: B_MIME_STRING_TYPE]); OTAssertEqualObjects(data, [OFData dataWithItems: "application/x-vnd.Be-elfexecutable" count: 35]); } - (void)testSetExtendedAttributeDataAndTypeForNameOfItemAtPath { OFString *testFilePath = _testFileIRI.fileSystemRepresentation; OFData *data, *expectedData = [OFData dataWithItems: "foobar" count: 6]; id type, expectedType = [OFNumber numberWithUnsignedLong: 1234]; [_fileManager setExtendedAttributeData: expectedData andType: expectedType forName: @"testattribute" ofItemAtPath: testFilePath]; [_fileManager getExtendedAttributeData: &data andType: &type forName: @"testattribute" ofItemAtPath: testFilePath]; OTAssertEqualObjects(data, expectedData); OTAssertEqualObjects(type, expectedType); [_fileManager removeExtendedAttributeForName: @"testattribute" ofItemAtPath: testFilePath]; OTAssertThrowsSpecific( [_fileManager getExtendedAttributeData: &data andType: &type forName: @"testattribute" ofItemAtPath: testFilePath], OFGetItemAttributesFailedException); } #endif @end |
Modified tests/OFHMACTests.m from [dc8ace4048] to [f31bc9fa04].
1 | /* | | | | | | > > > > | < > | | > > > > > > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "ObjFW.h" #import "ObjFWTest.h" @interface OFHMACTests: OTTestCase { OFStream *_stream; } @end static const uint8_t key[] = "yM9h8K6IWnJRvxC/0F8XRWG7RnACDBz8wqK2tbXrYVLoKC3vPLeJikyJSM47tVHc" "DlXHww9zULAC2sJUlm2Kg1z4oz2aXY3Y1PQSB4VkC/m0DQ7hCI6cAg4TWnKdzWTy" "cvYGX+Y6HWeDY79/PGSd8fNItme6I8w4HDBqU7BP2sum3jbePJqoiSnhcyJZQTeZ" "jw0ZXoyrfHgOYD2M+NsTDaGpLblFtQ7n5CczjKtafG40PkEwx1dcrd46U9i3GyTK"; static const size_t keyLength = sizeof(key); static const uint8_t MD5Digest[] = |
︙ | ︙ | |||
43 44 45 46 47 48 49 | "\x14\x52\x33\x4B\x9C\x5F\xD8\x07\x4E\x98\xAE\x97\x46\x29\x24\xB4"; static const uint8_t SHA512Digest[] = "\xF5\x8C\x3F\x9C\xA2\x2F\x0A\xF3\x26\xD8\xC0\x7E\x20\x63\x88\x61" "\xC9\xE1\x1F\xD7\xC7\xE5\x59\x33\xD5\x2F\xAF\x56\x1C\x94\xC8\xA4" "\x61\xB3\xF9\x1A\xE3\x09\x43\xA6\x5B\x85\xB1\x50\x5B\xCB\x1A\x2E" "\xB7\xE8\x87\xC1\x73\x19\x63\xF6\xA2\x91\x8D\x7E\x2E\xCC\xEC\x99"; | | | > | > > | | < < | | < | > > | > > | | > > | < | > | < < | > > | | | | < < > | < < | < < < < < < < < < < | | | > | | | > > | | > > | | > | < < > | > | < < > | < < < | > | | > | | > | | > > | > | | | < > > | 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | "\x14\x52\x33\x4B\x9C\x5F\xD8\x07\x4E\x98\xAE\x97\x46\x29\x24\xB4"; static const uint8_t SHA512Digest[] = "\xF5\x8C\x3F\x9C\xA2\x2F\x0A\xF3\x26\xD8\xC0\x7E\x20\x63\x88\x61" "\xC9\xE1\x1F\xD7\xC7\xE5\x59\x33\xD5\x2F\xAF\x56\x1C\x94\xC8\xA4" "\x61\xB3\xF9\x1A\xE3\x09\x43\xA6\x5B\x85\xB1\x50\x5B\xCB\x1A\x2E" "\xB7\xE8\x87\xC1\x73\x19\x63\xF6\xA2\x91\x8D\x7E\x2E\xCC\xEC\x99"; @implementation OFHMACTests - (void)setUp { OFIRI *IRI; [super setUp]; IRI = [OFIRI IRIWithString: @"embedded:testfile.bin"]; _stream = [[OFIRIHandler openItemAtIRI: IRI mode: @"r"] retain]; } - (void)tearDown { [_stream close]; [super tearDown]; } - (void)dealloc { [_stream release]; [super dealloc]; } - (void)testWithHashClass: (Class)hashClass expectedDigest: (const unsigned char *)expectedDigest { OFHMAC *HMAC = [OFHMAC HMACWithHashClass: hashClass allowsSwappableMemory: true]; OTAssertNotNil(HMAC); OTAssertThrowsSpecific([HMAC updateWithBuffer: "" length: 0], OFInvalidArgumentException); [HMAC setKey: key length: keyLength]; while (!_stream.atEndOfStream) { char buffer[64]; size_t length = [_stream readIntoBuffer: buffer length: 64]; [HMAC updateWithBuffer: buffer length: length]; } [HMAC calculate]; OTAssertEqual(memcmp(HMAC.digest, expectedDigest, HMAC.digestSize), 0); } - (void)testHMACWithMD5 { [self testWithHashClass: [OFMD5Hash class] expectedDigest: MD5Digest]; } - (void)testHMACWithRIPEMD160 { [self testWithHashClass: [OFRIPEMD160Hash class] expectedDigest: RIPEMD160Digest]; } - (void)testHMACWithSHA1 { [self testWithHashClass: [OFSHA1Hash class] expectedDigest: SHA1Digest]; } - (void)testHMACWithSHA256 { [self testWithHashClass: [OFSHA256Hash class] expectedDigest: SHA256Digest]; } - (void)testHMACWithSHA384 { [self testWithHashClass: [OFSHA384Hash class] expectedDigest: SHA384Digest]; } - (void)testHMACWithSHA512 { [self testWithHashClass: [OFSHA512Hash class] expectedDigest: SHA512Digest]; } @end |
Modified tests/OFHTTPClientTests.m from [64ad652a21] to [e9b6e1eab7].
1 | /* | | | | | | > > > > | < > | | > | < > | | < | < < < < < < | < | < < < | < < < | < < < < < | < < < | < | < < < < < < < < | < < < | > | | < | < > > > | | < < | | | | < < | | | | > > > | > > > > > > > > > > > > > > > > > > > > > > > | > | | > | | > > > | > > > > > > > > > > > > > > > > > > > > | > > | > > | > > > > > > > > > > | | > > > > > > > > > > | > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <inttypes.h> #include <string.h> #import "ObjFW.h" #import "ObjFWTest.h" @interface OFHTTPClientTests: OTTestCase <OFHTTPClientDelegate> { OFHTTPResponse *_response; } @end @interface HTTPClientTestsServer: OFThread { OFCondition *_condition; uint16_t _port; } @property (readonly, nonatomic) OFCondition *condition; @property (readonly) uint16_t port; @end @implementation OFHTTPClientTests - (void)dealloc { [_response release]; [super dealloc]; } - (void)client: (OFHTTPClient *)client wantsRequestBody: (OFStream *)body request: (OFHTTPRequest *)request { [body writeString: @"Hello"]; } - (void)client: (OFHTTPClient *)client didPerformRequest: (OFHTTPRequest *)request response: (OFHTTPResponse *)response_ exception: (id)exception { OTAssertNil(exception); [_response release]; _response = [response_ retain]; [[OFRunLoop mainRunLoop] stop]; } - (void)testClient { HTTPClientTestsServer *server; OFIRI *IRI; OFHTTPRequest *request; OFHTTPClient *client; OFData *data; server = [[[HTTPClientTestsServer alloc] init] autorelease]; server.supportsSockets = true; [server.condition lock]; [server start]; [server.condition wait]; [server.condition unlock]; IRI = [OFIRI IRIWithString: [OFString stringWithFormat: @"http://127.0.0.1:%" @PRIu16 "/foo", server.port]]; request = [OFHTTPRequest requestWithIRI: IRI]; request.headers = [OFDictionary dictionaryWithObject: @"5" forKey: @"Content-Length"]; client = [OFHTTPClient client]; client.delegate = self; [client asyncPerformRequest: request]; [[OFRunLoop mainRunLoop] runUntilDate: [OFDate dateWithTimeIntervalSinceNow: 2]]; OTAssertNotNil(_response); OTAssertNotNil([_response.headers objectForKey: @"Content-Length"]); data = [_response readDataUntilEndOfStream]; OTAssertEqual(data.count, 7); OTAssertEqual(data.itemSize, 1); OTAssertEqual(memcmp(data.items, "foo\nbar", 7), 0); OTAssertNil([server join]); } @end @implementation HTTPClientTestsServer @synthesize condition = _condition, port = _port; - (instancetype)init { self = [super init]; @try { _condition = [[OFCondition alloc] init]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_condition release]; [super dealloc]; } - (id)main { OFTCPSocket *listener, *client; OFSocketAddress address; bool sawHost = false, sawContentLength = false, sawContentType = false; bool sawUserAgent = false; char buffer[5]; [_condition lock]; listener = [OFTCPSocket socket]; address = [listener bindToHost: @"127.0.0.1" port: 0]; _port = OFSocketAddressIPPort(&address); [listener listen]; [_condition signal]; [_condition unlock]; client = [listener accept]; if (![[client readLine] isEqual: @"GET /foo HTTP/1.1"]) return @"Wrong request"; for (size_t i = 0; i < 4; i++) { OFString *line = [client readLine]; if ([line isEqual: [OFString stringWithFormat: @"Host: 127.0.0.1:%" @PRIu16, _port]]) sawHost = true; else if ([line isEqual: @"Content-Length: 5"]) sawContentLength = true; if ([line isEqual: @"Content-Type: application/" @"x-www-form-urlencoded; charset=UTF-8"]) sawContentType = true; else if ([line hasPrefix: @"User-Agent:"]) sawUserAgent = true; } if (!sawHost) return @"Missing host"; if (!sawContentLength) return @"Missing content length"; if (!sawContentType) return @"Missing content type"; if (!sawUserAgent) return @"Missing user agent"; if (![[client readLine] isEqual: @""]) return @"Missing empty line"; [client readIntoBuffer: buffer exactLength: 5]; if (memcmp(buffer, "Hello", 5) != 0) return @"Missing body"; [client writeString: @"HTTP/1.0 200 OK\r\n" @"cONTeNT-lENgTH: 7\r\n" @"\r\n" @"foo\n" @"bar"]; [client close]; return nil; } @end |
Modified tests/OFHTTPCookieManagerTests.m from [fc980e6e00] to [e4999ac571].
1 | /* | | | | | | > > > > | < > | | > | > | | < | | | | | < | < < | | < | < < | | | < | < < | | | < | < < | | | | < | < < | | | | < | | | | | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFW.h" #import "ObjFWTest.h" @interface OFHTTPCookieManagerTests: OTTestCase @end @implementation OFHTTPCookieManagerTests - (void)testCookieManager { OFHTTPCookieManager *manager = [OFHTTPCookieManager manager]; OFIRI *IRI1, *IRI2, *IRI3, *IRI4; OFHTTPCookie *cookie1, *cookie2, *cookie3, *cookie4, *cookie5; IRI1 = [OFIRI IRIWithString: @"http://nil.im/foo"]; IRI2 = [OFIRI IRIWithString: @"https://nil.im/foo/bar"]; IRI3 = [OFIRI IRIWithString: @"https://test.nil.im/foo/bar"]; IRI4 = [OFIRI IRIWithString: @"http://webkeks.org/foo/bar"]; cookie1 = [OFHTTPCookie cookieWithName: @"test" value: @"1" domain: @"nil.im"]; [manager addCookie: cookie1 forIRI: IRI1]; OTAssertEqualObjects([manager cookiesForIRI: IRI1], [OFArray arrayWithObject: cookie1]); cookie2 = [OFHTTPCookie cookieWithName: @"test" value: @"2" domain: @"webkeks.org"]; [manager addCookie: cookie2 forIRI: IRI1]; OTAssertEqualObjects([manager cookiesForIRI: IRI1], [OFArray arrayWithObject: cookie1]); OTAssertEqualObjects([manager cookiesForIRI: IRI4], [OFArray array]); cookie3 = [OFHTTPCookie cookieWithName: @"test" value: @"3" domain: @"nil.im"]; cookie3.secure = true; [manager addCookie: cookie3 forIRI: IRI2]; OTAssertEqualObjects([manager cookiesForIRI: IRI2], [OFArray arrayWithObject: cookie3]); OTAssertEqualObjects([manager cookiesForIRI: IRI1], [OFArray array]); cookie3.expires = [OFDate dateWithTimeIntervalSinceNow: -1]; cookie4 = [OFHTTPCookie cookieWithName: @"test" value: @"4" domain: @"nil.im"]; cookie4.domain = @".nil.im"; [manager addCookie: cookie4 forIRI: IRI2]; OTAssertEqualObjects([manager cookiesForIRI: IRI2], [OFArray arrayWithObject: cookie4]); OTAssertEqualObjects([manager cookiesForIRI: IRI3], [OFArray arrayWithObject: cookie4]); cookie5 = [OFHTTPCookie cookieWithName: @"bar" value: @"5" domain: @"test.nil.im"]; [manager addCookie: cookie5 forIRI: IRI1]; OTAssertEqualObjects([manager cookiesForIRI: IRI1], [OFArray arrayWithObject: cookie4]); OTAssertEqualObjects([manager cookiesForIRI: IRI3], ([OFArray arrayWithObjects: cookie4, cookie5, nil])); OTAssertEqualObjects(manager.cookies, ([OFArray arrayWithObjects: cookie3, cookie4, cookie5, nil])); [manager purgeExpiredCookies]; OTAssertEqualObjects(manager.cookies, ([OFArray arrayWithObjects: cookie4, cookie5, nil])); } @end |
Modified tests/OFHTTPCookieTests.m from [beb8a32ced] to [30a9a576ce].
1 | /* | | | | | | > > > > | < > | | > | > | | < | | < | > | | | | | | | > > | < < < < < | | > > | | | | | > > | | > > > > > | > > | | > | > > > > > > > > | > | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFW.h" #import "ObjFWTest.h" @interface OFHTTPCookieTests: OTTestCase @end @implementation OFHTTPCookieTests - (void)testCookiesWithResponseHeaderFieldsForIRI { OFIRI *IRI = [OFIRI IRIWithString: @"http://nil.im"]; OFHTTPCookie *cookie1 = [OFHTTPCookie cookieWithName: @"foo" value: @"bar" domain: @"nil.im"]; OFHTTPCookie *cookie2 = [OFHTTPCookie cookieWithName: @"qux" value: @"cookie" domain: @"nil.im"]; OFDictionary *headers; headers = [OFDictionary dictionaryWithObject: @"foo=bar" forKey: @"Set-Cookie"]; OTAssertEqualObjects( [OFHTTPCookie cookiesWithResponseHeaderFields: headers forIRI: IRI], [OFArray arrayWithObject: cookie1]); headers = [OFDictionary dictionaryWithObject: @"foo=bar,qux=cookie" forKey: @"Set-Cookie"]; OTAssertEqualObjects( [OFHTTPCookie cookiesWithResponseHeaderFields: headers forIRI: IRI], ([OFArray arrayWithObjects: cookie1, cookie2, nil])); cookie1.expires = [OFDate dateWithTimeIntervalSince1970: 1234567890]; cookie2.expires = [OFDate dateWithTimeIntervalSince1970: 1234567890]; cookie1.path = @"/x"; cookie2.domain = @"webkeks.org"; cookie2.path = @"/objfw"; cookie2.secure = true; cookie2.HTTPOnly = true; [cookie2.extensions addObject: @"foo"]; [cookie2.extensions addObject: @"bar"]; headers = [OFDictionary dictionaryWithObject: @"foo=bar; " @"Expires=Fri, 13 Feb 2009 23:31:30 GMT; " @"Path=/x," @"qux=cookie; " @"Expires=Fri, 13 Feb 2009 23:31:30 GMT; " @"Domain=webkeks.org; " @"Path=/objfw; " @"Secure; " @"HTTPOnly; " @"foo; " @"bar" forKey: @"Set-Cookie"]; OTAssertEqualObjects( [OFHTTPCookie cookiesWithResponseHeaderFields: headers forIRI: IRI], ([OFArray arrayWithObjects: cookie1, cookie2, nil])); } - (void)testRequestHeaderFieldsWithCookies { OFHTTPCookie *cookie1 = [OFHTTPCookie cookieWithName: @"foo" value: @"bar" domain: @"nil.im"]; OFHTTPCookie *cookie2 = [OFHTTPCookie cookieWithName: @"qux" value: @"cookie" domain: @"nil.im"]; OTAssertEqualObjects([OFHTTPCookie requestHeaderFieldsWithCookies: ([OFArray arrayWithObjects: cookie1, cookie2, nil])], [OFDictionary dictionaryWithObject: @"foo=bar; qux=cookie" forKey: @"Cookie"]); } @end |
Modified tests/OFINIFileTests.m from [18e2931d0e] to [97d500cefe].
1 | /* | | | | | | > > > > | < > | | > | | > > > > | | > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < < | > > | | < < < < < < < < < < < < < < < < < < < < | | | < < < < < | < < < < | < < < < < | < < < < < | < < < < < < < < < | < | | < < | > > | | | | | > > > | | | > | > | | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFW.h" #import "ObjFWTest.h" @interface OFINIFileTests: OTTestCase { OFINIFile *_file; } @end @implementation OFINIFileTests - (void)setUp { OFIRI *IRI; [super setUp]; IRI = [OFIRI IRIWithString: @"embedded:testfile.ini"]; _file = [[OFINIFile alloc] initWithIRI: IRI encoding: OFStringEncodingISO8859_1]; } - (void)dealloc { [_file release]; [super dealloc]; } - (void)testCategoryForName { OTAssertNotNil([_file categoryForName: @"tests"]); OTAssertNotNil([_file categoryForName: @"foobar"]); OTAssertNotNil([_file categoryForName: @"types"]); } - (void)testStringValueForKey { OTAssertEqualObjects( [[_file categoryForName: @"tests"] stringValueForKey: @"foo"], @"bar"); OTAssertEqualObjects([[_file categoryForName: @"foobar"] stringValueForKey: @"quxquxqux"], @"hello\"wörld"); } - (void)testLongLongValueForKeyDefaultValue { OTAssertEqual([[_file categoryForName: @"types"] longLongValueForKey: @"integer" defaultValue: 2], 0x20); } - (void)testBoolValueForKeyDefaultValue { OTAssertTrue([[_file categoryForName: @"types"] boolValueForKey: @"bool" defaultValue: false]); } - (void)testFloatValueForKeyDefaultValue { OTAssertEqual([[_file categoryForName: @"types"] floatValueForKey: @"float" defaultValue: 1], 0.5f); } - (void)testDoubleValueForKeyDefaultValue { OTAssertEqual([[_file categoryForName: @"types"] doubleValueForKey: @"double" defaultValue: 3], 0.25); } - (void)testArrayValueForKey { OFINICategory *types = [_file categoryForName: @"types"]; OFArray *array = [OFArray arrayWithObjects: @"1", @"2", nil]; OTAssertEqualObjects([types arrayValueForKey: @"array1"], array); OTAssertEqualObjects([types arrayValueForKey: @"array2"], array); OTAssertEqualObjects([types arrayValueForKey: @"array3"], [OFArray array]); } - (void)testWriteToIRIEncoding { OFString *expectedOutput = @"[tests]\r\n" @"foo=baz\r\n" @"foobar=baz\r\n" @";comment\r\n" @"new=new\r\n" @"\r\n" @"[foobar]\r\n" @";foobarcomment\r\n" @"qux=\" asd\"\r\n" @"quxquxqux=\"hello\\\"wörld\"\r\n" @"qux2=\"a\\f\"\r\n" @"qux3=a\fb\r\n" @"\r\n" @"[types]\r\n" @"integer=16\r\n" @"bool=false\r\n" @"float=0.25\r\n" @"array1=foo\r\n" @"array1=bar\r\n" @"double=0.75\r\n"; OFINICategory *tests = [_file categoryForName: @"tests"]; OFINICategory *foobar = [_file categoryForName: @"foobar"]; OFINICategory *types = [_file categoryForName: @"types"]; OFArray *array = [OFArray arrayWithObjects: @"foo", @"bar", nil]; #if defined(OF_HAVE_FILES) && !defined(OF_NINTENDO_DS) OFIRI *writeIRI; #endif [tests setStringValue: @"baz" forKey: @"foo"]; [tests setStringValue: @"new" forKey: @"new"]; [foobar setStringValue: @"a\fb" forKey: @"qux3"]; [types setLongLongValue: 0x10 forKey: @"integer"]; [types setBoolValue: false forKey: @"bool"]; [types setFloatValue: 0.25f forKey: @"float"]; [types setDoubleValue: 0.75 forKey: @"double"]; [types setArrayValue: array forKey: @"array1"]; [foobar removeValueForKey: @"quxqux "]; [types removeValueForKey: @"array2"]; /* FIXME: Find a way to write files on Nintendo DS */ #if defined(OF_HAVE_FILES) && !defined(OF_NINTENDO_DS) writeIRI = [OFSystemInfo temporaryDirectoryIRI]; if (writeIRI == nil) writeIRI = [[OFFileManager defaultManager] currentDirectoryIRI]; writeIRI = [writeIRI IRIByAppendingPathComponent: @"objfw-tests.ini" isDirectory: false]; [_file writeToIRI: writeIRI encoding: OFStringEncodingISO8859_1]; @try { OTAssertEqualObjects([OFString stringWithContentsOfIRI: writeIRI encoding: OFStringEncodingISO8859_1], expectedOutput); } @finally { [[OFFileManager defaultManager] removeItemAtIRI: writeIRI]; } #else (void)expectedOutput; #endif } @end |
Modified tests/OFIPXSocketTests.m from [abf65b2714] to [aba74770c1].
1 | /* | | | | | | > > > > | < > | > | > | > | | > < < > | < < | | | | < < < | < < < < | < < | | > > > > > > > > > > | > > | > > > > | | > > > > > | | > | | | | | | | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #include <string.h> #import "ObjFW.h" #import "ObjFWTest.h" @interface OFIPXSocketTests: OTTestCase @end @implementation OFIPXSocketTests - (void)testIPXSocket { OFIPXSocket *sock = [OFIPXSocket socket]; const unsigned char zeroNode[IPX_NODE_LEN] = { 0 }; OFSocketAddress address1, address2; OFDictionary *networkInterfaces; char buffer[5]; unsigned char node1[IPX_NODE_LEN], node2[IPX_NODE_LEN]; unsigned char node[IPX_NODE_LEN]; @try { address1 = [sock bindToNetwork: 0 node: zeroNode port: 0 packetType: 0]; } @catch (OFBindSocketFailedException *e) { switch (e.errNo) { case EAFNOSUPPORT: OTSkip(@"IPX unsupported"); case EADDRNOTAVAIL: OTSkip(@"IPX not configured"); default: @throw e; } } /* * Find any network interface with IPX and send to it. Any should be * fine since we bound to 0.0. */ networkInterfaces = [OFSystemInfo networkInterfaces]; for (OFString *name in networkInterfaces) { OFNetworkInterface interface = [networkInterfaces objectForKey: name]; OFData *addresses = [interface objectForKey: OFNetworkInterfaceIPXAddresses]; if (addresses.count == 0) continue; OFSocketAddressSetIPXNetwork(&address1, OFSocketAddressIPXNetwork([addresses itemAtIndex: 0])); OFSocketAddressGetIPXNode([addresses itemAtIndex: 0], node); OFSocketAddressSetIPXNode(&address1, node); } OFSocketAddressGetIPXNode(&address1, node); if (OFSocketAddressIPXNetwork(&address1) == 0 && memcmp(node, zeroNode, 6) == 0) OTSkip(@"Could not determine own IPX address"); [sock sendBuffer: "Hello" length: 5 receiver: &address1]; OTAssertEqual([sock receiveIntoBuffer: buffer length: 5 sender: &address2], 5); OTAssertEqual(memcmp(buffer, "Hello", 5), 0); OFSocketAddressGetIPXNode(&address1, node1); OFSocketAddressGetIPXNode(&address2, node2); OTAssertEqual(memcmp(node1, node2, IPX_NODE_LEN), 0); OTAssertEqual(OFSocketAddressIPXPort(&address1), OFSocketAddressIPXPort(&address2)); } @end |
Renamed and modified tests/OFURITests.m [e9cb46977b] to tests/OFIRITests.m [cb4d01184f].
1 | /* | | | | | | > > > > | < > | | > > > > > > > | | | | | < < < | < | | | > | | > | | | > | > > > > > > > > > > > > > | > > > | < | | < | | < | | > | > | | < | | > | > | | < | | < | | | | | > > | | > | > > | | > | > | > | > > | | > | > > | | > | | | > > > | | < < > | | < < > | | < < > | | < > | > > | | | | > < | > | | | > | > > | | > | | | > | | > | | > | > | | | | | | | | | | > | | > > > > > > > > | > > > > > > > | > | < | | | | > | > > > | | > > > > > | > > | > | > > > > > | | > | | | | | > > > | > | | > | | > | | > > > | > | | > > > | | > > | > > | | | > > | > | > > > > > > > > > > > > > | > > > > > | | > > | | > > | > | | > > > | > | | | | > > > > | | | > | < | > > | | | < | | | < > > | > > > | | > > > | | > > > > > | > > | > > > > > | < | > > | | > > | | > > | | > > > > > > | < < > > > > | | > > > > > > | > > > > > | > > > | > | | | > > | < > > > > > | | | > > | > | > | > | > > | | > | | > > > > | > > | > > | > > > | > | > > > > | > | | | | | > > | > | > | < | | > | > | > | | | | | > > | > > > > > > > > > > | > | > > > > > > > | > | | | > | > | | | | | > > | < | > | > | > | | | > | > | | > | > | > | | | | | > > | < | > | > | | > | > | > | | > | | > | > | | > | | > | > | | | > > | | | > > | | | > | | | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFW.h" #import "ObjFWTest.h" @interface OFIRITests: OTTestCase { OFIRI *_IRI[11]; OFMutableIRI *_mutableIRI; } @end static OFString *IRI0String = @"ht+tp://us%3Aer:p%40w@ho%3Ast:1234/" @"pa%3Fth?que%23ry=1&f%26oo=b%3dar#frag%23ment"; @implementation OFIRITests - (void)setUp { [super setUp]; _IRI[0] = [[OFIRI alloc] initWithString: IRI0String]; _IRI[1] = [[OFIRI alloc] initWithString: @"http://foo:80"]; _IRI[2] = [[OFIRI alloc] initWithString: @"http://bar/"]; _IRI[3] = [[OFIRI alloc] initWithString: @"file:///etc/passwd"]; _IRI[4] = [[OFIRI alloc] initWithString: @"http://foo/bar/qux/foo%2fbar"]; _IRI[5] = [[OFIRI alloc] initWithString: @"https://[12:34::56:abcd]/"]; _IRI[6] = [[OFIRI alloc] initWithString: @"https://[12:34::56:abcd]:234/"]; _IRI[7] = [[OFIRI alloc] initWithString: @"urn:qux:foo"]; _IRI[8] = [[OFIRI alloc] initWithString: @"file:/foo?query#frag"]; _IRI[9] = [[OFIRI alloc] initWithString: @"file:foo@bar/qux?query#frag"]; _IRI[10] = [[OFIRI alloc] initWithString: @"http://ä/ö?ü"]; _mutableIRI = [[OFMutableIRI alloc] initWithScheme: @"dummy"]; } - (void)dealloc { for (uint_fast8_t i = 0; i < 11; i++) [_IRI[i] release]; [_mutableIRI release]; [super dealloc]; } - (void)testIRIWithStringFailsWithInvalidCharacters { OTAssertThrowsSpecific([OFIRI IRIWithString: @"ht,tp://foo"], OFInvalidFormatException); OTAssertThrowsSpecific([OFIRI IRIWithString: @"http://f`oo"], OFInvalidFormatException); OTAssertThrowsSpecific([OFIRI IRIWithString: @"http://foo/`"], OFInvalidFormatException); OTAssertThrowsSpecific([OFIRI IRIWithString: @"http://foo/foo?`"], OFInvalidFormatException); OTAssertThrowsSpecific([OFIRI IRIWithString: @"http://foo/foo?foo#`"], OFInvalidFormatException); OTAssertThrowsSpecific([OFIRI IRIWithString: @"https://[g]/"], OFInvalidFormatException); OTAssertThrowsSpecific([OFIRI IRIWithString: @"https://[f]:/"], OFInvalidFormatException); OTAssertThrowsSpecific([OFIRI IRIWithString: @"https://[f]:f/"], OFInvalidFormatException); OTAssertThrowsSpecific([OFIRI IRIWithString: @"foo:"], OFInvalidFormatException); } - (void)testIRIWithStringRelativeToIRI { OTAssertEqualObjects([[OFIRI IRIWithString: @"/foo" relativeToIRI: _IRI[0]] string], @"ht+tp://us%3Aer:p%40w@ho%3Ast:1234/foo"); OTAssertEqualObjects( [[OFIRI IRIWithString: @"foo/bar?q" relativeToIRI: [OFIRI IRIWithString: @"http://h/qux/quux"]] string], @"http://h/qux/foo/bar?q"); OTAssertEqualObjects( [[OFIRI IRIWithString: @"foo/bar" relativeToIRI: [OFIRI IRIWithString: @"http://h/qux/?x"]] string], @"http://h/qux/foo/bar"); OTAssertEqualObjects([[OFIRI IRIWithString: @"http://foo/?q" relativeToIRI: _IRI[0]] string], @"http://foo/?q"); OTAssertEqualObjects( [[OFIRI IRIWithString: @"foo" relativeToIRI: [OFIRI IRIWithString: @"http://foo/bar"]] string], @"http://foo/foo"); OTAssertEqualObjects( [[OFIRI IRIWithString: @"foo" relativeToIRI: [OFIRI IRIWithString: @"http://foo"]] string], @"http://foo/foo"); } - (void)testIRIWithStringRelativeToIRIFailsWithInvalidCharacters { OTAssertThrowsSpecific( [OFIRI IRIWithString: @"`" relativeToIRI: _IRI[0]], OFInvalidFormatException); OTAssertThrowsSpecific( [OFIRI IRIWithString: @"/`" relativeToIRI: _IRI[0]], OFInvalidFormatException); OTAssertThrowsSpecific( [OFIRI IRIWithString: @"?`" relativeToIRI: _IRI[0]], OFInvalidFormatException); OTAssertThrowsSpecific( [OFIRI IRIWithString: @"#`" relativeToIRI: _IRI[0]], OFInvalidFormatException); } #ifdef OF_HAVE_FILES - (void)testFileIRIWithPath { OTAssertEqualObjects( [[OFIRI fileIRIWithPath: @"testfile.txt"] fileSystemRepresentation], [[OFFileManager defaultManager].currentDirectoryPath stringByAppendingPathComponent: @"testfile.txt"]); } # if defined(OF_WINDOWS) || defined(OF_MSDOS) - (void)testFileIRWithPathC { OFIRI *IRI = [OFIRI fileIRIWithPath: @"c:\\"]; OTAssertEqualObjects(IRI.string, @"file:/c:/"); OTAssertEqualObjects(IRI.fileSystemRepresentation, @"c:\\"); } # endif # ifdef OF_WINDOWS - (void)testFileIRIWithPathUNC { OFIRI *IRI; IRI = [OFIRI fileIRIWithPath: @"\\\\foo\\bar" isDirectory: false]; OTAssertEqualObjects(IRI.host, @"foo"); OTAssertEqualObjects(IRI.path, @"/bar"); OTAssertEqualObjects(IRI.string, @"file://foo/bar"); OTAssertEqualObjects(IRI.fileSystemRepresentation, @"\\\\foo\\bar"); IRI = [OFIRI fileIRIWithPath: @"\\\\test" isDirectory: true]; OTAssertEqualObjects(IRI.host, @"test"); OTAssertEqualObjects(IRI.path, @"/"); OTAssertEqualObjects(IRI.string, @"file://test/"); OTAssertEqualObjects(IRI.fileSystemRepresentation, @"\\\\test"); } # endif #endif - (void)testString { OTAssertEqualObjects(_IRI[0].string, IRI0String); OTAssertEqualObjects(_IRI[1].string, @"http://foo:80"); OTAssertEqualObjects(_IRI[2].string, @"http://bar/"); OTAssertEqualObjects(_IRI[3].string, @"file:///etc/passwd"); OTAssertEqualObjects(_IRI[4].string, @"http://foo/bar/qux/foo%2fbar"); OTAssertEqualObjects(_IRI[5].string, @"https://[12:34::56:abcd]/"); OTAssertEqualObjects(_IRI[6].string, @"https://[12:34::56:abcd]:234/"); OTAssertEqualObjects(_IRI[7].string, @"urn:qux:foo"); OTAssertEqualObjects(_IRI[8].string, @"file:/foo?query#frag"); OTAssertEqualObjects(_IRI[9].string, @"file:foo@bar/qux?query#frag"); OTAssertEqualObjects(_IRI[10].string, @"http://ä/ö?ü"); } - (void)testScheme { OTAssertEqualObjects(_IRI[0].scheme, @"ht+tp"); OTAssertEqualObjects(_IRI[3].scheme, @"file"); OTAssertEqualObjects(_IRI[8].scheme, @"file"); OTAssertEqualObjects(_IRI[9].scheme, @"file"); OTAssertEqualObjects(_IRI[10].scheme, @"http"); } - (void)testUser { OTAssertEqualObjects(_IRI[0].user, @"us:er"); OTAssertNil(_IRI[3].user); OTAssertNil(_IRI[9].user); OTAssertNil(_IRI[10].user); } - (void)testPassword { OTAssertEqualObjects(_IRI[0].password, @"p@w"); OTAssertNil(_IRI[3].password); OTAssertNil(_IRI[9].password); OTAssertNil(_IRI[10].password); } - (void)testHost { OTAssertEqualObjects(_IRI[0].host, @"ho:st"); OTAssertEqualObjects(_IRI[5].host, @"12:34::56:abcd"); OTAssertEqualObjects(_IRI[6].host, @"12:34::56:abcd"); OTAssertNil(_IRI[7].host); OTAssertNil(_IRI[8].host); OTAssertNil(_IRI[9].host); OTAssertEqualObjects(_IRI[10].host, @"ä"); } - (void)testPort { OTAssertEqual(_IRI[0].port.unsignedShortValue, 1234); OTAssertNil(_IRI[3].port); OTAssertEqual(_IRI[6].port.unsignedShortValue, 234); OTAssertNil(_IRI[7].port); OTAssertNil(_IRI[8].port); OTAssertNil(_IRI[9].port); OTAssertNil(_IRI[10].port); } - (void)testPath { OTAssertEqualObjects(_IRI[0].path, @"/pa?th"); OTAssertEqualObjects(_IRI[3].path, @"/etc/passwd"); OTAssertEqualObjects(_IRI[7].path, @"qux:foo"); OTAssertEqualObjects(_IRI[8].path, @"/foo"); OTAssertEqualObjects(_IRI[9].path, @"foo@bar/qux"); OTAssertEqualObjects(_IRI[10].path, @"/ö"); } - (void)testPathComponents { OTAssertEqualObjects(_IRI[0].pathComponents, ([OFArray arrayWithObjects: @"/", @"pa?th", nil])); OTAssertEqualObjects(_IRI[3].pathComponents, ([OFArray arrayWithObjects: @"/", @"etc", @"passwd", nil])); OTAssertEqualObjects(_IRI[4].pathComponents, ([OFArray arrayWithObjects: @"/", @"bar", @"qux", @"foo/bar", nil])); } - (void)testLastPathComponent { OTAssertEqualObjects([[OFIRI IRIWithString: @"http://host/foo//bar/baz"] lastPathComponent], @"baz"); OTAssertEqualObjects( [[OFIRI IRIWithString: @"http://host/foo//bar/baz/"] lastPathComponent], @"baz"); OTAssertEqualObjects([[OFIRI IRIWithString: @"http://host/foo/"] lastPathComponent], @"foo"); OTAssertEqualObjects([[OFIRI IRIWithString: @"http://host/"] lastPathComponent], @"/"); OTAssertEqualObjects(_IRI[4].lastPathComponent, @"foo/bar"); } - (void)testPathExtension { OTAssertEqualObjects( [[OFIRI IRIWithString: @"http://host/path.dir/path.file"] pathExtension], @"file"); OTAssertEqualObjects( [[OFIRI IRIWithString: @"http://host/path/path.dir/"] pathExtension], @"dir"); } - (void)testQuery { OTAssertEqualObjects(_IRI[0].query, @"que#ry=1&f&oo=b=ar"); OTAssertNil(_IRI[3].query); OTAssertEqualObjects(_IRI[8].query, @"query"); OTAssertEqualObjects(_IRI[9].query, @"query"); OTAssertEqualObjects(_IRI[10].query, @"ü"); } - (void)testQueryItems { OTAssertEqualObjects(_IRI[0].queryItems, ([OFArray arrayWithObjects: [OFPair pairWithFirstObject: @"que#ry" secondObject: @"1"], [OFPair pairWithFirstObject: @"f&oo" secondObject: @"b=ar"], nil])); } - (void)testFragment { OTAssertEqualObjects(_IRI[0].fragment, @"frag#ment"); OTAssertNil(_IRI[3].fragment); OTAssertEqualObjects(_IRI[8].fragment, @"frag"); OTAssertEqualObjects(_IRI[9].fragment, @"frag"); } - (void)testCopy { OTAssertEqualObjects([[_IRI[0] copy] autorelease], _IRI[0]); } - (void)testIsEqual { OTAssertEqualObjects(_IRI[0], [OFIRI IRIWithString: IRI0String]); OTAssertNotEqualObjects(_IRI[1], _IRI[2]); OTAssertEqualObjects([OFIRI IRIWithString: @"HTTP://bar/"], _IRI[2]); } - (void)testHash { OTAssertEqual(_IRI[0].hash, [[OFIRI IRIWithString: IRI0String] hash]); OTAssertNotEqual(_IRI[1].hash, _IRI[2].hash); } - (void)testIRIWithStringFailsWithInvalidFormat { OTAssertThrowsSpecific([OFIRI IRIWithString: @"http"], OFInvalidFormatException); } - (void)testIRIByAppendingPathComponent { OTAssertEqualObjects( [[[OFIRI IRIWithString: @"http://host/path/component"] IRIByAppendingPathComponent: @"foo/bar"] path], @"/path/component/foo/bar"); OTAssertEqualObjects( [[[OFIRI IRIWithString: @"http://host/path/component/"] IRIByAppendingPathComponent: @"foo/bar"] path], @"/path/component/foo/bar"); OTAssertEqualObjects( [[[OFIRI IRIWithString: @"http://host/path/component/"] IRIByAppendingPathComponent: @"foo/bar" isDirectory: true] path], @"/path/component/foo/bar/"); } - (void)testIRIByDeletingLastPathComponent { OTAssertEqualObjects( [[[OFIRI IRIWithString: @"http://host/path/component"] IRIByDeletingLastPathComponent] path], @"/path/"); OTAssertEqualObjects( [[[OFIRI IRIWithString: @"http://host/path/directory/"] IRIByDeletingLastPathComponent] path], @"/path/"); OTAssertEqualObjects( [[[OFIRI IRIWithString: @"http://host/path"] IRIByDeletingLastPathComponent] path], @"/"); OTAssertEqualObjects( [[[OFIRI IRIWithString: @"http://host/"] IRIByDeletingLastPathComponent] path], @"/"); OTAssertEqualObjects( [[[OFIRI IRIWithString: @"http://host"] IRIByDeletingLastPathComponent] path], @""); } - (void)testIRIByAppendingPathExtension { OTAssertEqualObjects( [[[OFIRI IRIWithString: @"http://host/path.dir/path"] IRIByAppendingPathExtension: @"file"] path], @"/path.dir/path.file"); OTAssertEqualObjects( [[[OFIRI IRIWithString: @"http://host/path/path/"] IRIByAppendingPathExtension: @"dir"] path], @"/path/path.dir/"); } - (void)testIRIByDeletingPathExtension { OTAssertEqualObjects( [[[OFIRI IRIWithString: @"http://host/path.dir/path.file"] IRIByDeletingPathExtension] path], @"/path.dir/path"); OTAssertEqualObjects( [[[OFIRI IRIWithString: @"http://host/path/path.dir/"] IRIByDeletingPathExtension] path], @"/path/path/"); } - (void)testIRIByAddingPercentEncodingForUnicodeCharacters { OTAssertEqualObjects( _IRI[10].IRIByAddingPercentEncodingForUnicodeCharacters, [OFIRI IRIWithString: @"http://%C3%A4/%C3%B6?%C3%BC"]); } - (void)testSetPercentEncodedSchemeFailsWithInvalidCharacters { OTAssertThrowsSpecific(_mutableIRI.scheme = @"%20", OFInvalidFormatException); } - (void)testSetHost { _mutableIRI.host = @"ho:st"; OTAssertEqualObjects(_mutableIRI.percentEncodedHost, @"ho%3Ast"); _mutableIRI.host = @"12:34:ab"; OTAssertEqualObjects(_mutableIRI.percentEncodedHost, @"[12:34:ab]"); _mutableIRI.host = @"12:34:aB"; OTAssertEqualObjects(_mutableIRI.percentEncodedHost, @"[12:34:aB]"); _mutableIRI.host = @"12:34:g"; OTAssertEqualObjects(_mutableIRI.percentEncodedHost, @"12%3A34%3Ag"); } - (void)testSetPercentEncodedHost { _mutableIRI.percentEncodedHost = @"ho%3Ast"; OTAssertEqualObjects(_mutableIRI.host, @"ho:st"); _mutableIRI.percentEncodedHost = @"[12:34]"; OTAssertEqualObjects(_mutableIRI.host, @"12:34"); _mutableIRI.percentEncodedHost = @"[12::ab]"; OTAssertEqualObjects(_mutableIRI.host, @"12::ab"); } - (void)testSetPercentEncodedHostFailsWithInvalidCharacters { OTAssertThrowsSpecific(_mutableIRI.percentEncodedHost = @"/", OFInvalidFormatException); OTAssertThrowsSpecific(_mutableIRI.percentEncodedHost = @"[12:34", OFInvalidFormatException); OTAssertThrowsSpecific(_mutableIRI.percentEncodedHost = @"[a::g]", OFInvalidFormatException); } - (void)testSetUser { _mutableIRI.user = @"us:er"; OTAssertEqualObjects(_mutableIRI.percentEncodedUser, @"us%3Aer"); } - (void)testSetPercentEncodedUser { _mutableIRI.percentEncodedUser = @"us%3Aer"; OTAssertEqualObjects(_mutableIRI.user, @"us:er"); } - (void)testSetPercentEncodedUserFailsWithInvalidCharacters { OTAssertThrowsSpecific(_mutableIRI.percentEncodedHost = @"/", OFInvalidFormatException); } - (void)testSetPassword { _mutableIRI.password = @"pass:word"; OTAssertEqualObjects(_mutableIRI.percentEncodedPassword, @"pass%3Aword"); } - (void)testSetPercentEncodedPassword { _mutableIRI.percentEncodedPassword = @"pass%3Aword"; OTAssertEqualObjects(_mutableIRI.password, @"pass:word"); } - (void)testSetPercentEncodedPasswordFailsWithInvalidCharacters { OTAssertThrowsSpecific(_mutableIRI.percentEncodedPassword = @"/", OFInvalidFormatException); } - (void)testSetPath { _mutableIRI.path = @"pa/th@?"; OTAssertEqualObjects(_mutableIRI.percentEncodedPath, @"pa/th@%3F"); } - (void)testSetPercentEncodedPath { _mutableIRI.percentEncodedPath = @"pa/th@%3F"; OTAssertEqualObjects(_mutableIRI.path, @"pa/th@?"); } - (void)testSetPercentEncodedPathFailsWithInvalidCharacters { OTAssertThrowsSpecific(_mutableIRI.percentEncodedPath = @"?", OFInvalidFormatException); } - (void)testSetQuery { _mutableIRI.query = @"que/ry?#"; OTAssertEqualObjects(_mutableIRI.percentEncodedQuery, @"que/ry?%23"); } - (void)testSetPercentEncodedQuery { _mutableIRI.percentEncodedQuery = @"que/ry?%23"; OTAssertEqualObjects(_mutableIRI.query, @"que/ry?#"); } - (void)testSetPercentEncodedQueryFailsWithInvalidCharacters { OTAssertThrowsSpecific(_mutableIRI.percentEncodedQuery = @"`", OFInvalidFormatException); } - (void)testSetQueryItems { _mutableIRI.queryItems = [OFArray arrayWithObjects: [OFPair pairWithFirstObject: @"foo&bar" secondObject: @"baz=qux"], [OFPair pairWithFirstObject: @"f=oobar" secondObject: @"b&azqux"], nil]; OTAssertEqualObjects(_mutableIRI.percentEncodedQuery, @"foo%26bar=baz%3Dqux&f%3Doobar=b%26azqux"); } - (void)testSetFragment { _mutableIRI.fragment = @"frag/ment?#"; OTAssertEqualObjects(_mutableIRI.percentEncodedFragment, @"frag/ment?%23"); } - (void)testSetPercentEncodedFragment { _mutableIRI.percentEncodedFragment = @"frag/ment?%23"; OTAssertEqualObjects(_mutableIRI.fragment, @"frag/ment?#"); } - (void)testSetPercentEncodedFragmentFailsWithInvalidCharacters { OTAssertThrowsSpecific(_mutableIRI.percentEncodedFragment = @"`", OFInvalidFormatException); } -(void)testIRIByAppendingPathComponentIsDirectory { OTAssertEqualObjects([[OFIRI IRIWithString: @"file:///foo/bar"] IRIByAppendingPathComponent: @"qux" isDirectory: false], [OFIRI IRIWithString: @"file:///foo/bar/qux"]); OTAssertEqualObjects([[OFIRI IRIWithString: @"file:///foo/bar/"] IRIByAppendingPathComponent: @"qux" isDirectory: false], [OFIRI IRIWithString: @"file:///foo/bar/qux"]); OTAssertEqualObjects([[OFIRI IRIWithString: @"file:///foo/bar/"] IRIByAppendingPathComponent: @"qu?x" isDirectory: false], [OFIRI IRIWithString: @"file:///foo/bar/qu%3Fx"]); OTAssertEqualObjects([[OFIRI IRIWithString: @"file:///foo/bar/"] IRIByAppendingPathComponent: @"qu?x" isDirectory: true], [OFIRI IRIWithString: @"file:///foo/bar/qu%3Fx/"]); } - (void)testIRIByStandardizingPath { OTAssertEqualObjects([[OFIRI IRIWithString: @"http://foo/bar/.."] IRIByStandardizingPath], [OFIRI IRIWithString: @"http://foo/"]); OTAssertEqualObjects( [[OFIRI IRIWithString: @"http://foo/bar/%2E%2E/../qux/"] IRIByStandardizingPath], [OFIRI IRIWithString: @"http://foo/bar/qux/"]); OTAssertEqualObjects( [[OFIRI IRIWithString: @"http://foo/bar/./././qux/./"] IRIByStandardizingPath], [OFIRI IRIWithString: @"http://foo/bar/qux/"]); OTAssertEqualObjects([[OFIRI IRIWithString: @"http://foo/bar/../../qux"] IRIByStandardizingPath], [OFIRI IRIWithString: @"http://foo/../qux"]); } @end |
Modified tests/OFInvocationTests.m from [bb91b5d725] to [d29247d55f].
1 | /* | | | | | | > > > > | < > | < | > > > | > > | | | | | > | > | > > > > > > | > > > > > > | > > > > > > > > > > > > > > | | | < < | < < < < < < < < < < < | < < | < < | < < | < | > < | > < | > < | < | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #if defined(HAVE_COMPLEX_H) && !defined(__STDC_NO_COMPLEX__) # include <complex.h> #endif #import "ObjFW.h" #import "ObjFWTest.h" @interface OFInvocationTests: OTTestCase { OFInvocation *_invocation; } @end struct TestStruct { unsigned char c; unsigned int i; }; @implementation OFInvocationTests - (struct TestStruct)invocationTestMethod1: (unsigned char)c : (unsigned int)i : (struct TestStruct *)testStructPtr : (struct TestStruct)testStruct { return testStruct; } - (void)setUp { [super setUp]; SEL selector = @selector(invocationTestMethod1::::); OFMethodSignature *signature = [self methodSignatureForSelector: selector]; _invocation = [[OFInvocation alloc] initWithMethodSignature: signature]; } - (void)dealloc { [_invocation release]; [super dealloc]; } - (void)testSetAndGetReturnValue { struct TestStruct testStruct, testStruct2; memset(&testStruct, 0xFF, sizeof(testStruct)); testStruct.c = 0x55; testStruct.i = 0xAAAAAAAA; [_invocation setReturnValue: &testStruct]; [_invocation getReturnValue: &testStruct2]; OTAssertEqual(memcmp(&testStruct, &testStruct2, sizeof(testStruct)), 0); } - (void)testSetAndGetArgumentAtIndex { struct TestStruct testStruct, testStruct2; struct TestStruct *testStructPtr = &testStruct, *testStructPtr2; unsigned const char c = 0xAA; unsigned char c2; const unsigned int i = 0x55555555; unsigned int i2; memset(&testStruct, 0xFF, sizeof(testStruct)); testStruct.c = 0x55; testStruct.i = 0xAAAAAAAA; memset(&testStruct2, 0, sizeof(testStruct2)); [_invocation setArgument: &c atIndex: 2]; [_invocation setArgument: &i atIndex: 3]; [_invocation setArgument: &testStructPtr atIndex: 4]; [_invocation setArgument: &testStruct atIndex: 5]; [_invocation getArgument: &c2 atIndex: 2]; OTAssertEqual(c, c2); [_invocation getArgument: &i2 atIndex: 3]; OTAssertEqual(i, i2); [_invocation getArgument: &testStructPtr2 atIndex: 4]; OTAssertEqual(testStructPtr, testStructPtr2); [_invocation getArgument: &testStruct2 atIndex: 5]; OTAssertEqual(memcmp(&testStruct, &testStruct2, sizeof(testStruct)), 0); } @end |
Modified tests/OFJSONTests.m from [330199594e] to [3d70f6cb68].
1 | /* | | | | | | > > > > | < > | | > | | | > | | < | | | > > > > > > | > > > > > > > > | > | | > | > | | | > | > | | | | | | > > | | | | | > > | | > | | > | | > | > | > | > > | | > | | | > > > | | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFW.h" #import "ObjFWTest.h" @interface OFJSONTests: OTTestCase { OFDictionary *_dictionary; } @end static OFString *string = @"{\"foo\"\t:'b\\na\\r', \"x\":/*foo*/ [.5\r,0xF," @"null//bar\n,\"foo\",false]}"; @implementation OFJSONTests - (void)setUp { [super setUp]; _dictionary = [[OTOrderedDictionary alloc] initWithKeysAndObjects: @"foo", @"b\na\r", @"x", [OFArray arrayWithObjects: [OFNumber numberWithFloat: .5f], [OFNumber numberWithInt: 0xF], [OFNull null], @"foo", [OFNumber numberWithBool: false], nil], nil]; } - (void)dealloc { [_dictionary release]; [super dealloc]; } - (void)testObjectByParsingJSON { OTAssertEqualObjects(string.objectByParsingJSON, _dictionary); } - (void)testJSONRepresentation { OTAssert(_dictionary.JSONRepresentation, @"{\"foo\":\"b\\na\\r\",\"x\":[0.5,15,null,\"foo\",false]}"); } - (void)testPrettyJSONRepresentation { OTAssertEqualObjects([_dictionary JSONRepresentationWithOptions: OFJSONRepresentationOptionPretty], @"{\n\t\"foo\": \"b\\na\\r\",\n\t\"x\": [\n\t\t0.5,\n\t\t15," @"\n\t\tnull,\n\t\t\"foo\",\n\t\tfalse\n\t]\n}"); } - (void)testJSON5Representation { OTAssertEqualObjects([_dictionary JSONRepresentationWithOptions: OFJSONRepresentationOptionJSON5], @"{foo:\"b\\\na\\r\",x:[0.5,15,null,\"foo\",false]}"); } - (void)testObjectByParsingJSONFailsWithInvalidJSON { OTAssertThrowsSpecific([@"{" objectByParsingJSON], OFInvalidJSONException); OTAssertThrowsSpecific([@"]" objectByParsingJSON], OFInvalidJSONException); OTAssertThrowsSpecific([@"bar" objectByParsingJSON], OFInvalidJSONException); OTAssertThrowsSpecific([@"[\"a\" \"b\"]" objectByParsingJSON], OFInvalidJSONException); } - (void)testObjectByParsingJSONWithDeepNesting { OTAssertEqualObjects( @"[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[{}]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]" .objectByParsingJSON, [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFArray arrayWithObject: [OFDictionary dictionary]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]); } - (void)testObjectByParsingJSONFailsWithTooDeepNesting { OTAssertThrowsSpecific( [@"[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[{}]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]" objectByParsingJSON], OFInvalidJSONException); } @end |
Modified tests/OFKernelEventObserverTests.m from [cec268df6c] to [11704d0412].
1 | /* | | | | | | > > > > | < > | > > > < | < < < < | < < < > < < < | < | > | | < < > < > | | | | | > | < < < < < < | | > | < > | | > > | < < < < < < < < < < | < < < < < < < < < | < < < < < < < < < < < < < < | > | | < < < < < < < < | < < < < < < | < < < < < < < < < | | < > < < < < < < | < < < | < < | < < | < < | < | < | | < | < | < | > | > > > | > > < > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFW.h" #import "ObjFWTest.h" #ifdef HAVE_KQUEUE # import "OFKqueueKernelEventObserver.h" #endif #ifdef HAVE_EPOLL # import "OFEpollKernelEventObserver.h" #endif #ifdef HAVE_POLL # import "OFPollKernelEventObserver.h" #endif #ifdef HAVE_SELECT # import "OFSelectKernelEventObserver.h" #endif @interface OFKernelEventObserverTests: OTTestCase <OFKernelEventObserverDelegate> { OFTCPSocket *_server, *_client, *_accepted; OFKernelEventObserver *_observer; size_t _events; } @end static const size_t numExpectedEvents = 3; @implementation OFKernelEventObserverTests - (void)setUp { OFSocketAddress address; [super setUp]; _server = [[OFTCPSocket alloc] init]; address = [_server bindToHost: @"127.0.0.1" port: 0]; [_server listen]; _client = [[OFTCPSocket alloc] init]; [_client connectToHost: @"127.0.0.1" port: OFSocketAddressIPPort(&address)]; [_client writeBuffer: "0" length: 1]; } - (void)dealloc { [_client release]; [_server release]; [_accepted release]; [_observer release]; [super dealloc]; } - (void)testKernelEventObserverWithClass: (Class)class { bool deadlineExceeded = false; OFDate *deadline; _observer = [[class alloc] init]; _observer.delegate = self; [_observer addObjectForReading: _server]; deadline = [OFDate dateWithTimeIntervalSinceNow: 1]; while (_events < numExpectedEvents) { if (deadline.timeIntervalSinceNow < 0) { deadlineExceeded = true; break; } [_observer observeForTimeInterval: 0.01]; } OTAssertFalse(deadlineExceeded); OTAssertEqual(_events, numExpectedEvents); } - (void)objectIsReadyForReading: (id)object { char buffer; switch (_events++) { case 0: OTAssertEqual(object, _server); _accepted = [[object accept] retain]; [_observer addObjectForReading: _accepted]; break; case 1: OTAssert(object, _accepted); OTAssertEqual([object readIntoBuffer: &buffer length: 1], 1); OTAssertEqual(buffer, '0'); [_client close]; break; case 2: OTAssertEqual(object, _accepted); OTAssertEqual([object readIntoBuffer: &buffer length: 1], 0); break; default: OTAssert(false); } } #ifdef HAVE_SELECT - (void)testSelectKernelEventObserver { [self testKernelEventObserverWithClass: [OFSelectKernelEventObserver class]]; } #endif #ifdef HAVE_POLL - (void)testPollKernelEventObserver { [self testKernelEventObserverWithClass: [OFPollKernelEventObserver class]]; } #endif #ifdef HAVE_EPOLL - (void)testEpollKernelEventObserver { [self testKernelEventObserverWithClass: [OFEpollKernelEventObserver class]]; } #endif #ifdef HAVE_KQUEUE - (void)testKqueueKernelEventObserver { [self testKernelEventObserverWithClass: [OFKqueueKernelEventObserver class]]; } #endif @end |
Added tests/OFLHAArchiveTests.m version [f344be51ea].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFW.h" #import "ObjFWTest.h" #define bufferSize 4096 @interface OFLHAArchiveTests: OTTestCase { char _buffer[bufferSize]; } @end @implementation OFLHAArchiveTests - (void)testCreateAndExtractArchive { OFMemoryStream *stream = [OFMemoryStream streamWithMemoryAddress: _buffer size: bufferSize writable: true]; OFLHAArchive *archive = [OFLHAArchive archiveWithStream: stream mode: @"w"]; OFLHAArchiveEntry *entry = [OFMutableLHAArchiveEntry entryWithFileName: @"testfile.txt"]; OFStream *entryStream = [archive streamForWritingEntry: entry]; size_t size; [entryStream writeString: @"Hello World!"]; [archive close]; size = (size_t)[stream seekToOffset: 0 whence: OFSeekCurrent]; OTAssertLessThanOrEqual(size, bufferSize); stream = [OFMemoryStream streamWithMemoryAddress: _buffer size: size writable: false]; archive = [OFLHAArchive archiveWithStream: stream mode: @"r"]; entry = [archive nextEntry]; OTAssertEqualObjects(entry.fileName, @"testfile.txt"); entryStream = [archive streamForReadingCurrentEntry]; OTAssertEqualObjects([entryStream readLine], @"Hello World!"); OTAssertNil([entryStream readLine]); OTAssertNil([archive nextEntry]); } @end |
Modified tests/OFListTests.m from [43f56ef79d] to [4ca6ed93be].
1 | /* | | | | | | > > > > | < > | | > > > > > > | > > > > | > | | | > | > | > | > > > | > > > | | < < > | | | | > > | > > > | > > | > > | > | > | | | | > | > | > > > | > | > > > > > > > > > | > > | > | > | | > | | | | | > | | | | | | > | | > > > | > > > > | > > | > > > | > > > | | | > | > > > > | > > | | | > | > | | > | | > > > | > > > | | > | | | > > > | > | > | > > | > | | | > > > | > | | > | | > | | | | > > | | | > | | | > > > > > | > | > | | | > > > > > > | > > | > > > > > > > > > > | | | | | | > | | > | | < | | < | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFW.h" #import "ObjFWTest.h" @interface OFListTests: OTTestCase { OFList *_list; } @end @implementation OFListTests - (void)setUp { [super setUp]; _list = [[OFList alloc] init]; [_list appendObject: @"Foo"]; [_list appendObject: @"Bar"]; [_list appendObject: @"Baz"]; } - (void)dealloc { [_list release]; [super dealloc]; } - (void)testCount { OTAssertEqual(_list.count, 3); } - (void)testAppendObject { OFListItem item; [_list appendObject: @"Qux"]; item = _list.firstListItem; OTAssertEqualObjects(OFListItemObject(item), @"Foo"); item = OFListItemNext(item); OTAssertEqualObjects(OFListItemObject(item), @"Bar"); item = OFListItemNext(item); OTAssertEqualObjects(OFListItemObject(item), @"Baz"); item = OFListItemNext(item); OTAssertEqualObjects(OFListItemObject(item), @"Qux"); item = OFListItemNext(item); OTAssertEqual(item, NULL); } - (void)testFirstListItem { OTAssertEqualObjects(OFListItemObject(_list.firstListItem), @"Foo"); } - (void)testFirstObject { OTAssertEqualObjects(_list.firstObject, @"Foo"); } - (void)testLastListItem { OTAssertEqualObjects(OFListItemObject(_list.lastListItem), @"Baz"); } - (void)testLastObject { OTAssertEqualObjects(_list.lastObject, @"Baz"); } - (void)testListItemNext { OTAssertEqualObjects( OFListItemObject(OFListItemNext(_list.firstListItem)), @"Bar"); } - (void)testListItemPrevious { OTAssertEqualObjects( OFListItemObject(OFListItemPrevious(_list.lastListItem)), @"Bar"); } - (void)testRemoveListItem { OFListItem item; [_list removeListItem: OFListItemNext(_list.firstListItem)]; item = _list.firstListItem; OTAssertEqualObjects(OFListItemObject(item), @"Foo"); item = OFListItemNext(item); OTAssertEqualObjects(OFListItemObject(item), @"Baz"); item = OFListItemNext(item); OTAssertEqual(item, NULL); } - (void)testInsertObjectBeforeListItem { OFListItem item; [_list insertObject: @"Qux" beforeListItem: _list.lastListItem]; item = _list.firstListItem; OTAssertEqualObjects(OFListItemObject(item), @"Foo"); item = OFListItemNext(item); OTAssertEqualObjects(OFListItemObject(item), @"Bar"); item = OFListItemNext(item); OTAssertEqualObjects(OFListItemObject(item), @"Qux"); item = OFListItemNext(item); OTAssertEqualObjects(OFListItemObject(item), @"Baz"); item = OFListItemNext(item); OTAssertEqual(item, NULL); } - (void)testInsertObjectAfterListItem { OFListItem item; [_list insertObject: @"Qux" afterListItem: _list.firstListItem]; item = _list.firstListItem; OTAssertEqualObjects(OFListItemObject(item), @"Foo"); item = OFListItemNext(item); OTAssertEqualObjects(OFListItemObject(item), @"Qux"); item = OFListItemNext(item); OTAssertEqualObjects(OFListItemObject(item), @"Bar"); item = OFListItemNext(item); OTAssertEqualObjects(OFListItemObject(item), @"Baz"); item = OFListItemNext(item); OTAssertEqual(item, NULL); } - (void)testContainsObject { OTAssertTrue([_list containsObject: @"Foo"]); OTAssertFalse([_list containsObject: @"Qux"]); } - (void)testContainsObjectIdenticalTo { OFString *foo = _list.firstObject; OTAssertTrue([_list containsObjectIdenticalTo: foo]); OTAssertFalse( [_list containsObjectIdenticalTo: [[foo mutableCopy] autorelease]]); } - (void)testIsEqual { OFList *list = [OFList list]; [list appendObject: @"Foo"]; [list appendObject: @"Bar"]; [list appendObject: @"Baz"]; OTAssertEqualObjects(list, _list); [list appendObject: @"Qux"]; OTAssertNotEqualObjects(list, _list); } - (void)testHash { OFList *list = [OFList list]; [list appendObject: @"Foo"]; [list appendObject: @"Bar"]; [list appendObject: @"Baz"]; OTAssertEqual(list.hash, _list.hash); [list appendObject: @"Qux"]; OTAssertNotEqual(list.hash, _list.hash); } - (void)testCopy { OTAssertEqualObjects([[_list copy] autorelease], _list); } - (void)testDescription { OTAssertEqualObjects(_list.description, @"[\n\tFoo,\n\tBar,\n\tBaz\n]"); } - (void)testEnumerator { OFEnumerator *enumerator = [_list objectEnumerator]; OTAssertEqualObjects([enumerator nextObject], @"Foo"); OTAssertEqualObjects([enumerator nextObject], @"Bar"); OTAssertEqualObjects([enumerator nextObject], @"Baz"); OTAssertNil([enumerator nextObject]); } - (void)testDetectMutationDuringEnumeration { OFEnumerator *enumerator = [_list objectEnumerator]; [_list removeListItem: _list.firstListItem]; OTAssertThrowsSpecific([enumerator nextObject], OFEnumerationMutationException); } - (void)testFastEnumeration { size_t i = 0; for (OFString *object in _list) { OTAssertLessThan(i, 3); switch (i++) { case 0: OTAssertEqualObjects(object, @"Foo"); break; case 1: OTAssertEqualObjects(object, @"Bar"); break; case 2: OTAssertEqualObjects(object, @"Baz"); break; } } OTAssertEqual(i, 3); } - (void)testDetectMutationDuringFastEnumeration { bool detected = false; @try { for (OFString *object in _list) { (void)object; [_list removeListItem: _list.firstListItem]; } } @catch (OFEnumerationMutationException *e) { detected = true; } OTAssertTrue(detected); } @end |
Modified tests/OFLocaleTests.m from [a51f4edb4e] to [f67cf6d251].
1 | /* | | | | | | > > > > | < > | | > < | > | < > > | < > < < > > > | | < < | > < | < > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFW.h" #import "ObjFWTest.h" @interface OFLocaleTests: OTTestCase @end @implementation OFLocaleTests + (OFArray OF_GENERIC(OFPair OF_GENERIC(OFString *, id) *) *)summary { OFMutableArray *summary = [OFMutableArray array]; #define ADD(name, value) \ [summary addObject: [OFPair pairWithFirstObject: name \ secondObject: value]]; ADD(@"Language code", [OFLocale languageCode]) ADD(@"Country code", [OFLocale countryCode]) ADD(@"Encoding", OFStringEncodingName([OFLocale encoding])) ADD(@"Decimal separator", [OFLocale decimalSeparator]) #undef ADD return summary; } @end |
Deleted tests/OFMD5HashTests.m version [5005b07061].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Added tests/OFMatrix4x4Tests.m version [87807a43c2].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFW.h" #import "ObjFWTest.h" @interface OFMatrix4x4Tests: OTTestCase { OFMatrix4x4 *_matrix; } @end @implementation OFMatrix4x4Tests - (void)setUp { [super setUp]; _matrix = [[OFMatrix4x4 alloc] initWithValues: (const float [4][4]){ { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 10, 11, 12 }, { 13, 14, 15, 16 } }]; } - (void)dealloc { [_matrix release]; [super dealloc]; } - (void)testIdentityMatrix { OTAssertEqual(memcmp([[OFMatrix4x4 identityMatrix] values], (const float [4][4]){ { 1, 0, 0, 0 }, { 0, 1, 0, 0 }, { 0, 0, 1, 0 }, { 0, 0, 0, 1 } }, 16 * sizeof(float)), 0); } - (void)testDescription { OTAssertEqualObjects(_matrix.description, @"<OFMatrix4x4: {\n" @"\t1 2 3 4\n" @"\t5 6 7 8\n" @"\t9 10 11 12\n" @"\t13 14 15 16\n" @"}>"); } - (void)testIsEqual { OTAssertEqualObjects([OFMatrix4x4 identityMatrix], ([OFMatrix4x4 matrixWithValues: (const float [4][4]){ { 1, 0, 0, 0 }, { 0, 1, 0, 0 }, { 0, 0, 1, 0 }, { 0, 0, 0, 1 } }])); } - (void)testHash { OTAssertEqual([[OFMatrix4x4 identityMatrix] hash], [([OFMatrix4x4 matrixWithValues: (const float [4][4]){ { 1, 0, 0, 0 }, { 0, 1, 0, 0 }, { 0, 0, 1, 0 }, { 0, 0, 0, 1 } }]) hash]); } - (void)testCopy { OTAssertEqualObjects([[_matrix copy] autorelease], _matrix); } - (void)testMultiplyWithMatrix { OFMatrix4x4 *matrix; matrix = [[_matrix copy] autorelease]; [matrix multiplyWithMatrix: [OFMatrix4x4 identityMatrix]]; OTAssertEqualObjects(matrix, _matrix); matrix = [OFMatrix4x4 matrixWithValues: (const float [4][4]){ { 100, 200, 300, 400 }, { 500, 600, 700, 800 }, { 900, 1000, 1100, 1200 }, { 1300, 1400, 1500, 1600 } }]; [matrix multiplyWithMatrix: _matrix]; OTAssertEqualObjects(matrix, ([OFMatrix4x4 matrixWithValues: (const float [4][4]){ { 9000, 10000, 11000, 12000 }, { 20200, 22800, 25400, 28000 }, { 31400, 35600, 39800, 44000 }, { 42600, 48400, 54200, 60000 } }])); } - (void)testTranslateWithVector { OFMatrix4x4 *matrix = [OFMatrix4x4 identityMatrix]; OFVector4D point; [matrix translateWithVector: OFMakeVector3D(1, 2, 3)]; point = [matrix transformedVector: OFMakeVector4D(2, 3, 4, 1)]; OTAssertEqual(point.x, 3); OTAssertEqual(point.y, 5); OTAssertEqual(point.z, 7); OTAssertEqual(point.w, 1); } - (void)testScaleWithVector { OFMatrix4x4 *matrix = [OFMatrix4x4 identityMatrix]; OFVector4D point; [matrix translateWithVector: OFMakeVector3D(1, 2, 3)]; [matrix scaleWithVector: OFMakeVector3D(-1, 0.5f, 2)]; point = [matrix transformedVector: OFMakeVector4D(2, 3, 4, 1)]; OTAssertEqual(point.x, -3); OTAssertEqual(point.y, 2.5); OTAssertEqual(point.z, 14); OTAssertEqual(point.w, 1); } - (void)testTransformVectorsCount { OF_ALIGN(16) OFVector4D points[2] = {{ 1, 2, 3, 1 }, { 7, 8, 9, 2 }}; [_matrix transformVectors: points count: 2]; OTAssertEqual(points[0].x, 18); OTAssertEqual(points[0].y, 46); OTAssertEqual(points[0].z, 74); OTAssertEqual(points[0].w, 102); OTAssertEqual(points[1].x, 58); OTAssertEqual(points[1].y, 162); OTAssertEqual(points[1].z, 266); OTAssertEqual(points[1].w, 370); } @end |
Modified tests/OFMemoryStreamTests.m from [14fae61fb2] to [dda350e668].
1 | /* | | | | | | > > > > | < > | | > > > | | | < | < < < < | | | > < | | | | | | < | < | > | > | | | | > | | | | | | | > > > | > > | | | | | | | | < | | < > | > > > > > | > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFW.h" #import "ObjFWTest.h" @interface OFMemoryStreamTests: OTTestCase @end static const char string[] = "abcdefghijkl"; @implementation OFMemoryStreamTests - (void)testReadOnlyMemoryStream { OFMemoryStream *stream = [OFMemoryStream streamWithMemoryAddress: (char *)string size: sizeof(string) writable: false]; char buffer[10]; /* * Test the lowlevel methods, as otherwise OFStream will do one big * read and we will not test OFMemoryStream. */ OTAssertEqual([stream lowlevelReadIntoBuffer: buffer length: 5], 5); OTAssertEqual(memcmp(buffer, "abcde", 5), 0); OTAssertEqual([stream lowlevelReadIntoBuffer: buffer length: 3], 3); OTAssertEqual(memcmp(buffer, "fgh", 3), 0); OTAssertEqual([stream lowlevelReadIntoBuffer: buffer length: 10], 5); OTAssertEqual(memcmp(buffer, "ijkl", 5), 0); OTAssertTrue([stream lowlevelIsAtEndOfStream]); OTAssertEqual([stream lowlevelSeekToOffset: 0 whence: OFSeekCurrent], sizeof(string)); OTAssertTrue([stream lowlevelIsAtEndOfStream]); OTAssertEqual([stream lowlevelSeekToOffset: 4 whence: OFSeekSet], 4); OTAssertFalse([stream lowlevelIsAtEndOfStream]); OTAssertEqual([stream lowlevelReadIntoBuffer: buffer length: 10], 9); OTAssertEqual(memcmp(buffer, "efghijkl", 9), 0); OTAssertEqual([stream lowlevelSeekToOffset: -2 whence: OFSeekEnd], 11); OTAssertEqual([stream lowlevelReadIntoBuffer: buffer length: 10], 2); OTAssertEqual(memcmp(buffer, "l", 2), 0); OTAssertEqual([stream lowlevelReadIntoBuffer: buffer length: 10], 0); OTAssertThrowsSpecific([stream lowlevelWriteBuffer: "" length: 1], OFWriteFailedException); } - (void)testReadWriteMemoryStream { OFMutableData *data = [OFMutableData dataWithCapacity: 13]; OFMemoryStream *stream; [data increaseCountBy: 13]; stream = [OFMemoryStream streamWithMemoryAddress: data.mutableItems size: data.count writable: true]; OTAssertEqual([stream lowlevelWriteBuffer: "abcde" length: 5], 5); OTAssertEqual([stream lowlevelWriteBuffer: "fgh" length: 3], 3); OTAssertEqual([stream lowlevelWriteBuffer: "ijkl" length: 5], 5); OTAssertEqual(memcmp(data.items, string, data.count), 0); OTAssertEqual([stream lowlevelSeekToOffset: -3 whence: OFSeekEnd], 10); OTAssertThrowsSpecific([stream lowlevelWriteBuffer: "xyz" length: 4], OFWriteFailedException); } - (void)testWritingTooMuchThrows { char buffer; OFMemoryStream *stream = [OFMemoryStream streamWithMemoryAddress: &buffer size: 1 writable: true]; OTAssertThrowsSpecific([stream writeBuffer: "ab" length: 2], OFWriteFailedException); } @end |
Added tests/OFMessagePackTests.m version [e9caa1174f].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "ObjFW.h" #import "ObjFWTest.h" @interface OFMessagePackTests: OTTestCase @end const char *smallDictionaryRepresentation = "\xDE\x00\x10\x00\x01\x01\x02\x02\x03\x03\x04\x04\x05\x05\x06\x06" "\x07\x07\x08\x08\x09\x09\x0A\x0A\x0B\x0B\x0C\x0C\x0D\x0D\x0E\x0E" "\x0F\x0F\x10"; @implementation OFMessagePackTests - (void)testMessagePackRepresentationForNull { OTAssertEqualObjects([[OFNull null] messagePackRepresentation], [OFData dataWithItems: "\xC0" count: 1]); } - (void)testObjectByParsingMessagePackForNull { OTAssertEqualObjects([[OFData dataWithItems: "\xC0" count: 1] objectByParsingMessagePack], [OFNull null]); } - (void)testMessagePackRepresentationForNumber { OTAssertEqualObjects([[OFNumber numberWithChar: -30] messagePackRepresentation], [OFData dataWithItems: "\xE2" count: 1]); OTAssertEqualObjects([[OFNumber numberWithChar: -33] messagePackRepresentation], [OFData dataWithItems: "\xD0\xDF" count: 2]); OTAssertEqualObjects([[OFNumber numberWithUnsignedChar: 127] messagePackRepresentation], [OFData dataWithItems: "\x7F" count: 1]); OTAssertEqualObjects([[OFNumber numberWithUnsignedChar: 128] messagePackRepresentation], [OFData dataWithItems: "\xCC\x80" count: 2]); OTAssertEqualObjects([[OFNumber numberWithShort: -129] messagePackRepresentation], [OFData dataWithItems: "\xD1\xFF\x7F" count: 3]); OTAssertEqualObjects([[OFNumber numberWithUnsignedShort: 256] messagePackRepresentation], [OFData dataWithItems: "\xCD\x01\x00" count: 3]); OTAssertEqualObjects([[OFNumber numberWithLong: -32769] messagePackRepresentation], [OFData dataWithItems: "\xD2\xFF\xFF\x7F\xFF" count: 5]); OTAssertEqualObjects([[OFNumber numberWithUnsignedLong: 65536] messagePackRepresentation], [OFData dataWithItems: "\xCE\x00\x01\x00\x00" count: 5]); OTAssertEqualObjects([[OFNumber numberWithLongLong: -2147483649] messagePackRepresentation], [OFData dataWithItems: "\xD3\xFF\xFF\xFF\xFF\x7F\xFF\xFF\xFF" count: 9]); OTAssertEqualObjects([[OFNumber numberWithUnsignedLongLong: 4294967296] messagePackRepresentation], [OFData dataWithItems: "\xCF\x00\x00\x00\x01\x00\x00\x00\x00" count: 9]); OTAssertEqualObjects([[OFNumber numberWithFloat: 1.25f] messagePackRepresentation], [OFData dataWithItems: "\xCA\x3F\xA0\x00\x00" count: 5]); OTAssertEqualObjects([[OFNumber numberWithDouble: 1.25] messagePackRepresentation], [OFData dataWithItems: "\xCB\x3F\xF4\x00\x00\x00\x00\x00\x00" count: 9]); OTAssertEqualObjects( [[OFNumber numberWithBool: true] messagePackRepresentation], [OFData dataWithItems: "\xC3" count: 1]); OTAssertEqualObjects( [[OFNumber numberWithBool: false] messagePackRepresentation], [OFData dataWithItems: "\xC2" count: 1]); } - (void)testObjectByParsingMessagePackForNumber { OTAssertEqualObjects([[OFData dataWithItems: "\xE2" count: 1] objectByParsingMessagePack], [OFNumber numberWithChar: -30]); OTAssertEqualObjects([[OFData dataWithItems: "\xD0\xDF" count: 2] objectByParsingMessagePack], [OFNumber numberWithChar: -33]); OTAssertEqualObjects([[OFData dataWithItems: "\x7F" count: 1] objectByParsingMessagePack], [OFNumber numberWithUnsignedChar: 127]); OTAssertEqualObjects([[OFData dataWithItems: "\xCC\x80" count: 2] objectByParsingMessagePack], [OFNumber numberWithUnsignedChar: 128]); OTAssertEqualObjects([[OFData dataWithItems: "\xD1\xFF\x7F" count: 3] objectByParsingMessagePack], [OFNumber numberWithShort: -129]); OTAssertEqualObjects([[OFData dataWithItems: "\xCD\x01\x00" count: 3] objectByParsingMessagePack], [OFNumber numberWithUnsignedShort: 256]); OTAssertEqualObjects( [[OFData dataWithItems: "\xD2\xFF\xFF\x7F\xFF" count: 5] objectByParsingMessagePack], [OFNumber numberWithLong: -32769]); OTAssertEqualObjects( [[OFData dataWithItems: "\xCE\x00\x01\x00\x00" count: 5] objectByParsingMessagePack], [OFNumber numberWithUnsignedLong: 65536]); OTAssertEqualObjects( [[OFData dataWithItems: "\xD3\xFF\xFF\xFF\xFF\x7F\xFF\xFF\xFF" count: 9] objectByParsingMessagePack], [OFNumber numberWithLongLong: -2147483649]); OTAssertEqualObjects( [[OFData dataWithItems: "\xCF\x00\x00\x00\x01\x00\x00\x00\x00" count: 9] objectByParsingMessagePack], [OFNumber numberWithUnsignedLongLong: 4294967296]); OTAssertEqualObjects( [[OFData dataWithItems: "\xCA\x3F\xA0\x00\x00" count: 5] objectByParsingMessagePack], [OFNumber numberWithFloat: 1.25f]); OTAssertEqualObjects( [[OFData dataWithItems: "\xCB\x3F\xF4\x00\x00\x00\x00\x00\x00" count: 9] objectByParsingMessagePack], [OFNumber numberWithDouble: 1.25]); OTAssertEqualObjects([[OFData dataWithItems: "\xC3" count: 1] objectByParsingMessagePack], [OFNumber numberWithBool: true]); OTAssertEqualObjects([[OFData dataWithItems: "\xC2" count: 1] objectByParsingMessagePack], [OFNumber numberWithBool: false]); } static void generateStringAndData(OFString **string, OFMutableData **data, size_t length, const char *dataPrefix, size_t dataPrefixLength) { *data = [OFMutableData dataWithCapacity: length + dataPrefixLength]; [*data addItems: dataPrefix count: dataPrefixLength]; [*data increaseCountBy: length]; memset([*data mutableItemAtIndex: dataPrefixLength], 'x', length); *string = [OFString stringWithUTF8String: [*data itemAtIndex: dataPrefixLength] length: length]; } - (void)testMessagePackRepresentationForString { OFString *string; OFMutableData *data; OTAssertEqualObjects(@"x".messagePackRepresentation, [OFData dataWithItems: "\xA1x" count: 2]); generateStringAndData(&string, &data, 32, "\xD9\x20", 2); OTAssertEqualObjects(string.messagePackRepresentation, data); generateStringAndData(&string, &data, 256, "\xDA\x01\x00", 3); OTAssertEqualObjects(string.messagePackRepresentation, data); generateStringAndData(&string, &data, 65536, "\xDB\x00\x01\x00\x00", 5); OTAssertEqualObjects(string.messagePackRepresentation, data); } - (void)testObjectByParsingMessagePackForString { OFString *string; OFMutableData *data; OTAssertEqualObjects([[OFData dataWithItems: "\xA1x" count: 2] objectByParsingMessagePack], @"x"); generateStringAndData(&string, &data, 32, "\xD9\x20", 2); OTAssertEqualObjects(data.objectByParsingMessagePack, string); generateStringAndData(&string, &data, 256, "\xDA\x01\x00", 3); OTAssertEqualObjects(data.objectByParsingMessagePack, string); generateStringAndData(&string, &data, 65536, "\xDB\x00\x01\x00\x00", 5); OTAssertEqualObjects(data.objectByParsingMessagePack, string); } - (void)testMessagePackRepresentationForData { OFMutableData *data; OTAssertEqualObjects( [[OFData dataWithItems: "x" count: 1] messagePackRepresentation], [OFData dataWithItems: "\xC4\x01x" count: 3]); data = [OFMutableData data]; [data addItems: "\xC5\x01\x00" count: 3]; [data increaseCountBy: 256]; memset([data mutableItemAtIndex: 3], 'x', 256); OTAssertEqualObjects([[data subdataWithRange: OFMakeRange(3, 256)] messagePackRepresentation], data); data = [OFMutableData data]; [data addItems: "\xC6\x00\x01\x00\x00" count: 5]; [data increaseCountBy: 65536]; memset([data mutableItemAtIndex: 5], 'x', 65536); OTAssertEqualObjects([[data subdataWithRange: OFMakeRange(5, 65536)] messagePackRepresentation], data); } - (void)testObjectByParsingMessagePackForData { OFMutableData *data; OTAssertEqualObjects([[OFData dataWithItems: "\xC4\x01x" count: 3] objectByParsingMessagePack], [OFData dataWithItems: "x" count: 1]); data = [OFMutableData data]; [data addItems: "\xC5\x01\x00" count: 3]; [data increaseCountBy: 256]; memset([data mutableItemAtIndex: 3], 'x', 256); OTAssertEqualObjects(data.objectByParsingMessagePack, [data subdataWithRange: OFMakeRange(3, 256)]); data = [OFMutableData data]; [data addItems: "\xC6\x00\x01\x00\x00" count: 5]; [data increaseCountBy: 65536]; memset([data mutableItemAtIndex: 5], 'x', 65536); OTAssertEqualObjects(data.objectByParsingMessagePack, [data subdataWithRange: OFMakeRange(5, 65536)]); } - (void)testMessagePackRepresentationForArray { OFMutableArray *array = [OFMutableArray arrayWithCapacity: 65536]; OFNumber *number = [OFNumber numberWithUnsignedInt: 1]; OFMutableData *data; OTAssertEqualObjects([[OFArray array] messagePackRepresentation], [OFData dataWithItems: "\x90" count: 1]); OTAssertEqualObjects( [[OFArray arrayWithObject: number] messagePackRepresentation], [OFData dataWithItems: "\x91\x01" count: 2]); data = [OFMutableData dataWithCapacity: 19]; [data addItems: "\xDC\x00\x10" count: 3]; [data increaseCountBy: 16]; memset([data mutableItemAtIndex: 3], '\x01', 16); for (size_t i = 0; i < 16; i++) [array addObject: number]; OTAssertEqualObjects(array.messagePackRepresentation, data); data = [OFMutableData dataWithCapacity: 65541]; [data addItems: "\xDD\x00\x01\x00\x00" count: 5]; [data increaseCountBy: 65536]; memset([data mutableItemAtIndex: 5], '\x01', 65536); for (size_t i = 16; i < 65536; i++) [array addObject: number]; OTAssertEqualObjects(array.messagePackRepresentation, data); } - (void)testObjectByParsingMessagePackForArray { OFMutableArray *array = [OFMutableArray arrayWithCapacity: 65536]; OFNumber *number = [OFNumber numberWithUnsignedInt: 1]; OFMutableData *data; OTAssertEqualObjects([[OFData dataWithItems: "\x90" count: 1] objectByParsingMessagePack], [OFArray array]); OTAssertEqualObjects([[OFData dataWithItems: "\x91\x01" count: 2] objectByParsingMessagePack], [OFArray arrayWithObject: number]); data = [OFMutableData dataWithCapacity: 19]; [data addItems: "\xDC\x00\x10" count: 3]; [data increaseCountBy: 16]; memset([data mutableItemAtIndex: 3], '\x01', 16); for (size_t i = 0; i < 16; i++) [array addObject: number]; OTAssertEqualObjects(data.objectByParsingMessagePack, array); data = [OFMutableData dataWithCapacity: 65541]; [data addItems: "\xDD\x00\x01\x00\x00" count: 5]; [data increaseCountBy: 65536]; memset([data mutableItemAtIndex: 5], '\x01', 65536); for (size_t i = 16; i < 65536; i++) [array addObject: number]; OTAssertEqualObjects(data.objectByParsingMessagePack, array); } - (void)testMessagePackRepresentationForDictionary { OFMutableArray *keys = [OFMutableArray arrayWithCapacity: 65536]; OFMutableArray *objects = [OFMutableArray arrayWithCapacity: 65536]; OTAssertEqualObjects([[OFDictionary dictionary] messagePackRepresentation], [OFData dataWithItems: "\x80" count: 1]); OTAssertEqualObjects([[OFDictionary dictionaryWithObject: [OFNumber numberWithUnsignedInt: 2] forKey: [OFNumber numberWithUnsignedInt: 1]] messagePackRepresentation], [OFData dataWithItems: "\x81\x01\x02" count: 3]); for (unsigned int i = 0; i < 16; i++) { [keys addObject: [OFNumber numberWithUnsignedInt: i]]; [objects addObject: [OFNumber numberWithUnsignedInt: i + 1]]; } OTAssertEqualObjects([[OTOrderedDictionary dictionaryWithObjects: objects.objects forKeys: keys.objects count: 16] messagePackRepresentation], [OFData dataWithItems: smallDictionaryRepresentation count: 35]); for (unsigned int i = 16; i < 65536; i++) { [keys addObject: [OFNumber numberWithUnsignedInt: i]]; [objects addObject: [OFNumber numberWithUnsignedInt: i + 1]]; } OTAssertEqualObjects([[OTOrderedDictionary dictionaryWithObjects: objects.objects forKeys: keys.objects count: 65536] messagePackRepresentation], [OFData dataWithContentsOfIRI: [OFIRI IRIWithString: @"embedded:big_dictionary.msgpack"]]); } - (void)testObjectByParsingMessagePackForDictionary { OFMutableDictionary *dictionary = [OFMutableDictionary dictionaryWithCapacity: 65536]; OTAssertEqualObjects([[OFData dataWithItems: "\x80" count: 1] objectByParsingMessagePack], [OFDictionary dictionary]); OTAssertEqualObjects([[OFData dataWithItems: "\x81\x01\x02" count: 3] objectByParsingMessagePack], [OFDictionary dictionaryWithObject: [OFNumber numberWithUnsignedInt: 2] forKey: [OFNumber numberWithUnsignedInt: 1]]); for (unsigned int i = 0; i < 16; i++) [dictionary setObject: [OFNumber numberWithUnsignedInt: i + 1] forKey: [OFNumber numberWithUnsignedInt: i]]; OTAssertEqualObjects( [[OFData dataWithItems: smallDictionaryRepresentation count: 35] objectByParsingMessagePack], dictionary); for (unsigned int i = 16; i < 65536; i++) [dictionary setObject: [OFNumber numberWithUnsignedInt: i + 1] forKey: [OFNumber numberWithUnsignedInt: i]]; OTAssertEqualObjects(dictionary, [[OFData dataWithContentsOfIRI: [OFIRI IRIWithString: @"embedded:big_dictionary.msgpack"]] objectByParsingMessagePack]); } - (void)testMessagePackRepresentationForExtension { OFMessagePackExtension *extension; OFMutableData *data; extension = [OFMessagePackExtension extensionWithType: 1 data: [OFData dataWithItems: "x" count: 1]]; OTAssertEqualObjects(extension.messagePackRepresentation, [OFData dataWithItems: "\xD4\x01x" count: 3]); extension = [OFMessagePackExtension extensionWithType: 1 data: [OFData dataWithItems: "xy" count: 2]]; OTAssertEqualObjects(extension.messagePackRepresentation, [OFData dataWithItems: "\xD5\x01xy" count: 4]); extension = [OFMessagePackExtension extensionWithType: 1 data: [OFData dataWithItems: "abcd" count: 4]]; OTAssertEqualObjects(extension.messagePackRepresentation, [OFData dataWithItems: "\xD6\x01" "abcd" count: 6]); extension = [OFMessagePackExtension extensionWithType: 1 data: [OFData dataWithItems: "12345678" count: 8]]; OTAssertEqualObjects(extension.messagePackRepresentation, [OFData dataWithItems: "\xD7\x01" "12345678" count: 10]); extension = [OFMessagePackExtension extensionWithType: 1 data: [OFData dataWithItems: "12345678ABCDEFGH" count: 16]]; OTAssertEqualObjects(extension.messagePackRepresentation, [OFData dataWithItems: "\xD8\x01" "12345678ABCDEFGH" count: 18]); extension = [OFMessagePackExtension extensionWithType: 1 data: [OFData data]]; OTAssertEqualObjects(extension.messagePackRepresentation, [OFData dataWithItems: "\xC7\x00\x01" count: 3]); extension = [OFMessagePackExtension extensionWithType: 1 data: [OFData dataWithItems: "abc" count: 3]]; OTAssertEqualObjects(extension.messagePackRepresentation, [OFData dataWithItems: "\xC7\x03\x01" "abc" count: 6]); data = [OFMutableData dataWithCapacity: 260]; [data addItems: "\xC8\x01\x00\x01" count: 4]; [data increaseCountBy: 256]; memset([data mutableItemAtIndex: 4], 'x', 256); extension = [OFMessagePackExtension extensionWithType: 1 data: [data subdataWithRange: OFMakeRange(4, 256)]]; OTAssertEqualObjects(extension.messagePackRepresentation, data); data = [OFMutableData dataWithCapacity: 65542]; [data addItems: "\xC9\x00\x01\x00\x00\x01" count: 6]; [data increaseCountBy: 65536]; memset([data mutableItemAtIndex: 6], 'x', 65536); extension = [OFMessagePackExtension extensionWithType: 1 data: [data subdataWithRange: OFMakeRange(6, 65536)]]; OTAssertEqualObjects(extension.messagePackRepresentation, data); } - (void)testObjectByParsingMessagePackForExtension { OFMessagePackExtension *extension; OFMutableData *data; extension = [OFMessagePackExtension extensionWithType: 1 data: [OFData dataWithItems: "x" count: 1]]; OTAssertEqualObjects([[OFData dataWithItems: "\xD4\x01x" count: 3] objectByParsingMessagePack], extension); extension = [OFMessagePackExtension extensionWithType: 1 data: [OFData dataWithItems: "xy" count: 2]]; OTAssertEqualObjects([[OFData dataWithItems: "\xD5\x01xy" count: 4] objectByParsingMessagePack], extension); extension = [OFMessagePackExtension extensionWithType: 1 data: [OFData dataWithItems: "abcd" count: 4]]; OTAssertEqualObjects( [[OFData dataWithItems: "\xD6\x01" "abcd" count: 6] objectByParsingMessagePack], extension); extension = [OFMessagePackExtension extensionWithType: 1 data: [OFData dataWithItems: "12345678" count: 8]]; OTAssertEqualObjects( [[OFData dataWithItems: "\xD7\x01" "12345678" count: 10] objectByParsingMessagePack], extension); extension = [OFMessagePackExtension extensionWithType: 1 data: [OFData dataWithItems: "12345678ABCDEFGH" count: 16]]; OTAssertEqualObjects( [[OFData dataWithItems: "\xD8\x01" "12345678ABCDEFGH" count: 18] objectByParsingMessagePack], extension); extension = [OFMessagePackExtension extensionWithType: 1 data: [OFData data]]; OTAssertEqualObjects([[OFData dataWithItems: "\xC7\x00\x01" count: 3] objectByParsingMessagePack], extension); extension = [OFMessagePackExtension extensionWithType: 1 data: [OFData dataWithItems: "abc" count: 3]]; OTAssertEqualObjects( [[OFData dataWithItems: "\xC7\x03\x01" "abc" count: 6] objectByParsingMessagePack], extension); data = [OFMutableData dataWithCapacity: 260]; [data addItems: "\xC8\x01\x00\x01" count: 4]; [data increaseCountBy: 256]; memset([data mutableItemAtIndex: 4], 'x', 256); extension = [OFMessagePackExtension extensionWithType: 1 data: [data subdataWithRange: OFMakeRange(4, 256)]]; OTAssertEqualObjects(data.objectByParsingMessagePack, extension); data = [OFMutableData dataWithCapacity: 65542]; [data addItems: "\xC9\x00\x01\x00\x00\x01" count: 6]; [data increaseCountBy: 65536]; memset([data mutableItemAtIndex: 6], 'x', 65536); extension = [OFMessagePackExtension extensionWithType: 1 data: [data subdataWithRange: OFMakeRange(6, 65536)]]; OTAssertEqualObjects(data.objectByParsingMessagePack, extension); } - (void)testMessagePackRepresentationForDate { OTAssertEqualObjects([[OFDate dateWithTimeIntervalSince1970: 1] messagePackRepresentation], [OFData dataWithItems: "\xD6\xFF\x00\x00\x00\x01" count: 6]); OTAssertEqualObjects([[OFDate dateWithTimeIntervalSince1970: 1.25] messagePackRepresentation], [OFData dataWithItems: "\xD7\xFF\x3B\x9A\xCA\x00\x00\x00\x00\x01" count: 10]); OTAssertEqualObjects( [[OFDate dateWithTimeIntervalSince1970: 0x400000000 + 0.25] messagePackRepresentation], [OFData dataWithItems: "\xC7\x0C\xFF\x0E\xE6\xB2\x80\x00\x00\x00" "\x04\x00\x00\x00\x00" count: 15]); } - (void)testObjectByParsingMessagePackForDate { OTAssertEqualObjects( [[OFData dataWithItems: "\xD6\xFF\x00\x00\x00\x01" count: 6] objectByParsingMessagePack], [OFDate dateWithTimeIntervalSince1970: 1]); OTAssertEqualObjects( [[OFData dataWithItems: "\xD7\xFF\x3B\x9A\xCA\x00\x00\x00\x00\x01" count: 10] objectByParsingMessagePack], [OFDate dateWithTimeIntervalSince1970: 1.25]); OTAssertEqualObjects( [[OFData dataWithItems: "\xC7\x0C\xFF\x0E\xE6\xB2\x80\x00\x00\x00" "\x04\x00\x00\x00\x00" count: 15] objectByParsingMessagePack], [OFDate dateWithTimeIntervalSince1970: 0x400000000 + 0.25]); } @end |
Modified tests/OFMethodSignatureTests.m from [8b3d41a60c] to [bd602d6dd5].
1 | /* | | | | | | > > > > | < > | | > | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #if !defined(__STDC_NO_COMPLEX__) && defined(HAVE_COMPLEX_H) # include <complex.h> #endif #import "ObjFW.h" #import "ObjFWTest.h" @interface OFMethodSignatureTests: OTTestCase @end struct Test1Struct { char c; int i; char d; }; |
︙ | ︙ | |||
65 66 67 68 69 70 71 | int i; union { float f; double d; } u; }; | | | < | | < | | | | | | | | | | | < | | | | | | | | | | | | | | | < | | > | | < | | < | | > > | > | > | > | | < | | < | | < | | < | | < | | | > | > | | < | | < | | < | | < | | < > | | < < | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | int i; union { float f; double d; } u; }; @implementation OFMethodSignatureTests - (void)testSignatureWithObjCTypes { OFMethodSignature *methodSignature; methodSignature = [OFMethodSignature signatureWithObjCTypes: "i28@0:8S16*20"]; OTAssertEqual(methodSignature.numberOfArguments, 4); OTAssertEqual(strcmp(methodSignature.methodReturnType, "i"), 0); OTAssertEqual(strcmp([methodSignature argumentTypeAtIndex: 0], "@"), 0); OTAssertEqual(strcmp([methodSignature argumentTypeAtIndex: 1], ":"), 0); OTAssertEqual(strcmp([methodSignature argumentTypeAtIndex: 2], "S"), 0); OTAssertEqual(strcmp([methodSignature argumentTypeAtIndex: 3], "*"), 0); OTAssertEqual(methodSignature.frameLength, 28); OTAssertEqual([methodSignature argumentOffsetAtIndex: 0], 0); OTAssertEqual([methodSignature argumentOffsetAtIndex: 1], 8); OTAssertEqual([methodSignature argumentOffsetAtIndex: 2], 16); OTAssertEqual([methodSignature argumentOffsetAtIndex: 3], 20); methodSignature = [OFMethodSignature signatureWithObjCTypes: "{s0=csi(u1={s2=iii{s3=(u4=ic^v*)}})}24@0:8" "^{s0=csi(u1={s2=iii{s3=(u4=ic^v*)}})}16"]; OTAssertEqual(methodSignature.numberOfArguments, 3); OTAssertEqual(strcmp(methodSignature.methodReturnType, "{s0=csi(u1={s2=iii{s3=(u4=ic^v*)}})}"), 0); OTAssertEqual(strcmp([methodSignature argumentTypeAtIndex: 0], "@"), 0); OTAssertEqual(strcmp([methodSignature argumentTypeAtIndex: 1], ":"), 0); OTAssertEqual(strcmp([methodSignature argumentTypeAtIndex: 2], "^{s0=csi(u1={s2=iii{s3=(u4=ic^v*)}})}"), 0); OTAssertEqual(methodSignature.frameLength, 24); OTAssertEqual([methodSignature argumentOffsetAtIndex: 0], 0); OTAssertEqual([methodSignature argumentOffsetAtIndex: 1], 8); OTAssertEqual([methodSignature argumentOffsetAtIndex: 2], 16); } - (void)testSignatureWithObjCTypesFailsWithInvalidFormat { OTAssertThrowsSpecific( [OFMethodSignature signatureWithObjCTypes: "{ii"], OFInvalidFormatException); OTAssertThrowsSpecific([OFMethodSignature signatureWithObjCTypes: ""], OFInvalidFormatException); OTAssertThrowsSpecific([OFMethodSignature signatureWithObjCTypes: "0"], OFInvalidFormatException); OTAssertThrowsSpecific( [OFMethodSignature signatureWithObjCTypes: "{{}0"], OFInvalidFormatException); } - (void)testSizeOfTypeEncoding { OTAssertEqual(OFSizeOfTypeEncoding(@encode(struct Test1Struct)), sizeof(struct Test1Struct)); OTAssertEqual(OFSizeOfTypeEncoding(@encode(struct Test2Struct)), sizeof(struct Test2Struct)); #if !defined(__STDC_NO_COMPLEX__) && defined(HAVE_COMPLEX_H) && \ OF_GCC_VERSION >= 402 OTAssertEqual(OFSizeOfTypeEncoding(@encode(struct Test3Struct)), sizeof(struct Test3Struct)); #endif OTAssertEqual(OFSizeOfTypeEncoding(@encode(union Test3Union)), sizeof(union Test3Union)); OTAssertEqual(OFSizeOfTypeEncoding(@encode(union Test4Union)), sizeof(union Test4Union)); OTAssertEqual(OFSizeOfTypeEncoding(@encode(struct Test1Struct [5])), sizeof(struct Test1Struct [5])); } - (void)testAlignmentOfTypeEncoding { OTAssertEqual(OFAlignmentOfTypeEncoding(@encode(struct Test1Struct)), OF_ALIGNOF(struct Test1Struct)); OTAssertEqual(OFAlignmentOfTypeEncoding(@encode(struct Test2Struct)), OF_ALIGNOF(struct Test2Struct)); #if !defined(__STDC_NO_COMPLEX__) && defined(HAVE_COMPLEX_H) && \ OF_GCC_VERSION >= 402 OTAssertEqual(OFAlignmentOfTypeEncoding(@encode(struct Test3Struct)), OF_ALIGNOF(struct Test3Struct)); #endif OTAssertEqual(OFAlignmentOfTypeEncoding(@encode(union Test3Union)), OF_ALIGNOF(union Test3Union)); OTAssertEqual(OFAlignmentOfTypeEncoding(@encode(union Test4Union)), OF_ALIGNOF(union Test4Union)); OTAssertEqual( OFAlignmentOfTypeEncoding(@encode(struct Test1Struct [5])), OF_ALIGNOF(struct Test1Struct [5])); } @end |
Added tests/OFMutableArrayTests.h version [bddb111022].
> > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFArrayTests.h" @interface OFMutableArrayTests: OFArrayTests { OFMutableArray *_mutableArray; } @end |
Added tests/OFMutableArrayTests.m version [96c3237cac].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFMutableArrayTests.h" #import "OFArray+Private.h" @interface CustomMutableArray: OFMutableArray { OFMutableArray *_array; } @end static OFString *const cArray[] = { @"Foo", @"Bar", @"Baz" }; @implementation OFMutableArrayTests - (Class)arrayClass { return [CustomMutableArray class]; } - (void)setUp { [super setUp]; _mutableArray = [[self.arrayClass alloc] initWithObjects: cArray count: sizeof(cArray) / sizeof(*cArray)]; } - (void)dealloc { [_mutableArray release]; [super dealloc]; } - (void)testAddObject { [_mutableArray addObject: cArray[0]]; [_mutableArray addObject: cArray[2]]; OTAssertEqualObjects(_mutableArray, ([OFArray arrayWithObjects: @"Foo", @"Bar", @"Baz", @"Foo", @"Baz", nil])); } - (void)testInsertObjectAtIndex { [_mutableArray insertObject: cArray[1] atIndex: 1]; OTAssertEqualObjects(_mutableArray, ([OFArray arrayWithObjects: @"Foo", @"Bar", @"Bar", @"Baz", nil])); } - (void)testReplaceObjectWithObject { [_mutableArray insertObject: cArray[1] atIndex: 1]; [_mutableArray replaceObject: cArray[1] withObject: cArray[0]]; OTAssertEqualObjects(_mutableArray, ([OFArray arrayWithObjects: @"Foo", @"Foo", @"Foo", @"Baz", nil])); } - (void)testReplaceObjectIdenticalToWithObject { [_mutableArray insertObject: [[cArray[1] mutableCopy] autorelease] atIndex: 1]; [_mutableArray insertObject: [[cArray[1] mutableCopy] autorelease] atIndex: 4]; [_mutableArray replaceObjectIdenticalTo: cArray[1] withObject: cArray[0]]; OTAssertEqualObjects(_mutableArray, ([OFArray arrayWithObjects: @"Foo", @"Bar", @"Foo", @"Baz", @"Bar", nil])); } - (void)testReplaceObjectAtIndexWithObject { [_mutableArray replaceObjectAtIndex: 1 withObject: cArray[0]]; OTAssertEqualObjects(_mutableArray, ([OFArray arrayWithObjects: @"Foo", @"Foo", @"Baz", nil])); } - (void)testRemoveObject { [_mutableArray removeObject: cArray[1]]; OTAssertEqualObjects(_mutableArray, ([OFArray arrayWithObjects: @"Foo", @"Baz", nil])); } - (void)testRemoveObjectIdenticalTo { [_mutableArray removeObjectIdenticalTo: cArray[1]]; OTAssertEqualObjects(_mutableArray, ([OFArray arrayWithObjects: @"Foo", @"Baz", nil])); } - (void)testRemoveObjectAtIndex { [_mutableArray removeObjectAtIndex: 1]; OTAssertEqualObjects(_mutableArray, ([OFArray arrayWithObjects: @"Foo", @"Baz", nil])); } - (void)testRemoveObjectsInRange { [_mutableArray removeObjectsInRange: OFMakeRange(1, 2)]; OTAssertEqualObjects(_mutableArray, [OFArray arrayWithObject: @"Foo"]); } - (void)testRemoveObjectsInRangeFailsWhenOutOfRange { OTAssertThrowsSpecific([_mutableArray removeObjectsInRange: OFMakeRange(0, _mutableArray.count + 1)], OFOutOfRangeException); } - (void)testReverse { [_mutableArray reverse]; OTAssertEqualObjects(_mutableArray, ([OFArray arrayWithObjects: @"Baz", @"Bar", @"Foo", nil])); } #ifdef OF_HAVE_BLOCKS - (void)testReplaceObjectsUsingBlock { [_mutableArray replaceObjectsUsingBlock: ^ id (id object, size_t idx) { return [object lowercaseString]; }]; OTAssertEqualObjects(_mutableArray, ([OFArray arrayWithObjects: @"foo", @"bar", @"baz", nil])); } #endif - (void)testSetValueForKey { OFMutableArray *array = [self.arrayClass arrayWithObjects: [OFMutableIRI IRIWithString: @"http://foo.bar/"], [OFMutableIRI IRIWithString: @"http://bar.qux/"], [OFMutableIRI IRIWithString: @"http://qux.quxqux/"], nil]; [array setValue: [OFNumber numberWithShort: 1234] forKey: @"port"]; OTAssertEqualObjects(array, ([OFArray arrayWithObjects: [OFIRI IRIWithString: @"http://foo.bar:1234/"], [OFIRI IRIWithString: @"http://bar.qux:1234/"], [OFIRI IRIWithString: @"http://qux.quxqux:1234/"], nil])); } @end @implementation CustomMutableArray - (instancetype)initWithObjects: (id const *)objects count: (size_t)count { self = [super init]; @try { _array = [[OFMutableArray alloc] initWithObjects: objects count: count]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_array release]; [super dealloc]; } - (id)objectAtIndex: (size_t)idx { return [_array objectAtIndex: idx]; } - (size_t)count { return [_array count]; } - (void)insertObject: (id)object atIndex: (size_t)idx { [_array insertObject: object atIndex: idx]; } - (void)replaceObjectAtIndex: (size_t)idx withObject: (id)object { [_array replaceObjectAtIndex: idx withObject: object]; } - (void)removeObjectAtIndex: (size_t)idx { [_array removeObjectAtIndex: idx]; } @end |
Added tests/OFMutableDataTests.m version [1e767961eb].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "OFDataTests.h" @interface OFMutableDataTests: OFDataTests { OFMutableData *_mutableData; } @end @implementation OFMutableDataTests - (Class)dataClass { return [OFMutableData class]; } - (void)setUp { [super setUp]; _mutableData = [[OFMutableData alloc] initWithItems: "abcdef" count: 6]; } - (void)dealloc { [_mutableData release]; [super dealloc]; } - (void)testMutableCopy { OTAssertEqualObjects([[_data mutableCopy] autorelease], _data); OTAssertNotEqual([[_data mutableCopy] autorelease], _data); } - (void)testAddItem { [_mutableData addItem: "g"]; OTAssertEqualObjects(_mutableData, [OFData dataWithItems: "abcdefg" count: 7]); } - (void)testAddItemsCount { [_mutableData addItems: "gh" count: 2]; OTAssertEqualObjects(_mutableData, [OFData dataWithItems: "abcdefgh" count: 8]); } - (void)testAddItemsCountThrowsOnOutOfRange { OTAssertThrowsSpecific([_mutableData addItems: "" count: SIZE_MAX], OFOutOfRangeException); } - (void)testRemoveLastItem { [_mutableData removeLastItem]; OTAssertEqualObjects(_mutableData, [OFData dataWithItems: "abcde" count: 5]); } - (void)testRemoveItemsInRange { [_mutableData removeItemsInRange: OFMakeRange(1, 2)]; OTAssertEqualObjects(_mutableData, [OFData dataWithItems: "adef" count: 4]); } - (void)testRemoveItemsInRangeThrowsOnOutOfRangeRange { OTAssertThrowsSpecific( [_mutableData removeItemsInRange: OFMakeRange(6, 1)], OFOutOfRangeException); OTAssertThrowsSpecific( [_mutableData removeItemsInRange: OFMakeRange(7, 0)], OFOutOfRangeException); } - (void)testInsertItemsAtIndexCount { [_mutableData insertItems: "BC" atIndex: 1 count: 2]; OTAssertEqualObjects(_mutableData, [OFData dataWithItems: "aBCbcdef" count: 8]); } - (void)testInsertItemsAtIndexCountThrowsOnOutOfRangeIndex { OTAssertThrowsSpecific( [_mutableData insertItems: "a" atIndex: 7 count: 1], OFOutOfRangeException); } @end |
Added tests/OFMutableDictionaryTests.h version [ea95667079].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "ObjFW.h" #import "ObjFWTest.h" #import "OFDictionaryTests.h" @interface OFMutableDictionaryTests: OFDictionaryTests { OFMutableDictionary *_mutableDictionary; } @end |
Added tests/OFMutableDictionaryTests.m version [942d3a4177].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFMutableDictionaryTests.h" @interface CustomMutableDictionary: OFMutableDictionary { OFMutableDictionary *_dictionary; } @end @implementation OFMutableDictionaryTests - (Class)dictionaryClass { return [CustomMutableDictionary class]; } - (void)setUp { [super setUp]; _mutableDictionary = [[self.dictionaryClass alloc] init]; } - (void)dealloc { [_mutableDictionary release]; [super dealloc]; } - (void)testSetObjectForKey { [_mutableDictionary setObject: @"bar" forKey: @"foo"]; OTAssertEqualObjects([_mutableDictionary objectForKey: @"foo"], @"bar"); [_mutableDictionary setObject: @"qux" forKey: @"baz"]; OTAssertEqualObjects(_mutableDictionary, ([OFDictionary dictionaryWithKeysAndObjects: @"foo", @"bar", @"baz", @"qux", nil])); } - (void)testSetValueForKey { [_mutableDictionary setValue: @"bar" forKey: @"foo"]; OTAssertEqualObjects([_mutableDictionary objectForKey: @"foo"], @"bar"); [_mutableDictionary setValue: @"qux" forKey: @"baz"]; OTAssertEqualObjects(_mutableDictionary, ([OFDictionary dictionaryWithKeysAndObjects: @"foo", @"bar", @"baz", @"qux", nil])); } - (void)testRemoveObjectForKey { [_mutableDictionary addEntriesFromDictionary: _dictionary]; OTAssertEqual(_mutableDictionary.count, 2); [_mutableDictionary removeObjectForKey: @"key2"]; OTAssertEqual(_mutableDictionary.count, 1); OTAssertEqualObjects(_mutableDictionary, [OFDictionary dictionaryWithObject: @"value1" forKey: @"key1"]); } - (void)testMutableCopy { OFMutableDictionary *copy = [[_dictionary mutableCopy] autorelease]; OTAssertEqualObjects(copy, _dictionary); OTAssertNotEqual(copy, _dictionary); } #ifdef OF_HAVE_BLOCKS - (void)testReplaceObjectsUsingBlock { OFMutableDictionary *mutableDictionary = [[_dictionary mutableCopy] autorelease]; [mutableDictionary replaceObjectsUsingBlock: ^ id (id key, id object) { if ([key isEqual: @"key1"]) return @"value_1"; if ([key isEqual: @"key2"]) return @"value_2"; return nil; }]; OTAssertEqualObjects(mutableDictionary, ([OFDictionary dictionaryWithKeysAndObjects: @"key1", @"value_1", @"key2", @"value_2", nil])); } #endif @end @implementation CustomMutableDictionary - (instancetype)init { self = [super init]; @try { _dictionary = [[OFMutableDictionary alloc] init]; } @catch (id e) { [self release]; @throw e; } return self; } - (instancetype)initWithObjects: (const id *)objects_ forKeys: (const id *)keys_ count: (size_t)count { self = [super init]; @try { _dictionary = [[OFMutableDictionary alloc] initWithObjects: objects_ forKeys: keys_ count: count]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_dictionary release]; [super dealloc]; } - (id)objectForKey: (id)key { return [_dictionary objectForKey: key]; } - (size_t)count { return _dictionary.count; } - (OFEnumerator *)keyEnumerator { return [_dictionary keyEnumerator]; } - (void)setObject: (id)object forKey: (id)key { [_dictionary setObject: object forKey: key]; } - (void)removeObjectForKey: (id)key { [_dictionary removeObjectForKey: key]; } @end |
Added tests/OFMutableSetTests.h version [23546dab7b].
> > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFSetTests.h" @interface OFMutableSetTests: OFSetTests { OFMutableSet *_mutableSet; } @end |
Added tests/OFMutableSetTests.m version [ac80ae6cc2].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFMutableSetTests.h" @interface CustomMutableSet: OFMutableSet { OFMutableSet *_set; } @end @implementation OFMutableSetTests - (Class)setClass { return [CustomMutableSet class]; } - (void)setUp { [super setUp]; _mutableSet = [[OFMutableSet alloc] initWithObjects: @"foo", @"bar", @"baz", nil]; } - (void)dealloc { [_mutableSet release]; [super dealloc]; } - (void)testAddObject { [_mutableSet addObject: @"x"]; OTAssertEqualObjects(_mutableSet, ([OFSet setWithObjects: @"foo", @"bar", @"baz", @"x", nil])); } - (void)testRemoveObject { [_mutableSet removeObject: @"foo"]; OTAssertEqualObjects(_mutableSet, ([OFSet setWithObjects: @"bar", @"baz", nil])); } - (void)testMinusSet { [_mutableSet minusSet: [OFSet setWithObjects: @"foo", @"bar", nil]]; OTAssertEqualObjects(_mutableSet, ([OFSet setWithObjects: @"baz", nil])); } - (void)testIntersectSet { [_mutableSet intersectSet: [OFSet setWithObjects: @"foo", @"qux", nil]]; OTAssertEqualObjects(_mutableSet, ([OFSet setWithObjects: @"foo", nil])); } - (void)testUnionSet { [_mutableSet unionSet: [OFSet setWithObjects: @"x", @"y", nil]]; OTAssertEqualObjects(_mutableSet, ([OFSet setWithObjects: @"foo", @"bar", @"baz", @"x", @"y", nil])); } - (void)testRemoveAllObjects { [_mutableSet removeAllObjects]; OTAssertEqual(_mutableSet.count, 0); } @end @implementation CustomMutableSet - (instancetype)initWithObjects: (id const *)objects count: (size_t)count { self = [super init]; @try { _set = [[OFMutableSet alloc] initWithObjects: objects count: count]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_set release]; [super dealloc]; } - (size_t)count { return _set.count; } - (bool)containsObject: (id)object { return [_set containsObject: object]; } - (OFEnumerator *)objectEnumerator { return [_set objectEnumerator]; } - (void)addObject: (id)object { [_set addObject: object]; } - (void)removeObject: (id)object { [_set removeObject: object]; } @end |
Added tests/OFMutableStringTests.h version [d842a0f1e6].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "ObjFW.h" #import "ObjFWTest.h" #import "OFStringTests.h" @interface OFMutableStringTests: OFStringTests { OFMutableString *_mutableString; } @end |
Added tests/OFMutableStringTests.m version [1ae37675f3].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "OFMutableStringTests.h" @interface CustomMutableString: OFMutableString { OFMutableString *_string; } @end static OFString *const whitespace[] = { @" \r \t\n\t \tasd \t \t\t\r\n", @" \t\t \t\t \t \t" }; @implementation OFMutableStringTests - (Class)stringClass { return [CustomMutableString class]; } - (void)setUp { [super setUp]; _mutableString = [[self.stringClass alloc] initWithString: @"täṠ€🤔"]; } - (void)dealloc { [_mutableString release]; [super dealloc]; } - (void)testAppendString { [_mutableString appendString: @"ö"]; OTAssertEqualObjects(_mutableString, @"täṠ€🤔ö"); } - (void)testAppendUTF8String { [_mutableString appendUTF8String: "ö"]; OTAssertEqualObjects(_mutableString, @"täṠ€🤔ö"); } - (void)testAppendUTF8StringLength { [_mutableString appendUTF8String: "\xEF\xBB\xBF" "öÖ" length: 7]; OTAssertEqualObjects(_mutableString, @"täṠ€🤔öÖ"); } - (void)testAppendFormat { [_mutableString appendFormat: @"%02X", 15]; OTAssertEqualObjects(_mutableString, @"täṠ€🤔0F"); } - (void)testAppendCharactersLength { [_mutableString appendCharacters: (OFUnichar []){ 0xF6, 0xD6 } length: 2]; OTAssertEqualObjects(_mutableString, @"täṠ€🤔öÖ"); } - (void)testUppercase { [_mutableString uppercase]; #ifdef OF_HAVE_UNICODE_TABLES OTAssertEqualObjects(_mutableString, @"TÄṠ€🤔"); #else OTAssertEqualObjects(_mutableString, @"TäṠ€🤔"); #endif } - (void)testLowercase { [_mutableString lowercase]; #ifdef OF_HAVE_UNICODE_TABLES OTAssertEqualObjects(_mutableString, @"täṡ€🤔"); #else OTAssertEqualObjects(_mutableString, @"täṠ€🤔"); #endif } - (void)testCapitalize { OFMutableString *string = [self.stringClass stringWithString: @"täṠ€🤔täṠ€🤔 täṠ€🤔"]; [string capitalize]; #ifdef OF_HAVE_UNICODE_TABLES OTAssertEqualObjects(string, @"Täṡ€🤔täṡ€🤔 Täṡ€🤔"); #else OTAssertEqualObjects(string, @"TäṠ€🤔täṠ€🤔 TäṠ€🤔"); #endif } - (void)testInsertStringAtIndex { [_mutableString insertString: @"fööbär" atIndex: 2]; OTAssertEqualObjects(_mutableString, @"täfööbärṠ€🤔"); } - (void)testSetCharacterAtIndex { [_mutableString setCharacter: 0x1F600 atIndex: 2]; OTAssertEqualObjects(_mutableString, @"tä😀€🤔"); } - (void)testDeleteCharactersInRange { [_mutableString deleteCharactersInRange: OFMakeRange(2, 2)]; OTAssertEqualObjects(_mutableString, @"tä🤔"); } - (void)testDeleteCharactersInRangeThrowsWithOutOfRangeRange { OTAssertThrowsSpecific( [_mutableString deleteCharactersInRange: OFMakeRange(4, 2)], OFOutOfRangeException); OTAssertThrowsSpecific( [_mutableString deleteCharactersInRange: OFMakeRange(5, 1)], OFOutOfRangeException); OTAssertThrowsSpecific( [_mutableString deleteCharactersInRange: OFMakeRange(6, 0)], OFOutOfRangeException); } - (void)testReplaceCharactersInRangeWithString { OFMutableString *string = [self.stringClass stringWithString: @"𝄞öööbä€"]; [string replaceCharactersInRange: OFMakeRange(1, 3) withString: @"äöüß"]; OTAssertEqualObjects(string, @"𝄞äöüßbä€"); [string replaceCharactersInRange: OFMakeRange(4, 2) withString: @"b"]; OTAssertEqualObjects(string, @"𝄞äöübä€"); [string replaceCharactersInRange: OFMakeRange(0, 7) withString: @""]; OTAssertEqualObjects(string, @""); } - (void)testReplaceCharactersInRangeWithStringFailsWithOutOfRangeRange { OTAssertThrowsSpecific( [_mutableString replaceCharactersInRange: OFMakeRange(4, 2) withString: @"abc"], OFOutOfRangeException); OTAssertThrowsSpecific( [_mutableString replaceCharactersInRange: OFMakeRange(5, 1) withString: @"abc"], OFOutOfRangeException); OTAssertThrowsSpecific( [_mutableString replaceCharactersInRange: OFMakeRange(6, 0) withString: @""], OFOutOfRangeException); } - (void)testReplaceOccurrencesOfStringWithString { OFMutableString *string; string = [self.stringClass stringWithString: @"asd fo asd fofo asd"]; [string replaceOccurrencesOfString: @"fo" withString: @"foo"]; OTAssertEqualObjects(string, @"asd foo asd foofoo asd"); string = [self.stringClass stringWithString: @"XX"]; [string replaceOccurrencesOfString: @"X" withString: @"XX"]; OTAssertEqualObjects(string, @"XXXX"); } - (void)testReplaceOccurrencesOfStringWithStringOptionsRange { OFMutableString *string = [self.stringClass stringWithString: @"foofoobarfoobarfoo"]; [string replaceOccurrencesOfString: @"oo" withString: @"óò" options: 0 range: OFMakeRange(2, 15)]; OTAssertEqualObjects(string, @"foofóòbarfóòbarfoo"); } - (void) testReplaceOccurrencesOfStringWithStringOptionsRangeThrowsWithOutOfRangeRange { OTAssertThrowsSpecific( [_mutableString replaceOccurrencesOfString: @"t" withString: @"abc" options: 0 range: OFMakeRange(4, 2)], OFOutOfRangeException); OTAssertThrowsSpecific( [_mutableString replaceOccurrencesOfString: @"t" withString: @"abc" options: 0 range: OFMakeRange(5, 1)], OFOutOfRangeException); OTAssertThrowsSpecific( [_mutableString replaceOccurrencesOfString: @"t" withString: @"" options: 0 range: OFMakeRange(6, 0)], OFOutOfRangeException); } - (void)deleteLeadingWhitespaces { OFMutableString *string; string = [self.stringClass stringWithString: whitespace[0]]; [string deleteLeadingWhitespaces]; OTAssertEqualObjects(string, @"asd \t \t\t\r\n"); string = [self.stringClass stringWithString: whitespace[1]]; [string deleteLeadingWhitespaces]; OTAssertEqualObjects(string, @""); } - (void)deleteTrailingWhitespaces { OFMutableString *string; string = [self.stringClass stringWithString: whitespace[0]]; [string deleteTrailingWhitespaces]; OTAssertEqualObjects(string, @" \r \t\n\t \tasd"); string = [self.stringClass stringWithString: whitespace[1]]; [string deleteTrailingWhitespaces]; OTAssertEqualObjects(string, @""); } - (void)deleteEnclosingWhitespaces { OFMutableString *string; string = [self.stringClass stringWithString: whitespace[0]]; [string deleteEnclosingWhitespaces]; OTAssertEqualObjects(string, @"asd"); string = [self.stringClass stringWithString: whitespace[1]]; [string deleteEnclosingWhitespaces]; OTAssertEqualObjects(string, @""); } @end @implementation CustomMutableString - (instancetype)init { self = [super init]; @try { _string = [[OFMutableString alloc] init]; } @catch (id e) { [self release]; @throw e; } return self; } - (instancetype)initWithString: (OFString *)string { self = [super init]; @try { _string = [string mutableCopy]; } @catch (id e) { [self release]; @throw e; } return self; } - (instancetype)initWithCString: (const char *)cString encoding: (OFStringEncoding)encoding length: (size_t)length { self = [super init]; @try { _string = [[OFMutableString alloc] initWithCString: cString encoding: encoding length: length]; } @catch (id e) { [self release]; @throw e; } return self; } - (instancetype)initWithUTF16String: (const OFChar16 *)UTF16String length: (size_t)length byteOrder: (OFByteOrder)byteOrder { self = [super init]; @try { _string = [[OFMutableString alloc] initWithUTF16String: UTF16String length: length byteOrder: byteOrder]; } @catch (id e) { [self release]; @throw e; } return self; } - (instancetype)initWithUTF32String: (const OFChar32 *)UTF32String length: (size_t)length byteOrder: (OFByteOrder)byteOrder { self = [super init]; @try { _string = [[OFMutableString alloc] initWithUTF32String: UTF32String length: length byteOrder: byteOrder]; } @catch (id e) { [self release]; @throw e; } return self; } - (instancetype)initWithFormat: (OFConstantString *)format arguments: (va_list)arguments { self = [super init]; @try { _string = [[OFMutableString alloc] initWithFormat: format arguments: arguments]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_string release]; [super dealloc]; } - (OFUnichar)characterAtIndex: (size_t)idx { return [_string characterAtIndex: idx]; } - (size_t)length { return _string.length; } - (void)replaceCharactersInRange: (OFRange)range withString: (OFString *)string { [_string replaceCharactersInRange: range withString: string]; } @end |
Added tests/OFMutableUTF8StringTests.m version [06129d231a].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFMutableStringTests.h" #import "OFMutableUTF8String.h" @interface OFMutableUTF8StringTests: OFMutableStringTests @end @implementation OFMutableUTF8StringTests - (Class)arrayClass { return [OFMutableUTF8String class]; } @end |
Modified tests/OFNotificationCenterTests.m from [4d3ddfb6ba] to [1b32e4dd91].
1 | /* | | | | | | > > > > | < > | | > < | > > > | | | < | < | < | < | < | < | | | | | | | | | | | | | | | | | | | | < | | > | > < | | > | > < | | > | > | < | | | | > > | > | > | > < | | | | | | | | | | | | | | | | < | | > | | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFW.h" #import "ObjFWTest.h" static const OFNotificationName notificationName = @"OFNotificationCenterTestName"; static const OFNotificationName otherNotificationName = @"OFNotificationCenterTestOtherName"; @interface OFNotificationCenterTests: OTTestCase @end @interface OFNotificationCenterTestClass: OFObject { @public id _expectedObject; int _received; } - (void)handleNotification: (OFNotification *)notification; @end @implementation OFNotificationCenterTestClass - (void)handleNotification: (OFNotification *)notification { OFEnsure([notification.name isEqual: notificationName]); OFEnsure(_expectedObject == nil || notification.object == _expectedObject); _received++; } @end @implementation OFNotificationCenterTests - (void)testNotificationCenter { OFNotificationCenter *center = [OFNotificationCenter defaultCenter]; OFNotificationCenterTestClass *test1, *test2, *test3, *test4; OFNotification *notification; test1 = [[[OFNotificationCenterTestClass alloc] init] autorelease]; test1->_expectedObject = self; test2 = [[[OFNotificationCenterTestClass alloc] init] autorelease]; test3 = [[[OFNotificationCenterTestClass alloc] init] autorelease]; test3->_expectedObject = self; test4 = [[[OFNotificationCenterTestClass alloc] init] autorelease]; /* First one intentionally added twice to test deduplication. */ [center addObserver: test1 selector: @selector(handleNotification:) name: notificationName object: self]; [center addObserver: test1 selector: @selector(handleNotification:) name: notificationName object: self]; [center addObserver: test2 selector: @selector(handleNotification:) name: notificationName object: nil]; [center addObserver: test3 selector: @selector(handleNotification:) name: otherNotificationName object: self]; [center addObserver: test4 selector: @selector(handleNotification:) name: otherNotificationName object: nil]; notification = [OFNotification notificationWithName: notificationName object: nil]; [center postNotification: notification]; OTAssertEqual(test1->_received, 0); OTAssertEqual(test2->_received, 1); OTAssertEqual(test3->_received, 0); OTAssertEqual(test4->_received, 0); notification = [OFNotification notificationWithName: notificationName object: self]; [center postNotification: notification]; OTAssertEqual(test1->_received, 1); OTAssertEqual(test2->_received, 2); OTAssertEqual(test3->_received, 0); OTAssertEqual(test4->_received, 0); notification = [OFNotification notificationWithName: notificationName object: @"foo"]; [center postNotification: notification]; OTAssertEqual(test1->_received, 1); OTAssertEqual(test2->_received, 3); OTAssertEqual(test3->_received, 0); OTAssertEqual(test4->_received, 0); #ifdef OF_HAVE_BLOCKS __block bool received = false; id handle; notification = [OFNotification notificationWithName: notificationName object: self]; handle = [center addObserverForName: notificationName object: self usingBlock: ^ (OFNotification *notification_) { OTAssertEqual(notification_, notification); OTAssertFalse(received); received = true; }]; [center postNotification: notification]; OTAssertTrue(received); OTAssertEqual(test1->_received, 2); OTAssertEqual(test2->_received, 4); OTAssertEqual(test3->_received, 0); OTAssertEqual(test4->_received, 0); /* Act like the block test didn't happen. */ [center removeObserver: handle]; test1->_received--; test2->_received--; #endif [center removeObserver: test1 selector: @selector(handleNotification:) name: notificationName object: self]; [center removeObserver: test2 selector: @selector(handleNotification:) name: notificationName object: nil]; [center removeObserver: test3 selector: @selector(handleNotification:) name: otherNotificationName object: self]; [center removeObserver: test4 selector: @selector(handleNotification:) name: otherNotificationName object: nil]; notification = [OFNotification notificationWithName: notificationName object: self]; [center postNotification: notification]; OTAssertEqual(test1->_received, 1); OTAssertEqual(test2->_received, 3); OTAssertEqual(test3->_received, 0); OTAssertEqual(test4->_received, 0); } @end |
Modified tests/OFNumberTests.m from [c4180587af] to [19e5d55328].
1 | /* | | | | | | > > > > | < > | | > > > | | > > | | > | | | | > > > | > | | > > | | | > | > > > > > > | | > > > | | | > > | | | | | | > > | | | | | | > > | < | < | | > > | | | | | | > > | | | | > > > | < | | | | > > | | | | > > | | | | > > | | | | < | | < > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFW.h" #import "ObjFWTest.h" @interface OFNumberTests: OTTestCase { OFNumber *_number; } @end @implementation OFNumberTests - (void)setUp { [super setUp]; _number = [[OFNumber alloc] initWithLongLong: 123456789]; } - (void)dealloc { [_number release]; [super dealloc]; } - (void)testIsEqual { OTAssertEqualObjects(_number, [OFNumber numberWithLong: 123456789]); } - (void)testHash { OTAssertEqual(_number.hash, [[OFNumber numberWithLong: 123456789] hash]); } - (void)testCharValue { OTAssertEqual(_number.charValue, 21); } - (void)testDoubleValue { OTAssertEqual(_number.doubleValue, 123456789.L); } - (void)testSignedCharMinAndMaxUnmodified { OTAssertEqual([[OFNumber numberWithChar: SCHAR_MIN] charValue], SCHAR_MIN); OTAssertEqual([[OFNumber numberWithChar: SCHAR_MAX] charValue], SCHAR_MAX); } - (void)testShortMinAndMaxUnmodified { OTAssertEqual([[OFNumber numberWithShort: SHRT_MIN] shortValue], SHRT_MIN); OTAssertEqual([[OFNumber numberWithShort: SHRT_MAX] shortValue], SHRT_MAX); } - (void)testIntMinAndMaxUnmodified { OTAssertEqual([[OFNumber numberWithInt: INT_MIN] intValue], INT_MIN); OTAssertEqual([[OFNumber numberWithInt: INT_MAX] intValue], INT_MAX); } - (void)testLongMinAndMaxUnmodified { OTAssertEqual([[OFNumber numberWithLong: LONG_MIN] longValue], LONG_MIN); OTAssertEqual([[OFNumber numberWithLong: LONG_MAX] longValue], LONG_MAX);; } - (void)testLongLongMinAndMaxUnmodified { OTAssertEqual([[OFNumber numberWithLongLong: LLONG_MIN] longLongValue], LLONG_MIN); OTAssertEqual([[OFNumber numberWithLongLong: LLONG_MAX] longLongValue], LLONG_MAX); } - (void)testUnsignedCharMaxUnmodified { OTAssertEqual([[OFNumber numberWithUnsignedChar: UCHAR_MAX] unsignedCharValue], UCHAR_MAX); } - (void)testUnsignedShortMaxUnmodified { OTAssertEqual([[OFNumber numberWithUnsignedShort: USHRT_MAX] unsignedShortValue], USHRT_MAX); } - (void)testUnsignedIntMaxUnmodified { OTAssertEqual([[OFNumber numberWithUnsignedInt: UINT_MAX] unsignedIntValue], UINT_MAX); } - (void)testUnsignedLongMaxUnmodified { OTAssertEqual([[OFNumber numberWithUnsignedLong: ULONG_MAX] unsignedLongValue], ULONG_MAX); } - (void)testUnsignedLongLongMaxUnmodified { OTAssertEqual([[OFNumber numberWithUnsignedLongLong: ULLONG_MAX] unsignedLongLongValue], ULLONG_MAX); } @end |
Modified tests/OFObjectTests.m from [fcfeee4a72] to [543753ed41].
1 | /* | | | | | | > > > > | < > | | | < < < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFW.h" #import "ObjFWTest.h" @interface MyObject: OFObject { id _objectValue; Class _classValue; bool _boolValue; char _charValue; |
︙ | ︙ | |||
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | @property (nonatomic) unsigned short unsignedShortValue; @property (nonatomic) unsigned int unsignedIntValue; @property (nonatomic) unsigned long unsignedLongValue; @property (nonatomic) unsigned long long unsignedLongLongValue; @property (nonatomic) float floatValue; @property (nonatomic) double doubleValue; @end @implementation MyObject @synthesize objectValue = _objectValue, classValue = _classValue; @synthesize boolValue = _boolValue, charValue = _charValue; @synthesize shortValue = _shortValue, intValue = _intValue; @synthesize longValue = _longValue, longLongValue = _longLongValue; @synthesize unsignedCharValue = _unsignedCharValue; @synthesize unsignedShortValue = _unsignedShortValue; @synthesize unsignedIntValue = _unsignedIntValue; @synthesize unsignedLongValue = _unsignedLongValue; @synthesize unsignedLongLongValue = _unsignedLongLongValue; @synthesize floatValue = _floatValue, doubleValue = _doubleValue; - (void)dealloc { [_objectValue release]; [super dealloc]; } @end | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | @property (nonatomic) unsigned short unsignedShortValue; @property (nonatomic) unsigned int unsignedIntValue; @property (nonatomic) unsigned long unsignedLongValue; @property (nonatomic) unsigned long long unsignedLongLongValue; @property (nonatomic) float floatValue; @property (nonatomic) double doubleValue; @end @interface OFObjectTests: OTTestCase { MyObject *_myObject; } @end @implementation OFObjectTests - (void)setUp { [super setUp]; _myObject = [[MyObject alloc] init]; } - (void)dealloc { [_myObject release]; [super dealloc]; } - (void)testClassDescription { OTAssertEqualObjects([OFObject description], @"OFObject"); OTAssertEqualObjects([MyObject description], @"MyObject"); } - (void)testInstanceDescription { OFObject *object = [[[OFObject alloc] init] autorelease]; OTAssertEqualObjects(object.description, @"<OFObject>"); OTAssertEqualObjects(_myObject.description, @"<MyObject>"); } - (void)testValueForKey { _myObject.objectValue = @"Hello"; _myObject.classValue = _myObject.class; OTAssertEqualObjects([_myObject valueForKey: @"objectValue"], @"Hello"); OTAssertEqualObjects([_myObject valueForKey: @"classValue"], _myObject.class); OTAssertEqualObjects([_myObject valueForKey: @"class"], _myObject.class); } - (void)testValueForKeyWithUndefinedKeyThrows { OTAssertThrowsSpecific([_myObject valueForKey: @"undefined"], OFUndefinedKeyException); } - (void)testSetValueForKey { [_myObject setValue: @"World" forKey: @"objectValue"]; [_myObject setValue: [OFObject class] forKey: @"classValue"]; OTAssertEqualObjects(_myObject.objectValue, @"World"); OTAssertEqualObjects(_myObject.classValue, [OFObject class]); } - (void)testSetValueWithUndefinedKeyThrows { OTAssertThrowsSpecific([_myObject setValue: @"x" forKey: @"undefined"], OFUndefinedKeyException); } - (void)testAutoWrappingOfValueForKey { _myObject.boolValue = 1; _myObject.charValue = 2; _myObject.shortValue = 3; _myObject.intValue = 4; _myObject.longValue = 5; _myObject.longLongValue = 6; _myObject.unsignedCharValue = 7; _myObject.unsignedShortValue = 8; _myObject.unsignedIntValue = 9; _myObject.unsignedLongValue = 10; _myObject.unsignedLongLongValue = 11; _myObject.floatValue = 12; _myObject.doubleValue = 13; OTAssertEqualObjects([_myObject valueForKey: @"boolValue"], [OFNumber numberWithBool: 1]); OTAssertEqualObjects([_myObject valueForKey: @"charValue"], [OFNumber numberWithChar: 2]); OTAssertEqualObjects([_myObject valueForKey: @"shortValue"], [OFNumber numberWithShort: 3]); OTAssertEqualObjects([_myObject valueForKey: @"intValue"], [OFNumber numberWithInt: 4]); OTAssertEqualObjects([_myObject valueForKey: @"longValue"], [OFNumber numberWithLong: 5]); OTAssertEqualObjects([_myObject valueForKey: @"longLongValue"], [OFNumber numberWithLongLong: 6]); OTAssertEqualObjects([_myObject valueForKey: @"unsignedCharValue"], [OFNumber numberWithUnsignedChar: 7]); OTAssertEqualObjects([_myObject valueForKey: @"unsignedShortValue"], [OFNumber numberWithUnsignedShort: 8]); OTAssertEqualObjects([_myObject valueForKey: @"unsignedIntValue"], [OFNumber numberWithUnsignedInt: 9]); OTAssertEqualObjects([_myObject valueForKey: @"unsignedLongValue"], [OFNumber numberWithUnsignedLong: 10]); OTAssertEqualObjects([_myObject valueForKey: @"unsignedLongLongValue"], [OFNumber numberWithUnsignedLongLong: 11]); OTAssertEqualObjects([_myObject valueForKey: @"floatValue"], [OFNumber numberWithFloat: 12]); OTAssertEqualObjects([_myObject valueForKey: @"doubleValue"], [OFNumber numberWithDouble: 13]); } - (void)testAutoWrappingOfSetValueForKey { [_myObject setValue: [OFNumber numberWithBool: 0] forKey: @"boolValue"]; [_myObject setValue: [OFNumber numberWithChar: 10] forKey: @"charValue"]; [_myObject setValue: [OFNumber numberWithShort: 20] forKey: @"shortValue"]; [_myObject setValue: [OFNumber numberWithInt: 30] forKey: @"intValue"]; [_myObject setValue: [OFNumber numberWithLong: 40] forKey: @"longValue"]; [_myObject setValue: [OFNumber numberWithLongLong: 50] forKey: @"longLongValue"]; [_myObject setValue: [OFNumber numberWithUnsignedChar: 60] forKey: @"unsignedCharValue"]; [_myObject setValue: [OFNumber numberWithUnsignedShort: 70] forKey: @"unsignedShortValue"]; [_myObject setValue: [OFNumber numberWithUnsignedInt: 80] forKey: @"unsignedIntValue"]; [_myObject setValue: [OFNumber numberWithUnsignedLong: 90] forKey: @"unsignedLongValue"]; [_myObject setValue: [OFNumber numberWithUnsignedLongLong: 100] forKey: @"unsignedLongLongValue"]; [_myObject setValue: [OFNumber numberWithFloat: 110] forKey: @"floatValue"]; [_myObject setValue: [OFNumber numberWithDouble: 120] forKey: @"doubleValue"]; OTAssertEqual(_myObject.isBoolValue, 0); OTAssertEqual(_myObject.charValue, 10); OTAssertEqual(_myObject.shortValue, 20); OTAssertEqual(_myObject.intValue, 30); OTAssertEqual(_myObject.longValue, 40); OTAssertEqual(_myObject.longLongValue, 50); OTAssertEqual(_myObject.unsignedCharValue, 60); OTAssertEqual(_myObject.unsignedShortValue, 70); OTAssertEqual(_myObject.unsignedIntValue, 80); OTAssertEqual(_myObject.unsignedLongValue, 90); OTAssertEqual(_myObject.unsignedLongLongValue, 100); OTAssertEqual(_myObject.floatValue, 110); OTAssertEqual(_myObject.doubleValue, 120); } - (void)testSetValueForKeyWithNilThrows { OTAssertThrowsSpecific( [_myObject setValue: (id _Nonnull)nil forKey: @"intValue"], OFInvalidArgumentException); } - (void)testValueForKeyPath { _myObject.objectValue = [[[MyObject alloc] init] autorelease]; [_myObject.objectValue setObjectValue: [[[MyObject alloc] init] autorelease]]; [[_myObject.objectValue objectValue] setDoubleValue: 0.5]; OTAssertEqual([[_myObject valueForKeyPath: @"objectValue.objectValue.doubleValue"] doubleValue], 0.5); } - (void)testSetValueForKeyPath { _myObject.objectValue = [[[MyObject alloc] init] autorelease]; [_myObject.objectValue setObjectValue: [[[MyObject alloc] init] autorelease]]; [_myObject setValue: [OFNumber numberWithDouble: 0.75] forKeyPath: @"objectValue.objectValue.doubleValue"]; OTAssertEqual([[_myObject.objectValue objectValue] doubleValue], 0.75); } @end @implementation MyObject @synthesize objectValue = _objectValue, classValue = _classValue; @synthesize boolValue = _boolValue, charValue = _charValue; @synthesize shortValue = _shortValue, intValue = _intValue; @synthesize longValue = _longValue, longLongValue = _longLongValue; @synthesize unsignedCharValue = _unsignedCharValue; @synthesize unsignedShortValue = _unsignedShortValue; @synthesize unsignedIntValue = _unsignedIntValue; @synthesize unsignedLongValue = _unsignedLongValue; @synthesize unsignedLongLongValue = _unsignedLongLongValue; @synthesize floatValue = _floatValue, doubleValue = _doubleValue; - (void)dealloc { [_objectValue release]; [super dealloc]; } @end |
Modified tests/OFPBKDF2Tests.m from [9316c48e09] to [faa30a6c5a].
1 | /* | | | | | | > > > > | < > | | > | | > > > > | | > | | | > | > | > > > > > | > > > | | | > > | | | | > > > > | | > > | | | | > > > > | | > > | | | | > > > > | | | > > | | > > > > | | | | | > | | | | > > > > | | > > | | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "ObjFW.h" #import "ObjFWTest.h" @interface OFPBKDF2Tests: OTTestCase { OFHMAC *_HMAC; } @end @implementation OFPBKDF2Tests - (void)setUp { [super setUp]; _HMAC = [[OFHMAC alloc] initWithHashClass: [OFSHA1Hash class] allowsSwappableMemory: true]; } - (void)dealloc { [_HMAC release]; [super dealloc]; } /* Test vectors from RFC 6070 */ - (void)testRFC6070TestVector1 { unsigned char key[20]; OFPBKDF2((OFPBKDF2Parameters){ .HMAC = _HMAC, .iterations = 1, .salt = (unsigned char *)"salt", .saltLength = 4, .password = "password", .passwordLength = 8, .key = key, .keyLength = 20, .allowsSwappableMemory = true }); OTAssertEqual(memcmp(key, "\x0C\x60\xC8\x0F\x96\x1F\x0E\x71\xF3\xA9\xB5" "\x24\xAF\x60\x12\x06\x2F\xE0\x37\xA6", 20), 0); } - (void)testRFC6070TestVector2 { unsigned char key[20]; OFPBKDF2((OFPBKDF2Parameters){ .HMAC = _HMAC, .iterations = 2, .salt = (unsigned char *)"salt", .saltLength = 4, .password = "password", .passwordLength = 8, .key = key, .keyLength = 20, .allowsSwappableMemory = true }); OTAssertEqual(memcmp(key, "\xEA\x6C\x01\x4D\xC7\x2D\x6F\x8C\xCD\x1E\xD9" "\x2A\xCE\x1D\x41\xF0\xD8\xDE\x89\x57", 20), 0); } - (void)testRFC6070TestVector3 { unsigned char key[20]; OFPBKDF2((OFPBKDF2Parameters){ .HMAC = _HMAC, .iterations = 4096, .salt = (unsigned char *)"salt", .saltLength = 4, .password = "password", .passwordLength = 8, .key = key, .keyLength = 20, .allowsSwappableMemory = true }); OTAssertEqual(memcmp(key, "\x4B\x00\x79\x01\xB7\x65\x48\x9A\xBE\xAD\x49" "\xD9\x26\xF7\x21\xD0\x65\xA4\x29\xC1", 20), 0); } #if 0 /* This test takes too long, even on a fast machine. */ - (void)testRFC6070TestVector4 { unsigned char key[20]; OFPBKDF2((OFPBKDF2Parameters){ .HMAC = _HMAC, .iterations = 16777216, .salt = (unsigned char *)"salt", .saltLength = 4, .password = "password", .passwordLength = 8, .key = key, .keyLength = 20, .allowsSwappableMemory = true }); OTAssertEqual(memcmp(key, "\xEE\xFE\x3D\x61\xCD\x4D\xA4\xE4\xE9\x94\x5B" "\x3D\x6B\xA2\x15\x8C\x26\x34\xE9\x84", 20), 0); } #endif - (void)testRFC6070TestVector5 { unsigned char key[25]; OFPBKDF2((OFPBKDF2Parameters){ .HMAC = _HMAC, .iterations = 4096, .salt = (unsigned char *)"saltSALTsaltSALTsalt" "SALTsaltSALTsalt", .saltLength = 36, .password = "passwordPASSWORDpassword", .passwordLength = 24, .key = key, .keyLength = 25, .allowsSwappableMemory = true }); OTAssertEqual(memcmp(key, "\x3D\x2E\xEC\x4F\xE4\x1C\x84\x9B\x80\xC8\xD8" "\x36\x62\xC0\xE4\x4A\x8B\x29\x1A\x96\x4C\xF2\xF0\x70\x38", 25), 0); } - (void)testRFC6070TestVector6 { unsigned char key[16]; OFPBKDF2((OFPBKDF2Parameters){ .HMAC = _HMAC, .iterations = 4096, .salt = (unsigned char *)"sa\0lt", .saltLength = 5, .password = "pass\0word", .passwordLength = 9, .key = key, .keyLength = 16, .allowsSwappableMemory = true }); OTAssertEqual(memcmp(key, "\x56\xFA\x6A\xA7\x55\x48\x09\x9D\xCC\x37\xD7" "\xF0\x34\x25\xE0\xC3", 16), 0); } @end |
Modified tests/OFPluginTests.m from [bb55705657] to [39645d7bd7].
1 | /* | | | | | | > > > > | < > | | > < | < < | < < | | < > < > | > > > > | > < | | < > | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFW.h" #import "ObjFWTest.h" #import "plugin/TestPlugin.h" @interface OFPluginTests: OTTestCase @end @implementation OFPluginTests - (void)testPlugin { TestPlugin *test = nil; OFString *path; OFPlugin *plugin; Class (*class)(void); #ifndef OF_IOS path = [OFPlugin pathForName: @"plugin/TestPlugin"]; #else path = [OFPlugin pathForName: @"PlugIns/TestPlugin"]; #endif OTAssertNotNil(path); plugin = [OFPlugin pluginWithPath: path]; OTAssertNotNil(plugin); class = (Class (*)(void))(uintptr_t)[plugin addressForSymbol: @"class"]; OTAssert(class != NULL); @try { test = [[class() alloc] init]; OTAssertEqual([test test: 1234], 2468); } @finally { [test release]; } } @end |
Modified tests/OFPropertyListTests.m from [6b258c8840] to [779103d77a].
1 | /* | | | | | | > > > > | < > | | > > > > | < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < > | | | > > > > > > > > | | | > > > > > > > > > > > > > | < | | | | | > > > | | | > | | < | < | < > | | < < > | | < | | | > > | > < < < > | | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFW.h" #import "ObjFWTest.h" @interface OFPropertyListTests: OTTestCase @end #define PLIST(x) \ @"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" \ @"<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" " \ @"\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">" \ @"<plist version=\"1.0\">\n" \ x @"\n" \ @"</plist>" @implementation OFPropertyListTests - (void)testObjectByParsingPropertyList { OFArray *array = [OFArray arrayWithObjects: @"Hello", [OFData dataWithItems: "World!" count: 6], [OFDate dateWithTimeIntervalSince1970: 1521030896], [OFNumber numberWithBool: true], [OFNumber numberWithBool: false], [OFNumber numberWithFloat: 12.25f], [OFNumber numberWithInt: -10], nil]; OTAssertEqualObjects([PLIST( @"<string>Hello</string>") objectByParsingPropertyList], @"Hello"); OTAssertEqualObjects([PLIST( @"<array>" @" <string>Hello</string>" @" <data>V29ybGQh</data>" @" <date>2018-03-14T12:34:56Z</date>" @" <true/>" @" <false/>" @" <real>12.25</real>" @" <integer>-10</integer>" @"</array>") objectByParsingPropertyList], array); OTAssertEqualObjects([PLIST( @"<dict>" @" <key>array</key>" @" <array>" @" <string>Hello</string>" @" <data>V29ybGQh</data>" @" <date>2018-03-14T12:34:56Z</date>" @" <true/>" @" <false/>" @" <real>12.25</real>" @" <integer>-10</integer>" @" </array>" @" <key>foo</key>" @" <string>bar</string>" @"</dict>") objectByParsingPropertyList], ([OFDictionary dictionaryWithKeysAndObjects: @"array", array, @"foo", @"bar", nil])); } - (void)testDetectUnsupportedVersion { OTAssertThrowsSpecific( [[PLIST(@"<string/>") stringByReplacingOccurrencesOfString: @"1.0" withString: @"1.1"] objectByParsingPropertyList], OFUnsupportedVersionException); } - (void)testDetectInvalidFormat { OTAssertThrowsSpecific( [PLIST(@"<string x='b'/>") objectByParsingPropertyList], OFInvalidFormatException); OTAssertThrowsSpecific( [PLIST(@"<string xmlns='foo'/>") objectByParsingPropertyList], OFInvalidFormatException); OTAssertThrowsSpecific( [PLIST(@"<dict count='0'/>") objectByParsingPropertyList], OFInvalidFormatException); OTAssertThrowsSpecific( [PLIST(@"<dict><key/><string/><key/></dict>") objectByParsingPropertyList], OFInvalidFormatException); OTAssertThrowsSpecific( [PLIST(@"<dict><key x='x'/><string/></dict>") objectByParsingPropertyList], OFInvalidFormatException); } @end |
Deleted tests/OFRIPEMD160HashTests.m version [c46510efe0].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Modified tests/OFSCTPSocketTests.m from [cb1c374bbd] to [61d02ea1d1].
1 | /* | | | | | | > > > > | < > | | > | > | | < | | | | < | < < < | < | < < | < | < | | < < | | < | < | | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #include <string.h> #import "ObjFW.h" #import "ObjFWTest.h" @interface OFSCTPSocketTests: OTTestCase @end @implementation OFSCTPSocketTests - (void)testSCTPSocket { OFSCTPSocket *server, *client, *accepted; uint16_t port; char buffer[6]; server = [OFSCTPSocket socket]; client = [OFSCTPSocket socket]; @try { port = [server bindToHost: @"127.0.0.1" port: 0]; } @catch (OFBindSocketFailedException *e) { switch (e.errNo) { case EPROTONOSUPPORT: OTSkip(@"SCTP unsupported"); default: @throw e; } } [server listen]; [client connectToHost: @"127.0.0.1" port: port]; accepted = [server accept]; OTAssertEqualObjects(OFSocketAddressString(accepted.remoteAddress), @"127.0.0.1"); [client sendBuffer: "Hello!" length: 6]; [accepted receiveIntoBuffer: buffer length: 6]; OTAssertEqual(memcmp(buffer, "Hello!", 6), 0); } @end |
Deleted tests/OFSHA1HashTests.m version [76d8541713].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted tests/OFSHA224HashTests.m version [a723282b7a].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted tests/OFSHA256HashTests.m version [ea4a5936cb].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted tests/OFSHA384HashTests.m version [4335e4cd7c].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted tests/OFSHA512HashTests.m version [9748b0700b].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Modified tests/OFSPXSocketTests.m from [951eb7a23c] to [20389c70d4].
1 | /* | | | | | | > > > > | < > | > | > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #include <string.h> #import "ObjFW.h" #import "ObjFWTest.h" @interface OFSPXSocketTests: OTTestCase { OFSPXSocket *_sockServer; OFSocketAddress _addrServer; } @end @interface SPXSocketDelegate: OFObject <OFSPXSocketDelegate> { @public OFSequencedPacketSocket *_expectedServerSocket; OFSPXSocket *_expectedClientSocket; unsigned char _expectedNode[IPX_NODE_LEN]; uint32_t _expectedNetwork; uint16_t _expectedPort; bool _accepted; bool _connected; } @end @implementation OFSPXSocketTests - (void)setUp { const unsigned char zeroNode[IPX_NODE_LEN] = { 0 }; _sockServer = [[OFSPXSocket alloc] init]; @try { _addrServer = [_sockServer bindToNetwork: 0 node: zeroNode port: 0]; } @catch (OFBindSocketFailedException *e) { switch (e.errNo) { case EAFNOSUPPORT: OTSkip(@"IPX unsupported"); case ESOCKTNOSUPPORT: OTSkip(@"SPX unsupported"); case EADDRNOTAVAIL: OTSkip(@"IPX not configured"); default: @throw e; } } } - (void)dealloc { [_sockServer release]; [super dealloc]; } - (void)testSPXSocket { OFSPXSocket *sockClient, *sockAccepted; const OFSocketAddress *addrAccepted; uint32_t network; unsigned char node[IPX_NODE_LEN], node2[IPX_NODE_LEN]; uint16_t port; OFDictionary *networkInterfaces; char buffer[5]; sockClient = [OFSPXSocket socket]; network = OFSocketAddressIPXNetwork(&_addrServer); OFSocketAddressGetIPXNode(&_addrServer, node); port = OFSocketAddressIPXPort(&_addrServer); [_sockServer listen]; /* * Find any network interface with IPX and send to it. Any should be * fine since we bound to 0.0. */ networkInterfaces = [OFSystemInfo networkInterfaces]; for (OFString *name in networkInterfaces) { OFNetworkInterface interface = [networkInterfaces objectForKey: name]; OFData *addresses = [interface objectForKey: OFNetworkInterfaceIPXAddresses]; if (addresses.count == 0) continue; network = OFSocketAddressIPXNetwork([addresses itemAtIndex: 0]); OFSocketAddressGetIPXNode([addresses itemAtIndex: 0], node); } [sockClient connectToNetwork: network node: node port: port]; sockAccepted = [_sockServer accept]; [sockAccepted sendBuffer: "Hello" length: 5]; OTAssertEqual([sockClient receiveIntoBuffer: buffer length: 5], 5); OTAssertEqual(memcmp(buffer, "Hello", 5), 0); addrAccepted = sockAccepted.remoteAddress; OFSocketAddressGetIPXNode(addrAccepted, node2); OTAssertEqual(memcmp(node, node2, IPX_NODE_LEN), 0); } - (void)testAsyncSPXSocket { SPXSocketDelegate *delegate = [[[SPXSocketDelegate alloc] init] autorelease]; uint32_t network; unsigned char node[IPX_NODE_LEN]; uint16_t port; OFDictionary *networkInterfaces; OFSPXSocket *sockClient; delegate->_expectedServerSocket = _sockServer; _sockServer.delegate = delegate; sockClient = [OFSPXSocket socket]; delegate->_expectedClientSocket = sockClient; sockClient.delegate = delegate; [_sockServer listen]; [_sockServer asyncAccept]; network = OFSocketAddressIPXNetwork(&_addrServer); OFSocketAddressGetIPXNode(&_addrServer, node); port = OFSocketAddressIPXPort(&_addrServer); /* * Find any network interface with IPX and send to it. Any should be * fine since we bound to 0.0. */ networkInterfaces = [OFSystemInfo networkInterfaces]; for (OFString *name in networkInterfaces) { OFNetworkInterface interface = [networkInterfaces objectForKey: name]; OFData *addresses = [interface objectForKey: OFNetworkInterfaceIPXAddresses]; if (addresses.count == 0) continue; network = OFSocketAddressIPXNetwork([addresses itemAtIndex: 0]); OFSocketAddressGetIPXNode([addresses itemAtIndex: 0], node); } delegate->_expectedNetwork = network = OFSocketAddressIPXNetwork(&_addrServer); OFSocketAddressGetIPXNode(&_addrServer, node); memcpy(delegate->_expectedNode, node, IPX_NODE_LEN); delegate->_expectedPort = port = OFSocketAddressIPXPort(&_addrServer); @try { [sockClient asyncConnectToNetwork: network node: node port: port]; [[OFRunLoop mainRunLoop] runUntilDate: [OFDate dateWithTimeIntervalSinceNow: 2]]; OTAssertTrue(delegate->_accepted); OTAssertTrue(delegate->_connected); } @catch (OFObserveKernelEventsFailedException *e) { /* * Make sure it doesn't stay in the run loop and throws again * next time we run the run loop. */ [sockClient cancelAsyncRequests]; [_sockServer cancelAsyncRequests]; switch (e.errNo) { case ENOTSOCK: OTSkip(@"select() not supported for SPX"); default: @throw e; } } } @end @implementation SPXSocketDelegate - (bool)socket: (OFSequencedPacketSocket *)sock didAcceptSocket: (OFSequencedPacketSocket *)accepted exception: (id)exception |
︙ | ︙ | |||
62 63 64 65 66 67 68 69 | network == _expectedNetwork && memcmp(node, _expectedNode, IPX_NODE_LEN) == 0 && port == _expectedPort && exception == nil); if (_accepted && _connected) [[OFRunLoop mainRunLoop] stop]; } @end | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 230 231 232 233 234 235 236 237 | network == _expectedNetwork && memcmp(node, _expectedNode, IPX_NODE_LEN) == 0 && port == _expectedPort && exception == nil); if (_accepted && _connected) [[OFRunLoop mainRunLoop] stop]; } @end |
Modified tests/OFSPXStreamSocketTests.m from [ca6bf9ee77] to [7ec314006d].
1 | /* | | | | | | > > > > | < > | > | > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #include <string.h> #import "ObjFW.h" #import "ObjFWTest.h" @interface OFSPXStreamSocketTests: OTTestCase { OFSPXStreamSocket *_sockServer; OFSocketAddress _addrServer; } @end @interface SPXStreamSocketDelegate: OFObject <OFSPXStreamSocketDelegate> { @public OFStreamSocket *_expectedServerSocket; OFSPXStreamSocket *_expectedClientSocket; uint32_t _expectedNetwork; unsigned char _expectedNode[IPX_NODE_LEN]; uint16_t _expectedPort; bool _accepted; bool _connected; } @end @implementation OFSPXStreamSocketTests - (void)setUp { const unsigned char zeroNode[IPX_NODE_LEN] = { 0 }; _sockServer = [[OFSPXStreamSocket alloc] init]; @try { _addrServer = [_sockServer bindToNetwork: 0 node: zeroNode port: 0]; } @catch (OFBindSocketFailedException *e) { switch (e.errNo) { case EAFNOSUPPORT: OTSkip(@"IPX unsupported"); case ESOCKTNOSUPPORT: case EPROTONOSUPPORT: OTSkip(@"SPX unsupported"); case EADDRNOTAVAIL: OTSkip(@"IPX not configured"); default: @throw e; } } } - (void)dealloc { [_sockServer release]; [super dealloc]; } - (void)testSPXStreamSocket { OFSPXStreamSocket *sockClient, *sockAccepted; const OFSocketAddress *addrAccepted; uint32_t network; unsigned char node[IPX_NODE_LEN], node2[IPX_NODE_LEN]; uint16_t port; OFDictionary *networkInterfaces; char buffer[5]; sockClient = [OFSPXStreamSocket socket]; network = OFSocketAddressIPXNetwork(&_addrServer); OFSocketAddressGetIPXNode(&_addrServer, node); port = OFSocketAddressIPXPort(&_addrServer); [_sockServer listen]; /* * Find any network interface with IPX and send to it. Any should be * fine since we bound to 0.0. */ networkInterfaces = [OFSystemInfo networkInterfaces]; for (OFString *name in networkInterfaces) { OFNetworkInterface interface = [networkInterfaces objectForKey: name]; OFData *addresses = [interface objectForKey: OFNetworkInterfaceIPXAddresses]; if (addresses.count == 0) continue; network = OFSocketAddressIPXNetwork([addresses itemAtIndex: 0]); OFSocketAddressGetIPXNode([addresses itemAtIndex: 0], node); } [sockClient connectToNetwork: network node: node port: port]; sockAccepted = [_sockServer accept]; [sockAccepted writeBuffer: "Hello" length: 5]; /* Test reassembly (this would not work with OFSPXSocket) */ OTAssertEqual([sockClient readIntoBuffer: buffer length: 2], 2); OTAssertEqual([sockClient readIntoBuffer: buffer + 2 length: 3], 3); OTAssertEqual(memcmp(buffer, "Hello", 5), 0); addrAccepted = sockAccepted.remoteAddress; OFSocketAddressGetIPXNode(addrAccepted, node2); OTAssertEqual(memcmp(node, node2, IPX_NODE_LEN), 0); } - (void)testAsyncSPXStreamSocket { SPXStreamSocketDelegate *delegate = [[[SPXStreamSocketDelegate alloc] init] autorelease]; uint32_t network; unsigned char node[IPX_NODE_LEN]; uint16_t port; OFDictionary *networkInterfaces; OFSPXStreamSocket *sockClient; delegate->_expectedServerSocket = _sockServer; _sockServer.delegate = delegate; sockClient = [OFSPXStreamSocket socket]; delegate->_expectedClientSocket = sockClient; sockClient.delegate = delegate; [_sockServer listen]; [_sockServer asyncAccept]; network = OFSocketAddressIPXNetwork(&_addrServer); OFSocketAddressGetIPXNode(&_addrServer, node); port = OFSocketAddressIPXPort(&_addrServer); /* * Find any network interface with IPX and send to it. Any should be * fine since we bound to 0.0. */ networkInterfaces = [OFSystemInfo networkInterfaces]; for (OFString *name in networkInterfaces) { OFNetworkInterface interface = [networkInterfaces objectForKey: name]; OFData *addresses = [interface objectForKey: OFNetworkInterfaceIPXAddresses]; if (addresses.count == 0) continue; network = OFSocketAddressIPXNetwork([addresses itemAtIndex: 0]); OFSocketAddressGetIPXNode([addresses itemAtIndex: 0], node); } delegate->_expectedNetwork = network = OFSocketAddressIPXNetwork(&_addrServer); OFSocketAddressGetIPXNode(&_addrServer, node); memcpy(delegate->_expectedNode, node, IPX_NODE_LEN); delegate->_expectedPort = port = OFSocketAddressIPXPort(&_addrServer); @try { [sockClient asyncConnectToNetwork: network node: node port: port]; [[OFRunLoop mainRunLoop] runUntilDate: [OFDate dateWithTimeIntervalSinceNow: 2]]; OTAssertTrue(delegate->_accepted); OTAssertTrue(delegate->_connected); } @catch (OFObserveKernelEventsFailedException *e) { /* * Make sure it doesn't stay in the run loop and throws again * next time we run the run loop. */ [sockClient cancelAsyncRequests]; [_sockServer cancelAsyncRequests]; switch (e.errNo) { case ENOTSOCK: OTSkip(@"select() not supported for SPX"); default: @throw e; } } } @end @implementation SPXStreamSocketDelegate - (bool)socket: (OFStreamSocket *)sock didAcceptSocket: (OFStreamSocket *)accepted exception: (id)exception |
︙ | ︙ | |||
62 63 64 65 66 67 68 69 | network == _expectedNetwork && memcmp(node, _expectedNode, IPX_NODE_LEN) == 0 && port == _expectedPort && exception == nil); if (_accepted && _connected) [[OFRunLoop mainRunLoop] stop]; } @end | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 233 234 235 236 237 238 239 240 | network == _expectedNetwork && memcmp(node, _expectedNode, IPX_NODE_LEN) == 0 && port == _expectedPort && exception == nil); if (_accepted && _connected) [[OFRunLoop mainRunLoop] stop]; } @end |
Modified tests/OFScryptTests.m from [b11c7bebe9] to [a6d12637a8].
1 | /* | | | | | | > > > > | < > | | > > > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "ObjFW.h" #import "ObjFWTest.h" @interface OFScryptTests: OTTestCase @end /* Test vectors form RFC 7914 */ static const unsigned char salsa20Input[64] = { 0x7E, 0x87, 0x9A, 0x21, 0x4F, 0x3E, 0xC9, 0x86, 0x7C, 0xA9, 0x40, 0xE6, 0x41, 0x71, 0x8F, 0x26, 0xBA, 0xEE, 0x55, 0x5B, 0x8C, 0x61, 0xC1, 0xB5, 0x0D, 0xF8, 0x46, 0x11, 0x6D, 0xCD, 0x3B, 0x1D, 0xEE, 0x24, 0xF3, 0x19, 0xDF, 0x9B, 0x3D, 0x85, 0x14, 0x12, 0x1E, 0x4B, 0x5A, 0xC5, 0xAA, 0x32, 0x76, 0x02, 0x1D, 0x29, 0x09, 0xC7, 0x48, 0x29, 0xED, 0xEB, 0xC6, 0x8D, |
︙ | ︙ | |||
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | 0x77, 0xD6, 0x57, 0x62, 0x38, 0x65, 0x7B, 0x20, 0x3B, 0x19, 0xCA, 0x42, 0xC1, 0x8A, 0x04, 0x97, 0xF1, 0x6B, 0x48, 0x44, 0xE3, 0x07, 0x4A, 0xE8, 0xDF, 0xDF, 0xFA, 0x3F, 0xED, 0xE2, 0x14, 0x42, 0xFC, 0xD0, 0x06, 0x9D, 0xED, 0x09, 0x48, 0xF8, 0x32, 0x6A, 0x75, 0x3A, 0x0F, 0xC8, 0x1F, 0x17, 0xE8, 0xD3, 0xE0, 0xFB, 0x2E, 0x0D, 0x36, 0x28, 0xCF, 0x35, 0xE2, 0x0C, 0x38, 0xD1, 0x89, 0x06 }; static const unsigned char testVector2[64] = { 0xFD, 0xBA, 0xBE, 0x1C, 0x9D, 0x34, 0x72, 0x00, 0x78, 0x56, 0xE7, 0x19, 0x0D, 0x01, 0xE9, 0xFE, 0x7C, 0x6A, 0xD7, 0xCB, 0xC8, 0x23, 0x78, 0x30, 0xE7, 0x73, 0x76, 0x63, 0x4B, 0x37, 0x31, 0x62, 0x2E, 0xAF, 0x30, 0xD9, 0x2E, 0x22, 0xA3, 0x88, 0x6F, 0xF1, 0x09, 0x27, 0x9D, 0x98, 0x30, 0xDA, 0xC7, 0x27, 0xAF, 0xB9, 0x4A, 0x83, 0xEE, 0x6D, 0x83, 0x60, 0xCB, 0xDF, 0xA2, 0xCC, 0x06, 0x40 }; | > > > > | > > | | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | 0x77, 0xD6, 0x57, 0x62, 0x38, 0x65, 0x7B, 0x20, 0x3B, 0x19, 0xCA, 0x42, 0xC1, 0x8A, 0x04, 0x97, 0xF1, 0x6B, 0x48, 0x44, 0xE3, 0x07, 0x4A, 0xE8, 0xDF, 0xDF, 0xFA, 0x3F, 0xED, 0xE2, 0x14, 0x42, 0xFC, 0xD0, 0x06, 0x9D, 0xED, 0x09, 0x48, 0xF8, 0x32, 0x6A, 0x75, 0x3A, 0x0F, 0xC8, 0x1F, 0x17, 0xE8, 0xD3, 0xE0, 0xFB, 0x2E, 0x0D, 0x36, 0x28, 0xCF, 0x35, 0xE2, 0x0C, 0x38, 0xD1, 0x89, 0x06 }; /* Nintendo DS does not have enough RAM for the second test vector. */ #ifndef OF_NINTENDO_DS static const unsigned char testVector2[64] = { 0xFD, 0xBA, 0xBE, 0x1C, 0x9D, 0x34, 0x72, 0x00, 0x78, 0x56, 0xE7, 0x19, 0x0D, 0x01, 0xE9, 0xFE, 0x7C, 0x6A, 0xD7, 0xCB, 0xC8, 0x23, 0x78, 0x30, 0xE7, 0x73, 0x76, 0x63, 0x4B, 0x37, 0x31, 0x62, 0x2E, 0xAF, 0x30, 0xD9, 0x2E, 0x22, 0xA3, 0x88, 0x6F, 0xF1, 0x09, 0x27, 0x9D, 0x98, 0x30, 0xDA, 0xC7, 0x27, 0xAF, 0xB9, 0x4A, 0x83, 0xEE, 0x6D, 0x83, 0x60, 0xCB, 0xDF, 0xA2, 0xCC, 0x06, 0x40 }; #endif /* * The third test vector is too expensive for m68k. * Nintendo DS does not have enough RAM for the third test vector. */ #if !defined(OF_M68K) && !defined(OF_NINTENDO_DS) static const unsigned char testVector3[64] = { 0x70, 0x23, 0xBD, 0xCB, 0x3A, 0xFD, 0x73, 0x48, 0x46, 0x1C, 0x06, 0xCD, 0x81, 0xFD, 0x38, 0xEB, 0xFD, 0xA8, 0xFB, 0xBA, 0x90, 0x4F, 0x8E, 0x3E, 0xA9, 0xB5, 0x43, 0xF6, 0x54, 0x5D, 0xA1, 0xF2, 0xD5, 0x43, 0x29, 0x55, 0x61, 0x3F, 0x0F, 0xCF, 0x62, 0xD4, 0x97, 0x05, 0x24, 0x2A, 0x9A, 0xF9, 0xE6, 0x1E, 0x85, 0xDC, 0x0D, 0x65, 0x1E, 0x40, 0xDF, 0xCF, 0x01, 0x7B, 0x45, 0x57, 0x58, 0x87 |
︙ | ︙ | |||
129 130 131 132 133 134 135 | 0xAB, 0xE5, 0xEE, 0x98, 0x20, 0xAD, 0xAA, 0x47, 0x8E, 0x56, 0xFD, 0x8F, 0x4B, 0xA5, 0xD0, 0x9F, 0xFA, 0x1C, 0x6D, 0x92, 0x7C, 0x40, 0xF4, 0xC3, 0x37, 0x30, 0x40, 0x49, 0xE8, 0xA9, 0x52, 0xFB, 0xCB, 0xF4, 0x5C, 0x6F, 0xA7, 0x7A, 0x41, 0xA4 }; #endif | | | < < < < < | | | | | > > > > | | | | > > > > | | | | | > > > > | > > | | | > > > > > > | > > | | > > > | > > | > > > | | > > | > | > > > | | | < < > > | 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | 0xAB, 0xE5, 0xEE, 0x98, 0x20, 0xAD, 0xAA, 0x47, 0x8E, 0x56, 0xFD, 0x8F, 0x4B, 0xA5, 0xD0, 0x9F, 0xFA, 0x1C, 0x6D, 0x92, 0x7C, 0x40, 0xF4, 0xC3, 0x37, 0x30, 0x40, 0x49, 0xE8, 0xA9, 0x52, 0xFB, 0xCB, 0xF4, 0x5C, 0x6F, 0xA7, 0x7A, 0x41, 0xA4 }; #endif @implementation OFScryptTests - (void)testSalsa20_8Core { uint32_t salsa20Buffer[16]; memcpy(salsa20Buffer, salsa20Input, 64); OFSalsa20_8Core(salsa20Buffer); OTAssertEqual(memcmp(salsa20Buffer, salsa20Output, 64), 0); } - (void)testBlockMix { uint32_t blockMixBuffer[32]; OFScryptBlockMix(blockMixBuffer, blockMixInput.u32, 1); OTAssertEqual(memcmp(blockMixBuffer, blockMixOutput, 128), 0); } - (void)testROMix { uint32_t ROMixBuffer[32], ROMixTmp[17 * 32]; memcpy(ROMixBuffer, ROMixInput, 128); OFScryptROMix(ROMixBuffer, 1, 16, ROMixTmp); OTAssertEqual(memcmp(ROMixBuffer, ROMixOutput, 128), 0); } - (void)testRFC7941TestVector1 { unsigned char output[64]; OFScrypt((OFScryptParameters){ .blockSize = 1, .costFactor = 16, .parallelization = 1, .salt = (unsigned char *)"", .saltLength = 0, .password = "", .passwordLength = 0, .key = output, .keyLength = 64, .allowsSwappableMemory = true }); OTAssertEqual(memcmp(output, testVector1, 64), 0); } /* Nintendo DS does not have enough RAM for the second test vector. */ #ifndef OF_NINTENDO_DS - (void)testRFC7941TestVector2 { unsigned char output[64]; OFScrypt((OFScryptParameters){ .blockSize = 8, .costFactor = 1024, .parallelization = 16, .salt = (unsigned char *)"NaCl", .saltLength = 4, .password = "password", .passwordLength = 8, .key = output, .keyLength = 64, .allowsSwappableMemory = true }); OTAssertEqual(memcmp(output, testVector2, 64), 0); } #endif /* * The third test vector is too expensive for m68k. * Nintendo DS does not have enough RAM for the third test vector. */ #if !defined(OF_M68K) && !defined(OF_NINTENDO_DS) - (void)testRFC7941TestVector3 { unsigned char output[64]; OFScrypt((OFScryptParameters){ .blockSize = 8, .costFactor = 16384, .parallelization = 1, .salt = (unsigned char *)"SodiumChloride", .saltLength = 14, .password = "pleaseletmein", .passwordLength = 13, .key = output, .keyLength = 64, .allowsSwappableMemory = true }); OTAssertEqual(memcmp(output, testVector3, 64), 0); } #endif /* The forth test vector is too expensive to include it in the tests. */ #if 0 - (void)testRFC7941TestVector4 { unsigned char output[64]; OFScrypt((OFScryptParameters){ .blockSize = 8, .costFactor = 1048576, .parallelization = 1, .salt = (unsigned char *)"SodiumChloride", .saltLength = 14, .password = "pleaseletmein", .passwordLength = 13, .key = output, .keyLength = 64, .allowsSwappableMemory = true }); OTAssertEqual(memcmp(output, testVector4, 64), 0); } #endif @end |
Deleted tests/OFSerializationTests.m version [d36329ce8f].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Added tests/OFSetTests.h version [845cb4f451].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "ObjFW.h" #import "ObjFWTest.h" @interface OFSetTests: OTTestCase { OFSet *_set; } @property (readonly, nonatomic) Class setClass; @end |
Modified tests/OFSetTests.m from [d6c98b6473] to [eeb6210c3b].
1 | /* | | | | | | > > > > | < > | | > > | > > | > > > > > | > | > | > | | > > | > | > | > > > > | > | > > | > > > > > | > > > | > > > > > > > | | | < > | | | > > > | > > > | > > > | > > > > > > | < > > > > > | > > > > > > > > > > > > | | > > | < > | > | | < > > | > > > > > > | > | < > > > | > > > > > > > > > > > > > > > | < > > | > | | > > | > > > > > | > > > | > > | > > > | | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFSetTests.h" @interface CustomSet: OFSet { OFSet *_set; } @end @implementation OFSetTests - (Class)setClass { return [CustomSet class]; } - (void)setUp { [super setUp]; _set = [[OFSet alloc] initWithObjects: @"foo", @"bar", @"baz", nil]; } - (void)dealloc { [_set release]; [super dealloc]; } - (void)testSetWithArray { OTAssertEqualObjects([self.setClass setWithArray: ([OFArray arrayWithObjects: @"foo", @"bar", @"baz", @"foo", nil])], _set); } - (void)testIsEqual { OTAssertEqualObjects(_set, ([OFSet setWithObjects: @"foo", @"bar", @"baz", nil])); } - (void)testHash { OTAssertEqual(_set.hash, [([OFSet setWithObjects: @"foo", @"bar", @"baz", nil]) hash]); } - (void)testDescription { OFString *description = _set.description; OTAssert( [description isEqual: @"{(\n\tfoo,\n\tbar,\n\tbaz\n)}"] || [description isEqual: @"{(\n\tfoo,\n\tbaz,\n\tbar\n)}"] || [description isEqual: @"{(\n\tbar,\n\tfoo,\n\tbaz\n)}"] || [description isEqual: @"{(\n\tbar,\n\tbaz,\n\tfoo\n)}"] || [description isEqual: @"{(\n\tbaz,\n\tfoo,\n\tbar\n)}"] || [description isEqual: @"{(\n\tbaz,\n\tbar,\n\tfoo\n)}"]); } - (void)testCopy { OTAssertEqualObjects([[_set copy] autorelease], _set); } - (void)testMutableCopy { OTAssertEqualObjects([[_set mutableCopy] autorelease], _set); } - (void)testIsSubsetOfSet { OTAssertTrue([([OFSet setWithObjects: @"foo", nil]) isSubsetOfSet: _set]); OTAssertFalse([([OFSet setWithObjects: @"foo", @"Foo", nil]) isSubsetOfSet: _set]); } - (void)testIntersectsSet { OTAssertTrue([([OFSet setWithObjects: @"foo", @"Foo", nil]) intersectsSet: _set]); OTAssertFalse([([OFSet setWithObjects: @"Foo", nil]) intersectsSet: _set]); } - (void)testEnumerator { OFEnumerator *enumerator = [_set objectEnumerator]; bool seenFoo = false, seenBar = false, seenBaz = false; OFString *object; while ((object = [enumerator nextObject]) != nil) { if ([object isEqual: @"foo"]) { OTAssertFalse(seenFoo); seenFoo = true; } else if ([object isEqual: @"bar"]) { OTAssertFalse(seenBar); seenBar = true; } else if ([object isEqual: @"baz"]) { OTAssertFalse(seenBaz); seenBaz = true; } else OTAssert(false, @"Unexpected object seen: %@", object); } OTAssert(seenFoo && seenBar && seenBaz); } - (void)testFastEnumeration { bool seenFoo = false, seenBar = false, seenBaz = false; for (OFString *object in _set) { if ([object isEqual: @"foo"]) { OTAssertFalse(seenFoo); seenFoo = true; } else if ([object isEqual: @"bar"]) { OTAssertFalse(seenBar); seenBar = true; } else if ([object isEqual: @"baz"]) { OTAssertFalse(seenBaz); seenBaz = true; } else OTAssert(false, @"Unexpected object seen: %@", object); } OTAssert(seenFoo && seenBar && seenBaz); } #ifdef OF_HAVE_BLOCKS - (void)testEnumerateObjectsUsingBlock { __block bool seenFoo = false, seenBar = false, seenBaz = false; [_set enumerateObjectsUsingBlock: ^ (id object, bool *stop) { if ([object isEqual: @"foo"]) { OTAssertFalse(seenFoo); seenFoo = true; } else if ([object isEqual: @"bar"]) { OTAssertFalse(seenBar); seenBar = true; } else if ([object isEqual: @"baz"]) { OTAssertFalse(seenBaz); seenBaz = true; } else OTAssert(false, @"Unexpected object seen: %@", object); }]; OTAssert(seenFoo && seenBar && seenBaz); } - (void)testFilteredSetUsingBlock { OFSet *filteredSet = [_set filteredSetUsingBlock: ^ (id object) { return [object hasPrefix: @"ba"]; }]; OTAssertEqualObjects(filteredSet, ([OFSet setWithObjects: @"bar", @"baz", nil])); } #endif - (void)testValueForKey { OFSet *set = [[self.setClass setWithObjects: @"a", @"ab", @"abc", @"b", nil] valueForKey: @"length"]; OTAssertEqualObjects(set, ([OFSet setWithObjects: [OFNumber numberWithInt: 1], [OFNumber numberWithInt: 2], [OFNumber numberWithInt: 3], nil])); OTAssertEqualObjects([set valueForKey: @"@count"], [OFNumber numberWithInt: 3]); } @end @implementation CustomSet - (instancetype)initWithObjects: (id const *)objects count: (size_t)count { self = [super init]; @try { _set = [[OFSet alloc] initWithObjects: objects count: count]; } @catch (id e) { [self release]; @throw e; } return self; } |
︙ | ︙ | |||
111 112 113 114 115 116 117 118 | return [_set containsObject: object]; } - (OFEnumerator *)objectEnumerator { return [_set objectEnumerator]; } @end | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 228 229 230 231 232 233 234 235 | return [_set containsObject: object]; } - (OFEnumerator *)objectEnumerator { return [_set objectEnumerator]; } @end |
Modified tests/OFSocketTests.m from [0766971ff5] to [ead74f522a].
1 | /* | | | | | | > > > > | < > | | > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFW.h" #import "ObjFWTest.h" @interface OFSocketTests: OTTestCase @end #define COMPARE_V6(a, a0, a1, a2, a3, a4, a5, a6, a7) \ (a.sockaddr.in6.sin6_addr.s6_addr[0] == (a0 >> 8) && \ a.sockaddr.in6.sin6_addr.s6_addr[1] == (a0 & 0xFF) && \ a.sockaddr.in6.sin6_addr.s6_addr[2] == (a1 >> 8) && \ a.sockaddr.in6.sin6_addr.s6_addr[3] == (a1 & 0xFF) && \ a.sockaddr.in6.sin6_addr.s6_addr[4] == (a2 >> 8) && \ |
︙ | ︙ | |||
48 49 50 51 52 53 54 | a.sockaddr.in6.sin6_addr.s6_addr[10] = a5 >> 8; \ a.sockaddr.in6.sin6_addr.s6_addr[11] = a5 & 0xFF; \ a.sockaddr.in6.sin6_addr.s6_addr[12] = a6 >> 8; \ a.sockaddr.in6.sin6_addr.s6_addr[13] = a6 & 0xFF; \ a.sockaddr.in6.sin6_addr.s6_addr[14] = a7 >> 8; \ a.sockaddr.in6.sin6_addr.s6_addr[15] = a7 & 0xFF; | < < | | < | < < | > | | | > > | > < | > < | > < | > < | > > | > > > > | | | | > > > > | > > > > > < | | | | | < | | | > > > | | | | > > > > > > > > > < | | | < | | | | | > > | > < | > < | > < | > < | > < | > < | > < | > > | > | > | | > > | | | | > > > | | | < | | < | | > > | > > | | | < | | > | < | | | > > | > | > > > > | > | < < | | | | < | | > > > | | | > | > | > > > | > > > | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | a.sockaddr.in6.sin6_addr.s6_addr[10] = a5 >> 8; \ a.sockaddr.in6.sin6_addr.s6_addr[11] = a5 & 0xFF; \ a.sockaddr.in6.sin6_addr.s6_addr[12] = a6 >> 8; \ a.sockaddr.in6.sin6_addr.s6_addr[13] = a6 & 0xFF; \ a.sockaddr.in6.sin6_addr.s6_addr[14] = a7 >> 8; \ a.sockaddr.in6.sin6_addr.s6_addr[15] = a7 & 0xFF; @implementation OFSocketTests - (void)testParseIPv4 { OFSocketAddress address = OFSocketAddressParseIP(@"127.0.0.1", 1234); OTAssertEqual(OFFromBigEndian32(address.sockaddr.in.sin_addr.s_addr), 0x7F000001); OTAssertEqual(OFFromBigEndian16(address.sockaddr.in.sin_port), 1234); } - (void)testParseRejectsInvalidIPv4 { OTAssertThrowsSpecific(OFSocketAddressParseIP(@"127.0.0.0.1", 1234), OFInvalidFormatException); OTAssertThrowsSpecific(OFSocketAddressParseIP(@"127.0.0.256", 1234), OFInvalidFormatException); OTAssertThrowsSpecific(OFSocketAddressParseIP(@"127.0.0. 1", 1234), OFInvalidFormatException); OTAssertThrowsSpecific(OFSocketAddressParseIP(@" 127.0.0.1", 1234), OFInvalidFormatException); OTAssertThrowsSpecific(OFSocketAddressParseIP(@"127.0.a.1", 1234), OFInvalidFormatException); OTAssertThrowsSpecific(OFSocketAddressParseIP(@"127.0..1", 1234), OFInvalidFormatException); } - (void)testPortForIPv4 { OFSocketAddress address = OFSocketAddressParseIP(@"127.0.0.1", 1234); OTAssertEqual(OFSocketAddressIPPort(&address), 1234); } - (void)testStringForIPv4 { OFSocketAddress address = OFSocketAddressParseIP(@"127.0.0.1", 1234); OTAssertEqualObjects(OFSocketAddressString(&address), @"127.0.0.1"); } - (void)testParseIPv6 { OFSocketAddress address; address = OFSocketAddressParseIP( @"1122:3344:5566:7788:99aa:bbCc:ddee:ff00", 1234); OTAssert(COMPARE_V6(address, 0x1122, 0x3344, 0x5566, 0x7788, 0x99AA, 0xBBCC, 0xDDEE, 0xFF00)); OTAssertEqual(OFFromBigEndian16(address.sockaddr.in6.sin6_port), 1234); address = OFSocketAddressParseIP(@"::", 1234); OTAssert(COMPARE_V6(address, 0, 0, 0, 0, 0, 0, 0, 0)); OTAssertEqual(OFFromBigEndian16(address.sockaddr.in6.sin6_port), 1234); address = OFSocketAddressParseIP(@"aaAa::bBbb", 1234); OTAssert(COMPARE_V6(address, 0xAAAA, 0, 0, 0, 0, 0, 0, 0xBBBB)); OTAssertEqual(OFFromBigEndian16(address.sockaddr.in6.sin6_port), 1234); address = OFSocketAddressParseIP(@"aaAa::", 1234); OTAssert(COMPARE_V6(address, 0xAAAA, 0, 0, 0, 0, 0, 0, 0)); OTAssertEqual(OFFromBigEndian16(address.sockaddr.in6.sin6_port), 1234); address = OFSocketAddressParseIP(@"::aaAa", 1234); OTAssert(COMPARE_V6(address, 0, 0, 0, 0, 0, 0, 0, 0xAAAA)); OTAssertEqual(OFFromBigEndian16(address.sockaddr.in6.sin6_port), 1234); address = OFSocketAddressParseIP(@"fd00::1%123", 1234); OTAssert(COMPARE_V6(address, 0xFD00, 0, 0, 0, 0, 0, 0, 1)); OTAssertEqual(OFFromBigEndian16(address.sockaddr.in6.sin6_port), 1234); OTAssertEqual(address.sockaddr.in6.sin6_scope_id, 123); address = OFSocketAddressParseIP(@"::ffff:127.0.0.1", 1234); OTAssert(COMPARE_V6(address, 0, 0, 0, 0, 0, 0xFFFF, 0x7F00, 1)); OTAssertEqual(OFFromBigEndian16(address.sockaddr.in6.sin6_port), 1234); address = OFSocketAddressParseIP(@"64:ff9b::127.0.0.1", 1234); OTAssert(COMPARE_V6(address, 0x64, 0xFF9B, 0, 0, 0, 0, 0x7F00, 1)); OTAssertEqual(OFFromBigEndian16(address.sockaddr.in6.sin6_port), 1234); } - (void)testParseRejectsInvalidIPv6 { OTAssertThrowsSpecific(OFSocketAddressParseIP(@"1:::2", 1234), OFInvalidFormatException); OTAssertThrowsSpecific(OFSocketAddressParseIP(@"1: ::2", 1234), OFInvalidFormatException); OTAssertThrowsSpecific(OFSocketAddressParseIP(@"1:: :2", 1234), OFInvalidFormatException); OTAssertThrowsSpecific(OFSocketAddressParseIP(@"1::2::3", 1234), OFInvalidFormatException); OTAssertThrowsSpecific(OFSocketAddressParseIP(@"10000::1", 1234), OFInvalidFormatException); OTAssertThrowsSpecific(OFSocketAddressParseIP(@"::10000", 1234), OFInvalidFormatException); OTAssertThrowsSpecific(OFSocketAddressParseIP(@"::1::", 1234), OFInvalidFormatException); OTAssertThrowsSpecific(OFSocketAddressParseIP(@"1:2:3:4:5:6:7:", 1234), OFInvalidFormatException); OTAssertThrowsSpecific(OFSocketAddressParseIP(@"1:2:3:4:5:6:7::", 1234), OFInvalidFormatException); OTAssertThrowsSpecific(OFSocketAddressParseIP(@"1:2", 1234), OFInvalidFormatException); } - (void)testPortForIPv6 { OFSocketAddress address = OFSocketAddressParseIP(@"::", 1234); OTAssertEqual(OFSocketAddressIPPort(&address), 1234); } - (void)testStringForIPv6 { OFSocketAddress address = OFSocketAddressParseIP(@"::", 1234); OTAssertEqualObjects(OFSocketAddressString(&address), @"::"); SET_V6(address, 0, 0, 0, 0, 0, 0, 0, 1) OTAssertEqualObjects(OFSocketAddressString(&address), @"::1"); SET_V6(address, 1, 0, 0, 0, 0, 0, 0, 0) OTAssertEqualObjects(OFSocketAddressString(&address), @"1::"); SET_V6(address, 0x1122, 0x3344, 0x5566, 0x7788, 0x99AA, 0xBBCC, 0xDDEE, 0xFF00) OTAssertEqualObjects(OFSocketAddressString(&address), @"1122:3344:5566:7788:99aa:bbcc:ddee:ff00"); SET_V6(address, 0x1122, 0x3344, 0x5566, 0x7788, 0x99AA, 0xBBCC, 0xDDEE, 0) OTAssertEqualObjects(OFSocketAddressString(&address), @"1122:3344:5566:7788:99aa:bbcc:ddee:0"); SET_V6(address, 0x1122, 0x3344, 0x5566, 0x7788, 0x99AA, 0xBBCC, 0, 0) OTAssertEqualObjects(OFSocketAddressString(&address), @"1122:3344:5566:7788:99aa:bbcc::"); SET_V6(address, 0, 0x3344, 0x5566, 0x7788, 0x99AA, 0xBBCC, 0xDDEE, 0xFF00) OTAssertEqualObjects(OFSocketAddressString(&address), @"0:3344:5566:7788:99aa:bbcc:ddee:ff00"); SET_V6(address, 0, 0, 0x5566, 0x7788, 0x99AA, 0xBBCC, 0xDDEE, 0xFF00) OTAssertEqualObjects(OFSocketAddressString(&address), @"::5566:7788:99aa:bbcc:ddee:ff00"); SET_V6(address, 0, 0, 0x5566, 0, 0, 0, 0xDDEE, 0xFF00) OTAssertEqualObjects(OFSocketAddressString(&address), @"0:0:5566::ddee:ff00"); SET_V6(address, 0, 0, 0x5566, 0x7788, 0x99AA, 0xBBCC, 0, 0) OTAssertEqualObjects(OFSocketAddressString(&address), @"::5566:7788:99aa:bbcc:0:0"); address.sockaddr.in6.sin6_scope_id = 123; OTAssertEqualObjects(OFSocketAddressString(&address), @"::5566:7788:99aa:bbcc:0:0%123"); } - (void)testAddressEqual { OFSocketAddress addr1 = OFSocketAddressParseIP(@"127.0.0.1", 1234); OFSocketAddress addr2 = OFSocketAddressParseIP(@"127.0.0.1", 1234); OFSocketAddress addr3 = OFSocketAddressParseIP(@"127.0.0.1", 1235); OTAssertTrue(OFSocketAddressEqual(&addr1, &addr2)); OTAssertFalse(OFSocketAddressEqual(&addr1, &addr3)); } - (void)testAddressHash { OFSocketAddress addr1 = OFSocketAddressParseIP(@"127.0.0.1", 1234); OFSocketAddress addr2 = OFSocketAddressParseIP(@"127.0.0.1", 1234); OFSocketAddress addr3 = OFSocketAddressParseIP(@"127.0.0.1", 1235); OTAssertEqual(OFSocketAddressHash(&addr1), OFSocketAddressHash(&addr2)); OTAssertNotEqual(OFSocketAddressHash(&addr1), OFSocketAddressHash(&addr3)); } @end |
Modified tests/OFStreamTests.m from [12c9753c4d] to [c1be2e2921].
1 | /* | | | | | | > > > > | < > | | > | > | | > > > > > > > > > > > > > > > > > > > > > > > > > | | | | | < < < < < < < < < < < < < < < < < < < < < < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFW.h" #import "ObjFWTest.h" @interface OFStreamTests: OTTestCase @end @interface OFTestStream: OFStream { int _state; } @end @implementation OFStreamTests - (void)testStream { size_t pageSize = [OFSystemInfo pageSize]; OFTestStream *stream = [[[OFTestStream alloc] init] autorelease]; char *cString = OFAllocMemory(pageSize - 2, 1); @try { OFString *string; memset(cString, 'X', pageSize - 3); cString[pageSize - 3] = '\0'; OTAssertEqualObjects([stream readLine], @"foo"); string = [stream readLine]; OTAssertNotNil(string); OTAssertEqual(string.length, pageSize - 3); OTAssertEqual(strcmp(string.UTF8String, cString), 0); } @finally { OFFreeMemory(cString); } } @end @implementation OFTestStream - (bool)lowlevelIsAtEndOfStream { return (_state > 1); } - (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)size { size_t pageSize = [OFSystemInfo pageSize]; switch (_state) { case 0: if (size < 1) return 0; memcpy(buffer, "f", 1); _state++; return 1; case 1: if (size < pageSize) return 0; memcpy(buffer, "oo\n", 3); memset((char *)buffer + 3, 'X', pageSize - 3); _state++; return pageSize; } return 0; } @end |
Added tests/OFStringTests.h version [e1686f7a85].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "ObjFW.h" #import "ObjFWTest.h" @interface OFStringTests: OTTestCase { OFString *_string; } @property (readonly, nonatomic) Class stringClass; @end |
Modified tests/OFStringTests.m from [10adf25aaa] to [46bc1e7497].
1 | /* | | | | | | > > > > | < > | < < | < < < < < < < | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdlib.h> #include <string.h> #include <math.h> #import "OFStringTests.h" #ifndef INFINITY # define INFINITY __builtin_inf() #endif static const OFUnichar unicharString[] = { 0xFEFF, 'f', 0xF6, 0xF6, 'b', 0xE4, 'r', 0x1F03A, 0 }; static const OFUnichar swappedUnicharString[] = { 0xFFFE0000, 0x66000000, 0xF6000000, 0xF6000000, 0x62000000, 0xE4000000, 0x72000000, 0x3AF00100, 0 }; static const OFChar16 char16String[] = { 0xFEFF, 'f', 0xF6, 0xF6, 'b', 0xE4, 'r', 0xD83C, 0xDC3A, 0 }; static const OFChar16 swappedChar16String[] = { 0xFFFE, 0x6600, 0xF600, 0xF600, 0x6200, 0xE400, 0x7200, 0x3CD8, 0x3ADC, 0 }; @interface CustomString: OFString { OFMutableString *_string; } @end @interface CustomMutableString: OFMutableString { OFMutableString *_string; } @end @interface EntityHandler: OFObject <OFStringXMLUnescapingDelegate> @end @implementation OFStringTests - (Class)stringClass { return [CustomString class]; } - (void)setUp { [super setUp]; _string = [[self.stringClass alloc] initWithString: @"täṠ€🤔"]; } - (void)dealloc { [_string release]; [super dealloc]; } - (void)testIsEqual { OTAssertEqualObjects(_string, @"täṠ€🤔"); OTAssertEqualObjects(@"täṠ€🤔", _string); OTAssertNotEqualObjects([self.stringClass stringWithString: @"test"], @"täṠ€🤔"); OTAssertNotEqualObjects(@"täṠ€🤔", [self.stringClass stringWithString: @"test"]); } - (void)testHash { OTAssertEqual(_string.hash, @"täṠ€🤔".hash); OTAssertNotEqual([[self.stringClass stringWithString: @"test"] hash], @"täṠ€".hash); } - (void)testCopy { OTAssertEqualObjects([[_string copy] autorelease], _string); } - (void)testMutableCopy { OTAssertEqualObjects([[_string mutableCopy] autorelease], _string); } - (void)testCompare { OTAssertEqual([_string compare: @"täṠ€🤔"], OFOrderedSame); OTAssertEqual([[self.stringClass stringWithString: @""] compare: @"a"], OFOrderedAscending); OTAssertEqual([[self.stringClass stringWithString: @"a"] compare: @"b"], OFOrderedAscending); OTAssertEqual([[self.stringClass stringWithString: @"cd"] compare: @"bc"], OFOrderedDescending); OTAssertEqual([[self.stringClass stringWithString: @"ä"] compare: @"ö"], OFOrderedAscending); OTAssertEqual([[self.stringClass stringWithString: @"€"] compare: @"ß"], OFOrderedDescending); OTAssertEqual([[self.stringClass stringWithString: @"aa"] compare: @"z"], OFOrderedAscending); OTAssertEqual([@"aa" compare: [self.stringClass stringWithString: @"z"]], OFOrderedAscending); } - (void)testCaseInsensitiveCompare { #ifdef OF_HAVE_UNICODE_TABLES OTAssertEqual([[self.stringClass stringWithString: @"a"] caseInsensitiveCompare: @"A"], OFOrderedSame); OTAssertEqual([[self.stringClass stringWithString: @"Ä"] caseInsensitiveCompare: @"ä"], OFOrderedSame); OTAssertEqual([[self.stringClass stringWithString: @"я"] caseInsensitiveCompare: @"Я"], OFOrderedSame); OTAssertEqual([[self.stringClass stringWithString: @"€"] caseInsensitiveCompare: @"ß"], OFOrderedDescending); OTAssertEqual([[self.stringClass stringWithString: @"ß"] caseInsensitiveCompare: @"→"], OFOrderedAscending); OTAssertEqual([[self.stringClass stringWithString: @"AA"] caseInsensitiveCompare: @"z"], OFOrderedAscending); OTAssertEqual([[self.stringClass stringWithString: @"ABC"] caseInsensitiveCompare: @"AbD"], OFOrderedAscending); #else OTAssertEqual([[self.stringClass stringWithString: @"a"] caseInsensitiveCompare: @"A"], OFOrderedSame); OTAssertEqual([[self.stringClass stringWithString: @"AA"] caseInsensitiveCompare: @"z"], OFOrderedAscending); OTAssertEqual([[self.stringClass stringWithString: @"ABC"] caseInsensitiveCompare: @"AbD"], OFOrderedAscending); #endif } - (void)testDescription { OTAssertEqualObjects(_string.description, @"täṠ€🤔"); } - (void)testLength { OTAssertEqual(_string.length, 5); } - (void)testUTF8StringLength { OTAssertEqual(_string.UTF8StringLength, 13); } - (void)testCharacterAtIndex { OTAssertEqual([_string characterAtIndex: 0], 't'); OTAssertEqual([_string characterAtIndex: 1], 0xE4); OTAssertEqual([_string characterAtIndex: 2], 0x1E60); OTAssertEqual([_string characterAtIndex: 3], 0x20AC); OTAssertEqual([_string characterAtIndex: 4], 0x1F914); } - (void)testCharacterAtIndexFailsWithOutOfRangeIndex { OTAssertThrowsSpecific([_string characterAtIndex: 5], OFOutOfRangeException); } - (void)testUppercaseString { #ifdef OF_HAVE_UNICODE_TABLES OTAssertEqualObjects(_string.uppercaseString, @"TÄṠ€🤔"); #else OTAssertEqualObjects(_string.uppercaseString, @"TäṠ€🤔"); #endif } - (void)testLowercaseString { #ifdef OF_HAVE_UNICODE_TABLES OTAssertEqualObjects(_string.lowercaseString, @"täṡ€🤔"); #else OTAssertEqualObjects(_string.lowercaseString, @"täṠ€🤔"); #endif } - (void)testCapitalizedString { #ifdef OF_HAVE_UNICODE_TABLES OTAssertEqualObjects([[self.stringClass stringWithString: @"täṠ€🤔täṠ€🤔 täṠ€🤔"] capitalizedString], @"Täṡ€🤔täṡ€🤔 Täṡ€🤔"); #else OTAssertEqualObjects([[self.stringClass stringWithString: @"täṠ€🤔täṠ€🤔 täṠ€🤔"] capitalizedString], @"TäṠ€🤔täṠ€🤔 TäṠ€🤔"); #endif } - (void)testStringWithUTF8StringLength { OTAssertEqualObjects([self.stringClass stringWithUTF8String: "\xEF\xBB\xBF" "foobar" length: 6], @"foo"); } - (void)testStringWithUTF16String { OTAssertEqualObjects([self.stringClass stringWithUTF16String: char16String], @"fööbär🀺"); OTAssertEqualObjects([self.stringClass stringWithUTF16String: swappedChar16String], @"fööbär🀺"); } - (void)testStringWithUTF32String { OTAssertEqualObjects([self.stringClass stringWithUTF32String: unicharString], @"fööbär🀺"); OTAssertEqualObjects([self.stringClass stringWithUTF32String: swappedUnicharString], @"fööbär🀺"); } - (void)testStringWithUTF8StringFailsWithInvalidUTF8 { OTAssertThrowsSpecific( [self.stringClass stringWithUTF8String: "\xE0\x80"], OFInvalidEncodingException); OTAssertThrowsSpecific( [self.stringClass stringWithUTF8String: "\xF0\x80\x80\xC0"], OFInvalidEncodingException); } - (void)testStringWithCStringEncodingISO8859_1 { OTAssertEqualObjects([self.stringClass stringWithCString: "\xE4\xF6\xFC" encoding: OFStringEncodingISO8859_1], @"äöü"); } #ifdef HAVE_ISO_8859_15 - (void)testStringWithCStringEncodingISO8859_15 { OTAssertEqualObjects([self.stringClass stringWithCString: "\xA4\xA6\xA8\xB4\xB8\xBC\xBD\xBE" encoding: OFStringEncodingISO8859_15], @"€ŠšŽžŒœŸ"); } #endif #ifdef HAVE_WINDOWS_1252 - (void)testStringWithCStringEncodingWindows1252 { OTAssertEqualObjects([self.stringClass stringWithCString: "\x80\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B" "\x8C\x8E\x91\x92\x93\x94\x95\x96\x97\x98\x99" "\x9A\x9B\x9C\x9E\x9F" encoding: OFStringEncodingWindows1252], @"€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ"); } #endif #ifdef HAVE_CODEPAGE_437 - (void)testStringWithCStringEncodingCodepage437 { OTAssertEqualObjects([self.stringClass stringWithCString: "\xB0\xB1\xB2\xDB" encoding: OFStringEncodingCodepage437], @"░▒▓█"); } #endif #ifdef OF_HAVE_FILES - (void)testStringWithContentsOfFileEncoding { OTAssertEqualObjects([self.stringClass stringWithContentsOfFile: @"testfile.txt" encoding: OFStringEncodingISO8859_1], @"testäöü"); } - (void)testStringWithContentsOfIRIEncoding { OTAssertEqualObjects([self.stringClass stringWithContentsOfIRI: [OFIRI fileIRIWithPath: @"testfile.txt"] encoding: OFStringEncodingISO8859_1], @"testäöü"); } #endif - (void)testCStringWithEncodingASCII { OTAssertEqual(strcmp([[self.stringClass stringWithString: @"This is a test"] cStringWithEncoding: OFStringEncodingASCII], "This is a test"), 0); OTAssertThrowsSpecific([[self.stringClass stringWithString: @"This is a tést"] cStringWithEncoding: OFStringEncodingASCII], OFInvalidEncodingException); } - (void)testCStringWithEncodingISO8859_1 { OTAssertEqual(strcmp([[self.stringClass stringWithString: @"This is ä test"] cStringWithEncoding: OFStringEncodingISO8859_1], "This is \xE4 test"), 0); OTAssertThrowsSpecific([[self.stringClass stringWithString: @"This is ä t€st"] cStringWithEncoding: OFStringEncodingISO8859_1], OFInvalidEncodingException); } #ifdef HAVE_ISO_8859_15 - (void)testCStringWithEncodingISO8859_15 { OTAssertEqual(strcmp([[self.stringClass stringWithString: @"This is ä t€st"] cStringWithEncoding: OFStringEncodingISO8859_15], "This is \xE4 t\xA4st"), 0); OTAssertThrowsSpecific( [[self.stringClass stringWithString: @"This is ä t€st…"] cStringWithEncoding: OFStringEncodingISO8859_15], OFInvalidEncodingException); } #endif #ifdef HAVE_WINDOWS_1252 - (void)testCStringWithEncodingWindows1252 { OTAssertEqual( strcmp([[self.stringClass stringWithString: @"This is ä t€st…"] cStringWithEncoding: OFStringEncodingWindows1252], "This is \xE4 t\x80st\x85"), 0); OTAssertThrowsSpecific( [[self.stringClass stringWithString: @"This is ä t€st…‼"] cStringWithEncoding: OFStringEncodingWindows1252], OFInvalidEncodingException); } #endif #ifdef HAVE_CODEPAGE_437 - (void)testCStringWithEncodingCodepage437 { OTAssertEqual( strcmp([[self.stringClass stringWithString: @"Tést strîng ░▒▓"] cStringWithEncoding: OFStringEncodingCodepage437], "T\x82st str\x8Cng \xB0\xB1\xB2"), 0); OTAssertThrowsSpecific( [[self.stringClass stringWithString: @"T€st strîng ░▒▓"] cStringWithEncoding: OFStringEncodingCodepage437], OFInvalidEncodingException); } #endif - (void)testLossyCStringWithEncodingASCII { OTAssertEqual(strcmp([[self.stringClass stringWithString: @"This is a tést"] lossyCStringWithEncoding: OFStringEncodingASCII], "This is a t?st"), 0); } - (void)testLossyCStringWithEncodingISO8859_1 { OTAssertEqual( strcmp([[self.stringClass stringWithString: @"This is ä t€st"] lossyCStringWithEncoding: OFStringEncodingISO8859_1], "This is \xE4 t?st"), 0); } #ifdef HAVE_ISO_8859_15 - (void)testLossyCStringWithEncodingISO8859_15 { OTAssertEqual( strcmp([[self.stringClass stringWithString: @"This is ä t€st…"] lossyCStringWithEncoding: OFStringEncodingISO8859_15], "This is \xE4 t\xA4st?"), 0); } #endif #ifdef HAVE_WINDOWS_1252 - (void)testLossyCStringWithEncodingWindows1252 { OTAssertEqual( strcmp([[self.stringClass stringWithString: @"This is ä t€st…‼"] lossyCStringWithEncoding: OFStringEncodingWindows1252], "This is \xE4 t\x80st\x85?"), 0); } #endif #ifdef HAVE_CODEPAGE_437 - (void)testLossyCStringWithEncodingCodepage437 { OTAssertEqual( strcmp([[self.stringClass stringWithString: @"T€st strîng ░▒▓"] lossyCStringWithEncoding: OFStringEncodingCodepage437], "T?st str\x8Cng \xB0\xB1\xB2"), 0); } #endif - (void)testStringWithFormat { OTAssertEqualObjects( ([self.stringClass stringWithFormat: @"%@:%d", @"test", 123]), @"test:123"); } - (void)testRangeOfString { OFString *string = [self.stringClass stringWithString: @"𝄞öö"]; OTAssertEqual([string rangeOfString: @"öö"].location, 1); OTAssertEqual([string rangeOfString: @"ö"].location, 1); OTAssertEqual([string rangeOfString: @"𝄞"].location, 0); OTAssertEqual([string rangeOfString: @"x"].location, OFNotFound); OTAssertEqual([string rangeOfString: @"öö" options: OFStringSearchBackwards].location, 1); OTAssertEqual([string rangeOfString: @"ö" options: OFStringSearchBackwards].location, 2); OTAssertEqual([string rangeOfString: @"𝄞" options: OFStringSearchBackwards].location, 0); OTAssertEqual([string rangeOfString: @"x" options: OFStringSearchBackwards].location, OFNotFound); } - (void)testRangeOfStringFailsWithOutOfRangeRange { OTAssertThrowsSpecific( [_string rangeOfString: @"t" options: 0 range: OFMakeRange(6, 1)], OFOutOfRangeException); } - (void)testIndexOfCharacterFromSet { OFCharacterSet *characterSet = [OFCharacterSet characterSetWithCharactersInString: @"cđ"]; OTAssertEqual([[self.stringClass stringWithString: @"abcđabcđe"] indexOfCharacterFromSet: characterSet], 2); OTAssertEqual([[self.stringClass stringWithString: @"abcđabcđë"] indexOfCharacterFromSet: characterSet options: OFStringSearchBackwards], 7); OTAssertEqual([[self.stringClass stringWithString: @"abcđabcđë"] indexOfCharacterFromSet: characterSet options: 0 range: OFMakeRange(4, 4)], 6); OTAssertEqual([[self.stringClass stringWithString: @"abcđabcđëf"] indexOfCharacterFromSet: characterSet options: 0 range: OFMakeRange(8, 2)], OFNotFound); } - (void)testIndexOfCharacterFromSetFailsWithOutOfRangeRange { OFCharacterSet *characterSet = [OFCharacterSet characterSetWithCharactersInString: @"cđ"]; OTAssertThrowsSpecific([[self.stringClass stringWithString: @"𝄞öö"] indexOfCharacterFromSet: characterSet options: 0 range: OFMakeRange(3, 1)], OFOutOfRangeException); } - (void)testSubstringWithRange { OTAssertEqualObjects([_string substringWithRange: OFMakeRange(1, 2)], @"äṠ"); OTAssertEqualObjects([_string substringWithRange: OFMakeRange(3, 0)], @""); } - (void)testSubstringWithRangeFailsWithOutOfRangeRange { OTAssertThrowsSpecific([_string substringWithRange: OFMakeRange(4, 2)], OFOutOfRangeException); OTAssertThrowsSpecific([_string substringWithRange: OFMakeRange(6, 0)], OFOutOfRangeException); } - (void)testStringByAppendingString { OTAssertEqualObjects([_string stringByAppendingString: @"äöü"], @"täṠ€🤔äöü"); } - (void)testHasPrefix { OTAssertTrue([_string hasPrefix: @"täṠ"]); OTAssertFalse([_string hasPrefix: @"🤔"]); } - (void)testHasSuffix { OTAssertTrue([_string hasSuffix: @"🤔"]); OTAssertFalse([_string hasSuffix: @"täṠ"]); } - (void)testComponentsSeparatedByString { OTAssertEqualObjects([[self.stringClass stringWithString: @"fooXXbarXXXXbazXXXX"] componentsSeparatedByString: @"XX"], ([OFArray arrayWithObjects: @"foo", @"bar", @"", @"baz", @"", @"", nil])); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo"] componentsSeparatedByString: @""], [OFArray arrayWithObject: @"foo"]); } - (void)testComponentsSeparatedByStringOptions { OTAssertEqualObjects([[self.stringClass stringWithString: @"fooXXbarXXXXbazXXXX"] componentsSeparatedByString: @"XX" options: OFStringSkipEmptyComponents], ([OFArray arrayWithObjects: @"foo", @"bar", @"baz", nil])); } - (void)testComponentsSeparatedByCharactersInSet { OFCharacterSet *characterSet = [OFCharacterSet characterSetWithCharactersInString: @"XYZ"]; OTAssertEqualObjects([[self.stringClass stringWithString: @"fooXYbarXYZXbazXYXZx"] componentsSeparatedByCharactersInSet: characterSet], ([OFArray arrayWithObjects: @"foo", @"", @"bar", @"", @"", @"", @"baz", @"", @"", @"", @"x", nil])); } - (void)testComponentsSeparatedByCharactersInSetOptions { OFCharacterSet *characterSet = [OFCharacterSet characterSetWithCharactersInString: @"XYZ"]; OTAssertEqualObjects([[self.stringClass stringWithString: @"fooXYbarXYZXbazXYXZ"] componentsSeparatedByCharactersInSet: characterSet options: OFStringSkipEmptyComponents], ([OFArray arrayWithObjects: @"foo", @"bar", @"baz", nil])); } - (void)testLongLongValue { OTAssertEqual([[self.stringClass stringWithString: @"1234"] longLongValue], 1234); OTAssertEqual([[self.stringClass stringWithString: @"\r\n+123 "] longLongValue], 123); OTAssertEqual([[self.stringClass stringWithString: @"-500\t"] longLongValue], -500); OTAssertEqual([[self.stringClass stringWithString: @"-0x10\t"] longLongValueWithBase: 0], -0x10); OTAssertEqual([[self.stringClass stringWithString: @"\t\t\r\n"] longLongValue], 0); OTAssertEqual([[self.stringClass stringWithString: @"123f"] longLongValueWithBase: 16], 0x123f); OTAssertEqual([[self.stringClass stringWithString: @"-1234"] longLongValueWithBase: 0], -1234); OTAssertEqual([[self.stringClass stringWithString: @"\t\n0xABcd\r"] longLongValueWithBase: 0], 0xABCD); OTAssertEqual([[self.stringClass stringWithString: @"1234567"] longLongValueWithBase: 8], 01234567); OTAssertEqual([[self.stringClass stringWithString: @"\r\n0123"] longLongValueWithBase: 0], 0123); OTAssertEqual([[self.stringClass stringWithString: @"765\t"] longLongValueWithBase: 8], 0765); OTAssertEqual([[self.stringClass stringWithString: @"\t\t\r\n"] longLongValueWithBase: 8], 0); } - (void)testLongLongValueThrowsOnInvalidFormat { OTAssertThrowsSpecific( [[self.stringClass stringWithString: @"abc"] longLongValue], OFInvalidFormatException); OTAssertThrowsSpecific( [[self.stringClass stringWithString: @"0a"] longLongValue], OFInvalidFormatException); OTAssertThrowsSpecific( [[self.stringClass stringWithString: @"0 1"] longLongValue], OFInvalidFormatException); OTAssertThrowsSpecific( [[self.stringClass stringWithString: @"0xABCDEFG"] longLongValueWithBase: 0], OFInvalidFormatException); OTAssertThrowsSpecific( [[self.stringClass stringWithString: @"0x"] longLongValueWithBase: 0], OFInvalidFormatException); } - (void)testLongLongValueThrowsOnOutOfRange { OTAssertThrowsSpecific([[self.stringClass stringWithString: @"-12345678901234567890123456789012345678901234567890" @"12345678901234567890123456789012345678901234567890"] longLongValueWithBase: 16], OFOutOfRangeException) } - (void)testUnsignedLongLongValue { OTAssertEqual([[self.stringClass stringWithString: @"1234"] unsignedLongLongValue], 1234); OTAssertEqual([[self.stringClass stringWithString: @"\r\n+123 "] unsignedLongLongValue], 123); OTAssertEqual([[self.stringClass stringWithString: @"\t\t\r\n"] unsignedLongLongValue], 0); OTAssertEqual([[self.stringClass stringWithString: @"123f"] unsignedLongLongValueWithBase: 16], 0x123f); OTAssertEqual([[self.stringClass stringWithString: @"1234"] unsignedLongLongValueWithBase: 0], 1234); OTAssertEqual([[self.stringClass stringWithString: @"\t\n0xABcd\r"] unsignedLongLongValueWithBase: 0], 0xABCD); OTAssertEqual([[self.stringClass stringWithString: @"1234567"] unsignedLongLongValueWithBase: 8], 01234567); OTAssertEqual([[self.stringClass stringWithString: @"\r\n0123"] unsignedLongLongValueWithBase: 0], 0123); OTAssertEqual([[self.stringClass stringWithString: @"765\t"] unsignedLongLongValueWithBase: 8], 0765); OTAssertEqual([[self.stringClass stringWithString: @"\t\t\r\n"] unsignedLongLongValueWithBase: 8], 0); } - (void)testUnsignedLongLongValueThrowsOnOutOfRange { OTAssertThrowsSpecific([[self.stringClass stringWithString: @"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" @"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"] unsignedLongLongValueWithBase: 16], OFOutOfRangeException); } - (void)testFloatValue { /* * These test numbers can be generated without rounding if we have IEEE * floating point numbers, thus we can use OTAssertEqual on them. */ OTAssertEqual([[self.stringClass stringWithString: @"\t-0.25 "] floatValue], -0.25); OTAssertEqual([[self.stringClass stringWithString: @"\r\n\tINF\t\n"] floatValue], INFINITY); OTAssertEqual([[self.stringClass stringWithString: @"\r -INFINITY\n"] floatValue], -INFINITY); OTAssertTrue(isnan([[self.stringClass stringWithString: @" NAN\t\t"] floatValue])); OTAssertTrue(isnan([[self.stringClass stringWithString: @" -NaN\t\t"] floatValue])); } - (void)testFloatValueThrowsOnInvalidFormat { OTAssertThrowsSpecific([[self.stringClass stringWithString: @"0.0a"] floatValue], OFInvalidFormatException); OTAssertThrowsSpecific([[self.stringClass stringWithString: @"0 0"] floatValue], OFInvalidFormatException); OTAssertThrowsSpecific([[self.stringClass stringWithString: @"0,0"] floatValue], OFInvalidFormatException); } - (void)testDoubleValue { #if (defined(OF_SOLARIS) && defined(OF_X86)) || defined(OF_AMIGAOS_M68K) /* * Solaris' strtod() has weird rounding on x86, but not on AMD64. * AmigaOS 3 with libnix has weird rounding as well. */ OTAssertEqual([[self.stringClass stringWithString: @"\t-0.125 "] doubleValue], -0.125); #elif defined(OF_ANDROID) || defined(OF_SOLARIS) || defined(OF_HPUX) || \ defined(OF_DJGPP) || defined(OF_AMIGAOS_M68K) /* * Android, Solaris, HP-UX, DJGPP and AmigaOS 3 do not accept 0x for * strtod(). */ OTAssertEqual([[self.stringClass stringWithString: @"\t-0.123456789 "] doubleValue], -0.123456789); #else OTAssertEqual([[self.stringClass stringWithString: @"\t-0x1.FFFFFFFFFFFFFP-1020 "] doubleValue], -0x1.FFFFFFFFFFFFFP-1020); #endif OTAssertEqual([[self.stringClass stringWithString: @"\r\n\tINF\t\n"] doubleValue], INFINITY); OTAssertEqual([[self.stringClass stringWithString: @"\r -INFINITY\n"] doubleValue], -INFINITY); OTAssert(isnan([[self.stringClass stringWithString: @" NAN\t\t"] doubleValue])); OTAssert(isnan([[self.stringClass stringWithString: @" -NaN\t\t"] doubleValue])); } - (void)testDoubleValueThrowsOnInvalidFormat { OTAssertThrowsSpecific([[self.stringClass stringWithString: @"0.0a"] doubleValue], OFInvalidFormatException); OTAssertThrowsSpecific([[self.stringClass stringWithString: @"0 0"] doubleValue], OFInvalidFormatException); OTAssertThrowsSpecific([[self.stringClass stringWithString: @"0,0"] doubleValue], OFInvalidFormatException); } - (void)testCharacters { OTAssertEqual(memcmp([[self.stringClass stringWithString: @"fööbär🀺"] characters], unicharString + 1, sizeof(unicharString) - 8), 0); } - (void)testUTF16String { OFString *string = [self.stringClass stringWithString: @"fööbär🀺"]; OTAssertEqual(memcmp(string.UTF16String, char16String + 1, OFUTF16StringLength(char16String) * 2), 0); #ifdef OF_BIG_ENDIAN OTAssertEqual(memcmp([string UTF16StringWithByteOrder: OFByteOrderLittleEndian], swappedChar16String + 1, OFUTF16StringLength(swappedChar16String) * 2), 0); #else OTAssertEqual(memcmp([string UTF16StringWithByteOrder: OFByteOrderBigEndian], swappedChar16String + 1, OFUTF16StringLength(swappedChar16String) * 2), 0); #endif } - (void)testUTF16StringLength { OTAssertEqual(_string.UTF16StringLength, 6); } - (void)testUTF32String { OFString *string = [self.stringClass stringWithString: @"fööbär🀺"]; OTAssertEqual(memcmp(string.UTF32String, unicharString + 1, OFUTF32StringLength(unicharString) * 4), 0); #ifdef OF_BIG_ENDIAN OTAssertEqual(memcmp([string UTF32StringWithByteOrder: OFByteOrderLittleEndian], swappedUnicharString + 1, OFUTF32StringLength(swappedUnicharString) * 4), 0); #else OTAssertEqual(memcmp([string UTF32StringWithByteOrder: OFByteOrderBigEndian], swappedUnicharString + 1, OFUTF32StringLength(swappedUnicharString) * 4), 0); #endif } - (void)testStringByMD5Hashing { OTAssertEqualObjects(_string.stringByMD5Hashing, @"7e6bef5fe100d93e808d15b1c6e6145a"); } - (void)testStringByRIPEMD160Hashing { OTAssertEqualObjects(_string.stringByRIPEMD160Hashing, @"2fd0ec899c55cf2821a2f844b9d80887fc351103"); } - (void)testStringBySHA1Hashing { OTAssertEqualObjects(_string.stringBySHA1Hashing, @"3f76f9358b372b7147344b7a3ba6d309e4466b3a"); } - (void)testStringBySHA224Hashing { OTAssertEqualObjects(_string.stringBySHA224Hashing, @"6e57ec72e4da55c46d88a15ce7ce4d8db83d0493a263134a3734259d"); } - (void)testStringBySHA256Hashing { OTAssertEqualObjects(_string.stringBySHA256Hashing, @"6eac4d3d0b4152c82ff88599482696ca" @"d6dca0b533e8a2e6963d995b19b0a683"); } - (void)testStringBySHA384Hashing { OTAssertEqualObjects(_string.stringBySHA384Hashing, @"d9bd6a671407d01cee4022888677040d" @"108dd0270c38e0ce755d6dcadb4bf9c1" @"89204dd2a51f954be55ea5d5fe00667b"); } - (void)testStringBySHA512Hashing { OTAssertEqualObjects(_string.stringBySHA512Hashing, @"64bec66b3633c585da6d32760fa3617a" @"47ca4c247472bdbbfb452b2dbf5a3612" @"5629053394a16ecd08f8a21d461537c5" @"f1224cbb379589e73dcd6763ec4f886c"); } - (void)testStringByAddingPercentEncodingWithAllowedCharacters { OFCharacterSet *characterSet = [OFCharacterSet characterSetWithCharactersInString: @"abfo'_~$🍏"]; OTAssertEqualObjects([[self.stringClass stringWithString: @"foo\"ba'_~$]🍏🍌"] stringByAddingPercentEncodingWithAllowedCharacters: characterSet], @"foo%22ba'_~$%5D🍏%F0%9F%8D%8C"); } - (void)testStringByRemovingPercentEncoding { OTAssertEqualObjects([[self.stringClass stringWithString: @"foo%20bar%22+%24%F0%9F%8D%8C"] stringByRemovingPercentEncoding], @"foo bar\"+$🍌"); } - (void)testStringByRemovingPercentEncodingThrowsOnInvalidFormat { OTAssertThrowsSpecific([[self.stringClass stringWithString: @"foo%xbar"] stringByRemovingPercentEncoding], OFInvalidFormatException); } - (void)testStringByRemovingPercentEncodingThrowsOnInvalidEncoding { OTAssertThrowsSpecific([[self.stringClass stringWithString: @"foo%FFbar"] stringByRemovingPercentEncoding], OFInvalidEncodingException); } - (void)testStringByXMLEscaping { OTAssertEqualObjects([[self.stringClass stringWithString: @"<hello> &world'\"!&"] stringByXMLEscaping], @"<hello> &world'"!&"); } - (void)testStringByXMLUnescaping { OTAssertEqualObjects([[self.stringClass stringWithString: @"<hello> &world'"!&"] stringByXMLUnescaping], @"<hello> &world'\"!&"); OTAssertEqualObjects([[self.stringClass stringWithString: @"y"] stringByXMLUnescaping], @"y"); OTAssertEqualObjects([[self.stringClass stringWithString: @"ä"] stringByXMLUnescaping], @"ä"); OTAssertEqualObjects([[self.stringClass stringWithString: @"€"] stringByXMLUnescaping], @"€"); OTAssertEqualObjects([[self.stringClass stringWithString: @"𝄞"] stringByXMLUnescaping], @"𝄞"); } - (void)testStringByXMLUnescapingThrowsOnUnknownEntities { OTAssertThrowsSpecific([[self.stringClass stringWithString: @"&foo;"] stringByXMLUnescaping], OFUnknownXMLEntityException); } - (void)testStringByXMLUnescapingThrowsOnInvalidFormat { OTAssertThrowsSpecific([[self.stringClass stringWithString: @"x&"] stringByXMLUnescaping], OFInvalidFormatException); OTAssertThrowsSpecific([[self.stringClass stringWithString: @"&#;"] stringByXMLUnescaping], OFInvalidFormatException); OTAssertThrowsSpecific([[self.stringClass stringWithString: @"&#x;"] stringByXMLUnescaping], OFInvalidFormatException); OTAssertThrowsSpecific([[self.stringClass stringWithString: @"&#g;"] stringByXMLUnescaping], OFInvalidFormatException); OTAssertThrowsSpecific([[self.stringClass stringWithString: @"&#xg;"] stringByXMLUnescaping], OFInvalidFormatException); } - (void)testStringByXMLUnescapingWithDelegate { EntityHandler *entityHandler = [[[EntityHandler alloc] init] autorelease]; OTAssertEqualObjects([[self.stringClass stringWithString: @"x&foo;y"] stringByXMLUnescapingWithDelegate: entityHandler], @"xbary"); } #ifdef OF_HAVE_BLOCKS - (void)testStringByXMLUnescapingWithBlock { OTAssertEqualObjects([[self.stringClass stringWithString: @"x&foo;y"] stringByXMLUnescapingWithBlock: ^ OFString * (OFString *string, OFString *entity) { if ([entity isEqual: @"foo"]) return @"bar"; return nil; }], @"xbary"); } - (void)testEnumerateLinesUsingBlock { __block size_t count = 0; [[self.stringClass stringWithString: @"foo\nbar\nbaz"] enumerateLinesUsingBlock: ^ (OFString *line, bool *stop) { switch (count++) { case 0: OTAssertEqualObjects(line, @"foo"); break; case 1: OTAssertEqualObjects(line, @"bar"); break; case 2: OTAssertEqualObjects(line, @"baz"); break; default: OTAssert(false); } }]; OTAssertEqual(count, 3); } #endif #ifdef OF_HAVE_FILES - (void)testIsAbsolutePath { # if defined(OF_WINDOWS) || defined(OF_MSDOS) OTAssertTrue( [[self.stringClass stringWithString: @"C:\\foo"] isAbsolutePath]); OTAssertTrue( [[self.stringClass stringWithString: @"a:/foo"] isAbsolutePath]); OTAssertFalse( [[self.stringClass stringWithString: @"foo"] isAbsolutePath]); OTAssertFalse( [[self.stringClass stringWithString: @"b:foo"] isAbsolutePath]); # ifdef OF_WINDOWS OTAssertTrue( [[self.stringClass stringWithString: @"\\\\foo"] isAbsolutePath]); # endif # elif defined(OF_AMIGAOS) OTAssertTrue( [[self.stringClass stringWithString: @"dh0:foo"] isAbsolutePath]); OTAssertTrue( [[self.stringClass stringWithString: @"dh0:a/b"] isAbsolutePath]); OTAssertFalse( [[self.stringClass stringWithString: @"foo/bar"] isAbsolutePath]); OTAssertFalse( [[self.stringClass stringWithString: @"foo"] isAbsolutePath]); # elif defined(OF_NINTENDO_DS) || defined(OF_NINTENDO_3DS) || \ defined(OF_WII) || defined(OF_NINTENDO_SWITCH) OTAssertTrue( [[self.stringClass stringWithString: @"sdmc:/foo"] isAbsolutePath]); OTAssertFalse( [[self.stringClass stringWithString: @"sdmc:foo"] isAbsolutePath]); OTAssertFalse( [[self.stringClass stringWithString: @"foo/bar"] isAbsolutePath]); OTAssertFalse( [[self.stringClass stringWithString: @"foo"] isAbsolutePath]); # else OTAssertTrue( [[self.stringClass stringWithString: @"/foo"] isAbsolutePath]); OTAssertTrue( [[self.stringClass stringWithString: @"/foo/bar"] isAbsolutePath]); OTAssertFalse( [[self.stringClass stringWithString: @"foo/bar"] isAbsolutePath]); OTAssertFalse( [[self.stringClass stringWithString: @"foo"] isAbsolutePath]); # endif } - (void)testStringByAppendingPathComponent { # if defined(OF_WINDOWS) || defined(OF_MSDOS) OTAssertEqualObjects([[self.stringClass stringWithString: @"foo\\bar"] stringByAppendingPathComponent: @"baz"], @"foo\\bar\\baz"); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo\\bar\\"] stringByAppendingPathComponent: @"baz"], @"foo\\bar\\baz"); # else OTAssertEqualObjects([[self.stringClass stringWithString: @"foo/bar"] stringByAppendingPathComponent: @"baz"], @"foo/bar/baz"); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo/bar/"] stringByAppendingPathComponent: @"baz"], @"foo/bar/baz"); # endif } - (void)testStringByAppendingPathExtension { # if defined(OF_WINDOWS) || defined(OF_MSDOS) OTAssertEqualObjects([[self.stringClass stringWithString: @"foo"] stringByAppendingPathExtension: @"bar"], @"foo.bar"); OTAssertEqualObjects([[self.stringClass stringWithString: @"c:\\tmp\\foo"] stringByAppendingPathExtension: @"bar"], @"c:\\tmp\\foo.bar"); OTAssertEqualObjects([[self.stringClass stringWithString: @"c:\\tmp\\/\\"] stringByAppendingPathExtension: @"bar"], @"c:\\tmp.bar"); # elif defined(OF_AMIGAOS) OTAssertEqualObjects([[self.stringClass stringWithString: @"foo"] stringByAppendingPathExtension: @"bar"], @"foo.bar"); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo/bar"] stringByAppendingPathExtension: @"baz"], @"foo/bar.baz"); # else OTAssertEqualObjects([[self.stringClass stringWithString: @"foo"] stringByAppendingPathExtension: @"bar"], @"foo.bar"); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo/bar"] stringByAppendingPathExtension: @"baz"], @"foo/bar.baz"); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo///"] stringByAppendingPathExtension: @"bar"], @"foo.bar"); # endif } - (void)testPathWithComponents { # if defined(OF_WINDOWS) || defined(OF_MSDOS) OTAssertEqualObjects([self.stringClass pathWithComponents: ([OFArray arrayWithObjects: @"foo", @"bar", @"baz", nil])], @"foo\\bar\\baz"); OTAssertEqualObjects([self.stringClass pathWithComponents: ([OFArray arrayWithObjects: @"c:\\", @"foo", @"bar", @"baz", nil])], @"c:\\foo\\bar\\baz"); OTAssertEqualObjects([self.stringClass pathWithComponents: ([OFArray arrayWithObjects: @"c:", @"foo", @"bar", @"baz", nil])], @"c:foo\\bar\\baz"); OTAssertEqualObjects([self.stringClass pathWithComponents: ([OFArray arrayWithObjects: @"c:", @"\\", @"foo", @"bar", @"baz", nil])], @"c:\\foo\\bar\\baz"); OTAssertEqualObjects([self.stringClass pathWithComponents: ([OFArray arrayWithObjects: @"c:", @"/", @"foo", @"bar", @"baz", nil])], @"c:/foo\\bar\\baz"); OTAssertEqualObjects([self.stringClass pathWithComponents: ([OFArray arrayWithObjects: @"foo/", @"bar\\", @"", @"baz", @"\\", nil])], @"foo/bar\\baz"); OTAssertEqualObjects([self.stringClass pathWithComponents: [OFArray arrayWithObject: @"foo"]], @"foo"); OTAssertEqualObjects([self.stringClass pathWithComponents: [OFArray arrayWithObject: @"c:"]], @"c:"); OTAssertEqualObjects([self.stringClass pathWithComponents: [OFArray arrayWithObject: @"c:\\"]], @"c:\\"); OTAssertEqualObjects([self.stringClass pathWithComponents: [OFArray arrayWithObject: @"\\"]], @"\\"); OTAssertEqualObjects([self.stringClass pathWithComponents: [OFArray arrayWithObject: @"/"]], @"/"); # ifdef OF_WINDOWS OTAssertEqualObjects([self.stringClass pathWithComponents: ([OFArray arrayWithObjects: @"\\\\", @"foo", @"bar", nil])], @"\\\\foo\\bar"); # endif # elif defined(OF_AMIGAOS) OTAssertEqualObjects([self.stringClass pathWithComponents: ([OFArray arrayWithObjects: @"dh0:", @"foo", @"bar", @"baz", nil])], @"dh0:foo/bar/baz"); OTAssertEqualObjects([self.stringClass pathWithComponents: ([OFArray arrayWithObjects: @"foo", @"bar", @"baz", nil])], @"foo/bar/baz"); OTAssertEqualObjects([self.stringClass pathWithComponents: ([OFArray arrayWithObjects: @"foo/", @"bar", @"", @"baz", @"/", nil])], @"foo//bar/baz//"); OTAssertEqualObjects([self.stringClass pathWithComponents: [OFArray arrayWithObject: @"foo"]], @"foo"); # elif defined(OF_WII) || defined(OF_NINTENDO_DS) || \ defined(OF_NINTENDO_3DS) || defined(OF_NINTENDO_SWITCH) OTAssertEqualObjects([self.stringClass pathWithComponents: ([OFArray arrayWithObjects: @"foo", @"bar", @"baz", nil])], @"foo/bar/baz"); OTAssertEqualObjects([self.stringClass pathWithComponents: ([OFArray arrayWithObjects: @"sdmc:", @"foo", @"bar", @"baz", nil])], @"sdmc:/foo/bar/baz"); OTAssertEqualObjects([self.stringClass pathWithComponents: ([OFArray arrayWithObjects: @"foo/", @"bar/", @"", @"baz", @"/", nil])], @"foo/bar/baz"); OTAssertEqualObjects([self.stringClass pathWithComponents: [OFArray arrayWithObject: @"foo"]], @"foo"); OTAssertEqualObjects([self.stringClass pathWithComponents: [OFArray arrayWithObject: @"sdmc:"]], @"sdmc:/"); # else OTAssertEqualObjects([self.stringClass pathWithComponents: ([OFArray arrayWithObjects: @"/", @"foo", @"bar", @"baz", nil])], @"/foo/bar/baz"); OTAssertEqualObjects([self.stringClass pathWithComponents: ([OFArray arrayWithObjects: @"foo", @"bar", @"baz", nil])], @"foo/bar/baz"); OTAssertEqualObjects([self.stringClass pathWithComponents: ([OFArray arrayWithObjects: @"foo/", @"bar", @"", @"baz", @"/", nil])], @"foo/bar/baz"); OTAssertEqualObjects([self.stringClass pathWithComponents: [OFArray arrayWithObject: @"foo"]], @"foo"); # endif } - (void)testPathComponents { # if defined(OF_WINDOWS) || defined(OF_MSDOS) OTAssertEqualObjects([[self.stringClass stringWithString: @"c:/tmp"] pathComponents], ([OFArray arrayWithObjects: @"c:/", @"tmp", nil])); OTAssertEqualObjects([[self.stringClass stringWithString: @"c:\\tmp\\"] pathComponents], ([OFArray arrayWithObjects: @"c:\\", @"tmp", nil])); OTAssertEqualObjects([[self.stringClass stringWithString: @"c:\\"] pathComponents], [OFArray arrayWithObject: @"c:\\"]); OTAssertEqualObjects([[self.stringClass stringWithString: @"c:/"] pathComponents], [OFArray arrayWithObject: @"c:/"]); OTAssertEqualObjects([[self.stringClass stringWithString: @"c:"] pathComponents], [OFArray arrayWithObject: @"c:"]); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo\\bar"] pathComponents], ([OFArray arrayWithObjects: @"foo", @"bar", nil])); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo\\bar/baz/"] pathComponents], ([OFArray arrayWithObjects: @"foo", @"bar", @"baz", nil])); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo\\/"] pathComponents], [OFArray arrayWithObject: @"foo"]); # ifdef OF_WINDOWS OTAssertEqualObjects([[self.stringClass stringWithString: @"\\\\foo\\bar"] pathComponents], ([OFArray arrayWithObjects: @"\\\\", @"foo", @"bar", nil])); # endif OTAssertEqualObjects([[self.stringClass stringWithString: @""] pathComponents], [OFArray array]); # elif defined(OF_AMIGAOS) OTAssertEqualObjects([[self.stringClass stringWithString: @"dh0:tmp"] pathComponents], ([OFArray arrayWithObjects: @"dh0:", @"tmp", nil])); OTAssertEqualObjects([[self.stringClass stringWithString: @"dh0:tmp/"] pathComponents], ([OFArray arrayWithObjects: @"dh0:", @"tmp", nil])); OTAssertEqualObjects([[self.stringClass stringWithString: @"dh0:/"] pathComponents], ([OFArray arrayWithObjects: @"dh0:", @"/", nil])); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo/bar"] pathComponents], ([OFArray arrayWithObjects: @"foo", @"bar", nil])); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo/bar/baz/"] pathComponents], ([OFArray arrayWithObjects: @"foo", @"bar", @"baz", nil])); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo//"] pathComponents], ([OFArray arrayWithObjects: @"foo", @"/", nil])); OTAssertEqualObjects([[self.stringClass stringWithString: @""] pathComponents], [OFArray array]); # elif defined(OF_NINTENDO_3DS) || defined(OF_WII) || \ defined(OF_NINTENDO_SWITCH) OTAssertEqualObjects([[self.stringClass stringWithString: @"sdmc:/tmp"] pathComponents], ([OFArray arrayWithObjects: @"sdmc:", @"tmp", nil])); OTAssertEqualObjects([[self.stringClass stringWithString: @"sdmc:/"] pathComponents], [OFArray arrayWithObject: @"sdmc:"]); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo/bar"] pathComponents], ([OFArray arrayWithObjects: @"foo", @"bar", nil])); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo/bar/baz/"] pathComponents], ([OFArray arrayWithObjects: @"foo", @"bar", @"baz", nil])); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo//"] pathComponents], [OFArray arrayWithObject: @"foo"]); OTAssertEqualObjects([[self.stringClass stringWithString: @""] pathComponents], [OFArray array]); # else OTAssertEqualObjects([[self.stringClass stringWithString: @"/tmp"] pathComponents], ([OFArray arrayWithObjects: @"/", @"tmp", nil])); OTAssertEqualObjects([[self.stringClass stringWithString: @"/tmp/"] pathComponents], ([OFArray arrayWithObjects: @"/", @"tmp", nil])); OTAssertEqualObjects([[self.stringClass stringWithString: @"/"] pathComponents], [OFArray arrayWithObject: @"/"]); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo/bar"] pathComponents], ([OFArray arrayWithObjects: @"foo", @"bar", nil])); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo/bar/baz/"] pathComponents], ([OFArray arrayWithObjects: @"foo", @"bar", @"baz", nil])); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo//"] pathComponents], [OFArray arrayWithObject: @"foo"]); OTAssertEqualObjects([[self.stringClass stringWithString: @""] pathComponents], [OFArray array]); # endif } - (void)testLastPathComponent { # if defined(OF_WINDOWS) || defined(OF_MSDOS) OTAssertEqualObjects([[self.stringClass stringWithString: @"c:/tmp"] lastPathComponent], @"tmp"); OTAssertEqualObjects([[self.stringClass stringWithString: @"c:\\tmp\\"] lastPathComponent], @"tmp"); OTAssertEqualObjects([[self.stringClass stringWithString: @"c:\\"] lastPathComponent], @"c:\\"); OTAssertEqualObjects([[self.stringClass stringWithString: @"c:/"] lastPathComponent], @"c:/"); OTAssertEqualObjects([[self.stringClass stringWithString: @"\\"] lastPathComponent], @"\\"); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo"] lastPathComponent], @"foo"); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo\\bar"] lastPathComponent], @"bar"); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo/bar/baz/"] lastPathComponent], @"baz"); # ifdef OF_WINDOWS OTAssertEqualObjects([[self.stringClass stringWithString: @"\\\\foo\\bar"] lastPathComponent], @"bar"); OTAssertEqualObjects([[self.stringClass stringWithString: @"\\\\"] lastPathComponent], @"\\\\"); # endif # elif defined(OF_AMIGAOS) OTAssertEqualObjects([[self.stringClass stringWithString: @"dh0:tmp"] lastPathComponent], @"tmp"); OTAssertEqualObjects([[self.stringClass stringWithString: @"dh0:tmp/"] lastPathComponent], @"tmp"); OTAssertEqualObjects([[self.stringClass stringWithString: @"dh0:/"] lastPathComponent], @"/"); OTAssertEqualObjects([[self.stringClass stringWithString: @"dh0:"] lastPathComponent], @"dh0:"); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo"] lastPathComponent], @"foo"); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo/bar"] lastPathComponent], @"bar"); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo/bar/baz/"] lastPathComponent], @"baz"); # elif defined(OF_WII) || defined(OF_NINTENDO_DS) || \ defined(OF_NINTENDO_3DS) || defined(OF_NINTENDO_SWITCH) OTAssertEqualObjects([[self.stringClass stringWithString: @"sdmc:/tmp"] lastPathComponent], @"tmp"); OTAssertEqualObjects([[self.stringClass stringWithString: @"sdmc:/tmp/"] lastPathComponent], @"tmp"); OTAssertEqualObjects([[self.stringClass stringWithString: @"sdmc:/"] lastPathComponent], @"sdmc:/"); OTAssertEqualObjects([[self.stringClass stringWithString: @"sdmc:"] lastPathComponent], @"sdmc:"); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo"] lastPathComponent], @"foo"); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo/bar"] lastPathComponent], @"bar"); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo/bar/baz/"] lastPathComponent], @"baz"); # else OTAssertEqualObjects([[self.stringClass stringWithString: @"/tmp"] lastPathComponent], @"tmp"); OTAssertEqualObjects([[self.stringClass stringWithString: @"/tmp/"] lastPathComponent], @"tmp"); OTAssertEqualObjects([[self.stringClass stringWithString: @"/"] lastPathComponent], @"/"); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo"] lastPathComponent], @"foo"); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo/bar"] lastPathComponent], @"bar"); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo/bar/baz/"] lastPathComponent], @"baz"); # endif } - (void)testPathExtension { OTAssertEqualObjects([[self.stringClass stringWithString: @"foo.bar"] pathExtension], @"bar"); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo/.bar"] pathExtension], @""); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo/.bar.baz"] pathExtension], @"baz"); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo/bar.baz/"] pathExtension], @"baz"); } - (void)testStringByDeletingLastPathComponent { # if defined(OF_WINDOWS) || defined(OF_MSDOS) OTAssertEqualObjects([[self.stringClass stringWithString: @"\\tmp"] stringByDeletingLastPathComponent], @"\\"); OTAssertEqualObjects([[self.stringClass stringWithString: @"/tmp/"] stringByDeletingLastPathComponent], @"/"); OTAssertEqualObjects([[self.stringClass stringWithString: @"c:\\"] stringByDeletingLastPathComponent], @"c:\\"); OTAssertEqualObjects([[self.stringClass stringWithString: @"c:/"] stringByDeletingLastPathComponent], @"c:/"); OTAssertEqualObjects([[self.stringClass stringWithString: @"c:\\tmp/foo/"] stringByDeletingLastPathComponent], @"c:\\tmp"); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo\\bar"] stringByDeletingLastPathComponent], @"foo"); OTAssertEqualObjects([[self.stringClass stringWithString: @"\\"] stringByDeletingLastPathComponent], @"\\"); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo"] stringByDeletingLastPathComponent], @"."); # ifdef OF_WINDOWS OTAssertEqualObjects([[self.stringClass stringWithString: @"\\\\foo\\bar"] stringByDeletingLastPathComponent], @"\\\\foo"); OTAssertEqualObjects([[self.stringClass stringWithString: @"\\\\foo"] stringByDeletingLastPathComponent], @"\\\\"); OTAssertEqualObjects([[self.stringClass stringWithString: @"\\\\"] stringByDeletingLastPathComponent], @"\\\\"); # endif # elif defined(OF_AMIGAOS) OTAssertEqualObjects([[self.stringClass stringWithString: @"dh0:"] stringByDeletingLastPathComponent], @"dh0:"); OTAssertEqualObjects([[self.stringClass stringWithString: @"dh0:tmp"] stringByDeletingLastPathComponent], @"dh0:"); OTAssertEqualObjects([[self.stringClass stringWithString: @"dh0:tmp/"] stringByDeletingLastPathComponent], @"dh0:"); OTAssertEqualObjects([[self.stringClass stringWithString: @"dh0:/"] stringByDeletingLastPathComponent], @"dh0:"); OTAssertEqualObjects([[self.stringClass stringWithString: @"dh0:tmp/foo/"] stringByDeletingLastPathComponent], @"dh0:tmp"); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo/bar"] stringByDeletingLastPathComponent], @"foo"); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo"] stringByDeletingLastPathComponent], @""); # elif defined(OF_NINTENDO_3DS) || defined(OF_WII) || \ defined(OF_NINTENDO_SWITCH) OTAssertEqualObjects([[self.stringClass stringWithString: @"/tmp/"] stringByDeletingLastPathComponent], @""); OTAssertEqualObjects([[self.stringClass stringWithString: @"sdmc:/tmp/foo/"] stringByDeletingLastPathComponent], @"sdmc:/tmp"); OTAssertEqualObjects([[self.stringClass stringWithString: @"sdmc:/"] stringByDeletingLastPathComponent], @"sdmc:/"); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo/bar"] stringByDeletingLastPathComponent], @"foo"); OTAssertEqualObjects([[self.stringClass stringWithString: @"/"] stringByDeletingLastPathComponent], @""); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo"] stringByDeletingLastPathComponent], @"."); # else OTAssertEqualObjects([[self.stringClass stringWithString: @"/tmp"] stringByDeletingLastPathComponent], @"/"); OTAssertEqualObjects([[self.stringClass stringWithString: @"/tmp/"] stringByDeletingLastPathComponent], @"/"); OTAssertEqualObjects([[self.stringClass stringWithString: @"/tmp/foo/"] stringByDeletingLastPathComponent], @"/tmp"); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo/bar"] stringByDeletingLastPathComponent], @"foo"); OTAssertEqualObjects([[self.stringClass stringWithString: @"/"] stringByDeletingLastPathComponent], @"/"); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo"] stringByDeletingLastPathComponent], @"."); # endif } - (void)testStringByDeletingPathExtension { # if defined(OF_WINDOWS) || defined(OF_MSDOS) OTAssertEqualObjects([[self.stringClass stringWithString: @"foo.bar"] stringByDeletingPathExtension], @"foo"); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo..bar"] stringByDeletingPathExtension], @"foo."); OTAssertEqualObjects([[self.stringClass stringWithString: @"c:/foo.\\bar"] stringByDeletingPathExtension], @"c:/foo.\\bar"); OTAssertEqualObjects([[self.stringClass stringWithString: @"c:\\foo./bar.baz"] stringByDeletingPathExtension], @"c:\\foo.\\bar"); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo.bar/"] stringByDeletingPathExtension], @"foo"); OTAssertEqualObjects([[self.stringClass stringWithString: @".foo"] stringByDeletingPathExtension], @".foo"); OTAssertEqualObjects([[self.stringClass stringWithString: @".foo.bar"] stringByDeletingPathExtension], @".foo"); # elif defined(OF_AMIGAOS) OTAssertEqualObjects([[self.stringClass stringWithString: @"foo.bar"] stringByDeletingPathExtension], @"foo"); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo..bar"] stringByDeletingPathExtension], @"foo."); OTAssertEqualObjects([[self.stringClass stringWithString: @"dh0:foo.bar"] stringByDeletingPathExtension], @"dh0:foo"); OTAssertEqualObjects([[self.stringClass stringWithString: @"dh0:foo./bar"] stringByDeletingPathExtension], @"dh0:foo./bar"); OTAssertEqualObjects([[self.stringClass stringWithString: @"dh0:foo./bar.baz"] stringByDeletingPathExtension], @"dh0:foo./bar"); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo.bar/"] stringByDeletingPathExtension], @"foo"); OTAssertEqualObjects([[self.stringClass stringWithString: @".foo"] stringByDeletingPathExtension], @".foo"); OTAssertEqualObjects([[self.stringClass stringWithString: @".foo\\bar"] stringByDeletingPathExtension], @".foo\\bar"); OTAssertEqualObjects([[self.stringClass stringWithString: @".foo.bar"] stringByDeletingPathExtension], @".foo"); # elif defined(OF_WII) || defined(OF_NINTENDO_DS) || \ defined(OF_NINTENDO_3DS) || defined(OF_NINTENDO_SWITCH) OTAssertEqualObjects([[self.stringClass stringWithString: @"foo.bar"] stringByDeletingPathExtension], @"foo"); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo..bar"] stringByDeletingPathExtension], @"foo."); OTAssertEqualObjects([[self.stringClass stringWithString: @"sdmc:/foo./bar"] stringByDeletingPathExtension], @"sdmc:/foo./bar"); OTAssertEqualObjects([[self.stringClass stringWithString: @"sdmc:/foo./bar.baz"] stringByDeletingPathExtension], @"sdmc:/foo./bar"); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo.bar/"] stringByDeletingPathExtension], @"foo"); OTAssertEqualObjects([[self.stringClass stringWithString: @".foo"] stringByDeletingPathExtension], @".foo"); OTAssertEqualObjects([[self.stringClass stringWithString: @".foo.bar"] stringByDeletingPathExtension], @".foo"); # else OTAssertEqualObjects([[self.stringClass stringWithString: @"foo.bar"] stringByDeletingPathExtension], @"foo"); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo..bar"] stringByDeletingPathExtension], @"foo."); OTAssertEqualObjects([[self.stringClass stringWithString: @"/foo./bar"] stringByDeletingPathExtension], @"/foo./bar"); OTAssertEqualObjects([[self.stringClass stringWithString: @"/foo./bar.baz"] stringByDeletingPathExtension], @"/foo./bar"); OTAssertEqualObjects([[self.stringClass stringWithString: @"foo.bar/"] stringByDeletingPathExtension], @"foo"); OTAssertEqualObjects([[self.stringClass stringWithString: @".foo"] stringByDeletingPathExtension], @".foo"); OTAssertEqualObjects([[self.stringClass stringWithString: @".foo\\bar"] stringByDeletingPathExtension], @".foo\\bar"); OTAssertEqualObjects([[self.stringClass stringWithString: @".foo.bar"] stringByDeletingPathExtension], @".foo"); # endif } # if defined(OF_WINDOWS) || defined(OF_MSDOS) - (void)testStringByStandardizingPath { /* TODO: Add more tests */ OTAssertEqualObjects([[self.stringClass stringWithString: @"c:\\..\\asd"] stringByStandardizingPath], @"c:\\..\\asd"); # ifndef OF_MSDOS OTAssertEqualObjects([[self.stringClass stringWithString: @"\\\\foo\\..\\bar\\qux"] stringByStandardizingPath], @"\\\\bar\\qux"); # endif } # endif #endif @end @implementation CustomString - (instancetype)init { self = [super init]; @try { _string = [[OFMutableString alloc] init]; } @catch (id e) { |
︙ | ︙ | |||
176 177 178 179 180 181 182 | - (size_t)length { return _string.length; } @end | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 | - (size_t)length { return _string.length; } @end @implementation EntityHandler - (OFString *)string: (OFString *)string containsUnknownEntityNamed: (OFString *)entity { if ([entity isEqual: @"foo"]) return @"bar"; return nil; } @end |
Added tests/OFSubprocessTests.m version [d547a0d972].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFW.h" #import "ObjFWTest.h" @interface OFSubprocessTests: OTTestCase @end @implementation OFSubprocessTests - (void)testSubprocess { #ifdef OF_HAVE_FILES OFString *program = [@"subprocess" stringByAppendingPathComponent: @"subprocess" @PROG_SUFFIX]; #else OFString *program = @"subprocess/subprocess" @PROG_SUFFIX; #endif OFArray *arguments = [OFArray arrayWithObjects: @"tést", @"123", nil]; OFMutableDictionary *environment = [[[OFApplication environment] mutableCopy] autorelease]; OFSubprocess *subprocess; [environment setObject: @"yés" forKey: @"tëst"]; subprocess = [OFSubprocess subprocessWithProgram: program programName: program arguments: arguments environment: environment]; [subprocess writeLine: @"Hellö world!"]; #ifdef OF_HAVE_UNICODE_TABLES OTAssertEqualObjects([subprocess readLine], @"HELLÖ WORLD!"); #else OTAssertEqualObjects([subprocess readLine], @"HELLö WORLD!"); #endif [subprocess closeForWriting]; OTAssertEqual([subprocess waitForTermination], 0); } @end |
Modified tests/OFSystemInfoTests.m from [5b9edfd152] to [9d8e320163].
1 | /* | | | | | | > > > > | < > | | > < | > | > | > | > | > > > > | > | > | < < | > | | > | | | > > > > < > > | > > > > > > | | | < | | | | > > > | < < | < | | < < | < < | | | > > | | | > > > > > > > > | | | > > | | < | | | > | | < | | | > | | | > | | | > | | | > | | | > | < | > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFW.h" #import "ObjFWTest.h" @interface OFSystemInfoTests: OTTestCase @end #ifdef OF_HAVE_SOCKETS static void appendAddresses(OFMutableString *string, OFData *addresses, bool *firstAddress) { size_t count = addresses.count; for (size_t i = 0; i < count; i++) { const OFSocketAddress *address = [addresses itemAtIndex: i]; if (!*firstAddress) [string appendString: @", "]; *firstAddress = false; [string appendString: OFSocketAddressString(address)]; } } #endif @implementation OFSystemInfoTests + (OFArray OF_GENERIC(OFPair OF_GENERIC(OFString *, id) *) *)summary { OFMutableArray *summary = [OFMutableArray array]; #ifdef OF_HAVE_SOCKETS OFDictionary *networkInterfaces; OFMutableString *networkInterfacesString; bool firstInterface = true; #endif #define ADD(name, value) \ [summary addObject: [OFPair pairWithFirstObject: name \ secondObject: value]]; #define ADD_UINT(name, value) \ ADD(name, [OFNumber numberWithUnsignedInt: value]); #define ADD_ULONGLONG(name, value) \ ADD(name, [OFNumber numberWithUnsignedLongLong: value]); #define ADD_BOOL(name, value) \ ADD(name, [OFNumber numberWithBool: value]); ADD(@"ObjFW version", [OFSystemInfo ObjFWVersion]) ADD_UINT(@"ObjFW version major", [OFSystemInfo ObjFWVersionMajor]) ADD_UINT(@"ObjFW version minor", [OFSystemInfo ObjFWVersionMinor]) ADD(@"Operating system name", [OFSystemInfo operatingSystemName]); ADD(@"Operating system version", [OFSystemInfo operatingSystemVersion]); #ifdef OF_WINDOWS ADD(@"Wine version", [OFSystemInfo wineVersion]); #endif ADD_ULONGLONG(@"Page size", [OFSystemInfo pageSize]); ADD_ULONGLONG(@"Number of CPUs", [OFSystemInfo numberOfCPUs]); ADD(@"User config IRI", [OFSystemInfo userConfigIRI].string); ADD(@"User data IRI", [OFSystemInfo userDataIRI].string); ADD(@"Temporary directory IRI", [OFSystemInfo temporaryDirectoryIRI].string); ADD(@"CPU vendor", [OFSystemInfo CPUVendor]); ADD(@"CPU model", [OFSystemInfo CPUModel]); #if defined(OF_AMD64) || defined(OF_X86) ADD_BOOL(@"Supports MMX", [OFSystemInfo supportsMMX]); ADD_BOOL(@"Supports 3DNow!", [OFSystemInfo supports3DNow]); ADD_BOOL(@"Supports enhanced 3DNow!", [OFSystemInfo supportsEnhanced3DNow]); ADD_BOOL(@"Supports SSE", [OFSystemInfo supportsSSE]); ADD_BOOL(@"Supports SSE2", [OFSystemInfo supportsSSE2]); ADD_BOOL(@"Supports SSE3", [OFSystemInfo supportsSSE3]); ADD_BOOL(@"Supports SSSE3", [OFSystemInfo supportsSSSE3]); ADD_BOOL(@"Supports SSE4.1", [OFSystemInfo supportsSSE41]); ADD_BOOL(@"Supports SSE4.2", [OFSystemInfo supportsSSE42]); ADD_BOOL(@"Supports AVX", [OFSystemInfo supportsAVX]); ADD_BOOL(@"Supports AVX2", [OFSystemInfo supportsAVX2]); ADD_BOOL(@"Supports AES-NI", [OFSystemInfo supportsAESNI]); ADD_BOOL(@"Supports SHA extensions", [OFSystemInfo supportsSHAExtensions]); ADD_BOOL(@"Supports fused multiply-add", [OFSystemInfo supportsFusedMultiplyAdd]); ADD_BOOL(@"Supports F16C", [OFSystemInfo supportsF16C]); ADD_BOOL(@"Supports AVX-512 Foundation", [OFSystemInfo supportsAVX512Foundation]); ADD_BOOL(@"Supports AVX-512 Conflict Detection Instructions", [OFSystemInfo supportsAVX512ConflictDetectionInstructions]); ADD_BOOL(@"Supports AVX-512 Exponential and Reciprocal Instructions", [OFSystemInfo supportsAVX512ExponentialAndReciprocalInstructions]); ADD_BOOL(@"Supports AVX-512 Prefetch Instructions", [OFSystemInfo supportsAVX512PrefetchInstructions]); ADD_BOOL(@"Supports AVX-512 Vector Length Extensions", [OFSystemInfo supportsAVX512VectorLengthExtensions]); ADD_BOOL(@"Supports AVX-512 Doubleword and Quadword Instructions", [OFSystemInfo supportsAVX512DoublewordAndQuadwordInstructions]); ADD_BOOL(@"Supports AVX-512 Byte and Word Instructions", [OFSystemInfo supportsAVX512ByteAndWordInstructions]); ADD_BOOL(@"Supports AVX-512 Integer Fused Multiply Add", [OFSystemInfo supportsAVX512IntegerFusedMultiplyAdd]); ADD_BOOL(@"Supports AVX-512 Vector Byte Manipulation Instructions", [OFSystemInfo supportsAVX512VectorByteManipulationInstructions]); ADD_BOOL(@"Supports AVX-512 Vector Population Count Instruction", [OFSystemInfo supportsAVX512VectorPopulationCountInstruction]); ADD_BOOL(@"Supports AVX-512 Vector Neutral Network Instructions", [OFSystemInfo supportsAVX512VectorNeuralNetworkInstructions]); ADD_BOOL(@"Supports AVX-512 Vector Byte Manipulation Instructions 2", [OFSystemInfo supportsAVX512VectorByteManipulationInstructions2]); ADD_BOOL(@"Supports AVX-512 Bit Algorithms", [OFSystemInfo supportsAVX512BitAlgorithms]); ADD_BOOL(@"Supports AVX-512 Float16 Instructions", [OFSystemInfo supportsAVX512Float16Instructions]); ADD_BOOL(@"Supports AVX-512 BFloat16 Instructions", [OFSystemInfo supportsAVX512BFloat16Instructions]); #endif #ifdef OF_POWERPC ADD_BOOL(@"Supports AltiVec", [OFSystemInfo supportsAltiVec]); #endif #undef ADD #undef ADD_UINT #undef ADD_ULONGLONG #undef ADD_BOOL #ifdef OF_HAVE_SOCKETS networkInterfaces = [OFSystemInfo networkInterfaces]; networkInterfacesString = [OFMutableString string]; for (OFString *name in networkInterfaces) { bool firstAddress = true; OFNetworkInterface interface; OFData *hardwareAddress; if (!firstInterface) [networkInterfacesString appendString: @"; "]; firstInterface = false; [networkInterfacesString appendFormat: @"%@(", name]; interface = [networkInterfaces objectForKey: name]; appendAddresses(networkInterfacesString, [interface objectForKey: OFNetworkInterfaceIPv4Addresses], &firstAddress); # ifdef OF_HAVE_IPV6 appendAddresses(networkInterfacesString, [interface objectForKey: OFNetworkInterfaceIPv6Addresses], &firstAddress); # endif # ifdef OF_HAVE_IPX appendAddresses(networkInterfacesString, [interface objectForKey: OFNetworkInterfaceIPXAddresses], &firstAddress); # endif # ifdef OF_HAVE_APPLETALK appendAddresses(networkInterfacesString, [interface objectForKey: OFNetworkInterfaceAppleTalkAddresses], &firstAddress); # endif hardwareAddress = [interface objectForKey: OFNetworkInterfaceHardwareAddress]; if (hardwareAddress != nil) { const unsigned char *bytes = hardwareAddress.items; size_t length = hardwareAddress.count; if (!firstAddress) [networkInterfacesString appendString: @", "]; for (size_t i = 0; i < length; i++) { if (i > 0) [networkInterfacesString appendString: @":"]; [networkInterfacesString appendFormat: @"%02X", bytes[i]]; } } [networkInterfacesString appendString: @")"]; } [summary addObject: [OFPair pairWithFirstObject: @"Network interfaces" secondObject: networkInterfacesString]]; #endif return summary; } @end |
Modified tests/OFTCPSocketTests.m from [e205251e21] to [69896382b4].
1 | /* | | | | | | > > > > | < > | | > | > | | < | < > | | < | < | < | > | < < | | | < | | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "ObjFW.h" #import "ObjFWTest.h" @interface OFTCPSocketTests: OTTestCase @end @implementation OFTCPSocketTests - (void)testTCPSocket { OFTCPSocket *server, *client, *accepted; OFSocketAddress address; char buffer[6]; server = [OFTCPSocket socket]; client = [OFTCPSocket socket]; address = [server bindToHost: @"127.0.0.1" port: 0]; [server listen]; [client connectToHost: @"127.0.0.1" port: OFSocketAddressIPPort(&address)]; accepted = [server accept]; OTAssertEqualObjects(OFSocketAddressString(accepted.remoteAddress), @"127.0.0.1"); [client writeString: @"Hello!"]; [accepted readIntoBuffer: buffer exactLength: 6]; OTAssertEqual(memcmp(buffer, "Hello!", 6), 0); } @end |
Added tests/OFTarArchiveTests.m version [7579e530c5].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFW.h" #import "ObjFWTest.h" #define bufferSize 4096 @interface OFTarArchiveTests: OTTestCase { char _buffer[bufferSize]; } @end @implementation OFTarArchiveTests - (void)testCreateAndExtractArchive { OFMemoryStream *stream = [OFMemoryStream streamWithMemoryAddress: _buffer size: bufferSize writable: true]; OFTarArchive *archive = [OFTarArchive archiveWithStream: stream mode: @"w"]; OFMutableTarArchiveEntry *entry = [OFMutableTarArchiveEntry entryWithFileName: @"testfile.txt"]; OFTarArchiveEntry *entry2; OFStream *entryStream; size_t size; entry.uncompressedSize = 12; entryStream = [archive streamForWritingEntry: entry]; [entryStream writeString: @"Hello World!"]; [archive close]; size = (size_t)[stream seekToOffset: 0 whence: OFSeekCurrent]; OTAssertLessThanOrEqual(size, bufferSize); stream = [OFMemoryStream streamWithMemoryAddress: _buffer size: size writable: false]; archive = [OFTarArchive archiveWithStream: stream mode: @"r"]; entry2 = [archive nextEntry]; OTAssertEqualObjects(entry2.fileName, @"testfile.txt"); entryStream = [archive streamForReadingCurrentEntry]; OTAssertEqualObjects([entryStream readLine], @"Hello World!"); OTAssertNil([entryStream readLine]); OTAssertNil([archive nextEntry]); } @end |
Modified tests/OFThreadTests.m from [3abe7860ab] to [09a3605776].
1 | /* | | | | | | > > > > | < > | | > | > | | < | < < | < | < | | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFW.h" #import "ObjFWTest.h" @interface OFThreadTests: OTTestCase @end @interface TestThread: OFThread @end @implementation TestThread - (id)main { [[OFThread threadDictionary] setObject: @"bar" forKey: @"foo"]; OFEnsure([[[OFThread threadDictionary] objectForKey: @"foo"] isEqual: @"bar"]); return @"success"; } @end @implementation OFThreadTests - (void)testThread { TestThread *thread = [TestThread thread]; [thread start]; OTAssertEqualObjects([thread join], @"success"); OTAssertNil([[OFThread threadDictionary] objectForKey: @"foo"]); } @end |
Modified tests/OFUDPSocketTests.m from [435a3297c3] to [5ea8498a1f].
1 | /* | | | | | | > > > > | < > | | > | > | | < | < | | | < | | < < | < | | | | < < < < < < < < < < < | < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "ObjFW.h" #import "ObjFWTest.h" @interface OFUDPSocketTests: OTTestCase @end @implementation OFUDPSocketTests - (void)testUDPSocket { OFUDPSocket *sock = [OFUDPSocket socket]; OFSocketAddress addr1, addr2; char buffer[6]; sock = [OFUDPSocket socket]; addr1 = [sock bindToHost: @"127.0.0.1" port: 0]; OTAssertEqualObjects(OFSocketAddressString(&addr1), @"127.0.0.1"); [sock sendBuffer: "Hello" length: 6 receiver: &addr1]; [sock receiveIntoBuffer: buffer length: 6 sender: &addr2]; OTAssertEqual(memcmp(buffer, "Hello", 6), 0); OTAssertEqualObjects(OFSocketAddressString(&addr2), @"127.0.0.1"); OTAssertEqual(OFSocketAddressIPPort(&addr2), OFSocketAddressIPPort(&addr1)); } @end |
Modified tests/OFUNIXDatagramSocketTests.m from [61f9f2c60c] to [4c8636fec8].
1 | /* | | | | | | > > > > | < > | > | > | > | | < > < | | | < < | < < < | < < < < < | < | | | | | | | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #include <string.h> #import "ObjFW.h" #import "ObjFWTest.h" @interface OFUNIXDatagramSocketTests: OTTestCase @end @implementation OFUNIXDatagramSocketTests - (void)testUNIXDatagramSocket { OFUNIXDatagramSocket *sock = [OFUNIXDatagramSocket socket]; OFString *path; OFSocketAddress address1, address2; char buffer[5]; #if defined(OF_HAVE_FILES) && !defined(OF_IOS) path = [[OFSystemInfo temporaryDirectoryIRI] IRIByAppendingPathComponent: [[OFUUID UUID] UUIDString]] .fileSystemRepresentation; #else /* * We can have sockets, including UNIX sockets, while file support is * disabled. * * We also use this code path for iOS, as the temporaryDirectoryIRI is * too long on the iOS simulator. */ path = [OFString stringWithFormat: @"/tmp/%@", [[OFUUID UUID] UUIDString]]; #endif @try { address1 = [sock bindToPath: path]; } @catch (OFBindSocketFailedException *e) { switch (e.errNo) { case EAFNOSUPPORT: case EPERM: OTSkip(@"UNIX datagram sockets unsupported"); default: @throw e; } } @try { [sock sendBuffer: "Hello" length: 5 receiver: &address1]; OTAssertEqual([sock receiveIntoBuffer: buffer length: 5 sender: &address2], 5); OTAssertEqual(memcmp(buffer, "Hello", 5), 0); OTAssertTrue(OFSocketAddressEqual(&address1, &address2)); OTAssertEqual(OFSocketAddressHash(&address1), OFSocketAddressHash(&address2)); } @finally { #ifdef OF_HAVE_FILES [[OFFileManager defaultManager] removeItemAtPath: path]; #endif } } @end |
Modified tests/OFUNIXStreamSocketTests.m from [cebf3c029f] to [29e0656238].
1 | /* | | | | | | > > > > | < > | > | > | > | | < | | | | | | < < < | < < < | < | | < < | < | | | | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #include <string.h> #import "ObjFW.h" #import "ObjFWTest.h" @interface OFUNIXStreamSocketTests: OTTestCase @end @implementation OFUNIXStreamSocketTests - (void)testUNIXStreamSocket { OFString *path; OFUNIXStreamSocket *sockClient, *sockServer, *sockAccepted; char buffer[5]; #if defined(OF_HAVE_FILES) && !defined(OF_IOS) path = [[OFSystemInfo temporaryDirectoryIRI] IRIByAppendingPathComponent: [[OFUUID UUID] UUIDString]] .fileSystemRepresentation; #else /* * We can have sockets, including UNIX sockets, while file support is * disabled. * * We also use this code path for iOS, as the temporaryDirectory:RI is * too long on the iOS simulator. */ path = [OFString stringWithFormat: @"/tmp/%@", [[OFUUID UUID] UUIDString]]; #endif sockClient = [OFUNIXStreamSocket socket]; sockServer = [OFUNIXStreamSocket socket]; @try { [sockServer bindToPath: path]; } @catch (OFBindSocketFailedException *e) { switch (e.errNo) { case EAFNOSUPPORT: case EPERM: OTSkip(@"UNIX stream sockets unsupported"); default: @throw e; } } @try { [sockServer listen]; [sockClient connectToPath: path]; sockAccepted = [sockServer accept]; [sockAccepted writeBuffer: "Hello" length: 5]; OTAssertEqual([sockClient readIntoBuffer: buffer length: 5], 5); OTAssertEqual(memcmp(buffer, "Hello", 5), 0); OTAssertEqual(OFSocketAddressUNIXPath( sockAccepted.remoteAddress).length, 0); } @finally { #ifdef OF_HAVE_FILES [[OFFileManager defaultManager] removeItemAtPath: path]; #endif } } @end |
Added tests/OFUTF8StringTests.m version [80c5788e7a].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFStringTests.h" #import "OFUTF8String.h" @interface OFUTF8StringTests: OFStringTests @end @implementation OFUTF8StringTests - (Class)arrayClass { return [OFUTF8String class]; } @end |
Modified tests/OFValueTests.m from [f614b296d4] to [0b1aefa48a].
1 | /* | | | | | | > > > > | < > | | > | > | | > > > | > > > > > > > | > > > | > > | | > > > > > > > > > | < < < < < < < < < < < < < < < < | < | | | > | < | > | > | > > | | | | | | < | > | | > > > | < | > | | < < < < < < | > | > | > | | > > > | < | > | | < < < < < < | > | > | > | | > > > | < | > | | < < < | | | < | > | | > > > | < | > | | < < < | | | > | > | > | > | | | | > | < | > | | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "ObjFW.h" #import "ObjFWTest.h" @interface OFValueTests: OTTestCase @end @implementation OFValueTests - (void)testObjCType { OFRange range = OFMakeRange(1, 64); OFValue *value = [OFValue valueWithBytes: &range objCType: @encode(OFRange)]; OTAssertEqual(strcmp(value.objCType, @encode(OFRange)), 0); } - (void)testGetValueSize { OFRange range = OFMakeRange(1, 64), range2; OFValue *value = [OFValue valueWithBytes: &range objCType: @encode(OFRange)]; [value getValue: &range2 size: sizeof(OFRange)]; OTAssert(OFEqualRanges(range2, range)); } - (void)testGetValueSizeThrowsOnWrongSize { OFRange range = OFMakeRange(1, 64); OFValue *value = [OFValue valueWithBytes: &range objCType: @encode(OFRange)]; OTAssertThrowsSpecific( [value getValue: &range size: sizeof(OFRange) - 1], OFOutOfRangeException); } - (void)testPointer { void *pointer = &pointer; OFValue *value = [OFValue valueWithPointer: pointer]; OTAssertEqual(value.pointerValue, pointer); OTAssertEqual([[OFValue valueWithBytes: &pointer objCType: @encode(void *)] pointerValue], pointer); OTAssertThrowsSpecific( [[OFValue valueWithBytes: "a" objCType: @encode(char)] pointerValue], OFOutOfRangeException); } - (void)testNonretainedObject { id object = (id)&object; OFValue *value = [OFValue valueWithNonretainedObject: object]; OTAssertEqual(value.nonretainedObjectValue, object); OTAssertEqual([[OFValue valueWithBytes: &object objCType: @encode(id)] nonretainedObjectValue], object); OTAssertThrowsSpecific( [[OFValue valueWithBytes: "a" objCType: @encode(char)] nonretainedObjectValue], OFOutOfRangeException); } - (void)testRange { OFRange range = OFMakeRange(1, 64), range2; OFValue *value = [OFValue valueWithRange: range]; OTAssert(OFEqualRanges(value.rangeValue, range)); OTAssert(OFEqualRanges( [[OFValue valueWithBytes: &range objCType: @encode(OFRange)] rangeValue], range)); [value getValue: &range2 size: sizeof(range2)]; OTAssert(OFEqualRanges(range2, range)); OTAssertThrowsSpecific( [[OFValue valueWithBytes: "a" objCType: @encode(char)] rangeValue], OFOutOfRangeException); } - (void)testPoint { OFPoint point = OFMakePoint(1.5f, 3.0f), point2; OFValue *value = [OFValue valueWithPoint: point]; OTAssert(OFEqualPoints(value.pointValue, point)); OTAssert(OFEqualPoints( [[OFValue valueWithBytes: &point objCType: @encode(OFPoint)] pointValue], point)); [value getValue: &point2 size: sizeof(point2)]; OTAssert(OFEqualPoints(point2, point)); OTAssertThrowsSpecific( [[OFValue valueWithBytes: "a" objCType: @encode(char)] pointValue], OFOutOfRangeException); } - (void)testSize { OFSize size = OFMakeSize(4.5f, 5.0f), size2; OFValue *value = [OFValue valueWithSize: size]; OTAssert(OFEqualSizes(value.sizeValue, size)); OTAssert(OFEqualSizes( [[OFValue valueWithBytes: &size objCType: @encode(OFSize)] sizeValue], size)); [value getValue: &size2 size: sizeof(size2)]; OTAssert(OFEqualSizes(size2, size)); OTAssertThrowsSpecific( [[OFValue valueWithBytes: "a" objCType: @encode(char)] sizeValue], OFOutOfRangeException); } - (void)testRect { OFRect rect = OFMakeRect(1.5f, 3.0f, 4.5f, 6.0f), rect2; OFValue *value = [OFValue valueWithRect: rect]; OTAssert(OFEqualRects(value.rectValue, rect)); OTAssert(OFEqualRects( [[OFValue valueWithBytes: &rect objCType: @encode(OFRect)] rectValue], rect)); [value getValue: &rect2 size: sizeof(rect2)]; OTAssert(OFEqualRects(rect2, rect)); OTAssertThrowsSpecific( [[OFValue valueWithBytes: "a" objCType: @encode(char)] rectValue], OFOutOfRangeException); } - (void)testIsEqual { OFRect rect = OFMakeRect(1.5f, 3.0f, 4.5f, 6.0f); OTAssertEqualObjects([OFValue valueWithRect: rect], [OFValue valueWithBytes: &rect objCType: @encode(OFRect)]); OTAssertNotEqualObjects( [OFValue valueWithBytes: "a" objCType: @encode(signed char)], [OFValue valueWithBytes: "a" objCType: @encode(unsigned char)]); OTAssertNotEqualObjects( [OFValue valueWithBytes: "a" objCType: @encode(char)], [OFValue valueWithBytes: "b" objCType: @encode(char)]); } @end |
Modified tests/OFWindowsRegistryKeyTests.m from [ddf274227c] to [5d63a7e2aa].
1 | /* | | | | | | > > > > | < > | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | > > > > | > > > > > | > | > > > > > | > > > > > > > > > > > | > > > > > > > > < < | < < | < < | < < < < | < < | < | | < < < < < | > > | < < < < < < < < < | < < < | < | < < < < < < | | < | | < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFW.h" #import "ObjFWTest.h" @interface OFWindowsRegistryKeyTests: OTTestCase { OFWindowsRegistryKey *_softwareKey, *_objFWKey; } @end @implementation OFWindowsRegistryKeyTests - (void)setUp { [super setUp]; _softwareKey = [[[OFWindowsRegistryKey currentUserKey] openSubkeyAtPath: @"Software" accessRights: KEY_ALL_ACCESS options: 0] retain]; _objFWKey = [[_softwareKey createSubkeyAtPath: @"ObjFW" accessRights: KEY_ALL_ACCESS securityAttributes: NULL options: 0 disposition: NULL] retain]; } - (void)tearDown { [_softwareKey deleteSubkeyAtPath: @"ObjFW"]; [super tearDown]; } - (void)dealloc { [_softwareKey release]; [_objFWKey release]; [super dealloc]; } - (void)testClassesRootKey { OTAssertEqual([[OFWindowsRegistryKey classesRootKey] class], [OFWindowsRegistryKey class]); } - (void)testCurrentConfigKey { OTAssertEqual([[OFWindowsRegistryKey currentConfigKey] class], [OFWindowsRegistryKey class]); } - (void)testCurrentUserKey { OTAssertEqual([[OFWindowsRegistryKey currentUserKey] class], [OFWindowsRegistryKey class]); } - (void)testLocalMachineKey { OTAssertEqual([[OFWindowsRegistryKey localMachineKey] class], [OFWindowsRegistryKey class]); } - (void)testOpenSubkeyAtPathAccessRightsOptionsThrowsForNonExistentKey { OTAssertThrowsSpecific([[OFWindowsRegistryKey currentUserKey] openSubkeyAtPath: @"nonexistent" accessRights: KEY_ALL_ACCESS options: 0], OFOpenWindowsRegistryKeyFailedException); } - (void)testSetAndGetData { OFData *data = [OFData dataWithItems: "abcdef" count: 6]; DWORD type; [_objFWKey setData: data forValueNamed: @"data" type: REG_BINARY]; OTAssertEqualObjects([_objFWKey dataForValueNamed: @"data" type: &type], data); OTAssertEqual(type, REG_BINARY); } - (void)testSetAndGetString { DWORD type; [_objFWKey setString: @"foobar" forValueNamed: @"string"]; OTAssertEqualObjects([_objFWKey stringForValueNamed: @"string"], @"foobar"); [_objFWKey setString: @"%PATH%;foo" forValueNamed: @"expand" type: REG_EXPAND_SZ]; OTAssertEqualObjects([_objFWKey stringForValueNamed: @"expand" type: &type], @"%PATH%;foo"); OTAssertEqual(type, REG_EXPAND_SZ); } - (void)testDeleteValue { [_objFWKey setString: @"foobar" forValueNamed: @"deleteme"]; OTAssertEqualObjects([_objFWKey stringForValueNamed: @"deleteme"], @"foobar"); [_objFWKey deleteValueNamed: @"deleteme"]; OTAssertNil([_objFWKey stringForValueNamed: @"deleteme"]); } @end |
Modified tests/OFXMLElementBuilderTests.m from [82fd282c44] to [d74257dfbe].
1 | /* | | | | | | > > > > | < > | | > | > | | | > > | > > > > > > > > | | | | | < < | | > | | < | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFW.h" #import "ObjFWTest.h" @interface OFXMLElementBuilderTests: OTTestCase <OFXMLElementBuilderDelegate> { OFXMLNode *_nodes[2]; size_t _i; } @end @implementation OFXMLElementBuilderTests - (void)dealloc { [_nodes[0] release]; [_nodes[1] release]; [super dealloc]; } - (void)elementBuilder: (OFXMLElementBuilder *)builder didBuildElement: (OFXMLElement *)element { OTAssertEqual(_i, 0); _nodes[_i++] = [element retain]; } - (void)elementBuilder: (OFXMLElementBuilder *)builder didBuildOrphanNode: (OFXMLNode *)node { OTAssertEqual(_i, 1); _nodes[_i++] = [node retain]; } - (void)testElementBuilder { OFXMLParser *parser = [OFXMLParser parser]; OFXMLElementBuilder *builder = [OFXMLElementBuilder builder]; OFString *string = @"<foo>bar<![CDATA[f<oo]]>baz<qux/>" " <qux xmlns:qux='urn:qux'><?asd?><qux:bar/><x qux:y='z'/></qux>" "</foo>"; parser.delegate = builder; builder.delegate = self; [parser parseString: string]; OTAssertEqualObjects(_nodes[0].XMLString, string); [parser parseString: @"<!--foo-->"]; OTAssertEqualObjects(_nodes[1].XMLString, @"<!--foo-->"); OTAssertEqual(_i, 2); } @end |
Modified tests/OFXMLNodeTests.m from [29eb2048b3] to [9d3d467c22].
1 | /* | | | | | | > > > > | < > | | > | > | | < < | > > | < | < < | < > | | | | < < < < < < < < < < < < < | < < < < < | < < < | < < < | > > | | > | | < | | < | | | < | | < | < < < | | > | | | < < < < < < < < < | < < < < < | < | | | | | > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > | > | > > > > | > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > | > > > | > > > > > > > > > > > | > > > > > > > | > > | | | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFW.h" #import "ObjFWTest.h" @interface OFXMLNodeTests: OTTestCase @end @implementation OFXMLNodeTests - (void)testElementWithName { OTAssertEqualObjects( [[OFXMLElement elementWithName: @"foo"] XMLString], @"<foo/>"); } - (void)testElementWithNameStringValue { OTAssertEqualObjects( [[OFXMLElement elementWithName: @"foo" stringValue: @"b&ar"] XMLString], @"<foo>b&ar</foo>"); } - (void)testElementWithNameNamespace { OFXMLElement *element; element = [OFXMLElement elementWithName: @"foo" namespace: @"urn:objfw:test"]; [element addAttributeWithName: @"test" stringValue: @"test"]; [element setPrefix: @"objfw-test" forNamespace: @"urn:objfw:test"]; OTAssertEqualObjects(element.XMLString, @"<objfw-test:foo test='test'/>"); element = [OFXMLElement elementWithName: @"foo" namespace: @"urn:objfw:test"]; [element addAttributeWithName: @"test" stringValue: @"test"]; OTAssertEqualObjects(element.XMLString, @"<foo xmlns='urn:objfw:test' test='test'/>"); } - (void)testElementWithNameNamespaceStringValue { OFXMLElement *element = [OFXMLElement elementWithName: @"foo" namespace: @"urn:objfw:test" stringValue: @"x"]; [element setPrefix: @"objfw-test" forNamespace: @"urn:objfw:test"]; OTAssertEqualObjects(element.XMLString, @"<objfw-test:foo>x</objfw-test:foo>"); } - (void)testElementWithXMLStringAndStringValue { OTAssertEqualObjects([[OFXMLElement elementWithXMLString: @"<?xml version='1.0' encoding='UTF-8'?>\r\n<x>foo<![CDATA[bar]]>" @"<y>b<!-- fooo -->az</y>qux</x>"] stringValue], @"foobarbazqux"); } - (void)testCharactersWithString { OTAssertEqualObjects( [[OFXMLCharacters charactersWithString: @"<foo>"] XMLString], @"<foo>"); } - (void)testCDATAWithString { OTAssertEqualObjects( [[OFXMLCDATA CDATAWithString: @"<foo>"] XMLString], @"<![CDATA[<foo>]]>"); } - (void)testCommentWithText { OTAssertEqualObjects( [[OFXMLComment commentWithText: @" comment "] XMLString], @"<!-- comment -->"); } - (void)testIsEqual { OTAssertEqualObjects( [OFXMLElement elementWithXMLString: @"<foo bar='asd'/>"], [OFXMLElement elementWithXMLString: @"<foo bar='asd'></foo>"]); OTAssertEqualObjects( [OFXMLElement elementWithXMLString: @"<x><y/></x>"], [OFXMLElement elementWithXMLString: @"<x><y></y></x>"]); OTAssertNotEqualObjects( [OFXMLElement elementWithXMLString: @"<x><Y/></x>"], [OFXMLElement elementWithXMLString: @"<x><y></y></x>"]); } - (void)testHash { OTAssertEqual( [[OFXMLElement elementWithXMLString: @"<foo bar='asd'/>"] hash], [[OFXMLElement elementWithXMLString: @"<foo bar='asd'></foo>"] hash]); OTAssertEqual( [[OFXMLElement elementWithXMLString: @"<x><y/></x>"] hash], [[OFXMLElement elementWithXMLString: @"<x><y></y></x>"] hash]); OTAssertNotEqual( [[OFXMLElement elementWithXMLString: @"<x><Y/></x>"] hash], [[OFXMLElement elementWithXMLString: @"<x><y></y></x>"] hash]); } - (void)testAddAttributeWithNameStringValue { OFXMLElement *element = [OFXMLElement elementWithName: @"foo" stringValue: @"b&ar"]; [element setPrefix: @"objfw-test" forNamespace: @"urn:objfw:test"]; [element addAttributeWithName: @"foo" stringValue: @"b&ar"]; [element addAttributeWithName: @"foo" namespace: @"urn:objfw:test" stringValue: @"bar"]; OTAssertEqualObjects(element.XMLString, @"<foo foo='b&ar' objfw-test:foo='bar'>b&ar</foo>"); } - (void)testRemoveAttributeForNameNamespace { OFXMLElement *element = [OFXMLElement elementWithName: @"foo" stringValue: @"b&ar"]; [element setPrefix: @"objfw-test" forNamespace: @"urn:objfw:test"]; [element addAttributeWithName: @"foo" stringValue: @"b&ar"]; [element addAttributeWithName: @"foo" namespace: @"urn:objfw:test" stringValue: @"bar"]; [element removeAttributeForName: @"foo"]; OTAssertEqualObjects(element.XMLString, @"<foo objfw-test:foo='bar'>b&ar</foo>"); [element removeAttributeForName: @"foo" namespace: @"urn:objfw:test"]; OTAssertEqualObjects(element.XMLString, @"<foo>b&ar</foo>"); } - (void)testAddChild { OFXMLElement *element; element = [OFXMLElement elementWithName: @"foo"]; [element addAttributeWithName: @"foo" stringValue: @"b&ar"]; [element addChild: [OFXMLElement elementWithName: @"bar"]]; OTAssertEqualObjects(element.XMLString, @"<foo foo='b&ar'><bar/></foo>"); element = [OFXMLElement elementWithName: @"foo" namespace: @"urn:objfw:test"]; [element setPrefix: @"objfw-test" forNamespace: @"urn:objfw:test"]; [element addAttributeWithName: @"test" stringValue: @"test"]; [element addChild: [OFXMLElement elementWithName: @"bar" namespace: @"urn:objfw:test"]]; OTAssertEqualObjects(element.XMLString, @"<objfw-test:foo test='test'><objfw-test:bar/></objfw-test:foo>"); } - (void)testElementsForNameNamespace { OFXMLElement *element = [OFXMLElement elementWithName: @"foo"]; OFXMLElement *bar; [element addChild: [OFXMLElement elementWithName: @"foo"]]; bar = [OFXMLElement elementWithName: @"bar" namespace: @"urn:objfw:test"]; [element addChild: bar]; OTAssertEqualObjects([element elementsForName: @"bar" namespace: @"urn:objfw:test"], [OFArray arrayWithObject: bar]); } - (void)testXMLStringWithIndentation { OTAssertEqualObjects([[OFXMLElement elementWithXMLString: @"<x><y><z>a\nb</z><!-- foo --></y></x>"] XMLStringWithIndentation: 2], @"<x>\n <y>\n <z>a\nb</z>\n <!-- foo -->\n </y>\n</x>"); } @end |
Modified tests/OFXMLParserTests.m from [dc6afcdede] to [0530fa90c8].
1 | /* | | | | | | > > > > | < > | | > | > | > > | < < < < < | | < | | | | < | > | | < | > > > | | < | > | < | > | > > > > > > > < | > > | > < | < > > > | > > > | > < | < | < < < < < < > > > > > > | > | > > | > | > | | | | < < < < | > > > | < | > | < | > | | | | < < | | | < < | < < < < < | > | < < < < < | < < < < < < | < | > > > > > > | > > > | > > > < | | < < < | < < < | < < < < < < < < < < | | < > > | > > > > > | > > > < | > | < < < < < < | < < < < < < < < < < | | < | > > > < | | < < | > < | > < < < < < | > | | | < | > | < | > | | | < | > | < | > > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdlib.h> #include <string.h> #import "ObjFW.h" #import "ObjFWTest.h" @interface OFXMLParserTests: OTTestCase <OFXMLParserDelegate> { int _i; } @end enum EventType { eventTypeProcessingInstruction, eventTypeTagOpen, eventTypeTagClose, eventTypeString, eventTypeCDATA, eventTypeComment }; @implementation OFXMLParserTests - (void)parser: (OFXMLParser *)parser didCreateEvent: (enum EventType)type name: (OFString *)name prefix: (OFString *)prefix namespace: (OFString *)namespace attributes: (OFArray *)attrs string: (OFString *)string { switch (_i++) { case 0: OTAssertEqual(type, eventTypeProcessingInstruction); OTAssertEqualObjects(name, @"xml"); OTAssertEqualObjects(string, @"version='1.0'"); break; case 1: OTAssertEqual(type, eventTypeProcessingInstruction); OTAssertEqualObjects(name, @"p?i"); OTAssertNil(string); break; case 2: OTAssertEqual(type, eventTypeTagOpen); OTAssertEqualObjects(name, @"root"); OTAssertNil(prefix); OTAssertNil(namespace); OTAssertEqual(attrs.count, 0); break; case 3: OTAssertEqual(type, eventTypeString); OTAssertEqualObjects(string, @"\n\n "); break; case 4: OTAssertEqual(type, eventTypeCDATA); OTAssertEqualObjects(string, @"f<]]]oo]"); OTAssertEqual(parser.lineNumber, 3); break; case 5: OTAssertEqual(type, eventTypeTagOpen); OTAssertEqualObjects(name, @"bar"); OTAssertNil(prefix); OTAssertNil(namespace); OTAssertNil(attrs); break; case 6: OTAssertEqual(type, eventTypeTagClose); OTAssertEqualObjects(name, @"bar"); OTAssertNil(prefix); OTAssertNil(namespace); OTAssertNil(attrs); break; case 7: OTAssertEqual(type, eventTypeString); OTAssertEqualObjects(string, @"\n "); break; case 8: OTAssertEqual(type, eventTypeTagOpen); OTAssertEqualObjects(name, @"foobar"); OTAssertNil(prefix); OTAssertEqualObjects(namespace, @"urn:objfw:test:foobar"); OTAssertEqualObjects(attrs, [OFArray arrayWithObject: [OFXMLAttribute attributeWithName: @"xmlns" stringValue: @"urn:objfw:test:" @"foobar"]]); break; case 9: OTAssertEqual(type, eventTypeString); OTAssertEqualObjects(string, @"\n "); break; case 10: OTAssertEqual(type, eventTypeTagOpen); OTAssertEqualObjects(name, @"qux"); OTAssertNil(prefix); OTAssertEqualObjects(namespace, @"urn:objfw:test:foobar"); OTAssertEqualObjects(attrs, [OFArray arrayWithObject: [OFXMLAttribute attributeWithName: @"foo" namespace: @"http://www.w3.org/" @"2000/xmlns/" stringValue: @"urn:objfw:test:foo"]]); break; case 11: OTAssertEqual(type, eventTypeString); OTAssertEqualObjects(string, @"\n "); break; case 12: OTAssertEqual(type, eventTypeTagOpen); OTAssertEqualObjects(name, @"bla"); OTAssertEqualObjects(prefix, @"foo"); OTAssertEqualObjects(namespace, @"urn:objfw:test:foo"); OTAssertEqualObjects(attrs, ([OFArray arrayWithObjects: [OFXMLAttribute attributeWithName: @"bla" namespace: @"urn:objfw:test:foo" stringValue: @"bla"], [OFXMLAttribute attributeWithName: @"blafoo" stringValue: @"foo"], nil])); break; case 13: OTAssertEqual(type, eventTypeString); OTAssertEqualObjects(string, @"\n "); break; case 14: OTAssertEqual(type, eventTypeTagOpen); OTAssertEqualObjects(name, @"blup"); OTAssertNil(prefix); OTAssertEqualObjects(namespace, @"urn:objfw:test:foobar"); OTAssertEqualObjects(attrs, ([OFArray arrayWithObjects: [OFXMLAttribute attributeWithName: @"qux" namespace: @"urn:objfw:test:foo" stringValue: @"asd"], [OFXMLAttribute attributeWithName: @"quxqux" stringValue: @"test"], nil])); break; case 15: OTAssertEqual(type, eventTypeTagClose); OTAssertEqualObjects(name, @"blup"); OTAssertNil(prefix); OTAssertEqualObjects(namespace, @"urn:objfw:test:foobar"); break; case 16: OTAssertEqual(type, eventTypeString); OTAssertEqualObjects(string, @"\n "); break; case 17: OTAssertEqual(type, eventTypeTagOpen); OTAssertEqualObjects(name, @"bla"); OTAssertEqualObjects(prefix, @"bla"); OTAssertEqualObjects(namespace, @"urn:objfw:test:bla"); OTAssertEqualObjects(attrs, ([OFArray arrayWithObjects: [OFXMLAttribute attributeWithName: @"bla" namespace: @"http://www.w3.org/" @"2000/xmlns/" stringValue: @"urn:objfw:test:bla"], [OFXMLAttribute attributeWithName: @"qux" stringValue: @"qux"], [OFXMLAttribute attributeWithName: @"foo" namespace: @"urn:objfw:test:bla" stringValue: @"blafoo"], nil])); break; case 18: OTAssertEqual(type, eventTypeTagClose); OTAssertEqualObjects(name, @"bla"); OTAssertEqualObjects(prefix, @"bla"); OTAssertEqualObjects(namespace, @"urn:objfw:test:bla"); break; case 19: OTAssertEqual(type, eventTypeString); OTAssertEqualObjects(string, @"\n "); break; case 20: OTAssertEqual(type, eventTypeTagOpen); OTAssertEqualObjects(name, @"abc"); OTAssertNil(prefix); OTAssertEqualObjects(namespace, @"urn:objfw:test:abc"); OTAssertEqualObjects(attrs, ([OFArray arrayWithObjects: [OFXMLAttribute attributeWithName: @"xmlns" stringValue: @"urn:objfw:test:abc"], [OFXMLAttribute attributeWithName: @"abc" stringValue: @"abc"], [OFXMLAttribute attributeWithName: @"abc" namespace: @"urn:objfw:test:foo" stringValue: @"abc"], nil])); break; case 21: OTAssertEqual(type, eventTypeTagClose); OTAssertEqualObjects(name, @"abc"); OTAssertNil(prefix); OTAssertEqualObjects(namespace, @"urn:objfw:test:abc"); break; case 22: OTAssertEqual(type, eventTypeString); OTAssertEqualObjects(string, @"\n "); break; case 23: OTAssertEqual(type, eventTypeTagClose); OTAssertEqualObjects(name, @"bla"); OTAssertEqualObjects(prefix, @"foo"); OTAssertEqualObjects(namespace, @"urn:objfw:test:foo"); break; case 24: OTAssertEqual(type, eventTypeString); OTAssertEqualObjects(string, @"\n "); break; case 25: OTAssertEqual(type, eventTypeComment); OTAssertEqualObjects(string, @" commänt "); break; case 26: OTAssertEqual(type, eventTypeString); OTAssertEqualObjects(string, @"\n "); break; case 27: OTAssertEqual(type, eventTypeTagClose); OTAssertEqualObjects(name, @"qux"); OTAssertNil(prefix); OTAssertEqualObjects(namespace, @"urn:objfw:test:foobar"); break; case 28: OTAssertEqual(type, eventTypeString); OTAssertEqualObjects(string, @"\n "); break; case 29: OTAssertEqual(type, eventTypeTagClose); OTAssertEqualObjects(name, @"foobar"); OTAssertNil(prefix); OTAssertEqualObjects(namespace, @"urn:objfw:test:foobar"); break; case 30: OTAssertEqual(type, eventTypeString); OTAssertEqualObjects(string, @"\n"); break; case 31: OTAssertEqual(type, eventTypeTagClose); OTAssertEqualObjects(name, @"root"); OTAssertNil(prefix); OTAssertNil(namespace); break; } } - (void)parser: (OFXMLParser *)parser foundProcessingInstructionWithTarget: (OFString *)target text: (OFString *)text |
︙ | ︙ | |||
353 354 355 356 357 358 359 | { if ([entity isEqual: @"foo"]) return @"foobar"; return nil; } | | < | | < | | | < | | | | | | > | > > | | > > | < > | < > > > | | < | | | < > | | < | 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 | { if ([entity isEqual: @"foo"]) return @"foobar"; return nil; } - (void)testParser { static const char *string = "\xEF\xBB\xBF<?xml version='1.0'?><?p?i?>" "<!DOCTYPE foo><root>\r\r" " <![CDATA[f<]]]oo]]]><bar/>\n" " <foobar xmlns='urn:objfw:test:foobar'>\r\n" " <qux xmlns:foo='urn:objfw:test:foo'>\n" " <foo:bla foo:bla = 'bla' blafoo='foo'>\n" " <blup foo:qux='asd' quxqux='test'/>\n" " <bla:bla\r\rxmlns:bla\r=\t\"urn:objfw:test:bla\" qux='qux'\r\n" " bla:foo='blafoo'/>\n" " <abc xmlns='urn:objfw:test:abc' abc='abc' foo:abc='abc'/>\n" " </foo:bla>\n" " <!-- commänt -->\n" " </qux>\n" " </foobar>\n" "</root>"; OFXMLParser *parser; size_t j, length; parser = [OFXMLParser parser]; parser.delegate = self; /* Simulate a stream where we only get chunks */ length = strlen(string); for (j = 0; j < length; j+= 2) { if (parser.hasFinishedParsing) abort(); if (j + 2 > length) [parser parseBuffer: string + j length: 1]; else [parser parseBuffer: string + j length: 2]; } OTAssertEqual(_i, 32); OTAssertEqual(parser.lineNumber, 18); OTAssertTrue(parser.hasFinishedParsing); /* Parsing whitespaces after the document */ [parser parseString: @" \t\r\n "]; /* Parsing comments after the document */ [parser parseString: @" \t<!-- foo -->\r<!--bar-->\n "]; /* Detection of junk after the document */ OTAssertThrowsSpecific([parser parseString: @"a"], OFMalformedXMLException); OTAssertThrowsSpecific([parser parseString: @"<!["], OFMalformedXMLException); } - (void)testDetectionOfInvalidXMLProcessingInstructions { OFXMLParser *parser; parser = [OFXMLParser parser]; OTAssertThrowsSpecific([parser parseString: @"<?xml version='2.0'?>"], OFMalformedXMLException); parser = [OFXMLParser parser]; OTAssertThrowsSpecific([parser parseString: @"<x><?xml?></x>"], OFMalformedXMLException); } - (void)testDetectionOfInvalidEncoding { OFXMLParser *parser = [OFXMLParser parser]; OTAssertThrowsSpecific( [parser parseString: @"<?xml encoding='UTF-7'?>"], OFInvalidEncodingException); } @end |
Added tests/OFZIPArchiveTests.m version [08ab024bf5].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFW.h" #import "ObjFWTest.h" #define bufferSize 4096 @interface OFZIPArchiveTests: OTTestCase { char _buffer[bufferSize]; } @end @implementation OFZIPArchiveTests - (void)testCreateAndExtractArchive { OFMemoryStream *stream = [OFMemoryStream streamWithMemoryAddress: _buffer size: bufferSize writable: true]; OFZIPArchive *archive = [OFZIPArchive archiveWithStream: stream mode: @"w"]; OFZIPArchiveEntry *entry = [OFMutableZIPArchiveEntry entryWithFileName: @"testfile.txt"]; OFStream *entryStream = [archive streamForWritingEntry: entry]; size_t size; [entryStream writeString: @"Hello World!"]; [archive close]; size = (size_t)[stream seekToOffset: 0 whence: OFSeekCurrent]; OTAssertLessThanOrEqual(size, bufferSize); stream = [OFMemoryStream streamWithMemoryAddress: _buffer size: size writable: false]; archive = [OFZIPArchive archiveWithStream: stream mode: @"r"]; OTAssertEqual(archive.entries.count, 1); entry = archive.entries.firstObject; OTAssertEqualObjects(entry.fileName, @"testfile.txt"); entryStream = [archive streamForReadingFile: entry.fileName]; OTAssertEqualObjects([entryStream readLine], @"Hello World!"); OTAssertNil([entryStream readLine]); } @end |
Added tests/OFZooArchiveTests.m version [2f7f170b9f].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFW.h" #import "ObjFWTest.h" #define bufferSize 4096 @interface OFZooArchiveTests: OTTestCase { char _buffer[bufferSize]; } @end @implementation OFZooArchiveTests - (void)testCreateAndExtractArchive { OFMemoryStream *stream = [OFMemoryStream streamWithMemoryAddress: _buffer size: bufferSize writable: true]; OFZooArchive *archive = [OFZooArchive archiveWithStream: stream mode: @"w"]; OFZooArchiveEntry *entry = [OFMutableZooArchiveEntry entryWithFileName: @"testfile.txt"]; OFStream *entryStream = [archive streamForWritingEntry: entry]; size_t size; [entryStream writeString: @"Hello World!"]; [archive close]; size = (size_t)[stream seekToOffset: 0 whence: OFSeekCurrent]; OTAssertLessThanOrEqual(size, bufferSize); stream = [OFMemoryStream streamWithMemoryAddress: _buffer size: size writable: false]; archive = [OFZooArchive archiveWithStream: stream mode: @"r"]; entry = [archive nextEntry]; OTAssertEqualObjects(entry.fileName, @"testfile.txt"); entryStream = [archive streamForReadingCurrentEntry]; OTAssertEqualObjects([entryStream readLine], @"Hello World!"); OTAssertNil([entryStream readLine]); OTAssertNil([archive nextEntry]); } @end |
Modified tests/RuntimeARCTests.m from [62782bae47] to [e521ed5e84].
1 | /* | | | | | | > > > > | < > | | > | > | | > > > > > > > > > > > > > > > > > > | < < < < < < < < < < < < < < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFW.h" #import "ObjFWTest.h" @interface RuntimeARCTests: OTTestCase @end @interface RuntimeARCTestClass: OFObject @end @implementation RuntimeARCTests - (void)testExceptionsDuringInit { OTAssertThrows((void)[[RuntimeARCTestClass alloc] init]); } - (void)testWeakReferences { id object = [[OFObject alloc] init]; __weak id weak = object; OTAssertEqual(weak, object); object = nil; OTAssertNil(weak); } @end @implementation RuntimeARCTestClass - (instancetype)init { self = [super init]; #if defined(OF_WINDOWS) && defined(OF_AMD64) /* * Clang has a bug on Windows where it creates an invalid call into * objc_retainAutoreleasedReturnValue(). Work around it by not using an * autoreleased exception. */ @throw [[OFException alloc] init]; #else @throw [OFException exception]; #endif return self; } @end |
Modified tests/RuntimeTests.m from [9aa59cf983] to [cafe5e0521].
1 | /* | | | | | | > > > > | < > | | | < < | < | > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFW.h" #import "ObjFWTest.h" static void *testKey = &testKey; @interface RuntimeTestClass: OFObject { OFString *_foo, *_bar; } @property (nonatomic, copy) OFString *foo; @property (retain) OFString *bar; - (id)nilSuperTest; @end @interface RuntimeTests: OTTestCase { RuntimeTestClass *_test; } @end @interface OFObject (SuperTest) - (id)superTest; @end @implementation RuntimeTests - (void)setUp { [super setUp]; _test = [[RuntimeTestClass alloc] init]; } - (void)dealloc { [_test release]; [super dealloc]; } - (void)testCallNonExistentMethodViaSuper { OTAssertThrowsSpecific([_test superTest], OFNotImplementedException); } - (void)testCallMethodViaSuperWithNilSelf { OTAssertNil([_test nilSuperTest]); } - (void)testPropertyCopyNonatomic { OFMutableString *string = [OFMutableString stringWithString: @"foo"]; OFString *foo = @"foo"; _test.foo = string; OTAssertEqualObjects(_test.foo, foo); OTAssertNotEqual(_test.foo, foo); OTAssertEqual(_test.foo.retainCount, 1); } - (void)testPropertyRetainAtomic { OFMutableString *string = [OFMutableString stringWithString: @"foo"]; _test.bar = string; OTAssertEqual(_test.bar, string); OTAssertEqual(string.retainCount, 3); } - (void)testAssociatedObjects { objc_setAssociatedObject(self, testKey, _test, OBJC_ASSOCIATION_ASSIGN); OTAssertEqual(_test.retainCount, 1); objc_setAssociatedObject(self, testKey, _test, OBJC_ASSOCIATION_RETAIN); OTAssertEqual(_test.retainCount, 2); OTAssertEqual(objc_getAssociatedObject(self, testKey), _test); OTAssertEqual(_test.retainCount, 3); objc_setAssociatedObject(self, testKey, _test, OBJC_ASSOCIATION_ASSIGN); OTAssertEqual(_test.retainCount, 2); objc_setAssociatedObject(self, testKey, _test, OBJC_ASSOCIATION_RETAIN_NONATOMIC); OTAssertEqual(_test.retainCount, 3); OTAssertEqual(objc_getAssociatedObject(self, testKey), _test); OTAssertEqual(_test.retainCount, 3); objc_removeAssociatedObjects(self); OTAssertEqual(_test.retainCount, 2); } #ifdef OF_OBJFW_RUNTIME - (void)testTaggedPointers { int classID; uintmax_t value; id object; if (sizeof(uintptr_t) == 8) value = 0xDEADBEEFDEADBEF; else if (sizeof(uintptr_t) == 4) value = 0xDEADBEF; else OTAssert(sizeof(uintptr_t) == 8 || sizeof(uintptr_t) == 4); OTAssertNotEqual(objc_registerTaggedPointerClass([OFString class]), -1); classID = objc_registerTaggedPointerClass([OFNumber class]); OTAssertNotEqual(classID, -1); object = objc_createTaggedPointer(classID, (uintptr_t)value); OTAssertNotNil(object); OTAssertEqual(object_getClass(object), [OFNumber class]); OTAssertEqual([object class], [OFNumber class]); OTAssertEqual(object_getTaggedPointerValue(object), value); OTAssertNotNil(objc_createTaggedPointer(classID, UINTPTR_MAX >> 4)); OTAssertNil(objc_createTaggedPointer(classID, (UINTPTR_MAX >> 4) + 1)); } #endif @end @implementation RuntimeTestClass @synthesize foo = _foo; @synthesize bar = _bar; - (void)dealloc { [_foo release]; [_bar release]; |
︙ | ︙ | |||
53 54 55 56 57 58 59 60 | - (id)nilSuperTest { self = nil; return [self superTest]; } @end | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 164 165 166 167 168 169 170 171 | - (id)nilSuperTest { self = nil; return [self superTest]; } @end |
Deleted tests/TestsAppDelegate.h version [b5a7bd5c8a].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted tests/TestsAppDelegate.m version [f192383371].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Added tests/big_dictionary.msgpack version [02714ede05].
cannot compute difference between binary files
Modified tests/iOS.xcodeproj/project.pbxproj from [2c6fcc5e96] to [a002968e40].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | // !$*UTF8*$! { archiveVersion = 1; classes = { }; objectVersion = 48; objects = { /* Begin PBXBuildFile section */ 4B6AB9CD202BA431007BAC7D /* TestPlugin.bundle in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B6AB9CA202BA408007BAC7D /* TestPlugin.bundle */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 4BC7FD07201394F300280496 /* ObjFW.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BC7FD06201394F300280496 /* ObjFW.framework */; }; 4BC7FD092013954B00280496 /* tests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BC7FD082013954B00280496 /* tests.a */; }; 4BC7FD0B2013956D00280496 /* ObjFW.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4BC7FD06201394F300280496 /* ObjFW.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 4BC7FD102013960600280496 /* testfile.txt in Resources */ = {isa = PBXBuildFile; fileRef = 4BC7FD0C2013960600280496 /* testfile.txt */; }; 4BC7FD112013960600280496 /* testfile.bin in Resources */ = {isa = PBXBuildFile; fileRef = 4BC7FD0D2013960600280496 /* testfile.bin */; }; | > < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | // !$*UTF8*$! { archiveVersion = 1; classes = { }; objectVersion = 48; objects = { /* Begin PBXBuildFile section */ 4B1E2CEF2B8294F200BB28B6 /* libobjfwtest.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B1E2CEE2B8294F200BB28B6 /* libobjfwtest.a */; }; 4B6AB9CD202BA431007BAC7D /* TestPlugin.bundle in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B6AB9CA202BA408007BAC7D /* TestPlugin.bundle */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 4BC7FD07201394F300280496 /* ObjFW.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BC7FD06201394F300280496 /* ObjFW.framework */; }; 4BC7FD092013954B00280496 /* tests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BC7FD082013954B00280496 /* tests.a */; }; 4BC7FD0B2013956D00280496 /* ObjFW.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4BC7FD06201394F300280496 /* ObjFW.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 4BC7FD102013960600280496 /* testfile.txt in Resources */ = {isa = PBXBuildFile; fileRef = 4BC7FD0C2013960600280496 /* testfile.txt */; }; 4BC7FD112013960600280496 /* testfile.bin in Resources */ = {isa = PBXBuildFile; fileRef = 4BC7FD0D2013960600280496 /* testfile.bin */; }; 4BC7FD132013960600280496 /* testfile.ini in Resources */ = {isa = PBXBuildFile; fileRef = 4BC7FD0F2013960600280496 /* testfile.ini */; }; 4BEBFB6E2013934E002E8710 /* ImportTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BEBFB6D2013934E002E8710 /* ImportTest.m */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ 4B6AB9CC202BA428007BAC7D /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; |
︙ | ︙ | |||
38 39 40 41 42 43 44 45 46 47 48 49 | 4BC7FD0B2013956D00280496 /* ObjFW.framework in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ 4B6AB9CA202BA408007BAC7D /* TestPlugin.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = TestPlugin.bundle; path = plugin/TestPlugin.bundle; sourceTree = "<group>"; }; 4BC7FD06201394F300280496 /* ObjFW.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ObjFW.framework; path = ../src/ObjFW.framework; sourceTree = "<group>"; }; 4BC7FD082013954B00280496 /* tests.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = tests.a; sourceTree = "<group>"; }; 4BC7FD0C2013960600280496 /* testfile.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = testfile.txt; sourceTree = "<group>"; }; 4BC7FD0D2013960600280496 /* testfile.bin */ = {isa = PBXFileReference; lastKnownFileType = archive.macbinary; path = testfile.bin; sourceTree = "<group>"; }; | > < < > > > | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | 4BC7FD0B2013956D00280496 /* ObjFW.framework in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ 4B1E2CEE2B8294F200BB28B6 /* libobjfwtest.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libobjfwtest.a; path = ../src/test/libobjfwtest.a; sourceTree = "<group>"; }; 4B6AB9CA202BA408007BAC7D /* TestPlugin.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = TestPlugin.bundle; path = plugin/TestPlugin.bundle; sourceTree = "<group>"; }; 4BC7FD06201394F300280496 /* ObjFW.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ObjFW.framework; path = ../src/ObjFW.framework; sourceTree = "<group>"; }; 4BC7FD082013954B00280496 /* tests.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = tests.a; sourceTree = "<group>"; }; 4BC7FD0C2013960600280496 /* testfile.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = testfile.txt; sourceTree = "<group>"; }; 4BC7FD0D2013960600280496 /* testfile.bin */ = {isa = PBXFileReference; lastKnownFileType = archive.macbinary; path = testfile.bin; sourceTree = "<group>"; }; 4BC7FD0F2013960600280496 /* testfile.ini */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = testfile.ini; sourceTree = "<group>"; }; 4BEBFB5B2013934E002E8710 /* tests.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = tests.app; sourceTree = BUILT_PRODUCTS_DIR; }; 4BEBFB6C2013934E002E8710 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = SOURCE_ROOT; }; 4BEBFB6D2013934E002E8710 /* ImportTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ImportTest.m; sourceTree = SOURCE_ROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ 4BEBFB582013934E002E8710 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 4BC7FD092013954B00280496 /* tests.a in Frameworks */, 4B1E2CEF2B8294F200BB28B6 /* libobjfwtest.a in Frameworks */, 4BC7FD07201394F300280496 /* ObjFW.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ 4BC7FD05201394F300280496 /* Frameworks */ = { isa = PBXGroup; children = ( 4B6AB9CA202BA408007BAC7D /* TestPlugin.bundle */, 4BC7FD082013954B00280496 /* tests.a */, 4B1E2CEE2B8294F200BB28B6 /* libobjfwtest.a */, 4BC7FD06201394F300280496 /* ObjFW.framework */, ); name = Frameworks; sourceTree = "<group>"; }; 4BEBFB522013934E002E8710 = { isa = PBXGroup; |
︙ | ︙ | |||
95 96 97 98 99 100 101 | sourceTree = "<group>"; }; 4BEBFB5D2013934E002E8710 /* tests */ = { isa = PBXGroup; children = ( 4BEBFB6C2013934E002E8710 /* Info.plist */, 4BEBFB6D2013934E002E8710 /* ImportTest.m */, | < | 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | sourceTree = "<group>"; }; 4BEBFB5D2013934E002E8710 /* tests */ = { isa = PBXGroup; children = ( 4BEBFB6C2013934E002E8710 /* Info.plist */, 4BEBFB6D2013934E002E8710 /* ImportTest.m */, 4BC7FD0D2013960600280496 /* testfile.bin */, 4BC7FD0F2013960600280496 /* testfile.ini */, 4BC7FD0C2013960600280496 /* testfile.txt */, ); name = tests; sourceTree = "<group>"; }; |
︙ | ︙ | |||
164 165 166 167 168 169 170 | /* Begin PBXResourcesBuildPhase section */ 4BEBFB592013934E002E8710 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 4BC7FD102013960600280496 /* testfile.txt in Resources */, | < | 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | /* Begin PBXResourcesBuildPhase section */ 4BEBFB592013934E002E8710 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 4BC7FD102013960600280496 /* testfile.txt in Resources */, 4BC7FD132013960600280496 /* testfile.ini in Resources */, 4BC7FD112013960600280496 /* testfile.bin in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ |
︙ | ︙ | |||
304 305 306 307 308 309 310 311 | DEVELOPMENT_TEAM = MXKNFCKFL6; FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../src"; INFOPLIST_FILE = Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)", ); | > | > | | 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | DEVELOPMENT_TEAM = MXKNFCKFL6; FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../src"; INFOPLIST_FILE = Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)", "$(PROJECT_DIR)/../src/test", ); OTHER_LDFLAGS = "-all_load"; PRODUCT_BUNDLE_IDENTIFIER = im.nil.objfw.tests; PRODUCT_NAME = "$(TARGET_NAME)"; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; }; 4BEBFB732013934E002E8710 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = MXKNFCKFL6; FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../src"; INFOPLIST_FILE = Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)", "$(PROJECT_DIR)/../src/test", ); OTHER_LDFLAGS = "-all_load"; PRODUCT_BUNDLE_IDENTIFIER = im.nil.objfw.tests; PRODUCT_NAME = "$(TARGET_NAME)"; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; }; /* End XCBuildConfiguration section */ |
︙ | ︙ |
Modified tests/objc_sync/Makefile from [0df383ed25] to [1e35f54ff7].
︙ | ︙ | |||
10 11 12 13 14 15 16 | rm -f libobjfw.so.${OBJFW_LIB_MAJOR} rm -f libobjfw.so.${OBJFW_LIB_MAJOR_MINOR} rm -f objfw${OBJFW_LIB_MAJOR}.dll libobjfw.${OBJFW_LIB_MAJOR}.dylib rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR} rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR} rm -f objfwrt${OBJFWRT_LIB_MAJOR}.dll rm -f libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib | < | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | rm -f libobjfw.so.${OBJFW_LIB_MAJOR} rm -f libobjfw.so.${OBJFW_LIB_MAJOR_MINOR} rm -f objfw${OBJFW_LIB_MAJOR}.dll libobjfw.${OBJFW_LIB_MAJOR}.dylib rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR} rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR} rm -f objfwrt${OBJFWRT_LIB_MAJOR}.dll rm -f libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib if test -f ../../src/libobjfw.so; then \ ${LN_S} ../../src/libobjfw.so libobjfw.so.${OBJFW_LIB_MAJOR}; \ ${LN_S} ../../src/libobjfw.so \ libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \ elif test -f ../../src/libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; then \ ${LN_S} ../../src/libobjfw.so.${OBJFW_LIB_MAJOR_MINOR} \ libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \ |
︙ | ︙ | |||
43 44 45 46 47 48 49 | ${LN_S} ../../src/runtime/objfwrt${OBJFWRT_LIB_MAJOR}.dll \ objfwrt${OBJFWRT_LIB_MAJOR}.dll; \ fi if test -f ../../src/runtime/libobjfwrt.dylib; then \ ${LN_S} ../../src/runtime/libobjfwrt.dylib \ libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib; \ fi | < < < < | < < | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | ${LN_S} ../../src/runtime/objfwrt${OBJFWRT_LIB_MAJOR}.dll \ objfwrt${OBJFWRT_LIB_MAJOR}.dll; \ fi if test -f ../../src/runtime/libobjfwrt.dylib; then \ ${LN_S} ../../src/runtime/libobjfwrt.dylib \ libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib; \ fi LD_LIBRARY_PATH=.$${LD_LIBRARY_PATH+:}$$LD_LIBRARY_PATH \ DYLD_LIBRARY_PATH=.$${DYLD_LIBRARY_PATH+:}$$DYLD_LIBRARY_PATH \ LIBRARY_PATH=.$${LIBRARY_PATH+:}$$LIBRARY_PATH \ ${WRAPPER} ./${PROG_NOINST}; EXIT=$$?; \ rm -f libobjfw.so.${OBJFW_LIB_MAJOR}; \ rm -f libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \ rm -f objfw${OBJFW_LIB_MAJOR}.dll; \ rm -f libobjfw.${OBJFW_LIB_MAJOR}.dylib; \ rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR}; \ rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}; \ rm -f objfwrt${OBJFWRT_LIB_MAJOR}.dll; \ rm -f libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib; \ exit $$EXIT CPPFLAGS += -I../../src -I../../src/runtime -I../.. LIBS := -L../../src -lobjfw -L../../src/runtime ${RUNTIME_LIBS} ${LIBS} LD = ${OBJC} |
Modified tests/objc_sync/test.m from [1f28b08c51] to [b1a83d058b].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <stdio.h> #import "OFString.h" |
︙ | ︙ |
Modified tests/plugin/TestPlugin.h from [2f9aa9b796] to [c7addf8a50].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" @interface TestPlugin: OFObject - (int)test: (int)num; @end |
Modified tests/plugin/TestPlugin.m from [5616dbe160] to [08d2f004ac].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "TestPlugin.h" #ifdef OF_OBJFW_RUNTIME |
︙ | ︙ |
Deleted tests/serialization.xml version [ea3d1a36ad].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Added tests/subprocess/Makefile version [0c326652cc].
> > > > > > > > > | 1 2 3 4 5 6 7 8 9 | PROG_NOINST = subprocess${PROG_SUFFIX} SRCS = Subprocess.m include ../../buildsys.mk include ../../extra.mk CPPFLAGS += -I../../src -I../../src/exceptions -I../../src/runtime -I../.. LIBS := -L../../src -lobjfw -L../../src/runtime ${RUNTIME_LIBS} ${LIBS} LD = ${OBJC} |
Added tests/subprocess/Subprocess.m version [f5dfed46e5].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "ObjFW.h" @interface Subprocess: OFObject <OFApplicationDelegate> @end OF_APPLICATION_DELEGATE(Subprocess) @implementation Subprocess - (void)applicationDidFinishLaunching: (OFNotification *)notification { OFString *line; if (![[OFApplication arguments] isEqual: [OFArray arrayWithObjects: @"tést", @"123", nil]]) [OFApplication terminateWithStatus: 1]; if (![[[OFApplication environment] objectForKey: @"tëst"] isEqual: @"yés"]) { [OFApplication terminateWithStatus: 2]; } #ifdef OF_WINDOWS /* On Windows 9x, closing the pipe doesn't seem to cause EOF. */ if (![OFSystemInfo isWindowsNT]) { if ((line = [OFStdIn readLine]) != nil) [OFStdOut writeLine: line.uppercaseString]; } else #endif while ((line = [OFStdIn readLine]) != nil) [OFStdOut writeLine: line.uppercaseString]; [OFApplication terminate]; } @end |
Modified tests/terminal/Makefile from [e8770b0b9b] to [6ef6cabc1b].
︙ | ︙ | |||
10 11 12 13 14 15 16 | rm -f libobjfw.so.${OBJFW_LIB_MAJOR} rm -f libobjfw.so.${OBJFW_LIB_MAJOR_MINOR} rm -f objfw${OBJFW_LIB_MAJOR}.dll libobjfw.${OBJFW_LIB_MAJOR}.dylib rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR} rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR} rm -f objfwrt${OBJFWRT_LIB_MAJOR}.dll rm -f libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib | < | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | rm -f libobjfw.so.${OBJFW_LIB_MAJOR} rm -f libobjfw.so.${OBJFW_LIB_MAJOR_MINOR} rm -f objfw${OBJFW_LIB_MAJOR}.dll libobjfw.${OBJFW_LIB_MAJOR}.dylib rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR} rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR} rm -f objfwrt${OBJFWRT_LIB_MAJOR}.dll rm -f libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib if test -f ../../src/libobjfw.so; then \ ${LN_S} ../../src/libobjfw.so libobjfw.so.${OBJFW_LIB_MAJOR}; \ ${LN_S} ../../src/libobjfw.so \ libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \ elif test -f ../../src/libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; then \ ${LN_S} ../../src/libobjfw.so.${OBJFW_LIB_MAJOR_MINOR} \ libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \ |
︙ | ︙ | |||
43 44 45 46 47 48 49 | ${LN_S} ../../src/runtime/objfwrt${OBJFWRT_LIB_MAJOR}.dll \ objfwrt${OBJFWRT_LIB_MAJOR}.dll; \ fi if test -f ../../src/runtime/libobjfwrt.dylib; then \ ${LN_S} ../../src/runtime/libobjfwrt.dylib \ libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib; \ fi | < < < < | < < | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | ${LN_S} ../../src/runtime/objfwrt${OBJFWRT_LIB_MAJOR}.dll \ objfwrt${OBJFWRT_LIB_MAJOR}.dll; \ fi if test -f ../../src/runtime/libobjfwrt.dylib; then \ ${LN_S} ../../src/runtime/libobjfwrt.dylib \ libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib; \ fi LD_LIBRARY_PATH=.$${LD_LIBRARY_PATH+:}$$LD_LIBRARY_PATH \ DYLD_LIBRARY_PATH=.$${DYLD_LIBRARY_PATH+:}$$DYLD_LIBRARY_PATH \ LIBRARY_PATH=.$${LIBRARY_PATH+:}$$LIBRARY_PATH \ ${WRAPPER} ./${PROG_NOINST}; EXIT=$$?; \ rm -f libobjfw.so.${OBJFW_LIB_MAJOR}; \ rm -f libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \ rm -f objfw${OBJFW_LIB_MAJOR}.dll; \ rm -f libobjfw.${OBJFW_LIB_MAJOR}.dylib; \ rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR}; \ rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}; \ rm -f objfwrt${OBJFWRT_LIB_MAJOR}.dll; \ rm -f libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib; \ exit $$EXIT CPPFLAGS += -I../../src -I../../src/exceptions -I../../src/runtime -I../.. LIBS := -L../../src -lobjfw -L../../src/runtime ${RUNTIME_LIBS} ${LIBS} LD = ${OBJC} |
Modified tests/terminal/TerminalTests.m from [695364c6d5] to [7c129c58ea].
1 | /* | | | | | | > > > > | < > | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFApplication.h" #import "OFArray.h" #import "OFColor.h" #import "OFStdIOStream.h" #import "OFThread.h" @interface TerminalTests: OFObject <OFApplicationDelegate> @end OF_APPLICATION_DELEGATE(TerminalTests) @implementation TerminalTests - (void)applicationDidFinishLaunching: (OFNotification *)notification { OFArray *colors = [OFArray arrayWithObjects: [OFColor black], [OFColor silver], [OFColor gray], [OFColor white], [OFColor maroon], [OFColor red], [OFColor purple], [OFColor fuchsia], [OFColor green], [OFColor lime], [OFColor olive], [OFColor yellow], [OFColor navy], [OFColor blue], [OFColor teal], [OFColor aqua], nil]; size_t i; OFEnumerator OF_GENERIC(OFColor *) *reverseEnumerator; |
︙ | ︙ |
Modified tests/testfile.ini from [70f0fff498] to [9e2ef2dc1a].
1 2 3 4 5 6 7 8 9 | [tests] foo = bar foobar=baz ;comment [foobar] ;foobarcomment qux=" asd" "quxqux " = asd | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | [tests] foo = bar foobar=baz ;comment [foobar] ;foobarcomment qux=" asd" "quxqux " = asd quxquxqux="hello\"wrld" qux2="a\f" [types] integer = 0x20 bool = true float = 0.5 array1 = 1 |
︙ | ︙ |
Modified utils/Makefile from [d5d46e8aaf] to [ba4530b9f8].
1 2 | include ../extra.mk | | | | | | < | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | include ../extra.mk SUBDIRS += ${OBJFW_NEW} \ ${OFARC} \ ${OFDNS} \ ${OFHASH} \ ${OFHTTP} include ../buildsys.mk DISTCLEAN = objfw-config install-extra: objfw-config objfw-compile objfw-embed for i in objfw-config objfw-compile objfw-embed; do \ ${INSTALL_STATUS}; \ if ${MKDIR_P} ${DESTDIR}${bindir} && ${INSTALL} -m 755 $$i \ ${DESTDIR}${bindir}/${BIN_PREFIX}$$i; then \ ${INSTALL_OK}; \ else \ ${INSTALL_FAILED}; \ fi \ done uninstall-extra: |
︙ | ︙ |
Deleted utils/completions/Makefile version [53ed45f23f].
|
| < < < < < |
Deleted utils/completions/fish/Makefile version [6569e87046].
|
| < < < < < < < < < < |
Deleted utils/completions/fish/objfw-compile.fish version [e113a8c395].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted utils/completions/fish/objfw-config.fish version [a2dae654a7].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted utils/completions/fish/ofarc.fish version [1ed287a4cf].
|
| < < < < < < < < < < < < < < |
Deleted utils/completions/fish/ofdns.fish version [5080d1ffbb].
|
| < < < < < |
Deleted utils/completions/fish/ofhash.fish version [ffdc6cdbcf].
|
| < < < < < < < |
Deleted utils/completions/fish/ofhttp.fish version [99fd9b7109].
|
| < < < < < < < < < < < < < < < |
Modified utils/objfw-compile from [ffd05ad528] to [e35f021548].
1 2 | #!/bin/sh # | | > | > > > > | | | | < | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | #!/bin/sh # # Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> # # All rights reserved. # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License version 3.0 only, # as published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License # version 3.0 for more details. # # You should have received a copy of the GNU Lesser General Public License # version 3.0 along with this program. If not, see # <https://www.gnu.org/licenses/>. # if test x"$(basename "$0")" != x"objfw-compile"; then OBJFW_CONFIG="$(basename "$0" | sed 's/-objfw-compile$//')-objfw-config" else OBJFW_CONFIG="objfw-config" fi |
︙ | ︙ |
Modified utils/objfw-config.in from [c7e6aa0918] to [b9613126d3].
1 2 | #!/bin/sh # | | > | > > > > | | | | < | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | #!/bin/sh # # Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> # # All rights reserved. # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License version 3.0 only, # as published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License # version 3.0 for more details. # # You should have received a copy of the GNU Lesser General Public License # version 3.0 along with this program. If not, see # <https://www.gnu.org/licenses/>. # prefix="@prefix@" exec_prefix="@exec_prefix@" libdir="@libdir@" packagesdir="$libdir/objfw-config" CFLAGS="" CPPFLAGS="@OBJFW_CPPFLAGS@ -I@includedir@" CXXFLAGS="" OBJC="@OBJC@" OBJCFLAGS="@OBJFW_OBJCFLAGS@" LIB_CFLAGS="@LIB_CFLAGS@" LIB_LDFLAGS="@LIB_LDFLAGS@" LIB_PREFIX="@LIB_PREFIX@" LIB_SUFFIX="@LIB_SUFFIX@" LDFLAGS="@LDFLAGS@" LDFLAGS_REEXPORT="@LDFLAGS_REEXPORT@" LDFLAGS_RPATH="@LDFLAGS_RPATH@" LIBS="-lobjfw @RUNTIME_LIBS@ @LIBS@" FRAMEWORK_LIBS="-framework ObjFW" FRAMEWORK_LIBS="$FRAMEWORK_LIBS @RUNTIME_FRAMEWORK_LIBS@ @LIBS@" PLUGIN_CFLAGS="@PLUGIN_CFLAGS@" PLUGIN_LDFLAGS="@PLUGIN_LDFLAGS@" PLUGIN_SUFFIX="@PLUGIN_SUFFIX@" PROG_SUFFIX="@EXEEXT@" STATIC_LIBS="${libdir}/libobjfw.a @LIBS@" VERSION="@PACKAGE_VERSION@" |
︙ | ︙ | |||
101 102 103 104 105 106 107 108 109 110 111 112 113 114 | package_depends_on "$1" ;; esac shift done } parse_packages "$@" flag_printed="no" output_flag() { if test x"$flag_printed" = x"yes"; then printf " %s" "$1" else printf "%s" "$1" | > > > > > | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | package_depends_on "$1" ;; esac shift done } parse_packages "$@" # Add search directories after all packages have been processed so that they # always come first. LIBS="-L${libdir} $LIBS" FRAMEWORK_LIBS="-F${prefix}/Library/Frameworks $FRAMEWORK_LIBS" flag_printed="no" output_flag() { if test x"$flag_printed" = x"yes"; then printf " %s" "$1" else printf "%s" "$1" |
︙ | ︙ |
Modified utils/objfw-embed from [b832fbf4cf] to [a51ac82a5f].
1 2 3 4 5 6 7 8 9 10 11 12 | #!/bin/sh if test $# != 3; then echo "Usage: $0 source_file filename output.m" 1>&2 exit 1 fi exec 1>$3 cat <<EOF #include <stddef.h> #include <stdint.h> | > > > > > > > > > > > > > > > > > > > > | > > > | > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | #!/bin/sh # # Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> # # All rights reserved. # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License version 3.0 only, # as published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License # version 3.0 for more details. # # You should have received a copy of the GNU Lesser General Public License # version 3.0 along with this program. If not, see # <https://www.gnu.org/licenses/>. # if test $# != 3; then echo "Usage: $0 source_file filename output.m" 1>&2 exit 1 fi exec 1>$3 cat <<EOF #include <stddef.h> #include <stdint.h> #ifdef OF_COMPILING_OBJFW # import "OFEmbeddedIRIHandler.h" #else # import <ObjFW/OFEmbeddedIRIHandler.h> #endif static const uint8_t bytes[] = { EOF od -vtx1 "$1" | cut -d' ' -sf2- | \ sed '/^ *$/d;s/^ *//;s/ *$//;s/ */ /g;s/^/0x/;s/ /, 0x/g;s/$/,/' cat <<EOF }; static void __attribute__((__constructor__)) ctor(void) { OFRegisterEmbeddedFile(@"$2", bytes, sizeof(bytes)); } EOF |
Modified utils/objfw-new/Makefile from [fe068759c6] to [8cc4a388ef].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | include ../../extra.mk PROG = objfw-new${PROG_SUFFIX} SRCS = NewApp.m \ NewClass.m \ ObjFWNew.m \ Property.m include ../../buildsys.mk ${PROG}: ${LIBOBJFW_DEP_LVL2} ${LIBOBJFWRT_DEP_LVL2} CPPFLAGS += -I../../src \ -I../../src/runtime \ -I../../src/exceptions \ -I../.. | > | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | include ../../extra.mk PROG = objfw-new${PROG_SUFFIX} SRCS = NewApp.m \ NewClass.m \ NewTest.m \ ObjFWNew.m \ Property.m include ../../buildsys.mk ${PROG}: ${LIBOBJFW_DEP_LVL2} ${LIBOBJFWRT_DEP_LVL2} CPPFLAGS += -I../../src \ -I../../src/runtime \ -I../../src/exceptions \ -I../.. LIBS := -L../../src -lobjfw -L../../src/runtime ${RUNTIME_LIBS} ${LIBS} LD = ${OBJC} LDFLAGS += ${LDFLAGS_RPATH} |
Modified utils/objfw-new/NewApp.m from [a817ca083b] to [867dd88e04].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #import "OFApplication.h" |
︙ | ︙ | |||
44 45 46 47 48 49 50 | @"\n" @"@interface %@: OFObject <OFApplicationDelegate>\n" @"@end\n" @"\n" @"OF_APPLICATION_DELEGATE(%@)\n" @"\n" @"@implementation %@\n" | | > | 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | @"\n" @"@interface %@: OFObject <OFApplicationDelegate>\n" @"@end\n" @"\n" @"OF_APPLICATION_DELEGATE(%@)\n" @"\n" @"@implementation %@\n" @"- (void)applicationDidFinishLaunching: " @"(OFNotification *)notification\n" @"{\n" @" [OFApplication terminate];\n" @"}\n" @"@end\n", name, name, name]; [file close]; } |
Modified utils/objfw-new/NewClass.m from [13b11d77d3] to [160c9fb54e].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #import "Property.h" |
︙ | ︙ |
Added utils/objfw-new/NewTest.m version [bf4310ca02].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #import "OFApplication.h" #import "OFFile.h" #import "OFStdIOStream.h" #import "OFString.h" #import "OFOpenItemFailedException.h" void newTest(OFString *name) { OFString *path = [name stringByAppendingPathExtension: @"m"]; OFFile *file = nil; @try { file = [OFFile fileWithPath: path mode: @"wx"]; } @catch (OFOpenItemFailedException *e) { if (e.errNo != EEXIST) @throw e; [OFStdErr writeFormat: @"File %@ already exists! Aborting...\n", e.path]; [OFApplication terminateWithStatus: 1]; } [file writeFormat: @"#import <ObjFW/ObjFW.h>\n" @"#import <ObjFWTest/ObjFWTest.h>\n" @"\n" @"@interface %@: OTTestCase\n" @"@end\n" @"\n" @"@implementation %@\n" @"@end\n", name, name]; [file close]; } |
Modified utils/objfw-new/ObjFWNew.m from [efa3835453] to [40f4d106fa].
1 | /* | | | | | | > > > > | < > | > | > | > | > > > > > > > > > > > > > > > | | | > > | > > > > > > | > | < > < > > > < > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFApplication.h" #import "OFArray.h" #import "OFObject.h" #import "OFOptionsParser.h" #import "OFStdIOStream.h" #import "OFString.h" @interface ObjFWNew: OFObject <OFApplicationDelegate> @end extern void newApp(OFString *); extern void newClass(OFString *, OFString *, OFMutableArray *); extern void newTest(OFString *); OF_APPLICATION_DELEGATE(ObjFWNew) static void help(OFStream *stream, bool full, int status) { [stream writeFormat: @"Usage: %@ --app|--class|--test [--superclass=] [--property=] name" @"\n", [OFApplication programName]]; if (full) { [stream writeString: @"\n"]; [stream writeLine: @"Options:\n" @" -a --app Create a new app\n" @" -c --class Create a new class\n" @" -h --help Show this help\n" @" -p --property= Add a property to the class.\n" @" E.g.: --property='(readonly, " @"nonatomic) id foo'\n" @" -s --superclass= Specify the superclass for the " @"class\n" @" -t --test Create a new test\n"]; } [OFApplication terminateWithStatus: status]; } @implementation ObjFWNew - (void)applicationDidFinishLaunching: (OFNotification *)notification { bool app, class, test; OFString *superclass = nil, *name; OFMutableArray OF_GENERIC(OFString *) *properties = nil; const OFOptionsParserOption options[] = { { 'a', @"app", 0, &app, NULL }, { 'c', @"class", 0, &class, NULL }, { 'h', @"help", 0, NULL, NULL }, { 'p', @"property", 1, NULL, NULL }, { 's', @"superclass", 1, NULL, &superclass }, { 't', @"test", 0, &test, NULL }, { '\0', nil, 0, NULL, NULL } }; OFOptionsParser *optionsParser; OFUnichar option; if ([OFApplication arguments].count == 0) help(OFStdErr, true, 1); optionsParser = [OFOptionsParser parserWithOptions: options]; while ((option = [optionsParser nextOption]) != '\0') { switch (option) { case 'h': help(OFStdOut, true, 0); break; case 'p': if (properties == nil) properties = [OFMutableArray array]; [properties addObject: optionsParser.argument]; break; case '?': case ':': case '=': help(OFStdErr, false, 1); break; } } if (app + class + test != 1 || optionsParser.remainingArguments.count != 1) help(OFStdErr, false, 1); if ((superclass && !class) || (properties != nil && !class)) help(OFStdErr, false, 1); name = optionsParser.remainingArguments.firstObject; if ([name rangeOfString: @"."].location != OFNotFound) { [OFStdErr writeLine: @"Name must not contain dots!"]; [OFApplication terminate]; } if (app) newApp(name); else if (class) newClass(name, superclass, properties); else if (test) newTest(name); else help(OFStdErr, false, 1); [OFApplication terminate]; } @end |
Modified utils/objfw-new/Property.h from [e9facd5dfc] to [e0d730155c].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFString.h" OF_ASSUME_NONNULL_BEGIN |
︙ | ︙ |
Modified utils/objfw-new/Property.m from [101e199c45] to [4b7980bf57].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "Property.h" #import "OFArray.h" |
︙ | ︙ |
Modified utils/ofarc/Archive.h from [c57fe80fee] to [d4a3c6ba6c].
1 | /* | | | | | | > > > > | < > | | | > > > > > > | | | > | | | | > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFString.h" OF_ASSUME_NONNULL_BEGIN @class OFArray OF_GENERIC(ObjectType); @class OFIRI; @class OFStream; @protocol Archive <OFObject> + (instancetype)archiveWithIRI: (nullable OFIRI *)IRI stream: (OF_KINDOF(OFStream *))stream mode: (OFString *)mode encoding: (OFStringEncoding)encoding; - (instancetype)initWithIRI: (nullable OFIRI *)IRI stream: (OF_KINDOF(OFStream *))stream mode: (OFString *)mode encoding: (OFStringEncoding)encoding; - (void)listFiles; - (void)extractFiles: (OFArray OF_GENERIC(OFString *) *)files; - (void)printFiles: (OFArray OF_GENERIC(OFString *) *)files; @optional - (void)addFiles: (OFArray OF_GENERIC(OFString *) *)files archiveComment: (nullable OFString *)archiveComment; @end OF_ASSUME_NONNULL_END |
Modified utils/ofarc/GZIPArchive.h from [384191029a] to [c70b7f2f37].
1 | /* | | | | | | > > > > | < > | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFGZIPStream.h" #import "Archive.h" @interface GZIPArchive: OFObject <Archive> { OFGZIPStream *_stream; OFIRI *_archiveIRI; } @end |
Modified utils/ofarc/GZIPArchive.m from [2e682cb46c] to [921ad8e721].
1 | /* | | | | | | > > > > | < > | > > | > | | > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFApplication.h" #import "OFArray.h" #import "OFFile.h" #import "OFFileManager.h" #import "OFIRI.h" #import "OFLocale.h" #import "OFStdIOStream.h" #import "GZIPArchive.h" #import "OFArc.h" static OFArc *app; static void setPermissions(OFString *destination, OFIRI *source) { #ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS OFFileManager *fileManager = [OFFileManager defaultManager]; OFFileAttributes attributes = [fileManager attributesOfItemAtIRI: source]; OFFileAttributeKey key = OFFilePOSIXPermissions; OFFileAttributes destinationAttributes = [OFDictionary dictionaryWithObject: [attributes objectForKey: key] forKey: key]; [fileManager setAttributes: destinationAttributes ofItemAtPath: destination]; #endif [app quarantineFile: destination]; } static void setModificationDate(OFString *path, OFGZIPStream *stream) { OFDate *modificationDate = stream.modificationDate; OFFileAttributes attributes; |
︙ | ︙ | |||
61 62 63 64 65 66 67 | @implementation GZIPArchive + (void)initialize { if (self == [GZIPArchive class]) app = (OFArc *)[OFApplication sharedApplication].delegate; } | | < < < < < < < < | > > > > > > > > > > > > > | | < | | | 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | @implementation GZIPArchive + (void)initialize { if (self == [GZIPArchive class]) app = (OFArc *)[OFApplication sharedApplication].delegate; } + (instancetype)archiveWithIRI: (OFIRI *)IRI stream: (OF_KINDOF(OFStream *))stream mode: (OFString *)mode encoding: (OFStringEncoding)encoding { return [[[self alloc] initWithIRI: IRI stream: stream mode: mode encoding: encoding] autorelease]; } - (instancetype)initWithIRI: (OFIRI *)IRI stream: (OF_KINDOF(OFStream *))stream mode: (OFString *)mode encoding: (OFStringEncoding)encoding { self = [super init]; @try { _stream = [[OFGZIPStream alloc] initWithStream: stream mode: mode]; _archiveIRI = [IRI copy]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_stream release]; [_archiveIRI release]; [super dealloc]; } - (void)listFiles { [OFStdErr writeLine: OF_LOCALIZED(@"cannot_list_gz", @"Cannot list files of a .gz archive!")]; app->_exitStatus = 1; } - (void)extractFiles: (OFArray OF_GENERIC(OFString *) *)files { OFString *fileName; OFFile *output; if (files.count != 0) { [OFStdErr writeLine: OF_LOCALIZED( @"cannot_extract_specific_file_from_gz", @"Cannot extract a specific file of a .gz archive!")]; app->_exitStatus = 1; return; } fileName = _archiveIRI.IRIByDeletingPathExtension.lastPathComponent; if (app->_outputLevel >= 0) [OFStdOut writeString: OF_LOCALIZED(@"extracting_file", @"Extracting %[file]...", @"file", fileName)]; if (![app shouldExtractFile: fileName outFileName: fileName]) return; output = [OFFile fileWithPath: fileName mode: @"w"]; setPermissions(fileName, _archiveIRI); while (!_stream.atEndOfStream) { ssize_t length = [app copyBlockFromStream: _stream toStream: output fileName: fileName]; if (length < 0) { |
︙ | ︙ | |||
152 153 154 155 156 157 158 | @"Extracting %[file]... done", @"file", fileName)]; } } - (void)printFiles: (OFArray OF_GENERIC(OFString *) *)files { | | | | 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | @"Extracting %[file]... done", @"file", fileName)]; } } - (void)printFiles: (OFArray OF_GENERIC(OFString *) *)files { OFString *fileName = _archiveIRI.IRIByDeletingPathExtension.lastPathComponent; if (files.count > 0) { [OFStdErr writeLine: OF_LOCALIZED( @"cannot_print_specific_file_from_gz", @"Cannot print a specific file of a .gz archive!")]; app->_exitStatus = 1; return; |
︙ | ︙ |
Modified utils/ofarc/LHAArchive.h from [5ad6942309] to [01a81b9c55].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFLHAArchive.h" #import "Archive.h" @interface LHAArchive: OFObject <Archive> |
︙ | ︙ |
Modified utils/ofarc/LHAArchive.m from [7f7a619844] to [69dcc3a6c2].
1 | /* | | | | | | > > > > | < > | > > > > > > > > | | | | < | | | | | > > > > | | > > > > | < < < < < < < < | > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #import "OFApplication.h" #import "OFArray.h" #import "OFDate.h" #import "OFFile.h" #import "OFFileManager.h" #import "OFIRI.h" #import "OFLocale.h" #import "OFNumber.h" #import "OFPair.h" #import "OFSet.h" #import "OFStdIOStream.h" #import "OFString.h" #import "LHAArchive.h" #import "OFArc.h" #import "OFSetItemAttributesFailedException.h" static OFArc *app; static OFString * indent(OFString *string) { return [string stringByReplacingOccurrencesOfString: @"\n" withString: @"\n\t"]; } static void setPermissions(OFString *path, OFLHAArchiveEntry *entry) { #ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS OFNumber *POSIXPermissions = entry.POSIXPermissions; if (POSIXPermissions != nil) { OFFileAttributes attributes; POSIXPermissions = [OFNumber numberWithUnsignedShort: POSIXPermissions.unsignedShortValue & 0777]; attributes = [OFDictionary dictionaryWithObject: POSIXPermissions forKey: OFFilePOSIXPermissions]; [[OFFileManager defaultManager] setAttributes: attributes ofItemAtPath: path]; } #endif [app quarantineFile: path]; } static void setModificationDate(OFString *path, OFLHAArchiveEntry *entry) { OFFileAttributes attributes = [OFDictionary dictionaryWithObject: entry.modificationDate forKey: OFFileModificationDate]; @try { [[OFFileManager defaultManager] setAttributes: attributes ofItemAtPath: path]; } @catch (OFSetItemAttributesFailedException *e) { if (e.errNo != EISDIR) @throw e; } } @implementation LHAArchive + (void)initialize { if (self == [LHAArchive class]) app = (OFArc *)[OFApplication sharedApplication].delegate; } + (instancetype)archiveWithIRI: (OFIRI *)IRI stream: (OF_KINDOF(OFStream *))stream mode: (OFString *)mode encoding: (OFStringEncoding)encoding { return [[[self alloc] initWithIRI: IRI stream: stream mode: mode encoding: encoding] autorelease]; } - (instancetype)initWithIRI: (OFIRI *)IRI stream: (OF_KINDOF(OFStream *))stream mode: (OFString *)mode encoding: (OFStringEncoding)encoding { self = [super init]; @try { _archive = [[OFLHAArchive alloc] initWithStream: stream mode: mode]; if (encoding != OFStringEncodingAutodetect) |
︙ | ︙ | |||
222 223 224 225 226 227 228 | [OFString stringWithFormat: @"%c", entry.operatingSystemIdentifier]; [OFStdOut writeString: @"\t"]; [OFStdOut writeLine: OF_LOCALIZED( @"list_osid", @"Operating system identifier: " | | | 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | [OFString stringWithFormat: @"%c", entry.operatingSystemIdentifier]; [OFStdOut writeString: @"\t"]; [OFStdOut writeLine: OF_LOCALIZED( @"list_osid", @"Operating system identifier: " @"%[osid]", @"osid", OSID)]; } } if (app->_outputLevel >= 3) { OFString *extensions = indent(entry.extensions.description); |
︙ | ︙ | |||
247 248 249 250 251 252 253 254 255 256 257 258 259 260 | } } - (void)extractFiles: (OFArray OF_GENERIC(OFString *) *)files { OFFileManager *fileManager = [OFFileManager defaultManager]; bool all = (files.count == 0); OFMutableSet OF_GENERIC(OFString *) *missing = [OFMutableSet setWithArray: files]; OFLHAArchiveEntry *entry; while ((entry = [_archive nextEntry]) != nil) { void *pool = objc_autoreleasePoolPush(); OFString *fileName = entry.fileName; | > | 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | } } - (void)extractFiles: (OFArray OF_GENERIC(OFString *) *)files { OFFileManager *fileManager = [OFFileManager defaultManager]; bool all = (files.count == 0); OFMutableArray *delayedModificationDates = [OFMutableArray array]; OFMutableSet OF_GENERIC(OFString *) *missing = [OFMutableSet setWithArray: files]; OFLHAArchiveEntry *entry; while ((entry = [_archive nextEntry]) != nil) { void *pool = objc_autoreleasePoolPush(); OFString *fileName = entry.fileName; |
︙ | ︙ | |||
285 286 287 288 289 290 291 | @"Extracting %[file]...", @"file", fileName)]; if ([fileName hasSuffix: @"/"]) { [fileManager createDirectoryAtPath: outFileName createParents: true]; setPermissions(outFileName, entry); | > > > > > | > > | 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | @"Extracting %[file]...", @"file", fileName)]; if ([fileName hasSuffix: @"/"]) { [fileManager createDirectoryAtPath: outFileName createParents: true]; setPermissions(outFileName, entry); /* * As creating a new file in a directory changes its * modification date, we can only set it once all files * have been created. */ [delayedModificationDates addObject: [OFPair pairWithFirstObject: outFileName secondObject: entry]]; if (app->_outputLevel >= 0) { [OFStdOut writeString: @"\r"]; [OFStdOut writeLine: OF_LOCALIZED( @"extracting_file_done", @"Extracting %[file]... done", @"file", fileName)]; |
︙ | ︙ | |||
355 356 357 358 359 360 361 362 363 364 365 366 367 368 | @"file", fileName)]; } outer_loop_end: objc_autoreleasePoolPop(pool); } if (missing.count > 0) { for (OFString *file in missing) [OFStdErr writeLine: OF_LOCALIZED( @"file_not_in_archive", @"File %[file] is not in the archive!", @"file", file)]; | > > > | 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 | @"file", fileName)]; } outer_loop_end: objc_autoreleasePoolPop(pool); } for (OFPair *pair in delayedModificationDates) setModificationDate(pair.firstObject, pair.secondObject); if (missing.count > 0) { for (OFString *file in missing) [OFStdErr writeLine: OF_LOCALIZED( @"file_not_in_archive", @"File %[file] is not in the archive!", @"file", file)]; |
︙ | ︙ | |||
416 417 418 419 420 421 422 423 424 425 | @"File %[file] is not in the archive!", @"file", file)]; app->_exitStatus = 1; } } - (void)addFiles: (OFArray OF_GENERIC(OFString *) *)files { OFFileManager *fileManager = [OFFileManager defaultManager]; | > < < < < < < < | 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 | @"File %[file] is not in the archive!", @"file", file)]; app->_exitStatus = 1; } } - (void)addFiles: (OFArray OF_GENERIC(OFString *) *)files archiveComment: (OFString *)archiveComment { OFFileManager *fileManager = [OFFileManager defaultManager]; for (OFString *fileName in files) { void *pool = objc_autoreleasePoolPush(); OFFileAttributes attributes; OFFileAttributeType type; OFMutableLHAArchiveEntry *entry; OFStream *output; |
︙ | ︙ |
Modified utils/ofarc/Makefile from [482a60034a] to [c3efee1ee5].
1 2 3 4 5 6 7 | include ../../extra.mk PROG = ofarc${PROG_SUFFIX} SRCS = GZIPArchive.m \ LHAArchive.m \ OFArc.m \ TarArchive.m \ | | > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | include ../../extra.mk PROG = ofarc${PROG_SUFFIX} SRCS = GZIPArchive.m \ LHAArchive.m \ OFArc.m \ TarArchive.m \ ZIPArchive.m \ ZooArchive.m DATA = localization/de.json \ localization/localizations.json include ../../buildsys.mk PACKAGE_NAME = ofarc ${PROG}: ${LIBOBJFW_DEP_LVL2} ${LIBOBJFWRT_DEP_LVL2} CPPFLAGS += -I../../src \ -I../../src/runtime \ -I../../src/exceptions \ -I../.. \ -DLOCALIZATION_DIR=\"${datadir}/ofarc/localization\" LIBS := -L../../src -L../../src/tls ${OFHTTP_LIBS} -lobjfw \ -L../../src/runtime ${RUNTIME_LIBS} \ ${LIBS} LD = ${OBJC} LDFLAGS += ${LDFLAGS_RPATH} |
Modified utils/ofarc/OFArc.h from [926be48eea] to [3412bfb9c2].
1 | /* | | | | | | > > > > | < > | > > > < | | | | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" #import "OFString.h" #import "Archive.h" OF_ASSUME_NONNULL_BEGIN @class OFIRI; #ifndef S_IRWXG # define S_IRWXG 0 #endif #ifndef S_IRWXO # define S_IRWXO 0 #endif @interface OFArc: OFObject <OFApplicationDelegate> { OFData *_quarantine; int8_t _overwrite; @public int8_t _outputLevel; int _exitStatus; } - (id <Archive>)openArchiveWithIRI: (nullable OFIRI *)IRI type: (OFString *)type mode: (char)mode encoding: (OFStringEncoding)encoding; - (bool)shouldExtractFile: (OFString *)fileName outFileName: (OFString *)outFileName; - (ssize_t)copyBlockFromStream: (OFStream *)input toStream: (OFStream *)output fileName: (OFString *)fileName; - (nullable OFString *)safeLocalPathForPath: (OFString *)path; - (void)quarantineFile: (OFString *)path; @end OF_ASSUME_NONNULL_END |
Modified utils/ofarc/OFArc.m from [92125fd380] to [f2ee58a5d5].
1 | /* | | | | | | > > > > | < > | > > < > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <string.h> #import "OFApplication.h" #import "OFArray.h" #import "OFFile.h" #import "OFFileManager.h" #import "OFIRI.h" #import "OFIRIHandler.h" #import "OFLocale.h" #import "OFOptionsParser.h" #import "OFSandbox.h" #import "OFStdIOStream.h" #import "OFArc.h" #import "GZIPArchive.h" #import "LHAArchive.h" #import "TarArchive.h" #import "ZIPArchive.h" #import "ZooArchive.h" #import "OFCreateDirectoryFailedException.h" #import "OFGetItemAttributesFailedException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFNotImplementedException.h" #import "OFOpenItemFailedException.h" #import "OFReadFailedException.h" #import "OFSeekFailedException.h" #import "OFWriteFailedException.h" |
︙ | ︙ | |||
53 54 55 56 57 58 59 | @"Usage: %[prog] -[acCfhlnpqtvx] archive.zip [file1 file2 ...]", @"prog", [OFApplication programName])]; if (full) { [stream writeString: @"\n"]; [stream writeLine: OF_LOCALIZED(@"full_usage", @"Options:\n" | | > > | | | > > | | | > > | > | | | | | | | | > | | 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | @"Usage: %[prog] -[acCfhlnpqtvx] archive.zip [file1 file2 ...]", @"prog", [OFApplication programName])]; if (full) { [stream writeString: @"\n"]; [stream writeLine: OF_LOCALIZED(@"full_usage", @"Options:\n" @" -a --append Append to archive\n" @" --archive-comment= Archive comment to use when " @"creating or appending\n" @" -c --create Create archive\n" @" -C --directory= Extract into the specified " @"directory\n" @" -E --encoding= The encoding used by the " @"archive\n" @" (only tar, lha and zoo files)" @"\n" @" -f --force Force / overwrite files\n" @" -h --help Show this help\n" @" --iri Use an IRI to access the " @"archive\n" @" -l --list List all files in the archive" @"\n" @" -n --no-clobber Never overwrite files\n" @" -p --print Print one or more files from " @"the archive\n" @" -q --quiet Quiet mode (no output, " @"except errors)\n" @" -t --type= Archive type (gz, lha, tar, " @"tgz, zip, zoo)\n" @" -v --verbose Verbose output for file list" @"\n" @" -x --extract Extract files")]; } [OFApplication terminateWithStatus: status]; } static void mutuallyExclusiveError(OFUnichar shortOption1, OFString *longOption1, |
︙ | ︙ | |||
95 96 97 98 99 100 101 102 103 104 105 106 107 108 | @"are mutually exclusive!", @"shortopt1", shortOption1Str, @"longopt1", longOption1, @"shortopt2", shortOption2Str, @"longopt2", longOption2)]; [OFApplication terminateWithStatus: 1]; } static void mutuallyExclusiveError5(OFUnichar shortOption1, OFString *longOption1, OFUnichar shortOption2, OFString *longOption2, OFUnichar shortOption3, OFString *longOption3, OFUnichar shortOption4, OFString *longOption4, OFUnichar shortOption5, OFString *longOption5) | > > > > > > > > > > > > | 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | @"are mutually exclusive!", @"shortopt1", shortOption1Str, @"longopt1", longOption1, @"shortopt2", shortOption2Str, @"longopt2", longOption2)]; [OFApplication terminateWithStatus: 1]; } static OFIRI * argumentToIRI(OFString *argument, bool isIRI) { if (isIRI) return [OFIRI IRIWithString: argument]; if ([argument isEqual: @"-"]) return nil; return [OFIRI fileIRIWithPath: argument]; } static void mutuallyExclusiveError5(OFUnichar shortOption1, OFString *longOption1, OFUnichar shortOption2, OFString *longOption2, OFUnichar shortOption3, OFString *longOption3, OFUnichar shortOption4, OFString *longOption4, OFUnichar shortOption5, OFString *longOption5) |
︙ | ︙ | |||
142 143 144 145 146 147 148 | [OFStdErr writeLine: OF_LOCALIZED( @"writing_not_supported", @"Writing archives of type %[type] is not (yet) supported!", @"type", type)]; } static void | | > > > > > > > | | | > > > > | > | | | 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | [OFStdErr writeLine: OF_LOCALIZED( @"writing_not_supported", @"Writing archives of type %[type] is not (yet) supported!", @"type", type)]; } static void addFiles(id <Archive> archive, OFArray OF_GENERIC(OFString *) *files, OFString *archiveComment) { OFMutableArray *expandedFiles = [OFMutableArray arrayWithCapacity: files.count]; OFFileManager *fileManager = [OFFileManager defaultManager]; for (OFString *file in files) { OFFileAttributes attributes = [fileManager attributesOfItemAtPath: file]; if ([attributes.fileType isEqual: OFFileTypeDirectory]) [expandedFiles addObjectsFromArray: [fileManager subpathsOfDirectoryAtPath: file]]; else [expandedFiles addObject: file]; } if (expandedFiles.count < 1) { [OFStdErr writeLine: OF_LOCALIZED(@"add_no_file_specified", @"Need one or more files to add!")]; [OFApplication terminateWithStatus: 1]; } [archive addFiles: expandedFiles archiveComment: archiveComment]; } @implementation OFArc - (void)applicationDidFinishLaunching: (OFNotification *)notification { OFString *archiveComment, *outputDir, *encodingString, *type; bool isIRI; const OFOptionsParserOption options[] = { { 'a', @"append", 0, NULL, NULL }, { 0, @"archive-comment", 1, NULL, &archiveComment }, { 'c', @"create", 0, NULL, NULL }, { 'C', @"directory", 1, NULL, &outputDir }, { 'E', @"encoding", 1, NULL, &encodingString }, { 'f', @"force", 0, NULL, NULL }, { 'h', @"help", 0, NULL, NULL }, { 0, @"iri", 0, &isIRI, NULL }, { 'l', @"list", 0, NULL, NULL }, { 'n', @"no-clobber", 0, NULL, NULL }, { 'p', @"print", 0, NULL, NULL }, { 'q', @"quiet", 0, NULL, NULL }, { 't', @"type", 1, NULL, &type }, { 'v', @"verbose", 0, NULL, NULL }, { 'x', @"extract", 0, NULL, NULL }, { '\0', nil, 0, NULL, NULL } }; OFUnichar option, mode = '\0'; OFStringEncoding encoding = OFStringEncodingAutodetect; OFOptionsParser *optionsParser; OFArray OF_GENERIC(OFString *) *remainingArguments, *files; OFIRI *IRI; id <Archive> archive; #ifdef OF_HAVE_SANDBOX OFSandbox *sandbox = [OFSandbox sandbox]; sandbox.allowsStdIO = true; sandbox.allowsReadingFiles = true; sandbox.allowsWritingFiles = true; sandbox.allowsCreatingFiles = true; sandbox.allowsChangingFileAttributes = true; sandbox.allowsUserDatabaseReading = true; /* Dropped after parsing options */ sandbox.allowsUnveil = true; [OFApplication of_activateSandbox: sandbox]; #endif #ifndef OF_AMIGAOS [OFLocale addLocalizationDirectoryIRI: [OFIRI fileIRIWithPath: @LOCALIZATION_DIR]]; #else [OFLocale addLocalizationDirectoryIRI: [OFIRI fileIRIWithPath: @"PROGDIR:/share/ofarc/localization"]]; #endif optionsParser = [OFOptionsParser parserWithOptions: options]; while ((option = [optionsParser nextOption]) != '\0') { switch (option) { case 'f': if (_overwrite < 0) |
︙ | ︙ | |||
333 334 335 336 337 338 339 340 341 342 343 | switch (mode) { case 'a': case 'c': if (remainingArguments.count < 1) help(OFStdErr, false, 1); files = [remainingArguments objectsInRange: OFMakeRange(1, remainingArguments.count - 1)]; #ifdef OF_HAVE_SANDBOX | > | | | < | | | | > > | | | < | | | > > > > | | < < < | < | | | > | | | < | | | > > > > > > > > > > > > > < < < | | < < < | | | | | > < < < < < < | > | > | < < < | | > > | | | | > > > | > > | > | | | > | | | > | | | > | | | > | | > > > > > < < < | | < < < | | | | | | | | | 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 | switch (mode) { case 'a': case 'c': if (remainingArguments.count < 1) help(OFStdErr, false, 1); IRI = argumentToIRI(remainingArguments.firstObject, isIRI); files = [remainingArguments objectsInRange: OFMakeRange(1, remainingArguments.count - 1)]; #ifdef OF_HAVE_SANDBOX if ([IRI.scheme isEqual: @"file"]) [sandbox unveilPath: IRI.fileSystemRepresentation permissions: (mode == 'a' ? @"rwc" : @"wc")]; for (OFString *path in files) [sandbox unveilPath: path permissions: @"r"]; sandbox.allowsUnveil = false; [OFApplication of_activateSandbox: sandbox]; #endif archive = [self openArchiveWithIRI: IRI type: type mode: mode encoding: encoding]; addFiles(archive, files, archiveComment); break; case 'l': if (remainingArguments.count != 1) help(OFStdErr, false, 1); IRI = argumentToIRI(remainingArguments.firstObject, isIRI); #ifdef OF_HAVE_SANDBOX if ([IRI.scheme isEqual: @"file"]) [sandbox unveilPath: IRI.fileSystemRepresentation permissions: @"r"]; sandbox.allowsUnveil = false; [OFApplication of_activateSandbox: sandbox]; #endif archive = [self openArchiveWithIRI: IRI type: type mode: mode encoding: encoding]; [archive listFiles]; break; case 'p': if (remainingArguments.count < 1) help(OFStdErr, false, 1); IRI = argumentToIRI(remainingArguments.firstObject, isIRI); files = [remainingArguments objectsInRange: OFMakeRange(1, remainingArguments.count - 1)]; #ifdef OF_HAVE_SANDBOX if ([IRI.scheme isEqual: @"file"]) [sandbox unveilPath: IRI.fileSystemRepresentation permissions: @"r"]; sandbox.allowsUnveil = false; [OFApplication of_activateSandbox: sandbox]; #endif archive = [self openArchiveWithIRI: IRI type: type mode: mode encoding: encoding]; [archive printFiles: files]; break; case 'x': if (remainingArguments.count < 1) help(OFStdErr, false, 1); IRI = argumentToIRI(remainingArguments.firstObject, isIRI); files = [remainingArguments objectsInRange: OFMakeRange(1, remainingArguments.count - 1)]; #ifdef OF_HAVE_SANDBOX if ([IRI.scheme isEqual: @"file"]) [sandbox unveilPath: IRI.fileSystemRepresentation permissions: @"r"]; if (files.count > 0) for (OFString *path in files) [sandbox unveilPath: path permissions: @"wc"]; else { OFString *path = outputDir; if (path == nil) path = [[OFFileManager defaultManager] currentDirectoryPath]; /* We need 'r' to change the directory to it. */ [sandbox unveilPath: path permissions: @"rwc"]; } sandbox.allowsUnveil = false; [OFApplication of_activateSandbox: sandbox]; #endif archive = [self openArchiveWithIRI: IRI type: type mode: mode encoding: encoding]; #ifdef OF_MACOS @try { OFString *attributeName = @"com.apple.quarantine"; _quarantine = [[[OFFileManager defaultManager] extendedAttributeDataForName: attributeName ofItemAtIRI: IRI] retain]; } @catch (OFGetItemAttributesFailedException *e) { if (e.errNo != /*ENOATTR*/ 93) @throw e; } #endif if (outputDir != nil) { OFFileManager *fileManager = [OFFileManager defaultManager]; if (![fileManager directoryExistsAtPath: outputDir]) [fileManager createDirectoryAtPath: outputDir createParents: true]; [fileManager changeCurrentDirectoryPath: outputDir]; } @try { [archive extractFiles: files]; } @catch (OFCreateDirectoryFailedException *e) { [OFStdErr writeString: @"\r"]; [OFStdErr writeLine: OF_LOCALIZED( @"failed_to_create_directory", @"Failed to create directory %[dir]: %[error]", @"dir", e.IRI.fileSystemRepresentation, @"error", OFStrError(e.errNo))]; _exitStatus = 1; } @catch (OFOpenItemFailedException *e) { [OFStdErr writeString: @"\r"]; [OFStdErr writeLine: OF_LOCALIZED( @"failed_to_open_file", @"Failed to open file %[file]: %[error]", @"file", e.path, @"error", OFStrError(e.errNo))]; _exitStatus = 1; } break; default: help(OFStdErr, true, 1); break; } [OFApplication terminateWithStatus: _exitStatus]; } - (id <Archive>)openArchiveWithIRI: (OFIRI *)IRI type: (OFString *)type mode: (char)mode encoding: (OFStringEncoding)encoding { /* To make clang-analyzer happy about assigning nil to path later. */ OFString *modeString, *fileModeString; OFStream *file = nil; id <Archive> archive = nil; switch (mode) { case 'a': modeString = @"a"; fileModeString = @"r+"; break; case 'c': modeString = @"w"; fileModeString = @"w+"; break; case 'l': case 'p': case 'x': modeString = fileModeString = @"r"; break; default: @throw [OFInvalidArgumentException exception]; } if (IRI == nil) { switch (mode) { case 'a': case 'c': file = OFStdOut; break; case 'l': case 'p': case 'x': file = OFStdIn; break; default: @throw [OFInvalidArgumentException exception]; } } else { @try { file = [OFIRIHandler openItemAtIRI: IRI mode: fileModeString]; } @catch (OFOpenItemFailedException *e) { [OFStdErr writeString: @"\r"]; [OFStdErr writeLine: OF_LOCALIZED( @"failed_to_open_file", @"Failed to open file %[file]: %[error]", @"file", e.IRI.string, @"error", OFStrError(e.errNo))]; [OFApplication terminateWithStatus: 1]; } } if (type == nil || [type isEqual: @"auto"]) { OFString *lowercasePath = IRI.path.lowercaseString; /* This one has to be first for obvious reasons */ if ([lowercasePath hasSuffix: @".tar.gz"] || [lowercasePath hasSuffix: @".tgz"]) type = @"tgz"; else if ([lowercasePath hasSuffix: @".gz"]) type = @"gz"; else if ([lowercasePath hasSuffix: @".lha"] || [lowercasePath hasSuffix: @".lzh"] || [lowercasePath hasSuffix: @".lzs"] || [lowercasePath hasSuffix: @".pma"]) type = @"lha"; else if ([lowercasePath hasSuffix: @".tar"]) type = @"tar"; else if ([lowercasePath hasSuffix: @".zoo"]) type = @"zoo"; else type = @"zip"; } @try { if ([type isEqual: @"gz"]) archive = [GZIPArchive archiveWithIRI: IRI stream: file mode: modeString encoding: encoding]; else if ([type isEqual: @"lha"]) archive = [LHAArchive archiveWithIRI: IRI stream: file mode: modeString encoding: encoding]; else if ([type isEqual: @"tar"]) archive = [TarArchive archiveWithIRI: IRI stream: file mode: modeString encoding: encoding]; else if ([type isEqual: @"tgz"]) { OFStream *GZIPStream = [OFGZIPStream streamWithStream: file mode: modeString]; archive = [TarArchive archiveWithIRI: IRI stream: GZIPStream mode: modeString encoding: encoding]; } else if ([type isEqual: @"zip"]) archive = [ZIPArchive archiveWithIRI: IRI stream: file mode: modeString encoding: encoding]; else if ([type isEqual: @"zoo"]) archive = [ZooArchive archiveWithIRI: IRI stream: file mode: modeString encoding: encoding]; else { [OFStdErr writeLine: OF_LOCALIZED( @"unknown_archive_type", @"Unknown archive type: %[type]", @"type", type)]; goto error; } } @catch (OFNotImplementedException *e) { if ((mode == 'a' || mode == 'c') && sel_isEqual(e.selector, @selector(initWithStream:mode:))) { writingNotSupported(type); goto error; } @throw e; } @catch (OFReadFailedException *e) { [OFStdErr writeLine: OF_LOCALIZED(@"failed_to_read_file", @"Failed to read file %[file]: %[error]", @"file", IRI.string, @"error", OFStrError(e.errNo))]; goto error; } @catch (OFSeekFailedException *e) { [OFStdErr writeLine: OF_LOCALIZED(@"failed_to_seek_in_file", @"Failed to seek in file %[file]: %[error]", @"file", IRI.string, @"error", OFStrError(e.errNo))]; goto error; } @catch (OFInvalidFormatException *e) { [OFStdErr writeLine: OF_LOCALIZED( @"file_is_not_a_valid_archive", @"File %[file] is not a valid archive!", @"file", IRI.string)]; goto error; } if ((mode == 'a' || mode == 'c') && ![archive respondsToSelector: @selector(addFiles:archiveComment:)]) { writingNotSupported(type); goto error; } return archive; error: if (mode == 'c' && IRI != nil) [[OFFileManager defaultManager] removeItemAtIRI: IRI]; [OFApplication terminateWithStatus: 1]; abort(); } - (bool)shouldExtractFile: (OFString *)fileName outFileName: (OFString *)outFileName { OFString *line; |
︙ | ︙ | |||
711 712 713 714 715 716 717 | { char buffer[bufferSize]; size_t length; @try { length = [input readIntoBuffer: buffer length: bufferSize]; } @catch (OFReadFailedException *e) { | < < < | < < < | | 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 | { char buffer[bufferSize]; size_t length; @try { length = [input readIntoBuffer: buffer length: bufferSize]; } @catch (OFReadFailedException *e) { [OFStdOut writeString: @"\r"]; [OFStdErr writeLine: OF_LOCALIZED(@"failed_to_read_file", @"Failed to read file %[file]: %[error]", @"file", fileName, @"error", OFStrError(e.errNo))]; return -1; } @try { [output writeBuffer: buffer length: length]; } @catch (OFWriteFailedException *e) { [OFStdOut writeString: @"\r"]; [OFStdErr writeLine: OF_LOCALIZED(@"failed_to_write_file", @"Failed to write file %[file]: %[error]", @"file", fileName, @"error", OFStrError(e.errNo))]; return -1; } return length; } - (OFString *)safeLocalPathForPath: (OFString *)path |
︙ | ︙ | |||
784 785 786 787 788 789 790 791 | [path retain]; objc_autoreleasePoolPop(pool); return [path autorelease]; } @end | > > > > > > > > > > > | 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 | [path retain]; objc_autoreleasePoolPop(pool); return [path autorelease]; } - (void)quarantineFile: (OFString *)path { #ifdef OF_MACOS if (_quarantine != nil) [[OFFileManager defaultManager] setExtendedAttributeData: _quarantine forName: @"com.apple.quarantine" ofItemAtPath: path]; #endif } @end |
Modified utils/ofarc/TarArchive.h from [5ee57845a6] to [3eb2e0fc33].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFTarArchive.h" #import "Archive.h" @interface TarArchive: OFObject <Archive> |
︙ | ︙ |
Modified utils/ofarc/TarArchive.m from [1feea72626] to [5f6c2853e6].
1 | /* | | | | | | > > > > | < > | > > > > > > > > > > | | > > > > | < < < < < < < < | > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #import "OFApplication.h" #import "OFArray.h" #import "OFDate.h" #import "OFFile.h" #import "OFFileManager.h" #import "OFLocale.h" #import "OFNumber.h" #import "OFPair.h" #import "OFSet.h" #import "OFStdIOStream.h" #import "OFString.h" #import "TarArchive.h" #import "OFArc.h" #import "OFSetItemAttributesFailedException.h" static OFArc *app; static void setPermissions(OFString *path, OFTarArchiveEntry *entry) { #ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS OFNumber *POSIXPermissions = [OFNumber numberWithUnsignedLongLong: entry.POSIXPermissions.longLongValue & 0777]; OFFileAttributes attributes = [OFDictionary dictionaryWithObject: POSIXPermissions forKey: OFFilePOSIXPermissions]; [[OFFileManager defaultManager] setAttributes: attributes ofItemAtPath: path]; #endif [app quarantineFile: path]; } static void setModificationDate(OFString *path, OFTarArchiveEntry *entry) { OFDate *modificationDate = entry.modificationDate; OFFileAttributes attributes; if (modificationDate == nil) return; attributes = [OFDictionary dictionaryWithObject: modificationDate forKey: OFFileModificationDate]; @try { [[OFFileManager defaultManager] setAttributes: attributes ofItemAtPath: path]; } @catch (OFSetItemAttributesFailedException *e) { if (e.errNo != EISDIR) @throw e; } } @implementation TarArchive + (void)initialize { if (self == [TarArchive class]) app = (OFArc *)[OFApplication sharedApplication].delegate; } + (instancetype)archiveWithIRI: (OFIRI *)IRI stream: (OF_KINDOF(OFStream *))stream mode: (OFString *)mode encoding: (OFStringEncoding)encoding { return [[[self alloc] initWithIRI: IRI stream: stream mode: mode encoding: encoding] autorelease]; } - (instancetype)initWithIRI: (OFIRI *)IRI stream: (OF_KINDOF(OFStream *))stream mode: (OFString *)mode encoding: (OFStringEncoding)encoding { self = [super init]; @try { _archive = [[OFTarArchive alloc] initWithStream: stream mode: mode]; if (encoding != OFStringEncodingAutodetect) |
︙ | ︙ | |||
268 269 270 271 272 273 274 275 276 277 278 279 280 281 | } } - (void)extractFiles: (OFArray OF_GENERIC(OFString *) *)files { OFFileManager *fileManager = [OFFileManager defaultManager]; bool all = (files.count == 0); OFMutableSet OF_GENERIC(OFString *) *missing = [OFMutableSet setWithArray: files]; OFTarArchiveEntry *entry; while ((entry = [_archive nextEntry]) != nil) { void *pool = objc_autoreleasePoolPush(); OFString *fileName = entry.fileName; | > | 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | } } - (void)extractFiles: (OFArray OF_GENERIC(OFString *) *)files { OFFileManager *fileManager = [OFFileManager defaultManager]; bool all = (files.count == 0); OFMutableArray *delayedModificationDates = [OFMutableArray array]; OFMutableSet OF_GENERIC(OFString *) *missing = [OFMutableSet setWithArray: files]; OFTarArchiveEntry *entry; while ((entry = [_archive nextEntry]) != nil) { void *pool = objc_autoreleasePoolPush(); OFString *fileName = entry.fileName; |
︙ | ︙ | |||
319 320 321 322 323 324 325 | if (type == OFTarArchiveEntryTypeDirectory || (type == OFTarArchiveEntryTypeFile && [fileName hasSuffix: @"/"])) { [fileManager createDirectoryAtPath: outFileName createParents: true]; setPermissions(outFileName, entry); | > > > > > | > > | 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 | if (type == OFTarArchiveEntryTypeDirectory || (type == OFTarArchiveEntryTypeFile && [fileName hasSuffix: @"/"])) { [fileManager createDirectoryAtPath: outFileName createParents: true]; setPermissions(outFileName, entry); /* * As creating a new file in a directory changes its * modification date, we can only set it once all files * have been created. */ [delayedModificationDates addObject: [OFPair pairWithFirstObject: outFileName secondObject: entry]]; if (app->_outputLevel >= 0) { [OFStdOut writeString: @"\r"]; [OFStdOut writeLine: OF_LOCALIZED( @"extracting_file_done", @"Extracting %[file]... done", @"file", fileName)]; |
︙ | ︙ | |||
389 390 391 392 393 394 395 396 397 398 399 400 401 402 | @"file", fileName)]; } outer_loop_end: objc_autoreleasePoolPop(pool); } if (missing.count > 0) { for (OFString *file in missing) [OFStdErr writeLine: OF_LOCALIZED( @"file_not_in_archive", @"File %[file] is not in the archive!", @"file", file)]; | > > > | 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 | @"file", fileName)]; } outer_loop_end: objc_autoreleasePoolPop(pool); } for (OFPair *pair in delayedModificationDates) setModificationDate(pair.firstObject, pair.secondObject); if (missing.count > 0) { for (OFString *file in missing) [OFStdErr writeLine: OF_LOCALIZED( @"file_not_in_archive", @"File %[file] is not in the archive!", @"file", file)]; |
︙ | ︙ | |||
450 451 452 453 454 455 456 457 458 459 | @"File %[file] is not in the archive!", @"file", file)]; app->_exitStatus = 1; } } - (void)addFiles: (OFArray OF_GENERIC(OFString *) *)files { OFFileManager *fileManager = [OFFileManager defaultManager]; | > < < < < < < < | 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 | @"File %[file] is not in the archive!", @"file", file)]; app->_exitStatus = 1; } } - (void)addFiles: (OFArray OF_GENERIC(OFString *) *)files archiveComment: (OFString *)archiveComment { OFFileManager *fileManager = [OFFileManager defaultManager]; for (OFString *fileName in files) { void *pool = objc_autoreleasePoolPush(); OFFileAttributes attributes; OFFileAttributeType type; OFMutableTarArchiveEntry *entry; OFStream *output; |
︙ | ︙ |
Modified utils/ofarc/ZIPArchive.h from [8566715690] to [2cb2734914].
1 | /* | | | | | | > > > > | < > | | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFZIPArchive.h" #import "Archive.h" @interface ZIPArchive: OFObject <OFZIPArchiveDelegate, Archive> { OFIRI *_archiveIRI; OFZIPArchive *_archive; } @end |
Modified utils/ofarc/ZIPArchive.m from [cefb3af267] to [be437b8b44].
1 | /* | | | | | | > > > > | < > | > > > > > > > > > | | > > > > | < < < < < < < < | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #import "OFApplication.h" #import "OFArray.h" #import "OFData.h" #import "OFDate.h" #import "OFFile.h" #import "OFFileManager.h" #import "OFIRI.h" #import "OFIRIHandler.h" #import "OFLocale.h" #import "OFNumber.h" #import "OFPair.h" #import "OFSet.h" #import "OFStdIOStream.h" #import "OFString.h" #import "ZIPArchive.h" #import "OFArc.h" #import "OFInvalidFormatException.h" #import "OFOpenItemFailedException.h" #import "OFOutOfRangeException.h" #import "OFSetItemAttributesFailedException.h" static OFArc *app; static void setPermissions(OFString *path, OFZIPArchiveEntry *entry) { #ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS if ((entry.versionMadeBy >> 8) == OFZIPArchiveEntryAttributeCompatibilityUNIX) { OFNumber *mode = [OFNumber numberWithUnsignedShort: (entry.versionSpecificAttributes >> 16) & 0777]; OFFileAttributes attributes = [OFDictionary dictionaryWithObject: mode forKey: OFFilePOSIXPermissions]; [[OFFileManager defaultManager] setAttributes: attributes ofItemAtPath: path]; } #endif [app quarantineFile: path]; } static void setModificationDate(OFString *path, OFZIPArchiveEntry *entry) { OFDate *modificationDate = entry.modificationDate; OFFileAttributes attributes; if (modificationDate == nil) return; attributes = [OFDictionary dictionaryWithObject: modificationDate forKey: OFFileModificationDate]; @try { [[OFFileManager defaultManager] setAttributes: attributes ofItemAtPath: path]; } @catch (OFSetItemAttributesFailedException *e) { if (e.errNo != EISDIR) @throw e; } } @implementation ZIPArchive + (void)initialize { if (self == [ZIPArchive class]) app = (OFArc *)[OFApplication sharedApplication].delegate; } + (instancetype)archiveWithIRI: (OFIRI *)IRI stream: (OF_KINDOF(OFStream *))stream mode: (OFString *)mode encoding: (OFStringEncoding)encoding { return [[[self alloc] initWithIRI: IRI stream: stream mode: mode encoding: encoding] autorelease]; } - (instancetype)initWithIRI: (OFIRI *)IRI stream: (OF_KINDOF(OFStream *))stream mode: (OFString *)mode encoding: (OFStringEncoding)encoding { self = [super init]; @try { _archiveIRI = [IRI copy]; _archive = [[OFZIPArchive alloc] initWithStream: stream mode: mode]; _archive.delegate = self; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_archiveIRI release]; [_archive release]; [super dealloc]; } - (OFSeekableStream *)archive: (OFZIPArchive *)archive wantsPartNumbered: (unsigned int)partNumber lastPartNumber: (unsigned int)lastPartNumber { OFIRI *IRI; if ([_archiveIRI.pathExtension caseInsensitiveCompare: @"zip"] != OFOrderedSame) return nil; if (partNumber > 98) return nil; if (partNumber == lastPartNumber) IRI = _archiveIRI; else { OFMutableIRI *copy = [[_archiveIRI mutableCopy] autorelease]; [copy deletePathExtension]; [copy appendPathExtension: [OFString stringWithFormat: @"z%02u", partNumber + 1]]; [copy makeImmutable]; IRI = copy; } return (OFSeekableStream *)[OFIRIHandler openItemAtIRI: IRI mode: @"r"]; } - (void)listFiles { if (app->_outputLevel >= 1 && _archive.archiveComment != nil) { [OFStdOut writeLine: OF_LOCALIZED( @"list_archive_comment", @"Archive comment:")]; [OFStdOut writeString: @"\t"]; [OFStdOut writeLine: [_archive.archiveComment stringByReplacingOccurrencesOfString: @"\n" withString: @"\n\t"]]; [OFStdOut writeLine: @""]; } for (OFZIPArchiveEntry *entry in _archive.entries) { void *pool = objc_autoreleasePoolPush(); [OFStdOut writeLine: entry.fileName]; if (app->_outputLevel >= 1) { OFString *compressedSize = [OFString |
︙ | ︙ | |||
235 236 237 238 239 240 241 242 243 244 245 246 247 248 | } } - (void)extractFiles: (OFArray OF_GENERIC(OFString *) *)files { OFFileManager *fileManager = [OFFileManager defaultManager]; bool all = (files.count == 0); OFMutableSet OF_GENERIC(OFString *) *missing = [OFMutableSet setWithArray: files]; for (OFZIPArchiveEntry *entry in _archive.entries) { void *pool = objc_autoreleasePoolPush(); OFString *fileName = entry.fileName; OFString *outFileName, *directory; | > | 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | } } - (void)extractFiles: (OFArray OF_GENERIC(OFString *) *)files { OFFileManager *fileManager = [OFFileManager defaultManager]; bool all = (files.count == 0); OFMutableArray *delayedModificationDates = [OFMutableArray array]; OFMutableSet OF_GENERIC(OFString *) *missing = [OFMutableSet setWithArray: files]; for (OFZIPArchiveEntry *entry in _archive.entries) { void *pool = objc_autoreleasePoolPush(); OFString *fileName = entry.fileName; OFString *outFileName, *directory; |
︙ | ︙ | |||
272 273 274 275 276 277 278 | @"Extracting %[file]...", @"file", fileName)]; if ([fileName hasSuffix: @"/"]) { [fileManager createDirectoryAtPath: outFileName createParents: true]; setPermissions(outFileName, entry); | > > > > > | > > | 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 | @"Extracting %[file]...", @"file", fileName)]; if ([fileName hasSuffix: @"/"]) { [fileManager createDirectoryAtPath: outFileName createParents: true]; setPermissions(outFileName, entry); /* * As creating a new file in a directory changes its * modification date, we can only set it once all files * have been created. */ [delayedModificationDates addObject: [OFPair pairWithFirstObject: outFileName secondObject: entry]]; if (app->_outputLevel >= 0) { [OFStdOut writeString: @"\r"]; [OFStdOut writeLine: OF_LOCALIZED( @"extracting_file_done", @"Extracting %[file]... done", @"file", fileName)]; |
︙ | ︙ | |||
342 343 344 345 346 347 348 349 350 351 352 353 354 355 | @"file", fileName)]; } outer_loop_end: objc_autoreleasePoolPop(pool); } if (missing.count > 0) { for (OFString *file in missing) [OFStdErr writeLine: OF_LOCALIZED( @"file_not_in_archive", @"File %[file] is not in the archive!", @"file", file)]; | > > > | 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 | @"file", fileName)]; } outer_loop_end: objc_autoreleasePoolPop(pool); } for (OFPair *pair in delayedModificationDates) setModificationDate(pair.firstObject, pair.secondObject); if (missing.count > 0) { for (OFString *file in missing) [OFStdErr writeLine: OF_LOCALIZED( @"file_not_in_archive", @"File %[file] is not in the archive!", @"file", file)]; |
︙ | ︙ | |||
396 397 398 399 400 401 402 403 404 405 | } [stream close]; } } - (void)addFiles: (OFArray OF_GENERIC(OFString *) *)files { OFFileManager *fileManager = [OFFileManager defaultManager]; | > | < < < < < | 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 | } [stream close]; } } - (void)addFiles: (OFArray OF_GENERIC(OFString *) *)files archiveComment: (OFString *)archiveComment { OFFileManager *fileManager = [OFFileManager defaultManager]; _archive.archiveComment = archiveComment; for (OFString *localFileName in files) { void *pool = objc_autoreleasePoolPush(); OFArray OF_GENERIC (OFString *) *components; OFString *fileName; OFFileAttributes attributes; bool isDirectory = false; |
︙ | ︙ |
Added utils/ofarc/ZooArchive.h version [1fb08abec8].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFZooArchive.h" #import "Archive.h" @interface ZooArchive: OFObject <Archive> { OFZooArchive *_archive; } @end |
Added utils/ofarc/ZooArchive.m version [99f872ffe6].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <errno.h> #import "OFApplication.h" #import "OFArray.h" #import "OFDate.h" #import "OFFile.h" #import "OFFileManager.h" #import "OFLocale.h" #import "OFNumber.h" #import "OFSet.h" #import "OFStdIOStream.h" #import "OFString.h" #import "ZooArchive.h" #import "OFArc.h" #import "OFSetItemAttributesFailedException.h" static OFArc *app; static void setPermissions(OFString *path, OFZooArchiveEntry *entry) { #ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS OFNumber *POSIXPermissions = entry.POSIXPermissions; if (POSIXPermissions != nil) { OFFileAttributes attributes; POSIXPermissions = [OFNumber numberWithUnsignedShort: POSIXPermissions.unsignedShortValue & 0777]; attributes = [OFDictionary dictionaryWithObject: POSIXPermissions forKey: OFFilePOSIXPermissions]; [[OFFileManager defaultManager] setAttributes: attributes ofItemAtPath: path]; } #endif [app quarantineFile: path]; } static void setModificationDate(OFString *path, OFZooArchiveEntry *entry) { OFFileAttributes attributes = [OFDictionary dictionaryWithObject: entry.modificationDate forKey: OFFileModificationDate]; @try { [[OFFileManager defaultManager] setAttributes: attributes ofItemAtPath: path]; } @catch (OFSetItemAttributesFailedException *e) { if (e.errNo != EISDIR) @throw e; } } @implementation ZooArchive + (void)initialize { if (self == [ZooArchive class]) app = (OFArc *)[OFApplication sharedApplication].delegate; } + (instancetype)archiveWithIRI: (OFIRI *)IRI stream: (OF_KINDOF(OFStream *))stream mode: (OFString *)mode encoding: (OFStringEncoding)encoding { return [[[self alloc] initWithIRI: IRI stream: stream mode: mode encoding: encoding] autorelease]; } - (instancetype)initWithIRI: (OFIRI *)IRI stream: (OF_KINDOF(OFStream *))stream mode: (OFString *)mode encoding: (OFStringEncoding)encoding { self = [super init]; @try { _archive = [[OFZooArchive alloc] initWithStream: stream mode: mode]; if (encoding != OFStringEncodingAutodetect) _archive.encoding = encoding; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_archive release]; [super dealloc]; } - (void)listFiles { OFZooArchiveEntry *entry; if (app->_outputLevel >= 1 && _archive.archiveComment != nil) { [OFStdOut writeLine: OF_LOCALIZED( @"list_archive_comment", @"Archive comment:")]; [OFStdOut writeString: @"\t"]; [OFStdOut writeLine: [_archive.archiveComment stringByReplacingOccurrencesOfString: @"\n" withString: @"\n\t"]]; [OFStdOut writeLine: @""]; } while ((entry = [_archive nextEntry]) != nil) { void *pool = objc_autoreleasePoolPush(); if (app->_outputLevel < 1 && entry.deleted) { objc_autoreleasePoolPop(pool); continue; } [OFStdOut writeLine: entry.fileName]; if (app->_outputLevel >= 1) { OFString *modificationDate = [entry.modificationDate localDateStringWithFormat: @"%Y-%m-%d %H:%M:%S"]; OFString *compressedSize = [OFString stringWithFormat: @"%llu", entry.compressedSize]; OFString *uncompressedSize = [OFString stringWithFormat: @"%llu", entry.uncompressedSize]; OFString *compressionMethod = [OFString stringWithFormat: @"%" PRIu8, entry.compressionMethod]; OFString *CRC16 = [OFString stringWithFormat: @"%04" PRIX16, entry.CRC16]; OFString *deleted = [OFString stringWithFormat: @"%" PRIu8, entry.deleted]; [OFStdOut writeString: @"\t"]; [OFStdOut writeLine: OF_LOCALIZED( @"list_compressed_size", @"[" @" 'Compressed: '," @" [" @" {'size == 1': '1 byte'}," @" {'': '%[size] bytes'}" @" ]" @"]".objectByParsingJSON, @"size", compressedSize)]; [OFStdOut writeString: @"\t"]; [OFStdOut writeLine: OF_LOCALIZED( @"list_uncompressed_size", @"[" @" 'Uncompressed: '," @" [" @" {'size == 1': '1 byte'}," @" {'': '%[size] bytes'}" @" ]" @"]".objectByParsingJSON, @"size", uncompressedSize)]; [OFStdOut writeString: @"\t"]; [OFStdOut writeLine: OF_LOCALIZED( @"list_compression_method", @"Compression method: %[method]", @"method", compressionMethod)]; [OFStdOut writeString: @"\t"]; [OFStdOut writeLine: OF_LOCALIZED(@"list_crc16", @"CRC16: %[crc16]", @"crc16", CRC16)]; [OFStdOut writeString: @"\t"]; [OFStdOut writeLine: OF_LOCALIZED( @"list_modification_date", @"Modification date: %[date]", @"date", modificationDate)]; if (entry.timeZone != nil) { float timeZone = entry.timeZone.floatValue; int hours = (int)timeZone; unsigned char minutes = (timeZone - hours) * 60; OFString *timeZoneString; if (hours > 0) timeZoneString = [OFString stringWithFormat: @"UTC+%02d:%02u", hours, minutes]; else timeZoneString = [OFString stringWithFormat: @"UTC-%02d:%02u", -hours, minutes]; [OFStdOut writeString: @"\t"]; [OFStdOut writeLine: OF_LOCALIZED( @"list_timezone", @"Time zone: %[timezone]", @"timezone", timeZoneString)]; } [OFStdOut writeString: @"\t"]; [OFStdOut writeLine: OF_LOCALIZED( @"list_deleted", @"[" @" 'Deleted: '," @" [" @" {'deleted == 0': 'No'}," @" {'': 'Yes'}" @" ]" @"]".objectByParsingJSON, @"deleted", deleted)]; if (entry.fileComment.length > 0) { [OFStdOut writeString: @"\t"]; [OFStdOut writeLine: OF_LOCALIZED( @"list_comment", @"Comment: %[comment]", @"comment", entry.fileComment)]; } } if (app->_outputLevel >= 2) { uint16_t minVersionNeeded = entry.minVersionNeeded; OFString *minVersionNeededString = [OFString stringWithFormat: @"%" PRIu8 @".%" PRIu8, minVersionNeeded >> 8, minVersionNeeded & 0xFF]; OFString *headerType = [OFString stringWithFormat: @"%" PRIu8, entry.headerType]; [OFStdOut writeString: @"\t"]; [OFStdOut writeLine: OF_LOCALIZED( @"list_min_version_needed", @"Minimum version needed: %[version]", @"version", minVersionNeededString)]; [OFStdOut writeString: @"\t"]; [OFStdOut writeLine: OF_LOCALIZED( @"list_header_type", @"Header type: %[type]", @"type", headerType)]; if (entry.headerType >= 2) { OFString *OSID = [OFString stringWithFormat: @"%u", entry.operatingSystemIdentifier]; [OFStdOut writeString: @"\t"]; [OFStdOut writeLine: OF_LOCALIZED( @"list_osid", @"Operating system identifier: " @"%[osid]", @"osid", OSID)]; } if (entry.POSIXPermissions != nil) { OFString *permissionsString = [OFString stringWithFormat: @"%llo", entry.POSIXPermissions .unsignedLongLongValue]; [OFStdOut writeString: @"\t"]; [OFStdOut writeLine: OF_LOCALIZED( @"list_posix_permissions", @"POSIX permissions: %[perm]", @"perm", permissionsString)]; } } objc_autoreleasePoolPop(pool); } } - (void)extractFiles: (OFArray OF_GENERIC(OFString *) *)files { OFFileManager *fileManager = [OFFileManager defaultManager]; bool all = (files.count == 0); OFMutableSet OF_GENERIC(OFString *) *missing = [OFMutableSet setWithArray: files]; OFZooArchiveEntry *entry; while ((entry = [_archive nextEntry]) != nil) { void *pool = objc_autoreleasePoolPush(); OFString *fileName = entry.fileName; OFString *outFileName, *directory; OFFile *output; OFStream *stream; unsigned long long written = 0, size = entry.uncompressedSize; int8_t percent = -1, newPercent; if (!all && ![files containsObject: fileName]) continue; if (all && entry.deleted) continue; [missing removeObject: fileName]; outFileName = [app safeLocalPathForPath: fileName]; if (outFileName == nil) { [OFStdErr writeLine: OF_LOCALIZED( @"refusing_to_extract_file", @"Refusing to extract %[file]!", @"file", fileName)]; app->_exitStatus = 1; goto outer_loop_end; } if (app->_outputLevel >= 0) [OFStdOut writeString: OF_LOCALIZED(@"extracting_file", @"Extracting %[file]...", @"file", fileName)]; directory = outFileName.stringByDeletingLastPathComponent; if (![fileManager directoryExistsAtPath: directory]) [fileManager createDirectoryAtPath: directory createParents: true]; if (![app shouldExtractFile: fileName outFileName: outFileName]) goto outer_loop_end; stream = [_archive streamForReadingCurrentEntry]; output = [OFFile fileWithPath: outFileName mode: @"w"]; setPermissions(outFileName, entry); while (!stream.atEndOfStream) { ssize_t length = [app copyBlockFromStream: stream toStream: output fileName: fileName]; if (length < 0) { app->_exitStatus = 1; goto outer_loop_end; } written += length; newPercent = (written == size ? 100 : (int8_t)(written * 100 / size)); if (app->_outputLevel >= 0 && percent != newPercent) { OFString *percentString; percent = newPercent; percentString = [OFString stringWithFormat: @"%3u", percent]; [OFStdOut writeString: @"\r"]; [OFStdOut writeString: OF_LOCALIZED( @"extracting_file_percent", @"Extracting %[file]... %[percent]%", @"file", fileName, @"percent", percentString)]; } } [output close]; setModificationDate(outFileName, entry); if (app->_outputLevel >= 0) { [OFStdOut writeString: @"\r"]; [OFStdOut writeLine: OF_LOCALIZED( @"extracting_file_done", @"Extracting %[file]... done", @"file", fileName)]; } outer_loop_end: objc_autoreleasePoolPop(pool); } if (missing.count > 0) { for (OFString *file in missing) [OFStdErr writeLine: OF_LOCALIZED( @"file_not_in_archive", @"File %[file] is not in the archive!", @"file", file)]; app->_exitStatus = 1; } } - (void)printFiles: (OFArray OF_GENERIC(OFString *) *)files_ { OFMutableSet *files; OFZooArchiveEntry *entry; if (files_.count < 1) { [OFStdErr writeLine: OF_LOCALIZED(@"print_no_file_specified", @"Need one or more files to print!")]; app->_exitStatus = 1; return; } files = [OFMutableSet setWithArray: files_]; while ((entry = [_archive nextEntry]) != nil) { OFString *fileName = entry.fileName; OFStream *stream; if (![files containsObject: fileName]) continue; stream = [_archive streamForReadingCurrentEntry]; while (!stream.atEndOfStream) { ssize_t length = [app copyBlockFromStream: stream toStream: OFStdOut fileName: fileName]; if (length < 0) { app->_exitStatus = 1; return; } } [files removeObject: fileName]; [stream close]; if (files.count == 0) break; } for (OFString *file in files) { [OFStdErr writeLine: OF_LOCALIZED(@"file_not_in_archive", @"File %[file] is not in the archive!", @"file", file)]; app->_exitStatus = 1; } } - (void)addFiles: (OFArray OF_GENERIC(OFString *) *)files archiveComment: (OFString *)archiveComment { OFFileManager *fileManager = [OFFileManager defaultManager]; _archive.archiveComment = archiveComment; for (OFString *fileName in files) { void *pool = objc_autoreleasePoolPush(); OFFileAttributes attributes; OFFileAttributeType type; OFMutableZooArchiveEntry *entry; OFStream *output; if (app->_outputLevel >= 0) [OFStdOut writeString: OF_LOCALIZED(@"adding_file", @"Adding %[file]...", @"file", fileName)]; attributes = [fileManager attributesOfItemAtPath: fileName]; type = attributes.fileType; if ([type isEqual: OFFileTypeDirectory]) { if (app->_outputLevel >= 0) { [OFStdOut writeString: @"\r"]; [OFStdOut writeLine: OF_LOCALIZED( @"adding_file_skipped", @"Adding %[file]... skipped", @"file", fileName)]; } continue; } entry = [OFMutableZooArchiveEntry entryWithFileName: fileName]; entry.timeZone = [OFNumber numberWithFloat: 0]; entry.modificationDate = attributes.fileModificationDate; #ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS entry.POSIXPermissions = [attributes objectForKey: OFFilePOSIXPermissions]; #endif output = [_archive streamForWritingEntry: entry]; if ([type isEqual: OFFileTypeRegular]) { unsigned long long written = 0; unsigned long long size = attributes.fileSize; int8_t percent = -1, newPercent; OFFile *input = [OFFile fileWithPath: fileName mode: @"r"]; while (!input.atEndOfStream) { ssize_t length = [app copyBlockFromStream: input toStream: output fileName: fileName]; if (length < 0) { app->_exitStatus = 1; goto outer_loop_end; } written += length; newPercent = (written == size ? 100 : (int8_t)(written * 100 / size)); if (app->_outputLevel >= 0 && percent != newPercent) { OFString *percentString; percent = newPercent; percentString = [OFString stringWithFormat: @"%3u", percent]; [OFStdOut writeString: @"\r"]; [OFStdOut writeString: OF_LOCALIZED( @"adding_file_percent", @"Adding %[file]... %[percent]%", @"file", fileName, @"percent", percentString)]; } } } if (app->_outputLevel >= 0) { [OFStdOut writeString: @"\r"]; [OFStdOut writeLine: OF_LOCALIZED( @"adding_file_done", @"Adding %[file]... done", @"file", fileName)]; } [output close]; outer_loop_end: objc_autoreleasePoolPop(pool); } [_archive close]; } @end |
Modified utils/ofarc/localization/de.json from [173fef355f] to [5b95b5a4b7].
|
| > > > > > > > > | > > > | | | > > > | | | > | | > > | | | | | > | > | | | | | | | | | | | | | | | | | | | | | | | | | | > | | | | | | | > | | | | | | | | | | | | | | | | | | | | | | | > > > > > > > > | | | | | | | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | /* * German localization for ofarc. * * Copyright (c) 2017-2024 Jonathan Schleifer <js@nil.im> * * Permission to use, copy, modify, and/or distribute this localization for * any purpose with or without fee is hereby granted. */ /* vim: se ft=javascript sw=4 et: */ { usage: [ "Benutzung: %[prog] -[acCfhlnpqtvx] archiv.zip [datei1 datei2 ...]" ], full_usage: [ "Optionen:\n", " -a --append Zu Archiv hinzufügen\n", " --archive-comment= Zu benutzender Archivkommentar beim ", "Erstellen oder\n", " Hinzufügen\n", " -c --create Archiv erstellen\n", " -C --directory= In angegebenes Verzeichnis entpacken\n", " -E --encoding= Das Encoding des Archivs\n", " (nur tar-, lha- und zoo-Dateien)\n", " -f --force Existierende Dateien überschreiben\n", " -h --help Diese Hilfe anzeigen\n", " --iri Eine IRI benutzen um auf das Archiv ", "zuzugreifen\n", " -l --list Alle Dateien im Archiv auflisten\n", " -n --no-clobber Dateien niemals überschreiben\n", " -p --print Eine oder mehr Dateien aus dem Archiv ", "ausgeben\n", " -q --quiet Ruhiger Modus (keine Ausgabe außer ", "Fehler)\n", " -t --type= Archiv-Typ (gz, lha, tar, tgz, zip, ", "zoo)\n", " -v --verbose Ausführlicher Modus für Datei-Liste\n", " -x --extract Dateien entpacken" ], "2_options_mutually_exclusive": [ "Fehler: -%[shortopt1] / --%[longopt1] und ", "-%[shortopt2] / --%[longopt2] schließen sich gegenseitig aus!" ], "5_options_mutually_exclusive": [ "Fehler: -%[shortopt1] / --%[longopt1], -%[shortopt2] / ", "--%[longopt2], -%[shortopt3] / --%[longopt3], ", "-%[shortopt4] / --%[longopt4] und\n", " -%[shortopt5] / --%[longopt5] schließen sich gegenseitig aus!" ], option_takes_no_argument: "%[prog]: Option --%[opt] nimmt kein Argument", long_option_requires_argument: [ "%[prog]: Option --%[opt] benötigt ein Argument" ], option_requires_argument: "%[prog]: Option -%[opt] benötigt ein Argument", unknown_long_option: "%[prog]: Unbekannte Option: --%[opt]", unknown_option: "%[prog]: Unbekannte Option: -%[opt]", invalid_encoding: "%[prog]: Invalid encoding: %[encoding]", writing_not_supported: [ "Schreiben von Dateien des Typs %[type] wird (noch) nicht unterstützt!" ], failed_to_create_directory: [ "Fehler beim Erstellen des Verzeichnis %[dir]: %[error]" ], failed_to_open_file: "Fehler beim Öffnen der Datei %[file]: %[error]", unknown_archive_type: "Unbekannter Archivtyp: %[type]", failed_to_read_file: "Fehler beim Lesen der Datei %[file]: %[error]", failed_to_write_file: "Fehler beim Schreiben der Datei %[file]: %[error]", failed_to_seek_in_file: "Fehler beim Suchen in Datei %[file]: %[error]", file_is_not_a_valid_archive: "Datei %[file] ist kein gültiges Archiv!", file_skipped: "übersprungen", ask_overwrite: "%[file] überschreiben? [ynAN?]", ask_overwrite_help: [ " y: Ja\n", " n: Nein\n", " A: Immer\n", " N: Nie" ], skipping_file: "Überspringe %[file]...", extracting_file: "Entpacke %[file]...", extracting_file_percent: "Entpacke %[file]... %[percent]%", extracting_file_done: "Entpacke %[file]... fertig", cannot_list_gz: "Kann Dateien eines .gz-Archivs nicht auflisten!", cannot_extract_specific_file_from_gz: [ "Kann keine spezifische Datei aus einem .gz-Archiv entpacken!" ], cannot_print_specific_file_from_gz: [ "Kann keine spezifische Datei aus einem .gz-Archiv ausgeben!" ], list_archive_comment: "Archivkommentar:", list_size: [ "Größe: ", [ {"size == 1": "1 Byte"}, {"": "%[size] Bytes"} ] ], list_posix_permissions: "POSIX-Berechtigungen: %[perm]", list_owner_account_id: "Besitzerkontennummer: %[id]", list_group_owner_account_id: "Gruppenbesitzerkontennummer: %[id]", list_owner_account_name: "Besitzerkontenname: %[name]", list_group_owner_account_name: "Gruppenbesitzerkontenname: %[name]", list_header_level: "Header-Level: %[level]", list_header_type: "Header-Typ: %[type]", list_modification_date: "Änderungsdatum: %[date]", list_type_normal: "Typ: Normale Datei", list_type_hardlink: "Typ: Harter Link", list_type_symlink: "Typ: Symbolischer Link", list_link_target: "Zieldateiname: %[target]", list_type_character_device: "Typ: Zeichenorientiertes Gerät", list_type_block_device: "Typ: Blockorientiertes Gerät", list_device_major: "Major-Nummer des Geräts: %[major]", list_device_minor: "Minor-Nummer des Geräts: %[minor]", list_type_directory: "Typ: Verzeichnis", list_type_fifo: "Typ: FIFO", list_type_contiguous_file: "Typ: Zusammenhängende Datei", list_type_unknown: "Typ: Unbekannt", list_compressed_size: [ "Komprimierte Größe: ", [ {"size == 1": "1 Byte"}, {"": "%[size] Bytes"} ] ], list_uncompressed_size: [ "Unkomprimierte Größe: ", [ {"size == 1": "1 Byte"}, {"": "%[size] Bytes"} ] ], list_compression_method: "Kompressionsmethode: %[method]", list_osid: "Betriebssystem-Identifikator: %[osid]", list_extensions: "Erweiterungen: %[extensions]", list_version_made_by: "Erstellt mit Version: %[version]", list_min_version_needed: "Mindestens benötigte Version: %[version]", list_general_purpose_bit_flag: "General Purpose Bit Flag: %[gpbf]", list_extra_field: "Extra-Feld: %[extra]", list_comment: "Kommentar: %[comment]", list_timezone: "Zeitzone: %[timezone]", list_deleted: [ "Gelöscht: ", [ {"deleted == 0": "Nein"}, {"": "Ja"} ] ], refusing_to_extract_file: "Verweigere Entpacken von %[file]!", file_not_in_archive: "Datei %[file] ist nicht im Archiv!", print_no_file_specified: [ "Benötige eine oder mehrere Dateien zum Ausgeben!" ], add_no_file_specified: [ "Benötige eine oder mehrere Dateien zum Hinzufügen!" ], adding_file: "Füge %[file] hinzu...", adding_file_percent: "Füge %[file] hinzu... %[percent]%", adding_file_done: "Füge %[file] hinzu... fertig", adding_file_skipped: "Füge %[file] hinzu... übersprungen", } |
Modified utils/ofarc/localization/localizations.json from [1722bb6119] to [df82f11fb6].
|
| > > > > > > > > | > | > > | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | /* * Localization mapping for ofarc. * * Copyright (c) 2017-2023 Jonathan Schleifer <js@nil.im> * * Permission to use, copy, modify, and/or distribute this mapping for any * purpose with or without fee is hereby granted. */ /* vim: se ft=javascript sw=4 et: */ { de: { "": "de" }, deutsch: { "": "de" }, german: { "": "de" }, } |
Modified utils/ofdns/Makefile from [94aeff9904] to [c4d144d3b6].
︙ | ︙ | |||
12 13 14 15 16 17 18 | ${PROG}: ${LIBOBJFW_DEP_LVL2} ${LIBOBJFWRT_DEP_LVL2} CPPFLAGS += -I../../src \ -I../../src/runtime \ -I../../src/exceptions \ -I../.. \ -DLOCALIZATION_DIR=\"${datadir}/ofdns/localization\" | | < < | 12 13 14 15 16 17 18 19 20 21 | ${PROG}: ${LIBOBJFW_DEP_LVL2} ${LIBOBJFWRT_DEP_LVL2} CPPFLAGS += -I../../src \ -I../../src/runtime \ -I../../src/exceptions \ -I../.. \ -DLOCALIZATION_DIR=\"${datadir}/ofdns/localization\" LIBS := -L../../src -lobjfw -L../../src/runtime ${RUNTIME_LIBS} ${LIBS} LD = ${OBJC} LDFLAGS += ${LDFLAGS_RPATH} |
Modified utils/ofdns/OFDNS.m from [7740440ce7] to [f6b9d1d659].
1 | /* | | | | | | > > > > | < > | > | < | | | | | > > | < | > > | > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFApplication.h" #import "OFArray.h" #import "OFDNSResolver.h" #import "OFIRI.h" #import "OFLocale.h" #import "OFOptionsParser.h" #import "OFSandbox.h" #import "OFStdIOStream.h" @interface OFDNS: OFObject <OFApplicationDelegate, OFDNSResolverQueryDelegate> { size_t _inFlight; int _errors; } @end OF_APPLICATION_DELEGATE(OFDNS) static void help(OFStream *stream, bool full, int status) { [OFStdErr writeLine: OF_LOCALIZED(@"usage", @"Usage: %[prog] -[chst] domain1 [domain2 ...]", @"prog", [OFApplication programName])]; if (full) { [stream writeString: @"\n"]; [stream writeLine: OF_LOCALIZED(@"full_usage", @"Options:\n " @"-c --class= " @" The DNS class to query (defaults to IN)\n " @"-h --help " @" Show this help\n " @"-s --server=" @" The server to query\n " @"-t --type= " @" The record type to query (defaults to ALL, can be " @"repeated)\n " @" --tcp " @" Force using TCP for the query")]; } [OFApplication terminateWithStatus: status]; } @implementation OFDNS - (void)resolver: (OFDNSResolver *)resolver didPerformQuery: (OFDNSQuery *)query response: (OFDNSResponse *)response exception: (id)exception { _inFlight--; if (exception == nil) [OFStdOut writeFormat: @"%@\n", response]; else { [OFStdErr writeLine: OF_LOCALIZED(@"failed_to_resolve", @"Failed to resolve: %[exception]", @"exception", exception)]; _errors++; } if (_inFlight == 0) [OFApplication terminateWithStatus: _errors]; } - (void)applicationDidFinishLaunching: (OFNotification *)notification { OFString *DNSClassString, *server; bool forceTCP; const OFOptionsParserOption options[] = { { 'c', @"class", 1, NULL, &DNSClassString }, { 'h', @"help", 0, NULL, NULL }, { 's', @"server", 1, NULL, &server }, { 't', @"type", 1, NULL, NULL }, { '\0', @"tcp", 0, &forceTCP, NULL }, { '\0', nil, 0, NULL, NULL } }; OFMutableArray OF_GENERIC(OFString *) *recordTypes; OFOptionsParser *optionsParser; OFUnichar option; OFArray OF_GENERIC(OFString *) *remainingArguments; OFDNSResolver *resolver; OFDNSClass DNSClass; #ifdef OF_HAVE_FILES # ifndef OF_AMIGAOS [OFLocale addLocalizationDirectoryIRI: [OFIRI fileIRIWithPath: @LOCALIZATION_DIR]]; # else [OFLocale addLocalizationDirectoryIRI: [OFIRI fileIRIWithPath: @"PROGDIR:/share/ofdns/localization"]]; # endif #endif #ifdef OF_HAVE_SANDBOX OFSandbox *sandbox = [[OFSandbox alloc] init]; @try { sandbox.allowsStdIO = true; |
︙ | ︙ | |||
176 177 178 179 180 181 182 183 184 185 186 187 188 | remainingArguments = optionsParser.remainingArguments; if (remainingArguments.count < 1) help(OFStdErr, false, 1); resolver = [OFDNSResolver resolver]; DNSClass = (DNSClassString != nil ? OFDNSClassParseName(DNSClassString) : OFDNSClassIN); if (recordTypes.count == 0) [recordTypes addObject: @"ALL"]; | > > > | < < | 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | remainingArguments = optionsParser.remainingArguments; if (remainingArguments.count < 1) help(OFStdErr, false, 1); resolver = [OFDNSResolver resolver]; resolver.configReloadInterval = 0; resolver.forcesTCP = forceTCP; DNSClass = (DNSClassString != nil ? OFDNSClassParseName(DNSClassString) : OFDNSClassIN); if (recordTypes.count == 0) [recordTypes addObject: @"ALL"]; if (server != nil) resolver.nameServers = [OFArray arrayWithObject: server]; for (OFString *domainName in remainingArguments) { for (OFString *recordTypeString in recordTypes) { OFDNSRecordType recordType = OFDNSRecordTypeParseName(recordTypeString); OFDNSQuery *query = [OFDNSQuery queryWithDomainName: domainName |
︙ | ︙ |
Modified utils/ofdns/localization/de.json from [a2dd6e542b] to [415733a1a9].
|
| > > > > > > > > | > > > | | | | | | | > | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | /* * German localization for ofdns. * * Copyright (c) 2020-2024 Jonathan Schleifer <js@nil.im> * * Permission to use, copy, modify, and/or distribute this localization for * any purpose with or without fee is hereby granted. */ /* vim: se ft=javascript sw=4 et: */ { usage: "Benutzung: %[prog] -[chst] domain1 [domain2 ...]", full_usage: [ "Optionen:\n", " -c --class= Die anzufragende DNS-Klasse (standardmäßig IN)\n", " -h --help Diese Hilfe anzeigen\n", " -s --server= Der abzufragende Server\n", " -t --type= Der anzufragende Record-Typ (standardmäßig ALL,\n", " kann wiederholt werden)\n", " --tcp Benutzung von TCP erzwingen" ], long_option_requires_argument: [ "%[prog]: Option --%[opt] benötigt ein Argument" ], option_requires_argument: "%[prog]: Option -%[opt] benötigt ein Argument", unknown_long_option: "%[prog]: Unbekannte Option: --%[opt]", unknown_option: "%[prog]: Unbekannte Option: -%[opt]", failed_to_resolve: "Auflösen fehlgeschlagen: %[exception]", } |
Modified utils/ofdns/localization/localizations.json from [1722bb6119] to [52f2647bf8].
|
| > > > > > > > > | > | > > | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | /* * Localization mapping for ofdns. * * Copyright (c) 2020-2023 Jonathan Schleifer <js@nil.im> * * Permission to use, copy, modify, and/or distribute this mapping for any * purpose with or without fee is hereby granted. */ /* vim: se ft=javascript sw=4 et: */ { de: { "": "de" }, deutsch: { "": "de" }, german: { "": "de" }, } |
Modified utils/ofhash/Makefile from [41087b215e] to [bdadc4d20f].
︙ | ︙ | |||
12 13 14 15 16 17 18 | ${PROG}: ${LIBOBJFW_DEP_LVL2} ${LIBOBJFWRT_DEP_LVL2} CPPFLAGS += -I../../src \ -I../../src/runtime \ -I../../src/exceptions \ -I../.. \ -DLOCALIZATION_DIR=\"${datadir}/ofhash/localization\" | | | | 12 13 14 15 16 17 18 19 20 21 22 23 | ${PROG}: ${LIBOBJFW_DEP_LVL2} ${LIBOBJFWRT_DEP_LVL2} CPPFLAGS += -I../../src \ -I../../src/runtime \ -I../../src/exceptions \ -I../.. \ -DLOCALIZATION_DIR=\"${datadir}/ofhash/localization\" LIBS := -L../../src -L../../src/tls ${OFHASH_LIBS} -lobjfw \ -L../../src/runtime ${RUNTIME_LIBS} \ ${LIBS} LD = ${OBJC} LDFLAGS += ${LDFLAGS_RPATH} |
Modified utils/ofhash/OFHash.m from [9cab35b0cf] to [2f46ff7479].
1 | /* | | | | | | > > > > | < > | > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFApplication.h" #import "OFArray.h" #import "OFFile.h" #import "OFIRI.h" #import "OFIRIHandler.h" #import "OFLocale.h" #import "OFMD5Hash.h" #import "OFOptionsParser.h" #import "OFRIPEMD160Hash.h" #import "OFSHA1Hash.h" #import "OFSHA224Hash.h" #import "OFSHA256Hash.h" |
︙ | ︙ | |||
40 41 42 43 44 45 46 | OF_APPLICATION_DELEGATE(OFHash) static void help(void) { [OFStdErr writeLine: OF_LOCALIZED(@"usage", @"Usage: %[prog] [--md5] [--ripemd160] [--sha1] [--sha224] " | | | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | OF_APPLICATION_DELEGATE(OFHash) static void help(void) { [OFStdErr writeLine: OF_LOCALIZED(@"usage", @"Usage: %[prog] [--md5] [--ripemd160] [--sha1] [--sha224] " @"[--sha256] [--sha384] [--sha512] [--iri] file1 [file2 ...]", @"prog", [OFApplication programName])]; [OFApplication terminateWithStatus: 1]; } static void printHash(OFString *algo, OFString *path, id <OFCryptographicHash> hash) |
︙ | ︙ | |||
64 65 66 67 68 69 70 | for (size_t i = 0; i < digestSize; i++) [OFStdOut writeFormat: @"%02x", digest[i]]; [OFStdOut writeFormat: @" %@\n", path]; } @implementation OFHash | | | > | > | | | | | | | > | | | 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | for (size_t i = 0; i < digestSize; i++) [OFStdOut writeFormat: @"%02x", digest[i]]; [OFStdOut writeFormat: @" %@\n", path]; } @implementation OFHash - (void)applicationDidFinishLaunching: (OFNotification *)notification { int exitStatus = 0; bool calculateMD5, calculateRIPEMD160, calculateSHA1, calculateSHA224; bool calculateSHA256, calculateSHA384, calculateSHA512, isIRI; const OFOptionsParserOption options[] = { { '\0', @"md5", 0, &calculateMD5, NULL }, { '\0', @"ripemd160", 0, &calculateRIPEMD160, NULL }, { '\0', @"sha1", 0, &calculateSHA1, NULL }, { '\0', @"sha224", 0, &calculateSHA224, NULL }, { '\0', @"sha256", 0, &calculateSHA256, NULL }, { '\0', @"sha384", 0, &calculateSHA384, NULL }, { '\0', @"sha512", 0, &calculateSHA512, NULL }, { '\0', @"iri", 0, &isIRI, NULL }, { '\0', nil, 0, NULL, NULL } }; OFOptionsParser *optionsParser = [OFOptionsParser parserWithOptions: options]; OFUnichar option; OFMD5Hash *MD5Hash = nil; OFRIPEMD160Hash *RIPEMD160Hash = nil; OFSHA1Hash *SHA1Hash = nil; OFSHA224Hash *SHA224Hash = nil; OFSHA256Hash *SHA256Hash = nil; OFSHA384Hash *SHA384Hash = nil; OFSHA512Hash *SHA512Hash = nil; #ifndef OF_AMIGAOS [OFLocale addLocalizationDirectoryIRI: [OFIRI fileIRIWithPath: @LOCALIZATION_DIR]]; #else [OFLocale addLocalizationDirectoryIRI: [OFIRI fileIRIWithPath: @"PROGDIR:/share/ofhash/localization"]]; #endif while ((option = [optionsParser nextOption]) != '\0') { switch (option) { case '?': if (optionsParser.lastLongOption != nil) [OFStdErr writeLine: OF_LOCALIZED( @"unknown_long_option", @"%[prog]: Unknown option: --%[opt]", @"prog", [OFApplication programName], @"opt", optionsParser.lastLongOption)]; else { OFString *optStr = [OFString stringWithFormat: @"%C", optionsParser.lastOption]; [OFStdErr writeLine: OF_LOCALIZED( @"unknown_option", @"%[prog]: Unknown option: -%[opt]", @"prog", [OFApplication programName], @"opt", optStr)]; } [OFApplication terminateWithStatus: 1]; break; } } #ifdef OF_HAVE_SANDBOX OFSandbox *sandbox = [OFSandbox sandbox]; @try { sandbox.allowsStdIO = true; sandbox.allowsReadingFiles = true; sandbox.allowsUserDatabaseReading = true; if (!isIRI) for (OFString *path in optionsParser.remainingArguments) [sandbox unveilPath: path permissions: @"r"]; [sandbox unveilPath: @LOCALIZATION_DIR permissions: @"r"]; [OFApplication of_activateSandbox: sandbox]; } @finally { [sandbox release]; } |
︙ | ︙ | |||
167 168 169 170 171 172 173 | if (calculateSHA512) SHA512Hash = [OFSHA512Hash hashWithAllowsSwappableMemory: true]; for (OFString *path in optionsParser.remainingArguments) { void *pool = objc_autoreleasePoolPush(); OFStream *file; | | > > > > > > > > | > > > | | 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | if (calculateSHA512) SHA512Hash = [OFSHA512Hash hashWithAllowsSwappableMemory: true]; for (OFString *path in optionsParser.remainingArguments) { void *pool = objc_autoreleasePoolPush(); OFStream *file; if (!isIRI && [path isEqual: @"-"]) file = OFStdIn; else { @try { if (isIRI) { OFIRI *IRI = [OFIRI IRIWithString: path]; file = [OFIRIHandler openItemAtIRI: IRI mode: @"r"]; } else file = [OFFile fileWithPath: path mode: @"r"]; } @catch (OFOpenItemFailedException *e) { OFString *error = [OFString stringWithCString: strerror(e.errNo) encoding: [OFLocale encoding]]; OFString *filePath = (e.IRI != nil ? e.IRI.string : e.path); [OFStdErr writeLine: OF_LOCALIZED( @"failed_to_open_file", @"Failed to open file %[file]: %[error]", @"file", filePath, @"error", error)]; exitStatus = 1; goto outer_loop_end; } } |
︙ | ︙ |
Modified utils/ofhash/localization/de.json from [e3d21e1de1] to [af38785614].
|
| > > > > > > > > | > > > | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | /* * German localization for ofhash. * * Copyright (c) 2017-2024 Jonathan Schleifer <js@nil.im> * * Permission to use, copy, modify, and/or distribute this localization for * any purpose with or without fee is hereby granted. */ /* vim: se ft=javascript sw=4 et: */ { usage: [ "Benutzung: %[prog] [--md5] [--ripemd160] [--sha1] [--sha224] ", "[--sha256] [--sha384] [--sha512] [--iri] datei1 [datei2 ...]" ], unknown_long_option: "%[prog]: Unbekannte Option: --%[opt]", unknown_option: "%[prog]: Unbekannte Option: -%[opt]", failed_to_open_file: "Fehler beim Öffnen der Datei %[file]: %[error]", failed_to_read_file: "Fehler beim Lesen der Datei %[file]: %[error]", } |
Modified utils/ofhash/localization/localizations.json from [1722bb6119] to [19e35e3a75].
|
| > > > > > > > > | > | > > | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | /* * Localization mapping for ofhash. * * Copyright (c) 2017-2023 Jonathan Schleifer <js@nil.im> * * Permission to use, copy, modify, and/or distribute this mapping for any * purpose with or without fee is hereby granted. */ /* vim: se ft=javascript sw=4 et: */ { de: { "": "de" }, deutsch: { "": "de" }, german: { "": "de" }, } |
Modified utils/ofhttp/Makefile from [a53c9301a9] to [75e10724b9].
︙ | ︙ | |||
13 14 15 16 17 18 19 | ${PROG}: ${LIBOBJFW_DEP_LVL2} ${LIBOBJFWRT_DEP_LVL2} CPPFLAGS += -I../../src \ -I../../src/runtime \ -I../../src/exceptions \ -I../../src/tls \ -I../.. \ | | < < | | 13 14 15 16 17 18 19 20 21 22 23 24 25 | ${PROG}: ${LIBOBJFW_DEP_LVL2} ${LIBOBJFWRT_DEP_LVL2} CPPFLAGS += -I../../src \ -I../../src/runtime \ -I../../src/exceptions \ -I../../src/tls \ -I../.. \ -DLOCALIZATION_DIR='"${datadir}/ofhttp/localization"' LIBS := -L../../src -L../../src/tls ${OFHTTP_LIBS} -lobjfw \ -L../../src/runtime ${RUNTIME_LIBS} \ ${LIBS} LD = ${OBJC} LDFLAGS += ${LDFLAGS_RPATH} |
Modified utils/ofhttp/OFHTTP.m from [36f1e9db6a] to [530fc4ed76].
1 | /* | | | | | | > > > > | < > | > > < > > | | | | < | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OFApplication.h" #import "OFArray.h" #import "OFData.h" #import "OFDate.h" #import "OFDictionary.h" #import "OFFile.h" #import "OFFileManager.h" #import "OFHTTPClient.h" #import "OFHTTPRequest.h" #import "OFHTTPResponse.h" #import "OFIRI.h" #import "OFLocale.h" #import "OFOptionsParser.h" #ifdef OF_HAVE_PLUGINS # import "OFPlugin.h" #endif #import "OFSandbox.h" #import "OFStdIOStream.h" #import "OFSystemInfo.h" #import "OFTCPSocket.h" #import "OFTLSStream.h" #ifdef HAVE_TLS_SUPPORT # import "ObjFWTLS.h" #endif #import "OFConnectSocketFailedException.h" #import "OFGetItemAttributesFailedException.h" #import "OFHTTPRequestFailedException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFInvalidServerResponseException.h" #import "OFOpenItemFailedException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFResolveHostFailedException.h" #import "OFSetItemAttributesFailedException.h" #import "OFTLSHandshakeFailedException.h" #import "OFUnsupportedProtocolException.h" #import "OFWriteFailedException.h" #import "ProgressBar.h" #define GIBIBYTE (1024 * 1024 * 1024) #define MEBIBYTE (1024 * 1024) #define KIBIBYTE (1024) @interface OFHTTP: OFObject <OFApplicationDelegate, OFHTTPClientDelegate, OFStreamDelegate> { OFArray OF_GENERIC(OFString *) *_IRIs; size_t _IRIIndex; int _errorCode; OFString *_outputPath, *_currentFileName; bool _continue, _force, _detectFileName, _detectFileNameRequest; bool _detectedFileName, _quiet, _verbose, _insecure, _ignoreStatus; bool _useUnicode; OFStream *_body; OFHTTPRequestMethod _method; OFMutableDictionary *_clientHeaders; OFHTTPClient *_HTTPClient; char *_buffer; OFStream *_output; unsigned long long _received, _length, _resumedFrom; ProgressBar *_progressBar; } - (void)downloadNextIRI; @end #ifdef HAVE_TLS_SUPPORT void _reference_to_ObjFWTLS(void) { _ObjFWTLS_reference = 1; } #endif OF_APPLICATION_DELEGATE(OFHTTP) static void help(OFStream *stream, bool full, int status) { [OFStdErr writeLine: OF_LOCALIZED(@"usage", @"Usage: %[prog] -[cehHmoOPqv] iri1 [iri2 ...]", @"prog", [OFApplication programName])]; if (full) { [stream writeString: @"\n"]; [stream writeLine: OF_LOCALIZED(@"full_usage", @"Options:\n " @"-b --body= " @" Specify the file to send as body\n " @" " @" (- for standard input)\n " @"-c --continue " @" Continue download of existing file\n " @"-f --force " @" Force / overwrite existing file\n " @"-h --help " @" Show this help\n " @"-H --header= " @" Add a header (e.g. X-Foo:Bar)\n " @"-m --method= " @" Set the method of the HTTP request\n " @"-o --output= " @" Specify output file name\n " @"-O --detect-filename" @" Do a HEAD request to detect the file name\n " @"-P --proxy= " @" Specify SOCKS5 proxy\n " @"-q --quiet " @" Quiet mode (no output, except errors)\n " @"-v --verbose " @" Verbose mode (print headers)\n " @" --insecure " @" Ignore TLS errors and allow insecure redirects\n " |
︙ | ︙ | |||
367 368 369 370 371 372 373 | - (void)setMethod: (OFString *)method { void *pool = objc_autoreleasePoolPush(); method = method.uppercaseString; @try { | | | 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 | - (void)setMethod: (OFString *)method { void *pool = objc_autoreleasePoolPush(); method = method.uppercaseString; @try { _method = OFHTTPRequestMethodParseString(method); } @catch (OFInvalidArgumentException *e) { [OFStdErr writeLine: OF_LOCALIZED(@"invalid_input_method", @"%[prog]: Invalid request method %[method]!", @"prog", [OFApplication programName], @"method", method)]; [OFApplication terminateWithStatus: 1]; } |
︙ | ︙ | |||
408 409 410 411 412 413 414 | [OFStdErr writeLine: OF_LOCALIZED(@"invalid_input_proxy", @"%[prog]: Proxy must to be in format host:port!", @"prog", [OFApplication programName])]; [OFApplication terminateWithStatus: 1]; } } | | | 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 | [OFStdErr writeLine: OF_LOCALIZED(@"invalid_input_proxy", @"%[prog]: Proxy must to be in format host:port!", @"prog", [OFApplication programName])]; [OFApplication terminateWithStatus: 1]; } } - (void)applicationDidFinishLaunching: (OFNotification *)notification { OFString *outputPath; const OFOptionsParserOption options[] = { { 'b', @"body", 1, NULL, NULL }, { 'c', @"continue", 0, &_continue, NULL }, { 'f', @"force", 0, &_force, NULL }, { 'h', @"help", 0, NULL, NULL }, |
︙ | ︙ | |||
447 448 449 450 451 452 453 | /* Dropped after parsing options */ sandbox.allowsUnveil = true; [OFApplication of_activateSandbox: sandbox]; #endif #ifndef OF_AMIGAOS | | > | | | 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 | /* Dropped after parsing options */ sandbox.allowsUnveil = true; [OFApplication of_activateSandbox: sandbox]; #endif #ifndef OF_AMIGAOS [OFLocale addLocalizationDirectoryIRI: [OFIRI fileIRIWithPath: @LOCALIZATION_DIR]]; #else [OFLocale addLocalizationDirectoryIRI: [OFIRI fileIRIWithPath: @"PROGDIR:/share/ofhttp/localization"]]; #endif optionsParser = [OFOptionsParser parserWithOptions: options]; while ((option = [optionsParser nextOption]) != '\0') { switch (option) { case 'b': [self setBody: optionsParser.argument]; |
︙ | ︙ | |||
473 474 475 476 477 478 479 | [self setMethod: optionsParser.argument]; break; case 'P': [self setProxy: optionsParser.argument]; break; case ':': if (optionsParser.lastLongOption != nil) | | | | | | | | | | | | | | | 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 | [self setMethod: optionsParser.argument]; break; case 'P': [self setProxy: optionsParser.argument]; break; case ':': if (optionsParser.lastLongOption != nil) [OFStdErr writeLine: OF_LOCALIZED( @"long_argument_missing", @"%[prog]: Argument for option --%[opt] " @"missing", @"prog", [OFApplication programName], @"opt", optionsParser.lastLongOption)]; else { OFString *optStr = [OFString stringWithFormat: @"%C", optionsParser.lastOption]; [OFStdErr writeLine: OF_LOCALIZED( @"argument_missing", @"%[prog]: Argument for option -%[opt] " @"missing", @"prog", [OFApplication programName], @"opt", optStr)]; } [OFApplication terminateWithStatus: 1]; break; case '=': [OFStdErr writeLine: OF_LOCALIZED( @"option_takes_no_argument", @"%[prog]: Option --%[opt] takes no argument", @"prog", [OFApplication programName], @"opt", optionsParser.lastLongOption)]; [OFApplication terminateWithStatus: 1]; break; case '?': if (optionsParser.lastLongOption != nil) [OFStdErr writeLine: OF_LOCALIZED( @"unknown_long_option", @"%[prog]: Unknown option: --%[opt]", @"prog", [OFApplication programName], @"opt", optionsParser.lastLongOption)]; else { OFString *optStr = [OFString stringWithFormat: @"%C", optionsParser.lastOption]; [OFStdErr writeLine: OF_LOCALIZED( @"unknown_option", @"%[prog]: Unknown option: -%[opt]", @"prog", [OFApplication programName], @"opt", optStr)]; } [OFApplication terminateWithStatus: 1]; break; |
︙ | ︙ | |||
542 543 544 545 546 547 548 | [sandbox unveilPath: @"/etc/ssl" permissions: @"r"]; sandbox.allowsUnveil = false; [OFApplication of_activateSandbox: sandbox]; #endif _outputPath = [outputPath copy]; | | | | | | | | | 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 | [sandbox unveilPath: @"/etc/ssl" permissions: @"r"]; sandbox.allowsUnveil = false; [OFApplication of_activateSandbox: sandbox]; #endif _outputPath = [outputPath copy]; _IRIs = [optionsParser.remainingArguments copy]; if (_IRIs.count < 1) help(OFStdErr, false, 1); if (_quiet && _verbose) { [OFStdErr writeLine: OF_LOCALIZED(@"quiet_xor_verbose", @"%[prog]: -q / --quiet and -v / --verbose are mutually " @"exclusive!", @"prog", [OFApplication programName])]; [OFApplication terminateWithStatus: 1]; } if (_outputPath != nil && _detectFileName) { [OFStdErr writeLine: OF_LOCALIZED( @"output_xor_detect_filename", @"%[prog]: -o / --output and -O / --detect-filename are " @"mutually exclusive!", @"prog", [OFApplication programName])]; [OFApplication terminateWithStatus: 1]; } if (_outputPath != nil && _IRIs.count > 1) { [OFStdErr writeLine: OF_LOCALIZED( @"output_only_with_one_iri", @"%[prog]: Cannot use -o / --output when more than one IRI " @"has been specified!", @"prog", [OFApplication programName])]; [OFApplication terminateWithStatus: 1]; } if (_insecure) _HTTPClient.allowsInsecureRedirects = true; #ifdef OF_WINDOWS _useUnicode = [OFSystemInfo isWindowsNT]; #else _useUnicode = ([OFLocale encoding] == OFStringEncodingUTF8); #endif [self performSelector: @selector(downloadNextIRI) afterDelay: 0]; } - (void)client: (OFHTTPClient *)client didCreateTLSStream: (OFTLSStream *)stream request: (OFHTTPRequest *)request { /* Use setter instead of property access to work around GCC bug. */ |
︙ | ︙ | |||
606 607 608 609 610 611 612 | char buffer[4096]; size_t length = [_body readIntoBuffer: buffer length: 4096]; [body writeBuffer: buffer length: length]; } } - (bool)client: (OFHTTPClient *)client | | | 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 | char buffer[4096]; size_t length = [_body readIntoBuffer: buffer length: 4096]; [body writeBuffer: buffer length: length]; } } - (bool)client: (OFHTTPClient *)client shouldFollowRedirectToIRI: (OFIRI *)IRI statusCode: (short)statusCode request: (OFHTTPRequest *)request response: (OFHTTPResponse *)response { if (_verbose) { void *pool = objc_autoreleasePoolPush(); OFDictionary OF_GENERIC(OFString *, OFString *) *headers = |
︙ | ︙ | |||
628 629 630 631 632 633 634 | [OFStdOut writeFormat: @" %@: %@\n", key, object]; objc_autoreleasePoolPop(pool); } if (!_quiet) { if (_useUnicode) | | | | | | | | | 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 | [OFStdOut writeFormat: @" %@: %@\n", key, object]; objc_autoreleasePoolPop(pool); } if (!_quiet) { if (_useUnicode) [OFStdOut writeFormat: @"☇ %@", IRI.string]; else [OFStdOut writeFormat: @"< %@", IRI.string]; } _length = 0; return true; } - (bool)stream: (OFStream *)response didReadIntoBuffer: (void *)buffer length: (size_t)length exception: (id)exception { if (exception != nil) { OFString *IRI; [_progressBar stop]; [_progressBar draw]; [_progressBar release]; _progressBar = nil; if (!_quiet) { [OFStdOut writeString: @"\n "]; [OFStdOut writeLine: OF_LOCALIZED(@"download_error", @"Error!")]; } IRI = [_IRIs objectAtIndex: _IRIIndex - 1]; [OFStdErr writeLine: OF_LOCALIZED( @"download_failed_exception", @"%[prog]: Failed to download <%[iri]>!\n" @" %[exception]", @"prog", [OFApplication programName], @"iri", IRI, @"exception", exception)]; _errorCode = 1; [self performSelector: @selector(downloadNextIRI) afterDelay: 0]; return false; } [_output writeBuffer: buffer length: length]; _received += length; |
︙ | ︙ | |||
689 690 691 692 693 694 695 | if (!_quiet) { [OFStdOut writeString: @"\n "]; [OFStdOut writeLine: OF_LOCALIZED(@"download_done", @"Done!")]; } | | | 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 | if (!_quiet) { [OFStdOut writeString: @"\n "]; [OFStdOut writeLine: OF_LOCALIZED(@"download_done", @"Done!")]; } [self performSelector: @selector(downloadNextIRI) afterDelay: 0]; return false; } return true; } |
︙ | ︙ | |||
811 812 813 814 815 816 817 | { if (exception != nil) { if ([exception isKindOfClass: [OFResolveHostFailedException class]]) { if (!_quiet) [OFStdOut writeString: @"\n"]; | | | | | | | | | | | > > > > > > > > > > > > > > > > | 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 | { if (exception != nil) { if ([exception isKindOfClass: [OFResolveHostFailedException class]]) { if (!_quiet) [OFStdOut writeString: @"\n"]; [OFStdErr writeLine: OF_LOCALIZED( @"download_resolve_host_failed", @"%[prog]: Failed to download <%[iri]>!\n" @" Failed to resolve host: %[exception]", @"prog", [OFApplication programName], @"iri", request.IRI.string, @"exception", exception)]; } else if ([exception isKindOfClass: [OFConnectSocketFailedException class]]) { if (!_quiet) [OFStdOut writeString: @"\n"]; [OFStdErr writeLine: OF_LOCALIZED( @"download_failed_connection_failed", @"%[prog]: Failed to download <%[iri]>!\n" @" Connection failed: %[exception]", @"prog", [OFApplication programName], @"iri", request.IRI.string, @"exception", exception)]; } else if ([exception isKindOfClass: [OFInvalidServerResponseException class]]) { if (!_quiet) [OFStdOut writeString: @"\n"]; [OFStdErr writeLine: OF_LOCALIZED( @"download_failed_invalid_server_response", @"%[prog]: Failed to download <%[iri]>!\n" @" Invalid server response!", @"prog", [OFApplication programName], @"iri", request.IRI.string)]; } else if ([exception isKindOfClass: [OFUnsupportedProtocolException class]]) { if (!_quiet) [OFStdOut writeString: @"\n"]; [OFStdErr writeLine: OF_LOCALIZED(@"no_tls_support", @"%[prog]: No TLS support in ObjFW!\n" @" In order to download via HTTPS, you need to " @"either build ObjFW with TLS\n" @" support or preload a library adding TLS " @"support to ObjFW!", @"prog", [OFApplication programName])]; } else if ([exception isKindOfClass: [OFTLSHandshakeFailedException class]]) { OFString *error = OFTLSStreamErrorCodeDescription( ((OFTLSHandshakeFailedException *)exception) .errorCode); if (!_quiet) [OFStdOut writeString: @"\n"]; [OFStdErr writeLine: OF_LOCALIZED( @"download_failed_tls_handshake_failed", @"%[prog]: Failed to download <%[iri]>!\n" @" TLS handshake failed: %[error]", @"prog", [OFApplication programName], @"iri", request.IRI.string, @"error", error)]; } else if ([exception isKindOfClass: [OFReadOrWriteFailedException class]]) { OFString *error = OF_LOCALIZED( @"download_failed_read_or_write_failed_any", @"Read or write failed"); if (!_quiet) |
︙ | ︙ | |||
877 878 879 880 881 882 883 | error = OF_LOCALIZED( @"download_failed_read_or_write_failed_" @"write", @"Write failed"); [OFStdErr writeLine: OF_LOCALIZED( @"download_failed_read_or_write_failed", | | | | | | | | | | 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 | error = OF_LOCALIZED( @"download_failed_read_or_write_failed_" @"write", @"Write failed"); [OFStdErr writeLine: OF_LOCALIZED( @"download_failed_read_or_write_failed", @"%[prog]: Failed to download <%[iri]>!\n" @" %[error]: %[exception]", @"prog", [OFApplication programName], @"iri", request.IRI.string, @"error", error, @"exception", exception)]; } else if ([exception isKindOfClass: [OFHTTPRequestFailedException class]]) { short statusCode; OFString *codeString; if (_ignoreStatus) { exception = nil; goto after_exception_handling; } statusCode = response.statusCode; codeString = [OFString stringWithFormat: @"%hd %@", statusCode, OFHTTPStatusCodeString(statusCode)]; [OFStdErr writeLine: OF_LOCALIZED(@"download_failed", @"%[prog]: Failed to download <%[iri]>!\n" @" HTTP status code: %[code]", @"prog", [OFApplication programName], @"iri", request.IRI.string, @"code", codeString)]; } else @throw exception; _errorCode = 1; [self performSelector: @selector(downloadNextIRI) afterDelay: 0]; return; } after_exception_handling: if (_method == OFHTTPRequestMethodHead) goto next; if (_detectFileNameRequest) { _currentFileName = [fileNameFromContentDisposition( [response.headers objectForKey: @"Content-Disposition"]) copy]; _detectedFileName = true; /* Handle this IRI on the next -[downloadNextIRI] call */ _IRIIndex--; [self performSelector: @selector(downloadNextIRI) afterDelay: 0]; return; } if ([_outputPath isEqual: @"-"]) _output = [OFStdOut copy]; else { |
︙ | ︙ | |||
961 962 963 964 965 966 967 968 969 970 971 972 973 974 | @"prog", [OFApplication programName], @"filename", _currentFileName, @"exception", e)]; _errorCode = 1; goto next; } } if (!_quiet) { _progressBar = [[ProgressBar alloc] initWithLength: _length resumedFrom: _resumedFrom useUnicode: _useUnicode]; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 | @"prog", [OFApplication programName], @"filename", _currentFileName, @"exception", e)]; _errorCode = 1; goto next; } #ifdef OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES @try { OFString *IRIString = request.IRI.string; OFData *downloadedFromData = [OFData dataWithItems: IRIString.UTF8String count: IRIString.UTF8StringLength + 1]; [[OFFileManager defaultManager] setExtendedAttributeData: downloadedFromData forName: @"user.ofhttp." @"downloaded_from" ofItemAtPath: _currentFileName]; } @catch (OFSetItemAttributesFailedException *) { /* Ignore */ } #endif #ifdef OF_MACOS @try { OFString *quarantine = [OFString stringWithFormat: @"0000;%08" @PRIx64 @";ofhttp;", (uint64_t)[[OFDate date] timeIntervalSince1970]]; OFData *quarantineData = [OFData dataWithItems: quarantine.UTF8String count: quarantine.UTF8StringLength]; [[OFFileManager defaultManager] setExtendedAttributeData: quarantineData forName: @"com.apple.quarantine" ofItemAtPath: _currentFileName]; } @catch (OFSetItemAttributesFailedException *e) { /* Ignore */ } #endif } if (!_quiet) { _progressBar = [[ProgressBar alloc] initWithLength: _length resumedFrom: _resumedFrom useUnicode: _useUnicode]; |
︙ | ︙ | |||
983 984 985 986 987 988 989 | [response asyncReadIntoBuffer: _buffer length: [OFSystemInfo pageSize]]; return; next: [_currentFileName release]; _currentFileName = nil; | | | | | | | | | | | | | | | | | | | | | | | | | 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 | [response asyncReadIntoBuffer: _buffer length: [OFSystemInfo pageSize]]; return; next: [_currentFileName release]; _currentFileName = nil; [self performSelector: @selector(downloadNextIRI) afterDelay: 0]; } - (void)downloadNextIRI { OFString *IRIString = nil; OFIRI *IRI; OFMutableDictionary *clientHeaders; OFHTTPRequest *request; _received = _length = _resumedFrom = 0; if (_output != OFStdOut) [_output release]; _output = nil; if (_IRIIndex >= _IRIs.count) [OFApplication terminateWithStatus: _errorCode]; @try { IRIString = [_IRIs objectAtIndex: _IRIIndex++]; IRI = [OFIRI IRIWithString: IRIString]; } @catch (OFInvalidFormatException *e) { [OFStdErr writeLine: OF_LOCALIZED(@"invalid_iri", @"%[prog]: Invalid IRI: <%[iri]>!", @"prog", [OFApplication programName], @"iri", IRIString)]; _errorCode = 1; goto next; } if (![IRI.scheme isEqual: @"http"] && ![IRI.scheme isEqual: @"https"]) { [OFStdErr writeLine: OF_LOCALIZED(@"invalid_scheme", @"%[prog]: Invalid scheme: <%[iri]>!", @"prog", [OFApplication programName], @"iri", IRIString)]; _errorCode = 1; goto next; } clientHeaders = [[_clientHeaders mutableCopy] autorelease]; if (_detectFileName && !_detectedFileName) { if (!_quiet) { if (_useUnicode) [OFStdOut writeFormat: @"⠒ %@", IRI.string]; else [OFStdOut writeFormat: @"? %@", IRI.string]; } request = [OFHTTPRequest requestWithIRI: IRI]; request.headers = clientHeaders; request.method = OFHTTPRequestMethodHead; _detectFileNameRequest = true; [_HTTPClient asyncPerformRequest: request]; return; } if (!_detectedFileName) { [_currentFileName release]; _currentFileName = nil; } else _detectedFileName = false; if (_currentFileName == nil) _currentFileName = [_outputPath copy]; if (_currentFileName == nil) _currentFileName = [IRI.path.lastPathComponent copy]; if ([_currentFileName isEqual: @"/"] || _currentFileName.length == 0) { [_currentFileName release]; _currentFileName = nil; } if (_currentFileName == nil) _currentFileName = @"unnamed"; if (_continue) { @try { unsigned long long size = [[OFFileManager defaultManager] attributesOfItemAtPath: _currentFileName].fileSize; OFString *range; if (size > ULLONG_MAX) @throw [OFOutOfRangeException exception]; _resumedFrom = (unsigned long long)size; range = [OFString stringWithFormat: @"bytes=%ju-", _resumedFrom]; [clientHeaders setObject: range forKey: @"Range"]; } @catch (OFGetItemAttributesFailedException *e) { } } if (!_quiet) { if (_useUnicode) [OFStdOut writeFormat: @"⇣ %@", IRI.string]; else [OFStdOut writeFormat: @"< %@", IRI.string]; } request = [OFHTTPRequest requestWithIRI: IRI]; request.headers = clientHeaders; request.method = _method; _detectFileNameRequest = false; [_HTTPClient asyncPerformRequest: request]; return; next: [self performSelector: @selector(downloadNextIRI) afterDelay: 0]; } @end |
Modified utils/ofhttp/ProgressBar.h from [be2c97fe71] to [b91e7f534c].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #import "OFObject.h" @class OFDate; @class OFTimer; |
︙ | ︙ |
Modified utils/ofhttp/ProgressBar.m from [9a2768256d] to [df1e34afda].
1 | /* | | | | | | > > > > | < > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #include <math.h> #import "OFDate.h" |
︙ | ︙ |
Modified utils/ofhttp/localization/de.json from [839a028930] to [89ce45218c].
|
| > > > > > > > > | > > > | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | /* * German localization for ofhttp. * * Copyright (c) 2017-2024 Jonathan Schleifer <js@nil.im> * * Permission to use, copy, modify, and/or distribute this localization for * any purpose with or without fee is hereby granted. */ /* vim: se ft=javascript sw=4 et: */ { usage: "Benutzung: %[prog] -[cehHmoOPqv] iri1 [iri2 ...]", full_usage: [ "Optionen:\n", " -b --body= Angegebene Datei als Body übergeben\n", " (- für Standard-Eingabe)\n", " -c --continue Download von existierender Datei ", "fortsetzen\n", " -f --force Existierende Datei überschreiben\n", " -h --help Diese Hilfe anzeigen\n", " -H --header= Einen Header (z.B. X-Foo:Bar) hinzufügen\n", " -m --method= HTTP Request-Methode setzen\n", " -o --output= Ausgabe-Dateiname angeben\n", " -O --detect-filename Dateiname mittels HEAD-Request ermitteln\n", " -P --proxy= SOCKS5-Proxy angeben\n", " -q --quiet Ruhiger Modus (keine Ausgabe außer Fehler)", "\n", " -v --verbose Ausführlicher Modus (gibt Header aus)\n", " --insecure TLS-Fehler ignorieren und unsichere\n", " Weiterleitungen erlauben\n", " --ignore-status HTTP Status-Code ignorieren" ], invalid_input_header: "%[prog]: Header müssen im Format Name:Wert sein!", invalid_input_method: "%[prog]: Ungültige Request-Methode %[method]!", invalid_input_proxy: "%[prog]: Proxy muss im Format Host:Port sein!", long_argument_missing: "%[prog]: Argument für Option --%[opt] fehlt", argument_missing: "%[prog]: Argument für option -%[opt] fehlt", option_takes_no_argument: "%[prog]: Option --%[opt] nimmt kein Argument", unknown_long_option: "%[prog]: Unbekannte Option: --%[opt]", unknown_option: "%[prog]: Unbekannte Option: -%[opt]", quiet_xor_verbose: [ "%[prog]: -q / --quiet und -v / --verbose schließen sich gegenseitig ", "aus!" ], output_xor_detect_filename: [ "%[prog]: -o / --output und -O / --detect-filename schließen sich ", "gegenseitig aus!" ], output_only_with_one_iri: [ "%[prog]: -o / --output kann nicht mit mehr als einer IRI benutzt ", "werden!" ], download_resolve_host_failed: [ "%[prog]: Fehler beim Download von <%[iri]>!\n", " Host auflösen fehlgeschlagen: %[exception]" ], download_failed_connection_failed: [ "%[prog]: Fehler beim Download von <%[iri]>!\n", " Verbindung fehlgeschlagen: %[exception]" ], download_failed_invalid_server_response: [ "%[prog]: Fehler beim Download von <%[iri]>!\n", " Ungültige Antwort vom Server!" ], no_tls_support: [ "%[prog]: Keine TLS-Unterstützung in ObjFW!\n", " Um via HTTPS runterzuladen müssen Sie entweder ObjFW mit TLS-", "Unterstützung\n", " kompilieren oder eine Bibliothek mittels „preload” laden, welche ", "TLS-Support\n", " zu ObjFW hinzufügt!" ], download_failed_tls_handshake_failed: [ "%[prog]: Fehler beim Download von <%[iri]>!\n", " TLS-Handshake fehlgeschlagen: %[error]" ], download_failed_read_or_write_failed_any: "Lesen oder Schreiben", download_failed_read_or_write_failed_read: "Lesen", download_failed_read_or_write_failed_write: "Schreiben", download_failed_read_or_write_failed: [ "%[prog]: Fehler beim Download von <%[iri]>!\n", " %[error]: %[exception]" ], download_failed: [ "%[prog]: Fehler beim Download von <%[iri]>!\n", " HTTP Status-Code: %[code]" ], download_error: "Fehler!", download_failed_exception: [ "%[prog]: Fehler beim Download von <%[iri]>!\n", " %[exception]" ], download_done: "Fertig!", invalid_iri: "%[prog]: Ungültige IRI: <%[iri]>!", invalid_scheme: "%[prog]: Ungültiges Schema: <%[iri]>!", type_unknown: "unbekannt", size_gib: "%[num] GiB", size_mib: "%[num] MiB", size_kib: "%[num] KiB", size_bytes: [ [ {"num == 1": "1 Byte"}, {"": "%[num] Bytes"} ] ], size_unknown: "unbekannt", info_name_unaligned: "Name: %[name]", info_name: "Name: %[name]", info_type: "Typ: %[type]", info_size: "Größe: %[size]", output_already_exists: "%[prog]: Datei %[filename] existiert bereits!", failed_to_open_output: [ "%[prog]: Kann Datei %[filename] nicht öffnen: %[exception]" ], eta_days: "%[num] t ", progress_bytes: [ [ {"num == 1": "1 Byte "}, {"": "%[num] Bytes"} ] ], } |
Modified utils/ofhttp/localization/localizations.json from [1722bb6119] to [be4c09810e].
|
| > > > > > > > > | > | > > | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | /* * Localization mapping for ofhttp. * * Copyright (c) 2017-2023 Jonathan Schleifer <js@nil.im> * * Permission to use, copy, modify, and/or distribute this mapping for any * purpose with or without fee is hereby granted. */ /* vim: se ft=javascript sw=4 et: */ { de: { "": "de" }, deutsch: { "": "de" }, german: { "": "de" }, } |