[conduit/syncml: 113/244] Work around the fact that ctypes hates callbacks returning strings
- From: John Carr <johncarr src gnome org>
- To: svn-commits-list gnome org
- Subject: [conduit/syncml: 113/244] Work around the fact that ctypes hates callbacks returning strings
- Date: Thu, 21 May 2009 05:53:51 -0400 (EDT)
commit 965994210a38d99d9253a78081e401ae0c63541c
Author: John Carr <john carr unrouted co uk>
Date: Wed Apr 29 03:36:02 2009 -0700
Work around the fact that ctypes hates callbacks returning strings
---
conduit/modules/SyncmlModule/SyncmlModule.py | 2 +-
conduit/modules/SyncmlModule/pysyncml.py | 6 +++++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/conduit/modules/SyncmlModule/SyncmlModule.py b/conduit/modules/SyncmlModule/SyncmlModule.py
index 725673b..1a3c71b 100644
--- a/conduit/modules/SyncmlModule/SyncmlModule.py
+++ b/conduit/modules/SyncmlModule/SyncmlModule.py
@@ -146,7 +146,7 @@ class SyncmlDataProvider(DataProvider.TwoWay):
def handle_get_anchor(self, sync_object, name, userdata, err):
anchor = self.anchor[name] if name in self.anchor else None
log.debug("get_anchor('%s') returns %s" % (name, anchor or "None"))
- return anchor
+ return pysyncml.strdup(anchor) if anchor else None
def handle_set_anchor(self, sync_object, name, value, userdata, err):
log.debug("set_anchor('%s', '%s')" % (name, value))
diff --git a/conduit/modules/SyncmlModule/pysyncml.py b/conduit/modules/SyncmlModule/pysyncml.py
index de17618..3514e91 100644
--- a/conduit/modules/SyncmlModule/pysyncml.py
+++ b/conduit/modules/SyncmlModule/pysyncml.py
@@ -1,6 +1,7 @@
from ctypes import *
lib = CDLL('libsyncml.so')
+libc = CDLL('libc.so.6')
def instancemethod(method):
def _(self, *args, **kwargs):
@@ -107,7 +108,7 @@ EventCallback = CFUNCTYPE(None, SyncObject, c_int, c_void_p, Error)
GetAlertTypeCallback = CFUNCTYPE(c_int, SyncObject, c_char_p, c_int, c_void_p, POINTER(Error))
ChangeCallback = CFUNCTYPE(c_int, SyncObject, c_char_p, c_int, c_char_p, c_char_p, c_uint, c_void_p, POINTER(Error))
ChangeStatusCallback = CFUNCTYPE(c_int, SyncObject, c_uint, c_char_p, c_char_p, POINTER(Error))
-GetAnchorCallback = CFUNCTYPE(c_char_p, SyncObject, c_char_p, c_void_p, POINTER(Error))
+GetAnchorCallback = CFUNCTYPE(c_void_p, SyncObject, c_char_p, c_void_p, POINTER(Error))
SetAnchorCallback = CFUNCTYPE(c_int, SyncObject, c_char_p, c_char_p, c_void_p, POINTER(Error))
WriteDevInfCallback = CFUNCTYPE(c_int, SyncObject, Info, c_void_p, POINTER(Error))
ReadDevInfCallback = CFUNCTYPE(Info, SyncObject, c_char_p, c_void_p, POINTER(Error))
@@ -247,3 +248,6 @@ lib.smlErrorPrint.restype = c_char_p
lib.g_thread_init.argtypes = [c_void_p]
lib.g_thread_init.restype = None
+libc.strdup.argtypes = [c_char_p]
+libc.strdup.restype = c_void_p
+strdup = libc.strdup
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]