On Wed, 21 Mar 2001, Gordon Lo wrote:

> Hey,
> I am writing a Perl interface to an existing C API. I
> would like to do something like this in a Perl
> handler:
> 
> # Handler
> sub handler {
>   my $r = shift;
>   .
>   .
>   my $rv = my_func($r, $some_other_args);
>   .
>   .
> }
> 
> where the corresponding C function looks like:
> 
> int my_func(request_rec *r, char *args) {
>   int n;
> .
> .
>   return n
> }
> 
> The question is: How do I access request_rec * out of
> an Apache::Request object($r) in XS/typemap/whatever??

In your typemap file:

TYPEMAP
Apache          T_APACHEOBJ

OUTPUT
T_APACHEOBJ
        sv_setref_pv($arg, \"${ntype}\", (void*)$var);

INPUT
T_APACHEOBJ
        r = sv2request_rec($arg, \"$ntype\", cv)

Then in your XS file, the sub looks like:

int
my_func (r, other)
        Apache r
        char * other
   CODE:
      RETVAL = ....
   OUTPUT:
      RETVAL

-- 
<Matt/>

    /||    ** Founder and CTO  **  **   http://axkit.com/     **
   //||    **  AxKit.com Ltd   **  ** XML Application Serving **
  // ||    ** http://axkit.org **  ** XSLT, XPathScript, XSP  **
 // \\| // ** mod_perl news and resources: http://take23.org  **
     \\//
     //\\
    //  \\

Reply via email to