Add debugLevel and set iteration time python binding.
authorMilan Broz <gmazyland@gmail.com>
Sun, 6 Nov 2011 22:44:44 +0000 (22:44 +0000)
committerMilan Broz <gmazyland@gmail.com>
Sun, 6 Nov 2011 22:44:44 +0000 (22:44 +0000)
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@674 36d66b0a-2a48-0410-832c-cd162a569da5

python/pycryptsetup-test.py
python/pycryptsetup.c

index 92ae6ce..1585f9d 100755 (executable)
@@ -33,6 +33,9 @@ c = pycryptsetup.CryptSetup(
         logFunc = log,
         passwordDialog = askpassword)
 
+# c.debugLevel(-1);
+c.debugLevel(0);
+c.iterationTime(1)
 r =  c.isLuks()
 print "isLuks  :", r
 c.askyes(message = "Is there anybody out there?")
index 419454b..2583ebd 100644 (file)
@@ -554,6 +554,38 @@ static PyObject *CryptSetup_Suspend(CryptSetupObject* self, PyObject *args, PyOb
        return PyObjectResult(crypt_suspend(self->device, self->activated_as));
 }
 
+#define CryptSetup_debugLevel_HELP "Set debug level\n\n\
+  debugLevel(level)\n\n\
+  level - debug level"
+
+static PyObject *CryptSetup_debugLevel(CryptSetupObject* self, PyObject *args, PyObject *kwds)
+{
+       static char *kwlist[] = {"level", NULL};
+       int level = 0;
+
+       if (!PyArg_ParseTupleAndKeywords(args, kwds, "i", kwlist, &level))
+               return NULL;
+
+       crypt_set_debug_level(level);
+       return PyObjectResult(0);
+}
+
+#define CryptSetup_iterationTime_HELP "Set iteration time\n\n\
+  iterationTime(time_ms)\n\n\
+  time_ms - time in miliseconds"
+
+static PyObject *CryptSetup_iterationTime(CryptSetupObject* self, PyObject *args, PyObject *kwds)
+{
+       static char *kwlist[] = {"time_ms", NULL};
+       uint64_t time_ms = 0;
+
+       if (!PyArg_ParseTupleAndKeywords(args, kwds, "l", kwlist, &time_ms))
+               return NULL;
+
+       crypt_set_iterarion_time(self->device, time_ms);
+       return PyObjectResult(0);
+}
+
 static PyMemberDef CryptSetup_members[] = {
        {"yesDialogCB", T_OBJECT_EX, offsetof(CryptSetupObject, yesDialogCB), 0, "confirmation dialog callback"},
        {"cmdLineLogCB", T_OBJECT_EX, offsetof(CryptSetupObject, cmdLineLogCB), 0, "logging callback"},
@@ -587,6 +619,10 @@ static PyMethodDef CryptSetup_methods[] = {
        {"resume", (PyCFunction)CryptSetup_Resume, METH_VARARGS|METH_KEYWORDS, CryptSetup_Resume_HELP},
        {"suspend", (PyCFunction)CryptSetup_Suspend, METH_NOARGS, CryptSetup_Suspend_HELP},
 
+       /* misc */
+       {"debugLevel", (PyCFunction)CryptSetup_debugLevel, METH_VARARGS|METH_KEYWORDS, CryptSetup_debugLevel_HELP},
+       {"iterationTime", (PyCFunction)CryptSetup_iterationTime, METH_VARARGS|METH_KEYWORDS, CryptSetup_iterationTime_HELP},
+
        {NULL} /* Sentinel */
 };