stas        2003/01/21 22:12:43

  Modified:    .        Changes
               t/response/TestModperl request_rec_tie_api.pm
               todo     api.txt
               xs/Apache/RequestIO Apache__RequestIO.h
               xs/maps  modperl_functions.map
               xs/tables/current/ModPerl FunctionTable.pm
  Log:
  OPEN and CLOSE tiehandle API + tests
  
  Revision  Changes    Path
  1.108     +1 -1      modperl-2.0/Changes
  
  Index: Changes
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/Changes,v
  retrieving revision 1.107
  retrieving revision 1.108
  diff -u -r1.107 -r1.108
  --- Changes   22 Jan 2003 03:19:43 -0000      1.107
  +++ Changes   22 Jan 2003 06:12:42 -0000      1.108
  @@ -10,7 +10,7 @@
   
   =item 1.99_09-dev
   
  -Add $r->FILENO implementation [Stas]
  +OPEN, CLOSE and FILENO implementation for Apache::RequestRec [Stas]
   
   Apache::Test: Support <NoAutoConfig> </NoAutoConfig> blocks in .pm
   files, so we can have a full manual control over generated config
  
  
  
  1.2       +30 -2     modperl-2.0/t/response/TestModperl/request_rec_tie_api.pm
  
  Index: request_rec_tie_api.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/t/response/TestModperl/request_rec_tie_api.pm,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- request_rec_tie_api.pm    22 Jan 2003 03:19:43 -0000      1.1
  +++ request_rec_tie_api.pm    22 Jan 2003 06:12:43 -0000      1.2
  @@ -7,15 +7,43 @@
   
   use Apache::Test;
   use Apache::TestUtil;
  +use Apache::TestConfig;
  +
  +use File::Spec::Functions qw(catfile catdir);
   
   use Apache::Const -compile => 'OK';
   
   sub handler {
       my $r = shift;
   
  -    plan $r, tests => 1;
  +    plan $r, tests => 3;
  +
  +    ok fileno STDOUT;
  +
  +    {
  +        my $vars = Apache::Test::config()->{vars};
  +        my $target_dir = catdir $vars->{serverroot}, 'logs';
  +        my $file = catfile $target_dir, "stdout";
  +
  +        # test OPEN
  +        my $received = open STDOUT, ">", $file or die "Can't open $file: $!";
  +        ok t_cmp(1, $received, "OPEN");
  +
  +        # test CLOSE, which is a noop
  +        ok $r->CLOSE;
  +        close $file;
  +
  +        # restore the tie
  +        tie *STDOUT, $r;
  +
  +        # flush things that went into the file as STDOUT
  +        open my $fh, $file or die "Can't open $file: $!";
  +        local $\;
  +        print <$fh>;
   
  -    ok t_cmp(fileno(STDOUT), $r->FILENO(), "FILENO");
  +        # cleanup
  +        unlink $file;
  +    }
   
       return Apache::OK;
   }
  
  
  
  1.31      +2 -1      modperl-2.0/todo/api.txt
  
  Index: api.txt
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/todo/api.txt,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- api.txt   22 Jan 2003 03:19:43 -0000      1.30
  +++ api.txt   22 Jan 2003 06:12:43 -0000      1.31
  @@ -3,8 +3,9 @@
   ------------------------------------------
   
   tied filehandle interface:
  - -CLOSE, OPEN, EOF, TELL, SEEK
  + -EOF, TELL, SEEK
    -READLINE - proper implementation (see comment in Apache::compat)
  + need to attempt to fix that interface so it'll work with IPC::Open* family  
   
   $r->finfo:
   need apr_finfo_t <-> struct stat conversion (might already be there,
  
  
  
  1.32      +24 -0     modperl-2.0/xs/Apache/RequestIO/Apache__RequestIO.h
  
  Index: Apache__RequestIO.h
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/xs/Apache/RequestIO/Apache__RequestIO.h,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- Apache__RequestIO.h       22 Jan 2003 03:19:43 -0000      1.31
  +++ Apache__RequestIO.h       22 Jan 2003 06:12:43 -0000      1.32
  @@ -14,6 +14,8 @@
   #define mpxs_Apache__RequestRec_PRINTF mpxs_ap_rprintf
   #define mpxs_Apache__RequestRec_BINMODE(r) \
       r ? SVYES : SVNO /* noop */
  +#define mpxs_Apache__RequestRec_CLOSE(r) \
  +    r ? SVYES : SVNO /* noop */
   
   #define mpxs_Apache__RequestRec_UNTIE(r, refcnt) \
       (r && refcnt) ? SVYES : SVNO /* noop */
  @@ -234,6 +236,28 @@
       }
   
       return &PL_sv_undef;
  +}
  +
  +static MP_INLINE
  +int mpxs_Apache__RequestRec_OPEN(pTHX_ SV *self,  SV *arg1, SV *arg2)
  +{
  +    char *name;
  +    STRLEN len;
  +    SV *arg;
  +    dHANDLE("STDOUT");
  +    
  +    modperl_io_handle_untie(aTHX_ handle); /* untie *STDOUT */
  + 
  +    if (arg2 && self) {
  +        arg = newSVsv(arg1);
  +        sv_catsv(arg, arg2);
  +    }
  +    else {
  +        arg = arg1;
  +    }
  +
  +    name = SvPV(arg, len);
  +    return do_open(handle, name, len, FALSE, O_RDONLY, 0, Nullfp);
   }
   
   static MP_INLINE
  
  
  
  1.50      +2 -0      modperl-2.0/xs/maps/modperl_functions.map
  
  Index: modperl_functions.map
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/xs/maps/modperl_functions.map,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- modperl_functions.map     22 Jan 2003 03:19:43 -0000      1.49
  +++ modperl_functions.map     22 Jan 2003 06:12:43 -0000      1.50
  @@ -38,6 +38,7 @@
    apr_size_t:DEFINE_PRINT  | | ...
    apr_size_t:DEFINE_PRINTF | | ...
    SV *:DEFINE_BINMODE  | | request_rec *:r
  + SV *:DEFINE_CLOSE    | | request_rec *:r
    SV *:DEFINE_UNTIE    | | request_rec *:r, int:refcnt
    mpxs_Apache__RequestRec_sendfile | | r, filename=r->filename, offset=0, len=0
    mpxs_Apache__RequestRec_read | | r, buffer, bufsiz, offset=0
  @@ -47,6 +48,7 @@
    apr_ssize_t:DEFINE_WRITE | | \
                request_rec *:r, SV *:buffer, apr_ssize_t:bufsiz=-1, int:offset=0
    mpxs_Apache__RequestRec_GETC
  + mpxs_Apache__RequestRec_OPEN | | SV *:self, SV *:arg1, SV *:arg2=Nullsv
    mpxs_Apache__RequestRec_FILENO
   
   MODULE=Apache::Response   PACKAGE=Apache::RequestRec
  
  
  
  1.98      +22 -0     modperl-2.0/xs/tables/current/ModPerl/FunctionTable.pm
  
  Index: FunctionTable.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/xs/tables/current/ModPerl/FunctionTable.pm,v
  retrieving revision 1.97
  retrieving revision 1.98
  diff -u -r1.97 -r1.98
  --- FunctionTable.pm  22 Jan 2003 03:19:43 -0000      1.97
  +++ FunctionTable.pm  22 Jan 2003 06:12:43 -0000      1.98
  @@ -5397,6 +5397,28 @@
     },
     {
       'return_type' => 'int',
  +    'name' => 'mpxs_Apache__RequestRec_OPEN',
  +    'args' => [
  +      {
  +        'type' => 'PerlInterpreter *',
  +        'name' => 'my_perl'
  +      },
  +      {
  +        'type' => 'SV *',
  +        'name' => 'self'
  +      },
  +      {
  +        'type' => 'SV *',
  +        'name' => 'arg1'
  +      },
  +      {
  +        'type' => 'SV *',
  +        'name' => 'arg2'
  +      },
  +    ]
  +  },
  +  {
  +    'return_type' => 'int',
       'name' => 'mpxs_Apache__RequestRec_FILENO',
       'args' => [
         {
  
  
  


Reply via email to