diff --git a/.gitignore b/.gitignore index a3e7af1e..c9bba8af 100644 --- a/.gitignore +++ b/.gitignore @@ -79,9 +79,8 @@ doc/Doxyfile *.swo # build dir -build/ -build_dev/ -.DS_Store/ +build +build_dev +.DS_Store build-*/ install/ - diff --git a/CMakeLists.txt b/CMakeLists.txt index 42439c85..7f3399fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.16..3.28) +cmake_minimum_required (VERSION 3.16..3.31) if(POLICY CMP0135) cmake_policy(SET CMP0135 NEW) endif() @@ -20,7 +20,7 @@ include(CTest) include(FetchContent) set (opendht_VERSION_MAJOR 3) -set (opendht_VERSION_MINOR 3.0) +set (opendht_VERSION_MINOR 4.0) set (opendht_VERSION ${opendht_VERSION_MAJOR}.${opendht_VERSION_MINOR}) set (PACKAGE_VERSION ${opendht_VERSION}) set (VERSION "${opendht_VERSION}") diff --git a/README.md b/README.md index 2c2aad9b..7137e7ac 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,7 @@ for r in results: IRC: join us on Libera.chat at [`#opendht`](https://web.libera.chat/#opendht). ## License -Copyright (C) 2014-2023 Savoir-faire Linux Inc. +Copyright (C) 2014-2025 Savoir-faire Linux Inc. OpenDHT is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. @@ -118,4 +118,4 @@ See COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html for the full GPLv3 l ## Acknowledgements This project was originally based on https://github.com/jech/dht by Juliusz Chroboczek. -It is independent from another project called OpenDHT (Sean Rhea. Ph.D. Thesis, 2005), now extinct. +It is independent from another (now extinct) project called OpenDHT (Sean Rhea. Ph.D. Thesis, 2005). diff --git a/c/opendht.cpp b/c/opendht.cpp index cf80546f..0ac831dc 100644 --- a/c/opendht.cpp +++ b/c/opendht.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author : Adrien Béraud * * This program is free software; you can redistribute it and/or modify diff --git a/c/opendht_c.h b/c/opendht_c.h index dd3750bf..137193d3 100644 --- a/c/opendht_c.h +++ b/c/opendht_c.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author : Adrien Béraud * * This program is free software; you can redistribute it and/or modify @@ -91,7 +91,7 @@ OPENDHT_C_PUBLIC dht_pkid dht_certificate_get_long_id(const dht_certificate*); OPENDHT_C_PUBLIC dht_publickey* dht_certificate_get_publickey(const dht_certificate*); OPENDHT_C_PUBLIC void dht_certificate_delete(dht_certificate*); -struct OPENDHT_PUBLIC dht_identity { +struct OPENDHT_C_PUBLIC dht_identity { dht_privatekey* privatekey; dht_certificate* certificate; }; diff --git a/configure.ac b/configure.ac index bdada013..b54d5b49 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ dnl define macros m4_define([opendht_major_version], 3) -m4_define([opendht_minor_version], 3) +m4_define([opendht_minor_version], 4) m4_define([opendht_patch_version], 0) m4_define([opendht_version], [opendht_major_version.opendht_minor_version.opendht_patch_version]) diff --git a/include/opendht.h b/include/opendht.h index 017fba43..107146d2 100644 --- a/include/opendht.h +++ b/include/opendht.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author : Adrien Béraud * * This program is free software; you can redistribute it and/or modify diff --git a/include/opendht/callbacks.h b/include/opendht/callbacks.h index 8303c410..2bce51d7 100644 --- a/include/opendht/callbacks.h +++ b/include/opendht/callbacks.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Authors: Adrien Béraud * Simon Désaulniers * Sébastien Blin diff --git a/include/opendht/crypto.h b/include/opendht/crypto.h index 6e8ff7a9..dd6fe736 100644 --- a/include/opendht/crypto.h +++ b/include/opendht/crypto.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author : Adrien Béraud * Vsevolod Ivanov * @@ -512,12 +512,18 @@ struct OPENDHT_PUBLIC Certificate { Blob getSerialNumber() const; + /** Read certificate full DN as described in RFC4514 */ + std::string getDN() const; + /** Read certificate Common Name (CN) */ std::string getName() const; /** Read certificate User ID (UID) */ std::string getUID() const; + /** Read certificate issuer DN as described in RFC4514 */ + std::string getIssuerDN() const; + /** Read certificate issuer Common Name (CN) */ std::string getIssuerName() const; @@ -748,7 +754,7 @@ OPENDHT_PUBLIC Blob aesGetSalt(const uint8_t* data, size_t data_length); OPENDHT_PUBLIC Blob inline aesGetSalt(const Blob& data) { return aesGetSalt(data.data(), data.size()); } -/** Get the encrypted data part of data password-encrypted with `aesEncrypt(data, password)` */ +/** Get the encrypted data (ciphertext) part of data password-encrypted with `aesEncrypt(data, password)` */ OPENDHT_PUBLIC std::string_view aesGetEncrypted(const uint8_t* data, size_t data_length); OPENDHT_PUBLIC std::string_view inline aesGetEncrypted(const Blob& data) { return aesGetEncrypted(data.data(), data.size()); diff --git a/include/opendht/crypto/secure_vector.h b/include/opendht/crypto/secure_vector.h index 1dfb5036..b69d6e2c 100644 --- a/include/opendht/crypto/secure_vector.h +++ b/include/opendht/crypto/secure_vector.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/include/opendht/default_types.h b/include/opendht/default_types.h index 007d5c6d..a54892c5 100644 --- a/include/opendht/default_types.h +++ b/include/opendht/default_types.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author : Adrien Béraud * * This program is free software; you can redistribute it and/or modify diff --git a/include/opendht/dht.h b/include/opendht/dht.h index b45fbab6..5413f4b7 100644 --- a/include/opendht/dht.h +++ b/include/opendht/dht.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Authors: Adrien Béraud * Simon Désaulniers * Sébastien Blin diff --git a/include/opendht/dht_interface.h b/include/opendht/dht_interface.h index 783b0371..2ccc80ee 100644 --- a/include/opendht/dht_interface.h +++ b/include/opendht/dht_interface.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author: Sébastien Blin * * This program is free software; you can redistribute it and/or modify diff --git a/include/opendht/dht_proxy_client.h b/include/opendht/dht_proxy_client.h index 21a9d81d..441f5faf 100644 --- a/include/opendht/dht_proxy_client.h +++ b/include/opendht/dht_proxy_client.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author: Sébastien Blin * Adrien Béraud * Vsevolod Ivanov diff --git a/include/opendht/dht_proxy_server.h b/include/opendht/dht_proxy_server.h index b87c47b4..926d6477 100644 --- a/include/opendht/dht_proxy_server.h +++ b/include/opendht/dht_proxy_server.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author: Sébastien Blin * Adrien Béraud * Vsevolod Ivanov diff --git a/include/opendht/dhtrunner.h b/include/opendht/dhtrunner.h index aa2d05d9..d8d960a6 100644 --- a/include/opendht/dhtrunner.h +++ b/include/opendht/dhtrunner.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Authors: Adrien Béraud * Simon Désaulniers * Sébastien Blin @@ -384,7 +384,7 @@ public: // securedht methods void findCertificate(InfoHash hash, std::function&)>); - void registerCertificate(std::shared_ptr cert); + void registerCertificate(const std::shared_ptr& cert); void setLocalCertificateStore(CertificateStoreQuery&& query_method); /** diff --git a/include/opendht/http.h b/include/opendht/http.h index 219fc5f6..8735e693 100644 --- a/include/opendht/http.h +++ b/include/opendht/http.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author: Vsevolod Ivanov * * This program is free software; you can redistribute it and/or modify diff --git a/include/opendht/indexation/pht.h b/include/opendht/indexation/pht.h index cfc3382c..ba1cb364 100644 --- a/include/opendht/indexation/pht.h +++ b/include/opendht/indexation/pht.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author(s) : Adrien Béraud * Simon Désaulniers * Nicolas Reynaud diff --git a/include/opendht/infohash.h b/include/opendht/infohash.h index 41f60fe8..7cfc0e1b 100644 --- a/include/opendht/infohash.h +++ b/include/opendht/infohash.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author : Adrien Béraud * * This program is free software; you can redistribute it and/or modify diff --git a/include/opendht/log.h b/include/opendht/log.h index 7c8e9ade..14a349a2 100644 --- a/include/opendht/log.h +++ b/include/opendht/log.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * * Author: Adrien Béraud * diff --git a/include/opendht/logger.h b/include/opendht/logger.h index af32a816..afc0895c 100644 --- a/include/opendht/logger.h +++ b/include/opendht/logger.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author : Adrien Béraud * * This program is free software; you can redistribute it and/or modify diff --git a/include/opendht/network_engine.h b/include/opendht/network_engine.h index 3d7f3280..a10e6b49 100644 --- a/include/opendht/network_engine.h +++ b/include/opendht/network_engine.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author(s) : Adrien Béraud * Simon Désaulniers * diff --git a/include/opendht/network_utils.h b/include/opendht/network_utils.h index 0994d4ae..4ed26525 100644 --- a/include/opendht/network_utils.h +++ b/include/opendht/network_utils.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author(s) : Adrien Béraud * * This program is free software; you can redistribute it and/or modify diff --git a/include/opendht/node.h b/include/opendht/node.h index dec8c75f..a692ea44 100644 --- a/include/opendht/node.h +++ b/include/opendht/node.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author(s) : Adrien Béraud * Simon Désaulniers * diff --git a/include/opendht/node_cache.h b/include/opendht/node_cache.h index 353eb73a..19224202 100644 --- a/include/opendht/node_cache.h +++ b/include/opendht/node_cache.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author(s) : Adrien Béraud * * This program is free software; you can redistribute it and/or modify diff --git a/include/opendht/node_export.h b/include/opendht/node_export.h index bb451acc..1b8f76b7 100644 --- a/include/opendht/node_export.h +++ b/include/opendht/node_export.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/include/opendht/peer_discovery.h b/include/opendht/peer_discovery.h index a22f4218..4f34dd8c 100644 --- a/include/opendht/peer_discovery.h +++ b/include/opendht/peer_discovery.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author(s) : Mingrui Zhang * Vsevolod Ivanov * @@ -49,10 +49,10 @@ public: * startDiscovery - Keep Listening data from the sender until node is joinned * or stop is called */ - void startDiscovery(const std::string &type, ServiceDiscoveredCallback callback); + void startDiscovery(std::string_view type, ServiceDiscoveredCallback callback); template - void startDiscovery(const std::string &type, std::function cb) { + void startDiscovery(std::string_view type, std::function cb) { startDiscovery(type, [cb](msgpack::object &&ob, SockAddr &&addr) { cb(ob.as(), std::move(addr)); }); @@ -61,11 +61,11 @@ public: /** * startPublish - Keeping sending data until node is joinned or stop is called */ - void startPublish(const std::string &type, const msgpack::sbuffer &pack_buf); - void startPublish(sa_family_t domain, const std::string &type, const msgpack::sbuffer &pack_buf); + void startPublish(std::string_view type, const msgpack::sbuffer &pack_buf); + void startPublish(sa_family_t domain, std::string_view type, const msgpack::sbuffer &pack_buf); template - void startPublish(const std::string &type, const T &object) { + void startPublish(std::string_view type, const T &object) { msgpack::sbuffer buf; msgpack::pack(buf, object); startPublish(type, buf); @@ -79,13 +79,13 @@ public: /** * Remove possible callBack to discovery */ - bool stopDiscovery(const std::string &type); + bool stopDiscovery(std::string_view type); /** * Remove different serivce message to send */ - bool stopPublish(const std::string &type); - bool stopPublish(sa_family_t domain, const std::string &type); + bool stopPublish(std::string_view type); + bool stopPublish(sa_family_t domain, std::string_view type); void connectivityChanged(); diff --git a/include/opendht/proxy.h b/include/opendht/proxy.h index 2274acbe..976a0ad1 100644 --- a/include/opendht/proxy.h +++ b/include/opendht/proxy.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author: Adrien Béraud * * This program is free software; you can redistribute it and/or modify diff --git a/include/opendht/rate_limiter.h b/include/opendht/rate_limiter.h index a7d45c0c..7f602a86 100644 --- a/include/opendht/rate_limiter.h +++ b/include/opendht/rate_limiter.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author : Adrien Béraud * * This program is free software; you can redistribute it and/or modify diff --git a/include/opendht/rng.h b/include/opendht/rng.h index a913c467..2677b01b 100644 --- a/include/opendht/rng.h +++ b/include/opendht/rng.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author : Adrien Béraud * * This program is free software; you can redistribute it and/or modify diff --git a/include/opendht/routing_table.h b/include/opendht/routing_table.h index 0a984815..66a2009a 100644 --- a/include/opendht/routing_table.h +++ b/include/opendht/routing_table.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author(s) : Adrien Béraud * Simon Désaulniers * diff --git a/include/opendht/scheduler.h b/include/opendht/scheduler.h index 6ed995e5..8b5880f7 100644 --- a/include/opendht/scheduler.h +++ b/include/opendht/scheduler.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author(s) : Adrien Béraud * Simon Désaulniers * diff --git a/include/opendht/securedht.h b/include/opendht/securedht.h index e057a72d..818d2ffe 100644 --- a/include/opendht/securedht.h +++ b/include/opendht/securedht.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Authors: Adrien Béraud * Simon Désaulniers * Sébastien Blin @@ -136,7 +136,7 @@ public: void findPublicKey(const InfoHash& node, const std::function)>& cb); Sp registerCertificate(const InfoHash& node, const Blob& cert); - void registerCertificate(Sp& cert); + void registerCertificate(const Sp& cert); Sp getCertificate(const InfoHash& node) const; Sp getPublicKey(const InfoHash& node) const; @@ -387,7 +387,7 @@ const ValueType CERTIFICATE_TYPE = { }, [](InfoHash, const Sp& o, Sp& n, const InfoHash&, const SockAddr&) { try { - return crypto::Certificate(o->data).getPublicKey().getId() == crypto::Certificate(n->data).getPublicKey().getId(); + return crypto::Certificate(o->data).getPublicKey().getLongId() == crypto::Certificate(n->data).getPublicKey().getLongId(); } catch (const std::exception& e) {} return false; } diff --git a/include/opendht/sockaddr.h b/include/opendht/sockaddr.h index 0003669c..da63d099 100644 --- a/include/opendht/sockaddr.h +++ b/include/opendht/sockaddr.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author : Adrien Béraud * * This program is free software; you can redistribute it and/or modify diff --git a/include/opendht/thread_pool.h b/include/opendht/thread_pool.h index 8b0ebfb2..e650c4a7 100644 --- a/include/opendht/thread_pool.h +++ b/include/opendht/thread_pool.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * * Author: Adrien Béraud * diff --git a/include/opendht/utils.h b/include/opendht/utils.h index c2650709..ed980181 100644 --- a/include/opendht/utils.h +++ b/include/opendht/utils.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author : Adrien Béraud * * This program is free software; you can redistribute it and/or modify diff --git a/include/opendht/value.h b/include/opendht/value.h index fda01094..8417fcbc 100644 --- a/include/opendht/value.h +++ b/include/opendht/value.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author(s) : Adrien Béraud * Simon Désaulniers * @@ -137,8 +137,6 @@ private: std::map types {}; }; -struct CryptoValueCache; - /** * A "value" is data potentially stored on the Dht, with some metadata. * diff --git a/meson.build b/meson.build index 1fb9c183..8678bf5b 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,5 @@ project('opendht', 'c', 'cpp', 'cython', - version: '3.3.0', + version: '3.4.0', default_options: [ 'cpp_std=c++17', 'warning_level=3' diff --git a/python/setup.py.in b/python/setup.py.in index 47de421b..3de80f52 100644 --- a/python/setup.py.in +++ b/python/setup.py.in @@ -1,4 +1,4 @@ -# Copyright (C) 2014-2023 Savoir-faire Linux Inc. +# Copyright (C) 2014-2025 Savoir-faire Linux Inc. # Author: Guillaume Roguez # Author: Adrien Béraud # diff --git a/python/tools/benchmark.py b/python/tools/benchmark.py index 2dfd8445..cace4543 100755 --- a/python/tools/benchmark.py +++ b/python/tools/benchmark.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -# Copyright (C) 2014-2023 Savoir-faire Linux Inc. +# Copyright (C) 2014-2025 Savoir-faire Linux Inc. # Author(s): Adrien Béraud # Simon Désaulniers # diff --git a/python/tools/dhtcluster.py b/python/tools/dhtcluster.py index 574d3bce..4c6cc5e0 100755 --- a/python/tools/dhtcluster.py +++ b/python/tools/dhtcluster.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -# Copyright (C) 2014-2023 Savoir-faire Linux Inc. +# Copyright (C) 2014-2025 Savoir-faire Linux Inc. # Author(s): Adrien Béraud # # This program is free software; you can redistribute it and/or modify diff --git a/rust/examples/dhtnode.rs b/rust/examples/dhtnode.rs index fdac0bbe..a971c470 100644 --- a/rust/examples/dhtnode.rs +++ b/rust/examples/dhtnode.rs @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author: Sébastien Blin * * This program is free software; you can redistribute it and/or modify diff --git a/rust/src/blob.rs b/rust/src/blob.rs index 9ef54356..8c95a007 100644 --- a/rust/src/blob.rs +++ b/rust/src/blob.rs @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author: Sébastien Blin * * This program is free software; you can redistribute it and/or modify diff --git a/rust/src/crypto.rs b/rust/src/crypto.rs index 16c23072..59ff3467 100644 --- a/rust/src/crypto.rs +++ b/rust/src/crypto.rs @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author: Sébastien Blin * * This program is free software; you can redistribute it and/or modify diff --git a/rust/src/dhtrunner.rs b/rust/src/dhtrunner.rs index 687ce82a..e6ba5404 100644 --- a/rust/src/dhtrunner.rs +++ b/rust/src/dhtrunner.rs @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author: Sébastien Blin * * This program is free software; you can redistribute it and/or modify diff --git a/rust/src/ffi.rs b/rust/src/ffi.rs index fb50b03a..211d9f2b 100644 --- a/rust/src/ffi.rs +++ b/rust/src/ffi.rs @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author: Sébastien Blin * * This program is free software; you can redistribute it and/or modify diff --git a/rust/src/infohash.rs b/rust/src/infohash.rs index 7ff9c1b8..8780f63f 100644 --- a/rust/src/infohash.rs +++ b/rust/src/infohash.rs @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author: Sébastien Blin * * This program is free software; you can redistribute it and/or modify diff --git a/rust/src/lib.rs b/rust/src/lib.rs index ce6b1ee1..c3d622ac 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author: Sébastien Blin * * This program is free software; you can redistribute it and/or modify diff --git a/rust/src/pkid.rs b/rust/src/pkid.rs index 83f72312..1b3498c0 100644 --- a/rust/src/pkid.rs +++ b/rust/src/pkid.rs @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author: Sébastien Blin * * This program is free software; you can redistribute it and/or modify diff --git a/rust/src/value.rs b/rust/src/value.rs index 1fab2ef3..e33917b8 100644 --- a/rust/src/value.rs +++ b/rust/src/value.rs @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author: Sébastien Blin * * This program is free software; you can redistribute it and/or modify diff --git a/src/Makefile.am b/src/Makefile.am index 7a11f204..e63782a9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -27,7 +27,7 @@ libopendht_la_SOURCES = \ default_types.cpp \ log.cpp \ network_utils.cpp \ - infohash.cpp \ + infohash.cpp \ thread_pool.cpp nobase_include_HEADERS = \ diff --git a/src/base64.cpp b/src/base64.cpp index 58af373b..963549b3 100644 --- a/src/base64.cpp +++ b/src/base64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/base64.h b/src/base64.h index 6363ec8a..80d04364 100644 --- a/src/base64.h +++ b/src/base64.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/callbacks.cpp b/src/callbacks.cpp index 759c6716..6b21f098 100644 --- a/src/callbacks.cpp +++ b/src/callbacks.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author(s) : Adrien Béraud * * This program is free software; you can redistribute it and/or modify diff --git a/src/compat/msvc/unistd.h b/src/compat/msvc/unistd.h index d43d4796..03687459 100644 --- a/src/compat/msvc/unistd.h +++ b/src/compat/msvc/unistd.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * * Author: Andreas Traczyk * diff --git a/src/compat/msvc/wingetopt.c b/src/compat/msvc/wingetopt.c deleted file mode 100644 index 79ba5fe7..00000000 --- a/src/compat/msvc/wingetopt.c +++ /dev/null @@ -1,971 +0,0 @@ -/* Getopt for Microsoft C -This code is a modification of the Free Software Foundation, Inc. -Getopt library for parsing command line argument the purpose was -to provide a Microsoft Visual C friendly derivative. This code -provides functionality for both Unicode and Multibyte builds. -Date: 02/03/2011 - Ludvik Jerabek - Initial Release -Version: 1.0 -Comment: Supports getopt, getopt_long, and getopt_long_only -and POSIXLY_CORRECT environment flag -License: LGPL -Revisions: -02/03/2011 - Ludvik Jerabek - Initial Release -02/20/2011 - Ludvik Jerabek - Fixed compiler warnings at Level 4 -07/05/2011 - Ludvik Jerabek - Added no_argument, required_argument, optional_argument defs -08/03/2011 - Ludvik Jerabek - Fixed non-argument runtime bug which caused runtime exception -08/09/2011 - Ludvik Jerabek - Added code to export functions for DLL and LIB -02/15/2012 - Ludvik Jerabek - Fixed _GETOPT_THROW definition missing in implementation file -08/01/2012 - Ludvik Jerabek - Created separate functions for char and wchar_t characters so single dll can do both unicode and ansi -10/15/2012 - Ludvik Jerabek - Modified to match latest GNU features -06/19/2015 - Ludvik Jerabek - Fixed maximum option limitation caused by option_a (255) and option_w (65535) structure val variable -**DISCLAIMER** -THIS MATERIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, -EITHER EXPRESS OR IMPLIED, INCLUDING, BUT Not LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -PURPOSE, OR NON-INFRINGEMENT. SOME JURISDICTIONS DO NOT ALLOW THE -EXCLUSION OF IMPLIED WARRANTIES, SO THE ABOVE EXCLUSION MAY NOT -APPLY TO YOU. IN NO EVENT WILL I BE LIABLE TO ANY PARTY FOR ANY -DIRECT, INDIRECT, SPECIAL OR OTHER CONSEQUENTIAL DAMAGES FOR ANY -USE OF THIS MATERIAL INCLUDING, WITHOUT LIMITATION, ANY LOST -PROFITS, BUSINESS INTERRUPTION, LOSS OF PROGRAMS OR OTHER DATA ON -YOUR INFORMATION HANDLING SYSTEM OR OTHERWISE, EVEN If WE ARE -EXPRESSLY ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -*/ -#ifndef _CRT_SECURE_NO_WARNINGS -# define _CRT_SECURE_NO_WARNINGS -#endif -#include -#include -#include -#include "wingetopt.h" - -#ifdef __cplusplus - #define _GETOPT_THROW throw() -#else - #define _GETOPT_THROW -#endif - -int optind = 1; -int opterr = 1; -int optopt = '?'; -enum ENUM_ORDERING { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER }; - -// -// -// Ansi structures and functions follow -// -// - -static struct _getopt_data_a -{ - int optind; - int opterr; - int optopt; - char *optarg; - int __initialized; - char *__nextchar; - enum ENUM_ORDERING __ordering; - int __posixly_correct; - int __first_nonopt; - int __last_nonopt; -} getopt_data_a; -char *optarg_a; - -static void exchange_a(char **argv, struct _getopt_data_a *d) -{ - int bottom = d->__first_nonopt; - int middle = d->__last_nonopt; - int top = d->optind; - char *tem; - while (top > middle && middle > bottom) - { - if (top - middle > middle - bottom) - { - int len = middle - bottom; - register int i; - for (i = 0; i < len; i++) - { - tem = argv[bottom + i]; - argv[bottom + i] = argv[top - (middle - bottom) + i]; - argv[top - (middle - bottom) + i] = tem; - } - top -= len; - } - else - { - int len = top - middle; - register int i; - for (i = 0; i < len; i++) - { - tem = argv[bottom + i]; - argv[bottom + i] = argv[middle + i]; - argv[middle + i] = tem; - } - bottom += len; - } - } - d->__first_nonopt += (d->optind - d->__last_nonopt); - d->__last_nonopt = d->optind; -} -static const char *_getopt_initialize_a (const char *optstring, struct _getopt_data_a *d, int posixly_correct) -{ - d->__first_nonopt = d->__last_nonopt = d->optind; - d->__nextchar = NULL; - d->__posixly_correct = posixly_correct | !!getenv("POSIXLY_CORRECT"); - if (optstring[0] == '-') - { - d->__ordering = RETURN_IN_ORDER; - ++optstring; - } - else if (optstring[0] == '+') - { - d->__ordering = REQUIRE_ORDER; - ++optstring; - } - else if (d->__posixly_correct) - d->__ordering = REQUIRE_ORDER; - else - d->__ordering = PERMUTE; - return optstring; -} -int _getopt_internal_r_a (int argc, char *const *argv, const char *optstring, const struct option_a *longopts, int *longind, int long_only, struct _getopt_data_a *d, int posixly_correct) -{ - int print_errors = d->opterr; - if (argc < 1) - return -1; - d->optarg = NULL; - if (d->optind == 0 || !d->__initialized) - { - if (d->optind == 0) - d->optind = 1; - optstring = _getopt_initialize_a (optstring, d, posixly_correct); - d->__initialized = 1; - } - else if (optstring[0] == '-' || optstring[0] == '+') - optstring++; - if (optstring[0] == ':') - print_errors = 0; - if (d->__nextchar == NULL || *d->__nextchar == '\0') - { - if (d->__last_nonopt > d->optind) - d->__last_nonopt = d->optind; - if (d->__first_nonopt > d->optind) - d->__first_nonopt = d->optind; - if (d->__ordering == PERMUTE) - { - if (d->__first_nonopt != d->__last_nonopt && d->__last_nonopt != d->optind) - exchange_a ((char **) argv, d); - else if (d->__last_nonopt != d->optind) - d->__first_nonopt = d->optind; - while (d->optind < argc && (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0')) - d->optind++; - d->__last_nonopt = d->optind; - } - if (d->optind != argc && !strcmp(argv[d->optind], "--")) - { - d->optind++; - if (d->__first_nonopt != d->__last_nonopt && d->__last_nonopt != d->optind) - exchange_a((char **) argv, d); - else if (d->__first_nonopt == d->__last_nonopt) - d->__first_nonopt = d->optind; - d->__last_nonopt = argc; - d->optind = argc; - } - if (d->optind == argc) - { - if (d->__first_nonopt != d->__last_nonopt) - d->optind = d->__first_nonopt; - return -1; - } - if ((argv[d->optind][0] != '-' || argv[d->optind][1] == '\0')) - { - if (d->__ordering == REQUIRE_ORDER) - return -1; - d->optarg = argv[d->optind++]; - return 1; - } - d->__nextchar = (argv[d->optind] + 1 + (longopts != NULL && argv[d->optind][1] == '-')); - } - if (longopts != NULL && (argv[d->optind][1] == '-' || (long_only && (argv[d->optind][2] || !strchr(optstring, argv[d->optind][1]))))) - { - char *nameend; - unsigned int namelen; - const struct option_a *p; - const struct option_a *pfound = NULL; - struct option_list - { - const struct option_a *p; - struct option_list *next; - } *ambig_list = NULL; - int exact = 0; - int indfound = -1; - int option_index; - for (nameend = d->__nextchar; *nameend && *nameend != '='; nameend++); - namelen = (unsigned int)(nameend - d->__nextchar); - for (p = longopts, option_index = 0; p->name; p++, option_index++) - if (!strncmp(p->name, d->__nextchar, namelen)) - { - if (namelen == (unsigned int)strlen(p->name)) - { - pfound = p; - indfound = option_index; - exact = 1; - break; - } - else if (pfound == NULL) - { - pfound = p; - indfound = option_index; - } - else if (long_only || pfound->has_arg != p->has_arg || pfound->flag != p->flag || pfound->val != p->val) - { - struct option_list *newp = (struct option_list*)alloca(sizeof(*newp)); - newp->p = p; - newp->next = ambig_list; - ambig_list = newp; - } - } - if (ambig_list != NULL && !exact) - { - if (print_errors) - { - struct option_list first; - first.p = pfound; - first.next = ambig_list; - ambig_list = &first; - fprintf (stderr, "%s: option '%s' is ambiguous; possibilities:", argv[0], argv[d->optind]); - do - { - fprintf (stderr, " '--%s'", ambig_list->p->name); - ambig_list = ambig_list->next; - } - while (ambig_list != NULL); - fputc ('\n', stderr); - } - d->__nextchar += strlen(d->__nextchar); - d->optind++; - d->optopt = 0; - return '?'; - } - if (pfound != NULL) - { - option_index = indfound; - d->optind++; - if (*nameend) - { - if (pfound->has_arg) - d->optarg = nameend + 1; - else - { - if (print_errors) - { - if (argv[d->optind - 1][1] == '-') - { - fprintf(stderr, "%s: option '--%s' doesn't allow an argument\n",argv[0], pfound->name); - } - else - { - fprintf(stderr, "%s: option '%c%s' doesn't allow an argument\n",argv[0], argv[d->optind - 1][0],pfound->name); - } - } - d->__nextchar += strlen(d->__nextchar); - d->optopt = pfound->val; - return '?'; - } - } - else if (pfound->has_arg == 1) - { - if (d->optind < argc) - d->optarg = argv[d->optind++]; - else - { - if (print_errors) - { - fprintf(stderr,"%s: option '--%s' requires an argument\n",argv[0], pfound->name); - } - d->__nextchar += strlen(d->__nextchar); - d->optopt = pfound->val; - return optstring[0] == ':' ? ':' : '?'; - } - } - d->__nextchar += strlen(d->__nextchar); - if (longind != NULL) - *longind = option_index; - if (pfound->flag) - { - *(pfound->flag) = pfound->val; - return 0; - } - return pfound->val; - } - if (!long_only || argv[d->optind][1] == '-' || strchr(optstring, *d->__nextchar) == NULL) - { - if (print_errors) - { - if (argv[d->optind][1] == '-') - { - fprintf(stderr, "%s: unrecognized option '--%s'\n",argv[0], d->__nextchar); - } - else - { - fprintf(stderr, "%s: unrecognized option '%c%s'\n",argv[0], argv[d->optind][0], d->__nextchar); - } - } - d->__nextchar = (char *)""; - d->optind++; - d->optopt = 0; - return '?'; - } - } - { - char c = *d->__nextchar++; - char *temp = (char*)strchr(optstring, c); - if (*d->__nextchar == '\0') - ++d->optind; - if (temp == NULL || c == ':' || c == ';') - { - if (print_errors) - { - fprintf(stderr, "%s: invalid option -- '%c'\n", argv[0], c); - } - d->optopt = c; - return '?'; - } - if (temp[0] == 'W' && temp[1] == ';') - { - char *nameend; - const struct option_a *p; - const struct option_a *pfound = NULL; - int exact = 0; - int ambig = 0; - int indfound = 0; - int option_index; - if (longopts == NULL) - goto no_longs; - if (*d->__nextchar != '\0') - { - d->optarg = d->__nextchar; - d->optind++; - } - else if (d->optind == argc) - { - if (print_errors) - { - fprintf(stderr,"%s: option requires an argument -- '%c'\n",argv[0], c); - } - d->optopt = c; - if (optstring[0] == ':') - c = ':'; - else - c = '?'; - return c; - } - else - d->optarg = argv[d->optind++]; - for (d->__nextchar = nameend = d->optarg; *nameend && *nameend != '='; nameend++); - for (p = longopts, option_index = 0; p->name; p++, option_index++) - if (!strncmp(p->name, d->__nextchar, nameend - d->__nextchar)) - { - if ((unsigned int) (nameend - d->__nextchar) == strlen(p->name)) - { - pfound = p; - indfound = option_index; - exact = 1; - break; - } - else if (pfound == NULL) - { - pfound = p; - indfound = option_index; - } - else if (long_only || pfound->has_arg != p->has_arg || pfound->flag != p->flag || pfound->val != p->val) - ambig = 1; - } - if (ambig && !exact) - { - if (print_errors) - { - fprintf(stderr, "%s: option '-W %s' is ambiguous\n",argv[0], d->optarg); - } - d->__nextchar += strlen(d->__nextchar); - d->optind++; - return '?'; - } - if (pfound != NULL) - { - option_index = indfound; - if (*nameend) - { - if (pfound->has_arg) - d->optarg = nameend + 1; - else - { - if (print_errors) - { - fprintf(stderr, "%s: option '-W %s' doesn't allow an argument\n",argv[0], pfound->name); - } - d->__nextchar += strlen(d->__nextchar); - return '?'; - } - } - else if (pfound->has_arg == 1) - { - if (d->optind < argc) - d->optarg = argv[d->optind++]; - else - { - if (print_errors) - { - fprintf(stderr, "%s: option '-W %s' requires an argument\n",argv[0], pfound->name); - } - d->__nextchar += strlen(d->__nextchar); - return optstring[0] == ':' ? ':' : '?'; - } - } - else - d->optarg = NULL; - d->__nextchar += strlen(d->__nextchar); - if (longind != NULL) - *longind = option_index; - if (pfound->flag) - { - *(pfound->flag) = pfound->val; - return 0; - } - return pfound->val; - } -no_longs: - d->__nextchar = NULL; - return 'W'; - } - if (temp[1] == ':') - { - if (temp[2] == ':') - { - if (*d->__nextchar != '\0') - { - d->optarg = d->__nextchar; - d->optind++; - } - else - d->optarg = NULL; - d->__nextchar = NULL; - } - else - { - if (*d->__nextchar != '\0') - { - d->optarg = d->__nextchar; - d->optind++; - } - else if (d->optind == argc) - { - if (print_errors) - { - fprintf(stderr,"%s: option requires an argument -- '%c'\n",argv[0], c); - } - d->optopt = c; - if (optstring[0] == ':') - c = ':'; - else - c = '?'; - } - else - d->optarg = argv[d->optind++]; - d->__nextchar = NULL; - } - } - return c; - } -} -int _getopt_internal_a (int argc, char *const *argv, const char *optstring, const struct option_a *longopts, int *longind, int long_only, int posixly_correct) -{ - int result; - getopt_data_a.optind = optind; - getopt_data_a.opterr = opterr; - result = _getopt_internal_r_a (argc, argv, optstring, longopts,longind, long_only, &getopt_data_a,posixly_correct); - optind = getopt_data_a.optind; - optarg_a = getopt_data_a.optarg; - optopt = getopt_data_a.optopt; - return result; -} -int getopt_a (int argc, char *const *argv, const char *optstring) _GETOPT_THROW -{ - return _getopt_internal_a (argc, argv, optstring, (const struct option_a *) 0, (int *) 0, 0, 0); -} -int getopt_long_a (int argc, char *const *argv, const char *options, const struct option_a *long_options, int *opt_index) _GETOPT_THROW -{ - return _getopt_internal_a (argc, argv, options, long_options, opt_index, 0, 0); -} -int getopt_long_only_a (int argc, char *const *argv, const char *options, const struct option_a *long_options, int *opt_index) _GETOPT_THROW -{ - return _getopt_internal_a (argc, argv, options, long_options, opt_index, 1, 0); -} -int _getopt_long_r_a (int argc, char *const *argv, const char *options, const struct option_a *long_options, int *opt_index, struct _getopt_data_a *d) -{ - return _getopt_internal_r_a (argc, argv, options, long_options, opt_index,0, d, 0); -} -int _getopt_long_only_r_a (int argc, char *const *argv, const char *options, const struct option_a *long_options, int *opt_index, struct _getopt_data_a *d) -{ - return _getopt_internal_r_a (argc, argv, options, long_options, opt_index, 1, d, 0); -} - -// -// -// Unicode Structures and Functions -// -// - -static struct _getopt_data_w -{ - int optind; - int opterr; - int optopt; - wchar_t *optarg; - int __initialized; - wchar_t *__nextchar; - enum ENUM_ORDERING __ordering; - int __posixly_correct; - int __first_nonopt; - int __last_nonopt; -} getopt_data_w; -wchar_t *optarg_w; - -static void exchange_w(wchar_t **argv, struct _getopt_data_w *d) -{ - int bottom = d->__first_nonopt; - int middle = d->__last_nonopt; - int top = d->optind; - wchar_t *tem; - while (top > middle && middle > bottom) - { - if (top - middle > middle - bottom) - { - int len = middle - bottom; - register int i; - for (i = 0; i < len; i++) - { - tem = argv[bottom + i]; - argv[bottom + i] = argv[top - (middle - bottom) + i]; - argv[top - (middle - bottom) + i] = tem; - } - top -= len; - } - else - { - int len = top - middle; - register int i; - for (i = 0; i < len; i++) - { - tem = argv[bottom + i]; - argv[bottom + i] = argv[middle + i]; - argv[middle + i] = tem; - } - bottom += len; - } - } - d->__first_nonopt += (d->optind - d->__last_nonopt); - d->__last_nonopt = d->optind; -} -static const wchar_t *_getopt_initialize_w (const wchar_t *optstring, struct _getopt_data_w *d, int posixly_correct) -{ - d->__first_nonopt = d->__last_nonopt = d->optind; - d->__nextchar = NULL; - d->__posixly_correct = posixly_correct | !!_wgetenv(L"POSIXLY_CORRECT"); - if (optstring[0] == L'-') - { - d->__ordering = RETURN_IN_ORDER; - ++optstring; - } - else if (optstring[0] == L'+') - { - d->__ordering = REQUIRE_ORDER; - ++optstring; - } - else if (d->__posixly_correct) - d->__ordering = REQUIRE_ORDER; - else - d->__ordering = PERMUTE; - return optstring; -} -int _getopt_internal_r_w (int argc, wchar_t *const *argv, const wchar_t *optstring, const struct option_w *longopts, int *longind, int long_only, struct _getopt_data_w *d, int posixly_correct) -{ - int print_errors = d->opterr; - if (argc < 1) - return -1; - d->optarg = NULL; - if (d->optind == 0 || !d->__initialized) - { - if (d->optind == 0) - d->optind = 1; - optstring = _getopt_initialize_w (optstring, d, posixly_correct); - d->__initialized = 1; - } - else if (optstring[0] == L'-' || optstring[0] == L'+') - optstring++; - if (optstring[0] == L':') - print_errors = 0; - if (d->__nextchar == NULL || *d->__nextchar == L'\0') - { - if (d->__last_nonopt > d->optind) - d->__last_nonopt = d->optind; - if (d->__first_nonopt > d->optind) - d->__first_nonopt = d->optind; - if (d->__ordering == PERMUTE) - { - if (d->__first_nonopt != d->__last_nonopt && d->__last_nonopt != d->optind) - exchange_w((wchar_t **) argv, d); - else if (d->__last_nonopt != d->optind) - d->__first_nonopt = d->optind; - while (d->optind < argc && (argv[d->optind][0] != L'-' || argv[d->optind][1] == L'\0')) - d->optind++; - d->__last_nonopt = d->optind; - } - if (d->optind != argc && !wcscmp(argv[d->optind], L"--")) - { - d->optind++; - if (d->__first_nonopt != d->__last_nonopt && d->__last_nonopt != d->optind) - exchange_w((wchar_t **) argv, d); - else if (d->__first_nonopt == d->__last_nonopt) - d->__first_nonopt = d->optind; - d->__last_nonopt = argc; - d->optind = argc; - } - if (d->optind == argc) - { - if (d->__first_nonopt != d->__last_nonopt) - d->optind = d->__first_nonopt; - return -1; - } - if ((argv[d->optind][0] != L'-' || argv[d->optind][1] == L'\0')) - { - if (d->__ordering == REQUIRE_ORDER) - return -1; - d->optarg = argv[d->optind++]; - return 1; - } - d->__nextchar = (argv[d->optind] + 1 + (longopts != NULL && argv[d->optind][1] == L'-')); - } - if (longopts != NULL && (argv[d->optind][1] == L'-' || (long_only && (argv[d->optind][2] || !wcschr(optstring, argv[d->optind][1]))))) - { - wchar_t *nameend; - unsigned int namelen; - const struct option_w *p; - const struct option_w *pfound = NULL; - struct option_list - { - const struct option_w *p; - struct option_list *next; - } *ambig_list = NULL; - int exact = 0; - int indfound = -1; - int option_index; - for (nameend = d->__nextchar; *nameend && *nameend != L'='; nameend++); - namelen = (unsigned int)(nameend - d->__nextchar); - for (p = longopts, option_index = 0; p->name; p++, option_index++) - if (!wcsncmp(p->name, d->__nextchar, namelen)) - { - if (namelen == (unsigned int)wcslen(p->name)) - { - pfound = p; - indfound = option_index; - exact = 1; - break; - } - else if (pfound == NULL) - { - pfound = p; - indfound = option_index; - } - else if (long_only || pfound->has_arg != p->has_arg || pfound->flag != p->flag || pfound->val != p->val) - { - struct option_list *newp = (struct option_list*)alloca(sizeof(*newp)); - newp->p = p; - newp->next = ambig_list; - ambig_list = newp; - } - } - if (ambig_list != NULL && !exact) - { - if (print_errors) - { - struct option_list first; - first.p = pfound; - first.next = ambig_list; - ambig_list = &first; - fwprintf(stderr, L"%s: option '%s' is ambiguous; possibilities:", argv[0], argv[d->optind]); - do - { - fwprintf (stderr, L" '--%s'", ambig_list->p->name); - ambig_list = ambig_list->next; - } - while (ambig_list != NULL); - fputwc (L'\n', stderr); - } - d->__nextchar += wcslen(d->__nextchar); - d->optind++; - d->optopt = 0; - return L'?'; - } - if (pfound != NULL) - { - option_index = indfound; - d->optind++; - if (*nameend) - { - if (pfound->has_arg) - d->optarg = nameend + 1; - else - { - if (print_errors) - { - if (argv[d->optind - 1][1] == L'-') - { - fwprintf(stderr, L"%s: option '--%s' doesn't allow an argument\n",argv[0], pfound->name); - } - else - { - fwprintf(stderr, L"%s: option '%c%s' doesn't allow an argument\n",argv[0], argv[d->optind - 1][0],pfound->name); - } - } - d->__nextchar += wcslen(d->__nextchar); - d->optopt = pfound->val; - return L'?'; - } - } - else if (pfound->has_arg == 1) - { - if (d->optind < argc) - d->optarg = argv[d->optind++]; - else - { - if (print_errors) - { - fwprintf(stderr,L"%s: option '--%s' requires an argument\n",argv[0], pfound->name); - } - d->__nextchar += wcslen(d->__nextchar); - d->optopt = pfound->val; - return optstring[0] == L':' ? L':' : L'?'; - } - } - d->__nextchar += wcslen(d->__nextchar); - if (longind != NULL) - *longind = option_index; - if (pfound->flag) - { - *(pfound->flag) = pfound->val; - return 0; - } - return pfound->val; - } - if (!long_only || argv[d->optind][1] == L'-' || wcschr(optstring, *d->__nextchar) == NULL) - { - if (print_errors) - { - if (argv[d->optind][1] == L'-') - { - fwprintf(stderr, L"%s: unrecognized option '--%s'\n",argv[0], d->__nextchar); - } - else - { - fwprintf(stderr, L"%s: unrecognized option '%c%s'\n",argv[0], argv[d->optind][0], d->__nextchar); - } - } - d->__nextchar = (wchar_t *)L""; - d->optind++; - d->optopt = 0; - return L'?'; - } - } - { - wchar_t c = *d->__nextchar++; - wchar_t *temp = (wchar_t*)wcschr(optstring, c); - if (*d->__nextchar == L'\0') - ++d->optind; - if (temp == NULL || c == L':' || c == L';') - { - if (print_errors) - { - fwprintf(stderr, L"%s: invalid option -- '%c'\n", argv[0], c); - } - d->optopt = c; - return L'?'; - } - if (temp[0] == L'W' && temp[1] == L';') - { - wchar_t *nameend; - const struct option_w *p; - const struct option_w *pfound = NULL; - int exact = 0; - int ambig = 0; - int indfound = 0; - int option_index; - if (longopts == NULL) - goto no_longs; - if (*d->__nextchar != L'\0') - { - d->optarg = d->__nextchar; - d->optind++; - } - else if (d->optind == argc) - { - if (print_errors) - { - fwprintf(stderr,L"%s: option requires an argument -- '%c'\n",argv[0], c); - } - d->optopt = c; - if (optstring[0] == L':') - c = L':'; - else - c = L'?'; - return c; - } - else - d->optarg = argv[d->optind++]; - for (d->__nextchar = nameend = d->optarg; *nameend && *nameend != L'='; nameend++); - for (p = longopts, option_index = 0; p->name; p++, option_index++) - if (!wcsncmp(p->name, d->__nextchar, nameend - d->__nextchar)) - { - if ((unsigned int) (nameend - d->__nextchar) == wcslen(p->name)) - { - pfound = p; - indfound = option_index; - exact = 1; - break; - } - else if (pfound == NULL) - { - pfound = p; - indfound = option_index; - } - else if (long_only || pfound->has_arg != p->has_arg || pfound->flag != p->flag || pfound->val != p->val) - ambig = 1; - } - if (ambig && !exact) - { - if (print_errors) - { - fwprintf(stderr, L"%s: option '-W %s' is ambiguous\n",argv[0], d->optarg); - } - d->__nextchar += wcslen(d->__nextchar); - d->optind++; - return L'?'; - } - if (pfound != NULL) - { - option_index = indfound; - if (*nameend) - { - if (pfound->has_arg) - d->optarg = nameend + 1; - else - { - if (print_errors) - { - fwprintf(stderr, L"%s: option '-W %s' doesn't allow an argument\n",argv[0], pfound->name); - } - d->__nextchar += wcslen(d->__nextchar); - return L'?'; - } - } - else if (pfound->has_arg == 1) - { - if (d->optind < argc) - d->optarg = argv[d->optind++]; - else - { - if (print_errors) - { - fwprintf(stderr, L"%s: option '-W %s' requires an argument\n",argv[0], pfound->name); - } - d->__nextchar += wcslen(d->__nextchar); - return optstring[0] == L':' ? L':' : L'?'; - } - } - else - d->optarg = NULL; - d->__nextchar += wcslen(d->__nextchar); - if (longind != NULL) - *longind = option_index; - if (pfound->flag) - { - *(pfound->flag) = pfound->val; - return 0; - } - return pfound->val; - } -no_longs: - d->__nextchar = NULL; - return L'W'; - } - if (temp[1] == L':') - { - if (temp[2] == L':') - { - if (*d->__nextchar != L'\0') - { - d->optarg = d->__nextchar; - d->optind++; - } - else - d->optarg = NULL; - d->__nextchar = NULL; - } - else - { - if (*d->__nextchar != L'\0') - { - d->optarg = d->__nextchar; - d->optind++; - } - else if (d->optind == argc) - { - if (print_errors) - { - fwprintf(stderr,L"%s: option requires an argument -- '%c'\n",argv[0], c); - } - d->optopt = c; - if (optstring[0] == L':') - c = L':'; - else - c = L'?'; - } - else - d->optarg = argv[d->optind++]; - d->__nextchar = NULL; - } - } - return c; - } -} -int _getopt_internal_w (int argc, wchar_t *const *argv, const wchar_t *optstring, const struct option_w *longopts, int *longind, int long_only, int posixly_correct) -{ - int result; - getopt_data_w.optind = optind; - getopt_data_w.opterr = opterr; - result = _getopt_internal_r_w (argc, argv, optstring, longopts,longind, long_only, &getopt_data_w,posixly_correct); - optind = getopt_data_w.optind; - optarg_w = getopt_data_w.optarg; - optopt = getopt_data_w.optopt; - return result; -} -int getopt_w (int argc, wchar_t *const *argv, const wchar_t *optstring) _GETOPT_THROW -{ - return _getopt_internal_w (argc, argv, optstring, (const struct option_w *) 0, (int *) 0, 0, 0); -} -int getopt_long_w (int argc, wchar_t *const *argv, const wchar_t *options, const struct option_w *long_options, int *opt_index) _GETOPT_THROW -{ - return _getopt_internal_w (argc, argv, options, long_options, opt_index, 0, 0); -} -int getopt_long_only_w (int argc, wchar_t *const *argv, const wchar_t *options, const struct option_w *long_options, int *opt_index) _GETOPT_THROW -{ - return _getopt_internal_w (argc, argv, options, long_options, opt_index, 1, 0); -} -int _getopt_long_r_w (int argc, wchar_t *const *argv, const wchar_t *options, const struct option_w *long_options, int *opt_index, struct _getopt_data_w *d) -{ - return _getopt_internal_r_w (argc, argv, options, long_options, opt_index,0, d, 0); -} -int _getopt_long_only_r_w (int argc, wchar_t *const *argv, const wchar_t *options, const struct option_w *long_options, int *opt_index, struct _getopt_data_w *d) -{ - return _getopt_internal_r_w (argc, argv, options, long_options, opt_index, 1, d, 0); -} \ No newline at end of file diff --git a/src/compat/msvc/wingetopt.h b/src/compat/msvc/wingetopt.h deleted file mode 100644 index bf1864a2..00000000 --- a/src/compat/msvc/wingetopt.h +++ /dev/null @@ -1,97 +0,0 @@ -#ifndef __WINGETOPT_H_ - #define __WINGETOPT_H_ - - #ifdef _GETOPT_API - #undef _GETOPT_API - #endif - - #if defined(EXPORTS_GETOPT) && defined(STATIC_GETOPT) - #error "The preprocessor definitions of EXPORTS_GETOPT and STATIC_GETOPT can only be used individually" - #elif defined(STATIC_GETOPT) - #define _GETOPT_API - #elif defined(EXPORTS_GETOPT) - #define _GETOPT_API __declspec(dllexport) - #else - #define _GETOPT_API __declspec(dllimport) - #endif - - // Change behavior for C\C++ - #ifdef __cplusplus - #define _BEGIN_EXTERN_C extern "C" { - #define _END_EXTERN_C } - #define _GETOPT_THROW throw() - #else - #define _BEGIN_EXTERN_C - #define _END_EXTERN_C - #define _GETOPT_THROW - #endif - - // Standard GNU options - #define null_argument 0 /*Argument Null*/ - #define no_argument 0 /*Argument Switch Only*/ - #define required_argument 1 /*Argument Required*/ - #define optional_argument 2 /*Argument Optional*/ - - - // Shorter Options - #define ARG_NULL 0 /*Argument Null*/ - #define ARG_NONE 0 /*Argument Switch Only*/ - #define ARG_REQ 1 /*Argument Required*/ - #define ARG_OPT 2 /*Argument Optional*/ - - #include - #include - -_BEGIN_EXTERN_C - - extern _GETOPT_API int optind; - extern _GETOPT_API int opterr; - extern _GETOPT_API int optopt; - - // Ansi - struct option_a - { - const char* name; - int has_arg; - int *flag; - int val; - }; - extern _GETOPT_API char *optarg_a; - extern _GETOPT_API int getopt_a(int argc, char *const *argv, const char *optstring) _GETOPT_THROW; - extern _GETOPT_API int getopt_long_a(int argc, char *const *argv, const char *options, const struct option_a *long_options, int *opt_index) _GETOPT_THROW; - extern _GETOPT_API int getopt_long_only_a(int argc, char *const *argv, const char *options, const struct option_a *long_options, int *opt_index) _GETOPT_THROW; - - // Unicode - struct option_w - { - const wchar_t* name; - int has_arg; - int *flag; - int val; - }; - extern _GETOPT_API wchar_t *optarg_w; - extern _GETOPT_API int getopt_w(int argc, wchar_t *const *argv, const wchar_t *optstring) _GETOPT_THROW; - extern _GETOPT_API int getopt_long_w(int argc, wchar_t *const *argv, const wchar_t *options, const struct option_w *long_options, int *opt_index) _GETOPT_THROW; - extern _GETOPT_API int getopt_long_only_w(int argc, wchar_t *const *argv, const wchar_t *options, const struct option_w *long_options, int *opt_index) _GETOPT_THROW; - -_END_EXTERN_C - - #undef _BEGIN_EXTERN_C - #undef _END_EXTERN_C - #undef _GETOPT_THROW - #undef _GETOPT_API - - #ifdef _UNICODE - #define getopt getopt_w - #define getopt_long getopt_long_w - #define getopt_long_only getopt_long_only_w - #define option option_w - #define optarg optarg_w - #else - #define getopt getopt_a - #define getopt_long getopt_long_a - #define getopt_long_only getopt_long_only_a - #define option option_a - #define optarg optarg_a - #endif -#endif // __WINGETOPT_H_ \ No newline at end of file diff --git a/src/compat/os_cert.cpp b/src/compat/os_cert.cpp index 1bf84c33..d8ed6a30 100644 --- a/src/compat/os_cert.cpp +++ b/src/compat/os_cert.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author: Andreas Traczyk * * This program is free software; you can redistribute it and/or modify diff --git a/src/compat/os_cert.h b/src/compat/os_cert.h index 54052d62..f1384d21 100644 --- a/src/compat/os_cert.h +++ b/src/compat/os_cert.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author: Andreas Traczyk * * This program is free software; you can redistribute it and/or modify diff --git a/src/crypto.cpp b/src/crypto.cpp index bb01ac88..51f3c4af 100644 --- a/src/crypto.cpp +++ b/src/crypto.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author : Adrien Béraud * Vsevolod Ivanov * @@ -648,7 +648,7 @@ GnuTLSFromType(NameType type) } static std::string -getDN(gnutls_x509_crq_t request, const char* oid) +readDN(gnutls_x509_crq_t request, const char* oid) { std::string dn; dn.resize(512); @@ -706,13 +706,13 @@ CertificateRequest::setName(const std::string& name) std::string CertificateRequest::getName() const { - return getDN(request, GNUTLS_OID_X520_COMMON_NAME); + return readDN(request, GNUTLS_OID_X520_COMMON_NAME); } std::string CertificateRequest::getUID() const { - return getDN(request, GNUTLS_OID_LDAP_UID); + return readDN(request, GNUTLS_OID_LDAP_UID); } void @@ -771,7 +771,21 @@ CertificateRequest::toString() const // Certificate static std::string -getDN(gnutls_x509_crt_t cert, const char* oid, bool issuer = false) +readDN(gnutls_x509_crt_t cert, bool issuer = false) +{ + gnutls_datum_t dn; + int err = issuer + ? gnutls_x509_crt_get_issuer_dn3(cert, &dn, 0) + : gnutls_x509_crt_get_dn3( cert, &dn, 0); + if (err != GNUTLS_E_SUCCESS) + return {}; + std::string ret((const char*)dn.data, dn.size); + gnutls_free(dn.data); + return ret; +} + +static std::string +readDN(gnutls_x509_crt_t cert, const char* oid, bool issuer = false) { std::string dn; dn.resize(512); @@ -929,28 +943,40 @@ Certificate::getSerialNumber() const return {serial, serial + size}; } +std::string +Certificate::getDN() const +{ + return readDN(cert); +} + std::string Certificate::getName() const { - return getDN(cert, GNUTLS_OID_X520_COMMON_NAME); + return readDN(cert, GNUTLS_OID_X520_COMMON_NAME); } std::string Certificate::getUID() const { - return getDN(cert, GNUTLS_OID_LDAP_UID); + return readDN(cert, GNUTLS_OID_LDAP_UID); +} + +std::string +Certificate::getIssuerDN() const +{ + return readDN(cert, true); } std::string Certificate::getIssuerName() const { - return getDN(cert, GNUTLS_OID_X520_COMMON_NAME, true); + return readDN(cert, GNUTLS_OID_X520_COMMON_NAME, true); } std::string Certificate::getIssuerUID() const { - return getDN(cert, GNUTLS_OID_LDAP_UID, true); + return readDN(cert, GNUTLS_OID_LDAP_UID, true); } std::vector> diff --git a/src/default_types.cpp b/src/default_types.cpp index b37f2faa..6d98b7a3 100644 --- a/src/default_types.cpp +++ b/src/default_types.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author : Adrien Béraud * * This program is free software; you can redistribute it and/or modify diff --git a/src/dht.cpp b/src/dht.cpp index b013017d..5d5637a8 100644 --- a/src/dht.cpp +++ b/src/dht.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author(s) : Adrien Béraud * Simon Désaulniers * diff --git a/src/dht_proxy_client.cpp b/src/dht_proxy_client.cpp index af579201..69c056d5 100644 --- a/src/dht_proxy_client.cpp +++ b/src/dht_proxy_client.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author: Sébastien Blin * Adrien Béraud * Vsevolod Ivanov diff --git a/src/dht_proxy_server.cpp b/src/dht_proxy_server.cpp index f1c02154..137b029c 100644 --- a/src/dht_proxy_server.cpp +++ b/src/dht_proxy_server.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author: Sébastien Blin * Adrien Béraud * Vsevolod Ivanov diff --git a/src/dhtrunner.cpp b/src/dhtrunner.cpp index 4c1e3040..f3af2142 100644 --- a/src/dhtrunner.cpp +++ b/src/dhtrunner.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Authors: Adrien Béraud * Simon Désaulniers * Sébastien Blin @@ -36,7 +36,9 @@ namespace dht { -static const std::string PEER_DISCOVERY_DHT_SERVICE = "dht"; +using namespace std::literals; + +constexpr auto PEER_DISCOVERY_DHT_SERVICE = "dht"sv; struct NodeInsertionPack { dht::InfoHash nodeId; @@ -619,7 +621,7 @@ DhtRunner::getPublicAddress(std::function&&)> cb, sa_ } void -DhtRunner::registerCertificate(std::shared_ptr cert) { +DhtRunner::registerCertificate(const std::shared_ptr& cert) { std::lock_guard lck(dht_mtx); dht_->registerCertificate(cert); } diff --git a/src/http.cpp b/src/http.cpp index 54bc63af..6459b7da 100644 --- a/src/http.cpp +++ b/src/http.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author: Vsevolod Ivanov * * This program is free software; you can redistribute it and/or modify @@ -604,7 +604,7 @@ Connection::async_read_until(const char* delim, BytesHandlerCb cb) { std::lock_guard lock(mutex_); if (!is_open()) { - asio::post(ctx_, [cb](){ cb(asio::error::broken_pipe, 0); }); + if (cb) asio::post(ctx_, [cb](){ cb(asio::error::broken_pipe, 0); }); return; } if (ssl_socket_) asio::async_read_until(*ssl_socket_, read_buf_, delim, wrapCallback(std::move(cb))); diff --git a/src/indexation/pht.cpp b/src/indexation/pht.cpp index a5b14c0d..67adbc79 100644 --- a/src/indexation/pht.cpp +++ b/src/indexation/pht.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author(s) : Adrien Béraud * Simon Désaulniers * Nicolas Reynaud diff --git a/src/infohash.cpp b/src/infohash.cpp index 9c09d183..e4fd0fe9 100644 --- a/src/infohash.cpp +++ b/src/infohash.cpp @@ -8,5 +8,5 @@ dht::HexMap::HexMap() { auto& e = (*this)[i]; e[0] = hex_digits[(i >> 4) & 0x0F]; e[1] = hex_digits[i & 0x0F]; - } + } } diff --git a/src/listener.h b/src/listener.h index ba920a3e..bd622ca3 100644 --- a/src/listener.h +++ b/src/listener.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author(s) : Adrien Béraud * * This program is free software; you can redistribute it and/or modify diff --git a/src/log.cpp b/src/log.cpp index daca16dc..5d6876f2 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * * Author: Adrien Béraud * diff --git a/src/net.h b/src/net.h index 87cbfff7..5e8a1aaf 100644 --- a/src/net.h +++ b/src/net.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author(s) : Adrien Béraud * * This program is free software; you can redistribute it and/or modify diff --git a/src/network_engine.cpp b/src/network_engine.cpp index fd6b8c92..52690bcb 100644 --- a/src/network_engine.cpp +++ b/src/network_engine.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author(s) : Adrien Béraud * Simon Désaulniers * diff --git a/src/network_utils.cpp b/src/network_utils.cpp index c681f0e1..820cd1d2 100644 --- a/src/network_utils.cpp +++ b/src/network_utils.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author(s) : Adrien Béraud * * This program is free software; you can redistribute it and/or modify diff --git a/src/node.cpp b/src/node.cpp index ac2be22d..d5c62d00 100644 --- a/src/node.cpp +++ b/src/node.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author(s) : Adrien Béraud * Simon Désaulniers * diff --git a/src/node_cache.cpp b/src/node_cache.cpp index 58a7018a..0dea8846 100644 --- a/src/node_cache.cpp +++ b/src/node_cache.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author(s) : Adrien Béraud * * This program is free software; you can redistribute it and/or modify diff --git a/src/op_cache.cpp b/src/op_cache.cpp index f775402d..a0cc6271 100644 --- a/src/op_cache.cpp +++ b/src/op_cache.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author(s) : Adrien Béraud * * This program is free software; you can redistribute it and/or modify diff --git a/src/op_cache.h b/src/op_cache.h index 4289be37..1283e412 100644 --- a/src/op_cache.h +++ b/src/op_cache.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author(s) : Adrien Béraud * * This program is free software; you can redistribute it and/or modify diff --git a/src/parsed_message.h b/src/parsed_message.h index b85a8e8e..a4b77e72 100644 --- a/src/parsed_message.h +++ b/src/parsed_message.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author(s) : Adrien Béraud * * This program is free software; you can redistribute it and/or modify diff --git a/src/peer_discovery.cpp b/src/peer_discovery.cpp index d6788394..f6aa9ad3 100644 --- a/src/peer_discovery.cpp +++ b/src/peer_discovery.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author(s) : Mingrui Zhang * Vsevolod Ivanov * Adrien Béraud @@ -42,13 +42,13 @@ public: DomainPeerDiscovery(asio::ip::udp domain, in_port_t port, Sp ioContext = {}, Sp logger = {}); ~DomainPeerDiscovery(); - void startDiscovery(const std::string &type, ServiceDiscoveredCallback callback); - void startPublish(const std::string &type, const msgpack::sbuffer &pack_buf); + void startDiscovery(std::string_view type, ServiceDiscoveredCallback callback); + void startPublish(std::string_view type, const msgpack::sbuffer &pack_buf); void stop(); - bool stopDiscovery(const std::string &type); - bool stopPublish(const std::string &type); + bool stopDiscovery(std::string_view type); + bool stopPublish(std::string_view type); void connectivityChanged(); @@ -75,7 +75,7 @@ private: asio::ip::udp::endpoint receiveFrom_; msgpack::sbuffer sbuf_; - std::map messages_; + std::map> messages_; std::map> callbackmap_; bool lrunning_ {false}; bool drunning_ {false}; @@ -133,10 +133,10 @@ PeerDiscovery::DomainPeerDiscovery::~DomainPeerDiscovery() } void -PeerDiscovery::DomainPeerDiscovery::startDiscovery(const std::string &type, ServiceDiscoveredCallback callback) +PeerDiscovery::DomainPeerDiscovery::startDiscovery(std::string_view type, ServiceDiscoveredCallback callback) { std::lock_guard lck(dmtx_); - callbackmap_[type] = callback; + callbackmap_[std::string(type)] = callback; if (not drunning_) { drunning_ = true; asio::post(*ioContext_, [this] () { @@ -236,23 +236,25 @@ PeerDiscovery::DomainPeerDiscovery::publish(const asio::ip::udp::endpoint& peer) void -PeerDiscovery::DomainPeerDiscovery::startPublish(const std::string &type, const msgpack::sbuffer &pack_buf) +PeerDiscovery::DomainPeerDiscovery::startPublish(std::string_view type, const msgpack::sbuffer &pack_buf) { msgpack::sbuffer pack_buf_c(pack_buf.size()); pack_buf_c.write(pack_buf.data(), pack_buf.size()); std::lock_guard lck(mtx_); - messages_[type] = std::move(pack_buf_c); + messages_[std::string(type)] = std::move(pack_buf_c); reloadMessages(); lrunning_ = true; asio::post(*ioContext_, [this] () { publish(sockAddrSend_); }); } bool -PeerDiscovery::DomainPeerDiscovery::stopDiscovery(const std::string& type) +PeerDiscovery::DomainPeerDiscovery::stopDiscovery(std::string_view type) { std::lock_guard lck(dmtx_); - if (callbackmap_.erase(type) > 0) { + auto it = callbackmap_.find(type); + if (it != callbackmap_.end()) { + callbackmap_.erase(it); if (callbackmap_.empty()) stopDiscovery(); return true; @@ -261,10 +263,12 @@ PeerDiscovery::DomainPeerDiscovery::stopDiscovery(const std::string& type) } bool -PeerDiscovery::DomainPeerDiscovery::stopPublish(const std::string& type) +PeerDiscovery::DomainPeerDiscovery::stopPublish(std::string_view type) { std::lock_guard lck(mtx_); - if (messages_.erase(type) > 0) { + auto it = messages_.find(type); + if (it != messages_.end()) { + messages_.erase(it); if (messages_.empty()) stopPublish(); else @@ -397,21 +401,21 @@ PeerDiscovery::~PeerDiscovery() { } void -PeerDiscovery::startDiscovery(const std::string& type, ServiceDiscoveredCallback callback) +PeerDiscovery::startDiscovery(std::string_view type, ServiceDiscoveredCallback callback) { if (peerDiscovery4_) peerDiscovery4_->startDiscovery(type, callback); if (peerDiscovery6_) peerDiscovery6_->startDiscovery(type, callback); } void -PeerDiscovery::startPublish(const std::string& type, const msgpack::sbuffer& pack_buf) +PeerDiscovery::startPublish(std::string_view type, const msgpack::sbuffer& pack_buf) { if (peerDiscovery4_) peerDiscovery4_->startPublish(type, pack_buf); if (peerDiscovery6_) peerDiscovery6_->startPublish(type, pack_buf); } void -PeerDiscovery::startPublish(sa_family_t domain, const std::string& type, const msgpack::sbuffer& pack_buf) +PeerDiscovery::startPublish(sa_family_t domain, std::string_view type, const msgpack::sbuffer& pack_buf) { if (domain == AF_INET) { if (peerDiscovery4_) peerDiscovery4_->startPublish(type, pack_buf); @@ -428,7 +432,7 @@ PeerDiscovery::stop() } bool -PeerDiscovery::stopDiscovery(const std::string &type) +PeerDiscovery::stopDiscovery(std::string_view type) { bool stopped4 = peerDiscovery4_ and peerDiscovery4_->stopDiscovery(type); bool stopped6 = peerDiscovery6_ and peerDiscovery6_->stopDiscovery(type); @@ -436,7 +440,7 @@ PeerDiscovery::stopDiscovery(const std::string &type) } bool -PeerDiscovery::stopPublish(const std::string &type) +PeerDiscovery::stopPublish(std::string_view type) { bool stopped4 = peerDiscovery4_ and peerDiscovery4_->stopPublish(type); bool stopped6 = peerDiscovery6_ and peerDiscovery6_->stopPublish(type); @@ -444,7 +448,7 @@ PeerDiscovery::stopPublish(const std::string &type) } bool -PeerDiscovery::stopPublish(sa_family_t domain, const std::string& type) +PeerDiscovery::stopPublish(sa_family_t domain, std::string_view type) { if (domain == AF_INET) { return peerDiscovery4_ and peerDiscovery4_->stopPublish(type); diff --git a/src/request.h b/src/request.h index 0f48eef3..1be5a9f4 100644 --- a/src/request.h +++ b/src/request.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author(s) : Adrien Béraud * Simon Désaulniers * diff --git a/src/routing_table.cpp b/src/routing_table.cpp index 54c57d57..ded72cb2 100644 --- a/src/routing_table.cpp +++ b/src/routing_table.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author(s) : Adrien Béraud * * This program is free software; you can redistribute it and/or modify diff --git a/src/search.h b/src/search.h index 52d991b7..a78831c5 100644 --- a/src/search.h +++ b/src/search.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author(s) : Adrien Béraud * * This program is free software; you can redistribute it and/or modify diff --git a/src/securedht.cpp b/src/securedht.cpp index 9aca9fb4..a24dfd43 100644 --- a/src/securedht.cpp +++ b/src/securedht.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Authors: Adrien Béraud * Simon Désaulniers * Sébastien Blin @@ -158,7 +158,7 @@ SecureDht::registerCertificate(const InfoHash& node, const Blob& data) } void -SecureDht::registerCertificate(Sp& cert) +SecureDht::registerCertificate(const Sp& cert) { if (cert) nodesCertificates_[cert->getId()] = cert; diff --git a/src/storage.h b/src/storage.h index dc5f2d94..a73926b0 100644 --- a/src/storage.h +++ b/src/storage.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author(s) : Adrien Béraud * * This program is free software; you can redistribute it and/or modify @@ -224,7 +224,7 @@ Storage::store(const InfoHash& id, const Sp& value, time_point created, t //DHT_LOG.DEBUG("Updating %s -> %s", id.toString().c_str(), value->toString().c_str()); // clear quota for previous value if (it->store_bucket) - it->store_bucket->erase(id, *value, it->expiration); + it->store_bucket->erase(id, *it->data, it->expiration); it->expiration = expiration; // update quota for new value it->store_bucket = sb; diff --git a/src/thread_pool.cpp b/src/thread_pool.cpp index 7fab7c11..910cc2b9 100644 --- a/src/thread_pool.cpp +++ b/src/thread_pool.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * * Author: Adrien Béraud * diff --git a/src/utils.cpp b/src/utils.cpp index 5a1b4c1d..66be48a9 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author : Adrien Béraud * * This program is free software; you can redistribute it and/or modify diff --git a/src/value.cpp b/src/value.cpp index 5a8d7045..8feb64cc 100644 --- a/src/value.cpp +++ b/src/value.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author(s) : Adrien Béraud * Simon Désaulniers * diff --git a/src/value_cache.h b/src/value_cache.h index 1789e6a5..11334eb3 100644 --- a/src/value_cache.h +++ b/src/value_cache.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author(s) : Adrien Béraud * * This program is free software; you can redistribute it and/or modify diff --git a/tests/cryptotester.cpp b/tests/cryptotester.cpp index 1673784c..1768d1fd 100644 --- a/tests/cryptotester.cpp +++ b/tests/cryptotester.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * * Author: Adrien Béraud * Vsevolod Ivanov diff --git a/tests/cryptotester.h b/tests/cryptotester.h index 6cd552c4..d26934f9 100644 --- a/tests/cryptotester.h +++ b/tests/cryptotester.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * * Author: Adrien Béraud * Vsevolod Ivanov diff --git a/tests/dhtproxy_stress_tester.h b/tests/dhtproxy_stress_tester.h index 8ad11137..74600d6c 100644 --- a/tests/dhtproxy_stress_tester.h +++ b/tests/dhtproxy_stress_tester.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/tests/dhtproxytester.cpp b/tests/dhtproxytester.cpp index ec3db48a..8ad47fe5 100644 --- a/tests/dhtproxytester.cpp +++ b/tests/dhtproxytester.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * * Author: Sébastien Blin * Vsevolod Ivanov diff --git a/tests/dhtproxytester.h b/tests/dhtproxytester.h index 55032ce5..413e83f0 100644 --- a/tests/dhtproxytester.h +++ b/tests/dhtproxytester.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * * Author: Sébastien Blin * diff --git a/tests/dhtrunnertester.cpp b/tests/dhtrunnertester.cpp index a882794f..8948f328 100644 --- a/tests/dhtrunnertester.cpp +++ b/tests/dhtrunnertester.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * * Author: Adrien Béraud * @@ -358,7 +358,8 @@ DhtRunnerTester::testIdOps() { { std::unique_lock lk(mutex); - CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&]{ return valueCount == 7 && valueCountEdit == 2; })); + CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&]{ return valueCount == 7; })); + CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&]{ return valueCountEdit == 2; })); } // editValue->data = dht::packMsg("v2"); diff --git a/tests/dhtrunnertester.h b/tests/dhtrunnertester.h index 501679d7..d72f69e3 100644 --- a/tests/dhtrunnertester.h +++ b/tests/dhtrunnertester.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * * Author: Adrien Béraud * diff --git a/tests/httptester.cpp b/tests/httptester.cpp index b3c713af..c040798b 100644 --- a/tests/httptester.cpp +++ b/tests/httptester.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * * Author: Vsevolod Ivanov * diff --git a/tests/httptester.h b/tests/httptester.h index 6c870a1e..a86fc908 100644 --- a/tests/httptester.h +++ b/tests/httptester.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * * Author: Vsevolod Ivanov * diff --git a/tests/infohashtester.cpp b/tests/infohashtester.cpp index 074eab48..b045de23 100644 --- a/tests/infohashtester.cpp +++ b/tests/infohashtester.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * * Author: Sébastien Blin * diff --git a/tests/infohashtester.h b/tests/infohashtester.h index 902c4ba3..23af731a 100644 --- a/tests/infohashtester.h +++ b/tests/infohashtester.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * * Author: Sébastien Blin * diff --git a/tests/peerdiscoverytester.cpp b/tests/peerdiscoverytester.cpp index 8ccd63b9..a172804c 100644 --- a/tests/peerdiscoverytester.cpp +++ b/tests/peerdiscoverytester.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * * Author: Mingrui Zhang * @@ -25,9 +25,11 @@ namespace test { +using namespace std::literals; + constexpr unsigned MULTICAST_PORT = 2222; -const std::string DHT_NODE_NAME {"dht"}; -const std::string JAMI_NODE_NAME {"jami"}; +constexpr auto DHT_NODE_NAME {"dht"sv}; +constexpr auto JAMI_NODE_NAME {"jami"sv}; struct DhtNode { dht::InfoHash nodeid; diff --git a/tests/peerdiscoverytester.h b/tests/peerdiscoverytester.h index b5484e49..99866d64 100644 --- a/tests/peerdiscoverytester.h +++ b/tests/peerdiscoverytester.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * * Author: Mingrui Zhang * diff --git a/tests/tests_runner.cpp b/tests/tests_runner.cpp index b471cb31..15f6cf17 100644 --- a/tests/tests_runner.cpp +++ b/tests/tests_runner.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author: Sébastien Blin * * This program is free software; you can redistribute it and/or modify diff --git a/tests/threadpooltester.cpp b/tests/threadpooltester.cpp index 65460bb6..e0de30e4 100644 --- a/tests/threadpooltester.cpp +++ b/tests/threadpooltester.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * * Author: Adrien Béraud * diff --git a/tests/threadpooltester.h b/tests/threadpooltester.h index bfc2ce1e..a16d92bc 100644 --- a/tests/threadpooltester.h +++ b/tests/threadpooltester.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * * Author: Adrien Béraud * diff --git a/tests/valuetester.cpp b/tests/valuetester.cpp index 20b76b34..469aa42c 100644 --- a/tests/valuetester.cpp +++ b/tests/valuetester.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * * Author: Adrien Béraud * diff --git a/tests/valuetester.h b/tests/valuetester.h index a2b3f098..06fb7016 100644 --- a/tests/valuetester.h +++ b/tests/valuetester.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * * Author: Adrien Béraud * diff --git a/tools/dhtchat.cpp b/tools/dhtchat.cpp index 9c4c3117..1aa54dd2 100644 --- a/tools/dhtchat.cpp +++ b/tools/dhtchat.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * * Author: Adrien Béraud * diff --git a/tools/dhtcnode.c b/tools/dhtcnode.c index cdb04714..3b8d0530 100644 --- a/tools/dhtcnode.c +++ b/tools/dhtcnode.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * Author : Adrien Béraud * * This program is free software; you can redistribute it and/or modify diff --git a/tools/dhtnode.cpp b/tools/dhtnode.cpp index 5284aa56..27ee6a16 100644 --- a/tools/dhtnode.cpp +++ b/tools/dhtnode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * * Authors: Adrien Béraud * Simon Désaulniers diff --git a/tools/dhtscanner.cpp b/tools/dhtscanner.cpp index 2141f890..e9f62987 100644 --- a/tools/dhtscanner.cpp +++ b/tools/dhtscanner.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * * Author: Adrien Béraud * diff --git a/tools/durl.cpp b/tools/durl.cpp index ab9afe43..55759edd 100644 --- a/tools/durl.cpp +++ b/tools/durl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * * Authors: Adrien Béraud * diff --git a/tools/perftest.cpp b/tools/perftest.cpp index 4dc759d2..59d639ee 100644 --- a/tools/perftest.cpp +++ b/tools/perftest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * * Author: Adrien Béraud * diff --git a/tools/proxy_loadtester.py b/tools/proxy_loadtester.py index 48344d14..eba3db66 100644 --- a/tools/proxy_loadtester.py +++ b/tools/proxy_loadtester.py @@ -1,4 +1,4 @@ -# Copyright (C) 2014-2023 Savoir-faire Linux Inc. +# Copyright (C) 2014-2025 Savoir-faire Linux Inc. # Author: Vsevolod Ivanov # # This program is free software; you can redistribute it and/or modify diff --git a/tools/tools_common.h b/tools/tools_common.h index 6bf4786d..0135f762 100644 --- a/tools/tools_common.h +++ b/tools/tools_common.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2023 Savoir-faire Linux Inc. + * Copyright (C) 2014-2025 Savoir-faire Linux Inc. * * Author: Adrien Béraud * Author: Sébastien Blin @@ -34,6 +34,12 @@ #include +#if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32__) && !defined(__NT__) + #pragma message "Building on UNIX-like platform, linking system getopt" + #include + #include + #include +#endif #if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32__) && !defined(__NT__) #pragma message "Building on UNIX-like platform, linking system getopt" #include @@ -42,20 +48,18 @@ #endif #ifdef _MSC_VER #pragma message("Building on WIN32 platform using MSVC, linking wingetopt") - #define SIGHUP 0 #include "wingetopt.h" - #include #endif #if defined(__MINGW32__) || defined (__MINGW64__) #pragma message "Building on MinGW, linking system-wide getopt" - #define SIGHUP 0 - #include #include #include #include #endif #if defined(_MSC_VER) || defined(__MINGW32__) || defined (__MINGW64__) + #define SIGHUP 0 + #include #define DISABLE_SIGNALS #endif