|
Panu Matilainen |
1c9fae |
changeset: 6176:c0237c16e2e3
|
|
Panu Matilainen |
1c9fae |
user: Panu Matilainen <pmatilai@redhat.com>
|
|
Panu Matilainen |
1c9fae |
date: Fri Jul 20 10:41:15 2007 +0300
|
|
Panu Matilainen |
1c9fae |
files: python/rpmmodule.c
|
|
Panu Matilainen |
1c9fae |
description:
|
|
Panu Matilainen |
1c9fae |
Add python methods for checking pending signals from rpmsqCaught.
|
|
Panu Matilainen |
1c9fae |
- a thin wrapper for rpmdbCheckSignals() from rpm5.org / Jeff Johnson
|
|
Panu Matilainen |
1c9fae |
- a function taking a list of signals to check and returning list caught
|
|
Panu Matilainen |
1c9fae |
signals (python doesn't know about signal sets so rpmsqCaught needs
|
|
Panu Matilainen |
1c9fae |
wrapping)
|
|
Panu Matilainen |
1c9fae |
|
|
Panu Matilainen |
1c9fae |
|
|
Panu Matilainen |
1c9fae |
diff -r d8e2ec20c948 -r c0237c16e2e3 python/rpmmodule.c
|
|
Panu Matilainen |
1c9fae |
--- a/python/rpmmodule.c Wed Jul 18 16:05:56 2007 +0300
|
|
Panu Matilainen |
1c9fae |
+++ b/python/rpmmodule.c Fri Jul 20 10:41:15 2007 +0300
|
|
Panu Matilainen |
1c9fae |
@@ -7,6 +7,7 @@
|
|
Panu Matilainen |
1c9fae |
#include <rpmio_internal.h>
|
|
Panu Matilainen |
1c9fae |
#include <rpmcli.h> /* XXX for rpmCheckSig */
|
|
Panu Matilainen |
1c9fae |
#include <rpmdb.h>
|
|
Panu Matilainen |
1c9fae |
+#include <rpmsq.h>
|
|
Panu Matilainen |
1c9fae |
|
|
Panu Matilainen |
1c9fae |
#include "legacy.h"
|
|
Panu Matilainen |
1c9fae |
#include "misc.h"
|
|
Panu Matilainen |
1c9fae |
@@ -58,6 +59,50 @@ static PyObject * archScore(PyObject * s
|
|
Panu Matilainen |
1c9fae |
}
|
|
Panu Matilainen |
1c9fae |
|
|
Panu Matilainen |
1c9fae |
/**
|
|
Panu Matilainen |
1c9fae |
+ * */
|
|
Panu Matilainen |
1c9fae |
+static PyObject * signalsCaught(PyObject * self, PyObject * check)
|
|
Panu Matilainen |
1c9fae |
+{
|
|
Panu Matilainen |
1c9fae |
+ PyObject *caught, *o;
|
|
Panu Matilainen |
1c9fae |
+ Py_ssize_t llen;
|
|
Panu Matilainen |
1c9fae |
+ int signum, i;
|
|
Panu Matilainen |
1c9fae |
+ sigset_t newMask, oldMask;
|
|
Panu Matilainen |
1c9fae |
+
|
|
Panu Matilainen |
1c9fae |
+ if (!PyList_Check(check)) {
|
|
Panu Matilainen |
1c9fae |
+ PyErr_SetString(PyExc_TypeError, "list expected");
|
|
Panu Matilainen |
1c9fae |
+ return NULL;
|
|
Panu Matilainen |
1c9fae |
+ }
|
|
Panu Matilainen |
1c9fae |
+
|
|
Panu Matilainen |
1c9fae |
+ llen = PyList_Size(check);
|
|
Panu Matilainen |
1c9fae |
+ caught = PyList_New(0);
|
|
Panu Matilainen |
1c9fae |
+
|
|
Panu Matilainen |
1c9fae |
+ /* block signals while checking for them */
|
|
Panu Matilainen |
1c9fae |
+ (void) sigfillset(&newMask);
|
|
Panu Matilainen |
1c9fae |
+ (void) sigprocmask(SIG_BLOCK, &newMask, &oldMask);
|
|
Panu Matilainen |
1c9fae |
+
|
|
Panu Matilainen |
1c9fae |
+ for (i = 0; i < llen; i++) {
|
|
Panu Matilainen |
1c9fae |
+ o = PyList_GetItem(check, i);
|
|
Panu Matilainen |
1c9fae |
+ signum = PyInt_AsLong(o);
|
|
Panu Matilainen |
1c9fae |
+ if (sigismember(&rpmsqCaught, signum)) {
|
|
Panu Matilainen |
1c9fae |
+ PyList_Append(caught, o);
|
|
Panu Matilainen |
1c9fae |
+ }
|
|
Panu Matilainen |
1c9fae |
+ }
|
|
Panu Matilainen |
1c9fae |
+ (void) sigprocmask(SIG_SETMASK, &oldMask, NULL);
|
|
Panu Matilainen |
1c9fae |
+
|
|
Panu Matilainen |
1c9fae |
+ return caught;
|
|
Panu Matilainen |
1c9fae |
+}
|
|
Panu Matilainen |
1c9fae |
+
|
|
Panu Matilainen |
1c9fae |
+/**
|
|
Panu Matilainen |
1c9fae |
+ * */
|
|
Panu Matilainen |
1c9fae |
+static PyObject * checkSignals(PyObject * self, PyObject * args)
|
|
Panu Matilainen |
1c9fae |
+{
|
|
Panu Matilainen |
1c9fae |
+ if (!PyArg_ParseTuple(args, ":checkSignals")) return NULL;
|
|
Panu Matilainen |
1c9fae |
+ rpmdbCheckSignals();
|
|
Panu Matilainen |
1c9fae |
+ Py_INCREF(Py_None);
|
|
Panu Matilainen |
1c9fae |
+ return Py_None;
|
|
Panu Matilainen |
1c9fae |
+}
|
|
Panu Matilainen |
1c9fae |
+
|
|
Panu Matilainen |
1c9fae |
+
|
|
Panu Matilainen |
1c9fae |
+/**
|
|
Panu Matilainen |
1c9fae |
*/
|
|
Panu Matilainen |
1c9fae |
static PyObject * setLogFile (PyObject * self, PyObject * args, PyObject *kwds)
|
|
Panu Matilainen |
1c9fae |
{
|
|
Panu Matilainen |
1c9fae |
@@ -145,6 +190,11 @@ static PyMethodDef rpmModuleMethods[] =
|
|
Panu Matilainen |
1c9fae |
|
|
Panu Matilainen |
1c9fae |
{ "archscore", (PyCFunction) archScore, METH_VARARGS|METH_KEYWORDS,
|
|
Panu Matilainen |
1c9fae |
NULL },
|
|
Panu Matilainen |
1c9fae |
+
|
|
Panu Matilainen |
1c9fae |
+ { "signalsCaught", (PyCFunction) signalsCaught, METH_O,
|
|
Panu Matilainen |
1c9fae |
+ NULL },
|
|
Panu Matilainen |
1c9fae |
+ { "checkSignals", (PyCFunction) checkSignals, METH_VARARGS,
|
|
Panu Matilainen |
1c9fae |
+ NULL },
|
|
Panu Matilainen |
1c9fae |
|
|
Panu Matilainen |
1c9fae |
{ "headerLoad", (PyCFunction) hdrLoad, METH_VARARGS|METH_KEYWORDS,
|
|
Panu Matilainen |
1c9fae |
NULL },
|
|
Panu Matilainen |
1c9fae |
|