annotate Modules/_xdrmodule.c @ 4566:6403c94de50d legacy-trunk

Added safeguard against failure in __del__.
author Guido van Rossum <guido@python.org>
date Wed, 27 Nov 1996 19:39:58 +0000
parents a3926484a658
children ddea69f9071b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4048
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 /* This module exports part of the C API to the XDR routines into Python.
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 * XDR is Sun's eXternal Data Representation, as described in RFC 1014. This
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 * module is used by xdrlib.py to support the float and double data types
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
4 * which are too much of a pain to support in Python directly. It is
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 * not required by xdrlib.py -- when not available, these types aren't
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 * supported at the Python layer. Note that representations that can be
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 * implemented solely in Python, are *not* reproduced here.
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 *
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 * Module version number: 1.0
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
10 *
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 * See xdrlib.py for usage notes.
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 *
4062
d6de2c148819 Test for xdrmem_create() failure.
Guido van Rossum <guido@python.org>
parents: 4048
diff changeset
13 * Note: this has so far, only been tested on Solaris 2.5 and IRIX 5.3. On
d6de2c148819 Test for xdrmem_create() failure.
Guido van Rossum <guido@python.org>
parents: 4048
diff changeset
14 * these systems, you will need to link with -lnsl for these symbols to be
d6de2c148819 Test for xdrmem_create() failure.
Guido van Rossum <guido@python.org>
parents: 4048
diff changeset
15 * defined.
4048
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
16 */
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
17
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
18 #include "Python.h"
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
19
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 #include <rpc/rpc.h>
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
21 #include <rpc/xdr.h>
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
22
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
23 static PyObject* xdr_error;
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
24
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
25
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
26
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
27 static PyObject*
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
28 pack_float(self, args)
4062
d6de2c148819 Test for xdrmem_create() failure.
Guido van Rossum <guido@python.org>
parents: 4048
diff changeset
29 PyObject* self;
d6de2c148819 Test for xdrmem_create() failure.
Guido van Rossum <guido@python.org>
parents: 4048
diff changeset
30 PyObject* args;
4048
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
31 {
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
32 XDR xdr;
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
33 float value;
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
34 union { /* guarantees proper alignment */
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
35 long dummy;
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
36 char buffer[4];
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
37 } addr;
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
38 PyObject* rtn = NULL;
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
39
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
40 if (!PyArg_ParseTuple(args, "f", &value))
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
41 return NULL;
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
42
4062
d6de2c148819 Test for xdrmem_create() failure.
Guido van Rossum <guido@python.org>
parents: 4048
diff changeset
43 xdr.x_ops = NULL;
4048
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
44 xdrmem_create(&xdr, addr.buffer, 4, XDR_ENCODE);
4062
d6de2c148819 Test for xdrmem_create() failure.
Guido van Rossum <guido@python.org>
parents: 4048
diff changeset
45 if( xdr.x_ops == NULL )
d6de2c148819 Test for xdrmem_create() failure.
Guido van Rossum <guido@python.org>
parents: 4048
diff changeset
46 PyErr_SetString(xdr_error, "XDR stream initialization failed.");
d6de2c148819 Test for xdrmem_create() failure.
Guido van Rossum <guido@python.org>
parents: 4048
diff changeset
47 else if (xdr_float(&xdr, &value))
4048
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
48 rtn = PyString_FromStringAndSize(addr.buffer, 4);
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
49 else
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
50 PyErr_SetString(xdr_error, "conversion from float failed");
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
51
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
52 xdr_destroy(&xdr);
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
53 return rtn;
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
54 }
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
55
4062
d6de2c148819 Test for xdrmem_create() failure.
Guido van Rossum <guido@python.org>
parents: 4048
diff changeset
56
d6de2c148819 Test for xdrmem_create() failure.
Guido van Rossum <guido@python.org>
parents: 4048
diff changeset
57
4048
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
58 static PyObject*
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
59 pack_double(self, args)
4062
d6de2c148819 Test for xdrmem_create() failure.
Guido van Rossum <guido@python.org>
parents: 4048
diff changeset
60 PyObject* self;
d6de2c148819 Test for xdrmem_create() failure.
Guido van Rossum <guido@python.org>
parents: 4048
diff changeset
61 PyObject* args;
4048
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
62 {
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
63 XDR xdr;
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
64 double value;
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
65 union { /* guarantees proper alignment */
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
66 long dummy;
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
67 char buffer[8];
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
68 } addr;
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
69 PyObject* rtn = NULL;
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
70
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
71 if (!PyArg_ParseTuple(args, "d", &value))
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
72 return NULL;
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
73
4062
d6de2c148819 Test for xdrmem_create() failure.
Guido van Rossum <guido@python.org>
parents: 4048
diff changeset
74 xdr.x_ops = NULL;
4048
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
75 xdrmem_create(&xdr, addr.buffer, 8, XDR_ENCODE);
4062
d6de2c148819 Test for xdrmem_create() failure.
Guido van Rossum <guido@python.org>
parents: 4048
diff changeset
76 if( xdr.x_ops == NULL )
d6de2c148819 Test for xdrmem_create() failure.
Guido van Rossum <guido@python.org>
parents: 4048
diff changeset
77 PyErr_SetString(xdr_error, "XDR stream initialization failed.");
d6de2c148819 Test for xdrmem_create() failure.
Guido van Rossum <guido@python.org>
parents: 4048
diff changeset
78 else if (xdr_double(&xdr, &value))
4048
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
79 rtn = PyString_FromStringAndSize(addr.buffer, 8);
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
80 else
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
81 PyErr_SetString(xdr_error, "conversion from double failed");
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
82
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
83 xdr_destroy(&xdr);
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
84 return rtn;
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
85 }
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
86
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
87
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
88
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
89 static PyObject*
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
90 unpack_float(self, args)
4062
d6de2c148819 Test for xdrmem_create() failure.
Guido van Rossum <guido@python.org>
parents: 4048
diff changeset
91 PyObject* self;
d6de2c148819 Test for xdrmem_create() failure.
Guido van Rossum <guido@python.org>
parents: 4048
diff changeset
92 PyObject* args;
4048
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
93 {
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
94 XDR xdr;
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
95 float value;
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
96 char* string;
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
97 int strlen;
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
98 PyObject* rtn = NULL;
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
99
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
100 if (!PyArg_ParseTuple(args, "s#", &string, &strlen))
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
101 return NULL;
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
102
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
103 if (strlen != 4) {
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
104 PyErr_SetString(PyExc_ValueError, "4 byte string expected");
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
105 return NULL;
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
106 }
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
107
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
108 /* Python guarantees that the string is 4 byte aligned */
4062
d6de2c148819 Test for xdrmem_create() failure.
Guido van Rossum <guido@python.org>
parents: 4048
diff changeset
109 xdr.x_ops = NULL;
4048
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
110 xdrmem_create(&xdr, (caddr_t)string, 4, XDR_DECODE);
4062
d6de2c148819 Test for xdrmem_create() failure.
Guido van Rossum <guido@python.org>
parents: 4048
diff changeset
111 if( xdr.x_ops == NULL )
d6de2c148819 Test for xdrmem_create() failure.
Guido van Rossum <guido@python.org>
parents: 4048
diff changeset
112 PyErr_SetString(xdr_error, "XDR stream initialization failed.");
d6de2c148819 Test for xdrmem_create() failure.
Guido van Rossum <guido@python.org>
parents: 4048
diff changeset
113 else if (xdr_float(&xdr, &value))
4048
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
114 rtn = Py_BuildValue("f", value);
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
115 else
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
116 PyErr_SetString(xdr_error, "conversion to float failed");
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
117
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
118 xdr_destroy(&xdr);
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
119 return rtn;
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
120 }
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
121
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
122
4062
d6de2c148819 Test for xdrmem_create() failure.
Guido van Rossum <guido@python.org>
parents: 4048
diff changeset
123
4048
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
124 static PyObject*
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
125 unpack_double(self, args)
4062
d6de2c148819 Test for xdrmem_create() failure.
Guido van Rossum <guido@python.org>
parents: 4048
diff changeset
126 PyObject* self;
d6de2c148819 Test for xdrmem_create() failure.
Guido van Rossum <guido@python.org>
parents: 4048
diff changeset
127 PyObject* args;
4048
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
128 {
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
129 XDR xdr;
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
130 double value;
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
131 char* string;
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
132 int strlen;
4182
a3926484a658 #include <netconfig.h> seems not needed and is harmful on NeXT, so drop it.
Guido van Rossum <guido@python.org>
parents: 4062
diff changeset
133 PyObject* rtn = NULL;
4048
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
134
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
135 if (!PyArg_ParseTuple(args, "s#", &string, &strlen))
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
136 return NULL;
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
137
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
138 if (strlen != 8) {
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
139 PyErr_SetString(PyExc_ValueError, "8 byte string expected");
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
140 return NULL;
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
141 }
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
142
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
143 /* Python guarantees that the string is 4 byte aligned */
4062
d6de2c148819 Test for xdrmem_create() failure.
Guido van Rossum <guido@python.org>
parents: 4048
diff changeset
144 xdr.x_ops = NULL;
4048
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
145 xdrmem_create(&xdr, (caddr_t)string, 8, XDR_DECODE);
4062
d6de2c148819 Test for xdrmem_create() failure.
Guido van Rossum <guido@python.org>
parents: 4048
diff changeset
146 if( xdr.x_ops == NULL )
d6de2c148819 Test for xdrmem_create() failure.
Guido van Rossum <guido@python.org>
parents: 4048
diff changeset
147 PyErr_SetString(xdr_error, "XDR stream initialization failed.");
d6de2c148819 Test for xdrmem_create() failure.
Guido van Rossum <guido@python.org>
parents: 4048
diff changeset
148 else if (xdr_double(&xdr, &value))
4048
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
149 rtn = Py_BuildValue("d", value);
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
150 else
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
151 PyErr_SetString(xdr_error, "conversion to double failed");
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
152
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
153 xdr_destroy(&xdr);
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
154 return rtn;
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
155 }
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
156
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
157
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
158
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
159 static struct PyMethodDef
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
160 xdr_methods[] = {
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
161 {"pack_float", pack_float, 1},
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
162 {"pack_double", pack_double, 1},
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
163 {"unpack_float", unpack_float, 1},
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
164 {"unpack_double", unpack_double, 1},
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
165 {NULL, NULL, 0} /* sentinel */
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
166 };
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
167
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
168
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
169
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
170 void
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
171 init_xdr()
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
172 {
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
173 PyObject* module;
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
174 PyObject* dict;
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
175
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
176 module = Py_InitModule("_xdr", xdr_methods);
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
177 dict = PyModule_GetDict(module);
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
178
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
179 xdr_error = PyString_FromString("_xdr.error");
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
180 PyDict_SetItemString(dict, "error", xdr_error);
f7b13d4182b3 Added _xdr module
Guido van Rossum <guido@python.org>
parents:
diff changeset
181 }