You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Geoffrey Young <gy...@laserlink.net> on 2001/06/19 13:44:02 UTC

Apache::Util stuff

hi all...

  sorry about always talking about the mundane 1.3 stuff, but...

  based on this comment by Doug:
http://marc.theaimsgroup.com/?l=apache-modperl&m=94148186408430&w=2

I was able to come up with the below module that allows you to use
Apache::Util outside of Apache.

So, my questions are:
  will the ap/apr split make this type of thing unnecessary in 2.0?

then (if you have the tuits)
  is this approach reasonable?
  not being too familiar with shared objects, does it make sense that
  some of the functions core dump - it seems to be any that call ap_palloc

thanks

--Geoff

package ExportUtil;

use DynaLoader;
use Exporter;

use strict;

our @ISA = qw(Exporter);

our @EXPORT_OK = qw(unescape_uri unescape_uri_info escape_html
                    validate_password size_string);

# these dump core
our @EXPORT_NOT_OK = qw(escape_uri ht_time parsedate);

# load the shared object file
my $libref =
DynaLoader::dl_load_file("/usr/local/apache/libexec/libhttpd.so");

# find the symbol table
my $symref = DynaLoader::dl_find_symbol($libref, "boot_Apache__Util");

# install the code reference to Apache::Util::bootstrap
my $coderef = DynaLoader::dl_install_xsub("Apache::Util::bootstrap", 
                                          $symref);

# call Apache::Util::bootstrap
&{$coderef};

# now do the same for the Apache class to get at
# unescape_uri and unescape_url
$symref = DynaLoader::dl_find_symbol($libref, "boot_Apache");

# install the code reference to Apache::bootstrap
$coderef = DynaLoader::dl_install_xsub("Apache::bootstrap", 
                                       $symref);

# call Apache::bootstrap
&{$coderef};

# now we can use our class
use  Apache::Util qw(unescape_uri unescape_uri_info escape_html
                     validate_password size_string);

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: Apache::Util stuff

Posted by Doug MacEachern <do...@covalent.net>.
On Tue, 19 Jun 2001, Geoffrey Young wrote:
 
> I was able to come up with the below module that allows you to use
> Apache::Util outside of Apache.

cool.
 
> So, my questions are:
>   will the ap/apr split make this type of thing unnecessary in 2.0?

we still need something to load the apr libraries outside of httpd, which
is done by xs/APR/APR/*.*

> then (if you have the tuits)
>   is this approach reasonable?
>   not being too familiar with shared objects, does it make sense that
>   some of the functions core dump - it seems to be any that call ap_palloc

you should be able to create an Apache::libhttpd module along the lines of
the xs/APR/APR stuff.  then rather than call the bootstrap yourself, just
set $ENV{MOD_PERL} in libhttpd.pm and 'use Apache::Util ()' should work. 
and will probably need to dig around http_main.c:standalone_main() to see
what things need to be initialized, like for using pools.



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org