[nanny] Add glib regex wrapper python module



commit 017190e3364d32130ab9764a2e43d80ba7464a8b
Author: Roberto Majadas <roberto majadas openshine com>
Date:   Fri Jan 29 00:52:14 2010 +0100

    Add glib regex wrapper python module

 daemon/src/Makefile.am    |   11 +++++++++++
 daemon/src/gregexmodule.c |   26 ++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 0 deletions(-)
---
diff --git a/daemon/src/Makefile.am b/daemon/src/Makefile.am
index 6048bf1..e836108 100644
--- a/daemon/src/Makefile.am
+++ b/daemon/src/Makefile.am
@@ -10,3 +10,14 @@ corelib_PYTHON =	 __init__.py 		\
 			LinuxWebContentFiltering.py \
 			LinuxUsersManager.py	\
 			LinuxSessionFiltering.py
+
+
+INCLUDES =      -I$(top_srcdir)                 \
+                $(PYTHON_CFLAGS) $(GLIB_CFLAGS)
+
+pkgpyexec_LTLIBRARIES = gregex.la
+
+gregex_la_SOURCES = gregexmodule.c
+gregex_la_LDFLAGS =  -module -avoid-version -export-symbols-regex initgregex
+gregex_la_LIBADD = $(PYTHON_LIBS) $(GLIB_LIBS)
+
diff --git a/daemon/src/gregexmodule.c b/daemon/src/gregexmodule.c
new file mode 100644
index 0000000..cea6dbb
--- /dev/null
+++ b/daemon/src/gregexmodule.c
@@ -0,0 +1,26 @@
+#include <config.h>
+#include <Python.h>
+#include <glib.h>
+
+static PyObject*
+py_regexp(PyObject* self, PyObject* args){
+        char *exp;
+	char *str;
+
+        PyArg_ParseTuple(args, "ss", &exp, &str);
+        return Py_BuildValue("i", g_regex_match_simple(exp, str, 0, 0));
+}
+
+
+static PyMethodDef gregex_methods[] = {
+        {"regexp", py_regexp, METH_VARARGS},
+        {NULL, NULL}
+};
+
+
+
+DL_EXPORT(void)
+initgregex(void) {
+        (void) Py_InitModule("gregex", gregex_methods);
+}
+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]