mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:07:36 +00:00
Userland: Replace most printf-style APIs with AK::Format APIs :^)
This commit is contained in:
parent
4f1889c2cb
commit
f5c35fccca
75 changed files with 642 additions and 644 deletions
|
@ -45,7 +45,7 @@ int main(int argc, char** argv)
|
|||
}
|
||||
|
||||
if (setgid(getgid()) || setuid(getuid())) {
|
||||
fprintf(stderr, "Failed to drop privileges.\n");
|
||||
warnln("Failed to drop privileges.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ int main(int argc, char** argv)
|
|||
|
||||
auto* hostent = gethostbyname(host);
|
||||
if (!hostent) {
|
||||
printf("Lookup failed for '%s'\n", host);
|
||||
warnln("Lookup failed for '{}'", host);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -101,17 +101,18 @@ int main(int argc, char** argv)
|
|||
sighandler_t ret = signal(SIGINT, [](int) {
|
||||
int packet_loss = 100;
|
||||
|
||||
printf("\n--- %s ping statistics ---\n", host);
|
||||
outln();
|
||||
outln("--- {} ping statistics ---", host);
|
||||
|
||||
if (total_pings)
|
||||
packet_loss -= 100.0f * successful_pings / total_pings;
|
||||
printf("%d packets transmitted, %d received, %d%% packet loss\n",
|
||||
outln("{} packets transmitted, {} received, {}% packet loss",
|
||||
total_pings, successful_pings, packet_loss);
|
||||
|
||||
int average_ms = 0;
|
||||
if (successful_pings)
|
||||
average_ms = total_ms / successful_pings;
|
||||
printf("rtt min/avg/max = %d/%d/%d ms\n", min_ms, average_ms, max_ms);
|
||||
outln("rtt min/avg/max = {}/{}/{} ms", min_ms, average_ms, max_ms);
|
||||
|
||||
exit(0);
|
||||
});
|
||||
|
@ -153,7 +154,7 @@ int main(int argc, char** argv)
|
|||
rc = recvfrom(fd, &pong_packet, sizeof(PongPacket), 0, (struct sockaddr*)&peer_address, &peer_address_size);
|
||||
if (rc < 0) {
|
||||
if (errno == EAGAIN) {
|
||||
printf("Request (seq=%u) timed out.\n", ntohs(ping_packet.header.un.echo.sequence));
|
||||
outln("Request (seq={}) timed out.", ntohs(ping_packet.header.un.echo.sequence));
|
||||
break;
|
||||
}
|
||||
perror("recvfrom");
|
||||
|
@ -190,7 +191,7 @@ int main(int argc, char** argv)
|
|||
max_ms = ms;
|
||||
|
||||
char addr_buf[INET_ADDRSTRLEN];
|
||||
printf("Pong from %s: id=%u, seq=%u%s, time=%dms\n",
|
||||
outln("Pong from {}: id={}, seq={}{}, time={}ms",
|
||||
inet_ntop(AF_INET, &peer_address.sin_addr, addr_buf, sizeof(addr_buf)),
|
||||
ntohs(pong_packet.header.un.echo.id),
|
||||
ntohs(pong_packet.header.un.echo.sequence),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue