On Sun, Jul 31, 2011 at 7:48 AM, Jeffrey Walton <[email protected]> wrote:
> jeffrey$ ./cryptopp-test.exe MaxRetrievable: 6
> Peeked: abcdef
> Peeked: ab
> MaxRetrievable: 6
> jeffrey$
>
> // g++ -g3 -ggdb -O0 cryptopp-test.cpp -o cryptopp-test.exe -lcryptopp
> // g++ -g -O2 cryptopp-test.cpp -o cryptopp-test.exe -lcryptopp
>
> #include <iostream>
> using std::cout;
> using std::endl;
>
> #include <cryptopp/mqueue.h>
> using CryptoPP::MessageQueue;
>
> int main(int, char**)
> {
> byte b1[] = {'a', 'b', 'c', 'd', 'e', 'f'};
> byte b2[16];
>
> MessageQueue queue;
> queue.Put2(b1, sizeof(b1), -1, true);
>
> size_t mr = queue.MaxRetrievable();
> cout << "MaxRetrievable: " << mr << endl;
>
> size_t pk = queue.Peek(b2, sizeof(b2));
> b2[pk] = '\0';
>
> cout << "Peeked: " << (const char*) b2 << endl;
>
> pk = queue.Peek(b2, 2);
> b2[pk] = '\0';
>
> cout << "Peeked: " << (const char*) b2 << endl;
>
> mr = queue.MaxRetrievable();
> cout << "MaxRetrievable: " << mr << endl;
> }
>
Speaks a thousand words !!
Thanks Jeff, a combination of misreading and too many late nights. Thanks a
bunch for this, really helps a lot.
David
--
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.