Re: Module initialization

2007-08-02 Thread Farokh Irani

On Aug 1, 2007, at 1:48 PM, Farokh Irani wrote:

I must just be dense, but I've spent a whole bunch of time trying 
to figure exactly how I can put initialization code into my module. 
It's code that needs to run only once when apache (2.2.x) is 
starting up, so any pointers would be appreciated.


oops, incomplete answer:

static int your_routine(apr_pool_t * p_conf, apr_pool_t * p_log, 
apr_pool_t * p_temp);


/* register our interests */
static void hooks(apr_pool_t * p)
{
  ap_hook_pre_config(your_routine, NULL, NULL, APR_HOOK_MIDDLE);
 ...
}

module AP_MODULE_DECLARE_DATA atom_module = {
  STANDARD20_MODULE_STUFF,
  NULL,   /* create per-directory config structure */
  NULL,   /* merge per-directory config structures */
  NULL,   /* create per-server config structure */
  NULL,   /* merge per-server config structures */
  directives, /* handle config directive */
  hooks   /* registrar */
};


OK, thanks for that tidbit. However, as someone else mentioned, if I 
need to do something when apache is restarted, will this do the trick?


Also, when apache is shutting down, can my module do clean up and how 
do I handle that?


Thanks!
--

Farokh

MCF Software...simply dependably engineered
Developers of ListSTAR http://www.liststar.com/, MacRADIUS
http://www.macradius.com/, Address List Sorter
http://www.mcfsoftware.com/als/, SimpleText Filter for EIMS
http://www.mcfsoftware.com/stf/ and Auto Reply plug-in for EIMS 
http://www.mcfsoftware.com/ar/.


Idle time?

2007-08-02 Thread Farokh Irani
Does apache support calling modules at idle time, ie after a time 
interval when there's nothing going on, calling the modules so they 
can get some processing time?


Thanks!
--

Farokh

MCF Software...simply dependably engineered
Developers of ListSTAR http://www.liststar.com/, MacRADIUS
http://www.macradius.com/, Address List Sorter
http://www.mcfsoftware.com/als/, SimpleText Filter for EIMS
http://www.mcfsoftware.com/stf/ and Auto Reply plug-in for EIMS 
http://www.mcfsoftware.com/ar/.


Re: [EMAIL PROTECTED]: Re: Broken APXS]

2007-07-23 Thread Farokh Irani

- Forwarded message from Eric Covener [EMAIL PROTECTED] -

On 7/22/07, Mike [EMAIL PROTECTED] wrote:

 Greetings.

 apxs accepts only *.c files as its input. For other extensions it
 doesn't invoke libtool in compile mode and several different issues
 leading to empty Apache module creation. The most probably reason is
 poor regex design.


This kind of invocation: $ apxs -cia mod_cpp.cpp other.C

Seems to behave better w/ the patch below:

http://people.apache.org/~covener/apxs-cpp.diff


