mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-11 01:06:01 +03:00
9e0f7acfe5
Added a simple /bin/ifconfig program that just pretty-prints that file. :^)
31 lines
775 B
C++
31 lines
775 B
C++
#include <LibCore/CFile.h>
|
|
#include <stdio.h>
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
UNUSED_PARAM(argc);
|
|
UNUSED_PARAM(argv);
|
|
|
|
CFile file("/proc/netadapters");
|
|
if (!file.open(CIODevice::ReadOnly)) {
|
|
fprintf(stderr, "Error: %s\n", file.error_string());
|
|
return 1;
|
|
}
|
|
|
|
for (;;) {
|
|
auto line = file.read_line(1024);
|
|
if (line.is_null())
|
|
break;
|
|
auto parts = String::copy(line, Chomp).split(',');
|
|
if (parts.size() < 4)
|
|
continue;
|
|
printf("%s:\n", parts[0].characters());
|
|
printf(" mac: %s\n", parts[2].characters());
|
|
printf(" ipv4: %s\n", parts[3].characters());
|
|
printf(" class: %s\n", parts[1].characters());
|
|
printf("\n");
|
|
}
|
|
|
|
return 0;
|
|
}
|