Ethereal-dev: [Ethereal-dev] Small patch to Follow TCP Stream/Hex dump

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Jirka Novak <j.novak@xxxxxxxxxxxx>
Date: Thu, 17 Jan 2002 14:12:33 +0100
Hello,

this patch add column with 'printed' bytes to Hex dump view. It looks as hex packet view now.

							Jirka Novak
Index: ethereal/gtk/follow_dlg.c
===================================================================
RCS file: /cvsroot/ethereal/gtk/follow_dlg.c,v
retrieving revision 1.17
diff -u -r1.17 follow_dlg.c
--- follow_dlg.c	2002/01/11 07:40:31	1.17
+++ follow_dlg.c	2002/01/17 13:09:15
@@ -53,6 +53,8 @@
 # include "snprintf.h"
 #endif
 
+#include <ctype.h>
+
 #include "color.h"
 #include "color_utils.h"
 #include "file.h"
@@ -526,7 +528,7 @@
 				sprintf(hexbuf, (is_server && 
 					follow_info->show_stream == BOTH_HOSTS) ?
 					"                                 "
-					"                              %08X  " :
+					"                                             %08X  " :
 					"%08X  ", *global_pos);
 				cur = strlen(hexbuf);
 				for (i = 0; i < 16 && current_pos + i < nchars;
@@ -541,6 +543,29 @@
 					hexbuf[cur++] = ' ';
 				    } else if (i != 15)
 					hexbuf[cur++] = ' ';
+				}
+				/* Fill it up if column isn't complete */
+				if (i<16)
+				{ int j;
+					
+				  for (j = i; j < 16; j++)
+				  { if (j == 7)
+				    { hexbuf[cur++] = ' '; }
+			            hexbuf[cur++] = ' ';
+			            hexbuf[cur++] = ' ';
+			            hexbuf[cur++] = ' ';
+				  }
+				}
+				else
+				{ hexbuf[cur++] = ' '; }
+
+				/* Now dump bytes as text */
+				for (i = 0; i < 16 && current_pos + i < nchars;
+				     i++) {
+				    hexbuf[cur++] = (isprint(buffer[current_pos + i]) ? buffer[current_pos + i] : '.' );
+				    if (i == 7) {
+					hexbuf[cur++] = ' ';
+				    } 
 				}
 				current_pos += i;
 				(*global_pos) += i;