perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: $parms->info(), take 2
Date Thu, 29 May 2003 22:59:28 GMT
 > also included is adding the -u flag to part of getdiff.pl.  I know
 > that's not platform independent, but -u was used elsewhere in getdiff.pl
 > and I'm sure you don't want people sending in non-unified diffs :)

+1, but commit it separately. We all have ~/.cvsrc with diff -u so we didn't 
notice that ;)

Geoffrey Young wrote:
> ok, here is an updated patch, with the XS cleaned up a bit.
> 
> the important change between this version and the last is that 
> $parms->info() is now read-only.  I couldn't think of a case where you 
> would want to write to the info slot, and doing so would just cause 
> erroneous results - since directive handlers typically rely on that data 
> to make decisions about how directives are to be handled, changing that 
> value in the middle of the config process would almost certainly be bad.
[..]
> --- /dev/null   Tue May  5 16:32:27 1998
> +++ xs/Apache/CmdParms/Apache__CmdParms.h       Thu May 29 09:47:03 2003
> @@ -0,0 +1,24 @@
> +#include "modperl_module.h"
> +
> +static XS(MPXS_Apache__CmdParms_info)
> +{
> +    dXSARGS;
> +
> +    mpxs_usage_items_1("cmd_parms");
> +
> +    mpxs_PPCODE({
> +        cmd_parms *obj;
> +        const char *data;
> +
> +        obj = mp_xs_sv2_Apache__CmdParms(ST(0));
> +
> +        data = ((modperl_module_cmd_data_t *)obj->info)->cmd_data;
> +
> +        if (data) {
> +            XPUSHs(sv_2mortal(newSVpv(data, 0)));
> +        }
> +        else {
> +            XPUSHs(&PL_sv_undef);
> +        }
> +    });
> +}

All you need is:

SV *mpxs_Apache__CmdParms_info(pTHX_ cmd_params* cmd_parms)
{
    const char *data =
        ((modperl_module_cmd_data_t *)cmd_parms->info)->cmd_data;
    if (data) {
        return newSVpv(data, 0);
    }

    return &PL_sv_undef;
}

or if you want to use "usage":

SV *mpxs_Apache__CmdParms_info(pTHX_ I32 items, SV **MARK, SV **SP)
{
    const char *data;

    mpxs_usage_items_1("cmd_parms");

    if ((data = ((modperl_module_cmd_data_t *)cmd_parms->info)->cmd_data));
        return newSVpv(data, 0);
    }

    return &PL_sv_undef;

}

this is untested, but should give you an idea. of course you need to adjust 
the map file and Functions.pm.

Doesn't it look much simpler?

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message