CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
making typemaps for unsigned char*


New User

May 20, 2005, 9:12 AM

Post #1 of 1 (865 views)
making typemaps for unsigned char* Can't Post

Hi there!

I am using SWIG in order to wrap some C functions and create a dynamic library (.so) so that I can access these functions with Perl.

Here the kind of prototype of my functions:
void MyFunction(unsigned char *input, unsigned char *output) ;

My functions receive the address of strings which binary (NOT NULL-terminated). (I don't need to know the legth of the strings).

Since SWIG doesn't deal with 'unsigned char * ' without some magic tricks, I used a typemap in order to convert a Perl SV* to an unsigned char* :
%typemap(in) (unsigned char *string1) {<br>
$1 = (unsigned char *)SvPV_nolen($input);<br>
Now I need to do the opposite, it should look like this:
%typemap(argout) unsigned char * {
if (argvi >= items) {
$result = sv_newmortal();
$result = newSVpv($1, 11);

but this didn't work.

Would anyone know how to write this second typemap in order to convert an unsigned char * into a *SV?

Thanks a lot in advance.



Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives