From 234c4a2478d06e3e1cdb6701ed761dd8e9a4438c Mon Sep 17 00:00:00 2001 From: "Darryl L. Pierce" Date: Tue, 18 Dec 2012 19:08:59 +0000 Subject: QPID-4416: Perl bindings fail on getContentPtr with null in the content Contributed by Jimmy Jones git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1423582 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/include/qpid/qpid.i | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'cpp/include') diff --git a/cpp/include/qpid/qpid.i b/cpp/include/qpid/qpid.i index 7b3e898082..28a9064ebb 100644 --- a/cpp/include/qpid/qpid.i +++ b/cpp/include/qpid/qpid.i @@ -17,8 +17,33 @@ * under the License. */ +/* + * Need some magic to wrap getContentPtr, otherwise it could return char * + * containing NULL, which would be incorrectly interpreted as end of string + */ +%extend qpid::messaging::Message +{ + mystr getContentPtr() + { + mystr s; + s.ptr = self->getContentPtr(); + s.len = self->getContentSize(); + return s; + } +} +%ignore qpid::messaging::Message::getContentPtr; +%typemap(out,fragment="SWIG_FromCharPtrAndSize") (mystr) { + %append_output(SWIG_FromCharPtrAndSize($1.ptr, $1.len)); +} + %{ +struct mystr +{ + size_t len; + const char *ptr; +}; + #include #include #include -- cgit v1.2.1