From f5e48e94a2f4d4bbd6e5628c7f2afafc6dbcc459 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Thu, 7 Mar 2024 17:28:52 -0500 Subject: build: Build mlibc + add distclean target Signed-off-by: Ian Moffett --- lib/mlibc/options/posix/generic/resolv_conf.cpp | 42 ------------------------- 1 file changed, 42 deletions(-) delete mode 100644 lib/mlibc/options/posix/generic/resolv_conf.cpp (limited to 'lib/mlibc/options/posix/generic/resolv_conf.cpp') diff --git a/lib/mlibc/options/posix/generic/resolv_conf.cpp b/lib/mlibc/options/posix/generic/resolv_conf.cpp deleted file mode 100644 index a5c3aa7..0000000 --- a/lib/mlibc/options/posix/generic/resolv_conf.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include -#include -#include -#include - -namespace mlibc { - -frg::optional get_nameserver() { - auto file = fopen("/etc/resolv.conf", "r"); - if (!file) - return frg::null_opt; - - char line[128]; - struct nameserver_data ret; - while (fgets(line, 128, file)) { - char *pos; - if (!strchr(line, '\n') && !feof(file)) { - // skip truncated lines - for (int c = getc(file); c != '\n' && c != EOF; c = getc(file)); - continue; - } - - // TODO(geert): resolv.conf can actually have multiple nameservers - // but we just pick the first one for now - if (!strncmp(line, "nameserver", 10) && isspace(line[10])) { - char *end; - for (pos = line + 11; isspace(*pos); pos++); - for (end = pos; *end && !isspace(*end); end++); - *end = '\0'; - ret.name = frg::string( - pos, end - pos, getAllocator()); - break; - } - } - - fclose(file); - if(ret.name.empty()) - return frg::null_opt; - return ret; -} - -} // namespace mlibc -- cgit v1.2.3