1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

[svn] Look for and use socklen_t.

This commit is contained in:
hniksic 2003-10-10 18:39:07 -07:00
parent 8ecf4f71f5
commit 5155384340
8 changed files with 62 additions and 20 deletions

33
aclocal.m4 vendored
View File

@ -74,7 +74,7 @@ case "x$am_cv_prog_cc_stdc" in
esac
])
AC_DEFUN(WGET_STRUCT_UTIMBUF,
AC_DEFUN([WGET_STRUCT_UTIMBUF],
[AC_MSG_CHECKING([for struct utimbuf])
if test x"$ac_cv_header_utime_h" = xyes; then
AC_EGREP_CPP([struct[ ]+utimbuf],
@ -87,6 +87,37 @@ else
fi])
dnl Check for socklen_t. The third argument of accept, getsockname,
dnl etc. is int * on some systems, but size_t * on others. POSIX
dnl finally standardized on socklen_t, but older systems don't have
dnl it. If socklen_t exists, we use it, else if accept() accepts
dnl size_t *, we use that, else we use int.
AC_DEFUN([WGET_SOCKLEN_T], [
AC_MSG_CHECKING(for socklen_t)
AC_TRY_COMPILE([
#include <sys/types.h>
#include <sys/socket.h>
socklen_t x;
],
[], [AC_MSG_RESULT(yes)], [
AC_TRY_COMPILE([
#include <sys/types.h>
#include <sys/socket.h>
int accept (int, struct sockaddr *, size_t *);
],
[], [
AC_MSG_RESULT(size_t)
AC_DEFINE(socklen_t, size_t)
], [
AC_MSG_RESULT(int)
AC_DEFINE(socklen_t, int)
])
])
])
dnl ************************************************************
dnl START OF IPv6 AUTOCONFIGURATION SUPPORT MACROS
dnl ************************************************************

View File

@ -175,8 +175,10 @@ dnl
AC_TYPE_SIGNAL
dnl
dnl Check for struct utimbuf
dnl Call several of Wget's macros.
dnl
WGET_STRUCT_UTIMBUF
WGET_SOCKLEN_T
dnl
dnl Checks for library functions.

View File

@ -1,3 +1,15 @@
2003-10-11 Hrvoje Niksic <hniksic@xemacs.org>
* ftp-basic.c (ftp_epsv): Use socklen_t * as the third argument to
getpeername.
* config.h.in: Define socklen_t stub.
* host.c (sockaddr_len): Return socklen_t.
* connect.c (conaddr): Use socklen_t as the third argument to
accept, getsockname, and connect.
2003-10-10 Hrvoje Niksic <hniksic@xemacs.org>
* recur.c (retrieve_tree): Don't descend into documents that are

View File

@ -271,6 +271,9 @@ char *alloca ();
/* Define if you want to enable the IPv6 support. */
#undef ENABLE_IPV6
/* Define if you don't have socklen_t. */
#undef socklen_t
/* First a gambit to see whether we're on Solaris. We'll
need it below. */
#ifdef __sun

View File

@ -98,7 +98,7 @@ resolve_bind_address (void)
struct cwt_context {
int fd;
const struct sockaddr *addr;
int addrlen;
socklen_t addrlen;
int result;
};
@ -114,7 +114,7 @@ connect_with_timeout_callback (void *arg)
ETIMEDOUT. */
static int
connect_with_timeout (int fd, const struct sockaddr *addr, int addrlen,
connect_with_timeout (int fd, const struct sockaddr *addr, socklen_t addrlen,
double timeout)
{
struct cwt_context ctx;
@ -327,10 +327,7 @@ bindport (unsigned short *port, int family)
DEBUGP (("Master socket fd %d bound.\n", msock));
if (!*port)
{
/* #### addrlen should be a 32-bit type, which int is not
guaranteed to be. Oh, and don't try to make it a size_t,
because that can be 64-bit. */
int sa_len = sockaddr_len ();
socklen_t sa_len = sockaddr_len ();
if (getsockname (msock, &srv.sa, &sa_len) < 0)
{
CLOSE (msock);
@ -392,7 +389,7 @@ select_fd (int fd, double maxtime, int writep)
uerr_t
acceptport (int *sock)
{
int addrlen = sockaddr_len ();
socklen_t addrlen = sockaddr_len ();
#ifdef HAVE_SELECT
if (select_fd (msock, opt.connect_timeout, 0) <= 0)
@ -423,11 +420,8 @@ int
conaddr (int fd, ip_address *ip)
{
wget_sockaddr mysrv;
/* see bindport() for discussion of using `int' here. */
int addrlen = sizeof (mysrv);
if (getsockname (fd, &mysrv.sa, (int *)&addrlen) < 0)
socklen_t addrlen = sizeof (mysrv);
if (getsockname (fd, &mysrv.sa, &addrlen) < 0)
return 0;
switch (mysrv.sa.sa_family)

View File

@ -420,9 +420,9 @@ ftp_epsv (struct rbuf *rbuf, ip_address *addr, unsigned short *port,
/* Now we have the port but we need the IPv6 :-( */
{
wget_sockaddr remote;
int len = sizeof (remote);
struct sockaddr_in *ipv4_sock = ( struct sockaddr_in *)&remote;
getpeername (RBUF_FD (rbuf), (struct sockaddr*)&remote, &len);
socklen_t addrlen = sizeof (remote);
struct sockaddr_in *ipv4_sock = (struct sockaddr_in *)&remote;
getpeername (RBUF_FD (rbuf), (struct sockaddr *)&remote, &addrlen);
switch(remote.sa.sa_family)
{
case AF_INET6:

View File

@ -419,9 +419,9 @@ wget_sockaddr_get_port (const wget_sockaddr *sa)
* - Public IP-Family Information
*
* Output:
* int structure length for socket options
* socklen_t structure length for socket options
*/
int
socklen_t
sockaddr_len ()
{
if (ip_default_family == AF_INET)

View File

@ -97,7 +97,7 @@ void wget_sockaddr_set_address PARAMS((wget_sockaddr *, int,
void wget_sockaddr_set_port PARAMS((wget_sockaddr *, unsigned short));
void *wget_sockaddr_get_addr PARAMS((wget_sockaddr *));
unsigned short wget_sockaddr_get_port PARAMS((const wget_sockaddr *));
int sockaddr_len PARAMS(());
socklen_t sockaddr_len PARAMS(());
void map_ipv4_to_ip PARAMS((ip4_address *, ip_address *));
int map_ip_to_ipv4 PARAMS((ip_address *, ip4_address *));