]>
git.ipfire.org Git - thirdparty/squid.git/blob - lib/getfullhostname.c
3 * $Id: getfullhostname.c,v 1.13 1997/04/28 04:30:04 wessels Exp $
6 * AUTHOR: Harvest Derived
8 * SQUID Internet Object Cache http://squid.nlanr.net/Squid/
9 * --------------------------------------------------------
11 * Squid is the result of efforts by numerous individuals from the
12 * Internet community. Development is led by Duane Wessels of the
13 * National Laboratory for Applied Network Research and funded by
14 * the National Science Foundation.
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
34 * Copyright (c) 1994, 1995. All rights reserved.
36 * The Harvest software was developed by the Internet Research Task
37 * Force Research Group on Resource Discovery (IRTF-RD):
39 * Mic Bowman of Transarc Corporation.
40 * Peter Danzig of the University of Southern California.
41 * Darren R. Hardy of the University of Colorado at Boulder.
42 * Udi Manber of the University of Arizona.
43 * Michael F. Schwartz of the University of Colorado at Boulder.
44 * Duane Wessels of the University of Colorado at Boulder.
46 * This copyright notice applies to software in the Harvest
47 * ``src/'' directory only. Users should consult the individual
48 * copyright notices in the ``components/'' subdirectories for
49 * copyright information about other software bundled with the
50 * Harvest source code distribution.
54 * The Harvest software may be used and re-distributed without
55 * charge, provided that the software origin and research team are
56 * cited in any use of the system. Most commonly this is
57 * accomplished by including a link to the Harvest Home Page
58 * (http://harvest.cs.colorado.edu/) from the query page of any
59 * Broker you deploy, as well as in the query result pages. These
60 * links are generated automatically by the standard Broker
61 * software distribution.
63 * The Harvest software is provided ``as is'', without express or
64 * implied warranty, and with no support nor obligation to assist
65 * in its use, correction, modification or enhancement. We assume
66 * no liability with respect to the infringement of copyrights,
67 * trade secrets, or any patents, and are not responsible for
68 * consequential damages. Proper use of the Harvest software is
69 * entirely the responsibility of the user.
73 * Users may make derivative works from the Harvest software, subject
74 * to the following constraints:
76 * - You must include the above copyright notice and these
77 * accompanying paragraphs in all forms of derivative works,
78 * and any documentation and other materials related to such
79 * distribution and use acknowledge that the software was
80 * developed at the above institutions.
82 * - You must notify IRTF-RD regarding your distribution of
83 * the derivative work.
85 * - You must clearly notify users that your are distributing
86 * a modified version and not the original Harvest software.
88 * - Any derivative product is also subject to these copyright
89 * and use restrictions.
91 * Note that the Harvest software is NOT in the public domain. We
92 * retain copyright, as specified above.
94 * HISTORY OF FREE SOFTWARE STATUS
96 * Originally we required sites to license the software in cases
97 * where they were going to build commercial products/services
98 * around Harvest. In June 1995 we changed this policy. We now
99 * allow people to use the core Harvest software (the code found in
100 * the Harvest ``src/'' directory) for free. We made this change
101 * in the interest of encouraging the widest possible deployment of
102 * the technology. The Harvest software is really a reference
103 * implementation of a set of protocols and formats, some of which
104 * we intend to standardize. We encourage commercial
105 * re-implementations of code complying to this set of standards.
120 #include <sys/param.h>
123 #include <sys/types.h>
125 #if HAVE_SYS_SOCKET_H
126 #include <sys/socket.h>
128 #if HAVE_NETINET_IN_H
129 #include <netinet/in.h>
132 #include <arpa/inet.h>
134 #if HAVE_NETDB_H && !defined(_SQUID_NETDB_H_) /* protect on NEXTSTEP */
135 #define _SQUID_NETDB_H_
142 #include "ansiproto.h"
146 * getfullhostname() - Returns the fully qualified name of the current
147 * host, or NULL on error. Pointer is only valid until the next call
148 * to the gethost*() functions.
151 getfullhostname(void)
153 const struct hostent
*hp
= NULL
;
154 static char buf
[SQUIDHOSTNAMELEN
+ 1];
156 if (gethostname(buf
, SQUIDHOSTNAMELEN
) < 0)
158 if ((hp
= gethostbyname(buf
)) != NULL
)
159 xstrncpy(buf
, hp
->h_name
, SQUIDHOSTNAMELEN
);