diff options
author | Lennart Poettering <lennart@poettering.net> | 2004-11-09 00:14:07 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2004-11-09 00:14:07 +0000 |
commit | 3916a66a87a639a1733cfe4fb33f32904eda7f59 (patch) | |
tree | b1289ecb8500a5c350b9e7ce1ec0bb5592a769ec /polyp/util.c | |
parent | 89e39f13b5b122d7dd17499b9b69fdccc196a30c (diff) |
export FQDN instead of hostname
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@277 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'polyp/util.c')
-rw-r--r-- | polyp/util.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/polyp/util.c b/polyp/util.c index b4c16dbb..ad91a307 100644 --- a/polyp/util.c +++ b/polyp/util.c @@ -43,6 +43,7 @@ #include <limits.h> #include <unistd.h> #include <grp.h> +#include <netdb.h> #include <samplerate.h> @@ -773,3 +774,22 @@ size_t pa_parsehex(const char *p, uint8_t *d, size_t dlength) { return j; } + +char *pa_get_fqdn(char *s, size_t l) { + char hn[256]; + struct addrinfo *a, hints; + + if (!pa_get_host_name(hn, sizeof(hn))) + return NULL; + + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_UNSPEC; + hints.ai_flags = AI_CANONNAME; + + if (getaddrinfo(hn, NULL, &hints, &a) < 0 || !a || !a->ai_canonname || !*a->ai_canonname) + return pa_strlcpy(s, hn, l); + + pa_strlcpy(s, a->ai_canonname, l); + freeaddrinfo(a); + return s; +} |