Squashed 'external/toxcore/c-toxcore/' changes from f1df709b87..8f0d505f9a

8f0d505f9a feat: add ngc events
9b8216e70c refactor: Make event dispatch ordered by receive time.
814c12a6f4 cleanup: Add dynamically derived array sizes to the API.
226b23be12 cleanup: Add explicit array sizes to toxencryptsave.
ef33cb4de0 cleanup: Add Toxav alias for ToxAV.
1da723b34d cleanup: Make Tox_Options a typedef.
b148a2afff chore: Simplify msvc build using vcpkg.
5cac6d7eb1 cleanup: Move `tox_get_system` out of the public API.
c9ca4007e3 refactor: Align group message sending with other send functions.
6c6c0b1b1b cleanup: Make setters take non-const `Tox *`.
a76f758d70 cleanup: Mark arrays in the tox API as `[]` instead of `*`.
baf6d1f6cf cleanup: Make array params in toxav `[]` instead of `*`.
79f55bd06a cleanup: Put the size of fixed arrays into the API types.
1e73698db2 cleanup: Add typedefs for public API int identifiers.
cac074c57f chore: Add fetch-sha256 script to update bootstrap node hash.
32576656bb Make the comment capitalization uniform
aff4dda17c Spellcheck tox-bootstrapd
40b5fbbe9d chore: Remove settings.yml in favour of hs-github-tools.
ebafd51be7 chore: Use GPL license with https.
0e42752f0f cleanup: Move all vptr-to-ptr casts to the beginning of a function.
5407384211 cleanup: Use github actions matrix to simplify CI.
82d8265688 fix: Use QueryPerformanceCounter on windows for monotonic time.
1224e656e3 chore: Add `net_(new|kill)_strerror` to cppcheck's allocators.
6a90ddfe4e cleanup: Run clang-tidy on headers, as well.
bd930cc80a cleanup: Make TCP connection failures a warning instead of error.
fad6e4e173 cleanup: Make all .c files include the headers they need.
ef4897a898 cleanup: Upgrade to clang-tidy-17 and fix some warnings.
REVERT: f1df709b87 feat: add ngc events
REVERT: 1b6c907235 refactor: Make event dispatch ordered by receive time.

git-subtree-dir: external/toxcore/c-toxcore
git-subtree-split: 8f0d505f9a598cc41c682178e1589bcc01efe9cb
This commit is contained in:
Green Sky 2024-01-09 16:39:05 +01:00
parent b2ae9530a4
commit 9ace11a0e2
152 changed files with 1542 additions and 1140 deletions

View File

@ -15,7 +15,6 @@ workflows:
- ubsan - ubsan
# Static analysis # Static analysis
- clang-analyze - clang-analyze
- clang-tidy
- cpplint - cpplint
- infer - infer
- static-analysis - static-analysis
@ -154,24 +153,6 @@ jobs:
- run: git submodule update --init --recursive - run: git submodule update --init --recursive
- run: other/analysis/run-clang-analyze - run: other/analysis/run-clang-analyze
clang-tidy:
working_directory: ~/work
docker:
- image: ubuntu
steps:
- run: *apt_install
- run:
apt-get install -y --no-install-recommends
ca-certificates
clang-tidy-14
- checkout
- run: git submodule update --init --recursive
- run:
other/analysis/run-clang-tidy ||
other/analysis/run-clang-tidy ||
other/analysis/run-clang-tidy
cpplint: cpplint:
working_directory: ~/work working_directory: ~/work
docker: docker:

View File

@ -1,4 +1,5 @@
# vim:ft=yaml # vim:ft=yaml
HeaderFilterRegex: "/c-toxcore/[^/]+/[^.].+"
CheckOptions: CheckOptions:
- key: readability-identifier-naming.ClassCase - key: readability-identifier-naming.ClassCase
value: Camel_Snake_Case value: Camel_Snake_Case
@ -35,6 +36,12 @@ CheckOptions:
value: lower_case value: lower_case
- key: llvmlibc-restrict-system-libc-headers.Includes - key: llvmlibc-restrict-system-libc-headers.Includes
value: "arpa/inet.h,assert.h,ctype.h,errno.h,fcntl.h,getopt.h,libconfig.h,linux/netdevice.h,math.h,netdb.h,netinet/in.h,opus.h,pthread.h,signal.h,sodium/crypto_scalarmult_curve25519.h,sodium.h,sodium/randombytes.h,stdio.h,stdlib.h,string.h,sys/ioctl.h,syslog.h,sys/resource.h,sys/socket.h,sys/stat.h,sys/time.h,sys/types.h,time.h,unistd.h,vpx/vp8cx.h,vpx/vp8dx.h,vpx/vpx_decoder.h,vpx/vpx_encoder.h,vpx/vpx_image.h" value: "arpa/inet.h,assert.h,ctype.h,errno.h,fcntl.h,getopt.h,libconfig.h,limits.h,linux/if.h,math.h,netdb.h,netinet/in.h,opus.h,pthread.h,signal.h,sodium/crypto_scalarmult_curve25519.h,sodium.h,sodium/randombytes.h,stdarg.h,stdbool.h,stddef.h,stdint.h,stdio.h,stdlib.h,string.h,sys/ioctl.h,syslog.h,sys/resource.h,sys/socket.h,sys/stat.h,sys/time.h,sys/types.h,time.h,unistd.h,vpx/vp8cx.h,vpx/vp8dx.h,vpx/vpx_decoder.h,vpx/vpx_encoder.h,vpx/vpx_image.h"
- key: hicpp-signed-bitwise.IgnorePositiveIntegerLiterals - key: hicpp-signed-bitwise.IgnorePositiveIntegerLiterals
value: true value: true
- key: concurrency-mt-unsafe.FunctionSet
value: posix
- key: misc-include-cleaner.IgnoreHeaders
value: "pthread.h;stdbool.h;stddef.h;stdint.;stdint.h;stdint...;cstdint;sodium.*;sys/.*;unistd.h;opus.*;vpx.*;attributes.h;tox_struct.h"
- key: readability-function-cognitive-complexity.Threshold
value: 153 # TODO(iphydf): Decrease. tox_new is the highest at the moment.

View File

@ -1,12 +1,15 @@
#!/bin/bash #!/bin/bash
set -exu set -exu -o pipefail
LOCAL="${1:-}" LOCAL="${1:-}"
readarray -t FILES <<<"$(git ls-files)" readarray -t FILES <<<"$(git ls-files)"
tar c "${FILES[@]}" | docker build -f other/bootstrap_daemon/docker/Dockerfile -t toxchat/bootstrap-node - if ! tar c "${FILES[@]}" | docker build -f other/bootstrap_daemon/docker/Dockerfile -t toxchat/bootstrap-node - 2>&1 | tee docker-build.log; then
grep -o "::error.*::[a-f0-9]* /usr/local/bin/tox-bootstrapd" docker-build.log
false
fi
docker tag toxchat/bootstrap-node:latest toxchat/bootstrap-node:"$(other/print-version)" docker tag toxchat/bootstrap-node:latest toxchat/bootstrap-node:"$(other/print-version)"
sudo useradd \ sudo useradd \

86
.github/settings.yml vendored
View File

@ -1,86 +0,0 @@
---
_extends: .github
repository:
name: c-toxcore
description: The future of online communications.
homepage: https://tox.chat/
topics: toxcore, network, p2p, security, encryption, cryptography
branches:
- name: "master"
protection:
required_status_checks:
contexts:
- "bazel-dbg"
- "bazel-opt"
- "build-alpine-s390x"
- "build-android"
- "build-autotools"
- "build-compcert"
- "build-macos"
- "build-tcc"
- "build-win32"
- "build-win64"
- "ci/circleci: asan"
- "ci/circleci: bazel-asan"
- "ci/circleci: bazel-msan"
- "ci/circleci: bazel-tsan"
- "ci/circleci: clang-analyze"
- "ci/circleci: clang-tidy"
- "ci/circleci: cpplint"
- "ci/circleci: infer"
- "ci/circleci: static-analysis"
- "ci/circleci: tsan"
- "ci/circleci: ubsan"
- "cimple"
- "cimplefmt"
- "CodeFactor"
- "code-review/reviewable"
- "common / buildifier"
- "coverage-linux"
- "docker-bootstrap-node"
- "docker-bootstrap-node-websocket"
- "docker-clusterfuzz"
- "docker-esp32"
- "docker-fuzzer"
- "docker-toxcore-js"
- "docker-win32"
- "docker-win64"
- "doxygen"
- "freebsd"
- "Hound"
- "misra"
- "mypy"
- "program-analysis"
- "sonar-scan"
- "tokstyle"
- "TokTok.c-toxcore"
- "TokTok.c-toxcore (windows_msvc_conan shared)"
- "TokTok.c-toxcore (windows_msvc_conan static)"
# Labels specific to c-toxcore.
labels:
- name: "bootstrap"
color: "#01707f"
description: "Bootstrap"
- name: "crypto"
color: "#1d76db"
description: "Crypto"
- name: "file transfers"
color: "#e02abf"
description: "File Transfers"
- name: "messenger"
color: "#d93f0b"
description: "Messenger"
- name: "network"
color: "#d4c5f9"
description: "Network"
- name: "toxav"
color: "#0052cc"
description: "Audio/video"

View File

@ -13,7 +13,10 @@ jobs:
common: common:
uses: TokTok/ci-tools/.github/workflows/common-ci.yml@master uses: TokTok/ci-tools/.github/workflows/common-ci.yml@master
cppcheck: analysis:
strategy:
matrix:
tool: [autotools, clang-tidy, compcert, cppcheck, doxygen, misra, tcc, tokstyle]
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Set up Docker Buildx - name: Set up Docker Buildx
@ -21,84 +24,16 @@ jobs:
- name: Docker Build - name: Docker Build
uses: docker/build-push-action@v4 uses: docker/build-push-action@v4
with: with:
file: other/docker/cppcheck/Dockerfile file: other/docker/${{ matrix.tool }}/Dockerfile
mypy: coverage-linux:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
submodules: recursive submodules: recursive
- name: Set up Python 3.9 - name: Build, test, and upload coverage
uses: actions/setup-python@v1 run: other/docker/coverage/run
with:
python-version: 3.9
- name: Install mypy
run: pip install mypy
- name: Run mypy
run: |
(find . -name "*.py" -and -not -name "conanfile.py"; grep -lR '^#!.*python') \
| xargs -n1 -P8 mypy --strict
doxygen:
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker Build
uses: docker/build-push-action@v4
with:
file: other/docker/doxygen/Dockerfile
tokstyle:
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker Build
uses: docker/build-push-action@v4
with:
file: other/docker/tokstyle/Dockerfile
misra:
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker Build
uses: docker/build-push-action@v4
with:
file: other/docker/misra/Dockerfile
build-autotools:
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker Build
uses: docker/build-push-action@v4
with:
file: other/docker/autotools/Dockerfile
build-tcc:
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker Build
uses: docker/build-push-action@v4
with:
file: other/docker/tcc/Dockerfile
build-compcert:
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker Build
uses: docker/build-push-action@v4
with:
file: other/docker/compcert/Dockerfile
generate-events: generate-events:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -120,42 +55,6 @@ jobs:
- name: Run cimplefmt - name: Run cimplefmt
run: other/docker/cimplefmt/run -u $(find tox* -name "*.[ch]") run: other/docker/cimplefmt/run -u $(find tox* -name "*.[ch]")
build-win32:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Cross compilation
run: .github/scripts/cmake-win32 script
build-win64:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Cross compilation
run: .github/scripts/cmake-win64 script
build-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Build and test
run: .github/scripts/cmake-osx
coverage-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Build, test, and upload coverage
run: other/docker/coverage/run
build-android: build-android:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@ -166,3 +65,68 @@ jobs:
- run: .github/scripts/cmake-android arm64-v8a - run: .github/scripts/cmake-android arm64-v8a
- run: .github/scripts/cmake-android x86 - run: .github/scripts/cmake-android x86
- run: .github/scripts/cmake-android x86_64 - run: .github/scripts/cmake-android x86_64
build-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Build and test
run: .github/scripts/cmake-osx
build-msvc:
strategy:
matrix:
version: [2019, 2022]
runs-on: windows-${{ matrix.version }}
env:
VCPKG_ROOT: "C:/vcpkg"
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Export GitHub Actions cache environment variables
uses: actions/github-script@v6
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Configure CMake
run: cmake --preset windows-default
- name: Build
run: cmake --build _build
- name: Test
run: |
cd _build
ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:6 --build-config Debug
build-windows:
strategy:
matrix:
bits: [32, 64]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Cross compilation
run: .github/scripts/cmake-win${{ matrix.bits }} script
mypy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install mypy
run: pip install mypy
- name: Run mypy
run: |
(find . -name "*.py" -and -not -name "conanfile.py"; grep -lR '^#!.*python') \
| xargs -n1 -P8 mypy --strict

2
.gitignore vendored
View File

@ -14,6 +14,8 @@ Thumbs.db
/_build /_build
/_install /_install
/tox-0.0.0* /tox-0.0.0*
/.vs
/CppProperties.json
CMakeCache.txt CMakeCache.txt
CMakeFiles CMakeFiles
Makefile Makefile

View File

@ -1,7 +1,7 @@
load("@rules_cc//cc:defs.bzl", "cc_library") load("@rules_cc//cc:defs.bzl", "cc_library")
load("//tools/project:build_defs.bzl", "project") load("//tools/project:build_defs.bzl", "project")
project() project(license = "gpl3-https")
genrule( genrule(
name = "public_headers", name = "public_headers",

View File

@ -81,7 +81,7 @@ find_package(GTest)
set(CMAKE_MACOSX_RPATH ON) set(CMAKE_MACOSX_RPATH ON)
# Set standard version for compiler. # Set standard version for compiler.
if(MSVC) if(MSVC AND MSVC_TOOLSET_VERSION LESS 143)
# https://developercommunity.visualstudio.com/t/older-winsdk-headers-are-incompatible-with-zcprepr/1593479 # https://developercommunity.visualstudio.com/t/older-winsdk-headers-are-incompatible-with-zcprepr/1593479
set(CMAKE_C_STANDARD 99) set(CMAKE_C_STANDARD 99)
else() else()
@ -94,6 +94,35 @@ set(CMAKE_CXX_EXTENSIONS OFF)
message(STATUS "Supported C compiler features = ${CMAKE_C_COMPILE_FEATURES}") message(STATUS "Supported C compiler features = ${CMAKE_C_COMPILE_FEATURES}")
message(STATUS "Supported C++ compiler features = ${CMAKE_CXX_COMPILE_FEATURES}") message(STATUS "Supported C++ compiler features = ${CMAKE_CXX_COMPILE_FEATURES}")
# Enable some warnings if we know the compiler.
if(MSVC)
add_compile_options(/W4 /analyze)
add_compile_options(/wd4100) # unreferenced formal parameter
add_compile_options(/wd4267) # narrowing conversion
add_compile_options(/wd4244) # narrowing conversion
add_compile_options(/wd4127) # conditional expression is constant
add_compile_options(/wd4995) # #pragma deprecated
add_compile_options(/wd4018) # signed/unsigned compare
add_compile_options(/wd4310) # cast truncates constant value
add_compile_options(/wd4389) # signed/unsigned compare
add_compile_options(/wd4245) # signed/unsigned assign/return/function call
add_compile_options(/wd4200) # nonstandard extension used: zero-sized array in struct/union
add_compile_options(/wd4702) # unreachable code
add_compile_options(/wd6340) # unsigned int passed to signed parameter
add_compile_options(/wd6326) # potential comparison of a constant with another constant
# TODO(iphydf): Look into these
add_compile_options(/wd4996) # use WSAAddressToStringW() instead of WSAAddressToStringA()
add_compile_options(/wd6255) # don't use alloca
add_compile_options(/wd6385) # reading invalid data
add_compile_options(/wd6001) # using uninitialized memory
add_compile_options(/wd6101) # returning uninitialized memory
add_compile_options(/wd6386) # buffer overrun
add_compile_options(/wd6011) # NULL dereference
add_compile_options(/wd6031) # sscanf return value ignored
add_compile_options(/wd6387) # passing NULL to fwrite
endif()
set(MIN_LOGGER_LEVEL "" CACHE STRING "Logging level to use (TRACE, DEBUG, INFO, WARNING, ERROR)") set(MIN_LOGGER_LEVEL "" CACHE STRING "Logging level to use (TRACE, DEBUG, INFO, WARNING, ERROR)")
if(MIN_LOGGER_LEVEL) if(MIN_LOGGER_LEVEL)
if(("${MIN_LOGGER_LEVEL}" STREQUAL "TRACE") OR if(("${MIN_LOGGER_LEVEL}" STREQUAL "TRACE") OR
@ -327,10 +356,14 @@ set(toxcore_SOURCES
toxcore/tox_unpack.h toxcore/tox_unpack.h
toxcore/util.c toxcore/util.c
toxcore/util.h) toxcore/util.h)
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ${LIBSODIUM_LIBRARIES}) if(TARGET unofficial-sodium::sodium)
set(toxcore_LINK_DIRECTORIES ${toxcore_LINK_DIRECTORIES} ${LIBSODIUM_LIBRARY_DIRS}) set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} unofficial-sodium::sodium)
set(toxcore_INCLUDE_DIRECTORIES ${toxcore_INCLUDE_DIRECTORIES} ${LIBSODIUM_INCLUDE_DIRS}) else()
set(toxcore_COMPILE_OPTIONS ${toxcore_COMPILE_OPTIONS} ${LIBSODIUM_CFLAGS_OTHER}) set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ${LIBSODIUM_LIBRARIES})
set(toxcore_LINK_DIRECTORIES ${toxcore_LINK_DIRECTORIES} ${LIBSODIUM_LIBRARY_DIRS})
set(toxcore_INCLUDE_DIRECTORIES ${toxcore_INCLUDE_DIRECTORIES} ${LIBSODIUM_INCLUDE_DIRS})
set(toxcore_COMPILE_OPTIONS ${toxcore_COMPILE_OPTIONS} ${LIBSODIUM_CFLAGS_OTHER})
endif()
set(toxcore_PKGCONFIG_REQUIRES ${toxcore_PKGCONFIG_REQUIRES} libsodium) set(toxcore_PKGCONFIG_REQUIRES ${toxcore_PKGCONFIG_REQUIRES} libsodium)
set(toxcore_API_HEADERS set(toxcore_API_HEADERS
${toxcore_SOURCE_DIR}/toxcore/tox.h^tox ${toxcore_SOURCE_DIR}/toxcore/tox.h^tox
@ -366,10 +399,14 @@ if(BUILD_TOXAV)
set(toxcore_API_HEADERS ${toxcore_API_HEADERS} set(toxcore_API_HEADERS ${toxcore_API_HEADERS}
${toxcore_SOURCE_DIR}/toxav/toxav.h^toxav) ${toxcore_SOURCE_DIR}/toxav/toxav.h^toxav)
if(MSVC)
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} PkgConfig::OPUS PkgConfig::VPX)
else()
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ${OPUS_LIBRARIES} ${VPX_LIBRARIES}) set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ${OPUS_LIBRARIES} ${VPX_LIBRARIES})
set(toxcore_LINK_DIRECTORIES ${toxcore_LINK_DIRECTORIES} ${OPUS_LIBRARY_DIRS} ${VPX_LIBRARY_DIRS}) set(toxcore_LINK_DIRECTORIES ${toxcore_LINK_DIRECTORIES} ${OPUS_LIBRARY_DIRS} ${VPX_LIBRARY_DIRS})
set(toxcore_INCLUDE_DIRECTORIES ${toxcore_INCLUDE_DIRECTORIES} ${OPUS_INCLUDE_DIRS} ${VPX_INCLUDE_DIRS}) set(toxcore_INCLUDE_DIRECTORIES ${toxcore_INCLUDE_DIRECTORIES} ${OPUS_INCLUDE_DIRS} ${VPX_INCLUDE_DIRS})
set(toxcore_COMPILE_OPTIONS ${toxcore_COMPILE_OPTIONS} ${OPUS_CFLAGS_OTHER} ${VPX_CFLAGS_OTHER}) set(toxcore_COMPILE_OPTIONS ${toxcore_COMPILE_OPTIONS} ${OPUS_CFLAGS_OTHER} ${VPX_CFLAGS_OTHER})
endif()
set(toxcore_PKGCONFIG_REQUIRES ${toxcore_PKGCONFIG_REQUIRES} opus vpx) set(toxcore_PKGCONFIG_REQUIRES ${toxcore_PKGCONFIG_REQUIRES} opus vpx)
endif() endif()
@ -400,7 +437,6 @@ if(CMAKE_THREAD_LIBS_INIT)
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} ${CMAKE_THREAD_LIBS_INIT}) set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} ${CMAKE_THREAD_LIBS_INIT})
endif() endif()
if(NSL_LIBRARIES) if(NSL_LIBRARIES)
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ${NSL_LIBRARIES}) set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ${NSL_LIBRARIES})
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} -lnsl) set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} -lnsl)
@ -416,9 +452,13 @@ if(SOCKET_LIBRARIES)
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} -lsocket) set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} -lsocket)
endif() endif()
if(TARGET PThreads4W::PThreads4W)
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} PThreads4W::PThreads4W)
elseif(TARGET Threads::Threads)
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} Threads::Threads)
endif()
if(WIN32) if(WIN32)
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ws2_32 iphlpapi) set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} iphlpapi wsock32 ws2_32)
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} -lws2_32 -liphlpapi)
endif() endif()
################################################################################ ################################################################################
@ -516,6 +556,14 @@ if(DHT_BOOTSTRAP)
target_link_libraries(DHT_bootstrap PRIVATE toxcore_shared) target_link_libraries(DHT_bootstrap PRIVATE toxcore_shared)
endif() endif()
target_link_libraries(DHT_bootstrap PRIVATE misc_tools) target_link_libraries(DHT_bootstrap PRIVATE misc_tools)
if(TARGET unofficial-sodium::sodium)
target_link_libraries(DHT_bootstrap PRIVATE unofficial-sodium::sodium)
endif()
if(TARGET PThreads4W::PThreads4W)
target_link_libraries(DHT_bootstrap PRIVATE PThreads4W::PThreads4W)
elseif(TARGET Threads::Threads)
target_link_libraries(DHT_bootstrap PRIVATE Threads::Threads)
endif()
install(TARGETS DHT_bootstrap RUNTIME DESTINATION bin) install(TARGETS DHT_bootstrap RUNTIME DESTINATION bin)
endif() endif()

