[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gethostname max len
From: |
Wolfgang Jaehrling |
Subject: |
Re: gethostname max len |
Date: |
Mon, 22 Mar 2004 02:05:11 +0100 |
User-agent: |
Mutt/1.3.28i |
On Mon, Mar 22, 2004 at 08:22:52AM +1000, Kevin Ryde wrote:
> * posix.c (scm_gethostname): Use sysconf(_SC_HOST_NAME_MAX) and
> MAXHOSTNAMELEN when available.
>
> It's possible MAXHOSTNAMELEN is enough in practice, but posix
> specifies HOST_NAME_MAX instead of MAXHOSTNAMELEN, so it seems
> worthwhile checking that too.
The Single Unix Specification says about sysconf():
"If name is an invalid value, sysconf() shall return -1 and set
errno to indicate the error. If the variable corresponding to name
has no limit, sysconf() shall return -1 without changing the value
of errno."
And in the following informative section:
"As -1 is a permissible return value in a successful situation, an
application wishing to check for error situations should set errno
to 0, then call sysconf(), and, if it returns -1, check to see if
errno is non-zero."
Which is what Guile probably also should do, otherwise it won't work
correctly on the GNU system, which has no limit on the length of host
names; the current code that checks for ENAMETOOLONG looks quite
GNU/Linux-specific.
Cheers,
Wolfgang
--
Repeating false statements makes them true.
Repeating false statements makes them true.
Repeating false statements makes them true.