mirror of
https://repo.or.cz/socat.git
synced 2024-12-22 23:42:34 +00:00
Check which getprotobynumber_r() variant to use
This commit is contained in:
parent
33a5019b18
commit
ffa09eac00
3 changed files with 27 additions and 4 deletions
8
CHANGES
8
CHANGES
|
@ -2,7 +2,13 @@
|
|||
Corrections:
|
||||
Socat 1.7.4.2 did not compile on OmniOS (and probably other OpenSolaris
|
||||
distributions)
|
||||
Thanks to Andy Fiddaman for sending a patch
|
||||
Thanks to Andy Fiddaman for sending a patch.
|
||||
|
||||
Socat since 1.7.4.0 did not compile on Solaris and its derivatives
|
||||
because the getprotobynumber_r() function prototype differ from the
|
||||
Linux versino.
|
||||
configure now checks for the variant.
|
||||
Thanks to Robert Zybeck for reporting this issue.
|
||||
|
||||
####################### V 1.7.4.2:
|
||||
|
||||
|
|
19
configure.ac
19
configure.ac
|
@ -134,6 +134,23 @@ if test $sc_cv_have_prototype_hstrerror = yes; then
|
|||
fi
|
||||
AC_MSG_RESULT($sc_cv_have_prototype_hstrerror)
|
||||
|
||||
# getprotobynumber_r() is not standardized
|
||||
AC_MSG_CHECKING(for getprotobynumber_r() variant)
|
||||
AC_CACHE_VAL(sc_cv_getprotobynumber_r,
|
||||
[AC_TRY_COMPILE([#include <stddef.h>
|
||||
#include <netdb.h>],[getprotobynumber_r(1,NULL,NULL,1024,NULL);],
|
||||
[sc_cv_getprotobynumber_r=1; tmp_bynum_variant=Linux],
|
||||
[AC_TRY_COMPILE([#include <stddef.h>
|
||||
#include <netdb.h>],[getprotobynumber_r(1,NULL,NULL,1024);],
|
||||
[sc_cv_getprotobynumber_r=2; tmp_bynum_variant=Solaris],
|
||||
# there is a 3 arg variant in AIX, but its doc is limited
|
||||
[sc_cv_getprotobynumber_r=]
|
||||
)])])
|
||||
if test "$sc_cv_getprotobynumber_r"; then
|
||||
AC_DEFINE_UNQUOTED(HAVE_GETPROTOBYNUMBER_R, $sc_cv_getprotobynumber_r)
|
||||
fi
|
||||
AC_MSG_RESULT($sc_cv_getprotobynumber_r /* $tmp_bynum_variant */)
|
||||
|
||||
|
||||
AC_MSG_CHECKING(whether to include help)
|
||||
AC_ARG_ENABLE(help, [ --disable-help disable help],
|
||||
|
@ -811,7 +828,7 @@ AC_TYPE_SIGNAL
|
|||
AC_FUNC_STRFTIME
|
||||
AC_CHECK_FUNCS(putenv select pselect poll socket strtod strtol)
|
||||
AC_CHECK_FUNCS(strtoul uname getpgid getsid gethostbyname getaddrinfo)
|
||||
AC_CHECK_FUNCS(getprotobynumber getprotobynumber_r)
|
||||
AC_CHECK_FUNCS(getprotobynumber)
|
||||
AC_CHECK_FUNCS(setgroups inet_aton)
|
||||
|
||||
AC_CHECK_FUNCS(grantpt unlockpt)
|
||||
|
|
4
fdname.c
4
fdname.c
|
@ -253,14 +253,14 @@ int sockname(int fd, FILE *outfile, char style) {
|
|||
#endif
|
||||
|
||||
#if defined(SO_PROTOCOL) || defined(SO_PROTOTYPE)
|
||||
#if HAVE_GETPROTOBYNUMBER_R
|
||||
#if HAVE_GETPROTOBYNUMBER_R==1 /* Linux */
|
||||
rc = getprotobynumber_r(proto, &protoent, protoname, sizeof(protoname), &protoentp);
|
||||
if (protoentp == NULL) {
|
||||
Warn2("sockname(): getprotobynumber_r(proto=%d, ...): %s",
|
||||
proto, strerror(rc));
|
||||
}
|
||||
strncpy(protoname, protoentp->p_name, sizeof(protoname));
|
||||
#elif HAVE_GETPROTOBYNUMBER
|
||||
#elif HAVE_GETPROTOBYNUMBER_R==2 /* Solaris */
|
||||
protoentp = getprotobynumber(proto);
|
||||
strncpy(protoname, protoentp->p_name, sizeof(protoname));
|
||||
#else
|
||||
|
|
Loading…
Reference in a new issue