DnsResolverAddPath
Description
Merge an additional hosts / resolv.conf file into an already-initialised resolver, on top of the system defaults DnsResolverInit loaded. The file is parsed with the same rules as /etc/hosts and /etc/resolv.conf and entries are APPENDED (the hosts table and/or nameserver list grow).
The self-classifying forms (DnsResolverAddPath / DnsResolverAddPaths) run BOTH parsers over each file: the two line grammars are disjoint (a hosts row leads with an IP literal, a resolv.conf directive leads with the nameserver keyword), so a hosts file contributes only host rows and a resolv.conf only nameservers. The typed forms (...HostsPath / ...ResolvPath) run a single parser when the caller already knows the file kind.
The Str * overload reads the path as-is; the (Zstr, len) overload copies [path, path+len) and NUL-terminates it. The plural forms apply the singular to each path in a Strs. Missing/unreadable files are tolerated (that table just doesn’t grow).
Success
Returns true. Parsed entries appended.
Failure
Returns false on NULL self / path.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
SysDns.c:1273:
"nameserver 8.8.8.8\n"
);
bool added = DnsResolverAddPath(&r, &path);
bool ok = added && VecLen(&r.hosts) == 1 && host_v4_is(find_host(&r.hosts, "hostrow"), 1, 2, 3, 4) &&- In
SysDns.c:1438:
"nameserver 8.8.8.8\n"
);
bool added = DnsResolverAddPath(&r, StrBegin(&path), StrLen(&path));
bool ok = added && VecLen(&r.hosts) == 1 && host_v4_is(find_host(&r.hosts, "zlhost"), 1, 2, 3, 4) &&