/*----------------------------------------------------------------------
       Return canonical form of host name ala c-client (UNIX version).

   Args: host      -- The host name

 Result: Canonical form, or input argument (worst case)
 ----*/
char *
canonical_name(host)
    char *host;
{
    struct hostent *hent;
    char tmp[MAILTMPLEN];

                                /* domain literal is easy */
    if (host[0] == '[' && host[(strlen (host))-1] == ']')
      return host;

    strncpy(tmp, host, sizeof(tmp)-1);
    tmp[sizeof(tmp)-1] = '\0';

    return (hent = gethostbyname((char *) lcase((unsigned char *) tmp))) ?
      hent->h_name : host;
}


