Gozer, This looks good to me. It fixes t/api/server_const.t and the test suite now/still passes 100% for me.
Do you want to commit it or should I. Thats a +1 btw. FYI: FreeBSD 6.2-RELEASE gcc 3.4.6 perl 5.8.8 w/o ithreads httpd 2.2.4 ap(r,u) 1.2.8 w/o threads + apr_dbd_mysql and mysql 5.0.33 mod_perl r521590 (aka trunk) including Fred's recent security patch.
Index: src/modules/perl/modperl_apache_compat.c =================================================================== --- src/modules/perl/modperl_apache_compat.c (revision 504721) +++ src/modules/perl/modperl_apache_compat.c (working copy) @@ -27,3 +27,45 @@ * and don't forget to insert comments explaining exactly * which httpd release allows us to remove the compat code */ + +/* pre-APACHE_2.2.4 */ +#if ! AP_MODULE_MAGIC_AT_LEAST(20051115,4) + +#define modperl_warn_fallback_http_function(ver, fallback) \ + { \ + dTHX; \ + Perl_warn(aTHX_ "%s() not available until httpd/%s " \ + "falling back to %s()", \ + __func__, ver, fallback); \ + } + +/* added in APACHE_2.2.4 */ +AP_DECLARE(const char *) ap_get_server_description(void) { + modperl_warn_fallback_http_function("2.2.4", "ap_get_server_version"); + return ap_get_server_version(); +} + +AP_DECLARE(const char *) ap_get_server_banner(void) { + modperl_warn_fallback_http_function("2.2.4", "ap_get_server_version"); + return ap_get_server_version(); +} + +#endif /* pre-APACHE_2.2.4 */ + +/* since-APACHE-2.3.0 */ +#if AP_MODULE_MAGIC_AT_LEAST(20060905,0) +#define modperl_warn_deprecated_http_function(ver, fallback) \ + { \ + dTHX; \ + Perl_warn(aTHX_ "%s() is deprecated since httpd/%s " \ + "try using %s() instead", \ + __func__, ver, fallback); \ + } + +AP_DECLARE(const char *) ap_get_server_version(void) { + modperl_warn_deprecated_http_function("2.3.0", + "ap_get_server_(description|banner)"); + return ap_get_server_banner(); +} + +#endif /* since-APACHE-2.3.0 */ Index: src/modules/perl/modperl_apache_compat.h =================================================================== --- src/modules/perl/modperl_apache_compat.h (revision 504721) +++ src/modules/perl/modperl_apache_compat.h (working copy) @@ -36,6 +36,23 @@ * which httpd release allows us to remove the compat code */ +/* pre-APACHE_2.2.4 */ +#if ! AP_MODULE_MAGIC_AT_LEAST(20051115,4) + +/* added in APACHE_2.2.4 */ +AP_DECLARE(const char *) ap_get_server_description(void); +AP_DECLARE(const char *) ap_get_server_banner(void); + +#endif /* pre-APACHE_2.2.4 */ + +/* since-APACHE-2.3.0 */ +#if AP_MODULE_MAGIC_AT_LEAST(20060905,0) + +/* removed in APACHE-2.3.0 */ +AP_DECLARE(const char *) ap_get_server_version(void); + +#endif /* since-APACHE-2.3.0 */ + /* ap_http_scheme is called ap_http_method in httpd 2.0 */ #ifndef ap_http_scheme #define ap_http_scheme(r) ap_http_method(r) Index: xs/maps/apache2_functions.map =================================================================== --- xs/maps/apache2_functions.map (revision 504721) +++ xs/maps/apache2_functions.map (working copy) @@ -176,6 +176,8 @@ !ap_get_local_host ~ap_get_server_built ~ap_get_server_version +~ap_get_server_banner +~ap_get_server_description ~ap_server_root Index: xs/Apache2/ServerUtil/Apache2__ServerUtil.h =================================================================== --- xs/Apache2/ServerUtil/Apache2__ServerUtil.h (revision 504721) +++ xs/Apache2/ServerUtil/Apache2__ServerUtil.h (working copy) @@ -195,4 +195,10 @@ newCONSTSUB(PL_defstash, "Apache2::ServerUtil::get_server_version", newSVpv(ap_get_server_version(), 0)); + + newCONSTSUB(PL_defstash, "Apache2::ServerUtil::get_server_banner", + newSVpv(ap_get_server_banner(), 0)); + + newCONSTSUB(PL_defstash, "Apache2::ServerUtil::get_server_description", + newSVpv(ap_get_server_description(), 0)); } Index: xs/tables/current/Apache2/FunctionTable.pm =================================================================== --- xs/tables/current/Apache2/FunctionTable.pm (revision 504721) +++ xs/tables/current/Apache2/FunctionTable.pm (working copy) @@ -1476,6 +1476,16 @@ }, { 'return_type' => 'const char *', + 'name' => 'ap_get_server_description', + 'args' => [] + }, + { + 'return_type' => 'const char *', + 'name' => 'ap_get_server_banner', + 'args' => [] + }, + { + 'return_type' => 'const char *', 'name' => 'ap_get_status_line', 'args' => [ { Index: t/response/TestAPI/server_const.pm =================================================================== --- t/response/TestAPI/server_const.pm (revision 504721) +++ t/response/TestAPI/server_const.pm (working copy) @@ -24,7 +24,7 @@ my $r = shift; - plan $r, tests => 3; + plan $r, tests => 5; # test Apache2::ServerUtil constant subroutines @@ -36,10 +36,20 @@ $built, 'Apache2::ServerUtil::get_server_built()'); - ok t_cmp(Apache2::ServerUtil::get_server_version, + ok t_cmp(Apache2::ServerUtil::get_server_description, $version, + 'Apache2::ServerUtil::get_server_description()'); + + my $server_version = Apache2::ServerUtil::get_server_version; + ok t_cmp($version, + qr/^$server_version/, 'Apache2::ServerUtil::get_server_version()'); + my $server_banner = Apache2::ServerUtil::get_server_banner; + ok t_cmp($version, + qr/^$server_banner/, + 'Apache2::ServerUtil::get_server_banner()'); + Apache2::Const::OK; } -------------------------------------------------------------------------------- Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5 http://gozer.ectoplasm.org/ F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5
-- ------------------------------------------------------------------------ Philip M. Gollucci ([EMAIL PROTECTED]) 323.219.4708 Consultant / http://p6m7g8.net/Resume/resume.shtml Senior Software Engineer - TicketMaster - http://ticketmaster.com 1024D/EC88A0BF 0DE5 C55C 6BF3 B235 2DAB B89E 1324 9B4F EC88 A0BF Work like you don't need the money, love like you'll never get hurt, and dance like nobody's watching.