From: Guido van Rossum Date: Mon, 24 Apr 2000 15:16:03 +0000 (+0000) Subject: Jack Jansen: The GUSI 2.0 I/O library used on the Mac uses the X-Git-Tag: v2.0b1~1952 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ff3ab42c04905f3a7050ab4be1eb421779576e8a;p=python 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.] --- diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index f23a3bee0a..2b7eb8dc0c 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -172,7 +172,7 @@ int shutdown( int, int ); #ifdef __BEOS__ #include #else -#ifndef macintosh +#ifndef USE_GUSI1 #include #endif #endif @@ -192,7 +192,7 @@ int shutdown( int, int ); #define O_NDELAY O_NONBLOCK /* For QNX only? */ #endif -#ifdef USE_GUSI +#ifdef USE_GUSI1 /* fdopen() isn't declared in stdio.h (sigh) */ #include #endif @@ -664,7 +664,8 @@ static PyObject * BUILD_FUNC_DEF_2(PySocketSock_accept,PySocketSockObject *,s, PyObject *,args) { char addrbuf[256]; - int addrlen, newfd; + int newfd; + socklen_t addrlen; PyObject *sock = NULL; PyObject *addr = NULL; PyObject *res = NULL; @@ -808,7 +809,7 @@ BUILD_FUNC_DEF_2(PySocketSock_getsockopt,PySocketSockObject *,s, PyObject *,args int optname; int res; PyObject *buf; - int buflen = 0; + socklen_t buflen = 0; #ifdef __BEOS__ /* We have incomplete socket support. */ @@ -822,7 +823,7 @@ BUILD_FUNC_DEF_2(PySocketSock_getsockopt,PySocketSockObject *,s, PyObject *,args if (buflen == 0) { int flag = 0; - int flagsize = sizeof flag; + socklen_t flagsize = sizeof flag; res = getsockopt(s->sock_fd, level, optname, (ANY *)&flag, &flagsize); if (res < 0) @@ -1010,7 +1011,9 @@ static PyObject * BUILD_FUNC_DEF_2(PySocketSock_getsockname,PySocketSockObject *,s, PyObject *,args) { char addrbuf[256]; - int addrlen, res; + int res; + socklen_t addrlen; + if (!PyArg_ParseTuple(args, ":getsockname")) return NULL; if (!getsockaddrlen(s, &addrlen)) @@ -1038,7 +1041,9 @@ static PyObject * BUILD_FUNC_DEF_2(PySocketSock_getpeername,PySocketSockObject *,s, PyObject *,args) { char addrbuf[256]; - int addrlen, res; + int res; + socklen_t addrlen; + if (!PyArg_ParseTuple(args, ":getpeername")) return NULL; if (!getsockaddrlen(s, &addrlen)) @@ -1177,7 +1182,8 @@ BUILD_FUNC_DEF_2(PySocketSock_recvfrom,PySocketSockObject *,s, PyObject *,args) PyObject *addr = NULL; PyObject *ret = NULL; - int addrlen, len, n, flags = 0; + int len, n, flags = 0; + socklen_t addrlen; if (!PyArg_ParseTuple(args, "i|i:recvfrom", &len, &flags)) return NULL; if (!getsockaddrlen(s, &addrlen)) @@ -1882,7 +1888,7 @@ BUILD_FUNC_DEF_2(PySocket_inet_aton, PyObject *, self, PyObject *, args) if (!PyArg_ParseTuple(args, "s:inet_aton", &ip_addr)) { return NULL; } -#ifdef macintosh +#ifdef USE_GUSI1 packed_addr = (long)inet_addr(ip_addr).s_addr; #else packed_addr = inet_addr(ip_addr);