21
CMakePresets.json Normal file
View File

@ -0,0 +1,21 @@
{
"version": 3,
"configurePresets": [
{
"name": "windows-default",
"binaryDir": "${sourceDir}/_build",
"cacheVariables": {
"ENABLE_SHARED": true,
"ENABLE_STATIC": true,
"AUTOTEST": true,
"BUILD_MISC_TESTS": true,
"BOOTSTRAP_DAEMON": false,
"MUST_BUILD_TOXAV": true,
"TEST_TIMEOUT_SECONDS": "60",
"CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS": true,
"CMAKE_COMPILE_WARNING_AS_ERROR": true,
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
}
}
]
}

View File

@ -1,7 +1,7 @@
GNU GENERAL PUBLIC LICENSE GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007 Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed. of this license document, but changing it is not allowed.
@ -645,7 +645,7 @@ the "copyright" line and a pointer to where the full notice is found.
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. 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. Also add information on how to contact you by electronic and paper mail.
@ -664,12 +664,11 @@ 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, 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. 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 For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>. <https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with 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 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 Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>. <https://www.gnu.org/licenses/why-not-lgpl.html>.

View File

@ -9,6 +9,11 @@ if(TARGET toxcore_static)
else() else()
target_link_libraries(auto_test_support PRIVATE toxcore_shared) target_link_libraries(auto_test_support PRIVATE toxcore_shared)
endif() endif()
if(TARGET PThreads4W::PThreads4W)
target_link_libraries(auto_test_support PRIVATE PThreads4W::PThreads4W)
elseif(TARGET Threads::Threads)
target_link_libraries(auto_test_support PRIVATE Threads::Threads)
endif()
function(auto_test target) function(auto_test target)
add_executable(auto_${target}_test ${target}_test.c) add_executable(auto_${target}_test ${target}_test.c)
@ -18,12 +23,15 @@ function(auto_test target)
else() else()
target_link_libraries(auto_${target}_test PRIVATE toxcore_shared) target_link_libraries(auto_${target}_test PRIVATE toxcore_shared)
endif() endif()
if(NOT ARGV1 STREQUAL "DONT_RUN") if(TARGET PThreads4W::PThreads4W)
target_link_libraries(auto_${target}_test PRIVATE PThreads4W::PThreads4W)
elseif(TARGET Threads::Threads)
target_link_libraries(auto_${target}_test PRIVATE Threads::Threads)
endif()
add_test(NAME ${target} COMMAND ${CROSSCOMPILING_EMULATOR} auto_${target}_test) add_test(NAME ${target} COMMAND ${CROSSCOMPILING_EMULATOR} auto_${target}_test)
set_tests_properties(${target} PROPERTIES TIMEOUT "${TEST_TIMEOUT_SECONDS}") set_tests_properties(${target} PROPERTIES TIMEOUT "${TEST_TIMEOUT_SECONDS}")
# add the source dir as environment variable, so the testdata can be found # add the source dir as environment variable, so the testdata can be found
set_tests_properties(${target} PROPERTIES ENVIRONMENT "LLVM_PROFILE_FILE=${target}.profraw;srcdir=${CMAKE_CURRENT_SOURCE_DIR}") set_tests_properties(${target} PROPERTIES ENVIRONMENT "LLVM_PROFILE_FILE=${target}.profraw;srcdir=${CMAKE_CURRENT_SOURCE_DIR}")
endif()
endfunction() endfunction()
auto_test(TCP) auto_test(TCP)
@ -89,6 +97,10 @@ if(BUILD_TOXAV)
auto_test(toxav_basic) auto_test(toxav_basic)
auto_test(toxav_many) auto_test(toxav_many)
if(MSVC)
target_link_libraries(auto_toxav_basic_test PRIVATE PkgConfig::VPX)
target_link_libraries(auto_toxav_many_test PRIVATE PkgConfig::VPX)
else()
target_link_libraries(auto_toxav_basic_test PRIVATE ${VPX_LIBRARIES}) target_link_libraries(auto_toxav_basic_test PRIVATE ${VPX_LIBRARIES})
target_link_directories(auto_toxav_basic_test PRIVATE ${VPX_LIBRARY_DIRS}) target_link_directories(auto_toxav_basic_test PRIVATE ${VPX_LIBRARY_DIRS})
target_include_directories(auto_toxav_basic_test SYSTEM PRIVATE ${VPX_INCLUDE_DIRS}) target_include_directories(auto_toxav_basic_test SYSTEM PRIVATE ${VPX_INCLUDE_DIRS})
@ -98,6 +110,7 @@ if(BUILD_TOXAV)
target_link_directories(auto_toxav_many_test PRIVATE ${VPX_LIBRARY_DIRS}) target_link_directories(auto_toxav_many_test PRIVATE ${VPX_LIBRARY_DIRS})
target_include_directories(auto_toxav_many_test SYSTEM PRIVATE ${VPX_INCLUDE_DIRS}) target_include_directories(auto_toxav_many_test SYSTEM PRIVATE ${VPX_INCLUDE_DIRS})
target_compile_options(auto_toxav_many_test PRIVATE ${VPX_CFLAGS_OTHER}) target_compile_options(auto_toxav_many_test PRIVATE ${VPX_CFLAGS_OTHER})
endif()
endif() endif()
if(PROXY_TEST) if(PROXY_TEST)

View File

@ -149,6 +149,8 @@ void set_mono_time_callback(AutoTox *autotox)
Mono_Time *mono_time = autotox->tox->mono_time; Mono_Time *mono_time = autotox->tox->mono_time;
autotox->clock = current_time_monotonic(mono_time); autotox->clock = current_time_monotonic(mono_time);
ck_assert_msg(autotox->clock >= 1000,
"clock is too low (not initialised?): %lu", (unsigned long)autotox->clock);
mono_time_set_current_time_callback(mono_time, nullptr, nullptr); // set to default first mono_time_set_current_time_callback(mono_time, nullptr, nullptr); // set to default first
mono_time_set_current_time_callback(mono_time, get_state_clock_callback, &autotox->clock); mono_time_set_current_time_callback(mono_time, get_state_clock_callback, &autotox->clock);
} }

View File

@ -395,8 +395,9 @@ static void group_message_test(AutoTox *autotoxes)
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL); iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
if (state1->peer_joined && !state1->message_sent) { if (state1->peer_joined && !state1->message_sent) {
tox_group_send_message(tox1, group_number, TOX_MESSAGE_TYPE_NORMAL, (const uint8_t *)TEST_MESSAGE, state1->pseudo_msg_id = tox_group_send_message(
TEST_MESSAGE_LEN, &state1->pseudo_msg_id, &err_send); tox1, group_number, TOX_MESSAGE_TYPE_NORMAL, (const uint8_t *)TEST_MESSAGE,
TEST_MESSAGE_LEN, &err_send);
ck_assert(err_send == TOX_ERR_GROUP_SEND_MESSAGE_OK); ck_assert(err_send == TOX_ERR_GROUP_SEND_MESSAGE_OK);
state1->message_sent = true; state1->message_sent = true;
} }
@ -419,7 +420,7 @@ static void group_message_test(AutoTox *autotoxes)
// tox1 sends group a message which should not be seen by tox0's message handler // tox1 sends group a message which should not be seen by tox0's message handler
tox_group_send_message(tox1, group_number, TOX_MESSAGE_TYPE_NORMAL, (const uint8_t *)IGNORE_MESSAGE, tox_group_send_message(tox1, group_number, TOX_MESSAGE_TYPE_NORMAL, (const uint8_t *)IGNORE_MESSAGE,
IGNORE_MESSAGE_LEN, nullptr, &err_send); IGNORE_MESSAGE_LEN, &err_send);
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL); iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
@ -506,7 +507,7 @@ static void group_message_test(AutoTox *autotoxes)
memcpy(m + 2, &checksum, sizeof(uint16_t)); memcpy(m + 2, &checksum, sizeof(uint16_t));
tox_group_send_message(tox0, group_number, TOX_MESSAGE_TYPE_NORMAL, (const uint8_t *)m, message_size, nullptr, &err_send); tox_group_send_message(tox0, group_number, TOX_MESSAGE_TYPE_NORMAL, (const uint8_t *)m, message_size, &err_send);
ck_assert(err_send == TOX_ERR_GROUP_SEND_MESSAGE_OK); ck_assert(err_send == TOX_ERR_GROUP_SEND_MESSAGE_OK);
} }
@ -528,7 +529,7 @@ static void group_message_test(AutoTox *autotoxes)
memcpy(m, &i, sizeof(uint16_t)); memcpy(m, &i, sizeof(uint16_t));
tox_group_send_message(tox0, group_number, TOX_MESSAGE_TYPE_NORMAL, (const uint8_t *)m, 2, nullptr, &err_send); tox_group_send_message(tox0, group_number, TOX_MESSAGE_TYPE_NORMAL, (const uint8_t *)m, 2, &err_send);
ck_assert(err_send == TOX_ERR_GROUP_SEND_MESSAGE_OK); ck_assert(err_send == TOX_ERR_GROUP_SEND_MESSAGE_OK);
} }

View File

