Module domain

This module provides a couple of simple utilities to deal with the access to internationalized domain names (IDNs). The predicate make_domain/3 allows constructing and deconstructing user and host. The predicate works bidirectional without loss of data.

?- make_domain('foo','λ.com',X).
X = 'foo@λ.com'

The predicate host_lookup/2 can be used to perform a forward or reverse lookup of a host name. The predicate will fail if the host name is not known. The predicate ping_host/1 can be used to check the reachability of a host name. The Java internet libraries do not automatically a name preparation. Neither do our Prolog predicates presented so far.

?- uri_puny('http://zü', X).
X = ''

Name preparation is for example required for host names. Domain name servers only work with ASCII represented host names and the recommended encoding of Unicode towards ASCII for host names is puny code. Such an encoding can be invoked by the predicate uri_puny/2 provided in this module.

The following domain predicates are provided:

make_domain(U, H, D):
If U and H are variables, then the predicate succeeds when U and H unify with the user and the host of the domain D. Otherwise the predicates succeeds when D unifies with the constructed domain.
host_lookup(U, C):
If U is a variable then the predicate succeeds when U unifies with reverse lookup of C. Otherwise the predicate succeeds when C unifies with the forward lookup of U.
The predicate succeeds when the host H is reachable.
uri_puny(S, P):
If S is a variable then the predicate succeeds when S unifies with the puny decode of P. Otherwise the predicate succeeds when P unifies with the puny encode of S.
sha1_hash(B, H):
The predicate succeeds in H with the SHA-1 hash block of the block B.