On 25/01/07, Jeffrey Walton <[EMAIL PROTECTED]> wrote:
> > I have huge lack of understanding source/filters/sink concept.
> We were all there once (I still am).
:)
> > to parse xml file from crypto filters
> Two separate and distinct operations. It is similar to the
> Unicode/MBCS set stuff in Windows. Though coupled, two separate and
> distinct operations.
I've used boost::iostreams before. Their conception works in other way
and allows to do that I want. Now I'm trying to use crypto... and have
some troubles.
> > int callbackFunc(void *context, const char *buffer, int len)
> Operation one - if this works with your program, it should work with
> Crypto++ objects on the stack. Are you able to save the context
> properly to a file when _not_ using Sources and Sinks?
>
> > FileSource * source = (FileSource *)context;
> > source->Pump(len);
> > return source->Get(buffer, len);
> Try Creating the FileSource on the stack. When the object dtor gets
> called, all filters in the chain are flushed.
Doesn't matter dtor o not dtor... I'll show you how does it works in
boost::streams:
filtering_istream fis;
fis.push(gzip_decompressor());
fis.push(some_decryptor(passphrase));
fis.push(base64_decoder());
fis.push(file_source("a file"));
fis.read(buffer, len)
fis.read(buffer, len)
... there are calls from a callback function
fis.read(buffer, len)
So, you build a chain of filters with source at the end and you can
pull data by reading the stream, you don't need to pump anything from
a source, then you ask the stream for some data, it pulls data from
the 1 filter, it has empty buffers, so it pulls data from the 2 filter
and so on while we reach the source which gives us actual data which
goes in filters' internal buffers.
I tried to call Get method in the same manner as 'read', but it
returns nothing, because nothing has been pumped from the source. I
expecting if BufferedTransformation should go to the beginning of the
chain an call Get from the source if the end of the chain was
requested for some data. But it doesn't happen.
> What you are probably are looking for (forgive me if my presumptions
> are not correct - I make a lot of mistakes ;):
>
> {
> // Place 'Context' in a File
> string s (context, context.length);
> FileSink( new StringSource( s ) );
> }
So, it means I need to make a temporary file, doesn't it?.. Or what do
you mean? context is 'user defined' object, so I can provide it for
xmlReadIO, so that the function will invoke the callback with the same
context value.
> or
>
> {
> // Read a File, send off to the callback...
> // s is created on the heap. Callback function must delete
> // delete s when complete...
> string* s = new string();
> FileSource( filename, new StringSink( *s ) );
>
> CallbackFunction( ..., s, ... );
> }
It puts ALL data into memory directly, libxml2 allows to parse xml
from a memory block, but I trying to avoid it, I want a stream
processing, to keep only constant-size buffers in the memory.
--
WBR, kan.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users"
Google Group.
To unsubscribe, send an email to [EMAIL PROTECTED]
More information about Crypto++ and this group is available at
http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---