summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2009-05-02 02:37:32 +0000
committerYang Tse <yangsita@gmail.com>2009-05-02 02:37:32 +0000
commit9137e717b04644592b9b527839470337fdd9f44d (patch)
treee7b9af9f3d06915f4900238ff4f5a077fb05810b /lib
parent80186aa7f44ed5155665d96336b508403b3d4a03 (diff)
downloadcurl-9137e717b04644592b9b527839470337fdd9f44d.tar.gz
Use build-time configured curl_socklen_t instead of socklen_t
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile.netware4
-rw-r--r--lib/config-amigaos.h7
-rw-r--r--lib/config-os400.h3
-rw-r--r--lib/config-riscos.h3
-rw-r--r--lib/config-symbian.h3
-rw-r--r--lib/config-tpf.h3
-rw-r--r--lib/config.dos1
-rw-r--r--lib/config.h.cmake3
-rw-r--r--lib/connect.c8
-rw-r--r--lib/curl_addrinfo.c2
-rw-r--r--lib/curl_addrinfo.h4
-rw-r--r--lib/ftp.c14
-rw-r--r--lib/krb5.c2
-rw-r--r--lib/memdebug.c2
-rw-r--r--lib/setup-os400.h9
-rw-r--r--lib/setup_once.h100
-rw-r--r--lib/tftp.c4
17 files changed, 25 insertions, 147 deletions
diff --git a/lib/Makefile.netware b/lib/Makefile.netware
index c1c2b251d..6ab10bae6 100644
--- a/lib/Makefile.netware
+++ b/lib/Makefile.netware
@@ -407,7 +407,6 @@ ifeq ($(LIBARCH),CLIB)
@echo $(DL)#define SEND_TYPE_ARG3 int$(DL) >> $@
@echo $(DL)#define SEND_TYPE_ARG4 int$(DL) >> $@
@echo $(DL)#define SEND_TYPE_RETV int$(DL) >> $@
- @echo $(DL)#define socklen_t int$(DL) >> $@
@echo $(DL)#define pressanykey PressAnyKeyToContinue$(DL) >> $@
else
@echo $(DL)#define OS "i586-pc-libc-NetWare"$(DL) >> $@
@@ -557,9 +556,6 @@ endif
@echo $(DL)#else$(DL) >> $@
@echo $(DL)#define HAVE_VARIADIC_MACROS_C99 1$(DL) >> $@
@echo $(DL)#endif$(DL) >> $@
-ifdef OLD_NOVELLSDK
- @echo $(DL)#define socklen_t int$(DL) >> $@
-endif
ifdef CABUNDLE
@echo $(DL)#define CURL_CA_BUNDLE "$(CABUNDLE)"$(DL) >> $@
else
diff --git a/lib/config-amigaos.h b/lib/config-amigaos.h
index 6a871d047..3da27426d 100644
--- a/lib/config-amigaos.h
+++ b/lib/config-amigaos.h
@@ -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
* you should have received as part of this distribution. The terms
@@ -108,9 +108,6 @@
#define TIME_WITH_SYS_TIME 1
#define in_addr_t int
-#ifndef socklen_t
-# define socklen_t int
-#endif
#ifndef O_RDONLY
# define O_RDONLY 0x0000
@@ -119,7 +116,7 @@
#define HAVE_GETNAMEINFO 1
#define GETNAMEINFO_QUAL_ARG1 const
#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_ARG7 int
diff --git a/lib/config-os400.h b/lib/config-os400.h
index efb019551..371cbea28 100644
--- a/lib/config-os400.h
+++ b/lib/config-os400.h
@@ -48,9 +48,6 @@
/* Define this to 'int' if ssize_t is not an available typedefed type */
#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 */
#undef RANDOM_FILE
diff --git a/lib/config-riscos.h b/lib/config-riscos.h
index e525c6a60..95e45d6fd 100644
--- a/lib/config-riscos.h
+++ b/lib/config-riscos.h
@@ -44,9 +44,6 @@
/* Define this to 'int' if ssize_t is not an available typedefed type */
#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 */
#undef RANDOM_FILE
diff --git a/lib/config-symbian.h b/lib/config-symbian.h
index de5fd851d..1cdce2616 100644
--- a/lib/config-symbian.h
+++ b/lib/config-symbian.h
@@ -788,9 +788,6 @@
/* Define to `unsigned int' if <sys/types.h> does not define. */
/* #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 */
/* #undef ssize_t */
diff --git a/lib/config-tpf.h b/lib/config-tpf.h
index e67467ba6..3e482a6bd 100644
--- a/lib/config-tpf.h
+++ b/lib/config-tpf.h
@@ -668,9 +668,6 @@
/* Define to `unsigned' if <sys/types.h> does not define. */
/* #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 */
/* #undef ssize_t */
diff --git a/lib/config.dos b/lib/config.dos
index cceefb814..e515f3ea9 100644
--- a/lib/config.dos
+++ b/lib/config.dos
@@ -117,7 +117,6 @@
#define CURL_DISABLE_LDAP 1
#define in_addr_t u_long
-#define socklen_t int
#if defined(__HIGHC__) || \
(defined(__GNUC__) && __GNUC__ < 4) /* gcc 4.x built-in ? */
diff --git a/lib/config.h.cmake b/lib/config.h.cmake
index bb0d552b5..d7f00de1c 100644
--- a/lib/config.h.cmake
+++ b/lib/config.h.cmake
@@ -946,8 +946,5 @@
/* Define to `unsigned int' if <sys/types.h> does not define. */
#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 */
#cmakedefine ssize_t ${ssize_t}
diff --git a/lib/connect.c b/lib/connect.c
index d4b621f33..d7b2f7fc0 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -281,7 +281,7 @@ static CURLcode bindlocal(struct connectdata *conn,
struct Curl_sockaddr_storage sa;
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;
#ifdef ENABLE_IPV6
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) {
/* we succeeded to bind */
struct Curl_sockaddr_storage add;
- socklen_t size = sizeof(add);
+ curl_socklen_t size = sizeof(add);
memset(&add, 0, sizeof(struct Curl_sockaddr_storage));
if(getsockname(sockfd, (struct sockaddr *) &add, &size) < 0) {
data->state.os_errno = error = SOCKERRNO;
@@ -470,7 +470,7 @@ static bool verifyconnect(curl_socket_t sockfd, int *error)
bool rc = TRUE;
#ifdef SO_ERROR
int err = 0;
- socklen_t errSize = sizeof(err);
+ curl_socklen_t errSize = sizeof(err);
#ifdef WIN32
/*
@@ -657,7 +657,7 @@ static void tcpnodelay(struct connectdata *conn,
{
#ifdef TCP_NODELAY
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;
#if 0
diff --git a/lib/curl_addrinfo.c b/lib/curl_addrinfo.c
index a9db3d75f..24ba4fa20 100644
--- a/lib/curl_addrinfo.c
+++ b/lib/curl_addrinfo.c
@@ -221,7 +221,7 @@ Curl_getaddrinfo_ex(const char *nodename,
* int ai_family;
* int ai_socktype;
* int ai_protocol;
- * socklen_t ai_addrlen; * Follow rfc3493 struct addrinfo *
+ * curl_socklen_t ai_addrlen; * Follow rfc3493 struct addrinfo *
* char *ai_canonname;
* struct sockaddr *ai_addr;
* struct Curl_addrinfo *ai_next;
diff --git a/lib/curl_addrinfo.h b/lib/curl_addrinfo.h
index 50480fa09..2fbb47a68 100644
--- a/lib/curl_addrinfo.h
+++ b/lib/curl_addrinfo.h
@@ -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
* you should have received as part of this distribution. The terms
@@ -57,7 +57,7 @@ struct Curl_addrinfo {
int ai_family;
int ai_socktype;
int ai_protocol;
- socklen_t ai_addrlen; /* Follow rfc3493 struct addrinfo */
+ curl_socklen_t ai_addrlen; /* Follow rfc3493 struct addrinfo */
char *ai_canonname;
struct sockaddr *ai_addr;
struct Curl_addrinfo *ai_next;
diff --git a/lib/ftp.c b/lib/ftp.c
index ca14b977d..e8f51c685 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -332,7 +332,7 @@ static CURLcode AllowServerConnect(struct connectdata *conn)
#else
struct sockaddr_in add;
#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)) {
size = sizeof(add);
@@ -888,7 +888,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
*/
struct Curl_sockaddr_storage ss;
Curl_addrinfo *res, *ai;
- socklen_t sslen;
+ curl_socklen_t sslen;
char hbuf[NI_MAXHOST];
struct sockaddr *sa=(struct sockaddr *)&ss;
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;
}
- if(sslen > (socklen_t)sizeof(ss))
+ if(sslen > (curl_socklen_t)sizeof(ss))
sslen = sizeof(ss);
rc = getnameinfo((struct sockaddr *)&ss, sslen, hbuf, sizeof(hbuf), NULL,
0, NIFLAGS);
@@ -992,7 +992,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
else
sa6->sin6_port = 0;
- if(sslen > (socklen_t)sizeof(ss))
+ if(sslen > (curl_socklen_t)sizeof(ss))
sslen = sizeof(ss);
if(bind(portsock, sa, sslen)) {
@@ -1112,7 +1112,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
Curl_addrinfo *addr = NULL;
unsigned short ip[4];
bool freeaddr = TRUE;
- socklen_t sslen = sizeof(sa);
+ curl_socklen_t sslen = sizeof(sa);
const char *ftpportstr = data->set.str[STRING_FTPPORT];
(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) );
return CURLE_FTP_PORT_FAILED;
}
- if(sslen > (socklen_t)sizeof(sa))
+ if(sslen > (curl_socklen_t)sizeof(sa))
sslen = sizeof(sa);
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) {
/* we succeeded to bind */
struct sockaddr_in add;
- socklen_t socksize = sizeof(add);
+ curl_socklen_t socksize = sizeof(add);
if(getsockname(portsock, (struct sockaddr *) &add,
&socksize)) {
diff --git a/lib/krb5.c b/lib/krb5.c
index d64161df0..e76391228 100644
--- a/lib/krb5.c
+++ b/lib/krb5.c
@@ -162,7 +162,7 @@ krb5_auth(void *app_data, struct connectdata *conn)
char *p;
const char *host = conn->dns_entry->addr->ai_canonname;
ssize_t nread;
- socklen_t l = sizeof(conn->local_addr);
+ curl_socklen_t l = sizeof(conn->local_addr);
struct SessionHandle *data = conn->data;
CURLcode result;
const char *service = "ftp", *srv_host = "host";
diff --git a/lib/memdebug.c b/lib/memdebug.c
index 3c74df025..3a0cf7153 100644
--- a/lib/memdebug.c
+++ b/lib/memdebug.c
@@ -255,7 +255,7 @@ int curl_accept(int s, void *saddr, void *saddrlen,
int line, const char *source)
{
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);
if(logfile)
fprintf(logfile, "FD %s:%d accept() = %d\n",
diff --git a/lib/setup-os400.h b/lib/setup-os400.h
index eb51bc24c..636ee7fa2 100644
--- a/lib/setup-os400.h
+++ b/lib/setup-os400.h
@@ -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
* 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
-extern int Curl_getnameinfo_a(const struct sockaddr * sa, socklen_t salen,
- char * nodename, socklen_t nodenamelen,
- char * servname, socklen_t servnamelen,
+extern int Curl_getnameinfo_a(const struct sockaddr * sa,
+ curl_socklen_t salen,
+ char * nodename, curl_socklen_t nodenamelen,
+ char * servname, curl_socklen_t servnamelen,
int flags);
#define getnameinfo Curl_getnameinfo_a
diff --git a/lib/setup_once.h b/lib/setup_once.h
index c1c899631..933d95abb 100644
--- a/lib/setup_once.h
+++ b/lib/setup_once.h
@@ -106,23 +106,6 @@ struct timeval {
#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)
/* Minix doesn't support recv on TCP sockets */
#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
-#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 */
diff --git a/lib/tftp.c b/lib/tftp.c
index 6440f8025..b095cc532 100644
--- a/lib/tftp.c
+++ b/lib/tftp.c
@@ -147,7 +147,7 @@ typedef struct tftp_state_data {
unsigned short block;
struct Curl_sockaddr_storage local_addr;
struct Curl_sockaddr_storage remote_addr;
- socklen_t remote_addrlen;
+ curl_socklen_t remote_addrlen;
ssize_t rbytes;
size_t sbytes;
size_t blksize;
@@ -947,7 +947,7 @@ static CURLcode tftp_do(struct connectdata *conn, bool *done)
CURLcode code;
int rc;
struct Curl_sockaddr_storage fromaddr;
- socklen_t fromlen;
+ curl_socklen_t fromlen;
int check_time = 0;
struct SingleRequest *k = &data->req;