Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Canonical Tap House pre-commit config — the single source of truth for the
# Tap family's local formatting hook. Distributed to every Tap repo by
# scripts/sync.sh (alongside .clang-format / .clang-tidy / STYLE.md) and kept
# honest by the drift-check workflow, so every repo runs the SAME hook at the
# SAME pinned clang-format version.
#
# Why the pin matters: an ad-hoc hook using each machine's own clang-format
# would format differently than CI and be worse than none. The `rev` below is
# the Tap-wide clang-format version — bump it HERE, re-sync, and every repo
# (and its CI, which runs `pre-commit run --all-files`) moves together.
#
# Adopt in a consumer repo:
# 1. taphouse/scripts/sync.sh /path/to/your-repo # copies this file in
# 2. cd your-repo && pre-commit install # once per clone
# Thereafter `git commit` formats staged C/C++ before it can be pushed, so the
# clang-format CI gate can never fail on a local commit again.
repos:
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v18.1.3 # Tap-wide clang-format version (matches CI)
hooks:
- id: clang-format
types_or: [c, c++]
exclude: '^third_party/' # vendored sources are formatted upstream, never by us
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
packing and unpacking [Open Sound Control](https://opensoundcontrol.stanford.edu/)
(OSC) packets, with UDP **and TCP** networking classes for Windows and POSIX.

It is a drop-in successor: the `oscpack` namespace and include paths are retained as a
deprecated compatibility alias, so existing code keeps building while new code uses the
`osctap` name.
It is a drop-in successor: the canonical namespace is `tap::osc`, and the former names
(`osctap`, and `oscpack` before it) plus the original include paths are retained as
compatibility aliases, so existing code keeps building while new code uses `tap::osc`.

> **Status:** actively modernized. The parsing path is audited, hardened, and fuzzed;
> a non-throwing validation gate, a freestanding/embedded profile, OSC-over-TCP, and an
Expand Down
11 changes: 6 additions & 5 deletions osctap/ip/AbstractUdpSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#include "IpEndpointName.h"
#include "NetworkingUtils.h"

namespace osctap {
namespace tap::osc {
class PacketListener;
class TimerListener;

Expand Down Expand Up @@ -192,10 +192,11 @@ namespace osctap {

} // namespace detail

} // namespace osctap
} // namespace tap::osc

// Backwards-compatibility alias: this library was formerly named oscpack.
// Existing code that uses the oscpack:: namespace continues to compile.
namespace oscpack = osctap;
// Backwards-compatibility aliases: the canonical namespace is tap::osc.
// The former names (osctap, and oscpack before it) keep compiling.
namespace osctap = tap::osc;
namespace oscpack = tap::osc;

#endif /* INCLUDED_OSCTAP_UDPSOCKET_H */
13 changes: 7 additions & 6 deletions osctap/ip/IpEndpointName.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@

#include "NetworkingUtils.h"

namespace osctap {
namespace tap::osc {
class IpEndpointName {
static unsigned long GetHostByName(const char* s) { return osctap::GetHostByName(s); }
static unsigned long GetHostByName(const char* s) { return tap::osc::GetHostByName(s); }

public:
static const unsigned long ANY_ADDRESS = 0xFFFFFFFF;
Expand Down Expand Up @@ -114,10 +114,11 @@ namespace osctap {
inline bool operator!=(const IpEndpointName& lhs, const IpEndpointName& rhs) {
return !(lhs == rhs);
}
} // namespace osctap
} // namespace tap::osc

// Backwards-compatibility alias: this library was formerly named oscpack.
// Existing code that uses the oscpack:: namespace continues to compile.
namespace oscpack = osctap;
// Backwards-compatibility aliases: the canonical namespace is tap::osc.
// The former names (osctap, and oscpack before it) keep compiling.
namespace osctap = tap::osc;
namespace oscpack = tap::osc;

#endif /* INCLUDED_OSCTAP_IPENDPOINTNAME_H */
11 changes: 6 additions & 5 deletions osctap/ip/PacketListener.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,19 @@
#ifndef INCLUDED_OSCTAP_PACKETLISTENER_H
#define INCLUDED_OSCTAP_PACKETLISTENER_H

namespace osctap {
namespace tap::osc {
class IpEndpointName;

class PacketListener {
public:
virtual ~PacketListener() {}
virtual void ProcessPacket(const char* data, int size, const IpEndpointName& remoteEndpoint) = 0;
};
} // namespace osctap
} // namespace tap::osc

// Backwards-compatibility alias: this library was formerly named oscpack.
// Existing code that uses the oscpack:: namespace continues to compile.
namespace oscpack = osctap;
// Backwards-compatibility aliases: the canonical namespace is tap::osc.
// The former names (osctap, and oscpack before it) keep compiling.
namespace osctap = tap::osc;
namespace oscpack = tap::osc;

#endif /* INCLUDED_OSCTAP_PACKETLISTENER_H */
10 changes: 6 additions & 4 deletions osctap/ip/TcpSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@
#include "posix/TcpSocket.h"
#endif

namespace osctap {
namespace tap::osc {
#if defined(_WIN32)
using TcpTransmitSocket = win32::TcpTransmitSocket;
using TcpListeningReceiveSocket = win32::TcpListeningReceiveSocket;
#else
using TcpTransmitSocket = posix::TcpTransmitSocket;
using TcpListeningReceiveSocket = posix::TcpListeningReceiveSocket;
#endif
} // namespace osctap
} // namespace tap::osc

// Backwards-compatibility alias: this library was formerly named oscpack.
namespace oscpack = osctap;
// Backwards-compatibility aliases: the canonical namespace is tap::osc.
// The former names (osctap, and oscpack before it) keep compiling.
namespace osctap = tap::osc;
namespace oscpack = tap::osc;

#endif /* INCLUDED_OSCTAP_TCPSOCKET_H */
11 changes: 6 additions & 5 deletions osctap/ip/TimerListener.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,17 @@
#ifndef INCLUDED_OSCTAP_TIMERLISTENER_H
#define INCLUDED_OSCTAP_TIMERLISTENER_H

namespace osctap {
namespace tap::osc {
class TimerListener {
public:
virtual ~TimerListener() {}
virtual void TimerExpired() = 0;
};
} // namespace osctap
} // namespace tap::osc

// Backwards-compatibility alias: this library was formerly named oscpack.
// Existing code that uses the oscpack:: namespace continues to compile.
namespace oscpack = osctap;
// Backwards-compatibility aliases: the canonical namespace is tap::osc.
// The former names (osctap, and oscpack before it) keep compiling.
namespace osctap = tap::osc;
namespace oscpack = tap::osc;

#endif /* INCLUDED_OSCTAP_TIMERLISTENER_H */
15 changes: 8 additions & 7 deletions osctap/ip/UdpSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@
#include "posix/UdpSocket.h"
#endif

namespace osctap {
namespace tap::osc {
namespace detail {
#if defined(_WIN32)
using Implementation = osctap::win32::Implementation;
using Implementation = tap::osc::win32::Implementation;
#else
using Implementation = osctap::posix::Implementation;
using Implementation = tap::osc::posix::Implementation;
#endif
} // namespace detail

using UdpTransmitSocket = detail::UdpTransmitSocket<detail::Implementation>;
using UdpReceiveSocket = detail::UdpReceiveSocket<detail::Implementation>;
using UdpListeningReceiveSocket = detail::UdpListeningReceiveSocket<detail::Implementation>;
} // namespace osctap
} // namespace tap::osc

// Backwards-compatibility alias: this library was formerly named oscpack.
// Existing code that uses the oscpack:: namespace continues to compile.
namespace oscpack = osctap;
// Backwards-compatibility aliases: the canonical namespace is tap::osc.
// The former names (osctap, and oscpack before it) keep compiling.
namespace osctap = tap::osc;
namespace oscpack = tap::osc;
11 changes: 6 additions & 5 deletions osctap/ip/posix/NetworkingUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <netdb.h>
#include <netinet/in.h>
#include <sys/socket.h>
namespace osctap {
namespace tap::osc {
// in general NetworkInitializer is only used internally, but if you're
// application creates multiple sockets from different threads at runtime you
// should instantiate one of these in main just to make sure the networking
Expand Down Expand Up @@ -42,8 +42,9 @@ namespace osctap {
}
return result;
}
} // namespace osctap
} // namespace tap::osc

// Backwards-compatibility alias: this library was formerly named oscpack.
// Existing code that uses the oscpack:: namespace continues to compile.
namespace oscpack = osctap;
// Backwards-compatibility aliases: the canonical namespace is tap::osc.
// The former names (osctap, and oscpack before it) keep compiling.
namespace osctap = tap::osc;
namespace oscpack = tap::osc;
4 changes: 2 additions & 2 deletions osctap/ip/posix/TcpSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include "ip/posix/UdpSocket.h"
#include "osc/OscStreamFraming.h"

namespace osctap {
namespace tap::osc {
namespace posix {

// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -296,6 +296,6 @@ namespace osctap {
};

} // namespace posix
} // namespace osctap
} // namespace tap::osc

#endif /* INCLUDED_OSCTAP_POSIX_TCPSOCKET_H */
15 changes: 8 additions & 7 deletions osctap/ip/posix/UdpSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
#include "ip/PacketListener.h"
#include "ip/TimerListener.h"

namespace osctap {
namespace tap::osc {

namespace posix {

Expand Down Expand Up @@ -470,13 +470,14 @@ namespace osctap {
};

struct Implementation {
using udp_socket_t = osctap::posix::UdpSocketImplementation;
using socket_multiplexer_t = osctap::posix::SocketReceiveMultiplexerImplementation<udp_socket_t>;
using udp_socket_t = tap::osc::posix::UdpSocketImplementation;
using socket_multiplexer_t = tap::osc::posix::SocketReceiveMultiplexerImplementation<udp_socket_t>;
};
} // namespace posix

} // namespace osctap
} // namespace tap::osc

// Backwards-compatibility alias: this library was formerly named oscpack.
// Existing code that uses the oscpack:: namespace continues to compile.
namespace oscpack = osctap;
// Backwards-compatibility aliases: the canonical namespace is tap::osc.
// The former names (osctap, and oscpack before it) keep compiling.
namespace osctap = tap::osc;
namespace oscpack = tap::osc;
11 changes: 6 additions & 5 deletions osctap/ip/win32/NetworkingUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

#include <cstring>

namespace osctap {
namespace tap::osc {
class NetworkInitializer {
public:
static const NetworkInitializer& instance() {
Expand Down Expand Up @@ -86,8 +86,9 @@ namespace osctap {

return result;
}
} // namespace osctap
} // namespace tap::osc

// Backwards-compatibility alias: this library was formerly named oscpack.
// Existing code that uses the oscpack:: namespace continues to compile.
namespace oscpack = osctap;
// Backwards-compatibility aliases: the canonical namespace is tap::osc.
// The former names (osctap, and oscpack before it) keep compiling.
namespace osctap = tap::osc;
namespace oscpack = tap::osc;
4 changes: 2 additions & 2 deletions osctap/ip/win32/TcpSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include "ip/win32/UdpSocket.h"
#include "osc/OscStreamFraming.h"

namespace osctap {
namespace tap::osc {
namespace win32 {

// Mirrors ip/posix/TcpSocket.h on Winsock. The connection-aware server uses
Expand Down Expand Up @@ -303,6 +303,6 @@ namespace osctap {
};

} // namespace win32
} // namespace osctap
} // namespace tap::osc

#endif /* INCLUDED_OSCTAP_WIN32_TCPSOCKET_H */
15 changes: 8 additions & 7 deletions osctap/ip/win32/UdpSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

typedef int socklen_t;

namespace osctap {
namespace tap::osc {
namespace win32 {
static void SockaddrFromIpEndpointName(struct sockaddr_in& sockAddr, const IpEndpointName& endpoint) {
std::memset((char*)&sockAddr, 0, sizeof(sockAddr));
Expand Down Expand Up @@ -438,12 +438,13 @@ namespace osctap {
};

struct Implementation {
using udp_socket_t = osctap::win32::UdpSocketImplementation;
using socket_multiplexer_t = osctap::win32::SocketReceiveMultiplexerImplementation<udp_socket_t>;
using udp_socket_t = tap::osc::win32::UdpSocketImplementation;
using socket_multiplexer_t = tap::osc::win32::SocketReceiveMultiplexerImplementation<udp_socket_t>;
};
} // namespace win32
} // namespace osctap
} // namespace tap::osc

// Backwards-compatibility alias: this library was formerly named oscpack.
// Existing code that uses the oscpack:: namespace continues to compile.
namespace oscpack = osctap;
// Backwards-compatibility aliases: the canonical namespace is tap::osc.
// The former names (osctap, and oscpack before it) keep compiling.
namespace osctap = tap::osc;
namespace oscpack = tap::osc;
15 changes: 8 additions & 7 deletions osctap/osc/MessageMappingOscPacketListener.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@

#include "OscPacketListener.h"

namespace osctap {
namespace tap::osc {

template <class T>
class MessageMappingOscPacketListener : public OscPacketListener {
public:
typedef void (T::*function_type)(const osctap::ReceivedMessage&, const IpEndpointName&);
typedef void (T::*function_type)(const tap::osc::ReceivedMessage&, const IpEndpointName&);

protected:
void RegisterMessageFunction(const char* addressPattern, function_type f) {
functions_.insert(std::make_pair(addressPattern, f));
}

virtual void ProcessMessage(const osctap::ReceivedMessage& m, const IpEndpointName& remoteEndpoint) {
virtual void ProcessMessage(const tap::osc::ReceivedMessage& m, const IpEndpointName& remoteEndpoint) {
typename function_map_type::iterator i = functions_.find(m.AddressPattern());
if (i != functions_.end())
(dynamic_cast<T*>(this)->*(i->second))(m, remoteEndpoint);
Expand All @@ -69,10 +69,11 @@ namespace osctap {
function_map_type functions_;
};

} // namespace osctap
} // namespace tap::osc

// Backwards-compatibility alias: this library was formerly named oscpack.
// Existing code that uses the oscpack:: namespace continues to compile.
namespace oscpack = osctap;
// Backwards-compatibility aliases: the canonical namespace is tap::osc.
// The former names (osctap, and oscpack before it) keep compiling.
namespace osctap = tap::osc;
namespace oscpack = tap::osc;

#endif /* INCLUDED_OSCTAP_MESSAGEMAPPINGOSCPACKETLISTENER_H */
6 changes: 3 additions & 3 deletions osctap/osc/OscConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
#define OSCTAP_THROW(EXC) (OSCTAP_FATAL_HANDLER((EXC).what()))
#else
#include <cstdlib> // std::abort
namespace osctap {
namespace tap::osc {
namespace detail {
// Default fatal handler used when exceptions are disabled and the integrator
// has not supplied OSCTAP_FATAL_HANDLER. Marked [[noreturn]] so the compiler
Expand All @@ -100,8 +100,8 @@ namespace osctap {
std::abort();
}
} // namespace detail
} // namespace osctap
#define OSCTAP_THROW(EXC) (::osctap::detail::OscFatalError((EXC).what()))
} // namespace tap::osc
#define OSCTAP_THROW(EXC) (::tap::osc::detail::OscFatalError((EXC).what()))
#endif
#endif

Expand Down
Loading
Loading