summaryrefslogtreecommitdiff
path: root/journald.c
diff options
context:
space:
mode:
Diffstat (limited to 'journald.c')
-rw-r--r--journald.c52
1 files changed, 0 insertions, 52 deletions
diff --git a/journald.c b/journald.c
deleted file mode 100644
index b106c52..0000000
--- a/journald.c
+++ /dev/null
@@ -1,52 +0,0 @@
-#include <Python.h>
-#include <systemd/sd-journal.h>
-
-static PyObject *
-journald_send(PyObject *self, PyObject *args) {
- struct iovec *iov = NULL;
- int argc = PyTuple_Size(args);
- int i;
-
- // Allocate sufficient iovector space for the arguments.
- iov = malloc(argc * sizeof(struct iovec));
- if (!iov) {
- return PyErr_NoMemory();
- }
-
- // Iterate through the Python arguments and fill the iovector.
- for (i = 0; i < argc; ++i) {
- PyObject *item = PyTuple_GetItem(args, i);
- char * stritem = PyString_AsString(item);
- if (stritem == NULL) {
- // PyString_AsString has already raised TypeError at this
- // point. We can just free iov and return NULL.
- free(iov);
- return NULL;
- }
- iov[i].iov_base = stritem;
- iov[i].iov_len = strlen(stritem);
- }
-
- // Send the iovector to journald.
- sd_journal_sendv(iov, argc);
-
- // Free the iovector. The actual strings
- // are already managed by Python.
- free(iov);
-
- // End with success.
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-static PyMethodDef journaldMethods[] = {
- {"send", journald_send, METH_VARARGS,
- "Send an entry to journald."},
- {NULL, NULL, 0, NULL} /* Sentinel */
-};
-
-PyMODINIT_FUNC
-initjournald(void)
-{
- (void) Py_InitModule("journald", journaldMethods);
-}