1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-22 08:08:50 -05:00

Use build-time configured curl_socklen_t instead of socklen_t

This commit is contained in:
Yang Tse 2009-05-02 02:37:32 +00:00
parent 80186aa7f4
commit 9137e717b0
30 changed files with 41 additions and 265 deletions

View File

@ -6,6 +6,9 @@
Changelog Changelog
Yang Tse (2 May 2009)
- Use a build-time configured curl_socklen_t data type instead of socklen_t.
Yang Tse (1 May 2009) Yang Tse (1 May 2009)
- Applied David McCreedy's patches "TPF-platform specific changes to various - Applied David McCreedy's patches "TPF-platform specific changes to various
files" and "http.c fix to Curl_proxyCONNECT for non-ASCII platforms", the files" and "http.c fix to Curl_proxyCONNECT for non-ASCII platforms", the

View File

@ -688,10 +688,6 @@ ENDIF(HAVE_INET_NTOA_R_DECL_REENTRANT)
# Some other minor tests # Some other minor tests
IF(NOT HAVE_SOCKLEN_T)
SET(socklen_t "int")
ENDIF(NOT HAVE_SOCKLEN_T)
IF(NOT HAVE_IN_ADDR_T) IF(NOT HAVE_IN_ADDR_T)
SET(in_addr_t "unsigned long") SET(in_addr_t "unsigned long")
ENDIF(NOT HAVE_IN_ADDR_T) ENDIF(NOT HAVE_IN_ADDR_T)

View File

@ -15,6 +15,7 @@ This release includes the following changes:
the build-time fixed number the build-time fixed number
o CURLOPT_SEEKFUNCTION may now return CURL_SEEKFUNC_CANTSEEK o CURLOPT_SEEKFUNCTION may now return CURL_SEEKFUNC_CANTSEEK
o curl can now upload with resume even when reading from a pipe o curl can now upload with resume even when reading from a pipe
o a build-time configured curl_socklen_t is now used instead of socklen_t
This release includes the following bugfixes: This release includes the following bugfixes:
@ -49,6 +50,6 @@ advice from friends like these:
Andre Guibert de Bruet, Andreas Farber, Frank Hempel, Pierre Brico, Andre Guibert de Bruet, Andreas Farber, Frank Hempel, Pierre Brico,
Kamil Dudka, Jim Freeman, Daniel Johnson, Toshio Kuratomi, Martin Storsjo, Kamil Dudka, Jim Freeman, Daniel Johnson, Toshio Kuratomi, Martin Storsjo,
Pramod Sharma, Gisle Vanem, Leanic Lefever, Rainer Koenig, Sven Wegener, Pramod Sharma, Gisle Vanem, Leanic Lefever, Rainer Koenig, Sven Wegener,
Tim Chen, Constantine Sapuntzakis David McCreedy Tim Chen, Constantine Sapuntzakis, David McCreedy
Thanks! (and sorry if I forgot to mention someone) Thanks! (and sorry if I forgot to mention someone)

View File

@ -983,94 +983,6 @@ AC_DEFUN([CURL_CHECK_HEADER_MEMORY], [
]) ])
dnl CURL_CHECK_TYPE_SOCKLEN_T
dnl -------------------------------------------------
dnl Check for existing socklen_t type, and provide
dnl an equivalent type if socklen_t not available
AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [
AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
AC_CHECK_TYPE([socklen_t], ,[
dnl socklen_t not available
AC_CACHE_CHECK([for socklen_t equivalent],
[curl_cv_socklen_t_equiv], [
curl_cv_socklen_t_equiv="unknown"
for arg1 in 'int' 'SOCKET'; do
for arg2 in "struct sockaddr" void; do
for t in int size_t unsigned long "unsigned long"; do
if test "$curl_cv_socklen_t_equiv" = "unknown"; then
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
#undef inline
#ifdef HAVE_WINDOWS_H
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
#else
#ifdef HAVE_WINSOCK_H
#include <winsock.h>
#endif
#endif
#define GETPEERNCALLCONV PASCAL
#else
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#define GETPEERNCALLCONV
#endif
extern int GETPEERNCALLCONV getpeername($arg1, $arg2 *, $t *);
]],[[
$t len=0;
getpeername(0,0,&len);
]])
],[
curl_cv_socklen_t_equiv="$t"
])
fi
done
done
done
])
case "$curl_cv_socklen_t_equiv" in
unknown)
AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
;;
*)
AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
[Type to use in place of socklen_t when system does not provide it.])
;;
esac
],[
#undef inline
#ifdef HAVE_WINDOWS_H
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
#ifdef HAVE_WS2TCPIP_H
#include <ws2tcpip.h>
#endif
#endif
#else
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#endif
])
])
dnl CURL_CHECK_FUNC_GETNAMEINFO dnl CURL_CHECK_FUNC_GETNAMEINFO
dnl ------------------------------------------------- dnl -------------------------------------------------
dnl Test if the getnameinfo function is available, dnl Test if the getnameinfo function is available,
@ -1084,7 +996,6 @@ dnl argument in GETNAMEINFO_QUAL_ARG1.
AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [ AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
AC_REQUIRE([CURL_CHECK_TYPE_SOCKLEN_T])dnl
AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h) AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
# #
AC_MSG_CHECKING([for getnameinfo]) AC_MSG_CHECKING([for getnameinfo])