@ -334,21 +334,21 @@ static void voice_state_message_test(AutoTox *autotox, Tox_Group_Voice_State voi
ck_assert(sq_err == TOX_ERR_GROUP_SELF_QUERY_OK); ck_assert(sq_err == TOX_ERR_GROUP_SELF_QUERY_OK);
Tox_Err_Group_Send_Message msg_err; Tox_Err_Group_Send_Message msg_err;
bool send_ret = tox_group_send_message(autotox->tox, state->group_number, TOX_MESSAGE_TYPE_NORMAL, tox_group_send_message(autotox->tox, state->group_number, TOX_MESSAGE_TYPE_NORMAL,
(const uint8_t *)"test", 4, nullptr, &msg_err); (const uint8_t *)"test", 4, &msg_err);
switch (self_role) { switch (self_role) {
case TOX_GROUP_ROLE_OBSERVER: { case TOX_GROUP_ROLE_OBSERVER: {
ck_assert(!send_ret && msg_err == TOX_ERR_GROUP_SEND_MESSAGE_PERMISSIONS); ck_assert(msg_err == TOX_ERR_GROUP_SEND_MESSAGE_PERMISSIONS);
break; break;
} }
case TOX_GROUP_ROLE_USER: { case TOX_GROUP_ROLE_USER: {
if (voice_state != TOX_GROUP_VOICE_STATE_ALL) { if (voice_state != TOX_GROUP_VOICE_STATE_ALL) {
ck_assert_msg(!send_ret && msg_err == TOX_ERR_GROUP_SEND_MESSAGE_PERMISSIONS, ck_assert_msg(msg_err == TOX_ERR_GROUP_SEND_MESSAGE_PERMISSIONS,
"%d, %d", send_ret, msg_err); "%d", msg_err);
} else { } else {
ck_assert(send_ret && msg_err == TOX_ERR_GROUP_SEND_MESSAGE_OK); ck_assert(msg_err == TOX_ERR_GROUP_SEND_MESSAGE_OK);
} }
break; break;
@ -356,16 +356,16 @@ static void voice_state_message_test(AutoTox *autotox, Tox_Group_Voice_State voi
case TOX_GROUP_ROLE_MODERATOR: { case TOX_GROUP_ROLE_MODERATOR: {
if (voice_state != TOX_GROUP_VOICE_STATE_FOUNDER) { if (voice_state != TOX_GROUP_VOICE_STATE_FOUNDER) {
ck_assert(send_ret && msg_err == TOX_ERR_GROUP_SEND_MESSAGE_OK); ck_assert(msg_err == TOX_ERR_GROUP_SEND_MESSAGE_OK);
} else { } else {
ck_assert(!send_ret && msg_err == TOX_ERR_GROUP_SEND_MESSAGE_PERMISSIONS); ck_assert(msg_err == TOX_ERR_GROUP_SEND_MESSAGE_PERMISSIONS);
} }
break; break;
} }
case TOX_GROUP_ROLE_FOUNDER: { case TOX_GROUP_ROLE_FOUNDER: {
ck_assert(send_ret && msg_err == TOX_ERR_GROUP_SEND_MESSAGE_OK); ck_assert(msg_err == TOX_ERR_GROUP_SEND_MESSAGE_OK);
break; break;
} }
} }

View File

@ -206,7 +206,7 @@ static void group_tcp_test(AutoTox *autotoxes)
Tox_Err_Group_Send_Message merr; Tox_Err_Group_Send_Message merr;
tox_group_send_message(autotoxes[0].tox, groupnumber, TOX_MESSAGE_TYPE_NORMAL, tox_group_send_message(autotoxes[0].tox, groupnumber, TOX_MESSAGE_TYPE_NORMAL,
(const uint8_t *)CODEWORD, CODEWORD_LEN, nullptr, &merr); (const uint8_t *)CODEWORD, CODEWORD_LEN, &merr);
ck_assert(merr == TOX_ERR_GROUP_SEND_MESSAGE_OK); ck_assert(merr == TOX_ERR_GROUP_SEND_MESSAGE_OK);
while (!state1->got_second_code) { while (!state1->got_second_code) {

View File

@ -10,6 +10,7 @@
#include "../toxcore/tox.h" #include "../toxcore/tox.h"
#include "../toxcore/tox_dispatch.h" #include "../toxcore/tox_dispatch.h"
#include "../toxcore/tox_events.h" #include "../toxcore/tox_events.h"
#include "../toxcore/tox_private.h"
#include "../toxcore/tox_unpack.h" #include "../toxcore/tox_unpack.h"
#include "auto_test_support.h" #include "auto_test_support.h"
#include "check_compat.h" #include "check_compat.h"

View File

@ -1,19 +1,26 @@
############################################################################### ###############################################################################
# #
# :: For UNIX-like systems that have pkg-config. # :: For systems that have pkg-config.
# #
############################################################################### ###############################################################################
include(ModulePackage) find_package(PkgConfig REQUIRED)
find_package(Threads REQUIRED)
find_library(NSL_LIBRARIES nsl ) find_library(NSL_LIBRARIES nsl )
find_library(RT_LIBRARIES rt ) find_library(RT_LIBRARIES rt )
find_library(SOCKET_LIBRARIES socket) find_library(SOCKET_LIBRARIES socket)
find_package(pthreads QUIET)
if(NOT TARGET PThreads4W::PThreads4W)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
endif()
# For toxcore. # For toxcore.
pkg_search_module(LIBSODIUM libsodium IMPORTED_TARGET) pkg_search_module(LIBSODIUM libsodium IMPORTED_TARGET REQUIRED)
if(MSVC)
find_package(unofficial-sodium REQUIRED)
endif()
# For toxav. # For toxav.
pkg_search_module(OPUS opus IMPORTED_TARGET) pkg_search_module(OPUS opus IMPORTED_TARGET)
@ -27,56 +34,3 @@ endif()
# For tox-bootstrapd. # For tox-bootstrapd.
pkg_search_module(LIBCONFIG libconfig IMPORTED_TARGET) pkg_search_module(LIBCONFIG libconfig IMPORTED_TARGET)
###############################################################################
#
# :: For MSVC Windows builds.
#
# These require specific installation paths of dependencies:
# - libsodium in third-party/libsodium/Win32/Release/v140/dynamic
# - pthreads in third-party/pthreads-win32/Pre-built.2
#
###############################################################################
if(MSVC)
# libsodium
# ---------
if(NOT LIBSODIUM_FOUND)
find_library(LIBSODIUM_LIBRARIES
NAMES sodium libsodium
PATHS
"third_party/libsodium/Win32/Release/v140/dynamic"
"third_party/libsodium/x64/Release/v140/dynamic"
)
if(LIBSODIUM_LIBRARIES)
include_directories("third_party/libsodium/include")
set(LIBSODIUM_FOUND TRUE)
message("libsodium: ${LIBSODIUM_LIBRARIES}")
else()
message(FATAL_ERROR "libsodium libraries not found")
endif()
endif()
# pthreads
# --------
if(CMAKE_USE_WIN32_THREADS_INIT)
find_library(CMAKE_THREAD_LIBS_INIT
NAMES pthreadVC2
PATHS
"third_party/pthreads-win32/Pre-built.2/lib/x86"
"third_party/pthreads-win32/Pre-built.2/lib/x64"
)
if(CMAKE_THREAD_LIBS_INIT)
include_directories("third_party/pthreads-win32/Pre-built.2/include")
add_definitions(-DHAVE_STRUCT_TIMESPEC)
message("libpthreads: ${CMAKE_THREAD_LIBS_INIT}")
else()
find_package(pthreads4w)
if(NOT pthreads4w_FOUND)
message(FATAL_ERROR "libpthreads libraries not found")
endif()
include_directories(${pthreads4w_INCLUDE_DIR})
link_libraries(${pthreads4w_LIBRARIES})
endif()
endif()
endif()

View File

@ -19,19 +19,17 @@ if(FULLY_STATIC)
set(ENABLE_STATIC ON) set(ENABLE_STATIC ON)
endif() endif()
find_package(PkgConfig)
function(add_module lib) function(add_module lib)
set(${lib}_SOURCES ${ARGN} PARENT_SCOPE)
if(ENABLE_SHARED) if(ENABLE_SHARED)
add_library(${lib}_shared SHARED ${ARGN}) add_library(${lib}_shared SHARED ${ARGN})
set_target_properties(${lib}_shared PROPERTIES OUTPUT_NAME ${lib}) set_target_properties(${lib}_shared PROPERTIES OUTPUT_NAME ${lib})
endif() endif()
if(ENABLE_STATIC) if(ENABLE_STATIC)
add_library(${lib}_static STATIC ${ARGN}) add_library(${lib}_static STATIC ${ARGN})
if(NOT MSVC)
set_target_properties(${lib}_static PROPERTIES OUTPUT_NAME ${lib}) set_target_properties(${lib}_static PROPERTIES OUTPUT_NAME ${lib})
endif() endif()
endif()
endfunction() endfunction()
function(install_module lib) function(install_module lib)

View File

@ -21,13 +21,11 @@ cc_binary(
"//c-toxcore/toxcore:Messenger", "//c-toxcore/toxcore:Messenger",
"//c-toxcore/toxcore:TCP_server", "//c-toxcore/toxcore:TCP_server",
"//c-toxcore/toxcore:ccompat", "//c-toxcore/toxcore:ccompat",
"//c-toxcore/toxcore:friend_requests",
"//c-toxcore/toxcore:group_onion_announce", "//c-toxcore/toxcore:group_onion_announce",
"//c-toxcore/toxcore:logger", "//c-toxcore/toxcore:logger",
"//c-toxcore/toxcore:mono_time", "//c-toxcore/toxcore:mono_time",
"//c-toxcore/toxcore:network", "//c-toxcore/toxcore:network",
"//c-toxcore/toxcore:onion_announce", "//c-toxcore/toxcore:onion_announce",
"//c-toxcore/toxcore:tox", "//c-toxcore/toxcore:tox",
"//c-toxcore/toxcore:util",
], ],
) )

View File

@ -16,12 +16,17 @@
#include "../toxcore/DHT.h" #include "../toxcore/DHT.h"
#include "../toxcore/LAN_discovery.h" #include "../toxcore/LAN_discovery.h"
#include "../toxcore/ccompat.h" #include "../toxcore/ccompat.h"
#include "../toxcore/friend_requests.h" #include "../toxcore/crypto_core.h"
#include "../toxcore/forwarding.h"
#include "../toxcore/group_announce.h"
#include "../toxcore/group_onion_announce.h" #include "../toxcore/group_onion_announce.h"
#include "../toxcore/logger.h" #include "../toxcore/logger.h"
#include "../toxcore/mem.h"
#include "../toxcore/mono_time.h" #include "../toxcore/mono_time.h"
#include "../toxcore/network.h"
#include "../toxcore/onion.h"
#include "../toxcore/onion_announce.h"
#include "../toxcore/tox.h" #include "../toxcore/tox.h"
#include "../toxcore/util.h"
#define TCP_RELAY_ENABLED #define TCP_RELAY_ENABLED
@ -46,7 +51,7 @@ static const char *motd_str = ""; //Change this to anything within 256 bytes(but
#define PORT 33445 #define PORT 33445
static void manage_keys(DHT *dht) static bool manage_keys(DHT *dht)
{ {
enum { KEYS_SIZE = CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_SECRET_KEY_SIZE }; enum { KEYS_SIZE = CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_SECRET_KEY_SIZE };
uint8_t keys[KEYS_SIZE]; uint8_t keys[KEYS_SIZE];
@ -60,7 +65,8 @@ static void manage_keys(DHT *dht)
if (read_size != KEYS_SIZE) { if (read_size != KEYS_SIZE) {
printf("Error while reading the key file\nExiting.\n"); printf("Error while reading the key file\nExiting.\n");
exit(1); fclose(keys_file);
return false;
} }
dht_set_self_public_key(dht, keys); dht_set_self_public_key(dht, keys);
@ -73,18 +79,20 @@ static void manage_keys(DHT *dht)
if (keys_file == nullptr) { if (keys_file == nullptr) {
printf("Error opening key file in write mode.\nKeys will not be saved.\n"); printf("Error opening key file in write mode.\nKeys will not be saved.\n");
return; return false;
} }
if (fwrite(keys, sizeof(uint8_t), KEYS_SIZE, keys_file) != KEYS_SIZE) { if (fwrite(keys, sizeof(uint8_t), KEYS_SIZE, keys_file) != KEYS_SIZE) {
printf("Error while writing the key file.\nExiting.\n"); printf("Error while writing the key file.\nExiting.\n");
exit(1); fclose(keys_file);
return false;
} }
printf("Keys saved successfully.\n"); printf("Keys saved successfully.\n");
} }
fclose(keys_file); fclose(keys_file);
return true;
} }
static const char *strlevel(Logger_Level level) static const char *strlevel(Logger_Level level)
@ -121,7 +129,7 @@ int main(int argc, char *argv[])
if (argc == 2 && !tox_strncasecmp(argv[1], "-h", 3)) { if (argc == 2 && !tox_strncasecmp(argv[1], "-h", 3)) {
printf("Usage (connected) : %s [--ipv4|--ipv6] IP PORT KEY\n", argv[0]); printf("Usage (connected) : %s [--ipv4|--ipv6] IP PORT KEY\n", argv[0]);
printf("Usage (unconnected): %s [--ipv4|--ipv6]\n", argv[0]); printf("Usage (unconnected): %s [--ipv4|--ipv6]\n", argv[0]);
exit(0); return 0;
} }
/* let user override default by cmdline */ /* let user override default by cmdline */
@ -129,7 +137,7 @@ int main(int argc, char *argv[])
int argvoffset = cmdline_parsefor_ipv46(argc, argv, &ipv6enabled); int argvoffset = cmdline_parsefor_ipv46(argc, argv, &ipv6enabled);
if (argvoffset < 0) { if (argvoffset < 0) {
exit(1); return 1;
} }
/* Initialize networking - /* Initialize networking -
@ -162,14 +170,16 @@ int main(int argc, char *argv[])
if (!(onion && forwarding && onion_a)) { if (!(onion && forwarding && onion_a)) {
printf("Something failed to initialize.\n"); printf("Something failed to initialize.\n");
exit(1); return 1;
} }
gca_onion_init(gc_announces_list, onion_a); gca_onion_init(gc_announces_list, onion_a);
perror("Initialization"); perror("Initialization");
manage_keys(dht); if (!manage_keys(dht)) {
return 1;
}
printf("Public key: "); printf("Public key: ");
#ifdef TCP_RELAY_ENABLED #ifdef TCP_RELAY_ENABLED
@ -179,7 +189,7 @@ int main(int argc, char *argv[])
if (tcp_s == nullptr) { if (tcp_s == nullptr) {
printf("TCP server failed to initialize.\n"); printf("TCP server failed to initialize.\n");
exit(1); return 1;
} }
#endif #endif
@ -189,7 +199,7 @@ int main(int argc, char *argv[])
if (file == nullptr) { if (file == nullptr) {
printf("Could not open file \"%s\" for writing. Exiting...\n", public_id_filename); printf("Could not open file \"%s\" for writing. Exiting...\n", public_id_filename);
exit(1); return 1;
} }
for (uint32_t i = 0; i < 32; ++i) { for (uint32_t i = 0; i < 32; ++i) {
@ -210,7 +220,7 @@ int main(int argc, char *argv[])
if (port_conv <= 0 || port_conv > UINT16_MAX) { if (port_conv <= 0 || port_conv > UINT16_MAX) {
printf("Failed to convert \"%s\" into a valid port. Exiting...\n", argv[argvoffset + 2]); printf("Failed to convert \"%s\" into a valid port. Exiting...\n", argv[argvoffset + 2]);
exit(1); return 1;
} }
const uint16_t port = net_htons((uint16_t)port_conv); const uint16_t port = net_htons((uint16_t)port_conv);
@ -222,7 +232,7 @@ int main(int argc, char *argv[])
if (!res) { if (!res) {
printf("Failed to convert \"%s\" into an IP address. Exiting...\n", argv[argvoffset + 1]); printf("Failed to convert \"%s\" into an IP address. Exiting...\n", argv[argvoffset + 1]);
exit(1); return 1;
} }
} }

View File

@ -1,6 +1,64 @@
#!/bin/bash #!/usr/bin/env bash
CHECKS="*" CHECKS="*"
ERRORS="*"
# Need to investigate or disable and document these.
# =========================================================
# TODO(iphydf): Fix these.
ERRORS="$ERRORS,-cert-err34-c"
ERRORS="$ERRORS,-readability-suspicious-call-argument"
# TODO(iphydf): Fix once cimple 0.0.19 is released.
CHECKS="$CHECKS,-google-readability-casting"
# TODO(iphydf): Fix these.
CHECKS="$CHECKS,-bugprone-switch-missing-default-case"
# TODO(iphydf): We might want some of these. For the ones we don't want, add a
# comment explaining why not.
CHECKS="$CHECKS,-clang-analyzer-optin.performance.Padding"
CHECKS="$CHECKS,-hicpp-signed-bitwise"
# TODO(iphydf): Maybe fix these?
CHECKS="$CHECKS,-bugprone-implicit-widening-of-multiplication-result"
CHECKS="$CHECKS,-bugprone-integer-division"
CHECKS="$CHECKS,-misc-no-recursion"
# TODO(iphydf): Only happens in bootstrap_daemon. Fix it.
CHECKS="$CHECKS,-cppcoreguidelines-avoid-non-const-global-variables"
# TODO(iphydf): Probably fix these.
CHECKS="$CHECKS,-cert-err33-c"
CHECKS="$CHECKS,-cppcoreguidelines-avoid-magic-numbers"
CHECKS="$CHECKS,-readability-magic-numbers"
# TODO(iphydf): We're using a lot of macros for constants. Should we convert
# all of them to enum?
CHECKS="$CHECKS,-modernize-macro-to-enum"
# Documented disabled checks. We don't want these for sure.
# =========================================================
# https://stackoverflow.com/questions/58672959/why-does-clang-tidy-say-vsnprintf-has-an-uninitialized-va-list-argument
CHECKS="$CHECKS,-clang-analyzer-valist.Uninitialized"
# We pass a lot of ints around, so many function parameters are some kind of
# int type that can be converted from another int type. We won't be getting
# away from that anytime soon.
CHECKS="$CHECKS,-bugprone-easily-swappable-parameters"
# Callback handlers often don't use all their parameters. There's
# IgnoreVirtual, but that doesn't work for C-style callbacks.
CHECKS="$CHECKS,-misc-unused-parameters"
# We sometimes use #if 0.
CHECKS="$CHECKS,-readability-avoid-unconditional-preprocessor-if"
# We have better macro hygiene checks with tokstyle. We can never pass macro
# arguments that require parentheses inside the macro.
CHECKS="$CHECKS,-bugprone-macro-parentheses"
# We don't use memcpy_s. # We don't use memcpy_s.
CHECKS="$CHECKS,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling" CHECKS="$CHECKS,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling"
@ -81,62 +139,48 @@ CHECKS="$CHECKS,-cert-dcl03-c"
CHECKS="$CHECKS,-hicpp-static-assert" CHECKS="$CHECKS,-hicpp-static-assert"
CHECKS="$CHECKS,-misc-static-assert" CHECKS="$CHECKS,-misc-static-assert"
# TODO(iphydf): We might want some of these. For the ones we don't want, add a
# comment explaining why not.
CHECKS="$CHECKS,-clang-analyzer-optin.performance.Padding"
CHECKS="$CHECKS,-hicpp-signed-bitwise"
CHECKS="$CHECKS,-misc-unused-parameters"
CHECKS="$CHECKS,-readability-function-cognitive-complexity"
# TODO(iphydf): Maybe fix these?
CHECKS="$CHECKS,-bugprone-easily-swappable-parameters"
CHECKS="$CHECKS,-bugprone-implicit-widening-of-multiplication-result"
CHECKS="$CHECKS,-bugprone-integer-division"
CHECKS="$CHECKS,-clang-analyzer-core.NullDereference"
CHECKS="$CHECKS,-clang-analyzer-valist.Uninitialized"
CHECKS="$CHECKS,-concurrency-mt-unsafe"
CHECKS="$CHECKS,-cppcoreguidelines-avoid-non-const-global-variables"
CHECKS="$CHECKS,-misc-no-recursion"
# TODO(iphydf): Probably fix these.
CHECKS="$CHECKS,-cert-err33-c"
CHECKS="$CHECKS,-cppcoreguidelines-avoid-magic-numbers"
CHECKS="$CHECKS,-google-readability-casting"
CHECKS="$CHECKS,-modernize-macro-to-enum"
CHECKS="$CHECKS,-readability-magic-numbers"
# TODO(iphydf): These two trip on list.c. Investigate why.
CHECKS="$CHECKS,-clang-analyzer-core.NonNullParamChecker"
CHECKS="$CHECKS,-clang-analyzer-unix.Malloc"
ERRORS="*"
# TODO(iphydf): Fix these.
ERRORS="$ERRORS,-bugprone-macro-parentheses"
ERRORS="$ERRORS,-cert-err34-c"
ERRORS="$ERRORS,-cert-str34-c"
ERRORS="$ERRORS,-readability-suspicious-call-argument"
set -eux set -eux
# TODO(iphydf): Add toxav.
DIRS=(
other/bootstrap_daemon/src
other
toxcore
toxcore/events
toxencryptsave
)
copy_files() {
find "${DIRS[@]}" \
-maxdepth 1 -type d -exec mkdir -p "$1/{}" \;
find "${DIRS[@]}" \
-maxdepth 1 -name "*.c" -exec cp "{}" "$1/{}" \;
}
run() { run() {
echo "Running clang-tidy in variant '$*'" echo "Running clang-tidy in variant '$*'"
EXTRA_ARGS=("$@") EXTRA_ARGS=("$@")
for i in "${!EXTRA_ARGS[@]}"; do for i in "${!EXTRA_ARGS[@]}"; do
EXTRA_ARGS[$i]="--extra-arg=${EXTRA_ARGS[$i]}" EXTRA_ARGS[$i]="--extra-arg=${EXTRA_ARGS[$i]}"
done done
clang-tidy-14 \ ls .clang-tidy
-p=_build \ copy_files a
if ! find "${DIRS[@]}" \
-maxdepth 1 -name "*.c" -print0 \
| xargs -0 -n15 -P"$(nproc)" clang-tidy \
-p="$PWD/_build" \
--extra-arg=-DMIN_LOGGER_LEVEL=LOGGER_LEVEL_TRACE \ --extra-arg=-DMIN_LOGGER_LEVEL=LOGGER_LEVEL_TRACE \
"${EXTRA_ARGS[@]}" \ "${EXTRA_ARGS[@]}" \
--fix \
--checks="$CHECKS" \ --checks="$CHECKS" \
--warnings-as-errors="$ERRORS" \ --warnings-as-errors="$ERRORS" \
--use-color \ --use-color; then
other/bootstrap_daemon/src/*.c \ copy_files b
other/*.c \ colordiff -ru a b
toxav/*.c \ rm -rf a b
toxcore/*.c \ false
toxencryptsave/*.c fi
rm -rf a
} }
cmake . -B_build -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON cmake . -B_build -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON

View File

@ -16,7 +16,6 @@
--align-reference=name --align-reference=name
# Formatting Options # Formatting Options
--add-brackets
--convert-tabs --convert-tabs
--max-code-length=120 --max-code-length=120

View File

@ -18,7 +18,6 @@ cc_binary(
"//c-toxcore/toxcore:mono_time", "//c-toxcore/toxcore:mono_time",
"//c-toxcore/toxcore:onion_announce", "//c-toxcore/toxcore:onion_announce",
"//c-toxcore/toxcore:tox", "//c-toxcore/toxcore:tox",
"//c-toxcore/toxcore:util",
"@libconfig", "@libconfig",
], ],
) )

View File

@ -259,7 +259,7 @@ docker run -d --name tox-bootstrapd --restart always \
toxchat/bootstrap-node toxchat/bootstrap-node
``` ```
We create a new user and protect its home directory in order to mount it in the Docker image, so that the kyepair the daemon uses would be stored on the host system, which makes it less likely that you would loose the keypair while playing with or updating the Docker container. We create a new user and protect its home directory in order to mount it in the Docker image, so that the keypair the daemon uses would be stored on the host system, which makes it less likely that you would loose the keypair while playing with or updating the Docker container.
You can check logs for your public key or any errors: You can check logs for your public key or any errors:
```sh ```sh

View File

@ -12,8 +12,7 @@ RUN ["apk", "--no-cache", "add",\
"libsodium-static",\ "libsodium-static",\
"musl-dev",\ "musl-dev",\
"ninja",\ "ninja",\
"python3"\ "python3"]
]
WORKDIR /src/c-toxcore WORKDIR /src/c-toxcore
@ -49,8 +48,10 @@ RUN CC=clang cmake -B_build -H. \
# Verify checksum from dev-built binary, so we can be sure Docker Hub doesn't # Verify checksum from dev-built binary, so we can be sure Docker Hub doesn't
# mess with your binaries. # mess with your binaries.
COPY other/bootstrap_daemon/docker/tox-bootstrapd.sha256 other/bootstrap_daemon/docker/ COPY other/bootstrap_daemon/docker/tox-bootstrapd.sha256 other/bootstrap_daemon/docker/
RUN sha256sum /usr/local/bin/tox-bootstrapd && \ RUN SHA256="$(sha256sum /usr/local/bin/tox-bootstrapd)" && \
sha256sum -c other/bootstrap_daemon/docker/tox-bootstrapd.sha256 (sha256sum -c other/bootstrap_daemon/docker/tox-bootstrapd.sha256 || \
(echo "::error file=other/bootstrap_daemon/docker/tox-bootstrapd.sha256,line=1::$SHA256" && \
false))
# Remove all the example bootstrap nodes from the config file. # Remove all the example bootstrap nodes from the config file.
COPY other/bootstrap_daemon/tox-bootstrapd.conf other/bootstrap_daemon/ COPY other/bootstrap_daemon/tox-bootstrapd.conf other/bootstrap_daemon/

View File

@ -0,0 +1,46 @@
#!/usr/bin/env python3
import json
import os
import pprint
import subprocess
import sys
import urllib.request
from typing import Any
SHA256_FILE = "other/bootstrap_daemon/docker/tox-bootstrapd.sha256"
with open(f"{os.environ['HOME']}/.github-token") as fh:
token = fh.read().strip()
head_sha = (subprocess.run(["git", "rev-parse", "HEAD"],
capture_output=True,
check=True).stdout.decode("utf-8").strip())
def request(url: str) -> Any:
return json.loads(
urllib.request.urlopen(
urllib.request.Request(
url,
headers={
"Accept": "application/vnd.github+json",
"Authorization": "Bearer " + token,
"X-GitHub-Api-Version": "2022-11-28",
},
)).read())
pp = pprint.PrettyPrinter(indent=2, compact=True)
annots = [
a for r in request(
f"https://api.github.com/repos/TokTok/c-toxcore/commits/{head_sha}/check-runs?per_page=100"
)["check_runs"] if r["name"] == "docker-bootstrap-node"
for a in request(r["output"]["annotations_url"])
if a["path"] == SHA256_FILE
]
if not annots:
print("could not find sha256sum output")
sys.exit(1)
with open(SHA256_FILE, "w") as fh:
fh.write(annots[0]["message"] + "\n")
print(f"updated {SHA256_FILE}")

View File

@ -1 +1 @@
b0bd5099f2f77fbd540a5a929a23cece39ff95e3a66702a5381342d01775cbd3 /usr/local/bin/tox-bootstrapd 8fadc6fd894bb8f60fd53d51dcd51ff24e62b41ae404d3921e0247b9337c9a30 /usr/local/bin/tox-bootstrapd

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later /* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2016-2018 The TokTok team. * Copyright © 2016-2024 The TokTok team.
* Copyright © 2015-2016 Tox project. * Copyright © 2015-2016 Tox project.
*/ */
@ -10,12 +10,12 @@
#include "command_line_arguments.h" #include "command_line_arguments.h"
#include "global.h" #include "global.h"
#include "log.h"
#include "../../../toxcore/ccompat.h" #include "../../../toxcore/ccompat.h"
#include <getopt.h> #include <getopt.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
@ -24,9 +24,9 @@
*/ */
static void print_help(void) static void print_help(void)
{ {
// 2 space ident // 2 space indent
// make sure all lines fit into 80 columns // Make sure all lines fit into 80 columns
// make sure options are listed in alphabetical order // Make sure options are listed in alphabetical order
log_write(LOG_LEVEL_INFO, log_write(LOG_LEVEL_INFO,
"Usage: tox-bootstrapd [OPTION]... --config=FILE_PATH\n" "Usage: tox-bootstrapd [OPTION]... --config=FILE_PATH\n"
"\n" "\n"
@ -39,7 +39,7 @@ static void print_help(void)
" (detach from the terminal) and won't use the PID file.\n" " (detach from the terminal) and won't use the PID file.\n"
" --help Print this help message.\n" " --help Print this help message.\n"
" --log-backend=BACKEND Specify which logging backend to use.\n" " --log-backend=BACKEND Specify which logging backend to use.\n"
" Valid BACKEND values (case sensetive):\n" " Valid BACKEND values (case sensitive):\n"
" syslog Writes log messages to syslog.\n" " syslog Writes log messages to syslog.\n"
" Default option when no --log-backend is\n" " Default option when no --log-backend is\n"
" specified.\n" " specified.\n"
@ -47,13 +47,14 @@ static void print_help(void)
" --version Print version information.\n"); " --version Print version information.\n");
} }
void handle_command_line_arguments(int argc, char *argv[], char **cfg_file_path, LOG_BACKEND *log_backend, Cli_Status handle_command_line_arguments(
int argc, char *argv[], char **cfg_file_path, LOG_BACKEND *log_backend,
bool *run_in_foreground) bool *run_in_foreground)
{ {
if (argc < 2) { if (argc < 2) {
log_write(LOG_LEVEL_ERROR, "Error: No arguments provided.\n\n"); log_write(LOG_LEVEL_ERROR, "Error: No arguments provided.\n\n");
print_help(); print_help();
exit(1); return CLI_STATUS_ERROR;
} }
opterr = 0; opterr = 0;
@ -89,7 +90,7 @@ void handle_command_line_arguments(int argc, char *argv[], char **cfg_file_path,
case 'h': case 'h':
print_help(); print_help();
exit(0); return CLI_STATUS_DONE;
case 'l': case 'l':
if (strcmp(optarg, "syslog") == 0) { if (strcmp(optarg, "syslog") == 0) {
@ -101,24 +102,24 @@ void handle_command_line_arguments(int argc, char *argv[], char **cfg_file_path,
} else { } else {
log_write(LOG_LEVEL_ERROR, "Error: Invalid BACKEND value for --log-backend option passed: %s\n\n", optarg); log_write(LOG_LEVEL_ERROR, "Error: Invalid BACKEND value for --log-backend option passed: %s\n\n", optarg);
print_help(); print_help();
exit(1); return CLI_STATUS_ERROR;
} }
break; break;
case 'v': case 'v':
log_write(LOG_LEVEL_INFO, "Version: %lu\n", DAEMON_VERSION_NUMBER); log_write(LOG_LEVEL_INFO, "Version: %lu\n", DAEMON_VERSION_NUMBER);
exit(0); return CLI_STATUS_DONE;
case '?': case '?':
log_write(LOG_LEVEL_ERROR, "Error: Unrecognized option %s\n\n", argv[optind - 1]); log_write(LOG_LEVEL_ERROR, "Error: Unrecognized option %s\n\n", argv[optind - 1]);
print_help(); print_help();
exit(1); return CLI_STATUS_ERROR;
case ':': case ':':
log_write(LOG_LEVEL_ERROR, "Error: No argument provided for option %s\n\n", argv[optind - 1]); log_write(LOG_LEVEL_ERROR, "Error: No argument provided for option %s\n\n", argv[optind - 1]);
print_help(); print_help();
exit(1); return CLI_STATUS_ERROR;
} }
} }
@ -129,6 +130,8 @@ void handle_command_line_arguments(int argc, char *argv[], char **cfg_file_path,
if (!cfg_file_path_set) { if (!cfg_file_path_set) {
log_write(LOG_LEVEL_ERROR, "Error: The required --config option wasn't specified\n\n"); log_write(LOG_LEVEL_ERROR, "Error: The required --config option wasn't specified\n\n");
print_help(); print_help();
exit(1); return CLI_STATUS_ERROR;
} }
return CLI_STATUS_OK;
} }

