]>
git.ipfire.org Git - thirdparty/squid.git/blob - lib/getfullhostname.c
2 * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
10 #include "getfullhostname.h"
13 /* for gethostname() function */
17 /* for gethostbyname() */
21 /* for RFC 2181 constants */
24 /* for xstrncpy() - may need breaking out of there. */
28 \retval NULL An error occured.
29 \retval * The fully qualified name (FQDN) of the current host.
30 * Pointer is only valid until the next call to the gethost*() functions.
32 \todo Make this a squid String result so the duration limit is flexible.
37 const struct hostent
*hp
= NULL
;
38 static char buf
[RFC2181_MAXHOSTNAMELEN
+ 1];
40 if (gethostname(buf
, RFC2181_MAXHOSTNAMELEN
) < 0)
42 /** \todo convert this to a getaddrinfo() call */
43 if ((hp
= gethostbyname(buf
)) != NULL
)
44 xstrncpy(buf
, hp
->h_name
, RFC2181_MAXHOSTNAMELEN
);