190926Snectar/* 290926Snectar * Copyright (c) 1999 - 2001 Kungliga Tekniska H�gskolan 390926Snectar * (Royal Institute of Technology, Stockholm, Sweden). 490926Snectar * All rights reserved. 590926Snectar * 690926Snectar * Redistribution and use in source and binary forms, with or without 790926Snectar * modification, are permitted provided that the following conditions 890926Snectar * are met: 990926Snectar * 1090926Snectar * 1. Redistributions of source code must retain the above copyright 1190926Snectar * notice, this list of conditions and the following disclaimer. 1290926Snectar * 1390926Snectar * 2. Redistributions in binary form must reproduce the above copyright 1490926Snectar * notice, this list of conditions and the following disclaimer in the 1590926Snectar * documentation and/or other materials provided with the distribution. 1690926Snectar * 1790926Snectar * 3. Neither the name of the Institute nor the names of its contributors 1890926Snectar * may be used to endorse or promote products derived from this software 1990926Snectar * without specific prior written permission. 2090926Snectar * 2190926Snectar * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 2290926Snectar * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2390926Snectar * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2490926Snectar * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 2590926Snectar * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2690926Snectar * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2790926Snectar * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2890926Snectar * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2990926Snectar * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3090926Snectar * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3190926Snectar * SUCH DAMAGE. 3290926Snectar */ 3390926Snectar 3490926Snectar#ifdef HAVE_CONFIG_H 3590926Snectar#include <config.h> 36178825SdfrRCSID("$Id: hostent_find_fqdn.c 14773 2005-04-12 11:29:18Z lha $"); 3790926Snectar#endif 3890926Snectar 3990926Snectar#include "roken.h" 4090926Snectar 4190926Snectar/* 4290926Snectar * Try to find a fqdn (with `.') in he if possible, else return h_name 4390926Snectar */ 4490926Snectar 45178825Sdfrconst char * ROKEN_LIB_FUNCTION 4690926Snectarhostent_find_fqdn (const struct hostent *he) 4790926Snectar{ 4890926Snectar const char *ret = he->h_name; 4990926Snectar const char **h; 5090926Snectar 5190926Snectar if (strchr (ret, '.') == NULL) 5290926Snectar for (h = (const char **)he->h_aliases; *h != NULL; ++h) { 5390926Snectar if (strchr (*h, '.') != NULL) { 5490926Snectar ret = *h; 5590926Snectar break; 5690926Snectar } 5790926Snectar } 5890926Snectar return ret; 5990926Snectar} 60