[fpc-pascal] Portable (or at least working) version of GetDomainName()?

Tomas Hajny XHajT03 at hajny.biz
Tue Apr 9 20:10:07 CEST 2013

On Tue, April 9, 2013 19:51, waldo kitty wrote:
> On 4/9/2013 04:24, Tomas Hajny wrote:
>> Have you tried using unit netdb from package fcl-net? It doesn't support
>> Windows (and some other platforms yet), but it should work for Unix
>> targets. I believe that the two approaches for finding out the domain
>> are
>> either getting it from the DNS or having it specified in /etc/resolv
>> (and
>> both are used by unit netdb - search for DefaultDomainList).
> shouldn't the OS' lookup routines handle whether the value from HOSTS or
> DNS is
> used automatically? i know that on some systems, one can specify to use
> first (ie: USE_HOSTS_FIRST=1 [OS2] or /etc/host.conf [*nix])... i've seen
> it in
> winwhatever once upon a long time ago...

That depends on what API provided by the respective OS. As far as I
understand it correctly, Unix does not provide such functionality in the
basic API (syscalls) but only e.g. in libc (which is in turn used by
nslookup, etc.), so Pascal code (for Unix) not using libc needs to
implement this logic (that's what unit netdb does).


More information about the fpc-pascal mailing list