Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #include "ibrcommon/ssl/InputCipherStream.h"
00009
00010 namespace ibrcommon
00011 {
00012 InputCipherStream::InputCipherStream(std::istream &stream, const CipherMode mode, const size_t buffer)
00013 : std::istream(this), _stream(stream), _mode(mode), data_buf_(new char[buffer]), read_buf_(new char[buffer]), data_size_(buffer)
00014 {
00015
00016 setg(0, 0, 0);
00017 setp(data_buf_, data_buf_ + data_size_ - 1);
00018 }
00019
00020 InputCipherStream::~InputCipherStream()
00021 {
00022 delete[] data_buf_;
00023 }
00024
00025 std::char_traits<char>::int_type InputCipherStream::underflow()
00026 {
00027 _stream.read(data_buf_, data_size_);
00028 int bytes = _stream.gcount();
00029
00030 if (bytes == 0)
00031 {
00032 return std::char_traits<char>::eof();
00033 }
00034
00035
00036
00037 setg(data_buf_, data_buf_, data_buf_ + bytes);
00038
00039 return std::char_traits<char>::not_eof((unsigned char) data_buf_[0]);
00040 }
00041 }