httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joachim Zobel <jzo...@heute-morgen.de>
Subject Re: splitting a string...
Date Sun, 31 Dec 2006 12:00:10 GMT
Hi.

One recommendation beforehand: If you can live with the memory
footprint, use mod_perl. It gives you full access to the apache API and
it is much easier to handle. 

Am Samstag, den 30.12.2006, 18:55 -0800 schrieb Drew Bertola:
> I'd like to know how I can get the portion of client content before the
> <head> tag (if it exists), and the portion after it.  That way, I can
> insert something just after the <head> tag (adult content warnings, etc).
> 
> I seem to get stuck right after finding the position of the head tag.  I
> can send on the tail end, but don't know how to capture the beginning
> portion:
> 
> 
> ...
>       apr_bucket_read(e, &str, &len, APR_NONBLOCK_READ);
> 
>       if ( ( position = strcasestr(str, search_tag) ) == NULL )
>         {
>           /*
>            * If we didn't find the <head> tag, just pass along
>            * everything to the next filter and we're done.
>            */
>           ap_fputs(f->next, ctx->bb, str);

If str was \0 terminated, you would not need a length. In the above
case, you better move the bucket you just read.

>         }
>       else
>         {
>           /*
>            * so, we have a <head> tag.  So, lets find and process it
>            * and insert our notice.
>            */
> 
>           tail = position + 6;
> 
>           head = ???  <<<<<<<<< Here's where I'm stuck...

You need to punch a \0 into str, the you can use it as head. 
        
You also need to handle the case that <head> is broken into 2 parts in 2
buckets.

Sincerely,
Joachim  



Mime
View raw message