[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-modules
Subject:    RE: [apache-modules] Getting all the output into an array in a filter
From:       "Tikka, Sami" <Sami.Tikka () F-Secure ! com>
Date:       2004-03-26 9:44:00
Message-ID: 83879A37F8F8E8439B850BD8F9364A660813DA () fsfimail3 ! fi ! f-secure ! com
[Download RAW message or body]

First of all, you have to realize your filter will probably be called
multiple times, i.e. it will not have access to all of its input in one
bucket brigade. This means that if the input brigade does have have an EOS
bucket in the end, this brigade will have to be stowed away somewhere until
you get more input.

Every filter struct has a field called 'ctx' where you can hang your own
data. On the first call, you should create a new brigade and store a pointer
to it into 'f->ctx'. Then just append the input brigade to your storage
brigade. Do this every time your filter is called. When you see the EOS
bucket, you know you won't be getting any more input and can start processing
the data in the storage brigade.

Easy, isn't it. There is just one snag: To append the input brigade to your
storage brigade you should use ap_save_brigade() instead of
APR_BRIGADE_CONCAT(), because your brigade might have had buckets allocated
from stack. Ap_save_brigade will check and fix that for you.

Of course there is the other problem of what to do if your input is very
large... But how you handle that is, I guess, up to you.

-- Sami

>-----Original Message-----
>From: Vacuum Joe [mailto:vacuumjoe@yahoo.com] 
>Sent: Friday, March 26, 2004 3:38 AM
>To: apache-modules@covalent.net
>Subject: [apache-modules] Getting all the output into an array 
>in a filter
>
>
>One more question:
>
>I have a filter which needs to collect together all
>the output from the generator and every filter before
>it into one big array of memory before it can start
>processing any of it.  As a practice filter, I'm
>trying to write a filter which will reverse the bytes
>of the data that go through it.  This means that it
>must store every byte, and then receive the very last
>byte, before it can begin outputting anything.  Not
>ideal from an efficiency perspective, but that's the
>way it goes.
>
>Anyway, it looks like the filter function will get
>called multiple times with different brigades or
>something.  What is the easiest way to collapse all of
>this output data into one big array and then process
>it all in the last step before sending it on?  I can't
>figure this out from reading through the docs.
>
>Thanks
>
>
>__________________________________
>Do you Yahoo!?
>Yahoo! Finance Tax Center - File online. File on time. 
http://taxes.yahoo.com/filing.html

---------------------------------------------------------------------
To unsubscribe, e-mail: apache-modules-unsubscribe@covalent.net
For additional commands, e-mail: apache-modules-help@covalent.net


---------------------------------------------------------------------
To unsubscribe, e-mail: apache-modules-unsubscribe@covalent.net
For additional commands, e-mail: apache-modules-help@covalent.net


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic