diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2007-07-20 10:41:15 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2007-07-20 10:41:15 +0300 |
commit | 17b615eeb63e76bf0ee0f5fe26ff9401892b9265 (patch) | |
tree | f93c8dfb4e22a45f83642c1d12d87b6d06962927 /python/rpmmodule.c | |
parent | 3b3a700984c9f04e6dc5c9905b89d793d6ea5fda (diff) | |
download | librpm-tizen-17b615eeb63e76bf0ee0f5fe26ff9401892b9265.tar.gz librpm-tizen-17b615eeb63e76bf0ee0f5fe26ff9401892b9265.tar.bz2 librpm-tizen-17b615eeb63e76bf0ee0f5fe26ff9401892b9265.zip |
Add python methods for checking pending signals from rpmsqCaught.
- a thin wrapper for rpmdbCheckSignals() from rpm5.org / Jeff Johnson
- a function taking a list of signals to check and returning list caught
signals (python doesn't know about signal sets so rpmsqCaught needs
wrapping)
Diffstat (limited to 'python/rpmmodule.c')
-rw-r--r-- | python/rpmmodule.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/python/rpmmodule.c b/python/rpmmodule.c index 624dc2cf9..85b6db257 100644 --- a/python/rpmmodule.c +++ b/python/rpmmodule.c @@ -7,6 +7,7 @@ #include <rpmio_internal.h> #include <rpmcli.h> /* XXX for rpmCheckSig */ #include <rpmdb.h> +#include <rpmsq.h> #include "legacy.h" #include "misc.h" @@ -58,6 +59,50 @@ static PyObject * archScore(PyObject * self, PyObject * args, PyObject * kwds) } /** + * */ +static PyObject * signalsCaught(PyObject * self, PyObject * check) +{ + PyObject *caught, *o; + Py_ssize_t llen; + int signum, i; + sigset_t newMask, oldMask; + + if (!PyList_Check(check)) { + PyErr_SetString(PyExc_TypeError, "list expected"); + return NULL; + } + + llen = PyList_Size(check); + caught = PyList_New(0); + + /* block signals while checking for them */ + (void) sigfillset(&newMask); + (void) sigprocmask(SIG_BLOCK, &newMask, &oldMask); + + for (i = 0; i < llen; i++) { + o = PyList_GetItem(check, i); + signum = PyInt_AsLong(o); + if (sigismember(&rpmsqCaught, signum)) { + PyList_Append(caught, o); + } + } + (void) sigprocmask(SIG_SETMASK, &oldMask, NULL); + + return caught; +} + +/** + * */ +static PyObject * checkSignals(PyObject * self, PyObject * args) +{ + if (!PyArg_ParseTuple(args, ":checkSignals")) return NULL; + rpmdbCheckSignals(); + Py_INCREF(Py_None); + return Py_None; +} + + +/** */ static PyObject * setLogFile (PyObject * self, PyObject * args, PyObject *kwds) { @@ -146,6 +191,11 @@ static PyMethodDef rpmModuleMethods[] = { { "archscore", (PyCFunction) archScore, METH_VARARGS|METH_KEYWORDS, NULL }, + { "signalsCaught", (PyCFunction) signalsCaught, METH_O, + NULL }, + { "checkSignals", (PyCFunction) checkSignals, METH_VARARGS, + NULL }, + { "headerLoad", (PyCFunction) hdrLoad, METH_VARARGS|METH_KEYWORDS, NULL }, { "mergeHeaderListFromFD", (PyCFunction) rpmMergeHeadersFromFD, METH_VARARGS|METH_KEYWORDS, |