[Patches] Patch to socketmodule.c

Jack Jansen Jack.Jansen@oratrix.com
Sat, 22 Apr 2000 01:19:08 +0200


This is a multi-part message in MIME format.
--------------2A0D8785DD8F008DF00A99BD
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

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, but for now the code is
#ifdeffed with USE_GUSI.
---
I confirm that, to the best of my knowledge and belief, this
                                                       contribution is free of
any claims of third parties under
                                                       copyright, patent or
other rights or interests ("claims").  To
                                                       the extent that I have
any such claims, I hereby grant to CNRI a
                                                       nonexclusive,
irrevocable, royalty-free, worldwide license to
                                                       reproduce, distribute,
perform and/or display publicly, prepare
                                                       derivative versions, and
otherwise use this contribution as part
                                                       of the Python software
and its related documentation, or any
                                                       derivative versions
thereof, at no cost to CNRI or its licensed
                                                       users, and to authorize
others to do so.

                                                       I acknowledge that CNRI
may, at its sole discretion, decide
                                                       whether or not to
incorporate this contribution in the Python
                                                       software and its related
documentation.  I further grant CNRI
                                                       permission to use my
name and other identifying information
                                                       provided to CNRI by me
for use in connection with the Python
                                                       software and its related documentation.
--------------2A0D8785DD8F008DF00A99BD
Content-Type: text/plain; charset=us-ascii; x-mac-type="54455854"; x-mac-creator="522A6368";
 name="patch-socketmodule"
Content-Transfer-Encoding: 7bit
Content-Description: Unknown Document
Content-Disposition: inline;
 filename="patch-socketmodule"

Index: socketmodule.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Modules/socketmodule.c,v
retrieving revision 1.103
diff -c -r1.103 socketmodule.c
*** socketmodule.c	2000/04/21 20:33:00	1.103
--- socketmodule.c	2000/04/21 22:59:54
***************
*** 172,178 ****
  #ifdef __BEOS__
  #include <net/netdb.h>
  #else
! #ifndef macintosh
  #include <arpa/inet.h>
  #endif
  #endif
--- 172,178 ----
  #ifdef __BEOS__
  #include <net/netdb.h>
  #else
! #ifndef USE_GUSI1
  #include <arpa/inet.h>
  #endif
  #endif
***************
*** 192,202 ****
  #define O_NDELAY O_NONBLOCK	/* For QNX only? */
  #endif
  
! #ifdef USE_GUSI
  /* fdopen() isn't declared in stdio.h (sigh) */
  #include <GUSI.h>
  #endif
  
  #ifdef USE_SSL
  #include "rsa.h"
  #include "crypto.h"
--- 192,209 ----
  #define O_NDELAY O_NONBLOCK	/* For QNX only? */
  #endif
  
! #ifdef USE_GUSI1
  /* fdopen() isn't declared in stdio.h (sigh) */
  #include <GUSI.h>
  #endif
  
+ #ifndef USE_GUSI2
+ /* GUSI socket library seems to be the only one to define socklen_t.
+ ** And it defines it as an unsigned int too.
+ */
+ typedef int socklen_t;
+ #endif
+ 
  #ifdef USE_SSL
  #include "rsa.h"
  #include "crypto.h"
