5static int printFile(
const char* path) {
6 FILE* file = fopen(path,
"r");
14 while ((count = fread(buffer, 1,
sizeof(buffer), file))) {
15 if (fwrite(buffer, 1, count, stdout) != count) {
28int main(
int argc,
char* argv[]) {
30 const bool help = argc == 2 && !strcmp(argv[1],
"--help");
31 fprintf(help ? stdout : stderr,
32 "Usage: netconfig\nShow network devices, addresses, and DNS.\n");
35 if (printFile(
"/proc/net/interfaces"))
38 if (printFile(
"/proc/resolv.conf"))
40 if (fflush(stdout) || ferror(stdout)) {