In message <[EMAIL PROTECTED]>
          Brian Ingerson <[EMAIL PROTECTED]> wrote:

> On 28/01/03 22:28 +0000, Miah Gregory wrote:

> > 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.

Does the above sound approximately accurate? I'm guessing I should do the
reverse(ish) of your code example below, but I don't know where to find the
list of macros.

> > 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.

Do you have any suggestions as to how I should be allocating memory? AFAIR,
the docs suggest to /not/ use malloc, but I'm not sure what I should be using
in preference.

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

I've looked at /usr/share/perl/5.8.0/ExtUtils/typemap, but this doesn't
appear to contain SvPT. Are these functions/macros defined in the headers
for perl itself?

> Perl SV-s contain a string pointer and a length. So I would use a SV*
> for input and output, and use the 'SvPV' macro to get the pointer and
> length.

>     SV* splitatoffset(SV* string) {
>         char* str_ptr;
>         STRLEN str_len;
>         str_ptr = SvPV(string, str_len);
>         printf("The length of '%s' is %d\n", str_ptr, str_len);
>     }

> I'll let you take it from there.

That's great, thanks! I'll start with that tomorrow.

> > 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.

> BTW, we keep the burner pretty low around here :)

Good to know, I fear I have an awful lot of silly questions. :-)

-- 
Miah Gregory

Reply via email to