httpd-apreq-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject cvs commit: httpd-apreq-2/glue/perl/xsbuilder/maps apreq_functions.map apreq_structures.map
Date Mon, 14 Jun 2004 02:02:23 GMT
joes        2004/06/13 19:02:23

  Modified:    .        CHANGES
               glue/perl/t/response/TestApReq request.pm
               glue/perl/xsbuilder/Apache/Request Apache__Request.h
                        Request_pm
               glue/perl/xsbuilder/maps apreq_functions.map
                        apreq_structures.map
  Added:       glue/perl/xsbuilder/Apache/Upload Apache__Upload.h Upload_pm
  Log:
  Split Apache::Uppload from Apache::Request for better organization of XS glue.
  
  Revision  Changes    Path
  1.37      +5 -0      httpd-apreq-2/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/CHANGES,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- CHANGES	12 Jun 2004 15:14:38 -0000	1.36
  +++ CHANGES	14 Jun 2004 02:02:23 -0000	1.37
  @@ -3,6 +3,11 @@
   @section v2_04_dev Changes with libapreq2-2.04-dev
   
   
  +- Perl API [joes]
  +  Separate Apache::Upload module from Apache::Request for 
  +  better organization.
  +
  +
   @section v2_03_dev Changes with libapreq2-2.03-dev (released June 12, 2004)
   
   - C API [joes]
  
  
  
  1.9       +2 -1      httpd-apreq-2/glue/perl/t/response/TestApReq/request.pm
  
  Index: request.pm
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/glue/perl/t/response/TestApReq/request.pm,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- request.pm	8 Jun 2004 04:13:36 -0000	1.8
  +++ request.pm	14 Jun 2004 02:02:23 -0000	1.9
  @@ -2,11 +2,12 @@
   
   use strict;
   use warnings FATAL => 'all';
  -use APR;
  +
   use Apache::RequestRec;
   use Apache::RequestIO;
   use Apache::Request ();
   use Apache::Connection;
  +use Apache::Upload;
   
   sub handler {
       my $r = shift;
  
  
  
  1.29      +0 -148    httpd-apreq-2/glue/perl/xsbuilder/Apache/Request/Apache__Request.h
  
  Index: Apache__Request.h
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/glue/perl/xsbuilder/Apache/Request/Apache__Request.h,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- Apache__Request.h	11 Jun 2004 18:51:28 -0000	1.28
  +++ Apache__Request.h	14 Jun 2004 02:02:23 -0000	1.29
  @@ -38,35 +38,16 @@
   #define apreq_xs_args_push(sv,d,k) apreq_xs_push(args,sv,d,k)
   #define apreq_xs_body_push(sv,d,k) apreq_xs_push(body,sv,d,k)
   #define apreq_xs_table_push(sv,d,k) apreq_xs_push(table,sv,d,k)
  -#define apreq_xs_upload_do      (items==1 ? apreq_xs_upload_table_keys  \
  -                                : apreq_xs_upload_table_values)
  -
  -#define apreq_xs_upload_push(sv,d,key) do {                             \
  -    apreq_request_t *req = apreq_xs_sv2(request,sv);                    \
  -    apr_status_t s;                                                     \
  -    do s = apreq_env_read(req->env, APR_BLOCK_READ, READ_BLOCK_SIZE);   \
  -    while (s == APR_INCOMPLETE);                                        \
  -    if (req->body)                                                      \
  -        apr_table_do(apreq_xs_upload_do, d, req->body, key, NULL);      \
  -} while (0)
  -
  -#define apreq_xs_upload_table_push(sv,d,k) apreq_xs_push(upload_table,sv,d,k)
   
   #define apreq_xs_request_sv2table(sv) apreq_params(apreq_env_pool(env), \
                                                      apreq_xs_sv2(request,sv))
   #define apreq_xs_args_sv2table(sv) apreq_xs_sv2(request,sv)->args
   #define apreq_xs_body_sv2table(sv) apreq_xs_sv2(request,sv)->body
   #define apreq_xs_table_sv2table(sv) apreq_xs_sv2table(sv)
  -#define apreq_xs_upload_sv2table(sv) apreq_uploads(apreq_env_pool(env), \
  -                                                   apreq_xs_sv2(request,sv))
  -#define apreq_xs_upload_table_sv2table(sv) apreq_xs_sv2table(sv)
  -
   #define apreq_xs_request_sv2env(sv) apreq_xs_sv2(request,sv)->env
   #define apreq_xs_args_sv2env(sv) apreq_xs_sv2(request,sv)->env
   #define apreq_xs_body_sv2env(sv) apreq_xs_sv2(request,sv)->env
  -#define apreq_xs_upload_sv2env(sv) apreq_xs_sv2(request,sv)->env
   #define apreq_xs_table_sv2env(sv) apreq_xs_sv2env(SvRV(sv))
  -#define apreq_xs_upload_table_sv2env(sv) apreq_xs_sv2env(SvRV(sv))
   
   #define apreq_xs_request_param(sv,k) apreq_param(apreq_xs_sv2(request,sv),k)
   #define apreq_xs_args_param(sv,k) \
  @@ -75,9 +56,6 @@
                        S2P(apr_table_get(apreq_xs_body_sv2table(sv),k))
   #define apreq_xs_table_param(sv,k) \
                        S2P(apr_table_get(apreq_xs_sv2table(sv),k))
  -#define apreq_xs_upload_param(sv,k) apreq_upload(apreq_xs_sv2(request,sv),k)
  -#define apreq_xs_upload_table_param(sv,k) \
  -                     S2P(apr_table_get(apreq_xs_sv2table(sv),k))
   
   #define PARAM_TABLE   "Apache::Request::Table"
   
  @@ -85,132 +63,6 @@
   APREQ_XS_DEFINE_GET(args,    PARAM_TABLE, param, NULL, 1);
   APREQ_XS_DEFINE_GET(body,    PARAM_TABLE, param, NULL, 1);
   APREQ_XS_DEFINE_GET(table,   PARAM_TABLE, param, NULL, 1);
  -
  -/* Upload API */
  -/* supercede earlier function definition */
  -#undef apreq_xs_param2sv
  -#define apreq_xs_param2sv(param,class) apreq_xs_param2rv(param,class)
  -#define apreq_xs_sv2param(sv) apreq_xs_rv2param(sv)
  -
  -static int apreq_xs_upload_table_keys(void *data, const char *key,
  -                                      const char *val)
  -{
  -#ifdef USE_ITHREADS
  -    struct apreq_xs_do_arg *d = (struct apreq_xs_do_arg *)data;
  -    dTHXa(d->perl);
  -#endif
  -
  -    dSP;
  -
  -    if (key) {
  -        if (val && apreq_value_to_param(apreq_strtoval(val))->bb)
  -            XPUSHs(sv_2mortal(newSVpv(key,0)));
  -        else    /* not an upload, so skip it */
  -            return 1;
  -    }
  -    else
  -        XPUSHs(&PL_sv_undef);
  -
  -    PUTBACK;
  -    return 1;
  -
  -}
  -
  -#define UPLOAD_TABLE  "Apache::Upload::Table"
  -#define UPLOAD_PKG    "Apache::Upload"
  -APREQ_XS_DEFINE_GET(upload, UPLOAD_TABLE, param, UPLOAD_PKG, RETVAL->bb);
  -APREQ_XS_DEFINE_GET(upload_table, UPLOAD_TABLE, param, UPLOAD_PKG, 1);
  -
  -
  -APR_INLINE
  -static XS(apreq_xs_upload_link)
  -{
  -    dXSARGS;
  -    MAGIC *mg;
  -    void *env;
  -    const char *name, *fname;
  -    apr_bucket_brigade *bb;
  -    apr_file_t *f;
  -
  -    if (items != 2 || !SvROK(ST(0)))
  -        Perl_croak(aTHX_ "Usage: $upload->link($name)");
  -
  -    if (!(mg = mg_find(SvRV(ST(0)), PERL_MAGIC_ext)))
  -        Perl_croak(aTHX_ "$upload->link($name): can't find env");
  -
  -    env = mg->mg_ptr;
  -    bb = apreq_xs_rv2param(ST(0))->bb;
  -    name = SvPV_nolen(ST(1));
  -
  -    f = apreq_brigade_spoolfile(bb);
  -    if (f == NULL) {
  -        apr_off_t len;
  -        apr_status_t s;
  -
  -        s = apr_file_open(&f, name, APR_CREATE | APR_EXCL | APR_WRITE |
  -                          APR_READ | APR_BINARY | APR_BUFFERED,
  -                          APR_OS_DEFAULT,
  -                          apreq_env_pool(env));
  -        if (s != APR_SUCCESS || 
  -            apreq_brigade_fwrite(f, &len, bb) != APR_SUCCESS)
  -            XSRETURN_UNDEF;
  -    
  -        XSRETURN_YES;
  -    }
  -    if (apr_file_name_get(&fname, f) != APR_SUCCESS)
  -        XSRETURN_UNDEF;
  -
  -    if (PerlLIO_link(fname, name) >= 0)
  -        XSRETURN_YES;
  -    else {
  -        apr_status_t s = apr_file_copy(fname, name,
  -                                       APR_OS_DEFAULT, 
  -                                       apreq_env_pool(env));
  -        if (s == APR_SUCCESS)
  -            XSRETURN_YES;
  -    }
  -
  -    XSRETURN_UNDEF;
  -}
  -
  -
  -static XS(apreq_xs_upload_slurp)
  -{
  -    dXSARGS;
  -    MAGIC *mg;
  -    void *env;
  -    char *data;
  -    apr_off_t len_off;
  -    apr_size_t len_size;
  -    apr_bucket_brigade *bb;
  -    apr_status_t s;
  -
  -    if (items != 2 || !SvROK(ST(0)))
  -        Perl_croak(aTHX_ "Usage: $upload->slurp($data)");
  -
  -    if (!(mg = mg_find(SvRV(ST(0)), PERL_MAGIC_ext)))
  -        Perl_croak(aTHX_ "$upload->slurp($data): can't find env");
  -
  -    env = mg->mg_ptr;
  -    bb = apreq_xs_rv2param(ST(0))->bb;
  -
  -    s = apr_brigade_length(bb, 0, &len_off);
  -    if (s != APR_SUCCESS)
  -        XSRETURN_IV(s);
  -
  -    len_size = len_off; /* max_body setting will be low enough to prevent
  -                         * overflow, but even if it wasn't the code below will
  -                         * at worst truncate the slurp data (not segfault).
  -                         */
  -                         
  -    SvUPGRADE(ST(1), SVt_PV);
  -    data = SvGROW(ST(1), len_size + 1);
  -    data[len_size] = 0;
  -    SvCUR_set(ST(1), len_size);
  -    SvPOK_only(ST(1));
  -    s = apr_brigade_flatten(bb, data, &len_size);
  -    XSRETURN_IV(s);
  -}
   
   static XS(apreq_xs_request_config)
   {
  
  
  
  1.10      +0 -5      httpd-apreq-2/glue/perl/xsbuilder/Apache/Request/Request_pm
  
  Index: Request_pm
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/glue/perl/xsbuilder/Apache/Request/Request_pm,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Request_pm	5 Apr 2004 22:44:30 -0000	1.9
  +++ Request_pm	14 Jun 2004 02:02:23 -0000	1.10
  @@ -1,11 +1,6 @@
  -
  -use APR;
   use APR::Table;
   use APR::Bucket;
   use APR::Brigade;
  -
  -package Apache::Upload::Table;
  -push our(@ISA), 'APR::Table';
   
   package Apache::Request::Table;
   push our(@ISA), 'APR::Table';
  
  
  
  1.1                  httpd-apreq-2/glue/perl/xsbuilder/Apache/Upload/Apache__Upload.h
  
  Index: Apache__Upload.h
  ===================================================================
  /* Upload API */
  #define READ_BLOCK_SIZE (1024 * 256)
  #define S2P(s) (s ? apreq_value_to_param(apreq_strtoval(s)) : NULL)
  #define apreq_xs_upload_do      (items==1 ? apreq_xs_upload_table_keys  \
                                  : apreq_xs_upload_table_values)
  
  #define apreq_xs_upload_push(sv,d,key) do {                             \
      apreq_request_t *req = apreq_xs_sv2(request,sv);                    \
      apr_status_t s;                                                     \
      do s = apreq_env_read(req->env, APR_BLOCK_READ, READ_BLOCK_SIZE);   \
      while (s == APR_INCOMPLETE);                                        \
      if (req->body)                                                      \
          apr_table_do(apreq_xs_upload_do, d, req->body, key, NULL);      \
  } while (0)
  
  #define apreq_xs_upload_table_push(sv,d,k) apreq_xs_push(upload_table,sv,d,k)
  #define apreq_xs_upload_sv2table(sv) apreq_uploads(apreq_env_pool(env), \
                                                     apreq_xs_sv2(request,sv))
  #define apreq_xs_upload_table_sv2table(sv) apreq_xs_sv2table(sv)
  #define apreq_xs_upload_sv2env(sv) apreq_xs_sv2(request,sv)->env
  #define apreq_xs_upload_table_sv2env(sv) apreq_xs_sv2env(SvRV(sv))
  #define apreq_xs_upload_param(sv,k) apreq_upload(apreq_xs_sv2(request,sv),k)
  #define apreq_xs_upload_table_param(sv,k) \
                       S2P(apr_table_get(apreq_xs_sv2table(sv),k))
  
  
  /* uploads are represented by the full apreq_param_t in C */
  #define apreq_upload_t apreq_param_t
  #define apreq_xs_param2sv(ptr,class)  apreq_xs_2sv(ptr,class)
  #define apreq_xs_sv2param(sv) ((apreq_upload_t *)SvIVX(SvRV(sv)))
  
  static int apreq_xs_upload_table_keys(void *data, const char *key,
                                        const char *val)
  {
  #ifdef USE_ITHREADS
      struct apreq_xs_do_arg *d = (struct apreq_xs_do_arg *)data;
      dTHXa(d->perl);
  #endif
  
      dSP;
  
      if (key) {
          if (val && apreq_value_to_param(apreq_strtoval(val))->bb)
              XPUSHs(sv_2mortal(newSVpv(key,0)));
          else    /* not an upload, so skip it */
              return 1;
      }
      else
          XPUSHs(&PL_sv_undef);
  
      PUTBACK;
      return 1;
  
  }
  
  #define UPLOAD_TABLE  "Apache::Upload::Table"
  #define UPLOAD_PKG    "Apache::Upload"
  APREQ_XS_DEFINE_GET(upload, UPLOAD_TABLE, param, UPLOAD_PKG, RETVAL->bb);
  APREQ_XS_DEFINE_GET(upload_table, UPLOAD_TABLE, param, UPLOAD_PKG, 1);
  APREQ_XS_DEFINE_ENV(upload);
  
  APR_INLINE
  static XS(apreq_xs_upload_link)
  {
      dXSARGS;
      MAGIC *mg;
      void *env;
      const char *name, *fname;
      apr_bucket_brigade *bb;
      apr_file_t *f;
  
      if (items != 2 || !SvROK(ST(0)))
          Perl_croak(aTHX_ "Usage: $upload->link($name)");
  
      if (!(mg = mg_find(SvRV(ST(0)), PERL_MAGIC_ext)))
          Perl_croak(aTHX_ "$upload->link($name): can't find env");
  
      env = mg->mg_ptr;
      bb = apreq_xs_sv2param(ST(0))->bb;
      name = SvPV_nolen(ST(1));
  
      f = apreq_brigade_spoolfile(bb);
      if (f == NULL) {
          apr_off_t len;
          apr_status_t s;
  
          s = apr_file_open(&f, name, APR_CREATE | APR_EXCL | APR_WRITE |
                            APR_READ | APR_BINARY | APR_BUFFERED,
                            APR_OS_DEFAULT,
                            apreq_env_pool(env));
          if (s != APR_SUCCESS || 
              apreq_brigade_fwrite(f, &len, bb) != APR_SUCCESS)
              XSRETURN_UNDEF;
      
          XSRETURN_YES;
      }
      if (apr_file_name_get(&fname, f) != APR_SUCCESS)
          XSRETURN_UNDEF;
  
      if (PerlLIO_link(fname, name) >= 0)
          XSRETURN_YES;
      else {
          apr_status_t s = apr_file_copy(fname, name,
                                         APR_OS_DEFAULT, 
                                         apreq_env_pool(env));
          if (s == APR_SUCCESS)
              XSRETURN_YES;
      }
  
      XSRETURN_UNDEF;
  }
  
  
  static XS(apreq_xs_upload_slurp)
  {
      dXSARGS;
      MAGIC *mg;
      void *env;
      char *data;
      apr_off_t len_off;
      apr_size_t len_size;
      apr_bucket_brigade *bb;
      apr_status_t s;
  
      if (items != 2 || !SvROK(ST(0)))
          Perl_croak(aTHX_ "Usage: $upload->slurp($data)");
  
      if (!(mg = mg_find(SvRV(ST(0)), PERL_MAGIC_ext)))
          Perl_croak(aTHX_ "$upload->slurp($data): can't find env");
  
      env = mg->mg_ptr;
      bb = apreq_xs_sv2param(ST(0))->bb;
  
      s = apr_brigade_length(bb, 0, &len_off);
      if (s != APR_SUCCESS)
          XSRETURN_IV(s);
  
      len_size = len_off; /* max_body setting will be low enough to prevent
                           * overflow, but even if it wasn't the code below will
                           * at worst truncate the slurp data (not segfault).
                           */
                           
      SvUPGRADE(ST(1), SVt_PV);
      data = SvGROW(ST(1), len_size + 1);
      data[len_size] = 0;
      SvCUR_set(ST(1), len_size);
      SvPOK_only(ST(1));
      s = apr_brigade_flatten(bb, data, &len_size);
      XSRETURN_IV(s);
  }
  
  
  
  1.1                  httpd-apreq-2/glue/perl/xsbuilder/Apache/Upload/Upload_pm
  
  Index: Upload_pm
  ===================================================================
  use APR::Table;
  use APR::Bucket;
  use APR::Brigade;
  
  package Apache::Upload::Table;
  push our(@ISA), 'APR::Table';
  
  
  
  1.18      +10 -8     httpd-apreq-2/glue/perl/xsbuilder/maps/apreq_functions.map
  
  Index: apreq_functions.map
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/glue/perl/xsbuilder/maps/apreq_functions.map,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- apreq_functions.map	8 Jun 2004 04:13:36 -0000	1.17
  +++ apreq_functions.map	14 Jun 2004 02:02:23 -0000	1.18
  @@ -10,7 +10,6 @@
    DEFINE_env     | apreq_xs_request_env |
    DEFINE_args    | apreq_xs_args_get |
    DEFINE_body    | apreq_xs_body_get |
  - DEFINE_upload  | apreq_xs_upload_get |
    DEFINE_config  | apreq_xs_request_config |
    DEFINE_parse   | apreq_xs_request_parse |
   apr_status_t:DEFINE_status  | apreq_env_read(apreq_xs_sv2(request,sv),APR_BLOCK_READ,0)
