From 462d27d7e633e368928569f8fbe9e25ab3e72e1c Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 11 Jul 2004 06:50:31 +0000 Subject: r1434: Merge this function in from Samba 3.0, but use a mem_ctx rather than an fstring. Andrew Bartlett (This used to be commit e8de8905b2f328395d71afdd73c77301c9366a66) --- source4/lib/util.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/source4/lib/util.c b/source4/lib/util.c index 3b23543bfc..3666d6e4e7 100644 --- a/source4/lib/util.c +++ b/source4/lib/util.c @@ -797,6 +797,23 @@ char *myhostname(TALLOC_CTX *mem_ctx) } +/********************************************************************** + Converts a name to a fully qalified domain name. +***********************************************************************/ + +char *name_to_fqdn(TALLOC_CTX *mem_ctx, const char *name) +{ + struct hostent *hp = sys_gethostbyname(name); + if ( hp && hp->h_name && *hp->h_name ) { + DEBUG(10,("name_to_fqdn: lookup for %s -> %s.\n", name, hp->h_name)); + return talloc_strdup(mem_ctx, hp->h_name); + } else { + DEBUG(10,("name_to_fqdn: lookup for %s failed.\n", name)); + return talloc_strdup(mem_ctx, name); + } +} + + /***************************************************************** A useful function for returning a path in the Samba lock directory. *****************************************************************/ -- cgit