diff options
author | lloyd <[email protected]> | 2009-03-30 18:27:18 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2009-03-30 18:27:18 +0000 |
commit | 96d6eb6f29c55e16a37cf11899547886f735b065 (patch) | |
tree | 9f13901e9b44c98d58b2589c9b09c6a7443eb7cd /src/utils/data_src.cpp | |
parent | 3cc3dd72c5f87b76852a55c1f2d1821dba967d8c (diff) |
Thomas Moschny passed along a request from the Fedora packagers which came
up during the Fedora submission review, that each source file include some
text about the license. One handy Perl script later and each file now has
the line
Distributed under the terms of the Botan license
after the copyright notices.
While I was in there modifying every file anyway, I also stripped out the
remainder of the block comments (lots of astericks before and after the
text); this is stylistic thing I picked up when I was first learning C++
but in retrospect it is not a good style as the structure makes it harder
to modify comments (with the result that comments become fewer, shorter and
are less likely to be updated, which are not good things).
Diffstat (limited to 'src/utils/data_src.cpp')
-rw-r--r-- | src/utils/data_src.cpp | 108 |
1 files changed, 55 insertions, 53 deletions
diff --git a/src/utils/data_src.cpp b/src/utils/data_src.cpp index de5544885..4164a6dd3 100644 --- a/src/utils/data_src.cpp +++ b/src/utils/data_src.cpp @@ -1,8 +1,10 @@ -/************************************************* -* DataSource Source File * -* (C) 1999-2007 Jack Lloyd * -* 2005 Matthew Gregan * -*************************************************/ +/* +* DataSource +* (C) 1999-2007 Jack Lloyd +* 2005 Matthew Gregan +* +* Distributed under the terms of the Botan license +*/ #include <botan/data_src.h> #include <botan/exceptn.h> @@ -12,25 +14,25 @@ namespace Botan { -/************************************************* -* Read a single byte from the DataSource * -*************************************************/ +/* +* Read a single byte from the DataSource +*/ u32bit DataSource::read_byte(byte& out) { return read(&out, 1); } -/************************************************* -* Peek a single byte from the DataSource * -*************************************************/ +/* +* Peek a single byte from the DataSource +*/ u32bit DataSource::peek_byte(byte& out) const { return peek(&out, 1, 0); } -/************************************************* -* Discard the next N bytes of the data * -*************************************************/ +/* +* Discard the next N bytes of the data +*/ u32bit DataSource::discard_next(u32bit n) { u32bit discarded = 0; @@ -40,9 +42,9 @@ u32bit DataSource::discard_next(u32bit n) return discarded; } -/************************************************* -* Read from a memory buffer * -*************************************************/ +/* +* Read from a memory buffer +*/ u32bit DataSource_Memory::read(byte out[], u32bit length) { u32bit got = std::min(source.size() - offset, length); @@ -51,9 +53,9 @@ u32bit DataSource_Memory::read(byte out[], u32bit length) return got; } -/************************************************* -* Peek into a memory buffer * -*************************************************/ +/* +* Peek into a memory buffer +*/ u32bit DataSource_Memory::peek(byte out[], u32bit length, u32bit peek_offset) const { @@ -65,44 +67,44 @@ u32bit DataSource_Memory::peek(byte out[], u32bit length, return got; } -/************************************************* -* Check if the memory buffer is empty * -*************************************************/ +/* +* Check if the memory buffer is empty +*/ bool DataSource_Memory::end_of_data() const { return (offset == source.size()); } -/************************************************* -* DataSource_Memory Constructor * -*************************************************/ +/* +* DataSource_Memory Constructor +*/ DataSource_Memory::DataSource_Memory(const byte in[], u32bit length) { source.set(in, length); offset = 0; } -/************************************************* -* DataSource_Memory Constructor * -*************************************************/ +/* +* DataSource_Memory Constructor +*/ DataSource_Memory::DataSource_Memory(const MemoryRegion<byte>& in) { source = in; offset = 0; } -/************************************************* -* DataSource_Memory Constructor * -*************************************************/ +/* +* DataSource_Memory Constructor +*/ DataSource_Memory::DataSource_Memory(const std::string& in) { source.set(reinterpret_cast<const byte*>(in.data()), in.length()); offset = 0; } -/************************************************* -* Read from a stream * -*************************************************/ +/* +* Read from a stream +*/ u32bit DataSource_Stream::read(byte out[], u32bit length) { source->read(reinterpret_cast<char*>(out), length); @@ -114,9 +116,9 @@ u32bit DataSource_Stream::read(byte out[], u32bit length) return got; } -/************************************************* -* Peek into a stream * -*************************************************/ +/* +* Peek into a stream +*/ u32bit DataSource_Stream::peek(byte out[], u32bit length, u32bit offset) const { if(end_of_data()) @@ -148,25 +150,25 @@ u32bit DataSource_Stream::peek(byte out[], u32bit length, u32bit offset) const return got; } -/************************************************* -* Check if the stream is empty or in error * -*************************************************/ +/* +* Check if the stream is empty or in error +*/ bool DataSource_Stream::end_of_data() const { return (!source->good()); } -/************************************************* -* Return a human-readable ID for this stream * -*************************************************/ +/* +* Return a human-readable ID for this stream +*/ std::string DataSource_Stream::id() const { return identifier; } -/************************************************* -* DataSource_Stream Constructor * -*************************************************/ +/* +* DataSource_Stream Constructor +*/ DataSource_Stream::DataSource_Stream(const std::string& path, bool use_binary) : identifier(path), owner(true) @@ -182,9 +184,9 @@ DataSource_Stream::DataSource_Stream(const std::string& path, total_read = 0; } -/************************************************* -* DataSource_Stream Constructor * -*************************************************/ +/* +* DataSource_Stream Constructor +*/ DataSource_Stream::DataSource_Stream(std::istream& in, const std::string& name) : identifier(name), owner(false) @@ -193,9 +195,9 @@ DataSource_Stream::DataSource_Stream(std::istream& in, total_read = 0; } -/************************************************* -* DataSource_Stream Destructor * -*************************************************/ +/* +* DataSource_Stream Destructor +*/ DataSource_Stream::~DataSource_Stream() { if(owner) |