[nanny] Use ctypes instead python module
- From: Roberto Majadas <telemaco src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nanny] Use ctypes instead python module
- Date: Sun, 23 Jan 2011 18:00:15 +0000 (UTC)
commit e91a4983dfb4ea3b49587e0ee87c1307993a252e
Author: Roberto Majadas <roberto majadas openshine com>
Date: Tue Sep 14 12:35:50 2010 +0200
Use ctypes instead python module
daemon/src/FilterManager.py | 13 +++++++++-
daemon/src/Makefile.am | 10 --------
daemon/src/gregexmodule.c | 50 -------------------------------------------
3 files changed, 11 insertions(+), 62 deletions(-)
---
diff --git a/daemon/src/FilterManager.py b/daemon/src/FilterManager.py
index 847f3e8..04f93ac 100644
--- a/daemon/src/FilterManager.py
+++ b/daemon/src/FilterManager.py
@@ -35,11 +35,20 @@ from glob import glob
from twisted.internet import reactor, threads, defer
from twisted.enterprise import adbapi
-import nanny.gregex
from BlockingDeferred import BlockingDeferred
+from ctypes import *
+g = cdll.LoadLibrary("libglib-2.0.so")
+g.g_regex_match_simple.restype=c_int
+g.g_regex_match_simple.argtypes=[c_wchar_p, c_wchar_p, c_int, c_int]
+
+
def regexp(expr, item):
- return bool(nanny.gregex.regexp(expr, item))
+ try:
+ return bool(g.g_regex_match_simple(expr, item, 0, 0))
+ except:
+ print "Regex failure"
+ return False
def on_db_connect(conn):
conn.create_function("gregexp", 2, regexp)
diff --git a/daemon/src/Makefile.am b/daemon/src/Makefile.am
index d576e14..d874fda 100644
--- a/daemon/src/Makefile.am
+++ b/daemon/src/Makefile.am
@@ -19,13 +19,3 @@ dgimporterdir = $(pythondir)/nanny/daemon
dgimporter_PYTHON = DansGuardianImporter.py
endif
-
-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)
-
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]