cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: getnameinfo() args

From: Jamie Lokier <jamie_at_shareable.org>
Date: Tue, 13 Dec 2005 18:48:49 +0000

Yang Tse wrote:
> getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
>
> Type of sa seems to always be const struct sockaddr *
> Type of host and serv seems to always be char*
> Types of salen can be, socklen_t size_t or int.

Do you know if this is consistent with the type of argument that must
be used with `accept'? In other words, is it socklen_t for
getnameinfo() when, and only when, it is 'socklen_t *' for accept's
last argument?

It easy enough to check what the argument to accept needs to be.

> Types of hostlen and servlen can be size_t or int
> Types of flags can be int or unsigned int.
>
> But I'm not sure if autoconf would be able to properly do the job
> since probes would be based on the ability to compile using different
> combinations of argument types and some would compile even not being
> the proper one. ???

In this case, the fact that it compiles is related to the fact that
the code is fine, despite the warning. `hostlen' and `servlen' are
always smaller than any of the possible types.

Sometimes you can check types be putting a function prototype in the
Autoconf test, after including the header file(s) which should provide
its prototype. If all the types, including the return type, match
then it compiles. Otherwise it may not. It will also compile if the
header files don't prototype the function at all, so conservative
defaults should be used, in that case. (It's easy to check for the
absence of a prototype in header files, if necessary, by declaring it
with fewer arguments).

-- Jamie
Received on 2005-12-13