Common/TraversalServer: Make use of fmt more
We can convert printf and fprintf over to the use of fmt as well, given that we've converted the sprintf calls over.
This commit is contained in:
parent
dc85194fac
commit
affe928987
|
@ -87,12 +87,12 @@ retry:
|
|||
}
|
||||
}
|
||||
#if DEBUG
|
||||
printf("failed to find key '");
|
||||
fmt::print("failed to find key '");
|
||||
for (size_t i = 0; i < sizeof(key); i++)
|
||||
{
|
||||
printf("%02x", ((u8*)&key)[i]);
|
||||
fmt::print("{:02x}", ((u8*)&key)[i]);
|
||||
}
|
||||
printf("'\n");
|
||||
fmt::print("'\n");
|
||||
#endif
|
||||
result.found = false;
|
||||
return result;
|
||||
|
@ -133,7 +133,7 @@ static Common::TraversalInetAddress MakeInetAddress(const sockaddr_in6& addr)
|
|||
{
|
||||
if (addr.sin6_family != AF_INET6)
|
||||
{
|
||||
fprintf(stderr, "bad sockaddr_in6\n");
|
||||
fmt::print(stderr, "bad sockaddr_in6\n");
|
||||
exit(1);
|
||||
}
|
||||
u32* words = (u32*)addr.sin6_addr.s6_addr;
|
||||
|
@ -197,8 +197,8 @@ static void TrySend(const void* buffer, size_t size, sockaddr_in6* addr, bool fr
|
|||
{
|
||||
#if DEBUG
|
||||
const auto* packet = static_cast<const Common::TraversalPacket*>(buffer);
|
||||
printf("%s-> %d %llu %s\n", fromAlt ? "alt " : "", static_cast<int>(packet->type),
|
||||
static_cast<long long>(packet->requestId), SenderName(addr));
|
||||
fmt::print("{}-> {} {} {}\n", fromAlt ? "alt " : "", static_cast<int>(packet->type),
|
||||
static_cast<long long>(packet->requestId), SenderName(addr));
|
||||
#endif
|
||||
if ((size_t)sendto(fromAlt ? sockAlt : sock, buffer, size, 0, (sockaddr*)addr, sizeof(*addr)) !=
|
||||
size)
|
||||
|
@ -271,8 +271,8 @@ static void ResendPackets()
|
|||
static void HandlePacket(Common::TraversalPacket* packet, sockaddr_in6* addr, bool toAlt)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("<- %d %llu %s\n", static_cast<int>(packet->type),
|
||||
static_cast<long long>(packet->requestId), SenderName(addr));
|
||||
fmt::print("<- {} {} {}\n", static_cast<int>(packet->type),
|
||||
static_cast<long long>(packet->requestId), SenderName(addr));
|
||||
#endif
|
||||
bool packetOk = true;
|
||||
switch (packet->type)
|
||||
|
@ -377,8 +377,8 @@ static void HandlePacket(Common::TraversalPacket* packet, sockaddr_in6* addr, bo
|
|||
break;
|
||||
}
|
||||
default:
|
||||
fprintf(stderr, "received unknown packet type %d from %s\n", static_cast<int>(packet->type),
|
||||
SenderName(addr));
|
||||
fmt::print(stderr, "received unknown packet type {} from {}\n", static_cast<int>(packet->type),
|
||||
SenderName(addr));
|
||||
break;
|
||||
}
|
||||
if (packet->type != Common::TraversalPacketType::Ack)
|
||||
|
@ -516,7 +516,7 @@ int main()
|
|||
}
|
||||
else if ((size_t)rv < sizeof(packet))
|
||||
{
|
||||
fprintf(stderr, "received short packet from %s\n", SenderName(&raddr));
|
||||
fmt::print(stderr, "received short packet from {}\n", SenderName(&raddr));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue