summaryrefslogtreecommitdiff
path: root/buffer.cpp
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2008-02-20 00:25:29 +0000
committerChristian Pointner <equinox@anytun.org>2008-02-20 00:25:29 +0000
commit7b75dd9d4afd6030fe1837ea7d2d3fcd225ae785 (patch)
treeeb9375dcfd63e78965d844674577491c1dd1a5e9 /buffer.cpp
parentfurther cleanups (diff)
further cleanups
cipher could work now
Diffstat (limited to 'buffer.cpp')
-rw-r--r--buffer.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/buffer.cpp b/buffer.cpp
index f0d7940..e8191f2 100644
--- a/buffer.cpp
+++ b/buffer.cpp
@@ -30,8 +30,7 @@
#include <stdexcept>
#include <string>
-#include <cstdio>
-#include <iostream>
+#include <sstream>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include "datatypes.h"
@@ -182,18 +181,19 @@ Buffer::operator u_int8_t*() // just for write/read tun
std::string Buffer::getHexDump() const
{
- char text[10];
- std::string ret = "";
-
+ std::stringstream ss;
+ ss << std::hex;
for( u_int32_t index = 0; index < length_; index++ )
{
- std::sprintf(text, "%#4x", buf_[index]);
- ret += text;
- ret += "";
- if( ((index+1) % 10) == 0 )
- ret += '\n';
+ ss << std::setw(2) << std::setfill('0') << static_cast<unsigned int>(buf_[index]) << " ";
+ if(!((index+1) % 16)) {
+ ss << std::endl;
+ continue;
+ }
+ if(!((index+1) % 8))
+ ss << " ";
}
- return ret;
+ return ss.str();
}
Buffer Buffer::operator^(const Buffer &xor_by) const