When I tried to use patch with this, one hunk failed (#3) and the 
others appeared to be offset. Does anyone know if this diff file 
applies to the apxs with 2.2.4?


Thanks.
--

Farokh

MCF Software...simply dependably engineered
Developers of ListSTAR http://www.liststar.com/, MacRADIUS
http://www.macradius.com/, Address List Sorter
http://www.mcfsoftware.com/als/, SimpleText Filter for EIMS
http://www.mcfsoftware.com/stf/ and Auto Reply plug-in for EIMS 
http://www.mcfsoftware.com/ar/.


APXS question

2007-07-22 Thread Farokh Irani
I'm trying to set up a makefile using apxs to compile and link a 
module and I'm running into a couple of problems.


If I use the following command line:
apxs -ic -S CC=g++ -n mod_fancy mod_fancy.cpp config.cpp
everything works fine.

In my makefile, I have the following (this is a partial):

mod_fancy.so: mod_fancy.o config.o
  apxs -i -n mod_fancy mod_fancy.o config.o

%.o : %.cpp
  apxs -S CC=g++ -c $

Now, when I try to run make, the compile works fine, but the final 
install doesn't work. Here's what I get:


/usr/local/apache2/bin/apxs -i -n mod_fancy mod_fancy.o config.o
/usr/local/apache2/build/instdso.sh 
SH_LIBTOOL='/usr/local/apache2/build/libtool' mod_fancy.o 
/usr/local/apache2/modules
/usr/local/apache2/build/libtool --mode=install cp mod_fancy.o 
/usr/local/apache2/modules/

cp mod_fancy.o /usr/local/apache2/modules/mod_fancy.o
Warning!  dlname not found in /usr/local/apache2/modules/mod_fancy.o.
Assuming installing a .so rather than a libtool archive.
chmod 755 /usr/local/apache2/modules/mod_fancy.so
/usr/local/apache2/build/instdso.sh 
SH_LIBTOOL='/usr/local/apache2/build/libtool' config.o 
/usr/local/apache2/modules
/usr/local/apache2/build/libtool --mode=install cp config.o 
/usr/local/apache2/modules/

cp config.o /usr/local/apache2/modules/config.o
Warning!  dlname not found in /usr/local/apache2/modules/config.o.
Assuming installing a .so rather than a libtool archive.
chmod 755 /usr/local/apache2/modules/config.so
chmod: /usr/local/apache2/modules/config.so: No such file or directory
apxs:Error: Command failed with rc=65536

I've tried it by using different files (ie .slo and .lo files), but I 
get the same error.


Any ideas? I'd really rather not have apxs recompiling every single 
file each time.


Thanks.
--

Farokh

MCF Software...simply dependably engineered
Developers of ListSTAR http://www.liststar.com/, MacRADIUS
http://www.macradius.com/, Address List Sorter
http://www.mcfsoftware.com/als/, SimpleText Filter for EIMS
http://www.mcfsoftware.com/stf/ and Auto Reply plug-in for EIMS 
http://www.mcfsoftware.com/ar/.


Re: APXS question

2007-07-22 Thread Farokh Irani

On 7/22/07, Farokh Irani [EMAIL PROTECTED] wrote:
/usr/local/apache2/bin/apxs -i -n mod_fancy .libs/mod_fancy.so 
.libs/config.so

/usr/local/apache2/build/instdso.sh
SH_LIBTOOL='/usr/local/apache2/build/libtool' .libs/mod_fancy.so
/usr/local/apache2/modules
/usr/local/apache2/build/libtool --mode=install cp .libs/mod_fancy.so
/usr/local/apache2/modules/
cp .libs/mod_fancy.so /usr/local/apache2/modules/mod_fancy.so
Warning!  dlname not found in /usr/local/apache2/modules/mod_fancy.so.
Assuming installing a .so rather than a libtool archive.
chmod 755 /usr/local/apache2/modules/mod_fancy.so
/usr/local/apache2/build/instdso.sh
SH_LIBTOOL='/usr/local/apache2/build/libtool' .libs/config.so
/usr/local/apache2/modules
/usr/local/apache2/build/libtool --mode=install cp .libs/config.so
/usr/local/apache2/modules/
cp .libs/config.so /usr/local/apache2/modules/config.so
Warning!  dlname not found in /usr/local/apache2/modules/config.so.
Assuming installing a .so rather than a libtool archive.


Was this msg truncated? I didn't see the same error as in the start of
this thread.


Hmm. Well, that's the most recent set of errors :)


It does unfortunately look like you're invoking apxs in such a way as
to install two DSO's, not to link two pieces of object code into a
single DSO.


I tried to use the .la files (as you mentioned in a different message) as in:
apxs -i -n mod_fancy mod_fancy.la config.la

Unfortunately, apxs generated two .so files, mod_fancy.so and 
config.so. It seems that apxs doesn't want to link multiple .la files 
into one .so as it does if I passed it .cpp files.


I think that what I'm going to have to do is to create a single 
library out of everything and then use apxs to install that. Anyone 
have thoughts on that?


Thanks.
--

Farokh

MCF Software...simply dependably engineered
Developers of ListSTAR http://www.liststar.com/, MacRADIUS
http://www.macradius.com/, Address List Sorter
http://www.mcfsoftware.com/als/, SimpleText Filter for EIMS
http://www.mcfsoftware.com/stf/ and Auto Reply plug-in for EIMS 
http://www.mcfsoftware.com/ar/.


Re: APXS troubles

2007-07-21 Thread Farokh Irani

On Fri, Jul 20, 2007 at 11:39:35PM -0400, Farokh Irani wrote:

  I took a further look at apxs, and it appears that the bad coding for the
  source files continues. In my apxs around line 406, you'll find the
  following:

 foreach $s (@srcs) {
  my $slo = $s;
  $slo =~ s|\.c$|.slo|;
  my $lo = $s;
  $lo =~ s|\.c$|.lo|;
  my $la = $s;
  $la =~ s|\.c$|.la|;
  my $o = $s;
  $o =~ s|\.c$|.o|;

  When I replaced the .c in the above with .cpp, everything worked fine using
  .cpp.

Change substitution command separators (s|||) to s///.
Then create regex disjunction (operator |).

$slo =~ s|\.c$|.slo|;

change to

$slo =~ s/\.c$|\.cpp$|\.cc$/.slo/;

and all the rest with the same style.


That does seem to work OK.

Thanks.
--

Farokh

MCF Software...simply dependably engineered
Developers of ListSTAR http://www.liststar.com/, MacRADIUS
http://www.macradius.com/, Address List Sorter
http://www.mcfsoftware.com/als/, SimpleText Filter for EIMS
http://www.mcfsoftware.com/stf/ and Auto Reply plug-in for EIMS 
http://www.mcfsoftware.com/ar/.


Re: APXS issue.

2007-07-21 Thread Farokh Irani

On Wed, 2007-07-18 at 07:23 -0400, Farokh Irani wrote:




 See any operating system documentation about shared libraries for
 more information, such as the ld(1) and ld.so(8) manual pages.
 --
 chmod 755 /usr/local/libexec/apache22/mod_fancy.so


 Not neccessary - shared libs don't need to be executable.


This is also something that is in the apxs code around line 488. Of 
course, the apxs2 on my debian machine does chmod 644.

--

Farokh

MCF Software...simply dependably engineered
Developers of ListSTAR http://www.liststar.com/, MacRADIUS
http://www.macradius.com/, Address List Sorter
http://www.mcfsoftware.com/als/, SimpleText Filter for EIMS
http://www.mcfsoftware.com/stf/ and Auto Reply plug-in for EIMS 
http://www.mcfsoftware.com/ar/.


Re: APXS troubles

2007-07-20 Thread Farokh Irani

On Fri, 2007-07-20 at 08:36 +0200, Mike wrote:

   if ($f =~ m|\.c$|) {   Here, bad coder! BAD!
  I don't know perl at all, so those were
  stabs in the dark. Any pointers on that would be appreciated.
 Try:

  if( $f =~ m/\.c$|\.cpp$|\.cc$/ )


OK, I tried this and while it appears to compile and link, the symbol 
winds up undefined again and nm shows the a similar output as when it 
was linked as an empty library.



I'd go for:

 if ( $f = ~m/\.c(c|pp){0,1}$/i )


This one doesn't compile. When I run apxs, perl complains:
Use of uninitialized value in pattern match (m//) at /usr/bin/apxs2 line 361.

Thanks.
--

Farokh

MCF Software...simply dependably engineered
Developers of ListSTAR http://www.liststar.com/, MacRADIUS
http://www.macradius.com/, Address List Sorter
http://www.mcfsoftware.com/als/, SimpleText Filter for EIMS
http://www.mcfsoftware.com/stf/ and Auto Reply plug-in for EIMS 
http://www.mcfsoftware.com/ar/.


Re: APXS troubles

2007-07-20 Thread Farokh Irani

On Fri, 2007-07-20 at 14:39 +0200, Mike wrote:

 On 7/20/07, Farokh Irani [EMAIL PROTECTED] wrote:
  So, somewhere there is still something going on with .c vs .cpp. I'll
  poke at apxs a bit and see if I can figure out why, but a crash
  course in perl wasn't what I was looking at doing right now :)
 So you mean a change from *.cpp to *.c is the only real working
 solution? That's strange but anyway it works now...


Well - from what I can observe this seems to be a bug in libtool itself
(why did I expect this, given libtools poor C++ support?).
The final link command emitted by apxs seems to be (my reindentation):

/usr/share/apr-1.0/build/libtool --silent --mode=link \  
--tag=disable-static g++ -o mod_fancy.la  \

-rpath /usr/lib/apache2/modules -module -avoid-version \
 config.cpp mod_fancy.cpp

Note that apxs is passing source file names to libtool. This doesn't
seem to work. Passing the '.libs/mod_fancy.o .libs/config.o' seems a
quick fix. I wonder if it's worth the effort.
NOTE: I've sucessfully compiled C++ modules, but 'I somehow always give
my sorce files '*.c' extentions.


I took a further look at apxs, and it appears that the bad coding for 
the source files continues. In my apxs around line 406, you'll find 
the following:


   foreach $s (@srcs) {
my $slo = $s;
$slo =~ s|\.c$|.slo|;
my $lo = $s;
$lo =~ s|\.c$|.lo|;
my $la = $s;
$la =~ s|\.c$|.la|;
my $o = $s;
$o =~ s|\.c$|.o|;

When I replaced the .c in the above with .cpp, everything worked fine 
using .cpp. Now, I'm not sure if the perl from the first fix:


if ( $f =~ m/\.c(c|pp){0,1}$/i ) instead of
if ($f =~ m|\.c$|)

can somehow be used in the above, but I'm sure that someone with perl 
experience should be able to point out how to fix it.

--

Farokh

MCF Software...simply dependably engineered
Developers of ListSTAR http://www.liststar.com/, MacRADIUS
http://www.macradius.com/, Address List Sorter
http://www.mcfsoftware.com/als/, SimpleText Filter for EIMS
http://www.mcfsoftware.com/stf/ and Auto Reply plug-in for EIMS 
http://www.mcfsoftware.com/ar/.


Debian 4 issue

2007-07-15 Thread Farokh Irani
I've set up a Debian 4 machine and I'm trying to compile/install a 
small test module. I'm using APXS2 as follows:


apxs2 -ic -S CC=g++ -n mod_fancy mod_fancy.cpp config.cpp

It compiles, and installs the mod_fancy.so file in /usr/lib/apache2/modules.

But, when I try to get apache to load it, I get an error when apache starts:
apache2: Syntax error on line 185 of /etc/apache2/apache2.conf: Syntax error
  on line 1 of /etc/apache2/mods-enabled/mod_fancy.load: Can't locate API
  module structure `fancy_module' in file
  /usr/lib/apache2/modules/mod_fancy.so:
  /usr/lib/apache2/modules/mod_fancy.so: undefined symbol: fancy_module

Using nm on the .so file, I get the following:
15e8 A __bss_start
03b0 t call_gmon_start
15e8 b completed.5621
14e8 d __CTOR_END__
14e4 d __CTOR_LIST__
 w __cxa_finalize@@GLIBC_2.1.3
0480 t __do_global_ctors_aux
03e0 t __do_global_dtors_aux
15e0 d __dso_handle
14f0 d __DTOR_END__
14ec d __DTOR_LIST__
14f8 a _DYNAMIC
15e8 A _edata
15ec A _end
04c4 T _fini
0440 t frame_dummy
04e0 r __FRAME_END__
15cc a _GLOBAL_OFFSET_TABLE_
 w __gmon_start__
0475 t __i686.get_pc_thunk.bx
0360 T _init
14f4 d __JCR_END__
14f4 d __JCR_LIST__
 w _Jv_RegisterClasses
15e4 d p.5619

Anyone have any ideas why the symbol isn't being exported? I'm using 
gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21).


Thanks.
--

Farokh

MCF Software...simply dependably engineered
Developers of ListSTAR http://www.liststar.com/, MacRADIUS
http://www.macradius.com/, Address List Sorter
http://www.mcfsoftware.com/als/, SimpleText Filter for EIMS
http://www.mcfsoftware.com/stf/ and Auto Reply plug-in for EIMS 
http://www.mcfsoftware.com/ar/.


Re: Possibly OT: g++ 4.0.1 on Mac OS X

2007-07-06 Thread Farokh Irani

On 06/07/07, Farokh Irani [EMAIL PROTECTED] wrote:

I'm trying to link together a couple of .o files into a .so file
using g++. The problem is that even though I have a -o specified, no
file is generated and no error comes up. Any pointers on how to
figure out what might be going on, or even where I could look for
more info, would be appreciated.

This is with g++ 4.0.1 on Mac OS X 10.4.10.


If you are trying to create an Apache module .so, why aren't you using apxs?

You can specify that g++ should be used instead of gcc by saying:

 apxs -S CC=g++ -c mod_example.c

This is much better and more portable than trying to create the .so
yourself. This is more so the case on MacOS X as how you build a
dynamically loadable module is different to options you would use for
other platforms. Also, on MacOS X a dynamically loadable module has to
be created in a different way to a shared library, they are not
interchangeable.


OK, I'm willing to give that a shot, but how do I use apxs to 
compile/link a multi-file source module? IE Right now I've got a 
small module that has 3 files, but I expect the source tree to grow 
to many more (possibly a hundred or more source files).

--

Farokh

MCF Software...simply dependably engineered
Developers of ListSTAR http://www.liststar.com/, MacRADIUS
http://www.macradius.com/, Address List Sorter
http://www.mcfsoftware.com/als/, SimpleText Filter for EIMS
http://www.mcfsoftware.com/stf/ and Auto Reply plug-in for EIMS 
http://www.mcfsoftware.com/ar/.


Re: Just starting module development

2007-03-12 Thread Farokh Irani

Farokh Irani wrote:
I'm trying to convert a plug-in that ran under WebSTAR as well as 
under Microsoft IIS to an Apache 2 module and I was wondering if 
anyone had any pointer or sample code that I should look at to make 
life easier. The WebSTAR code handles multiple threads (I haven't 
looked at the IIS code) so I figured it would be the best place to 
start. So, any pointers to sites or code would be appreciated.


Thanks!

Consider the book :

http://search.barnesandnoble.com/bookSearch/isbnInquiry.asp?r=1ISBN=0132409674

It's written by one of the nerds on this list (sorry Nick - no 
offense intended - I fall into the same category). Also, Nick's 
website : http://apache.webthing.com/ . I had a tutorial that I was 
writing on how to do that. Perhaps if we knew a bit more we could be 
more specific as to which tutorials would be best for you (e.g. if 
you are writing a simple content filter, or a content generator, or 
...).


It's a plugin that needs to scan the content of the page that was 
requested and the make appropriate substitutions before the content 
is sent to the browser. The code is all there and working for 
WebSTAR, using a multiple thread model, and I was hoping to find some 
sample Apache 2.0 code that would allow me to port it over easily. I 
know that's probably pie-in-the-sky, but I figured it wouldn't hurt 
to ask :).

--

Farokh

MCF Software...simply dependably engineered
Developers of ListSTAR http://www.liststar.com/, MacRADIUS
http://www.macradius.com/, Address List Sorter
http://www.mcfsoftware.com/als/, SimpleText Filter for EIMS
http://www.mcfsoftware.com/stf/ and Auto Reply plug-in for EIMS 
http://www.mcfsoftware.com/ar/.


Just starting module development

2007-03-05 Thread Farokh Irani
I'm trying to convert a plug-in that ran under WebSTAR as well as 
under Microsoft IIS to an Apache 2 module and I was wondering if 
anyone had any pointer or sample code that I should look at to make 
life easier. The WebSTAR code handles multiple threads (I haven't 
looked at the IIS code) so I figured it would be the best place to 
start. So, any pointers to sites or code would be appreciated.


Thanks!
--

Farokh

MCF Software...simply dependably engineered
Developers of ListSTAR http://www.liststar.com/, MacRADIUS
http://www.macradius.com/, Address List Sorter
http://www.mcfsoftware.com/als/, SimpleText Filter for EIMS
http://www.mcfsoftware.com/stf/ and Auto Reply plug-in for EIMS 
http://www.mcfsoftware.com/ar/.