Simon Josefsson wrote:
> Then I'm less sure that it makes sense for
> gnulib's limit.h to define HOST_NAME_MAX -- programs written against
> POSIX should not assume that symbol exists.
On the other hand, the support of POSIX for unspecified maximum host
name lengths is weak: You see in [1] that
- when the host name is longer than namelen, the string is truncated,
possibly NUL terminated or not,
- when gethostname fails, it is unspecified whether it sets errno.
The reality (see lib/xgethostname.c) is even worse:
- when the host name is longer than namelen, then some platforms
return -1, others don't; some platforms even write past the specified
namelength bytes,
- the errnos appearing in this case are far from standard.
I think it's a favour that gnulib can do to its users, to not force
developers to deal with these pitfalls.
And don't tell me that host names longer than 256 bytes occur frequently :-)
> Do sysconf work under mingw? Gnulib could provide a replacement if not.
That would be some work, because of the many arguments that sysconf
should support. [2]
Bruno
[1] http://www.opengroup.org/onlinepubs/9699919799/functions/gethostname.html
[2] http://www.opengroup.org/onlinepubs/9699919799/functions/sysconf.html