squid-
cache.org
Optimising Web Delivery
Docs
Download
Donate
Support
About
Contact
Shop
Blog
lib
getfullhostname.c
Go to the documentation of this file.
1
/*
2
* Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3
*
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.
7
*/
8
9
#include "
squid.h
"
10
#include "
getfullhostname.h
"
11
12
#if HAVE_UNISTD_H
13
/* for gethostname() function */
14
#include <unistd.h>
15
#endif
16
#if HAVE_NETDB_H
17
/* for gethostbyname() */
18
#include <netdb.h>
19
#endif
20
21
/* for RFC 2181 constants */
22
#include "
rfc2181.h
"
23
24
/* for xstrncpy() - may need breaking out of there. */
25
#include "
util.h
"
26
33
const
char
*
34
getfullhostname
(
void
)
35
{
36
const
struct
hostent *hp =
NULL
;
37
// TODO: make this dynamic so the duration limit is flexible
38
static
char
buf[
RFC2181_MAXHOSTNAMELEN
+ 1];
39
40
if
(gethostname(buf,
RFC2181_MAXHOSTNAMELEN
) < 0)
41
return
NULL
;
42
// TODO: convert this to a getaddrinfo() call
43
if
((hp = gethostbyname(buf)) !=
NULL
)
44
xstrncpy
(buf, hp->h_name,
RFC2181_MAXHOSTNAMELEN
);
45
return
buf;
46
}
47
getfullhostname
const char * getfullhostname(void)
Definition:
getfullhostname.c:34
getfullhostname.h
rfc2181.h
RFC2181_MAXHOSTNAMELEN
#define RFC2181_MAXHOSTNAMELEN
Definition:
rfc2181.h:27
squid.h
NULL
#define NULL
Definition:
types.h:145
util.h
xstrncpy
char * xstrncpy(char *dst, const char *src, size_t n)
Definition:
xstring.cc:37
Introduction
About Squid
Why Squid?
Squid Developers
How to Donate
How to Help Out
Getting Squid
Squid Source Packages
Squid Deployment Case-Studies
Squid Software Foundation
Documentation
Quick Setup
Configuration:
Reference
Examples
FAQ
and
Wiki
Guide Books:
Beginners
Definitive
Non-English
More...
Support
Security Advisories
Bugzilla Database
Mailing lists
Contacting us
Commercial services
Project Sponsors
Squid-based products
Miscellaneous
Developer Resources
Related Writings
Related Software:
Authenticators
Ecap
Icap
Ident
Log Analysis
Monitor
Proxies
Redirectors
General
Squid Artwork
Web Site Translations
Japanese
Mirrors
Website:
gr
il
pl
...
full list
FTP Package Archive