X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Examples%2FDVBAdapter%2FMPEdec.cc;h=f3fe77e08f9647c4f9d867f91930fc9024106ef6;hb=81ffa1c459b96dd44472bcef37e1e373934ee138;hp=48c6b82aa8066e75386679156eabe8742288bee3;hpb=2c4c9deecc7491fbfc916aeb41074dcb76e8a2c2;p=senf.git diff --git a/Examples/DVBAdapter/MPEdec.cc b/Examples/DVBAdapter/MPEdec.cc index 48c6b82..f3fe77e 100644 --- a/Examples/DVBAdapter/MPEdec.cc +++ b/Examples/DVBAdapter/MPEdec.cc @@ -33,6 +33,7 @@ #include "Packets/DefaultBundle/EthernetPacket.hh" #include "Packets/MPEGDVBBundle/DatagramSection.hh" #include "Utils/membind.hh" +#include "Utils/hexdump.hh" #include "Socket/Protocols/DVB/DVBDemuxHandles.hh" #include "Packets/ParseInt.hh" #include "Packets/Packet.hh" @@ -43,48 +44,6 @@ #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// -namespace { - - static const unsigned BLOCK_SIZE = 16; - - template - void hexdump(Iterator i, Iterator const & i_end, std::ostream& stream) - { - unsigned offset (0); - std::string ascii; - for (; i != i_end; ++i, ++offset) { - switch (offset % BLOCK_SIZE) { - case 0: - if (!ascii.empty()) { - stream << " " << ascii << "\n"; - ascii = ""; - } - stream << " " - << std::hex << std::setw(4) << std::setfill('0') - << offset << ' '; - break; - case BLOCK_SIZE/2: - stream << " "; - ascii += ' '; - break; - } - stream << ' ' << std::hex << std::setw(2) << std::setfill('0') - << unsigned(*i); - ascii += (*i >= ' ' && *i < 126) ? *i : '.'; - } - if (!ascii.empty()) { - for (; (offset % BLOCK_SIZE) != 0; ++offset) { - if ((offset % BLOCK_SIZE) == BLOCK_SIZE/2) - stream << " "; - stream << " "; - } - stream << " " << ascii << "\n"; - } - stream << std::dec; - } -} - - class MySniffer { senf::DVBDemuxSectionHandle handle; @@ -113,7 +72,7 @@ private: senf::DatagramSection section (senf::DatagramSection::create(data)); section.dump(std::cout); senf::PacketData & datagramData (section.last().data()); - hexdump(datagramData.begin(), datagramData.end(), std::cout); + senf::hexdump(datagramData.begin(), datagramData.end(), std::cout); } };