From 5f68ab2538a6ef3c57c716f753663dc930b9d74b Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 2 Nov 2004 11:06:00 +0000 Subject: r3474: Add conversion functions for the time_t type. (This used to be commit caa563faaa264c41afdb60d64dc9566fcd31518e) --- source4/scripting/swig/dcerpc.i | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'source4/scripting') 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) { -- cgit