View File

@ -12,6 +12,15 @@
#include "log.h" #include "log.h"
typedef enum Cli_Status {
/** Continue the program. Command line processing completed. */
CLI_STATUS_OK,
/** Stop the program with success status. */
CLI_STATUS_DONE,
/** Stop the program with error status. */
CLI_STATUS_ERROR,
} Cli_Status;
/** /**
* Handles command line arguments, setting cfg_file_path and log_backend. * Handles command line arguments, setting cfg_file_path and log_backend.
* Terminates the application if incorrect arguments are specified. * Terminates the application if incorrect arguments are specified.
@ -22,7 +31,8 @@
* @param log_backend Sets to the provided by the user log backend option. * @param log_backend Sets to the provided by the user log backend option.
* @param run_in_foreground Sets to the provided by the user foreground option. * @param run_in_foreground Sets to the provided by the user foreground option.
*/ */
void handle_command_line_arguments(int argc, char *argv[], char **cfg_file_path, LOG_BACKEND *log_backend, Cli_Status handle_command_line_arguments(
int argc, char *argv[], char **cfg_file_path, LOG_BACKEND *log_backend,
bool *run_in_foreground); bool *run_in_foreground);
#endif // C_TOXCORE_OTHER_BOOTSTRAP_DAEMON_SRC_COMMAND_LINE_ARGUMENTS_H #endif // C_TOXCORE_OTHER_BOOTSTRAP_DAEMON_SRC_COMMAND_LINE_ARGUMENTS_H

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later /* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2016-2023 The TokTok team. * Copyright © 2016-2024 The TokTok team.
* Copyright © 2014-2016 Tox project. * Copyright © 2014-2016 Tox project.
*/ */
@ -10,6 +10,7 @@
#include "config.h" #include "config.h"
#include "config_defaults.h" #include "config_defaults.h"
#include "global.h"
#include "log.h" #include "log.h"
#include <stdio.h> #include <stdio.h>
@ -18,6 +19,10 @@
#include <libconfig.h> #include <libconfig.h>
#include "../../../toxcore/DHT.h"
#include "../../../toxcore/ccompat.h"
#include "../../../toxcore/crypto_core.h"
#include "../../../toxcore/network.h"
#include "../../bootstrap_node_packets.h" #include "../../bootstrap_node_packets.h"
/** /**
@ -51,7 +56,7 @@ static void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_por
log_write(LOG_LEVEL_INFO, "Port #%zu: %u\n", i, default_ports[i]); log_write(LOG_LEVEL_INFO, "Port #%zu: %u\n", i, default_ports[i]);
} }
// similar procedure to the one of reading config file below // Similar procedure to the one of reading config file below
*tcp_relay_ports = (uint16_t *)malloc(default_ports_count * sizeof(uint16_t)); *tcp_relay_ports = (uint16_t *)malloc(default_ports_count * sizeof(uint16_t));
for (size_t i = 0; i < default_ports_count; ++i) { for (size_t i = 0; i < default_ports_count; ++i) {
@ -68,7 +73,7 @@ static void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_por
++*tcp_relay_port_count; ++*tcp_relay_port_count;
} }
// the loop above skips invalid ports, so we adjust the allocated memory size // The loop above skips invalid ports, so we adjust the allocated memory size
if ((*tcp_relay_port_count) > 0) { if ((*tcp_relay_port_count) > 0) {
*tcp_relay_ports = (uint16_t *)realloc(*tcp_relay_ports, (*tcp_relay_port_count) * sizeof(uint16_t)); *tcp_relay_ports = (uint16_t *)realloc(*tcp_relay_ports, (*tcp_relay_port_count) * sizeof(uint16_t));
} else { } else {
@ -98,7 +103,7 @@ static void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_por
config_setting_t *elem = config_setting_get_elem(ports_array, i); config_setting_t *elem = config_setting_get_elem(ports_array, i);
if (elem == nullptr) { if (elem == nullptr) {
// it's NULL if `ports_array` is not an array (we have that check earlier) or if `i` is out of range, which should not be // It's NULL if `ports_array` is not an array (we have that check earlier) or if `i` is out of range, which should not be
log_write(LOG_LEVEL_WARNING, "Port #%d: Something went wrong while parsing the port. Stopping reading ports.\n", i); log_write(LOG_LEVEL_WARNING, "Port #%d: Something went wrong while parsing the port. Stopping reading ports.\n", i);
break; break;
} }
@ -120,7 +125,7 @@ static void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_por
++*tcp_relay_port_count; ++*tcp_relay_port_count;
} }
// the loop above skips invalid ports, so we adjust the allocated memory size // The loop above skips invalid ports, so we adjust the allocated memory size
if ((*tcp_relay_port_count) > 0) { if ((*tcp_relay_port_count) > 0) {
*tcp_relay_ports = (uint16_t *)realloc(*tcp_relay_ports, (*tcp_relay_port_count) * sizeof(uint16_t)); *tcp_relay_ports = (uint16_t *)realloc(*tcp_relay_ports, (*tcp_relay_port_count) * sizeof(uint16_t));
} else { } else {
@ -260,7 +265,7 @@ int get_general_config(const char *cfg_file_path, char **pid_file_path, char **k
log_write(LOG_LEVEL_INFO, "'%s': %s\n", NAME_ENABLE_TCP_RELAY, *enable_tcp_relay ? "true" : "false"); log_write(LOG_LEVEL_INFO, "'%s': %s\n", NAME_ENABLE_TCP_RELAY, *enable_tcp_relay ? "true" : "false");
// show info about tcp ports only if tcp relay is enabled // Show info about tcp ports only if tcp relay is enabled
if (*enable_tcp_relay) { if (*enable_tcp_relay) {
if (*tcp_relay_port_count == 0) { if (*tcp_relay_port_count == 0) {
log_write(LOG_LEVEL_ERROR, "No TCP ports could be read.\n"); log_write(LOG_LEVEL_ERROR, "No TCP ports could be read.\n");
@ -407,7 +412,7 @@ int bootstrap_from_config(const char *cfg_file_path, DHT *dht, int enable_ipv6)
log_write(LOG_LEVEL_INFO, "Successfully added bootstrap node #%d: %s:%d %s\n", i, bs_address, bs_port, bs_public_key); log_write(LOG_LEVEL_INFO, "Successfully added bootstrap node #%d: %s:%d %s\n", i, bs_address, bs_port, bs_public_key);
next: next:
// config_setting_lookup_string() allocates string inside and doesn't allow us to free it direcly // config_setting_lookup_string() allocates string inside and doesn't allow us to free it directly
// though it's freed when the element is removed, so we free it right away in order to keep memory // though it's freed when the element is removed, so we free it right away in order to keep memory
// consumption minimal // consumption minimal
config_setting_remove_elem(node_list, 0); config_setting_remove_elem(node_list, 0);

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later /* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2016-2018 The TokTok team. * Copyright © 2016-2024 The TokTok team.
* Copyright © 2014-2016 Tox project. * Copyright © 2014-2016 Tox project.
*/ */
@ -30,7 +30,7 @@ int get_general_config(const char *cfg_file_path, char **pid_file_path, char **k
* Bootstraps off nodes listed in the config file. * Bootstraps off nodes listed in the config file.
* *
* @return 1 on success, some or no bootstrap nodes were added * @return 1 on success, some or no bootstrap nodes were added
* 0 on failure, a error accured while parsing config file. * 0 on failure, an error occurred while parsing the config file.
*/ */
int bootstrap_from_config(const char *cfg_file_path, DHT *dht, int enable_ipv6); int bootstrap_from_config(const char *cfg_file_path, DHT *dht, int enable_ipv6);

View File

@ -3,6 +3,8 @@
* Copyright © 2015-2016 Tox project. * Copyright © 2015-2016 Tox project.
*/ */
#include <stdarg.h>
/* /*
* Tox DHT bootstrap daemon. * Tox DHT bootstrap daemon.
* Logging utility with support of multiple logging backends. * Logging utility with support of multiple logging backends.

View File

@ -9,8 +9,11 @@
*/ */
#include "log_backend_stdout.h" #include "log_backend_stdout.h"
#include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include "log.h"
static FILE *log_backend_stdout_level(LOG_LEVEL level) static FILE *log_backend_stdout_level(LOG_LEVEL level)
{ {
switch (level) { switch (level) {

View File

@ -10,10 +10,12 @@
#include "log_backend_syslog.h" #include "log_backend_syslog.h"
#include "global.h" #include "global.h"
#include "log.h"
#include "../../../toxcore/ccompat.h" #include "../../../toxcore/ccompat.h"
#include <assert.h> #include <assert.h>
#include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <syslog.h> #include <syslog.h>

View File

@ -23,17 +23,24 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h>
// toxcore // toxcore
#include "../../../toxcore/tox.h" #include "../../../toxcore/DHT.h"
#include "../../../toxcore/LAN_discovery.h" #include "../../../toxcore/LAN_discovery.h"
#include "../../../toxcore/TCP_server.h" #include "../../../toxcore/TCP_server.h"
#include "../../../toxcore/announce.h" #include "../../../toxcore/announce.h"
#include "../../../toxcore/ccompat.h"
#include "../../../toxcore/crypto_core.h"
#include "../../../toxcore/forwarding.h"
#include "../../../toxcore/group_announce.h"
#include "../../../toxcore/group_onion_announce.h" #include "../../../toxcore/group_onion_announce.h"
#include "../../../toxcore/logger.h" #include "../../../toxcore/logger.h"
#include "../../../toxcore/mem.h"
#include "../../../toxcore/mono_time.h" #include "../../../toxcore/mono_time.h"
#include "../../../toxcore/network.h"
#include "../../../toxcore/onion.h"
#include "../../../toxcore/onion_announce.h" #include "../../../toxcore/onion_announce.h"
#include "../../../toxcore/util.h"
// misc // misc
#include "../../bootstrap_node_packets.h" #include "../../bootstrap_node_packets.h"
@ -116,7 +123,7 @@ static void print_public_key(const uint8_t *public_key)
// Demonizes the process, appending PID to the PID file and closing file descriptors based on log backend // Demonizes the process, appending PID to the PID file and closing file descriptors based on log backend
// Terminates the application if the daemonization fails. // Terminates the application if the daemonization fails.
static void daemonize(LOG_BACKEND log_backend, char *pid_file_path) static Cli_Status daemonize(LOG_BACKEND log_backend, char *pid_file_path)
{ {
// Check if the PID file exists // Check if the PID file exists
FILE *pid_file = fopen(pid_file_path, "r"); FILE *pid_file = fopen(pid_file_path, "r");
@ -131,7 +138,7 @@ static void daemonize(LOG_BACKEND log_backend, char *pid_file_path)
if (pid_file == nullptr) { if (pid_file == nullptr) {
log_write(LOG_LEVEL_ERROR, "Couldn't open the PID file for writing: %s. Exiting.\n", pid_file_path); log_write(LOG_LEVEL_ERROR, "Couldn't open the PID file for writing: %s. Exiting.\n", pid_file_path);
exit(1); return CLI_STATUS_ERROR;
} }
// Fork off from the parent process // Fork off from the parent process
@ -141,27 +148,27 @@ static void daemonize(LOG_BACKEND log_backend, char *pid_file_path)
fprintf(pid_file, "%d", pid); fprintf(pid_file, "%d", pid);
fclose(pid_file); fclose(pid_file);
log_write(LOG_LEVEL_INFO, "Forked successfully: PID: %d.\n", pid); log_write(LOG_LEVEL_INFO, "Forked successfully: PID: %d.\n", pid);
exit(0); return CLI_STATUS_DONE;
} else { } else {
fclose(pid_file); fclose(pid_file);
} }
if (pid < 0) { if (pid < 0) {
log_write(LOG_LEVEL_ERROR, "Forking failed. Exiting.\n"); log_write(LOG_LEVEL_ERROR, "Forking failed. Exiting.\n");
exit(1); return CLI_STATUS_ERROR;
} }
// Create a new SID for the child process // Create a new SID for the child process
if (setsid() < 0) { if (setsid() < 0) {
log_write(LOG_LEVEL_ERROR, "SID creation failure. Exiting.\n"); log_write(LOG_LEVEL_ERROR, "SID creation failure. Exiting.\n");
exit(1); return CLI_STATUS_ERROR;
} }
// Change the current working directory // Change the current working directory
if ((chdir("/")) < 0) { if ((chdir("/")) < 0) {
log_write(LOG_LEVEL_ERROR, "Couldn't change working directory to '/'. Exiting.\n"); log_write(LOG_LEVEL_ERROR, "Couldn't change working directory to '/'. Exiting.\n");
exit(1); return CLI_STATUS_ERROR;
} }
// Go quiet // Go quiet
@ -170,6 +177,8 @@ static void daemonize(LOG_BACKEND log_backend, char *pid_file_path)
close(STDIN_FILENO); close(STDIN_FILENO);
close(STDERR_FILENO); close(STDERR_FILENO);
} }
return CLI_STATUS_OK;
} }
// Logs toxcore logger message using our logger facility // Logs toxcore logger message using our logger facility
@ -212,11 +221,18 @@ int main(int argc, char *argv[])
char *cfg_file_path = nullptr; char *cfg_file_path = nullptr;
bool run_in_foreground = false; bool run_in_foreground = false;
// choose backend for printing command line argument parsing output based on whether the daemon is being run from a terminal // Choose backend for printing command line argument parsing output based on whether the daemon is being run from a terminal
LOG_BACKEND log_backend = isatty(STDOUT_FILENO) ? LOG_BACKEND_STDOUT : LOG_BACKEND_SYSLOG; LOG_BACKEND log_backend = isatty(STDOUT_FILENO) ? LOG_BACKEND_STDOUT : LOG_BACKEND_SYSLOG;
log_open(log_backend); log_open(log_backend);
handle_command_line_arguments(argc, argv, &cfg_file_path, &log_backend, &run_in_foreground); switch (handle_command_line_arguments(argc, argv, &cfg_file_path, &log_backend, &run_in_foreground)) {
case CLI_STATUS_OK:
break;
case CLI_STATUS_DONE:
return 0;
case CLI_STATUS_ERROR:
return 1;
}
log_close(); log_close();
log_open(log_backend); log_open(log_backend);
@ -254,7 +270,14 @@ int main(int argc, char *argv[])
} }
if (!run_in_foreground) { if (!run_in_foreground) {
daemonize(log_backend, pid_file_path); switch (daemonize(log_backend, pid_file_path)) {
case CLI_STATUS_OK:
break;
case CLI_STATUS_DONE:
return 0;
case CLI_STATUS_ERROR:
return 1;
}
} }
free(pid_file_path); free(pid_file_path);

