[Python-checkins] python/dist/src/Modules socketmodule.c, 1.282, 1.283

perky at projects.sourceforge.net perky at projects.sourceforge.net
Mon Feb 2 01:03:11 EST 2004


Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1954/Modules

Modified Files:
	socketmodule.c 
Log Message:
Add FreeBSD support for bluetooth sockets.
(SF Patch #888148, reviewed by loewis)


Index: socketmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v
retrieving revision 1.282
retrieving revision 1.283
diff -C2 -d -r1.282 -r1.283
*** socketmodule.c	31 Jan 2004 12:34:16 -0000	1.282
--- socketmodule.c	2 Feb 2004 06:03:09 -0000	1.283
***************
*** 323,326 ****
--- 323,344 ----
  #endif
  
+ #if defined(HAVE_BLUETOOTH_H) || defined(HAVE_BLUETOOTH_BLUETOOTH_H)
+ #define USE_BLUETOOTH 1
+ #if defined(__FreeBSD__)
+ #define BTPROTO_L2CAP BLUETOOTH_PROTO_L2CAP
+ #define BTPROTO_RFCOMM BLUETOOTH_PROTO_RFCOMM
+ #define sockaddr_l2 sockaddr_l2cap
+ #define sockaddr_rc sockaddr_rfcomm
+ #define _BT_SOCKADDR_MEMB(s, proto) &((s)->sock_addr)
+ #define _BT_L2_MEMB(sa, memb) ((sa)->l2cap_##memb)
+ #define _BT_RC_MEMB(sa, memb) ((sa)->rfcomm_##memb)
+ #else
+ #define _BT_SOCKADDRMEMB(s, proto) (&((s)->sock_addr).bt_##proto)
+ #define _BT_L2_MEMB(sa, memb) ((sa)->l2_##memb)
+ #define _BT_RC_MEMB(sa, memb) ((sa)->rc_##memb)
+ #define _BT_SCO_MEMB(sa, memb) ((sa)->sco_##memb)
+ #endif
+ #endif
+ 
  /*
   * Constants for getnameinfo()
***************
*** 1013,1017 ****
  #endif
  
! #ifdef HAVE_BLUETOOTH_BLUETOOTH_H
  	case AF_BLUETOOTH:
  	{
--- 1031,1035 ----
  #endif
  
! #ifdef USE_BLUETOOTH
  	case AF_BLUETOOTH:
  	{
***************
*** 1020,1028 ****
  			case BTPROTO_L2CAP:
  			{
! 				struct sockaddr_l2* addr = (struct sockaddr_l2*) &(s->sock_addr).bt_l2;
! 				bdaddr_t* bdaddr = &(addr->l2_bdaddr);
  
! 				addr->l2_family = AF_BLUETOOTH;
! 				if( !PyArg_ParseTuple(args, "(iiiiii)i", &bdaddr->b[0], &bdaddr->b[1], &bdaddr->b[2], &bdaddr->b[3], &bdaddr->b[4], &bdaddr->b[5], &addr->l2_psm) )
  				{
  					PyErr_SetString(socket_error, "getsockaddrarg: wrong format");
--- 1038,1046 ----
  			case BTPROTO_L2CAP:
  			{
! 				struct sockaddr_l2* addr = (struct sockaddr_l2*)_BT_SOCKADDR_MEMB(s, l2);
! 				bdaddr_t* bdaddr = &_BT_L2_MEMB(addr, bdaddr);
  
! 				_BT_L2_MEMB(addr, family) = AF_BLUETOOTH;
! 				if( !PyArg_ParseTuple(args, "(iiiiii)i", &bdaddr->b[0], &bdaddr->b[1], &bdaddr->b[2], &bdaddr->b[3], &bdaddr->b[4], &bdaddr->b[5], &_BT_L2_MEMB(addr, psm)) )
  				{
  					PyErr_SetString(socket_error, "getsockaddrarg: wrong format");
***************
*** 1036,1044 ****
  			case BTPROTO_RFCOMM:
  			{
! 				struct sockaddr_rc* addr = (struct sockaddr_rc*) &(s->sock_addr).bt_rc;
! 				bdaddr_t* bdaddr = &(addr->rc_bdaddr);
  
! 				addr->rc_family = AF_BLUETOOTH;
! 				if( !PyArg_ParseTuple(args, "(iiiiii)i", &bdaddr->b[0], &bdaddr->b[1], &bdaddr->b[2], &bdaddr->b[3], &bdaddr->b[4], &bdaddr->b[5], &addr->rc_channel) )
  				{
  					PyErr_SetString(socket_error, "getsockaddrarg: wrong format");
--- 1054,1062 ----
  			case BTPROTO_RFCOMM:
  			{
! 				struct sockaddr_rc* addr = (struct sockaddr_rc*)_BT_SOCKADDR_MEMB(s, rc);
! 				bdaddr_t* bdaddr = &_BT_RC_MEMB(addr, bdaddr);
  
! 				_BT_RC_MEMB(addr, family) = AF_BLUETOOTH;
! 				if( !PyArg_ParseTuple(args, "(iiiiii)i", &bdaddr->b[0], &bdaddr->b[1], &bdaddr->b[2], &bdaddr->b[3], &bdaddr->b[4], &bdaddr->b[5], &_BT_RC_MEMB(addr, channel)) )
  				{
  					PyErr_SetString(socket_error, "getsockaddrarg: wrong format");
***************
*** 1050,1059 ****
  				return 1;
  			}
  			case BTPROTO_SCO:
  			{
! 				struct sockaddr_sco* addr = (struct sockaddr_sco*) &(s->sock_addr).bt_sco;
! 				bdaddr_t* bdaddr = &(addr->sco_bdaddr);
  
! 				addr->sco_family = AF_BLUETOOTH;
  				if( !PyArg_ParseTuple(args, "iiiiii", &bdaddr->b[0], &bdaddr->b[1], &bdaddr->b[2], &bdaddr->b[3], &bdaddr->b[4], &bdaddr->b[5]) )
  				{
--- 1068,1078 ----
  				return 1;
  			}
+ #if !defined(__FreeBSD__)
  			case BTPROTO_SCO:
  			{
! 				struct sockaddr_sco* addr = (struct sockaddr_sco*)_BT_SOCKADDR_MEMB(s, sco);
! 				bdaddr_t* bdaddr = &_BT_SCO_MEMB(addr, bdaddr);
  
! 				_BT_SCO_MEMB(addr, family) = AF_BLUETOOTH;
  				if( !PyArg_ParseTuple(args, "iiiiii", &bdaddr->b[0], &bdaddr->b[1], &bdaddr->b[2], &bdaddr->b[3], &bdaddr->b[4], &bdaddr->b[5]) )
  				{
***************
*** 1066,1069 ****
--- 1085,1089 ----
  				return 1;
  			}
+ #endif
  			default:
  			{
***************
*** 1148,1152 ****
  #endif
  
! #ifdef HAVE_BLUETOOTH_BLUETOOTH_H
  	case AF_BLUETOOTH:
  	{
--- 1168,1172 ----
  #endif
  
! #ifdef USE_BLUETOOTH
  	case AF_BLUETOOTH:
  	{
***************
*** 1163,1166 ****
--- 1183,1187 ----
  				return 1;
  			}
+ #if !defined(__FreeBSD__)
  			case BTPROTO_SCO:
  			{
***************
*** 1168,1171 ****
--- 1189,1193 ----
  				return 1;
  			}
+ #endif
  			default:
  			{
***************
*** 3666,3673 ****
  #endif
  
! #ifdef HAVE_BLUETOOTH_BLUETOOTH_H
  	PyModule_AddIntConstant(m, "AF_BLUETOOTH", AF_BLUETOOTH);
  	PyModule_AddIntConstant(m, "BTPROTO_L2CAP", BTPROTO_L2CAP);
  	PyModule_AddIntConstant(m, "BTPROTO_SCO", BTPROTO_SCO);
  	PyModule_AddIntConstant(m, "BTPROTO_RFCOMM", BTPROTO_RFCOMM);
  	PyModule_AddObject(m, "BDADDR_ANY", Py_BuildValue( "iiiiii", 0,0,0,0,0,0 ) );
--- 3688,3697 ----
  #endif
  
! #ifdef USE_BLUETOOTH
  	PyModule_AddIntConstant(m, "AF_BLUETOOTH", AF_BLUETOOTH);
  	PyModule_AddIntConstant(m, "BTPROTO_L2CAP", BTPROTO_L2CAP);
+ #if !defined(__FreeBSD__)
  	PyModule_AddIntConstant(m, "BTPROTO_SCO", BTPROTO_SCO);
+ #endif
  	PyModule_AddIntConstant(m, "BTPROTO_RFCOMM", BTPROTO_RFCOMM);
  	PyModule_AddObject(m, "BDADDR_ANY", Py_BuildValue( "iiiiii", 0,0,0,0,0,0 ) );




More information about the Python-checkins mailing list