***************
*** 664,670 ****
  BUILD_FUNC_DEF_2(PySocketSock_accept,PySocketSockObject *,s, PyObject *,args)
  {
  	char addrbuf[256];
! 	int addrlen, newfd;
  	PyObject *sock = NULL;
  	PyObject *addr = NULL;
  	PyObject *res = NULL;
--- 671,678 ----
  BUILD_FUNC_DEF_2(PySocketSock_accept,PySocketSockObject *,s, PyObject *,args)
  {
  	char addrbuf[256];
! 	int newfd;
! 	socklen_t addrlen;
  	PyObject *sock = NULL;
  	PyObject *addr = NULL;
  	PyObject *res = NULL;
***************
*** 808,814 ****
  	int optname;
  	int res;
  	PyObject *buf;
! 	int buflen = 0;
  
  #ifdef __BEOS__
  /* We have incomplete socket support. */
--- 816,822 ----
  	int optname;
  	int res;
  	PyObject *buf;
! 	socklen_t buflen = 0;
  
  #ifdef __BEOS__
  /* We have incomplete socket support. */
***************
*** 822,828 ****
  	
  	if (buflen == 0) {
  		int flag = 0;
! 		int flagsize = sizeof flag;
  		res = getsockopt(s->sock_fd, level, optname,
  				 (ANY *)&flag, &flagsize);
  		if (res < 0)
--- 830,836 ----
  	
  	if (buflen == 0) {
  		int flag = 0;
! 		socklen_t flagsize = sizeof flag;
  		res = getsockopt(s->sock_fd, level, optname,
  				 (ANY *)&flag, &flagsize);
  		if (res < 0)
***************
*** 1010,1016 ****
  BUILD_FUNC_DEF_2(PySocketSock_getsockname,PySocketSockObject *,s, PyObject *,args)
  {
  	char addrbuf[256];
! 	int addrlen, res;
  	if (!PyArg_ParseTuple(args, ":getsockname"))
  		return NULL;
  	if (!getsockaddrlen(s, &addrlen))
--- 1018,1026 ----
  BUILD_FUNC_DEF_2(PySocketSock_getsockname,PySocketSockObject *,s, PyObject *,args)
  {
  	char addrbuf[256];
! 	int res;
! 	socklen_t addrlen;
! 
  	if (!PyArg_ParseTuple(args, ":getsockname"))
  		return NULL;
  	if (!getsockaddrlen(s, &addrlen))
***************
*** 1038,1044 ****
  BUILD_FUNC_DEF_2(PySocketSock_getpeername,PySocketSockObject *,s, PyObject *,args)
  {
  	char addrbuf[256];
! 	int addrlen, res;
  	if (!PyArg_ParseTuple(args, ":getpeername"))
  		return NULL;
  	if (!getsockaddrlen(s, &addrlen))
--- 1048,1056 ----
  BUILD_FUNC_DEF_2(PySocketSock_getpeername,PySocketSockObject *,s, PyObject *,args)
  {
  	char addrbuf[256];
! 	int res;
! 	socklen_t addrlen;
! 
  	if (!PyArg_ParseTuple(args, ":getpeername"))
  		return NULL;
  	if (!getsockaddrlen(s, &addrlen))
***************
*** 1177,1183 ****
  	PyObject *addr = NULL;
  	PyObject *ret = NULL;
  
! 	int addrlen, len, n, flags = 0;
  	if (!PyArg_ParseTuple(args, "i|i:recvfrom", &len, &flags))
  		return NULL;
  	if (!getsockaddrlen(s, &addrlen))
--- 1189,1196 ----
  	PyObject *addr = NULL;
  	PyObject *ret = NULL;
  
! 	int len, n, flags = 0;
! 	socklen_t addrlen;
  	if (!PyArg_ParseTuple(args, "i|i:recvfrom", &len, &flags))
  		return NULL;
  	if (!getsockaddrlen(s, &addrlen))
***************
*** 1882,1888 ****
  	if (!PyArg_ParseTuple(args, "s:inet_aton", &ip_addr)) {
  		return NULL;
  	}
! #ifdef macintosh
  	packed_addr = (long)inet_addr(ip_addr).s_addr;
  #else
  	packed_addr = inet_addr(ip_addr);
--- 1895,1901 ----
  	if (!PyArg_ParseTuple(args, "s:inet_aton", &ip_addr)) {
  		return NULL;
  	}
! #ifdef USE_GUSI1
  	packed_addr = (long)inet_addr(ip_addr).s_addr;
  #else
  	packed_addr = inet_addr(ip_addr);


--------------2A0D8785DD8F008DF00A99BD--