author | mickeyl <mickeyl> | 2004-05-02 19:17:27 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-05-02 19:17:27 (UTC) |
commit | 8602449caa5a055bd5f033e3792d0a59a0b41bfa (patch) (unidiff) | |
tree | 17f60677ff09e89eb270f1e6cc837687b0eab871 | |
parent | 3e8fab5fddb3a38d93eaca1a8d69d8f668c7cd99 (diff) | |
download | opie-8602449caa5a055bd5f033e3792d0a59a0b41bfa.zip opie-8602449caa5a055bd5f033e3792d0a59a0b41bfa.tar.gz opie-8602449caa5a055bd5f033e3792d0a59a0b41bfa.tar.bz2 |
dump takes less space now
NOTE: I think dump really doesn't belong here
-rw-r--r-- | libopie2/opienet/opcap.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp index 8ec4f47..8184f21 100644 --- a/libopie2/opienet/opcap.cpp +++ b/libopie2/opienet/opcap.cpp | |||
@@ -139,44 +139,42 @@ QString OPacket::_dumpStructure( QObjectList* l ) const | |||
139 | str.append( " |" ); | 139 | str.append( " |" ); |
140 | str += _dumpStructure( const_cast<QObjectList*>( o->children() ) ); | 140 | str += _dumpStructure( const_cast<QObjectList*>( o->children() ) ); |
141 | o = l->next(); | 141 | o = l->next(); |
142 | } | 142 | } |
143 | return str; | 143 | return str; |
144 | } | 144 | } |
145 | 145 | ||
146 | QString OPacket::dump( int bpl ) const | 146 | QString OPacket::dump( int bpl ) const |
147 | { | 147 | { |
148 | static int index = 0; | 148 | static int index = 0; |
149 | index++; | 149 | index++; |
150 | int len = _hdr.caplen; | 150 | int len = _hdr.caplen; |
151 | QString str; | 151 | QString str( "000:" ); |
152 | str.sprintf( "\n<----- Packet #%04d Len = 0x%X (%d) ----->\n\n", index, len, len ); | ||
153 | str.append( "0000: " ); | ||
154 | QString tmp; | 152 | QString tmp; |
155 | QString bytes; | 153 | QString bytes; |
156 | QString chars; | 154 | QString chars; |
157 | 155 | ||
158 | for ( int i = 0; i < len; ++i ) | 156 | for ( int i = 0; i < len; ++i ) |
159 | { | 157 | { |
160 | tmp.sprintf( "%02X ", _data[i] ); bytes.append( tmp ); | 158 | tmp.sprintf( "%02X ", _data[i] ); bytes.append( tmp ); |
161 | if ( (_data[i] > 31) && (_data[i]<128) ) chars.append( _data[i] ); | 159 | if ( (_data[i] > 31) && (_data[i]<128) ) chars.append( _data[i] ); |
162 | else chars.append( '.' ); | 160 | else chars.append( '.' ); |
163 | 161 | ||
164 | if ( !((i+1) % bpl) ) | 162 | if ( !((i+1) % bpl) ) |
165 | { | 163 | { |
166 | str.append( bytes ); | 164 | str.append( bytes ); |
167 | str.append( ' ' ); | 165 | str.append( ' ' ); |
168 | str.append( chars ); | 166 | str.append( chars ); |
169 | str.append( '\n' ); | 167 | str.append( '\n' ); |
170 | tmp.sprintf( "%04X: ", i+1 ); str.append( tmp ); | 168 | tmp.sprintf( "%03X:", i+1 ); str.append( tmp ); |
171 | bytes = ""; | 169 | bytes = ""; |
172 | chars = ""; | 170 | chars = ""; |
173 | } | 171 | } |
174 | 172 | ||
175 | } | 173 | } |
176 | if ( (len % bpl) ) | 174 | if ( (len % bpl) ) |
177 | { | 175 | { |
178 | str.append( bytes.leftJustify( 1 + 3*bpl ) ); | 176 | str.append( bytes.leftJustify( 1 + 3*bpl ) ); |
179 | str.append( chars ); | 177 | str.append( chars ); |
180 | } | 178 | } |
181 | str.append( '\n' ); | 179 | str.append( '\n' ); |
182 | return str; | 180 | return str; |