geoff 2003/08/19 12:30:33
Modified: xs/maps apr_functions.map xs/tables/current/Apache FunctionTable.pm t/response/TestAPR table.pm src/modules/perl modperl_apache_compat.c modperl_apache_compat.h Log: add ap_table_compress() to APR::Table Submitted by: geoff Reviewed by: stas Revision Changes Path 1.53 +1 -0 modperl-2.0/xs/maps/apr_functions.map Index: apr_functions.map =================================================================== RCS file: /home/cvs/modperl-2.0/xs/maps/apr_functions.map,v retrieving revision 1.52 retrieving revision 1.53 diff -u -r1.52 -r1.53 --- apr_functions.map 15 Apr 2003 08:39:52 -0000 1.52 +++ apr_functions.map 19 Aug 2003 19:30:33 -0000 1.53 @@ -236,6 +236,7 @@ apr_table_make apr_table_overlap apr_table_overlay | | base, overlay, p + apr_table_compress apr_table_add -apr_table_addn apr_table_do | mpxs_ | ... 1.44 +14 -0 modperl-2.0/xs/tables/current/Apache/FunctionTable.pm Index: FunctionTable.pm =================================================================== RCS file: /home/cvs/modperl-2.0/xs/tables/current/Apache/FunctionTable.pm,v retrieving revision 1.43 retrieving revision 1.44 diff -u -r1.43 -r1.44 --- FunctionTable.pm 15 Apr 2003 03:47:29 -0000 1.43 +++ FunctionTable.pm 19 Aug 2003 19:30:33 -0000 1.44 @@ -12372,6 +12372,20 @@ }, { 'return_type' => 'void', + 'name' => 'apr_table_compress', + 'args' => [ + { + 'type' => 'apr_table_t *', + 'name' => 'a' + }, + { + 'type' => 'unsigned', + 'name' => 'flags' + } + ] + }, + { + 'return_type' => 'void', 'name' => 'apr_table_set', 'args' => [ { 1.6 +33 -1 modperl-2.0/t/response/TestAPR/table.pm Index: table.pm =================================================================== RCS file: /home/cvs/modperl-2.0/t/response/TestAPR/table.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- table.pm 11 Apr 2002 11:08:44 -0000 1.5 +++ table.pm 19 Aug 2003 19:30:33 -0000 1.6 @@ -8,14 +8,20 @@ use APR::Table (); use Apache::Const -compile => 'OK'; +use APR::Const -compile => 'OVERLAP_TABLES_MERGE'; my $filter_count; my $TABLE_SIZE = 20; +use constant HAVE_APACHE_2_0_47 => have_min_apache_version('2.0.47'); + sub handler { my $r = shift; - plan $r, tests => 17; + my $tests = 19; + $tests += 2 if HAVE_APACHE_2_0_47; + + plan $r, tests => $tests; my $table = APR::Table::make($r->pool, $TABLE_SIZE); @@ -96,6 +102,32 @@ my_filter($key, $table->{$key}); } ok $filter_count == $TABLE_SIZE; + } + + # overlay and compress routines + my $base = APR::Table::make($r->pool, $TABLE_SIZE); + my $add = APR::Table::make($r->pool, $TABLE_SIZE); + + $base->set(foo => 'one'); + $base->add(foo => 'two'); + + $add->add(foo => 'three'); + $add->add(bar => 'beer'); + + my $overlay = $base->overlay($add, $r->pool); + + my @foo = $overlay->get('foo'); + my @bar = $overlay->get('bar'); + + ok @foo == 3; + ok $bar[0] eq 'beer'; + + if (HAVE_APACHE_2_0_47) { + $overlay->compress(APR::OVERLAP_TABLES_MERGE); + + # XXX is insertion order guaranteed on all platforms? + ok $overlay->get('foo') =~ m!(\w+, ){2}\w+!; + ok $overlay->get('bar') eq 'beer'; } Apache::OK; 1.2 +17 -3 modperl-2.0/src/modules/perl/modperl_apache_compat.c Index: modperl_apache_compat.c =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_apache_compat.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- modperl_apache_compat.c 24 Apr 2003 01:51:37 -0000 1.1 +++ modperl_apache_compat.c 19 Aug 2003 19:30:33 -0000 1.2 @@ -1,6 +1,6 @@ #include "mod_perl.h" -/* back compat adjustements for older Apache versions (2.0.36+) */ +/* back compat adjustements for older Apache versions */ /* pre-APR_0_9_0 (APACHE_2_0_40) */ #if APR_MAJOR_VERSION == 0 && APR_MINOR_VERSION == 9 && \ @@ -9,14 +9,28 @@ /* added in APACHE_2_0_40/APR_0_9_0 */ apr_status_t apr_socket_timeout_get(apr_socket_t *sock, apr_interval_time_t *t) { - modperl_apr_func_not_implemented(timeout_get, 0.9.0); + modperl_apr_func_not_implemented(apr_sockettimeout_get, 2.0.40, 0.9.0); return APR_ENOTIMPL; } apr_status_t apr_socket_timeout_set(apr_socket_t *sock, apr_interval_time_t t) { - modperl_apr_func_not_implemented(timeout_set, 0.9.0); + modperl_apr_func_not_implemented(apr_socket_timeout_set, 2.0.40, 0.9.0); return APR_ENOTIMPL; } #endif /* pre-APR_0_9_0 (APACHE_2_0_40) */ + +/* pre-APR_0_9_5 (APACHE_2_0_47) + * both 2.0.46 and 2.0.47 shipped with 0.9.4 - + * we need the one that shipped with 2.0.47, + which is major mmn 20020903, minor mmn 4 */ +#if ! AP_MODULE_MAGIC_AT_LEAST(20020903,4) + +/* added in APACHE_2_0_47/APR_0_9_4 */ +void apr_table_compress(apr_table_t *t, unsigned flags) +{ + modperl_apr_func_not_implemented(apr_table_compress, 2.0.47, 0.9.4); +} + +#endif /* pre-APR_0_9_5 (APACHE_2_0_47) */ 1.2 +19 -7 modperl-2.0/src/modules/perl/modperl_apache_compat.h Index: modperl_apache_compat.h =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_apache_compat.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- modperl_apache_compat.h 24 Apr 2003 01:51:37 -0000 1.1 +++ modperl_apache_compat.h 19 Aug 2003 19:30:33 -0000 1.2 @@ -1,7 +1,7 @@ #ifndef MODPERL_APACHE_COMPAT_H #define MODPERL_APACHE_COMPAT_H -/* back compat adjustements for older Apache versions (2.0.36+) */ +/* back compat adjustements for older Apache versions */ #if !APR_HAS_THREADS typedef unsigned long apr_os_thread_t; @@ -29,16 +29,28 @@ #define apr_socket_opt_get apr_getsocketopt #define apr_socket_opt_set apr_setsocketopt -#define modperl_apr_func_not_implemented(func, ver) \ - { \ - dTHX; \ - Perl_croak(aTHX_ #func "() requires APR version " #ver " or higher"); \ - } - /* added in APACHE_2_0_40/APR_0_9_0 */ apr_status_t apr_socket_timeout_get(apr_socket_t *sock, apr_interval_time_t *t); apr_status_t apr_socket_timeout_set(apr_socket_t *sock, apr_interval_time_t t); #endif /* pre-APR_0_9_0 (APACHE_2_0_40) */ + +/* pre-APR_0_9_5 (APACHE_2_0_47) + * both 2.0.46 and 2.0.47 shipped with 0.9.4 - + * we need the one that shipped with 2.0.47, + which is major mmn 20020903, minor mmn 4 */ +#if ! AP_MODULE_MAGIC_AT_LEAST(20020903,4) + +/* added in APACHE_2_0_47/APR_0_9_4 */ +void apr_table_compress(apr_table_t *t, unsigned flags); + +#endif /* pre-APR_0_9_5 (APACHE_2_0_47) */ + +#define modperl_apr_func_not_implemented(func, httpd_ver, apr_ver) \ + { \ + dTHX; \ + Perl_croak(aTHX_ #func "() requires httpd/" #httpd_ver \ + " and apr/" #apr_ver " or higher"); \ + } #endif /* MODPERL_APACHE_COMPAT_H */