View File

@ -12,6 +12,8 @@
#include <string.h> #include <string.h>
#include "../toxcore/network.h"
#define INFO_REQUEST_PACKET_LENGTH 78 #define INFO_REQUEST_PACKET_LENGTH 78
static uint32_t bootstrap_version; static uint32_t bootstrap_version;

View File

@ -2,7 +2,8 @@
# autotools-linux # autotools-linux
FROM ubuntu:22.04 FROM ubuntu:22.04
RUN apt-get update && apt-get install --no-install-recommends -y \ RUN apt-get update && \
DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \
autoconf \ autoconf \
automake \ automake \
ca-certificates \ ca-certificates \

View File

@ -0,0 +1,21 @@
FROM alpine:3.19.0
RUN ["apk", "add", "--no-cache", \
"bash", \
"clang", \
"clang-extra-tools", \
"cmake", \
"colordiff", \
"libconfig-dev", \
"libsodium-dev", \
"libvpx-dev", \
"linux-headers", \
"opus-dev", \
"pkgconfig", \
"samurai"]
ENV CC=clang CXX=clang++
COPY . /c-toxcore/
WORKDIR /c-toxcore
RUN other/analysis/run-clang-tidy

5
other/docker/clang-tidy/run Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
set -eux
BUILD=clang-tidy
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/Dockerfile" .

View File

@ -19,11 +19,14 @@ RUN apt-get update && \
make \ make \
ninja-build \ ninja-build \
pkg-config \ pkg-config \
python3-lxml \
python3-pip \ python3-pip \
python3-pygments \ python3-pygments \
&& apt-get clean \ && apt-get clean \
&& rm -rf /var/lib/apt/lists/* \ && rm -rf /var/lib/apt/lists/* \
&& pip3 install --no-cache-dir gcovr && pip3 install --no-cache-dir gcovr
# strip gtest so it doesn't end up in stack traces. This speeds up the
# mallocfail run below by a lot.
RUN ["strip", "-g",\ RUN ["strip", "-g",\
"/usr/lib/x86_64-linux-gnu/libgtest.a",\ "/usr/lib/x86_64-linux-gnu/libgtest.a",\
"/usr/lib/x86_64-linux-gnu/libgtest_main.a"] "/usr/lib/x86_64-linux-gnu/libgtest_main.a"]

View File

@ -92,6 +92,10 @@
<alloc init="true">new_networking_no_udp</alloc> <alloc init="true">new_networking_no_udp</alloc>
<dealloc arg="1">kill_networking</dealloc> <dealloc arg="1">kill_networking</dealloc>
</resource> </resource>
<resource>
<alloc init="true">net_new_strerror</alloc>
<dealloc arg="1">net_kill_strerror</dealloc>
</resource>
<resource> <resource>
<alloc init="true">new_onion</alloc> <alloc init="true">new_onion</alloc>
<dealloc arg="1">kill_onion</dealloc> <dealloc arg="1">kill_onion</dealloc>

View File

@ -1,6 +1,7 @@
FROM ubuntu:20.04 FROM ubuntu:20.04
RUN apt-get update && apt-get install --no-install-recommends -y \ RUN apt-get update && \
DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \
ca-certificates \ ca-certificates \
cppcheck \ cppcheck \
libopus-dev \ libopus-dev \

View File

@ -1,7 +1,8 @@
FROM toxchat/haskell:hs-tokstyle AS tokstyle FROM toxchat/haskell:hs-tokstyle AS tokstyle
FROM ubuntu:22.04 FROM ubuntu:22.04
RUN apt-get update && apt-get install --no-install-recommends -y \ RUN apt-get update && \
DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \
ca-certificates \ ca-certificates \
clang \ clang \
git \ git \

View File

@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
// Copyright © 2023 The TokTok team. // Copyright © 2023-2024 The TokTok team.
// this file can be used to generate event.c files // this file can be used to generate event.c files
// requires c++17 // requires c++17
@ -119,22 +119,54 @@ void generate_event_impl(const std::string& event_name, const std::vector<EventT
exit(1); exit(1);
} }
bool need_stdlib_h = false;
bool need_string_h = false;
bool need_tox_unpack_h = false;
for (const auto& t : event_types) {
std::visit(
overloaded{
[&](const EventTypeTrivial& t) {
if (bin_unpack_name_from_type(t.type).rfind("tox_", 0) == 0) {
need_tox_unpack_h = true;
}
},
[&](const EventTypeByteRange&) {
need_stdlib_h = true;
need_string_h = true;
}
},
t
);
}
f << R"(/* SPDX-License-Identifier: GPL-3.0-or-later f << R"(/* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2023 The TokTok team. * Copyright © 2023-2024 The TokTok team.
*/ */
#include "events_alloc.h" #include "events_alloc.h"
#include <assert.h> #include <assert.h>)";
#include <stdlib.h> if (need_stdlib_h) {
#include <string.h> f << R"(
#include <stdlib.h>)";
}
if (need_string_h) {
f << R"(
#include <string.h>)";
}
f << R"(
#include "../bin_pack.h" #include "../bin_pack.h"
#include "../bin_unpack.h" #include "../bin_unpack.h"
#include "../ccompat.h" #include "../ccompat.h"
#include "../mem.h"
#include "../tox.h" #include "../tox.h"
#include "../tox_events.h" #include "../tox_events.h")";
#include "../tox_unpack.h" if (need_tox_unpack_h) {
f << R"(
#include "../tox_unpack.h")";
}
f << R"(
/***************************************************** /*****************************************************

View File

@ -13,7 +13,6 @@ sh_test(
args = ["$(locations %s)" % f for f in CIMPLE_FILES] + [ args = ["$(locations %s)" % f for f in CIMPLE_FILES] + [
"-Wno-boolean-return", "-Wno-boolean-return",
"-Wno-callback-names", "-Wno-callback-names",
"-Wno-enum-names",
"+RTS", "+RTS",
"-N4", "-N4",
"-RTS", "-RTS",

View File

@ -8,10 +8,19 @@ if(TARGET toxcore_static)
else() else()
target_link_libraries(misc_tools PRIVATE toxcore_shared) target_link_libraries(misc_tools PRIVATE toxcore_shared)
endif() endif()
target_link_libraries(misc_tools PRIVATE ${LIBSODIUM_LIBRARIES}) if(TARGET unofficial-sodium::sodium)
target_link_directories(misc_tools PUBLIC ${LIBSODIUM_LIBRARY_DIRS}) target_link_libraries(misc_tools PRIVATE unofficial-sodium::sodium)
target_include_directories(misc_tools SYSTEM PRIVATE ${LIBSODIUM_INCLUDE_DIRS}) else()
target_compile_options(misc_tools PRIVATE ${LIBSODIUM_CFLAGS_OTHER}) target_link_libraries(misc_tools PRIVATE ${LIBSODIUM_LIBRARIES})
target_link_directories(misc_tools PUBLIC ${LIBSODIUM_LIBRARY_DIRS})
target_include_directories(misc_tools SYSTEM PRIVATE ${LIBSODIUM_INCLUDE_DIRS})
target_compile_options(misc_tools PRIVATE ${LIBSODIUM_CFLAGS_OTHER})
endif()
if(TARGET PThreads4W::PThreads4W)
target_link_libraries(misc_tools PRIVATE PThreads4W::PThreads4W)
elseif(TARGET Threads::Threads)
target_link_libraries(misc_tools PRIVATE Threads::Threads)
endif()
################################################################################ ################################################################################
# #
@ -27,4 +36,9 @@ if(BUILD_MISC_TESTS)
else() else()
target_link_libraries(Messenger_test PRIVATE toxcore_shared) target_link_libraries(Messenger_test PRIVATE toxcore_shared)
endif() endif()
if(TARGET PThreads4W::PThreads4W)
target_link_libraries(Messenger_test PRIVATE PThreads4W::PThreads4W)
elseif(TARGET Threads::Threads)
target_link_libraries(Messenger_test PRIVATE Threads::Threads)
endif()
endif() endif()

View File

@ -4,6 +4,7 @@
#include "../../toxcore/tox.h" #include "../../toxcore/tox.h"
#include "../../toxcore/tox_dispatch.h" #include "../../toxcore/tox_dispatch.h"
#include "../../toxcore/tox_events.h" #include "../../toxcore/tox_events.h"
#include "../../toxcore/tox_private.h"
#include "fuzz_support.h" #include "fuzz_support.h"
#include "fuzz_tox.h" #include "fuzz_tox.h"

View File

@ -196,13 +196,13 @@ void ac_iterate(ACSession *ac)
int ac_queue_message(Mono_Time *mono_time, void *acp, struct RTPMessage *msg) int ac_queue_message(Mono_Time *mono_time, void *acp, struct RTPMessage *msg)
{ {
if (acp == nullptr || msg == nullptr) { ACSession *ac = (ACSession *)acp;
if (ac == nullptr || msg == nullptr) {
free(msg); free(msg);
return -1; return -1;
} }
ACSession *ac = (ACSession *)acp;
if ((msg->header.pt & 0x7f) == (RTP_TYPE_AUDIO + 2) % 128) { if ((msg->header.pt & 0x7f) == (RTP_TYPE_AUDIO + 2) % 128) {
LOGGER_WARNING(ac->log, "Got dummy!"); LOGGER_WARNING(ac->log, "Got dummy!");
free(msg); free(msg);

View File

@ -208,6 +208,8 @@ static int bwc_send_custom_lossy_packet(Tox *tox, int32_t friendnumber, const ui
static int bwc_handle_data(Messenger *m, uint32_t friendnumber, const uint8_t *data, uint16_t length, void *object) static int bwc_handle_data(Messenger *m, uint32_t friendnumber, const uint8_t *data, uint16_t length, void *object)
{ {
BWController *bwc = (BWController *)object;
if (length - 1 != sizeof(struct BWCMessage)) { if (length - 1 != sizeof(struct BWCMessage)) {
return -1; return -1;
} }
@ -218,5 +220,5 @@ static int bwc_handle_data(Messenger *m, uint32_t friendnumber, const uint8_t *d
offset += net_unpack_u32(data + offset, &msg.recv); offset += net_unpack_u32(data + offset, &msg.recv);
assert(offset == length); assert(offset == length);
return on_update((BWController *)object, &msg); return on_update(bwc, &msg);
} }

View File

@ -290,8 +290,9 @@ static void group_av_peer_delete(void *object, uint32_t groupnumber, void *peer_
static void group_av_groupchat_delete(void *object, uint32_t groupnumber) static void group_av_groupchat_delete(void *object, uint32_t groupnumber)
{ {
if (object != nullptr) { Group_AV *group_av = (Group_AV *)object;
kill_group_av((Group_AV *)object); if (group_av != nullptr) {
kill_group_av(group_av);
} }
} }
@ -404,12 +405,13 @@ static int decode_audio_packet(Group_AV *group_av, Group_Peer_AV *peer_av, uint3
static int handle_group_audio_packet(void *object, uint32_t groupnumber, uint32_t friendgroupnumber, void *peer_object, static int handle_group_audio_packet(void *object, uint32_t groupnumber, uint32_t friendgroupnumber, void *peer_object,
const uint8_t *packet, uint16_t length) const uint8_t *packet, uint16_t length)
{ {
if (peer_object == nullptr || object == nullptr || length <= sizeof(uint16_t)) { Group_AV *group_av = (Group_AV *)object;
Group_Peer_AV *peer_av = (Group_Peer_AV *)peer_object;
if (group_av == nullptr || peer_av == nullptr || length <= sizeof(uint16_t)) {
return -1; return -1;
} }
Group_Peer_AV *peer_av = (Group_Peer_AV *)peer_object;
Group_Audio_Packet *pk = (Group_Audio_Packet *)calloc(1, sizeof(Group_Audio_Packet)); Group_Audio_Packet *pk = (Group_Audio_Packet *)calloc(1, sizeof(Group_Audio_Packet));
if (pk == nullptr) { if (pk == nullptr) {
@ -433,7 +435,7 @@ static int handle_group_audio_packet(void *object, uint32_t groupnumber, uint32_
return -1; return -1;
} }
while (decode_audio_packet((Group_AV *)object, peer_av, groupnumber, friendgroupnumber) == 0) { while (decode_audio_packet(group_av, peer_av, groupnumber, friendgroupnumber) == 0) {
/* Continue. */ /* Continue. */
} }

