r3474: Add conversion functions for the time_t type.
authorTim Potter <tpot@samba.org>
Tue, 2 Nov 2004 11:06:00 +0000 (11:06 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:05:18 +0000 (13:05 -0500)
(This used to be commit caa563faaa264c41afdb60d64dc9566fcd31518e)

source4/scripting/swig/dcerpc.i

index 6bb30847ebab624688707cda52981c0d92d64048..0a820c0a3cd81d81a0a8835c88e4c5ea7231c8ed 100644 (file)
@@ -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) {