[subscribed to list]

Hi all,

Firstly, my apologies if this has been covered before, I've had a look
through the archive, but I couldn't find anything relevant.

I'm trying to re-implement a fairly simple perl subroutine in C, and
inline it. Problem is, though, it takes as an argument, a 'string' of
data, and that data may contain NUL's. This means I can't simply use a
char * as the type.

Another problem is how I should return the two results. It would be nice
if I could return them in the same way as the perl subroutine. Looks as if
I need to set the return type as 'void', and use Inline_Stack_*, but
again, how do I pass back a 'string' that contains NUL's. I'm also not
sure about how to allocate the memory for these. I saw newSVpvf mentioned
on the mailing list, but it doesn't appear to take a length.

Where can I find out more about things like newSVpvf and the rest of these
macros/functions?

I'll paste the perl code here, just for reference, so the above might seem
clearer.

sub splitatoffset
{
    my ($data, $length) = @_;
    my ($a, $b);

    return ($data, "") if ($length > length($data));
    $a = substr($data, 0, $length);
    $b = substr($data, $length);

    return ($a, $b);
}

Before I get flamed, I'm not looking for a complete solution (although if
someone does that, I'll be the last to complain), but just enough to get
the perl glue in place and working. The C itself should be simple enough.

Many thanks in advance.

-- 
Miah Gregory

Reply via email to