View File

@ -2021,9 +2021,6 @@ AC_CHECK_TYPE([bool],[
CURL_CONFIGURE_CURL_SOCKLEN_T CURL_CONFIGURE_CURL_SOCKLEN_T
# Check for socklen_t or equivalent
CURL_CHECK_TYPE_SOCKLEN_T
TYPE_IN_ADDR_T TYPE_IN_ADDR_T
TYPE_SOCKADDR_STORAGE TYPE_SOCKADDR_STORAGE

View File

@ -35,7 +35,7 @@
(setq tab-width 8 (setq tab-width 8
indent-tabs-mode nil ; Use spaces. Not tabs. indent-tabs-mode nil ; Use spaces. Not tabs.
comment-column 40 comment-column 40
c-font-lock-extra-types (append '("bool" "CURL" "CURLcode" "ssize_t" "size_t" "socklen_t" "fd_set" "time_t" "curl_off_t" "curl_socket_t" "in_addr_t" "CURLSHcode" "CURLMcode" "Curl_addrinfo")) c-font-lock-extra-types (append '("bool" "CURL" "CURLcode" "ssize_t" "size_t" "curl_socklen_t" "fd_set" "time_t" "curl_off_t" "curl_socket_t" "in_addr_t" "CURLSHcode" "CURLMcode" "Curl_addrinfo"))
) )
;; keybindings for C, C++, and Objective-C. We can put these in ;; keybindings for C, C++, and Objective-C. We can put these in
;; c-mode-base-map because of inheritance ... ;; c-mode-base-map because of inheritance ...

View File

@ -389,8 +389,8 @@
# define CURL_SUFFIX_CURL_OFF_T L # define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL # define CURL_SUFFIX_CURL_OFF_TU UL
# endif # endif
# define CURL_TYPEOF_CURL_SOCKLEN_T FIXME # define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int
# define CURL_SIZEOF_CURL_SOCKLEN_T -1 # define CURL_SIZEOF_CURL_SOCKLEN_T 4
#elif defined(__OS400__) #elif defined(__OS400__)
# if defined(__ILEC400__) # if defined(__ILEC400__)

View File

@ -407,7 +407,6 @@ ifeq ($(LIBARCH),CLIB)
@echo $(DL)#define SEND_TYPE_ARG3 int$(DL) >> $@ @echo $(DL)#define SEND_TYPE_ARG3 int$(DL) >> $@
@echo $(DL)#define SEND_TYPE_ARG4 int$(DL) >> $@ @echo $(DL)#define SEND_TYPE_ARG4 int$(DL) >> $@
@echo $(DL)#define SEND_TYPE_RETV int$(DL) >> $@ @echo $(DL)#define SEND_TYPE_RETV int$(DL) >> $@
@echo $(DL)#define socklen_t int$(DL) >> $@
@echo $(DL)#define pressanykey PressAnyKeyToContinue$(DL) >> $@ @echo $(DL)#define pressanykey PressAnyKeyToContinue$(DL) >> $@
else else
@echo $(DL)#define OS "i586-pc-libc-NetWare"$(DL) >> $@ @echo $(DL)#define OS "i586-pc-libc-NetWare"$(DL) >> $@
@ -557,9 +556,6 @@ endif
@echo $(DL)#else$(DL) >> $@ @echo $(DL)#else$(DL) >> $@
@echo $(DL)#define HAVE_VARIADIC_MACROS_C99 1$(DL) >> $@ @echo $(DL)#define HAVE_VARIADIC_MACROS_C99 1$(DL) >> $@
@echo $(DL)#endif$(DL) >> $@ @echo $(DL)#endif$(DL) >> $@
ifdef OLD_NOVELLSDK
@echo $(DL)#define socklen_t int$(DL) >> $@
endif
ifdef CABUNDLE ifdef CABUNDLE
@echo $(DL)#define CURL_CA_BUNDLE "$(CABUNDLE)"$(DL) >> $@ @echo $(DL)#define CURL_CA_BUNDLE "$(CABUNDLE)"$(DL) >> $@
else else

View File

@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -108,9 +108,6 @@
#define TIME_WITH_SYS_TIME 1 #define TIME_WITH_SYS_TIME 1
#define in_addr_t int #define in_addr_t int
#ifndef socklen_t
# define socklen_t int
#endif
#ifndef O_RDONLY #ifndef O_RDONLY
# define O_RDONLY 0x0000 # define O_RDONLY 0x0000
@ -119,7 +116,7 @@
#define HAVE_GETNAMEINFO 1 #define HAVE_GETNAMEINFO 1
#define GETNAMEINFO_QUAL_ARG1 const #define GETNAMEINFO_QUAL_ARG1 const
#define GETNAMEINFO_TYPE_ARG1 struct sockaddr * #define GETNAMEINFO_TYPE_ARG1 struct sockaddr *
#define GETNAMEINFO_TYPE_ARG2 socklen_t #define GETNAMEINFO_TYPE_ARG2 int
#define GETNAMEINFO_TYPE_ARG46 size_t #define GETNAMEINFO_TYPE_ARG46 size_t
#define GETNAMEINFO_TYPE_ARG7 int #define GETNAMEINFO_TYPE_ARG7 int

View File

@ -48,9 +48,6 @@
/* Define this to 'int' if ssize_t is not an available typedefed type */ /* Define this to 'int' if ssize_t is not an available typedefed type */
#undef ssize_t #undef ssize_t
/* Type to use in place of socklen_t when system does not provide it. */
#undef socklen_t
/* Define this as a suitable file to read random data from */ /* Define this as a suitable file to read random data from */
#undef RANDOM_FILE #undef RANDOM_FILE

View File

@ -44,9 +44,6 @@
/* Define this to 'int' if ssize_t is not an available typedefed type */ /* Define this to 'int' if ssize_t is not an available typedefed type */
#undef ssize_t #undef ssize_t
/* Type to use in place of socklen_t when system does not provide it. */
#undef socklen_t
/* Define this as a suitable file to read random data from */ /* Define this as a suitable file to read random data from */
#undef RANDOM_FILE #undef RANDOM_FILE

View File

@ -788,9 +788,6 @@
/* Define to `unsigned int' if <sys/types.h> does not define. */ /* Define to `unsigned int' if <sys/types.h> does not define. */
/* #undef size_t */ /* #undef size_t */
/* Type to use in place of socklen_t when system does not provide it. */
/* #undef socklen_t */
/* the signed version of size_t */ /* the signed version of size_t */
/* #undef ssize_t */ /* #undef ssize_t */

View File

@ -668,9 +668,6 @@
/* Define to `unsigned' if <sys/types.h> does not define. */ /* Define to `unsigned' if <sys/types.h> does not define. */
/* #undef size_t */ /* #undef size_t */
/* Type to use in place of socklen_t when system does not provide it. */
/* #undef socklen_t */
/* the signed version of size_t */ /* the signed version of size_t */
/* #undef ssize_t */ /* #undef ssize_t */

View File

@ -117,7 +117,6 @@
#define CURL_DISABLE_LDAP 1 #define CURL_DISABLE_LDAP 1
#define in_addr_t u_long #define in_addr_t u_long
#define socklen_t int
#if defined(__HIGHC__) || \ #if defined(__HIGHC__) || \
(defined(__GNUC__) && __GNUC__ < 4) /* gcc 4.x built-in ? */ (defined(__GNUC__) && __GNUC__ < 4) /* gcc 4.x built-in ? */

View File

@ -946,8 +946,5 @@
/* Define to `unsigned int' if <sys/types.h> does not define. */ /* Define to `unsigned int' if <sys/types.h> does not define. */
#cmakedefine size_t ${size_t} #cmakedefine size_t ${size_t}
/* Type to use in place of socklen_t when system does not provide it. */
#cmakedefine socklen_t ${socklen_t}
/* the signed version of size_t */ /* the signed version of size_t */
#cmakedefine ssize_t ${ssize_t} #cmakedefine ssize_t ${ssize_t}

View File

@ -281,7 +281,7 @@ static CURLcode bindlocal(struct connectdata *conn,
struct Curl_sockaddr_storage sa; struct Curl_sockaddr_storage sa;
struct sockaddr *sock = (struct sockaddr *)&sa; /* bind to this address */ struct sockaddr *sock = (struct sockaddr *)&sa; /* bind to this address */
socklen_t sizeof_sa = 0; /* size of the data sock points to */ curl_socklen_t sizeof_sa = 0; /* size of the data sock points to */
struct sockaddr_in *si4 = (struct sockaddr_in *)&sa; struct sockaddr_in *si4 = (struct sockaddr_in *)&sa;
#ifdef ENABLE_IPV6 #ifdef ENABLE_IPV6
struct sockaddr_in6 *si6 = (struct sockaddr_in6 *)&sa; struct sockaddr_in6 *si6 = (struct sockaddr_in6 *)&sa;
@ -427,7 +427,7 @@ static CURLcode bindlocal(struct connectdata *conn,
if( bind(sockfd, sock, sizeof_sa) >= 0) { if( bind(sockfd, sock, sizeof_sa) >= 0) {
/* we succeeded to bind */ /* we succeeded to bind */
struct Curl_sockaddr_storage add; struct Curl_sockaddr_storage add;
socklen_t size = sizeof(add); curl_socklen_t size = sizeof(add);
memset(&add, 0, sizeof(struct Curl_sockaddr_storage)); memset(&add, 0, sizeof(struct Curl_sockaddr_storage));
if(getsockname(sockfd, (struct sockaddr *) &add, &size) < 0) { if(getsockname(sockfd, (struct sockaddr *) &add, &size) < 0) {
data->state.os_errno = error = SOCKERRNO; data->state.os_errno = error = SOCKERRNO;
@ -470,7 +470,7 @@ static bool verifyconnect(curl_socket_t sockfd, int *error)
bool rc = TRUE; bool rc = TRUE;
#ifdef SO_ERROR #ifdef SO_ERROR
int err = 0; int err = 0;
socklen_t errSize = sizeof(err); curl_socklen_t errSize = sizeof(err);
#ifdef WIN32 #ifdef WIN32
/* /*
@ -657,7 +657,7 @@ static void tcpnodelay(struct connectdata *conn,
{ {
#ifdef TCP_NODELAY #ifdef TCP_NODELAY
struct SessionHandle *data= conn->data; struct SessionHandle *data= conn->data;
socklen_t onoff = (socklen_t) data->set.tcp_nodelay; curl_socklen_t onoff = (curl_socklen_t) data->set.tcp_nodelay;
int proto = IPPROTO_TCP; int proto = IPPROTO_TCP;
#if 0 #if 0

View File

@ -221,7 +221,7 @@ Curl_getaddrinfo_ex(const char *nodename,
* int ai_family; * int ai_family;
* int ai_socktype; * int ai_socktype;
* int ai_protocol; * int ai_protocol;
* socklen_t ai_addrlen; * Follow rfc3493 struct addrinfo * * curl_socklen_t ai_addrlen; * Follow rfc3493 struct addrinfo *
* char *ai_canonname; * char *ai_canonname;
* struct sockaddr *ai_addr; * struct sockaddr *ai_addr;
* struct Curl_addrinfo *ai_next; * struct Curl_addrinfo *ai_next;

View File

@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -57,7 +57,7 @@ struct Curl_addrinfo {
int ai_family; int ai_family;
int ai_socktype; int ai_socktype;
int ai_protocol; int ai_protocol;
socklen_t ai_addrlen; /* Follow rfc3493 struct addrinfo */ curl_socklen_t ai_addrlen; /* Follow rfc3493 struct addrinfo */
char *ai_canonname; char *ai_canonname;
struct sockaddr *ai_addr; struct sockaddr *ai_addr;
struct Curl_addrinfo *ai_next; struct Curl_addrinfo *ai_next;

View File

@ -332,7 +332,7 @@ static CURLcode AllowServerConnect(struct connectdata *conn)
#else #else
struct sockaddr_in add; struct sockaddr_in add;
#endif #endif
socklen_t size = (socklen_t) sizeof(add); curl_socklen_t size = (curl_socklen_t) sizeof(add);
if(0 == getsockname(sock, (struct sockaddr *) &add, &size)) { if(0 == getsockname(sock, (struct sockaddr *) &add, &size)) {
size = sizeof(add); size = sizeof(add);
@ -888,7 +888,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
*/ */
struct Curl_sockaddr_storage ss; struct Curl_sockaddr_storage ss;
Curl_addrinfo *res, *ai; Curl_addrinfo *res, *ai;
socklen_t sslen; curl_socklen_t sslen;
char hbuf[NI_MAXHOST]; char hbuf[NI_MAXHOST];
struct sockaddr *sa=(struct sockaddr *)&ss; struct sockaddr *sa=(struct sockaddr *)&ss;
struct sockaddr_in * const sa4 = (void *)sa; struct sockaddr_in * const sa4 = (void *)sa;
@ -925,7 +925,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
return CURLE_FTP_PORT_FAILED; return CURLE_FTP_PORT_FAILED;
} }
if(sslen > (socklen_t)sizeof(ss)) if(sslen > (curl_socklen_t)sizeof(ss))
sslen = sizeof(ss); sslen = sizeof(ss);
rc = getnameinfo((struct sockaddr *)&ss, sslen, hbuf, sizeof(hbuf), NULL, rc = getnameinfo((struct sockaddr *)&ss, sslen, hbuf, sizeof(hbuf), NULL,
0, NIFLAGS); 0, NIFLAGS);
@ -992,7 +992,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
else else
sa6->sin6_port = 0; sa6->sin6_port = 0;
if(sslen > (socklen_t)sizeof(ss)) if(sslen > (curl_socklen_t)sizeof(ss))
sslen = sizeof(ss); sslen = sizeof(ss);
if(bind(portsock, sa, sslen)) { if(bind(portsock, sa, sslen)) {
@ -1112,7 +1112,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
Curl_addrinfo *addr = NULL; Curl_addrinfo *addr = NULL;
unsigned short ip[4]; unsigned short ip[4];
bool freeaddr = TRUE; bool freeaddr = TRUE;
socklen_t sslen = sizeof(sa); curl_socklen_t sslen = sizeof(sa);
const char *ftpportstr = data->set.str[STRING_FTPPORT]; const char *ftpportstr = data->set.str[STRING_FTPPORT];
(void)fcmd; /* not used in the IPv4 code */ (void)fcmd; /* not used in the IPv4 code */
@ -1161,7 +1161,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
Curl_strerror(conn, SOCKERRNO) ); Curl_strerror(conn, SOCKERRNO) );
return CURLE_FTP_PORT_FAILED; return CURLE_FTP_PORT_FAILED;
} }
if(sslen > (socklen_t)sizeof(sa)) if(sslen > (curl_socklen_t)sizeof(sa))
sslen = sizeof(sa); sslen = sizeof(sa);
sa_filled_in = TRUE; /* the sa struct is filled in */ sa_filled_in = TRUE; /* the sa struct is filled in */
@ -1189,7 +1189,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
if(bind(portsock, (struct sockaddr *)&sa, sslen) == 0) { if(bind(portsock, (struct sockaddr *)&sa, sslen) == 0) {
/* we succeeded to bind */ /* we succeeded to bind */
struct sockaddr_in add; struct sockaddr_in add;
socklen_t socksize = sizeof(add); curl_socklen_t socksize = sizeof(add);
if(getsockname(portsock, (struct sockaddr *) &add, if(getsockname(portsock, (struct sockaddr *) &add,
&socksize)) { &socksize)) {

View File

@ -162,7 +162,7 @@ krb5_auth(void *app_data, struct connectdata *conn)
char *p; char *p;
const char *host = conn->dns_entry->addr->ai_canonname; const char *host = conn->dns_entry->addr->ai_canonname;
ssize_t nread; ssize_t nread;
socklen_t l = sizeof(conn->local_addr); curl_socklen_t l = sizeof(conn->local_addr);
struct SessionHandle *data = conn->data; struct SessionHandle *data = conn->data;
CURLcode result; CURLcode result;
const char *service = "ftp", *srv_host = "host"; const char *service = "ftp", *srv_host = "host";

View File

@ -255,7 +255,7 @@ int curl_accept(int s, void *saddr, void *saddrlen,
int line, const char *source) int line, const char *source)
{ {
struct sockaddr *addr = (struct sockaddr *)saddr; struct sockaddr *addr = (struct sockaddr *)saddr;
socklen_t *addrlen = (socklen_t *)saddrlen; curl_socklen_t *addrlen = (curl_socklen_t *)saddrlen;
int sockfd=accept(s, addr, addrlen); int sockfd=accept(s, addr, addrlen);
if(logfile) if(logfile)
fprintf(logfile, "FD %s:%d accept() = %d\n", fprintf(logfile, "FD %s:%d accept() = %d\n",

View File

@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -47,9 +47,10 @@ extern int Curl_getaddrinfo_a(const char * nodename, const char * servname,
#define getaddrinfo Curl_getaddrinfo_a #define getaddrinfo Curl_getaddrinfo_a
extern int Curl_getnameinfo_a(const struct sockaddr * sa, socklen_t salen, extern int Curl_getnameinfo_a(const struct sockaddr * sa,
char * nodename, socklen_t nodenamelen, curl_socklen_t salen,
char * servname, socklen_t servnamelen, char * nodename, curl_socklen_t nodenamelen,
char * servname, curl_socklen_t servnamelen,
int flags); int flags);
#define getnameinfo Curl_getnameinfo_a #define getnameinfo Curl_getnameinfo_a

View File

@ -106,23 +106,6 @@ struct timeval {
#endif #endif
/*
* Windows build targets have socklen_t definition in
* ws2tcpip.h but some versions of ws2tcpip.h do not
* have the definition. It seems that when the socklen_t
* definition is missing from ws2tcpip.h the definition
* for INET_ADDRSTRLEN is also missing, and that when one
* definition is present the other one also is available.
*/
#if defined(WIN32) && !defined(HAVE_CONFIG_H)
# if ( defined(_MSC_VER) && !defined(INET_ADDRSTRLEN) ) || \
(!defined(_MSC_VER) && !defined(HAVE_WS2TCPIP_H) )
# define socklen_t int
# endif
#endif
#if defined(__minix) #if defined(__minix)
/* Minix doesn't support recv on TCP sockets */ /* Minix doesn't support recv on TCP sockets */
#define sread(x,y,z) (ssize_t)read((RECV_TYPE_ARG1)(x), \ #define sread(x,y,z) (ssize_t)read((RECV_TYPE_ARG1)(x), \
@ -451,88 +434,5 @@ typedef int sig_atomic_t;
#define ZERO_NULL 0 #define ZERO_NULL 0
#if defined (__LP64__) && defined(__hpux) && !defined(_XOPEN_SOURCE_EXTENDED)
#include <sys/socket.h>
/* HP-UX has this oddity where it features a few functions that don't work
with socklen_t so we need to convert to ints
This is due to socklen_t being a 64bit int under 64bit ABI, but the
pre-xopen (default) interfaces require an int, which is 32bits.
Therefore, Anytime socklen_t is passed by pointer, the libc function
truncates the 64bit socklen_t value by treating it as a 32bit value.
Note that some socket calls are allowed to have a NULL pointer for
the socklen arg.
*/
inline static int Curl_hp_getsockname(int s, struct sockaddr *name,
socklen_t *namelen)
{
int rc;
if(namelen) {
int len = *namelen;
rc = getsockname(s, name, &len);
*namelen = len;
}
else
rc = getsockname(s, name, 0);
return rc;
}
inline static int Curl_hp_getsockopt(int s, int level, int optname,
void *optval, socklen_t *optlen)
{
int rc;
if(optlen) {
int len = *optlen;
rc = getsockopt(s, level, optname, optval, &len);
*optlen = len;
}
else
rc = getsockopt(s, level, optname, optval, 0);
return rc;
}
inline static int Curl_hp_accept(int sockfd, struct sockaddr *addr,
socklen_t *addrlen)
{
int rc;
if(addrlen) {
int len = *addrlen;
rc = accept(sockfd, addr, &len);
*addrlen = len;
}
else
rc = accept(sockfd, addr, 0);
return rc;
}
inline static ssize_t Curl_hp_recvfrom(int s, void *buf, size_t len, int flags,
struct sockaddr *from,
socklen_t *fromlen)
{
ssize_t rc;
if(fromlen) {
int fromlen32 = *fromlen;
rc = recvfrom(s, buf, len, flags, from, &fromlen32);
*fromlen = fromlen32;
}
else {
rc = recvfrom(s, buf, len, flags, from, 0);
}
return rc;
}
#define getsockname(a,b,c) Curl_hp_getsockname((a),(b),(c))
#define getsockopt(a,b,c,d,e) Curl_hp_getsockopt((a),(b),(c),(d),(e))
#define accept(a,b,c) Curl_hp_accept((a),(b),(c))
#define recvfrom(a,b,c,d,e,f) Curl_hp_recvfrom((a),(b),(c),(d),(e),(f))
#endif /* HPUX work-around */
#endif /* __SETUP_ONCE_H */ #endif /* __SETUP_ONCE_H */

View File

@ -147,7 +147,7 @@ typedef struct tftp_state_data {
unsigned short block; unsigned short block;
struct Curl_sockaddr_storage local_addr; struct Curl_sockaddr_storage local_addr;
struct Curl_sockaddr_storage remote_addr; struct Curl_sockaddr_storage remote_addr;
socklen_t remote_addrlen; curl_socklen_t remote_addrlen;
ssize_t rbytes; ssize_t rbytes;
size_t sbytes; size_t sbytes;
size_t blksize; size_t blksize;
@ -947,7 +947,7 @@ static CURLcode tftp_do(struct connectdata *conn, bool *done)
CURLcode code; CURLcode code;
int rc; int rc;
struct Curl_sockaddr_storage fromaddr; struct Curl_sockaddr_storage fromaddr;
socklen_t fromlen; curl_socklen_t fromlen;
int check_time = 0; int check_time = 0;
struct SingleRequest *k = &data->req; struct SingleRequest *k = &data->req;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -237,9 +237,9 @@ buffer_undef(localkey_t key, long size)
int int
Curl_getnameinfo_a(const struct sockaddr * sa, socklen_t salen, Curl_getnameinfo_a(const struct sockaddr * sa, curl_socklen_t salen,
char * nodename, socklen_t nodenamelen, char * nodename, curl_socklen_t nodenamelen,
char * servname, socklen_t servnamelen, char * servname, curl_socklen_t servnamelen,
int flags) int flags)
{ {

View File

@ -25,9 +25,6 @@
/* Define if you can safely include both <sys/time.h> and <time.h>. */ /* Define if you can safely include both <sys/time.h> and <time.h>. */
#define TIME_WITH_SYS_TIME 1 #define TIME_WITH_SYS_TIME 1
/* Type to use in place of socklen_t when system does not provide it. */
#define socklen_t size_t
/* The number of bytes in a long double. */ /* The number of bytes in a long double. */
#define SIZEOF_LONG_DOUBLE 8 #define SIZEOF_LONG_DOUBLE 8
@ -287,7 +284,7 @@
#define GETNAMEINFO_TYPE_ARG1 struct sockaddr * #define GETNAMEINFO_TYPE_ARG1 struct sockaddr *
/* Define to the type of arg 2 for getnameinfo. */ /* Define to the type of arg 2 for getnameinfo. */
#define GETNAMEINFO_TYPE_ARG2 socklen_t #define GETNAMEINFO_TYPE_ARG2 unsigned int
/* Define to the type of args 4 and 6 for getnameinfo. */ /* Define to the type of args 4 and 6 for getnameinfo. */
#define GETNAMEINFO_TYPE_ARG46 size_t #define GETNAMEINFO_TYPE_ARG46 size_t

View File

@ -395,7 +395,6 @@ ifeq ($(LIBARCH),CLIB)
@echo $(DL)#define SEND_TYPE_ARG3 int$(DL) >> $@ @echo $(DL)#define SEND_TYPE_ARG3 int$(DL) >> $@
@echo $(DL)#define SEND_TYPE_ARG4 int$(DL) >> $@ @echo $(DL)#define SEND_TYPE_ARG4 int$(DL) >> $@
@echo $(DL)#define SEND_TYPE_RETV int$(DL) >> $@ @echo $(DL)#define SEND_TYPE_RETV int$(DL) >> $@
@echo $(DL)#define socklen_t int$(DL) >> $@
@echo $(DL)#define pressanykey PressAnyKeyToContinue$(DL) >> $@ @echo $(DL)#define pressanykey PressAnyKeyToContinue$(DL) >> $@
else else
@echo $(DL)#define OS "i586-pc-libc-NetWare"$(DL) >> $@ @echo $(DL)#define OS "i586-pc-libc-NetWare"$(DL) >> $@
@ -545,9 +544,6 @@ endif
@echo $(DL)#else$(DL) >> $@ @echo $(DL)#else$(DL) >> $@
@echo $(DL)#define HAVE_VARIADIC_MACROS_C99 1$(DL) >> $@ @echo $(DL)#define HAVE_VARIADIC_MACROS_C99 1$(DL) >> $@
@echo $(DL)#endif$(DL) >> $@ @echo $(DL)#endif$(DL) >> $@
ifdef OLD_NOVELLSDK
@echo $(DL)#define socklen_t int$(DL) >> $@
endif
ifdef CABUNDLE ifdef CABUNDLE
@echo $(DL)#define CURL_CA_BUNDLE "$(CABUNDLE)"$(DL) >> $@ @echo $(DL)#define CURL_CA_BUNDLE "$(CABUNDLE)"$(DL) >> $@
else else

View File

@ -47,9 +47,6 @@
/* Define this to 'int' if ssize_t is not an available typedefed type */ /* Define this to 'int' if ssize_t is not an available typedefed type */
#undef ssize_t #undef ssize_t
/* Type to use in place of socklen_t when system does not provide it. */
#undef socklen_t
/* Define this as a suitable file to read random data from */ /* Define this as a suitable file to read random data from */
#undef RANDOM_FILE #undef RANDOM_FILE

View File

@ -751,7 +751,7 @@ static curl_socket_t sockdaemon(curl_socket_t sock,
got */ got */
/* we succeeded to bind */ /* we succeeded to bind */
struct sockaddr_in add; struct sockaddr_in add;
socklen_t socksize = sizeof(add); curl_socklen_t socksize = sizeof(add);
if(getsockname(sock, (struct sockaddr *) &add, if(getsockname(sock, (struct sockaddr *) &add,
&socksize)<0) { &socksize)<0) {

View File

@ -152,7 +152,7 @@ static int maxtimeout = 5*TIMEOUT;
static char buf[PKTSIZE]; static char buf[PKTSIZE];
static char ackbuf[PKTSIZE]; static char ackbuf[PKTSIZE];
static struct sockaddr_in from; static struct sockaddr_in from;
static socklen_t fromlen; static curl_socklen_t fromlen;
struct bf { struct bf {
int counter; /* size of data in buffer, or flag */ int counter; /* size of data in buffer, or flag */
@ -376,7 +376,7 @@ static int synchnet(curl_socket_t f /* socket to flush */)
int j = 0; int j = 0;
char rbuf[PKTSIZE]; char rbuf[PKTSIZE];
struct sockaddr_in fromaddr; struct sockaddr_in fromaddr;
socklen_t fromaddrlen; curl_socklen_t fromaddrlen;
while (1) { while (1) {
#if defined(HAVE_IOCTLSOCKET) #if defined(HAVE_IOCTLSOCKET)