Apache2-ModXml2
view release on metacpan or search on metacpan
Av_CharPtrPtr.c view on Meta::CPAN
#ifdef __cplusplus
}
#endif
#if defined(_MSC_VER)
#define _CRT_SECURE_NO_DEPRECATE 1
#define _CRT_NONSTDC_NO_DEPRECATE 1
#endif
/* Used by the INPUT typemap for char**.
* Will convert a Perl AV* (containing strings) to a C char**.
*/
char ** XS_unpack_charPtrPtr(SV* rv )
{
AV *av;
SV **ssv;
char **s;
int avlen;
int x;
Av_CharPtrPtr.c view on Meta::CPAN
else
warn("XS_unpack_charPtrPtr: array elem %d was not a string.", x );
}
else
s[x] = (char*)NULL;
}
s[x] = (char*)NULL; /* sentinel */
return( s );
}
/* Used by the OUTPUT typemap for char**.
* Will convert a C char** to a Perl AV*.
*/
void XS_pack_charPtrPtr(SV* st, char **s)
{
AV *av = newAV();
SV *sv;
char **c;
for( c = s; *c != NULL; ++c ){
sv = newSVpv( *c, 0 );
{
int ret;
dSP;
ENTER;
SAVETMPS;
/* arguments */
PUSHMARK(SP);
XPUSHs(sv_2mortal(newSViv(PTR2IV(node))));
PUTBACK;
/* call */
ret = call_pv("XML::LibXML::Devel::refcnt_dec", G_SCALAR );
assert(ret == 1);
/* return value */
SPAGAIN;
/* Check the eval */
/*if (SvTRUE(ERRSV))
{
POPs;
croak("Call to transform function failed: %s", SvPV_nolen(ERRSV));
}*/
ret = POPi;
PUTBACK;
FREETMPS;
LEAVE;
return ret;
}
/**
* Static callback to be used as an XPath callback. The
* perl subroutine is passed as the void * argument.
int ret;
dSP;
ENTER;
SAVETMPS;
/* arguments */
PUSHMARK(SP);
XPUSHs(svNode);
PUTBACK;
/* call */
ret = call_sv(svTransform, G_SCALAR );
assert(ret == 1);
/* return value */
SPAGAIN;
ret = POPi;
PUTBACK;
FREETMPS;
LEAVE;
return ret;
}
/*
* Wrapper needed to give the macro a function pointer.
*/
int ret;
dSP;
ENTER;
SAVETMPS;
/* arguments */
PUSHMARK(SP);
XPUSHs(svR);
XPUSHs(svNode);
PUTBACK;
/* call */
ret = call_pv("Apache2::ModXml2::document_start", G_SCALAR );
assert(ret == 1);
/* return value */
SPAGAIN;
ret = POPi;
PUTBACK;
FREETMPS;
LEAVE;
return APR_SUCCESS;
}
MODULE = Apache2::ModXml2 PACKAGE = Apache2::ModXml2
PROTOTYPES: DISABLE
xml2_wrap_node( a, node, r_log )
APR::BucketAlloc a
void *node
Apache2::RequestRec r_log
APR::Bucket
end_bucket( b )
APR::Bucket b
CODE:
RETVAL = xml2_end_bucket(b);
OUTPUT:
RETVAL
APR::Bucket
make_start_bucket( b )
APR::Bucket b
CODE:
RETVAL = xml2_make_start_bucket(b);
OUTPUT:
RETVAL
int
cmp_bucket( a, b )
APR::Bucket a
APR::Bucket b
CODE:
RETVAL = a - b;
OUTPUT:
RETVAL
##########################################################################
# sxpath functions
# We pass namespaces as char **, since that has a default typemapping
int
xml2_xpath_filter_init( f, pattern, namespaces, transform )
Apache2::Filter f
const char *pattern
RETVAL = xml2_xpath_filter_init(f, pattern, (const char **)namespaces,
call_transform, SvREFCNT_inc(transform));
// We restore the original filter ctx. The stuct used
// by the xml2_xpath_filter_init has reserved space for this.
memcpy(f->ctx, ctx, sizeof(modperl_filter_ctx_t));
// Make shure the compiled pattern is cleaned up
apr_pool_cleanup_register(f->r->pool, transform,
(void *) wrap_SvREFCNT_dec,
apr_pool_cleanup_null);
OUTPUT:
RETVAL
int
xpath_filter( f, bb )
Apache2::Filter f
APR::Brigade bb
CODE:
RETVAL = xml2_xpath_filter(f, bb);
OUTPUT:
RETVAL
##########################################################################
# Helpers for internal use
# The document always exists for mod_xml2 nodes.
# We use it as the owner of all perl nodes.
void *
raw_owner_document( n )
void *n
PREINIT:
xmlNode *node = n;
CODE:
RETVAL = node->doc;
OUTPUT:
RETVAL
# Make typemapping useable for a callback
Apache2::RequestRec
rec_to_perl( r )
void * r
PREINIT:
request_rec *rec = r;
CODE:
RETVAL = rec;
OUTPUT:
RETVAL
PTR2ul|5.007001||p
PTRV|5.006000||p
PUSHMARK|||
PUSH_MULTICALL||5.011000|
PUSHi|||
PUSHmortal|5.009002||p
PUSHn|||
PUSHp|||
PUSHs|||
PUSHu|5.004000||p
PUTBACK|||
PerlIO_clearerr||5.007003|
PerlIO_close||5.007003|
PerlIO_context_layers||5.009004|
PerlIO_eof||5.007003|
PerlIO_error||5.007003|
PerlIO_fileno||5.007003|
PerlIO_fill||5.007003|
PerlIO_flush||5.007003|
PerlIO_get_base||5.007003|
PerlIO_get_bufsiz||5.007003|
{
dSP;
SV* sv = newSVpv(p, 0);
PUSHMARK(sp);
eval_sv(sv, G_SCALAR);
SvREFCNT_dec(sv);
SPAGAIN;
sv = POPs;
PUTBACK;
if (croak_on_error && SvTRUE(GvSV(errgv)))
croak(SvPVx(GvSV(errgv), na));
return sv;
}
#endif
#endif
TYPEMAP
APR::Bucket T_PTROBJ
APR::Brigade T_PTROBJ
APR::BucketAlloc T_PTROBJ
Apache2::RequestRec T_APACHEOBJ
Apache2::Filter T_PTROBJ
OUTPUT
T_APACHEOBJ
sv_setref_pv($arg, \"${ntype}\", (void*)$var);
INPUT
T_APACHEOBJ
$var = modperl_xs_sv2request_rec(aTHX_ $arg, \"$ntype\", cv)
( run in 0.463 second using v1.01-cache-2.11-cpan-c6e0e5ac2a7 )