X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fpython-systemd%2F_reader.c;h=50ad8892015e33ee0d034ce6d0117baad3ee5cfd;hb=5afbe712db5cc68213a24c45396ffb43fab05e3e;hp=14f8a4034762b8b981cab1b1cb425a00e40fc48c;hpb=6a58bf4135faa98f1600672179a2bf364d455f7e;p=elogind.git diff --git a/src/python-systemd/_reader.c b/src/python-systemd/_reader.c index 14f8a4034..50ad88920 100644 --- a/src/python-systemd/_reader.c +++ b/src/python-systemd/_reader.c @@ -30,6 +30,7 @@ #include "pyutil.h" #include "macro.h" #include "util.h" +#include "build.h" typedef struct { PyObject_HEAD @@ -429,7 +430,7 @@ static PyObject* Reader_get_all(Reader *self, PyObject *args) return NULL; SD_JOURNAL_FOREACH_DATA(self->j, msg, msg_len) { - PyObject _cleanup_Py_DECREF_ *key = NULL, *value = NULL; + _cleanup_Py_DECREF_ PyObject *key = NULL, *value = NULL; r = extract(msg, msg_len, &key, &value); if (r < 0) @@ -443,7 +444,7 @@ static PyObject* Reader_get_all(Reader *self, PyObject *args) if (r < 0) goto error; } else { - PyObject _cleanup_Py_DECREF_ *tmp_list = PyList_New(0); + _cleanup_Py_DECREF_ PyObject *tmp_list = PyList_New(0); if (!tmp_list) goto error; @@ -567,7 +568,10 @@ static PyObject* Reader_add_match(Reader *self, PyObject *args, PyObject *keywds PyDoc_STRVAR(Reader_add_disjunction__doc__, "add_disjunction() -> None\n\n" - "Inserts a logical OR between matches added before and afterwards."); + "Inserts a logical OR between matches added since previous\n" + "add_disjunction() or add_conjunction() and the next\n" + "add_disjunction() or add_conjunction().\n\n" + "See man:sd_journal_add_disjunction(3) for explanation."); static PyObject* Reader_add_disjunction(Reader *self, PyObject *args) { int r; @@ -579,6 +583,23 @@ static PyObject* Reader_add_disjunction(Reader *self, PyObject *args) } +PyDoc_STRVAR(Reader_add_conjunction__doc__, + "add_conjunction() -> None\n\n" + "Inserts a logical AND between matches added since previous\n" + "add_disjunction() or add_conjunction() and the next\n" + "add_disjunction() or add_conjunction().\n\n" + "See man:sd_journal_add_disjunction(3) for explanation."); +static PyObject* Reader_add_conjunction(Reader *self, PyObject *args) +{ + int r; + r = sd_journal_add_conjunction(self->j); + set_error(r, NULL, NULL); + if (r < 0) + return NULL; + Py_RETURN_NONE; +} + + PyDoc_STRVAR(Reader_flush_matches__doc__, "flush_matches() -> None\n\n" "Clear all current match filters."); @@ -760,7 +781,7 @@ PyDoc_STRVAR(Reader_get_cursor__doc__, "Wraps sd_journal_get_cursor(). See man:sd_journal_get_cursor(3)."); static PyObject* Reader_get_cursor(Reader *self, PyObject *args) { - char _cleanup_free_ *cursor = NULL; + _cleanup_free_ char *cursor = NULL; int r; assert(self); @@ -846,7 +867,7 @@ PyDoc_STRVAR(Reader_get_catalog__doc__, static PyObject* Reader_get_catalog(Reader *self, PyObject *args) { int r; - char _cleanup_free_ *msg = NULL; + _cleanup_free_ char *msg = NULL; assert(self); assert(!args); @@ -885,7 +906,7 @@ static PyObject* get_catalog(PyObject *self, PyObject *args) int r; char *id_ = NULL; sd_id128_t id; - char _cleanup_free_ *msg = NULL; + _cleanup_free_ char *msg = NULL; assert(!self); assert(args); @@ -980,6 +1001,7 @@ static PyMethodDef Reader_methods[] = { {"_get_monotonic", (PyCFunction) Reader_get_monotonic, METH_NOARGS, Reader_get_monotonic__doc__}, {"add_match", (PyCFunction) Reader_add_match, METH_VARARGS|METH_KEYWORDS, Reader_add_match__doc__}, {"add_disjunction", (PyCFunction) Reader_add_disjunction, METH_NOARGS, Reader_add_disjunction__doc__}, + {"add_conjunction", (PyCFunction) Reader_add_conjunction, METH_NOARGS, Reader_add_conjunction__doc__}, {"flush_matches", (PyCFunction) Reader_flush_matches, METH_NOARGS, Reader_flush_matches__doc__}, {"seek_head", (PyCFunction) Reader_seek_head, METH_NOARGS, Reader_seek_head__doc__}, {"seek_tail", (PyCFunction) Reader_seek_tail, METH_NOARGS, Reader_seek_tail__doc__}, @@ -1105,7 +1127,8 @@ init_reader(void) PyModule_AddIntConstant(m, "INVALIDATE", SD_JOURNAL_INVALIDATE) || PyModule_AddIntConstant(m, "LOCAL_ONLY", SD_JOURNAL_LOCAL_ONLY) || PyModule_AddIntConstant(m, "RUNTIME_ONLY", SD_JOURNAL_RUNTIME_ONLY) || - PyModule_AddIntConstant(m, "SYSTEM_ONLY", SD_JOURNAL_SYSTEM_ONLY)) { + PyModule_AddIntConstant(m, "SYSTEM_ONLY", SD_JOURNAL_SYSTEM_ONLY) || + PyModule_AddStringConstant(m, "__version__", PACKAGE_VERSION)) { #if PY_MAJOR_VERSION >= 3 Py_DECREF(m); return NULL;