mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 15:07:45 +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
|
@ -39,7 +39,7 @@ int main(int argc, char** argv)
|
|||
|
||||
auto file = Core::File::construct("/proc/net/adapters");
|
||||
if (!file->open(Core::OpenMode::ReadOnly)) {
|
||||
fprintf(stderr, "Error: %s\n", file->error_string());
|
||||
outln("Failed to open {}: {}", file->name(), file->error_string());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -61,21 +61,21 @@ int main(int argc, char** argv)
|
|||
auto bytes_out = if_object.get("bytes_out").to_u32();
|
||||
auto mtu = if_object.get("mtu").to_u32();
|
||||
|
||||
printf("%s:\n", name.characters());
|
||||
printf("\tmac: %s\n", mac_address.characters());
|
||||
printf("\tipv4: %s\n", ipv4_address.characters());
|
||||
printf("\tnetmask: %s\n", netmask.characters());
|
||||
printf("\tgateway: %s\n", gateway.characters());
|
||||
printf("\tclass: %s\n", class_name.characters());
|
||||
printf("\tRX: %u packets %u bytes (%s)\n", packets_in, bytes_in, human_readable_size(bytes_in).characters());
|
||||
printf("\tTX: %u packets %u bytes (%s)\n", packets_out, bytes_out, human_readable_size(bytes_out).characters());
|
||||
printf("\tMTU: %u\n", mtu);
|
||||
printf("\n");
|
||||
outln("{}:", name);
|
||||
outln("\tmac: {}", mac_address);
|
||||
outln("\tipv4: {}", ipv4_address);
|
||||
outln("\tnetmask: {}", netmask);
|
||||
outln("\tgateway: {}", gateway);
|
||||
outln("\tclass: {}", class_name);
|
||||
outln("\tRX: {} packets {} bytes ({})", packets_in, bytes_in, human_readable_size(bytes_in));
|
||||
outln("\tTX: {} packets {} bytes ({})", packets_out, bytes_out, human_readable_size(bytes_out));
|
||||
outln("\tMTU: {}", mtu);
|
||||
outln();
|
||||
});
|
||||
} else {
|
||||
|
||||
if (!value_adapter) {
|
||||
fprintf(stderr, "No network adapter was specified.\n");
|
||||
warnln("No network adapter was specified.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ int main(int argc, char** argv)
|
|||
auto address = IPv4Address::from_string(value_ipv4);
|
||||
|
||||
if (!address.has_value()) {
|
||||
fprintf(stderr, "Invalid IPv4 address: '%s'\n", value_ipv4);
|
||||
warnln("Invalid IPv4 address: '{}'", value_ipv4);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ int main(int argc, char** argv)
|
|||
|
||||
bool fits = ifname.copy_characters_to_buffer(ifr.ifr_name, IFNAMSIZ);
|
||||
if (!fits) {
|
||||
fprintf(stderr, "Interface name '%s' is too long\n", ifname.characters());
|
||||
warnln("Interface name '{}' is too long", ifname);
|
||||
return 1;
|
||||
}
|
||||
ifr.ifr_addr.sa_family = AF_INET;
|
||||
|
@ -117,7 +117,7 @@ int main(int argc, char** argv)
|
|||
auto address = IPv4Address::from_string(value_mask);
|
||||
|
||||
if (!address.has_value()) {
|
||||
fprintf(stderr, "Invalid IPv4 mask: '%s'\n", value_mask);
|
||||
warnln("Invalid IPv4 mask: '{}'", value_mask);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ int main(int argc, char** argv)
|
|||
|
||||
bool fits = ifname.copy_characters_to_buffer(ifr.ifr_name, IFNAMSIZ);
|
||||
if (!fits) {
|
||||
fprintf(stderr, "Interface name '%s' is too long\n", ifname.characters());
|
||||
warnln("Interface name '{}' is too long", ifname);
|
||||
return 1;
|
||||
}
|
||||
ifr.ifr_netmask.sa_family = AF_INET;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue