Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
d62d8bce
Kaydet (Commit)
d62d8bce
authored
Agu 20, 1996
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Test for xdrmem_create() failure.
Minor lay-out changes.
üst
cde317ae
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
15 deletions
+30
-15
_xdrmodule.c
Modules/_xdrmodule.c
+30
-15
No files found.
Modules/_xdrmodule.c
Dosyayı görüntüle @
d62d8bce
...
@@ -10,9 +10,9 @@
...
@@ -10,9 +10,9 @@
*
*
* See xdrlib.py for usage notes.
* See xdrlib.py for usage notes.
*
*
* Note: this has so far, only been tested on Solaris 2.5 and
SGI IRIX 5.3.
* Note: this has so far, only been tested on Solaris 2.5 and
IRIX 5.3. On
*
On these systems, you will need to link with -lnsl for thes
e
*
these systems, you will need to link with -lnsl for these symbols to b
e
*
symbols to be
defined.
* defined.
*/
*/
#include "Python.h"
#include "Python.h"
...
@@ -27,8 +27,8 @@ static PyObject* xdr_error;
...
@@ -27,8 +27,8 @@ static PyObject* xdr_error;
static
PyObject
*
static
PyObject
*
pack_float
(
self
,
args
)
pack_float
(
self
,
args
)
PyObject
*
self
;
PyObject
*
self
;
PyObject
*
args
;
PyObject
*
args
;
{
{
XDR
xdr
;
XDR
xdr
;
float
value
;
float
value
;
...
@@ -41,8 +41,11 @@ pack_float(self, args)
...
@@ -41,8 +41,11 @@ pack_float(self, args)
if
(
!
PyArg_ParseTuple
(
args
,
"f"
,
&
value
))
if
(
!
PyArg_ParseTuple
(
args
,
"f"
,
&
value
))
return
NULL
;
return
NULL
;
xdr
.
x_ops
=
NULL
;
xdrmem_create
(
&
xdr
,
addr
.
buffer
,
4
,
XDR_ENCODE
);
xdrmem_create
(
&
xdr
,
addr
.
buffer
,
4
,
XDR_ENCODE
);
if
(
xdr_float
(
&
xdr
,
&
value
))
if
(
xdr
.
x_ops
==
NULL
)
PyErr_SetString
(
xdr_error
,
"XDR stream initialization failed."
);
else
if
(
xdr_float
(
&
xdr
,
&
value
))
rtn
=
PyString_FromStringAndSize
(
addr
.
buffer
,
4
);
rtn
=
PyString_FromStringAndSize
(
addr
.
buffer
,
4
);
else
else
PyErr_SetString
(
xdr_error
,
"conversion from float failed"
);
PyErr_SetString
(
xdr_error
,
"conversion from float failed"
);
...
@@ -51,10 +54,12 @@ pack_float(self, args)
...
@@ -51,10 +54,12 @@ pack_float(self, args)
return
rtn
;
return
rtn
;
}
}
static
PyObject
*
static
PyObject
*
pack_double
(
self
,
args
)
pack_double
(
self
,
args
)
PyObject
*
self
;
PyObject
*
self
;
PyObject
*
args
;
PyObject
*
args
;
{
{
XDR
xdr
;
XDR
xdr
;
double
value
;
double
value
;
...
@@ -67,8 +72,11 @@ pack_double(self, args)
...
@@ -67,8 +72,11 @@ pack_double(self, args)
if
(
!
PyArg_ParseTuple
(
args
,
"d"
,
&
value
))
if
(
!
PyArg_ParseTuple
(
args
,
"d"
,
&
value
))
return
NULL
;
return
NULL
;
xdr
.
x_ops
=
NULL
;
xdrmem_create
(
&
xdr
,
addr
.
buffer
,
8
,
XDR_ENCODE
);
xdrmem_create
(
&
xdr
,
addr
.
buffer
,
8
,
XDR_ENCODE
);
if
(
xdr_double
(
&
xdr
,
&
value
))
if
(
xdr
.
x_ops
==
NULL
)
PyErr_SetString
(
xdr_error
,
"XDR stream initialization failed."
);
else
if
(
xdr_double
(
&
xdr
,
&
value
))
rtn
=
PyString_FromStringAndSize
(
addr
.
buffer
,
8
);
rtn
=
PyString_FromStringAndSize
(
addr
.
buffer
,
8
);
else
else
PyErr_SetString
(
xdr_error
,
"conversion from double failed"
);
PyErr_SetString
(
xdr_error
,
"conversion from double failed"
);
...
@@ -81,8 +89,8 @@ pack_double(self, args)
...
@@ -81,8 +89,8 @@ pack_double(self, args)
static
PyObject
*
static
PyObject
*
unpack_float
(
self
,
args
)
unpack_float
(
self
,
args
)
PyObject
*
self
;
PyObject
*
self
;
PyObject
*
args
;
PyObject
*
args
;
{
{
XDR
xdr
;
XDR
xdr
;
float
value
;
float
value
;
...
@@ -99,8 +107,11 @@ unpack_float(self, args)
...
@@ -99,8 +107,11 @@ unpack_float(self, args)
}
}
/* Python guarantees that the string is 4 byte aligned */
/* Python guarantees that the string is 4 byte aligned */
xdr
.
x_ops
=
NULL
;
xdrmem_create
(
&
xdr
,
(
caddr_t
)
string
,
4
,
XDR_DECODE
);
xdrmem_create
(
&
xdr
,
(
caddr_t
)
string
,
4
,
XDR_DECODE
);
if
(
xdr_float
(
&
xdr
,
&
value
))
if
(
xdr
.
x_ops
==
NULL
)
PyErr_SetString
(
xdr_error
,
"XDR stream initialization failed."
);
else
if
(
xdr_float
(
&
xdr
,
&
value
))
rtn
=
Py_BuildValue
(
"f"
,
value
);
rtn
=
Py_BuildValue
(
"f"
,
value
);
else
else
PyErr_SetString
(
xdr_error
,
"conversion to float failed"
);
PyErr_SetString
(
xdr_error
,
"conversion to float failed"
);
...
@@ -110,10 +121,11 @@ unpack_float(self, args)
...
@@ -110,10 +121,11 @@ unpack_float(self, args)
}
}
static
PyObject
*
static
PyObject
*
unpack_double
(
self
,
args
)
unpack_double
(
self
,
args
)
PyObject
*
self
;
PyObject
*
self
;
PyObject
*
args
;
PyObject
*
args
;
{
{
XDR
xdr
;
XDR
xdr
;
double
value
;
double
value
;
...
@@ -130,8 +142,11 @@ unpack_double(self, args)
...
@@ -130,8 +142,11 @@ unpack_double(self, args)
}
}
/* Python guarantees that the string is 4 byte aligned */
/* Python guarantees that the string is 4 byte aligned */
xdr
.
x_ops
=
NULL
;
xdrmem_create
(
&
xdr
,
(
caddr_t
)
string
,
8
,
XDR_DECODE
);
xdrmem_create
(
&
xdr
,
(
caddr_t
)
string
,
8
,
XDR_DECODE
);
if
(
xdr_double
(
&
xdr
,
&
value
))
if
(
xdr
.
x_ops
==
NULL
)
PyErr_SetString
(
xdr_error
,
"XDR stream initialization failed."
);
else
if
(
xdr_double
(
&
xdr
,
&
value
))
rtn
=
Py_BuildValue
(
"d"
,
value
);
rtn
=
Py_BuildValue
(
"d"
,
value
);
else
else
PyErr_SetString
(
xdr_error
,
"conversion to double failed"
);
PyErr_SetString
(
xdr_error
,
"conversion to double failed"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment