7 /* network domain name lookup
9 /* #include <get_domainname.h>
11 /* const char *get_domainname()
13 /* get_domainname() returns the local domain name as obtained
14 /* by stripping the hostname component from the result from
15 /* get_hostname(). The result is the hostname when get_hostname()
16 /* does not return a FQDN form ("foo"), or its result has only two
17 /* components ("foo.com").
19 /* Fatal errors: no hostname, invalid hostname.
25 /* The Secure Mailer license must be distributed with this software.
28 /* IBM T.J. Watson Research
30 /* Yorktown Heights, NY 10598, USA
38 /* Utility library. */
41 #include "get_hostname.h"
42 #include "get_domainname.h"
46 static char *my_domain_name
;
48 /* get_domainname - look up my domain name */
50 const char *get_domainname(void)
56 * Use the hostname when it is not a FQDN ("foo"), or when the hostname
57 * actually is a domain name ("foo.com").
59 if (my_domain_name
== 0) {
60 host
= get_hostname();
61 if ((dot
= strchr(host
, '.')) == 0 || strchr(dot
+ 1, '.') == 0) {
62 my_domain_name
= mystrdup(host
);
64 my_domain_name
= mystrdup(dot
+ 1);
67 return (my_domain_name
);