View File

@ -60,7 +60,7 @@ typedef struct MSIMessage {
static void msg_init(MSIMessage *dest, MSIRequest request); static void msg_init(MSIMessage *dest, MSIRequest request);
static int msg_parse_in(const Logger *log, MSIMessage *dest, const uint8_t *data, uint16_t length); static int msg_parse_in(const Logger *log, MSIMessage *dest, const uint8_t *data, uint16_t length);
static uint8_t *msg_parse_header_out(MSIHeaderID id, uint8_t *dest, const void *value, uint8_t value_len, static uint8_t *msg_parse_header_out(MSIHeaderID id, uint8_t *dest, const uint8_t *value, uint8_t value_len,
uint16_t *length); uint16_t *length);
static int send_message(const Messenger *m, uint32_t friend_number, const MSIMessage *msg); static int send_message(const Messenger *m, uint32_t friend_number, const MSIMessage *msg);
static int send_error(const Messenger *m, uint32_t friend_number, MSIError error); static int send_error(const Messenger *m, uint32_t friend_number, MSIError error);
@ -425,7 +425,7 @@ static int msg_parse_in(const Logger *log, MSIMessage *dest, const uint8_t *data
return 0; return 0;
} }
static uint8_t *msg_parse_header_out(MSIHeaderID id, uint8_t *dest, const void *value, uint8_t value_len, static uint8_t *msg_parse_header_out(MSIHeaderID id, uint8_t *dest, const uint8_t *value, uint8_t value_len,
uint16_t *length) uint16_t *length)
{ {
/* Parse a single header for sending */ /* Parse a single header for sending */
@ -657,12 +657,13 @@ CLEAR_CONTAINER:
} }
static void on_peer_status(Messenger *m, uint32_t friend_number, uint8_t status, void *data) static void on_peer_status(Messenger *m, uint32_t friend_number, uint8_t status, void *data)
{ {
MSISession *session = (MSISession *)data;
if (status != 0) { if (status != 0) {
// Friend is online. // Friend is online.
return; return;
} }
MSISession *session = (MSISession *)data;
LOGGER_DEBUG(m->log, "Friend %d is now offline", friend_number); LOGGER_DEBUG(m->log, "Friend %d is now offline", friend_number);
pthread_mutex_lock(session->mutex); pthread_mutex_lock(session->mutex);
@ -851,9 +852,10 @@ static void handle_pop(MSICall *call, const MSIMessage *msg)
} }
static void handle_msi_packet(Messenger *m, uint32_t friend_number, const uint8_t *data, uint16_t length, void *object) static void handle_msi_packet(Messenger *m, uint32_t friend_number, const uint8_t *data, uint16_t length, void *object)
{ {
MSISession *session = (MSISession *)object;
LOGGER_DEBUG(m->log, "Got msi message"); LOGGER_DEBUG(m->log, "Got msi message");
MSISession *session = (MSISession *)object;
MSIMessage msg; MSIMessage msg;
if (msg_parse_in(m->log, &msg, data, length) == -1) { if (msg_parse_in(m->log, &msg, data, length) == -1) {

View File

@ -65,10 +65,12 @@ extern "C" {
/** /**
* External Tox type. * External Tox type.
*/ */
#ifndef APIGEN_IGNORE
#ifndef TOX_DEFINED #ifndef TOX_DEFINED
#define TOX_DEFINED #define TOX_DEFINED
typedef struct Tox Tox; typedef struct Tox Tox;
#endif /* TOX_DEFINED */ #endif /* !TOX_DEFINED */
#endif /* !APIGEN_IGNORE */
/** /**
* @brief The ToxAV instance type. * @brief The ToxAV instance type.
@ -605,7 +607,7 @@ typedef enum Toxav_Err_Send_Frame {
* @param sampling_rate Audio sampling rate used in this frame. Valid sampling * @param sampling_rate Audio sampling rate used in this frame. Valid sampling
* rates are 8000, 12000, 16000, 24000, or 48000. * rates are 8000, 12000, 16000, 24000, or 48000.
*/ */
bool toxav_audio_send_frame(ToxAV *av, uint32_t friend_number, const int16_t *pcm, size_t sample_count, bool toxav_audio_send_frame(ToxAV *av, uint32_t friend_number, const int16_t pcm[], size_t sample_count,
uint8_t channels, uint32_t sampling_rate, Toxav_Err_Send_Frame *error); uint8_t channels, uint32_t sampling_rate, Toxav_Err_Send_Frame *error);
/** /**
@ -652,8 +654,12 @@ void toxav_callback_audio_bit_rate(ToxAV *av, toxav_audio_bit_rate_cb *callback,
* @param u U (Chroma) plane data. * @param u U (Chroma) plane data.
* @param v V (Chroma) plane data. * @param v V (Chroma) plane data.
*/ */
bool toxav_video_send_frame(ToxAV *av, uint32_t friend_number, uint16_t width, uint16_t height, const uint8_t *y, bool toxav_video_send_frame(
const uint8_t *u, const uint8_t *v, Toxav_Err_Send_Frame *error); ToxAV *av, uint32_t friend_number, uint16_t width, uint16_t height,
const uint8_t y[/*! height * width */],
const uint8_t u[/*! height/2 * width/2 */],
const uint8_t v[/*! height/2 * width/2 */],
Toxav_Err_Send_Frame *error);
/** /**
* Set the bit rate to be used in subsequent video frames. * Set the bit rate to be used in subsequent video frames.
@ -703,7 +709,7 @@ void toxav_callback_video_bit_rate(ToxAV *av, toxav_video_bit_rate_cb *callback,
* @param sampling_rate Sampling rate used in this frame. * @param sampling_rate Sampling rate used in this frame.
* *
*/ */
typedef void toxav_audio_receive_frame_cb(ToxAV *av, uint32_t friend_number, const int16_t *pcm, size_t sample_count, typedef void toxav_audio_receive_frame_cb(ToxAV *av, uint32_t friend_number, const int16_t pcm[], size_t sample_count,
uint8_t channels, uint32_t sampling_rate, void *user_data); uint8_t channels, uint32_t sampling_rate, void *user_data);
@ -735,8 +741,13 @@ void toxav_callback_audio_receive_frame(ToxAV *av, toxav_audio_receive_frame_cb
* @param ustride U chroma plane stride. * @param ustride U chroma plane stride.
* @param vstride V chroma plane stride. * @param vstride V chroma plane stride.
*/ */
typedef void toxav_video_receive_frame_cb(ToxAV *av, uint32_t friend_number, uint16_t width, uint16_t height, typedef void toxav_video_receive_frame_cb(
const uint8_t *y, const uint8_t *u, const uint8_t *v, int32_t ystride, int32_t ustride, int32_t vstride, ToxAV *av, uint32_t friend_number,
uint16_t width, uint16_t height,
const uint8_t y[/*! max(width, abs(ystride)) * height */],
const uint8_t u[/*! max(width/2, abs(ustride)) * (height/2) */],
const uint8_t v[/*! max(width/2, abs(vstride)) * (height/2) */],
int32_t ystride, int32_t ustride, int32_t vstride,
void *user_data); void *user_data);
@ -746,6 +757,8 @@ typedef void toxav_video_receive_frame_cb(ToxAV *av, uint32_t friend_number, uin
*/ */
void toxav_callback_video_receive_frame(ToxAV *av, toxav_video_receive_frame_cb *callback, void *user_data); void toxav_callback_video_receive_frame(ToxAV *av, toxav_video_receive_frame_cb *callback, void *user_data);
#ifndef APIGEN_IGNORE
/*** /***
* NOTE Compatibility with old toxav group calls. TODO(iphydf): remove * NOTE Compatibility with old toxav group calls. TODO(iphydf): remove
* *
@ -755,10 +768,10 @@ void toxav_callback_video_receive_frame(ToxAV *av, toxav_video_receive_frame_cb
*/ */
// TODO(iphydf): Use this better typed one instead of the void-pointer one below. // TODO(iphydf): Use this better typed one instead of the void-pointer one below.
typedef void toxav_group_audio_cb(Tox *tox, uint32_t groupnumber, uint32_t peernumber, const int16_t *pcm, typedef void toxav_group_audio_cb(Tox *tox, uint32_t groupnumber, uint32_t peernumber, const int16_t pcm[],
uint32_t samples, uint8_t channels, uint32_t sample_rate, void *user_data); uint32_t samples, uint8_t channels, uint32_t sample_rate, void *user_data);
typedef void toxav_audio_data_cb(void *tox, uint32_t groupnumber, uint32_t peernumber, const int16_t *pcm, typedef void toxav_audio_data_cb(void *tox, uint32_t groupnumber, uint32_t peernumber, const int16_t pcm[],
uint32_t samples, uint8_t channels, uint32_t sample_rate, void *userdata); uint32_t samples, uint8_t channels, uint32_t sample_rate, void *userdata);
/** @brief Create a new toxav group. /** @brief Create a new toxav group.
@ -768,7 +781,7 @@ typedef void toxav_audio_data_cb(void *tox, uint32_t groupnumber, uint32_t peern
* *
* Note that total size of pcm in bytes is equal to `samples * channels * sizeof(int16_t)`. * Note that total size of pcm in bytes is equal to `samples * channels * sizeof(int16_t)`.
*/ */
int toxav_add_av_groupchat(Tox *tox, toxav_audio_data_cb *audio_callback, void *userdata); int32_t toxav_add_av_groupchat(Tox *tox, toxav_audio_data_cb *audio_callback, void *userdata);
/** @brief Join a AV group (you need to have been invited first). /** @brief Join a AV group (you need to have been invited first).
* *
@ -777,7 +790,8 @@ int toxav_add_av_groupchat(Tox *tox, toxav_audio_data_cb *audio_callback, void *
* *
* Note that total size of pcm in bytes is equal to `samples * channels * sizeof(int16_t)`. * Note that total size of pcm in bytes is equal to `samples * channels * sizeof(int16_t)`.
*/ */
int toxav_join_av_groupchat(Tox *tox, uint32_t friendnumber, const uint8_t *data, uint16_t length, int32_t toxav_join_av_groupchat(
Tox *tox, uint32_t friendnumber, const uint8_t data[], uint16_t length,
toxav_audio_data_cb *audio_callback, void *userdata); toxav_audio_data_cb *audio_callback, void *userdata);
/** @brief Send audio to the group chat. /** @brief Send audio to the group chat.
@ -794,7 +808,8 @@ int toxav_join_av_groupchat(Tox *tox, uint32_t friendnumber, const uint8_t *data
* *
* Recommended values are: samples = 960, channels = 1, sample_rate = 48000 * Recommended values are: samples = 960, channels = 1, sample_rate = 48000
*/ */
int toxav_group_send_audio(Tox *tox, uint32_t groupnumber, const int16_t *pcm, unsigned int samples, uint8_t channels, int32_t toxav_group_send_audio(
Tox *tox, uint32_t groupnumber, const int16_t pcm[], uint32_t samples, uint8_t channels,
uint32_t sample_rate); uint32_t sample_rate);
/** @brief Enable A/V in a groupchat. /** @brief Enable A/V in a groupchat.
@ -812,7 +827,8 @@ int toxav_group_send_audio(Tox *tox, uint32_t groupnumber, const int16_t *pcm, u
* *
* Note that total size of pcm in bytes is equal to `samples * channels * sizeof(int16_t)`. * Note that total size of pcm in bytes is equal to `samples * channels * sizeof(int16_t)`.
*/ */
int toxav_groupchat_enable_av(Tox *tox, uint32_t groupnumber, int32_t toxav_groupchat_enable_av(
Tox *tox, uint32_t groupnumber,
toxav_audio_data_cb *audio_callback, void *userdata); toxav_audio_data_cb *audio_callback, void *userdata);
/** @brief Disable A/V in a groupchat. /** @brief Disable A/V in a groupchat.
@ -820,11 +836,13 @@ int toxav_groupchat_enable_av(Tox *tox, uint32_t groupnumber,
* @retval 0 on success. * @retval 0 on success.
* @retval -1 on failure. * @retval -1 on failure.
*/ */
int toxav_groupchat_disable_av(Tox *tox, uint32_t groupnumber); int32_t toxav_groupchat_disable_av(Tox *tox, uint32_t groupnumber);
/** @brief Return whether A/V is enabled in the groupchat. */ /** @brief Return whether A/V is enabled in the groupchat. */
bool toxav_groupchat_av_enabled(Tox *tox, uint32_t groupnumber); bool toxav_groupchat_av_enabled(Tox *tox, uint32_t groupnumber);
#endif /* !APIGEN_IGNORE */
/** @} */ /** @} */
#ifdef __cplusplus #ifdef __cplusplus
@ -834,6 +852,7 @@ bool toxav_groupchat_av_enabled(Tox *tox, uint32_t groupnumber);
//!TOKSTYLE- //!TOKSTYLE-
#ifndef DOXYGEN_IGNORE #ifndef DOXYGEN_IGNORE
typedef ToxAV Toxav;
typedef Toxav_Err_Call TOXAV_ERR_CALL; typedef Toxav_Err_Call TOXAV_ERR_CALL;
typedef Toxav_Err_New TOXAV_ERR_NEW; typedef Toxav_Err_New TOXAV_ERR_NEW;
typedef Toxav_Err_Answer TOXAV_ERR_ANSWER; typedef Toxav_Err_Answer TOXAV_ERR_ANSWER;

View File

@ -345,17 +345,18 @@ void vc_iterate(VCSession *vc)
int vc_queue_message(Mono_Time *mono_time, void *vcp, struct RTPMessage *msg) int vc_queue_message(Mono_Time *mono_time, void *vcp, struct RTPMessage *msg)
{ {
VCSession *vc = (VCSession *)vcp;
/* This function is called with complete messages /* This function is called with complete messages
* they have already been assembled. * they have already been assembled.
* this function gets called from handle_rtp_packet() and handle_rtp_packet_v3() * this function gets called from handle_rtp_packet() and handle_rtp_packet_v3()
*/ */
if (vcp == nullptr || msg == nullptr) { if (vc == nullptr || msg == nullptr) {
free(msg); free(msg);
return -1; return -1;
} }
VCSession *vc = (VCSession *)vcp;
const struct RTPHeader *const header = &msg->header; const struct RTPHeader *const header = &msg->header;
if (msg->header.pt == (RTP_TYPE_VIDEO + 2) % 128) { if (msg->header.pt == (RTP_TYPE_VIDEO + 2) % 128) {

View File

@ -16,13 +16,15 @@
#include "LAN_discovery.h" #include "LAN_discovery.h"
#include "bin_pack.h" #include "bin_pack.h"
#include "ccompat.h" #include "ccompat.h"
#include "crypto_core.h"
#include "logger.h" #include "logger.h"
#include "mem.h"
#include "mono_time.h" #include "mono_time.h"
#include "network.h" #include "network.h"
#include "ping.h" #include "ping.h"
#include "ping_array.h"
#include "shared_key_cache.h" #include "shared_key_cache.h"
#include "state.h" #include "state.h"
#include "util.h"
/** The timeout after which a node is discarded completely. */ /** The timeout after which a node is discarded completely. */
#define KILL_NODE_TIMEOUT (BAD_NODE_TIMEOUT + PING_INTERVAL) #define KILL_NODE_TIMEOUT (BAD_NODE_TIMEOUT + PING_INTERVAL)
@ -420,7 +422,8 @@ static bool bin_pack_ip_port(Bin_Pack *bp, const Logger *logger, const IP_Port *
non_null() non_null()
static bool bin_pack_ip_port_handler(Bin_Pack *bp, const Logger *logger, const void *obj) static bool bin_pack_ip_port_handler(Bin_Pack *bp, const Logger *logger, const void *obj)
{ {
return bin_pack_ip_port(bp, logger, (const IP_Port *)obj); const IP_Port *ip_port = (const IP_Port *)obj;
return bin_pack_ip_port(bp, logger, ip_port);
} }
int pack_ip_port(const Logger *logger, uint8_t *data, uint16_t length, const IP_Port *ip_port) int pack_ip_port(const Logger *logger, uint8_t *data, uint16_t length, const IP_Port *ip_port)
@ -508,7 +511,7 @@ int unpack_ip_port(IP_Port *ip_port, const uint8_t *data, uint16_t length, bool
return -1; return -1;
} }
*ip_port = empty_ip_port; ipport_reset(ip_port);
if (is_ipv4) { if (is_ipv4) {
const uint32_t size = 1 + SIZE_IP4 + sizeof(uint16_t); const uint32_t size = 1 + SIZE_IP4 + sizeof(uint16_t);
@ -1477,12 +1480,12 @@ static int sendnodes_ipv6(const DHT *dht, const IP_Port *ip_port, const uint8_t
non_null() non_null()
static int handle_getnodes(void *object, const IP_Port *source, const uint8_t *packet, uint16_t length, void *userdata) static int handle_getnodes(void *object, const IP_Port *source, const uint8_t *packet, uint16_t length, void *userdata)
{ {
DHT *const dht = (DHT *)object;
if (length != (CRYPTO_SIZE + CRYPTO_MAC_SIZE + sizeof(uint64_t))) { if (length != (CRYPTO_SIZE + CRYPTO_MAC_SIZE + sizeof(uint64_t))) {
return 1; return 1;
} }
DHT *const dht = (DHT *)object;
/* Check if packet is from ourself. */ /* Check if packet is from ourself. */
if (pk_equal(packet + 1, dht->self_public_key)) { if (pk_equal(packet + 1, dht->self_public_key)) {
return 1; return 1;
@ -2263,11 +2266,12 @@ non_null()
static int handle_nat_ping(void *object, const IP_Port *source, const uint8_t *source_pubkey, const uint8_t *packet, static int handle_nat_ping(void *object, const IP_Port *source, const uint8_t *source_pubkey, const uint8_t *packet,
uint16_t length, void *userdata) uint16_t length, void *userdata)
{ {
DHT *const dht = (DHT *)object;
if (length != sizeof(uint64_t) + 1) { if (length != sizeof(uint64_t) + 1) {
return 1; return 1;
} }
DHT *const dht = (DHT *)object;
uint64_t ping_id; uint64_t ping_id;
memcpy(&ping_id, packet + 1, sizeof(uint64_t)); memcpy(&ping_id, packet + 1, sizeof(uint64_t));

View File

@ -232,7 +232,7 @@ int unpack_ip_port(IP_Port *ip_port, const uint8_t *data, uint16_t length, bool
non_null() non_null()
int dht_create_packet(const Memory *mem, const Random *rng, int dht_create_packet(const Memory *mem, const Random *rng,
const uint8_t public_key[CRYPTO_PUBLIC_KEY_SIZE], const uint8_t public_key[CRYPTO_PUBLIC_KEY_SIZE],
const uint8_t *shared_key, const uint8_t type, const uint8_t *shared_key, uint8_t type,
const uint8_t *plain, size_t plain_length, const uint8_t *plain, size_t plain_length,
uint8_t *packet, size_t length); uint8_t *packet, size_t length);

View File

@ -32,7 +32,7 @@
#endif #endif
#ifdef __linux__ #ifdef __linux__
#include <linux/netdevice.h> #include <linux/if.h>
#endif #endif
#if defined(__FreeBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__DragonFly__)
@ -41,7 +41,7 @@
#include "ccompat.h" #include "ccompat.h"
#include "crypto_core.h" #include "crypto_core.h"
#include "util.h" #include "network.h"
#define MAX_INTERFACES 16 #define MAX_INTERFACES 16
@ -243,11 +243,11 @@ static IP broadcast_ip(Family family_socket, Family family_broadcast)
ip.ip.v6.uint8[15] = 0x01; ip.ip.v6.uint8[15] = 0x01;
} else if (net_family_is_ipv4(family_broadcast)) { } else if (net_family_is_ipv4(family_broadcast)) {
ip.family = net_family_ipv6(); ip.family = net_family_ipv6();
ip.ip.v6 = ip6_broadcast; ip.ip.v6 = get_ip6_broadcast();
} }
} else if (net_family_is_ipv4(family_socket) && net_family_is_ipv4(family_broadcast)) { } else if (net_family_is_ipv4(family_socket) && net_family_is_ipv4(family_broadcast)) {
ip.family = net_family_ipv4(); ip.family = net_family_ipv4();
ip.ip.v4 = ip4_broadcast; ip.ip.v4 = get_ip4_broadcast();
} }
return ip; return ip;

View File

@ -10,17 +10,33 @@
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include "DHT.h" #include "DHT.h"
#include "TCP_client.h"
#include "TCP_connection.h"
#include "TCP_server.h"
#include "announce.h"
#include "bin_pack.h"
#include "bin_unpack.h"
#include "ccompat.h" #include "ccompat.h"
#include "crypto_core.h"
#include "forwarding.h"
#include "friend_connection.h"
#include "friend_requests.h"
#include "group_announce.h"
#include "group_chats.h" #include "group_chats.h"
#include "group_common.h"
#include "group_onion_announce.h" #include "group_onion_announce.h"
#include "logger.h" #include "logger.h"
#include "mem.h"
#include "mono_time.h" #include "mono_time.h"
#include "net_crypto.h"
#include "network.h" #include "network.h"
#include "onion.h"
#include "onion_announce.h"
#include "onion_client.h"
#include "state.h" #include "state.h"
#include "util.h" #include "util.h"
@ -2385,11 +2401,12 @@ static int m_handle_packet_invite_groupchat(Messenger *m, const int i, const uin
non_null(1, 3) nullable(5) non_null(1, 3) nullable(5)
static int m_handle_packet(void *object, int i, const uint8_t *temp, uint16_t len, void *userdata) static int m_handle_packet(void *object, int i, const uint8_t *temp, uint16_t len, void *userdata)
{ {
Messenger *m = (Messenger *)object;
if (len == 0) { if (len == 0) {
return -1; return -1;
} }
Messenger *m = (Messenger *)object;
const uint8_t packet_id = temp[0]; const uint8_t packet_id = temp[0];
const uint8_t *data = temp + 1; const uint8_t *data = temp + 1;
const uint16_t data_length = len - 1; const uint16_t data_length = len - 1;
@ -3176,7 +3193,8 @@ static void pack_groupchats(const GC_Session *c, Bin_Pack *bp)
non_null() non_null()
static bool pack_groupchats_handler(Bin_Pack *bp, const Logger *log, const void *obj) static bool pack_groupchats_handler(Bin_Pack *bp, const Logger *log, const void *obj)
{ {
pack_groupchats((const GC_Session *)obj, bp); const GC_Session *session = (const GC_Session *)obj;
pack_groupchats(session, bp);
return true; // TODO(iphydf): Return bool from pack functions. return true; // TODO(iphydf): Return bool from pack functions.
} }

View File

@ -10,12 +10,17 @@
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include "DHT.h"
#include "TCP_common.h" #include "TCP_common.h"
#include "ccompat.h" #include "ccompat.h"
#include "crypto_core.h"
#include "forwarding.h"
#include "logger.h"
#include "mem.h"
#include "mono_time.h" #include "mono_time.h"
#include "network.h"
#include "util.h" #include "util.h"
typedef struct TCP_Client_Conn { typedef struct TCP_Client_Conn {

View File

@ -5,10 +5,13 @@
#include "TCP_common.h" #include "TCP_common.h"
#include <stdlib.h>
#include <string.h> #include <string.h>
#include "ccompat.h" #include "ccompat.h"
#include "crypto_core.h"
#include "logger.h"
#include "mem.h"
#include "network.h"
void wipe_priority_list(const Memory *mem, TCP_Priority_List *p) void wipe_priority_list(const Memory *mem, TCP_Priority_List *p)
{ {

View File

@ -9,12 +9,17 @@
#include "TCP_connection.h" #include "TCP_connection.h"
#include <assert.h> #include <assert.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include "DHT.h"
#include "TCP_client.h" #include "TCP_client.h"
#include "ccompat.h" #include "ccompat.h"
#include "crypto_core.h"
#include "forwarding.h"
#include "logger.h"
#include "mem.h"
#include "mono_time.h" #include "mono_time.h"
#include "network.h"
#include "util.h" #include "util.h"
struct TCP_Connections { struct TCP_Connections {
@ -1133,11 +1138,12 @@ non_null(1, 4) nullable(6)
static int tcp_conn_data_callback(void *object, uint32_t number, uint8_t connection_id, const uint8_t *data, static int tcp_conn_data_callback(void *object, uint32_t number, uint8_t connection_id, const uint8_t *data,
uint16_t length, void *userdata) uint16_t length, void *userdata)
{ {
const TCP_Client_Connection *tcp_client_con = (TCP_Client_Connection *)object;
if (length == 0) { if (length == 0) {
return -1; return -1;
} }
const TCP_Client_Connection *tcp_client_con = (TCP_Client_Connection *)object;
TCP_Connections *tcp_c = (TCP_Connections *)tcp_con_custom_object(tcp_client_con); TCP_Connections *tcp_c = (TCP_Connections *)tcp_con_custom_object(tcp_client_con);
const unsigned int tcp_connections_number = tcp_con_custom_uint(tcp_client_con); const unsigned int tcp_connections_number = tcp_con_custom_uint(tcp_client_con);
@ -1164,11 +1170,12 @@ non_null()
static int tcp_conn_oob_callback(void *object, const uint8_t *public_key, const uint8_t *data, uint16_t length, static int tcp_conn_oob_callback(void *object, const uint8_t *public_key, const uint8_t *data, uint16_t length,
void *userdata) void *userdata)
{ {
const TCP_Client_Connection *tcp_client_con = (const TCP_Client_Connection *)object;
if (length == 0) { if (length == 0) {
return -1; return -1;
} }
const TCP_Client_Connection *tcp_client_con = (const TCP_Client_Connection *)object;
TCP_Connections *tcp_c = (TCP_Connections *)tcp_con_custom_object(tcp_client_con); TCP_Connections *tcp_c = (TCP_Connections *)tcp_con_custom_object(tcp_client_con);
const unsigned int tcp_connections_number = tcp_con_custom_uint(tcp_client_con); const unsigned int tcp_connections_number = tcp_con_custom_uint(tcp_client_con);

View File

@ -8,7 +8,6 @@
*/ */
#include "TCP_server.h" #include "TCP_server.h"
#include <stdlib.h>
#include <string.h> #include <string.h>
#if !defined(_WIN32) && !defined(__WIN32__) && !defined (WIN32) #if !defined(_WIN32) && !defined(__WIN32__) && !defined (WIN32)
#include <sys/ioctl.h> #include <sys/ioctl.h>
@ -19,11 +18,17 @@
#include <unistd.h> #include <unistd.h>
#endif #endif
#include "DHT.h"
#include "TCP_common.h" #include "TCP_common.h"
#include "ccompat.h" #include "ccompat.h"
#include "crypto_core.h"
#include "forwarding.h"
#include "list.h" #include "list.h"
#include "logger.h"
#include "mem.h"
#include "mono_time.h" #include "mono_time.h"
#include "util.h" #include "network.h"
#include "onion.h"
#ifdef TCP_SERVER_USE_EPOLL #ifdef TCP_SERVER_USE_EPOLL
#define TCP_SOCKET_LISTENING 0 #define TCP_SOCKET_LISTENING 0
@ -909,7 +914,7 @@ static Socket new_listening_tcp_socket(const Logger *logger, const Network *ns,
if (!sock_valid(sock)) { if (!sock_valid(sock)) {
LOGGER_ERROR(logger, "TCP socket creation failed (family = %d)", family.value); LOGGER_ERROR(logger, "TCP socket creation failed (family = %d)", family.value);
return net_invalid_socket; return net_invalid_socket();
} }
bool ok = set_socket_nonblock(ns, sock); bool ok = set_socket_nonblock(ns, sock);
@ -930,7 +935,7 @@ static Socket new_listening_tcp_socket(const Logger *logger, const Network *ns,
port, family.value, error != nullptr ? error : "(null)"); port, family.value, error != nullptr ? error : "(null)");
net_kill_strerror(error); net_kill_strerror(error);
kill_sock(ns, sock); kill_sock(ns, sock);
return net_invalid_socket; return net_invalid_socket();
} }
LOGGER_DEBUG(logger, "successfully bound to TCP port %d", port); LOGGER_DEBUG(logger, "successfully bound to TCP port %d", port);

View File

@ -12,8 +12,15 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "DHT.h"
#include "LAN_discovery.h" #include "LAN_discovery.h"
#include "ccompat.h" #include "ccompat.h"
#include "crypto_core.h"
#include "forwarding.h"
#include "logger.h"
#include "mem.h"
#include "mono_time.h"
#include "network.h"
#include "shared_key_cache.h" #include "shared_key_cache.h"
#include "timed_auth.h" #include "timed_auth.h"
#include "util.h" #include "util.h"
@ -427,7 +434,7 @@ static int create_reply_plain_store_announce_request(Announcements *announce,
const uint8_t *to_auth, uint16_t to_auth_length) const uint8_t *to_auth, uint16_t to_auth_length)
{ {
const int plain_len = (int)length - (CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE + CRYPTO_MAC_SIZE); const int plain_len = (int)length - (CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE + CRYPTO_MAC_SIZE);
const int announcement_len = (int)plain_len - (TIMED_AUTH_SIZE + sizeof(uint32_t) + 1); const int announcement_len = plain_len - (TIMED_AUTH_SIZE + sizeof(uint32_t) + 1);
const uint8_t *const data_public_key = data; const uint8_t *const data_public_key = data;

View File

@ -10,6 +10,7 @@
#include "../third_party/cmp/cmp.h" #include "../third_party/cmp/cmp.h"
#include "ccompat.h" #include "ccompat.h"
#include "logger.h"
struct Bin_Pack { struct Bin_Pack {
uint8_t *bytes; uint8_t *bytes;

View File

@ -2,3 +2,5 @@
* Copyright © 2022 The TokTok team. * Copyright © 2022 The TokTok team.
*/ */
#include "ccompat.h" #include "ccompat.h"
static_assert(sizeof(int) >= 4, "toxcore does not support 16-bit platforms");

View File

@ -1,19 +1,17 @@
/* SPDX-License-Identifier: GPL-3.0-or-later /* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2023 The TokTok team. * Copyright © 2023-2024 The TokTok team.
*/ */
#include "events_alloc.h" #include "events_alloc.h"
#include <assert.h> #include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "../bin_pack.h" #include "../bin_pack.h"
#include "../bin_unpack.h" #include "../bin_unpack.h"
#include "../ccompat.h" #include "../ccompat.h"
#include "../mem.h"
#include "../tox.h" #include "../tox.h"
#include "../tox_events.h" #include "../tox_events.h"
#include "../tox_unpack.h"
/***************************************************** /*****************************************************

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later /* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2023 The TokTok team. * Copyright © 2023-2024 The TokTok team.
*/ */
#include "events_alloc.h" #include "events_alloc.h"
@ -11,6 +11,7 @@
#include "../bin_pack.h" #include "../bin_pack.h"
#include "../bin_unpack.h" #include "../bin_unpack.h"
#include "../ccompat.h" #include "../ccompat.h"
#include "../mem.h"
#include "../tox.h" #include "../tox.h"
#include "../tox_events.h" #include "../tox_events.h"
#include "../tox_unpack.h" #include "../tox_unpack.h"

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later /* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2023 The TokTok team. * Copyright © 2023-2024 The TokTok team.
*/ */
#include "events_alloc.h" #include "events_alloc.h"
@ -11,6 +11,7 @@
#include "../bin_pack.h" #include "../bin_pack.h"
#include "../bin_unpack.h" #include "../bin_unpack.h"
#include "../ccompat.h" #include "../ccompat.h"
#include "../mem.h"
#include "../tox.h" #include "../tox.h"
#include "../tox_events.h" #include "../tox_events.h"
#include "../tox_unpack.h" #include "../tox_unpack.h"

View File

@ -1,19 +1,17 @@
/* SPDX-License-Identifier: GPL-3.0-or-later /* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2023 The TokTok team. * Copyright © 2023-2024 The TokTok team.
*/ */
#include "events_alloc.h" #include "events_alloc.h"
#include <assert.h> #include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "../bin_pack.h" #include "../bin_pack.h"
#include "../bin_unpack.h" #include "../bin_unpack.h"
#include "../ccompat.h" #include "../ccompat.h"
#include "../mem.h"
#include "../tox.h" #include "../tox.h"
#include "../tox_events.h" #include "../tox_events.h"
#include "../tox_unpack.h"
/***************************************************** /*****************************************************

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later /* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2023 The TokTok team. * Copyright © 2023-2024 The TokTok team.
*/ */
#include "events_alloc.h" #include "events_alloc.h"
@ -11,9 +11,9 @@
#include "../bin_pack.h" #include "../bin_pack.h"
#include "../bin_unpack.h" #include "../bin_unpack.h"
#include "../ccompat.h" #include "../ccompat.h"
#include "../mem.h"
#include "../tox.h" #include "../tox.h"
#include "../tox_events.h" #include "../tox_events.h"
#include "../tox_unpack.h"
/***************************************************** /*****************************************************

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later /* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2023 The TokTok team. * Copyright © 2023-2024 The TokTok team.
*/ */
#include "events_alloc.h" #include "events_alloc.h"
@ -11,9 +11,9 @@
#include "../bin_pack.h" #include "../bin_pack.h"
#include "../bin_unpack.h" #include "../bin_unpack.h"
#include "../ccompat.h" #include "../ccompat.h"
#include "../mem.h"
#include "../tox.h" #include "../tox.h"
#include "../tox_events.h" #include "../tox_events.h"
#include "../tox_unpack.h"
/***************************************************** /*****************************************************

View File

@ -5,9 +5,11 @@
#include "events_alloc.h" #include "events_alloc.h"
#include <assert.h> #include <assert.h>
#include <stdlib.h>
#include "../ccompat.h" #include "../ccompat.h"
#include "../mem.h"
#include "../tox_event.h"
#include "../tox_events.h"
Tox_Events_State *tox_events_alloc(void *user_data) Tox_Events_State *tox_events_alloc(void *user_data)
{ {

View File

@ -2,8 +2,8 @@
* Copyright © 2022 The TokTok team. * Copyright © 2022 The TokTok team.
*/ */
#ifndef C_TOXCORE_TOXCORE_TOX_EVENTS_INTERNAL_H #ifndef C_TOXCORE_TOXCORE_EVENTS_EVENTS_ALLOC_H
#define C_TOXCORE_TOXCORE_TOX_EVENTS_INTERNAL_H #define C_TOXCORE_TOXCORE_EVENTS_EVENTS_ALLOC_H
#include "../attributes.h" #include "../attributes.h"
#include "../bin_pack.h" #include "../bin_pack.h"
@ -84,4 +84,4 @@ bool tox_events_add(Tox_Events *events, const Tox_Event *event);
} }
#endif #endif
#endif // C_TOXCORE_TOXCORE_TOX_EVENTS_INTERNAL_H #endif // C_TOXCORE_TOXCORE_EVENTS_EVENTS_ALLOC_H

View File

@ -1,19 +1,17 @@
/* SPDX-License-Identifier: GPL-3.0-or-later /* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2023 The TokTok team. * Copyright © 2023-2024 The TokTok team.
*/ */
#include "events_alloc.h" #include "events_alloc.h"
#include <assert.h> #include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "../bin_pack.h" #include "../bin_pack.h"
#include "../bin_unpack.h" #include "../bin_unpack.h"
#include "../ccompat.h" #include "../ccompat.h"
#include "../mem.h"
#include "../tox.h" #include "../tox.h"
#include "../tox_events.h" #include "../tox_events.h"
#include "../tox_unpack.h"
/***************************************************** /*****************************************************

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later /* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2023 The TokTok team. * Copyright © 2023-2024 The TokTok team.
*/ */
#include "events_alloc.h" #include "events_alloc.h"
@ -11,9 +11,9 @@
#include "../bin_pack.h" #include "../bin_pack.h"
#include "../bin_unpack.h" #include "../bin_unpack.h"
#include "../ccompat.h" #include "../ccompat.h"
#include "../mem.h"
#include "../tox.h" #include "../tox.h"
#include "../tox_events.h" #include "../tox_events.h"
#include "../tox_unpack.h"
/***************************************************** /*****************************************************

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later /* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2023 The TokTok team. * Copyright © 2023-2024 The TokTok team.
*/ */
#include "events_alloc.h" #include "events_alloc.h"
@ -11,9 +11,9 @@
#include "../bin_pack.h" #include "../bin_pack.h"
#include "../bin_unpack.h" #include "../bin_unpack.h"
#include "../ccompat.h" #include "../ccompat.h"
#include "../mem.h"
#include "../tox.h" #include "../tox.h"
#include "../tox_events.h" #include "../tox_events.h"
#include "../tox_unpack.h"
/***************************************************** /*****************************************************

View File

@ -1,16 +1,15 @@
/* SPDX-License-Identifier: GPL-3.0-or-later /* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2023 The TokTok team. * Copyright © 2023-2024 The TokTok team.
*/ */
#include "events_alloc.h" #include "events_alloc.h"
#include <assert.h> #include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "../bin_pack.h" #include "../bin_pack.h"
#include "../bin_unpack.h" #include "../bin_unpack.h"
#include "../ccompat.h" #include "../ccompat.h"
#include "../mem.h"
#include "../tox.h" #include "../tox.h"
#include "../tox_events.h" #include "../tox_events.h"
#include "../tox_unpack.h" #include "../tox_unpack.h"

View File

@ -1,16 +1,15 @@
/* SPDX-License-Identifier: GPL-3.0-or-later /* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2023 The TokTok team. * Copyright © 2023-2024 The TokTok team.
*/ */
#include "events_alloc.h" #include "events_alloc.h"
#include <assert.h> #include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "../bin_pack.h" #include "../bin_pack.h"
#include "../bin_unpack.h" #include "../bin_unpack.h"
#include "../ccompat.h" #include "../ccompat.h"
#include "../mem.h"
#include "../tox.h" #include "../tox.h"
#include "../tox_events.h" #include "../tox_events.h"
#include "../tox_unpack.h" #include "../tox_unpack.h"

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later /* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2023 The TokTok team. * Copyright © 2023-2024 The TokTok team.
*/ */
#include "events_alloc.h" #include "events_alloc.h"
@ -11,9 +11,9 @@
#include "../bin_pack.h" #include "../bin_pack.h"
#include "../bin_unpack.h" #include "../bin_unpack.h"
#include "../ccompat.h" #include "../ccompat.h"
#include "../mem.h"
#include "../tox.h" #include "../tox.h"
#include "../tox_events.h" #include "../tox_events.h"
#include "../tox_unpack.h"
/***************************************************** /*****************************************************

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later /* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2023 The TokTok team. * Copyright © 2023-2024 The TokTok team.
*/ */
#include "events_alloc.h" #include "events_alloc.h"
@ -11,9 +11,9 @@
#include "../bin_pack.h" #include "../bin_pack.h"
#include "../bin_unpack.h" #include "../bin_unpack.h"
#include "../ccompat.h" #include "../ccompat.h"
#include "../mem.h"
#include "../tox.h" #include "../tox.h"
#include "../tox_events.h" #include "../tox_events.h"
#include "../tox_unpack.h"
/***************************************************** /*****************************************************

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later /* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2023 The TokTok team. * Copyright © 2023-2024 The TokTok team.
*/ */
#include "events_alloc.h" #include "events_alloc.h"
@ -11,6 +11,7 @@
#include "../bin_pack.h" #include "../bin_pack.h"
#include "../bin_unpack.h" #include "../bin_unpack.h"
#include "../ccompat.h" #include "../ccompat.h"
#include "../mem.h"
#include "../tox.h" #include "../tox.h"
#include "../tox_events.h" #include "../tox_events.h"
#include "../tox_unpack.h" #include "../tox_unpack.h"

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later /* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2023 The TokTok team. * Copyright © 2023-2024 The TokTok team.
*/ */
#include "events_alloc.h" #include "events_alloc.h"
@ -11,9 +11,9 @@
#include "../bin_pack.h" #include "../bin_pack.h"
#include "../bin_unpack.h" #include "../bin_unpack.h"
#include "../ccompat.h" #include "../ccompat.h"
#include "../mem.h"
#include "../tox.h" #include "../tox.h"
#include "../tox_events.h" #include "../tox_events.h"
#include "../tox_unpack.h"
/***************************************************** /*****************************************************

View File

@ -1,19 +1,17 @@
/* SPDX-License-Identifier: GPL-3.0-or-later /* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2023 The TokTok team. * Copyright © 2023-2024 The TokTok team.
*/ */
#include "events_alloc.h" #include "events_alloc.h"
#include <assert.h> #include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "../bin_pack.h" #include "../bin_pack.h"
#include "../bin_unpack.h" #include "../bin_unpack.h"
#include "../ccompat.h" #include "../ccompat.h"
#include "../mem.h"
#include "../tox.h" #include "../tox.h"
#include "../tox_events.h" #include "../tox_events.h"
#include "../tox_unpack.h"
/***************************************************** /*****************************************************

View File

@ -5,12 +5,12 @@
#include "events_alloc.h" #include "events_alloc.h"
#include <assert.h> #include <assert.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include "../bin_pack.h" #include "../bin_pack.h"
#include "../bin_unpack.h" #include "../bin_unpack.h"
#include "../ccompat.h" #include "../ccompat.h"
#include "../mem.h"
#include "../tox.h" #include "../tox.h"
#include "../tox_events.h" #include "../tox_events.h"
#include "../tox_private.h" #include "../tox_private.h"

View File

@ -1,16 +1,15 @@
/* SPDX-License-Identifier: GPL-3.0-or-later /* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2023 The TokTok team. * Copyright © 2023-2024 The TokTok team.
*/ */
#include "events_alloc.h" #include "events_alloc.h"
#include <assert.h> #include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "../bin_pack.h" #include "../bin_pack.h"
#include "../bin_unpack.h" #include "../bin_unpack.h"
#include "../ccompat.h" #include "../ccompat.h"
#include "../mem.h"
#include "../tox.h" #include "../tox.h"
#include "../tox_events.h" #include "../tox_events.h"
#include "../tox_unpack.h" #include "../tox_unpack.h"

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later /* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2023 The TokTok team. * Copyright © 2023-2024 The TokTok team.
*/ */
#include "events_alloc.h" #include "events_alloc.h"
@ -11,9 +11,9 @@
#include "../bin_pack.h" #include "../bin_pack.h"
#include "../bin_unpack.h" #include "../bin_unpack.h"
#include "../ccompat.h" #include "../ccompat.h"
#include "../mem.h"
#include "../tox.h" #include "../tox.h"
#include "../tox_events.h" #include "../tox_events.h"
#include "../tox_unpack.h"
/***************************************************** /*****************************************************

View File

@ -1,19 +1,17 @@
/* SPDX-License-Identifier: GPL-3.0-or-later /* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2023 The TokTok team. * Copyright © 2023-2024 The TokTok team.
*/ */
#include "events_alloc.h" #include "events_alloc.h"
#include <assert.h> #include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "../bin_pack.h" #include "../bin_pack.h"
#include "../bin_unpack.h" #include "../bin_unpack.h"
#include "../ccompat.h" #include "../ccompat.h"
#include "../mem.h"
#include "../tox.h" #include "../tox.h"
#include "../tox_events.h" #include "../tox_events.h"
#include "../tox_unpack.h"
/***************************************************** /*****************************************************

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later /* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2023 The TokTok team. * Copyright © 2023-2024 The TokTok team.
*/ */
#include "events_alloc.h" #include "events_alloc.h"
@ -11,9 +11,9 @@
#include "../bin_pack.h" #include "../bin_pack.h"
#include "../bin_unpack.h" #include "../bin_unpack.h"
#include "../ccompat.h" #include "../ccompat.h"
#include "../mem.h"
#include "../tox.h" #include "../tox.h"
#include "../tox_events.h" #include "../tox_events.h"
#include "../tox_unpack.h"
/***************************************************** /*****************************************************

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later /* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2023 The TokTok team. * Copyright © 2023-2024 The TokTok team.
*/ */
#include "events_alloc.h" #include "events_alloc.h"
@ -11,9 +11,9 @@
#include "../bin_pack.h" #include "../bin_pack.h"
#include "../bin_unpack.h" #include "../bin_unpack.h"
#include "../ccompat.h" #include "../ccompat.h"
#include "../mem.h"
#include "../tox.h" #include "../tox.h"
#include "../tox_events.h" #include "../tox_events.h"
#include "../tox_unpack.h"
/***************************************************** /*****************************************************

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later /* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2023 The TokTok team. * Copyright © 2023-2024 The TokTok team.
*/ */
#include "events_alloc.h" #include "events_alloc.h"
@ -11,9 +11,9 @@
#include "../bin_pack.h" #include "../bin_pack.h"
#include "../bin_unpack.h" #include "../bin_unpack.h"
#include "../ccompat.h" #include "../ccompat.h"
#include "../mem.h"
#include "../tox.h" #include "../tox.h"
#include "../tox_events.h" #include "../tox_events.h"
#include "../tox_unpack.h"
/***************************************************** /*****************************************************

View File

@ -1,16 +1,15 @@
/* SPDX-License-Identifier: GPL-3.0-or-later /* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2023 The TokTok team. * Copyright © 2023-2024 The TokTok team.
*/ */
#include "events_alloc.h" #include "events_alloc.h"
#include <assert.h> #include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "../bin_pack.h" #include "../bin_pack.h"
#include "../bin_unpack.h" #include "../bin_unpack.h"
#include "../ccompat.h" #include "../ccompat.h"
#include "../mem.h"
#include "../tox.h" #include "../tox.h"
#include "../tox_events.h" #include "../tox_events.h"
#include "../tox_unpack.h" #include "../tox_unpack.h"

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later /* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2023 The TokTok team. * Copyright © 2023-2024 The TokTok team.
*/ */
#include "events_alloc.h" #include "events_alloc.h"
@ -11,6 +11,7 @@
#include "../bin_pack.h" #include "../bin_pack.h"
#include "../bin_unpack.h" #include "../bin_unpack.h"
#include "../ccompat.h" #include "../ccompat.h"
#include "../mem.h"
#include "../tox.h" #include "../tox.h"
#include "../tox_events.h" #include "../tox_events.h"
#include "../tox_unpack.h" #include "../tox_unpack.h"

View File

@ -1,16 +1,15 @@
/* SPDX-License-Identifier: GPL-3.0-or-later /* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2023 The TokTok team. * Copyright © 2023-2024 The TokTok team.
*/ */
#include "events_alloc.h" #include "events_alloc.h"
#include <assert.h> #include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "../bin_pack.h" #include "../bin_pack.h"
#include "../bin_unpack.h" #include "../bin_unpack.h"
#include "../ccompat.h" #include "../ccompat.h"
#include "../mem.h"
#include "../tox.h" #include "../tox.h"
#include "../tox_events.h" #include "../tox_events.h"
#include "../tox_unpack.h" #include "../tox_unpack.h"

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later /* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2023 The TokTok team. * Copyright © 2023-2024 The TokTok team.
*/ */
#include "events_alloc.h" #include "events_alloc.h"
@ -11,9 +11,9 @@
#include "../bin_pack.h" #include "../bin_pack.h"
#include "../bin_unpack.h" #include "../bin_unpack.h"
#include "../ccompat.h" #include "../ccompat.h"
#include "../mem.h"
#include "../tox.h" #include "../tox.h"
#include "../tox_events.h" #include "../tox_events.h"
#include "../tox_unpack.h"
/***************************************************** /*****************************************************

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later /* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2023 The TokTok team. * Copyright © 2023-2024 The TokTok team.
*/ */
#include "events_alloc.h" #include "events_alloc.h"
@ -11,6 +11,7 @@
#include "../bin_pack.h" #include "../bin_pack.h"
#include "../bin_unpack.h" #include "../bin_unpack.h"
#include "../ccompat.h" #include "../ccompat.h"
#include "../mem.h"
#include "../tox.h" #include "../tox.h"
#include "../tox_events.h" #include "../tox_events.h"
#include "../tox_unpack.h" #include "../tox_unpack.h"

View File

@ -1,19 +1,17 @@
/* SPDX-License-Identifier: GPL-3.0-or-later /* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2023 The TokTok team. * Copyright © 2023-2024 The TokTok team.
*/ */
#include "events_alloc.h" #include "events_alloc.h"
#include <assert.h> #include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "../bin_pack.h" #include "../bin_pack.h"
#include "../bin_unpack.h" #include "../bin_unpack.h"
#include "../ccompat.h" #include "../ccompat.h"
#include "../mem.h"
#include "../tox.h" #include "../tox.h"
#include "../tox_events.h" #include "../tox_events.h"
#include "../tox_unpack.h"
/***************************************************** /*****************************************************

View File

@ -1,19 +1,17 @@
/* SPDX-License-Identifier: GPL-3.0-or-later /* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2023 The TokTok team. * Copyright © 2023-2024 The TokTok team.
*/ */
#include "events_alloc.h" #include "events_alloc.h"
#include <assert.h> #include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "../bin_pack.h" #include "../bin_pack.h"
#include "../bin_unpack.h" #include "../bin_unpack.h"
#include "../ccompat.h" #include "../ccompat.h"
#include "../mem.h"
#include "../tox.h" #include "../tox.h"
#include "../tox_events.h" #include "../tox_events.h"
#include "../tox_unpack.h"
/***************************************************** /*****************************************************

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later /* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2023 The TokTok team. * Copyright © 2023-2024 The TokTok team.
*/ */
#include "events_alloc.h" #include "events_alloc.h"
@ -11,9 +11,9 @@
#include "../bin_pack.h" #include "../bin_pack.h"
#include "../bin_unpack.h" #include "../bin_unpack.h"
#include "../ccompat.h" #include "../ccompat.h"
#include "../mem.h"
#include "../tox.h" #include "../tox.h"
#include "../tox_events.h" #include "../tox_events.h"
#include "../tox_unpack.h"
/***************************************************** /*****************************************************

View File

@ -1,16 +1,15 @@
/* SPDX-License-Identifier: GPL-3.0-or-later /* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2023 The TokTok team. * Copyright © 2023-2024 The TokTok team.
*/ */
#include "events_alloc.h" #include "events_alloc.h"
#include <assert.h> #include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "../bin_pack.h" #include "../bin_pack.h"
#include "../bin_unpack.h" #include "../bin_unpack.h"
#include "../ccompat.h" #include "../ccompat.h"
#include "../mem.h"
#include "../tox.h" #include "../tox.h"
#include "../tox_events.h" #include "../tox_events.h"
#include "../tox_unpack.h" #include "../tox_unpack.h"

View File

@ -1,16 +1,15 @@
/* SPDX-License-Identifier: GPL-3.0-or-later /* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2023 The TokTok team. * Copyright © 2023-2024 The TokTok team.
*/ */
#include "events_alloc.h" #include "events_alloc.h"
#include <assert.h> #include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "../bin_pack.h" #include "../bin_pack.h"
#include "../bin_unpack.h" #include "../bin_unpack.h"
#include "../ccompat.h" #include "../ccompat.h"
#include "../mem.h"
#include "../tox.h" #include "../tox.h"
#include "../tox_events.h" #include "../tox_events.h"
#include "../tox_unpack.h" #include "../tox_unpack.h"

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later /* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2023 The TokTok team. * Copyright © 2023-2024 The TokTok team.
*/ */
#include "events_alloc.h" #include "events_alloc.h"
@ -11,6 +11,7 @@
#include "../bin_pack.h" #include "../bin_pack.h"
#include "../bin_unpack.h" #include "../bin_unpack.h"
#include "../ccompat.h" #include "../ccompat.h"
#include "../mem.h"
#include "../tox.h" #include "../tox.h"
#include "../tox_events.h" #include "../tox_events.h"
#include "../tox_unpack.h" #include "../tox_unpack.h"

Some files were not shown because too many files have changed in this diff Show More