Mercurial > cpython-lru_cache-weakref
annotate Modules/socketmodule.h @ 49955:878d40468c4e legacy-trunk
Issue #4384: Added logging integration with warnings module using captureWarnings(). This change includes a NullHandler which does nothing; it will be of use to library developers who want to avoid the "No handlers could be found for logger XXX" message which can appear if the library user doesn't configure logging.
| author | Vinay Sajip <vinay_sajip@yahoo.co.uk> |
|---|---|
| date | Wed, 03 Dec 2008 23:22:58 +0000 |
| parents | e9c935cd7888 |
| children | e38335d4df91 d11fbc796499 |
| 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> |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
11 # if !(defined(__BEOS__) || defined(__CYGWIN__) || (defined(PYOS_OS2) && defined(PYCC_VACPP))) |
|
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> |
|
47666
fcfe10f3dc14
Restore support for Microsoft VC6 compiler.
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44561
diff
changeset
|
18 /* VC6 is shipped with old platform headers, and does not have MSTcpIP.h |
|
fcfe10f3dc14
Restore support for Microsoft VC6 compiler.
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44561
diff
changeset
|
19 * Separate SDKs have all the functions we want, but older ones don't have |
|
47714
e9c935cd7888
on windows, r64214 broke compilation with some recent SDKs,
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47666
diff
changeset
|
20 * any version information. |
|
e9c935cd7888
on windows, r64214 broke compilation with some recent SDKs,
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47666
diff
changeset
|
21 * I use SIO_GET_MULTICAST_FILTER to detect a decent SDK. |
|
47666
fcfe10f3dc14
Restore support for Microsoft VC6 compiler.
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44561
diff
changeset
|
22 */ |
|
47714
e9c935cd7888
on windows, r64214 broke compilation with some recent SDKs,
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47666
diff
changeset
|
23 # ifdef SIO_GET_MULTICAST_FILTER |
|
47666
fcfe10f3dc14
Restore support for Microsoft VC6 compiler.
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44561
diff
changeset
|
24 # include <MSTcpIP.h> /* for SIO_RCVALL */ |
|
fcfe10f3dc14
Restore support for Microsoft VC6 compiler.
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44561
diff
changeset
|
25 # define HAVE_ADDRINFO |
|
fcfe10f3dc14
Restore support for Microsoft VC6 compiler.
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44561
diff
changeset
|
26 # define HAVE_SOCKADDR_STORAGE |
|
fcfe10f3dc14
Restore support for Microsoft VC6 compiler.
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44561
diff
changeset
|
27 # define HAVE_GETADDRINFO |
|
fcfe10f3dc14
Restore support for Microsoft VC6 compiler.
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44561
diff
changeset
|
28 # define HAVE_GETNAMEINFO |
|
fcfe10f3dc14
Restore support for Microsoft VC6 compiler.
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44561
diff
changeset
|
29 # define ENABLE_IPV6 |
|
fcfe10f3dc14
Restore support for Microsoft VC6 compiler.
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44561
diff
changeset
|
30 # else |
|
fcfe10f3dc14
Restore support for Microsoft VC6 compiler.
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44561
diff
changeset
|
31 typedef int socklen_t; |
|
fcfe10f3dc14
Restore support for Microsoft VC6 compiler.
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44561
diff
changeset
|
32 # endif /* IPPROTO_IPV6 */ |
|
fcfe10f3dc14
Restore support for Microsoft VC6 compiler.
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44561
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> |
|
40842
90e22fea8363
Patch #1432399: Add HCI sockets.
Martin v. Löwis <martin@v.loewis.de>
parents:
40416
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 |
|
44561
ac51cfe5c5c6
Issue #1646: Make socket support TIPC. The socket module now has support
Christian Heimes <christian@cheimes.de>
parents:
44474
diff
changeset
|
68 #ifdef HAVE_LINUX_TIPC_H |
|
ac51cfe5c5c6
Issue #1646: Make socket support TIPC. The socket module now has support
Christian Heimes <christian@cheimes.de>
parents:
44474
diff
changeset
|
69 # include <linux/tipc.h> |
|
ac51cfe5c5c6
Issue #1646: Make socket support TIPC. The socket module now has support
Christian Heimes <christian@cheimes.de>
parents:
44474
diff
changeset
|
70 #endif |
|
ac51cfe5c5c6
Issue #1646: Make socket support TIPC. The socket module now has support
Christian Heimes <christian@cheimes.de>
parents:
44474
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 */ |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
79 #define PySocket_MODULE_NAME "_socket" |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
80 #define PySocket_CAPI_NAME "CAPI" |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
81 |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
82 /* 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
|
83 #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
|
84 typedef SOCKET SOCKET_T; |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
85 # ifdef MS_WIN64 |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
86 # define SIZEOF_SOCKET_T 8 |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
87 # else |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
88 # define SIZEOF_SOCKET_T 4 |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
89 # endif |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
90 #else |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
91 typedef int SOCKET_T; |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
92 # define SIZEOF_SOCKET_T SIZEOF_INT |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
93 #endif |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
94 |
|
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
|
95 /* 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
|
96 typedef union sock_addr { |
|
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
97 struct sockaddr_in in; |
|
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
98 #ifdef AF_UNIX |
|
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
99 struct sockaddr_un un; |
|
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
100 #endif |
|
36286
ae4480935016
Patch #1103116: AF_NETLINK sockets basic support.
Martin v. Löwis <martin@v.loewis.de>
parents:
35551
diff
changeset
|
101 #ifdef AF_NETLINK |
|
ae4480935016
Patch #1103116: AF_NETLINK sockets basic support.
Martin v. Löwis <martin@v.loewis.de>
parents:
35551
diff
changeset
|
102 struct sockaddr_nl nl; |
|
ae4480935016
Patch #1103116: AF_NETLINK sockets basic support.
Martin v. Löwis <martin@v.loewis.de>
parents:
35551
diff
changeset
|
103 #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
|
104 #ifdef ENABLE_IPV6 |
|
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 struct sockaddr_in6 in6; |
|
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
106 struct sockaddr_storage storage; |
|
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 #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
|
108 #ifdef HAVE_BLUETOOTH_BLUETOOTH_H |
|
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 struct sockaddr_l2 bt_l2; |
|
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
110 struct sockaddr_rc bt_rc; |
|
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
111 struct sockaddr_sco bt_sco; |
|
40842
90e22fea8363
Patch #1432399: Add HCI sockets.
Martin v. Löwis <martin@v.loewis.de>
parents:
40416
diff
changeset
|
112 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
|
113 #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
|
114 #ifdef HAVE_NETPACKET_PACKET_H |
|
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
115 struct sockaddr_ll ll; |
|
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 } 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
|
118 |
|
21959
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
119 /* 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
|
120 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
|
121 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
|
122 |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
123 typedef struct { |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
124 PyObject_HEAD |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
125 SOCKET_T sock_fd; /* Socket file descriptor */ |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
126 int sock_family; /* Address family, e.g., AF_INET */ |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
127 int sock_type; /* Socket type, e.g., SOCK_STREAM */ |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
128 int sock_proto; /* Protocol type, usually 0 */ |
|
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
|
129 PyObject *(*errorhandler)(void); /* Error handler; checks |
|
21959
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
130 errno, returns NULL and |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
131 sets a Python exception */ |
|
23815
203d1412a7e8
Major overhaul of timeout sockets:
Guido van Rossum <guido@python.org>
parents:
23724
diff
changeset
|
132 double sock_timeout; /* Operation timeout in seconds; |
|
203d1412a7e8
Major overhaul of timeout sockets:
Guido van Rossum <guido@python.org>
parents:
23724
diff
changeset
|
133 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
|
134 } PySocketSockObject; |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
135 |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
136 /* --- 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
|
137 |
|
22041
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
138 /* 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
|
139 and how it works: |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
140 |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
141 The _ssl module needs access to the type object defined in |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
142 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
|
143 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
|
144 C API of a module in a struct which then gets exported to |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
145 other modules via a PyCObject. |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
146 |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
147 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
|
148 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
|
149 well also include other C APIs needed by other modules) |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
150 and exports it as PyCObject via the module dictionary |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
151 under the name "CAPI". |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
152 |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
153 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
|
154 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
|
155 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
|
156 |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
157 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
|
158 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
|
159 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
|
160 |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
161 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
|
162 PySocketModule: |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
163 |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
164 if (PySocketModule_ImportModuleAndAPI()) |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
165 return; |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
166 |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
167 |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
168 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
|
169 module: |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
170 |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
171 if (!PyArg_ParseTuple(args, "O!|zz:ssl", |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
172 |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
173 PySocketModule.Sock_Type, |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
174 |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
175 (PyObject*)&Sock, |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
176 &key_file, &cert_file)) |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
177 return NULL; |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
178 |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
179 Support could easily be extended to export more C APIs/symbols |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
180 this way. Currently, only the type object is exported, |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
181 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
|
182 access functions. |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
183 |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
184 */ |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
185 |
|
21959
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
186 /* 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
|
187 typedef struct { |
|
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
|
188 PyTypeObject *Sock_Type; |
|
31790
29da8bdfeb4e
Make socket.sslerror a subclass of socket.error .
Brett Cannon <bcannon@gmail.com>
parents:
31444
diff
changeset
|
189 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
|
190 } 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
|
191 |
|
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
|
192 /* XXX The net effect of the following appears to be to define a function |
|
72c95448ee4b
For readability, switch to tab indents; was using a mix of tab indents,
Tim Peters <tim.peters@gmail.com>
parents:
21959
diff
changeset
|
193 XXX named PySocketModule_APIObject in _ssl.c. It's unclear why it isn't |
|
22041
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
194 XXX defined there directly. |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
195 |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
196 >>> It's defined here because other modules might also want to use |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
197 >>> the C API. |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
198 |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
199 */ |
|
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 #ifndef PySocket_BUILDING_SOCKET |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
201 |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
202 /* --- 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
|
203 |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
204 /* Interfacestructure to C API for other modules. |
| 23724 | 205 Call PySocketModule_ImportModuleAndAPI() to initialize this |
|
21959
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
206 structure. After that usage is simple: |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
207 |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
208 if (!PyArg_ParseTuple(args, "O!|zz:ssl", |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
209 &PySocketModule.Sock_Type, (PyObject*)&Sock, |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
210 &key_file, &cert_file)) |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
211 return NULL; |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
212 ... |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
213 */ |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
214 |
|
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
|
215 static |
|
21959
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
216 PySocketModule_APIObject PySocketModule; |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
217 |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
218 /* You *must* call this before using any of the functions in |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
219 PySocketModule and check its outcome; otherwise all accesses will |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
220 result in a segfault. Returns 0 on success. */ |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
221 |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
222 #ifndef DPRINTF |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
223 # define DPRINTF if (0) printf |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
224 #endif |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
225 |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
226 static |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
227 int PySocketModule_ImportModuleAndAPI(void) |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
228 { |
|
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
|
229 PyObject *mod = 0, *v = 0; |
|
72c95448ee4b
For readability, switch to tab indents; was using a mix of tab indents,
Tim Peters <tim.peters@gmail.com>
parents:
21959
diff
changeset
|
230 char *apimodule = PySocket_MODULE_NAME; |
|
72c95448ee4b
For readability, switch to tab indents; was using a mix of tab indents,
Tim Peters <tim.peters@gmail.com>
parents:
21959
diff
changeset
|
231 char *apiname = PySocket_CAPI_NAME; |
|
72c95448ee4b
For readability, switch to tab indents; was using a mix of tab indents,
Tim Peters <tim.peters@gmail.com>
parents:
21959
diff
changeset
|
232 void *api; |
|
72c95448ee4b
For readability, switch to tab indents; was using a mix of tab indents,
Tim Peters <tim.peters@gmail.com>
parents:
21959
diff
changeset
|
233 |
|
72c95448ee4b
For readability, switch to tab indents; was using a mix of tab indents,
Tim Peters <tim.peters@gmail.com>
parents:
21959
diff
changeset
|
234 DPRINTF("Importing the %s C API...\n", apimodule); |
|
44439
0cbe94bea2c7
Modified PyImport_Import and PyImport_ImportModule to always use absolute imports by calling __import__ with an explicit level of 0
Christian Heimes <christian@cheimes.de>
parents:
40842
diff
changeset
|
235 mod = PyImport_ImportModuleNoBlock(apimodule); |
|
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
|
236 if (mod == NULL) |
|
72c95448ee4b
For readability, switch to tab indents; was using a mix of tab indents,
Tim Peters <tim.peters@gmail.com>
parents:
21959
diff
changeset
|
237 goto onError; |
|
72c95448ee4b
For readability, switch to tab indents; was using a mix of tab indents,
Tim Peters <tim.peters@gmail.com>
parents:
21959
diff
changeset
|
238 DPRINTF(" %s package found\n", apimodule); |
|
72c95448ee4b
For readability, switch to tab indents; was using a mix of tab indents,
Tim Peters <tim.peters@gmail.com>
parents:
21959
diff
changeset
|
239 v = PyObject_GetAttrString(mod, apiname); |
|
72c95448ee4b
For readability, switch to tab indents; was using a mix of tab indents,
Tim Peters <tim.peters@gmail.com>
parents:
21959
diff
changeset
|
240 if (v == NULL) |
|
72c95448ee4b
For readability, switch to tab indents; was using a mix of tab indents,
Tim Peters <tim.peters@gmail.com>
parents:
21959
diff
changeset
|
241 goto onError; |
|
72c95448ee4b
For readability, switch to tab indents; was using a mix of tab indents,
Tim Peters <tim.peters@gmail.com>
parents:
21959
diff
changeset
|
242 Py_DECREF(mod); |
|
72c95448ee4b
For readability, switch to tab indents; was using a mix of tab indents,
Tim Peters <tim.peters@gmail.com>
parents:
21959
diff
changeset
|
243 DPRINTF(" API object %s found\n", apiname); |
|
72c95448ee4b
For readability, switch to tab indents; was using a mix of tab indents,
Tim Peters <tim.peters@gmail.com>
parents:
21959
diff
changeset
|
244 api = PyCObject_AsVoidPtr(v); |
|
72c95448ee4b
For readability, switch to tab indents; was using a mix of tab indents,
Tim Peters <tim.peters@gmail.com>
parents:
21959
diff
changeset
|
245 if (api == NULL) |
|
72c95448ee4b
For readability, switch to tab indents; was using a mix of tab indents,
Tim Peters <tim.peters@gmail.com>
parents:
21959
diff
changeset
|
246 goto onError; |
|
72c95448ee4b
For readability, switch to tab indents; was using a mix of tab indents,
Tim Peters <tim.peters@gmail.com>
parents:
21959
diff
changeset
|
247 Py_DECREF(v); |
|
72c95448ee4b
For readability, switch to tab indents; was using a mix of tab indents,
Tim Peters <tim.peters@gmail.com>
parents:
21959
diff
changeset
|
248 memcpy(&PySocketModule, api, sizeof(PySocketModule)); |
|
72c95448ee4b
For readability, switch to tab indents; was using a mix of tab indents,
Tim Peters <tim.peters@gmail.com>
parents:
21959
diff
changeset
|
249 DPRINTF(" API object loaded and initialized.\n"); |
|
72c95448ee4b
For readability, switch to tab indents; was using a mix of tab indents,
Tim Peters <tim.peters@gmail.com>
parents:
21959
diff
changeset
|
250 return 0; |
|
72c95448ee4b
For readability, switch to tab indents; was using a mix of tab indents,
Tim Peters <tim.peters@gmail.com>
parents:
21959
diff
changeset
|
251 |
|
21959
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
252 onError: |
|
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
|
253 DPRINTF(" not found.\n"); |
|
72c95448ee4b
For readability, switch to tab indents; was using a mix of tab indents,
Tim Peters <tim.peters@gmail.com>
parents:
21959
diff
changeset
|
254 Py_XDECREF(mod); |
|
72c95448ee4b
For readability, switch to tab indents; was using a mix of tab indents,
Tim Peters <tim.peters@gmail.com>
parents:
21959
diff
changeset
|
255 Py_XDECREF(v); |
|
72c95448ee4b
For readability, switch to tab indents; was using a mix of tab indents,
Tim Peters <tim.peters@gmail.com>
parents:
21959
diff
changeset
|
256 return -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
|
257 } |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
258 |
|
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
|
259 #endif /* !PySocket_BUILDING_SOCKET */ |
|
21959
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
260 |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
261 #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
|
262 } |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
263 #endif |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
264 #endif /* !Py__SOCKET_H */ |
