Mercurial > cpython-lru_cache-weakref
annotate Modules/socketmodule.h @ 66978:aed2bbafa550 3.1
Blocked revisions 87324 via svnmerge
........
r87324 | r.david.murray | 2010-12-16 14:08:51 -0500 (Thu, 16 Dec 2010) | 9 lines
#10719: restore messages generated on invalid compileall args
Before the introduction of filename arguments to compileall it gave semi useful
messages about not being able to 'list' names that weren't valid directories.
This fix restores that behavior. In addition to the test for this case, the
patch also adds a test for the default behavior of compileall when no arguments
are provided, and fixes a bug in one of the previously added tests.
........
| author | R. David Murray <rdmurray@bitdance.com> |
|---|---|
| date | Thu, 16 Dec 2010 19:10:16 +0000 |
| parents | 5c89f9571ba5 |
| children | 3d9a86b8cc98 |
| rev | line source |
|---|---|
|
21959
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
1 /* Socket module header file */ |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
2 |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
3 /* Includes needed for the sockaddr_* symbols below */ |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
4 #ifndef MS_WINDOWS |
|
28949
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
23815
diff
changeset
|
5 #ifdef __VMS |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
23815
diff
changeset
|
6 # include <socket.h> |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
23815
diff
changeset
|
7 # else |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
23815
diff
changeset
|
8 # include <sys/socket.h> |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
23815
diff
changeset
|
9 # endif |
|
21959
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
10 # include <netinet/in.h> |
|
44082
4cb95fc4129e
Marc-Andre Lemburg has found the culprit of the problem in r57142.
Christian Heimes <christian@cheimes.de>
parents:
42645
diff
changeset
|
11 # if !(defined(__CYGWIN__) || (defined(PYOS_OS2) && defined(PYCC_VACPP))) |
|
21959
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
12 # include <netinet/tcp.h> |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
13 # endif |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
14 |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
15 #else /* MS_WINDOWS */ |
|
22096
9e5ff6747437
Patch #520062: Support IPv6 with VC.NET.
Martin v. Löwis <martin@v.loewis.de>
parents:
22041
diff
changeset
|
16 # include <winsock2.h> |
|
9e5ff6747437
Patch #520062: Support IPv6 with VC.NET.
Martin v. Löwis <martin@v.loewis.de>
parents:
22041
diff
changeset
|
17 # include <ws2tcpip.h> |
|
47667
b1f4ea4eb555
Merged revisions 64214 via svnmerge from
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44568
diff
changeset
|
18 /* VC6 is shipped with old platform headers, and does not have MSTcpIP.h |
|
b1f4ea4eb555
Merged revisions 64214 via svnmerge from
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44568
diff
changeset
|
19 * Separate SDKs have all the functions we want, but older ones don't have |
|
61467
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
20 * any version information. |
|
47718
96bff7e137fb
Merged revisions 64267-64272 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
47667
diff
changeset
|
21 * I use SIO_GET_MULTICAST_FILTER to detect a decent SDK. |
|
47667
b1f4ea4eb555
Merged revisions 64214 via svnmerge from
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44568
diff
changeset
|
22 */ |
|
47718
96bff7e137fb
Merged revisions 64267-64272 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
47667
diff
changeset
|
23 # ifdef SIO_GET_MULTICAST_FILTER |
|
47667
b1f4ea4eb555
Merged revisions 64214 via svnmerge from
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44568
diff
changeset
|
24 # include <MSTcpIP.h> /* for SIO_RCVALL */ |
|
b1f4ea4eb555
Merged revisions 64214 via svnmerge from
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44568
diff
changeset
|
25 # define HAVE_ADDRINFO |
|
b1f4ea4eb555
Merged revisions 64214 via svnmerge from
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44568
diff
changeset
|
26 # define HAVE_SOCKADDR_STORAGE |
|
b1f4ea4eb555
Merged revisions 64214 via svnmerge from
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44568
diff
changeset
|
27 # define HAVE_GETADDRINFO |
|
b1f4ea4eb555
Merged revisions 64214 via svnmerge from
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44568
diff
changeset
|
28 # define HAVE_GETNAMEINFO |
|
b1f4ea4eb555
Merged revisions 64214 via svnmerge from
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44568
diff
changeset
|
29 # define ENABLE_IPV6 |
|
b1f4ea4eb555
Merged revisions 64214 via svnmerge from
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44568
diff
changeset
|
30 # else |
|
b1f4ea4eb555
Merged revisions 64214 via svnmerge from
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44568
diff
changeset
|
31 typedef int socklen_t; |
|
b1f4ea4eb555
Merged revisions 64214 via svnmerge from
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44568
diff
changeset
|
32 # endif /* IPPROTO_IPV6 */ |
|
b1f4ea4eb555
Merged revisions 64214 via svnmerge from
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44568
diff
changeset
|
33 #endif /* MS_WINDOWS */ |
|
21959
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
34 |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
35 #ifdef HAVE_SYS_UN_H |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
36 # include <sys/un.h> |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
37 #else |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
38 # undef AF_UNIX |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
39 #endif |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
40 |
|
36286
ae4480935016
Patch #1103116: AF_NETLINK sockets basic support.
Martin v. Löwis <martin@v.loewis.de>
parents:
35551
diff
changeset
|
41 #ifdef HAVE_LINUX_NETLINK_H |
|
36298
9eeaa33f9640
Get socketmodule to build after adding netlink support.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36286
diff
changeset
|
42 # ifdef HAVE_ASM_TYPES_H |
|
9eeaa33f9640
Get socketmodule to build after adding netlink support.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36286
diff
changeset
|
43 # include <asm/types.h> |
|
9eeaa33f9640
Get socketmodule to build after adding netlink support.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36286
diff
changeset
|
44 # endif |
|
36286
ae4480935016
Patch #1103116: AF_NETLINK sockets basic support.
Martin v. Löwis <martin@v.loewis.de>
parents:
35551
diff
changeset
|
45 # include <linux/netlink.h> |
|
ae4480935016
Patch #1103116: AF_NETLINK sockets basic support.
Martin v. Löwis <martin@v.loewis.de>
parents:
35551
diff
changeset
|
46 #else |
|
ae4480935016
Patch #1103116: AF_NETLINK sockets basic support.
Martin v. Löwis <martin@v.loewis.de>
parents:
35551
diff
changeset
|
47 # undef AF_NETLINK |
|
ae4480935016
Patch #1103116: AF_NETLINK sockets basic support.
Martin v. Löwis <martin@v.loewis.de>
parents:
35551
diff
changeset
|
48 #endif |
|
ae4480935016
Patch #1103116: AF_NETLINK sockets basic support.
Martin v. Löwis <martin@v.loewis.de>
parents:
35551
diff
changeset
|
49 |
|
31441
493707692671
Patch #874083: Bluetooth support for socket module.
Martin v. Löwis <martin@v.loewis.de>
parents:
28949
diff
changeset
|
50 #ifdef HAVE_BLUETOOTH_BLUETOOTH_H |
|
493707692671
Patch #874083: Bluetooth support for socket module.
Martin v. Löwis <martin@v.loewis.de>
parents:
28949
diff
changeset
|
51 #include <bluetooth/bluetooth.h> |
|
493707692671
Patch #874083: Bluetooth support for socket module.
Martin v. Löwis <martin@v.loewis.de>
parents:
28949
diff
changeset
|
52 #include <bluetooth/rfcomm.h> |
|
493707692671
Patch #874083: Bluetooth support for socket module.
Martin v. Löwis <martin@v.loewis.de>
parents:
28949
diff
changeset
|
53 #include <bluetooth/l2cap.h> |
|
493707692671
Patch #874083: Bluetooth support for socket module.
Martin v. Löwis <martin@v.loewis.de>
parents:
28949
diff
changeset
|
54 #include <bluetooth/sco.h> |
|
40893
32c4897b5d46
Merged revisions 53623-53858 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40450
diff
changeset
|
55 #include <bluetooth/hci.h> |
|
31441
493707692671
Patch #874083: Bluetooth support for socket module.
Martin v. Löwis <martin@v.loewis.de>
parents:
28949
diff
changeset
|
56 #endif |
|
493707692671
Patch #874083: Bluetooth support for socket module.
Martin v. Löwis <martin@v.loewis.de>
parents:
28949
diff
changeset
|
57 |
|
31444
a282801b06b6
Add FreeBSD support for bluetooth sockets. (SF Patch #888148)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31441
diff
changeset
|
58 #ifdef HAVE_BLUETOOTH_H |
|
a282801b06b6
Add FreeBSD support for bluetooth sockets. (SF Patch #888148)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31441
diff
changeset
|
59 #include <bluetooth.h> |
|
a282801b06b6
Add FreeBSD support for bluetooth sockets. (SF Patch #888148)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31441
diff
changeset
|
60 #endif |
|
a282801b06b6
Add FreeBSD support for bluetooth sockets. (SF Patch #888148)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31441
diff
changeset
|
61 |
|
21959
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
62 #ifdef HAVE_NETPACKET_PACKET_H |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
63 # include <sys/ioctl.h> |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
64 # include <net/if.h> |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
65 # include <netpacket/packet.h> |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
66 #endif |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
67 |
|
44568
305d7d2ce047
Copied doc for reload() from trunk's function.rst to imp.rst
Christian Heimes <christian@cheimes.de>
parents:
44535
diff
changeset
|
68 #ifdef HAVE_LINUX_TIPC_H |
|
305d7d2ce047
Copied doc for reload() from trunk's function.rst to imp.rst
Christian Heimes <christian@cheimes.de>
parents:
44535
diff
changeset
|
69 # include <linux/tipc.h> |
|
305d7d2ce047
Copied doc for reload() from trunk's function.rst to imp.rst
Christian Heimes <christian@cheimes.de>
parents:
44535
diff
changeset
|
70 #endif |
|
305d7d2ce047
Copied doc for reload() from trunk's function.rst to imp.rst
Christian Heimes <christian@cheimes.de>
parents:
44535
diff
changeset
|
71 |
|
21959
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
72 #ifndef Py__SOCKET_H |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
73 #define Py__SOCKET_H |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
74 #ifdef __cplusplus |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
75 extern "C" { |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
76 #endif |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
77 |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
78 /* Python module and C API name */ |
|
61467
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
79 #define PySocket_MODULE_NAME "_socket" |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
80 #define PySocket_CAPI_NAME "CAPI" |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
81 #define PySocket_CAPSULE_NAME PySocket_MODULE_NAME "." PySocket_CAPI_NAME |
|
21959
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
82 |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
83 /* Abstract the socket file descriptor type */ |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
84 #ifdef MS_WINDOWS |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
85 typedef SOCKET SOCKET_T; |
|
61467
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
86 # ifdef MS_WIN64 |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
87 # define SIZEOF_SOCKET_T 8 |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
88 # else |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
89 # define SIZEOF_SOCKET_T 4 |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
90 # endif |
|
21959
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
91 #else |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
92 typedef int SOCKET_T; |
|
61467
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
93 # define SIZEOF_SOCKET_T SIZEOF_INT |
|
21959
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
94 #endif |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
95 |
|
64302
5c89f9571ba5
Merged revisions 84347 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
61467
diff
changeset
|
96 #if SIZEOF_SOCKET_T <= SIZEOF_LONG |
|
5c89f9571ba5
Merged revisions 84347 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
61467
diff
changeset
|
97 #define PyLong_FromSocket_t(fd) PyLong_FromLong((SOCKET_T)(fd)) |
|
5c89f9571ba5
Merged revisions 84347 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
61467
diff
changeset
|
98 #define PyLong_AsSocket_t(fd) (SOCKET_T)PyLong_AsLong(fd) |
|
5c89f9571ba5
Merged revisions 84347 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
61467
diff
changeset
|
99 #else |
|
5c89f9571ba5
Merged revisions 84347 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
61467
diff
changeset
|
100 #define PyLong_FromSocket_t(fd) PyLong_FromLongLong((SOCKET_T)(fd)) |
|
5c89f9571ba5
Merged revisions 84347 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
61467
diff
changeset
|
101 #define PyLong_AsSocket_t(fd) (SOCKET_T)PyLong_AsLongLong(fd) |
|
5c89f9571ba5
Merged revisions 84347 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
61467
diff
changeset
|
102 #endif |
|
5c89f9571ba5
Merged revisions 84347 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
61467
diff
changeset
|
103 |
|
35551
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
104 /* Socket address */ |
|
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
105 typedef union sock_addr { |
|
61467
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
106 struct sockaddr_in in; |
|
35551
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
107 #ifdef AF_UNIX |
|
61467
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
108 struct sockaddr_un un; |
|
35551
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
109 #endif |
|
36286
ae4480935016
Patch #1103116: AF_NETLINK sockets basic support.
Martin v. Löwis <martin@v.loewis.de>
parents:
35551
diff
changeset
|
110 #ifdef AF_NETLINK |
|
61467
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
111 struct sockaddr_nl nl; |
|
36286
ae4480935016
Patch #1103116: AF_NETLINK sockets basic support.
Martin v. Löwis <martin@v.loewis.de>
parents:
35551
diff
changeset
|
112 #endif |
|
35551
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
113 #ifdef ENABLE_IPV6 |
|
61467
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
114 struct sockaddr_in6 in6; |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
115 struct sockaddr_storage storage; |
|
35551
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
116 #endif |
|
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
117 #ifdef HAVE_BLUETOOTH_BLUETOOTH_H |
|
61467
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
118 struct sockaddr_l2 bt_l2; |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
119 struct sockaddr_rc bt_rc; |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
120 struct sockaddr_sco bt_sco; |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
121 struct sockaddr_hci bt_hci; |
|
35551
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
122 #endif |
|
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
123 #ifdef HAVE_NETPACKET_PACKET_H |
|
61467
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
124 struct sockaddr_ll ll; |
|
35551
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
125 #endif |
|
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
126 } sock_addr_t; |
|
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
127 |
|
21959
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
128 /* The object holding a socket. It holds some extra information, |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
129 like the address family, which is used to decode socket address |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
130 arguments properly. */ |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
131 |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
132 typedef struct { |
|
61467
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
133 PyObject_HEAD |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
134 SOCKET_T sock_fd; /* Socket file descriptor */ |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
135 int sock_family; /* Address family, e.g., AF_INET */ |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
136 int sock_type; /* Socket type, e.g., SOCK_STREAM */ |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
137 int sock_proto; /* Protocol type, usually 0 */ |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
138 PyObject *(*errorhandler)(void); /* Error handler; checks |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
139 errno, returns NULL and |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
140 sets a Python exception */ |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
141 double sock_timeout; /* Operation timeout in seconds; |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
142 0.0 means non-blocking */ |
|
21959
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
143 } PySocketSockObject; |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
144 |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
145 /* --- C API ----------------------------------------------------*/ |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
146 |
|
22041
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
147 /* Short explanation of what this C API export mechanism does |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
148 and how it works: |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
149 |
|
61467
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
150 The _ssl module needs access to the type object defined in |
|
22041
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
151 the _socket module. Since cross-DLL linking introduces a lot of |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
152 problems on many platforms, the "trick" is to wrap the |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
153 C API of a module in a struct which then gets exported to |
|
53816
911df82bc25d
add a replacement API for PyCObject, PyCapsule #5630
Benjamin Peterson <benjamin@python.org>
parents:
47718
diff
changeset
|
154 other modules via a PyCapsule. |
|
22041
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
155 |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
156 The code in socketmodule.c defines this struct (which currently |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
157 only contains the type object reference, but could very |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
158 well also include other C APIs needed by other modules) |
|
53816
911df82bc25d
add a replacement API for PyCObject, PyCapsule #5630
Benjamin Peterson <benjamin@python.org>
parents:
47718
diff
changeset
|
159 and exports it as PyCapsule via the module dictionary |
|
22041
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
160 under the name "CAPI". |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
161 |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
162 Other modules can now include the socketmodule.h file |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
163 which defines the needed C APIs to import and set up |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
164 a static copy of this struct in the importing module. |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
165 |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
166 After initialization, the importing module can then |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
167 access the C APIs from the _socket module by simply |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
168 referring to the static struct, e.g. |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
169 |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
170 Load _socket module and its C API; this sets up the global |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
171 PySocketModule: |
|
61467
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
172 |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
173 if (PySocketModule_ImportModuleAndAPI()) |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
174 return; |
|
22041
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
175 |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
176 |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
177 Now use the C API as if it were defined in the using |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
178 module: |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
179 |
|
61467
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
180 if (!PyArg_ParseTuple(args, "O!|zz:ssl", |
|
22041
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
181 |
|
61467
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
182 PySocketModule.Sock_Type, |
|
22041
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
183 |
|
61467
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
184 (PyObject*)&Sock, |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
185 &key_file, &cert_file)) |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
186 return NULL; |
|
22041
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
187 |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
188 Support could easily be extended to export more C APIs/symbols |
|
61467
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
189 this way. Currently, only the type object is exported, |
|
22041
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
190 other candidates would be socket constructors and socket |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
191 access functions. |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
192 |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
193 */ |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
194 |
|
21959
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
195 /* C API for usage by other Python modules */ |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
196 typedef struct { |
|
61467
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
197 PyTypeObject *Sock_Type; |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
55573
diff
changeset
|
198 PyObject *error; |
|
21969
72c95448ee4b
For readability, switch to tab indents; was using a mix of tab indents,
Tim Peters <tim.peters@gmail.com>
parents:
21959
diff
changeset
|
199 } PySocketModule_APIObject; |
|
21959
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
200 |
|
53824
b666e72f602f
turn this into a macro
Benjamin Peterson <benjamin@python.org>
parents:
53816
diff
changeset
|
201 #define PySocketModule_ImportModuleAndAPI() PyCapsule_Import(PySocket_CAPSULE_NAME, 1) |
|
21959
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
202 |
|
55573
5c8b2238a2f5
Merged revisions 74356-74357 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
53824
diff
changeset
|
203 #ifdef __cplusplus |
|
21959
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
204 } |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
205 #endif |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
206 #endif /* !Py__SOCKET_H */ |
