diff options
author | Tim Potter <tpot@samba.org> | 2004-11-02 11:06:00 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:05:18 -0500 |
commit | 5f68ab2538a6ef3c57c716f753663dc930b9d74b (patch) | |
tree | 172b673621f041da8a3ef5257854cabd072fd5b9 | |
parent | c4a192553a8e943b2dc7e270a36afeb98e6177f3 (diff) | |
download | samba-5f68ab2538a6ef3c57c716f753663dc930b9d74b.tar.gz samba-5f68ab2538a6ef3c57c716f753663dc930b9d74b.tar.bz2 samba-5f68ab2538a6ef3c57c716f753663dc930b9d74b.zip |
r3474: Add conversion functions for the time_t type.
(This used to be commit caa563faaa264c41afdb60d64dc9566fcd31518e)
-rw-r--r-- | source4/scripting/swig/dcerpc.i | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 6bb30847eb..0a820c0a3c 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -197,6 +197,29 @@ PyObject *NTTIME_to_python(NTTIME obj) return PyLong_FromUnsignedLongLong(obj); } +time_t time_t_from_python(PyObject *obj, char *name) +{ + if (obj == NULL) { + PyErr_Format(PyExc_ValueError, "Expecting key %s", name); + return 0; + } + + if (!PyLong_Check(obj) && !PyInt_Check(obj)) { + PyErr_Format(PyExc_TypeError, "Expecting int or long value for %s", name); + return 0; + } + + if (PyLong_Check(obj)) + return (time_t)PyLong_AsUnsignedLongLong(obj); + else + return (time_t)PyInt_AsUnsignedLongMask(obj); +} + +PyObject *time_t_to_python(time_t obj) +{ + return PyLong_FromUnsignedLongLong(obj); +} + HYPER_T HYPER_T_from_python(PyObject *obj, char *name) { if (obj == NULL) { |