From: tho Date: Thu, 2 Aug 2007 16:07:30 +0000 (+0000) Subject: bugfix in hexdump() X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=3f9475f73d6c84083101c4bdb04800e46b7738c5;p=senf.git bugfix in hexdump() git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@374 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Examples/DVBAdapter/ULEdec.cc b/Examples/DVBAdapter/ULEdec.cc index ea19430..1867d19 100644 --- a/Examples/DVBAdapter/ULEdec.cc +++ b/Examples/DVBAdapter/ULEdec.cc @@ -115,7 +115,7 @@ void ULEdec::handleTSPacket(senf::TransportPacket ts_packet) return; default: if ( (*payload_start++ | *payload_start++) != ULE_END_INDICATOR ) - std::cerr << "delimiting error\n"; + std::cerr << "delimiting error 1\n"; } else { BOOST_ASSERT( std::distance( payload_start, payload_end ) == 0 ); } @@ -127,26 +127,35 @@ void ULEdec::handleTSPacket(senf::TransportPacket ts_packet) unsigned char payload_pointer = *payload_start++; if (payload_pointer > 181) { std::cerr << "invalid payload_pointer\n"; + this->receiver_state = Idle; return; } switch (this->receiver_state) { case Idle: payload_start += payload_pointer; - readNewSNDUPacket( payload_start, payload_end ); break; case Reassembly: // Reassembly Payload Pointer Checking - unsigned char sndu_bytes_left = snduPacketBytesLeft(); - if (sndu_bytes_left != payload_pointer) { + if (snduPacketBytesLeft() != payload_pointer) { // delimiting error - std::cerr << "delimiting error\n"; + std::cerr << "delimiting error 2\n"; payload_start += payload_pointer; } else { - readContSNDUPacket( payload_start, payload_end ); + payload_start = readContSNDUPacket( payload_start, payload_end ); BOOST_ASSERT( isSDNUPacketComplete() ); + handleSNDUPacket(); } - readNewSNDUPacket( payload_start, payload_end ); } + do { + payload_start = readNewSNDUPacket( payload_start, payload_end ); + if (! isSDNUPacketComplete()) { + BOOST_ASSERT( std::distance( payload_start, payload_end ) == 0 ); + this->receiver_state = Reassembly; + break; + } + handleSNDUPacket(); + this->receiver_state = Idle; + } while (std::distance(payload_start, payload_end) < 2 ); } } // end pusi-switch @@ -241,7 +250,7 @@ int main(int argc, char const * argv[]) ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_ - + // Local Variables: // mode: c++ // fill-column: 100 diff --git a/Examples/DVBAdapter/ULEdec.hh b/Examples/DVBAdapter/ULEdec.hh index 288efaf..73d6699 100644 --- a/Examples/DVBAdapter/ULEdec.hh +++ b/Examples/DVBAdapter/ULEdec.hh @@ -49,7 +49,7 @@ public: private: typedef senf::PacketData::iterator iterator; - enum ReciverState { + enum ReceiverState { Idle, Reassembly }; @@ -59,7 +59,7 @@ private: senf::SNDUPacket snduPacket; - ReciverState receiver_state; + ReceiverState receiver_state; unsigned char priv_tscc; bool priv_sndu_type_1; iterator snduPacketData_iter; diff --git a/Utils/hexdump.ct b/Utils/hexdump.ct index 350c8c5..40aa12d 100644 --- a/Utils/hexdump.ct +++ b/Utils/hexdump.ct @@ -38,8 +38,7 @@ prefix_ void senf::hexdump(Iterator i, Iterator const & i_end, std::ostream& str unsigned offset (0); std::string ascii; for (; i != i_end; ++i, ++offset) { - switch ((offset % block_size)==0) { - case true: + if ((offset % block_size) == 0) { if (!ascii.empty()) { stream << " " << ascii << "\n"; ascii = ""; @@ -47,11 +46,9 @@ prefix_ void senf::hexdump(Iterator i, Iterator const & i_end, std::ostream& str stream << " " << std::hex << std::setw(4) << std::setfill('0') << offset << ' '; - break; - case false: + } else if ((offset % block_size) == block_size/2) { stream << " "; ascii += ' '; - break; } stream << ' ' << std::hex << std::setw(2) << std::setfill('0') << unsigned(*i); @@ -72,7 +69,7 @@ prefix_ void senf::hexdump(Iterator i, Iterator const & i_end, std::ostream& str #undef prefix_ //#include "hexdump.mpp" - + // Local Variables: // mode: c++ // fill-column: 100