static XS(MPXS_Apache__Directive_lookup)
MP_STATIC XS(MPXS_Apache__Directive_lookup)
static XS(MPXS_Apache__Directive_lookup){    dXSARGS;    if (items < 2 || items > 3) {	    Perl_croak(aTHX_                       "Usage: Apache::Directive::lookup(self, key, [args])");    }    mpxs_PPCODE({        Apache__Directive tree;        char *value;        const char *directive;        const char *args;        int args_len;        int directive_len;        char *key = (char *)SvPV_nolen(ST(1));        int scalar_context = (G_SCALAR == GIMME_V);	    if (SvROK(ST(0)) && sv_derived_from(ST(0), "Apache::Directive")) {	        IV tmp = SvIV((SV*)SvRV(ST(0)));	        tree = INT2PTR(Apache__Directive,tmp);	    }	    else {	        tree = ap_conftree;            }	    if (items < 3) {	        value = NULL;            }	    else {	        value = (char *)SvPV_nolen(ST(2));	    }        while (tree) {            directive = tree->directive;            directive_len = strlen(directive);            /* Remove starting '<' for container directives */            if (directive[0] == '<') {                directive++;                directive_len--;            }            if (0 == strncasecmp(directive, key, directive_len)) {                if (value) {                    args = tree->args;                    args_len = strlen(args);                    /* Skip the postfix '>' */                    if ('>' == args[args_len-1]) {                        args_len--;                    }                }                if ( (!value) || (0 == strncasecmp(args, value, args_len)) ) {                    if (tree->first_child) {                        XPUSHs(sv_2mortal(mpxs_Apache__Directive_as_hash(                                              aTHX_ tree->first_child)));                    }                    else {                       XPUSHs(sv_2mortal(newSVpv(tree->args, 0)));                    }                    if (scalar_context) {                        break;                    }                }            }            tree = tree->next ? tree->next : NULL;        }    });}