dougm       01/04/11 21:57:19

  Modified:    t/hooks/TestHooks authen.pm
               xs/Apache/Access Apache__Access.h
               xs/maps  apache_functions.map
  Log:
  implement $r->requires
  
  Revision  Changes    Path
  1.4       +5 -1      modperl-2.0/t/hooks/TestHooks/authen.pm
  
  Index: authen.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/t/hooks/TestHooks/authen.pm,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- authen.pm 2001/04/11 23:05:48     1.3
  +++ authen.pm 2001/04/12 04:57:19     1.4
  @@ -4,7 +4,7 @@
   use warnings FATAL => 'all';
   
   use Apache::Access ();
  -use Apache::Const -compile => qw(OK AUTH_REQUIRED);
  +use Apache::Const -compile => qw(OK AUTH_REQUIRED SERVER_ERROR);
   
   sub handler {
       my $r = shift;
  @@ -14,6 +14,10 @@
       return $rc if $rc != Apache::OK;
   
       my $user = $r->user;
  +
  +    my $requirement = $r->requires->[0]->{requirement};
  +
  +    return Apache::SERVER_ERROR unless $requirement eq 'valid-user';
   
       unless ($user eq 'dougm' and $sent_pw eq 'foo') {
           $r->note_basic_auth_failure;
  
  
  
  1.2       +35 -0     modperl-2.0/xs/Apache/Access/Apache__Access.h
  
  Index: Apache__Access.h
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/xs/Apache/Access/Apache__Access.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Apache__Access.h  2001/04/02 19:30:35     1.1
  +++ Apache__Access.h  2001/04/12 04:57:19     1.2
  @@ -22,3 +22,38 @@
           }
       });
   }
  +
  +static MP_INLINE SV *mpxs_ap_requires(pTHX_ request_rec *r)
  +{
  +    AV *av;
  +    HV *hv;
  +    register int x;
  +    const apr_array_header_t *reqs_arr = ap_requires(r);
  +    require_line *reqs;
  +
  +    if (!reqs_arr) {
  +        return &PL_sv_undef;
  +    }
  +
  +    reqs = (require_line *)reqs_arr->elts;
  +    av = newAV();
  +
  +    for (x=0; x < reqs_arr->nelts; x++) {
  +        /* XXX should we do this or let PerlAuthzHandler? */
  +        if (! (reqs[x].method_mask & (1 << r->method_number))) {
  +            continue;
  +        }
  +
  +        hv = newHV();
  +
  +        hv_store(hv, "method_mask", 11, 
  +                 newSViv((IV)reqs[x].method_mask), 0);
  +
  +        hv_store(hv, "requirement", 11, 
  +                 newSVpv(reqs[x].requirement,0), 0);
  +
  +        av_push(av, newRV_noinc((SV*)hv));
  +    }
  +
  +    return newRV_noinc((SV*)av); 
  +}
  
  
  
  1.11      +1 -1      modperl-2.0/xs/maps/apache_functions.map
  
  Index: apache_functions.map
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/xs/maps/apache_functions.map,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- apache_functions.map      2001/04/10 04:01:15     1.10
  +++ apache_functions.map      2001/04/12 04:57:19     1.11
  @@ -106,7 +106,7 @@
    ap_allow_options
    ap_allow_overrides
    ap_get_remote_logname
  -!ap_requires
  + SV *:ap_requires | mpxs_
    ap_satisfies
   
   #MODULE=Apache::Auth
  
  
  

Reply via email to