| SV *:sv
  @@ -23,18 +22,21 @@
   
   ##########  Apache::Upload:: Functions  ##########
   
  -MODULE=Apache::Request PACKAGE=Apache::Upload PREFIX=Apache__Upload_
  - apr_bucket_brigade *:DEFINE_bb  | apreq_brigade_copy(apreq_xs_rv2param(sv)->bb) | SV
*:sv
  - apr_table_t *:DEFINE_info       | apreq_param_info(apreq_xs_rv2param(sv)) | SV *:sv
  - const char *:DEFINE_name        | apreq_param_name(apreq_xs_rv2param(sv)) | SV *:sv
  - char *:DEFINE_filename          | apreq_param_value(apreq_xs_rv2param(sv)) | SV *:sv
  - apr_status_t:DEFINE_status      | apreq_param_status(apreq_xs_rv2param(sv)) | SV *:sv
  +MODULE=Apache::Upload PACKAGE=Apache::Upload PREFIX=Apache__Upload_
  +! apr_table_t *:DEFINE_info       | apreq_param_info(apreq_xs_sv2param(sv)) | SV *:sv
  + const char *:DEFINE_name        | apreq_param_name(apreq_xs_sv2param(sv)) | SV *:sv
  + char *:DEFINE_filename          | apreq_param_value(apreq_xs_sv2param(sv)) | SV *:sv
  + apr_status_t:DEFINE_status      | apreq_param_status(apreq_xs_sv2param(sv)) | SV *:sv
  + DEFINE_env                      | apreq_xs_upload_env |
    DEFINE_link                     | apreq_xs_upload_link |
    DEFINE_slurp                    | apreq_xs_upload_slurp |
   
  -MODULE=Apache::Request PACKAGE=Apache::Upload::Table PREFIX=Apache__Upload__Table_
  +MODULE=Apache::Upload PACKAGE=Apache::Upload::Table PREFIX=Apache__Upload__Table_
    DEFINE_get     | apreq_xs_upload_table_get |
    DEFINE_FETCH   | apreq_xs_upload_table_get |
  +
  +MODULE=Apache::Upload PACKAGE=Apache::Request PREFIX=Apache__Request_
  + DEFINE_upload  | apreq_xs_upload_get |
   
   
   
  
  
  
  1.7       +4 -4      httpd-apreq-2/glue/perl/xsbuilder/maps/apreq_structures.map
  
  Index: apreq_structures.map
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/glue/perl/xsbuilder/maps/apreq_structures.map,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- apreq_structures.map	24 Mar 2004 08:22:48 -0000	1.6
  +++ apreq_structures.map	14 Jun 2004 02:02:23 -0000	1.7
  @@ -7,11 +7,11 @@
   #   data[1]
   #</apreq_value_t>
   
  -!<apreq_param_t MODULE=Apache::Request>
  -!   info
  -!   bb
  +<apreq_param_t MODULE=Apache::Upload>
  +   info
  +   bb
   !   v
  -!</apreq_param_t>
  +</apreq_param_t>
   
   <apreq_request_t MODULE=Apache::Request>
   !   args
  
  
  

Mime
View raw message