Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ff3ab42

Browse files
committed
Jack Jansen: The GUSI 2.0 I/O library used on the Mac uses the
socklen_t (unsigned int) for most size parameters. Apparently this is part of the UNIX 98 standard. [GvR: the changes to configure.in etc. that I just checked in make sure that socklen_t is defined everywhere, so I deleted the little part of Jack's mod to define socklen_t if not in GUSI2. I suppose I will have to add it to the Windows config.h in a minute.]
1 parent ddc3b63 commit ff3ab42

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

Modules/socketmodule.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ int shutdown( int, int );
172172
#ifdef __BEOS__
173173
#include <net/netdb.h>
174174
#else
175-
#ifndef macintosh
175+
#ifndef USE_GUSI1
176176
#include <arpa/inet.h>
177177
#endif
178178
#endif
@@ -192,7 +192,7 @@ int shutdown( int, int );
192192
#define O_NDELAY O_NONBLOCK /* For QNX only? */
193193
#endif
194194

195-
#ifdef USE_GUSI
195+
#ifdef USE_GUSI1
196196
/* fdopen() isn't declared in stdio.h (sigh) */
197197
#include <GUSI.h>
198198
#endif
@@ -664,7 +664,8 @@ static PyObject *
664664
BUILD_FUNC_DEF_2(PySocketSock_accept,PySocketSockObject *,s, PyObject *,args)
665665
{
666666
char addrbuf[256];
667-
int addrlen, newfd;
667+
int newfd;
668+
socklen_t addrlen;
668669
PyObject *sock = NULL;
669670
PyObject *addr = NULL;
670671
PyObject *res = NULL;
@@ -808,7 +809,7 @@ BUILD_FUNC_DEF_2(PySocketSock_getsockopt,PySocketSockObject *,s, PyObject *,args
808809
int optname;
809810
int res;
810811
PyObject *buf;
811-
int buflen = 0;
812+
socklen_t buflen = 0;
812813

813814
#ifdef __BEOS__
814815
/* We have incomplete socket support. */
@@ -822,7 +823,7 @@ BUILD_FUNC_DEF_2(PySocketSock_getsockopt,PySocketSockObject *,s, PyObject *,args
822823

823824
if (buflen == 0) {
824825
int flag = 0;
825-
int flagsize = sizeof flag;
826+
socklen_t flagsize = sizeof flag;
826827
res = getsockopt(s->sock_fd, level, optname,
827828
(ANY *)&flag, &flagsize);
828829
if (res < 0)
@@ -1010,7 +1011,9 @@ static PyObject *
10101011
BUILD_FUNC_DEF_2(PySocketSock_getsockname,PySocketSockObject *,s, PyObject *,args)
10111012
{
10121013
char addrbuf[256];
1013-
int addrlen, res;
1014+
int res;
1015+
socklen_t addrlen;
1016+
10141017
if (!PyArg_ParseTuple(args, ":getsockname"))
10151018
return NULL;
10161019
if (!getsockaddrlen(s, &addrlen))
@@ -1038,7 +1041,9 @@ static PyObject *
10381041
BUILD_FUNC_DEF_2(PySocketSock_getpeername,PySocketSockObject *,s, PyObject *,args)
10391042
{
10401043
char addrbuf[256];
1041-
int addrlen, res;
1044+
int res;
1045+
socklen_t addrlen;
1046+
10421047
if (!PyArg_ParseTuple(args, ":getpeername"))
10431048
return NULL;
10441049
if (!getsockaddrlen(s, &addrlen))
@@ -1177,7 +1182,8 @@ BUILD_FUNC_DEF_2(PySocketSock_recvfrom,PySocketSockObject *,s, PyObject *,args)
11771182
PyObject *addr = NULL;
11781183
PyObject *ret = NULL;
11791184

1180-
int addrlen, len, n, flags = 0;
1185+
int len, n, flags = 0;
1186+
socklen_t addrlen;
11811187
if (!PyArg_ParseTuple(args, "i|i:recvfrom", &len, &flags))
11821188
return NULL;
11831189
if (!getsockaddrlen(s, &addrlen))
@@ -1882,7 +1888,7 @@ BUILD_FUNC_DEF_2(PySocket_inet_aton, PyObject *, self, PyObject *, args)
18821888
if (!PyArg_ParseTuple(args, "s:inet_aton", &ip_addr)) {
18831889
return NULL;
18841890
}
1885-
#ifdef macintosh
1891+
#ifdef USE_GUSI1
18861892
packed_addr = (long)inet_addr(ip_addr).s_addr;
18871893
#else
18881894
packed_addr = inet_addr(ip_addr);

0 commit comments

Comments
 (0)