public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: Till Harbaum <till@harbaum.org>
To: BlueZ Mailing List <bluez-devel@lists.sourceforge.net>
Subject: Re: [Bluez-devel] Little Hexdump-Patch for hcidump
Date: Thu, 26 Aug 2004 20:35:25 +0200	[thread overview]
Message-ID: <200408262035.25412.till@harbaum.org> (raw)
In-Reply-To: <1093539822.2581.32.camel@pegasus>

[-- Attachment #1: Type: text/plain, Size: 268 bytes --]

On Thursday 26 August 2004 19:03, Marcel Holtmann wrote:
> please send me a patch (diff -u) and adjust a little bit your coding
> style to match the other sources of hcidump.
Sorry ... of course .. here you go

Ciao,
  Till

-- 
Dr.Ing. Till Harbaum, till@harbaum.org

[-- Attachment #2: hexdump.patch --]
[-- Type: text/x-diff, Size: 1199 bytes --]

--- bluez-hcidump-1.10/parser/parser.c	2004-08-26 20:22:06.000000000 +0200
+++ bluez-hcidump-1.10-t/parser/parser.c	2004-08-26 20:23:45.000000000 +0200
@@ -99,23 +99,36 @@
 
 void hex_dump(int level, struct frame *frm, int num)
 {
-	unsigned char *buf = frm->ptr;
-	register int i,n;
+        unsigned char *buf = frm->ptr;
+        register int i,n,b2c;
 
-	if ((num < 0) || (num > frm->len))
-		num = frm->len;
+        if ((num < 0) || (num > frm->len))
+                num = frm->len;
+
+        n = 0;
+        while(num>0) {
+                p_indent(level, frm);
+                printf("%04x: ", n);
+
+                b2c = (num>16)?16:num;
+
+		for(i=0;i<b2c;i++) 
+		        printf("%02x ", buf[i]);
+
+		for(i=0;i<(16-b2c);i++) 
+		        printf("   ");
+
+		printf("  ");
+
+		for(i=0;i<b2c;i++) 
+		        printf("%c", isprint(buf[i])?buf[i]:'.');
 
-	for (i = 0, n = 1; i < num; i++, n++) {
-		if (n == 1)
-			p_indent(level, frm);
-		printf("%2.2X ", buf[i]);
-		if (n == DUMP_WIDTH) {
-			printf("\n");
-			n = 0;
-		}
-	}
-	if (i && n!=1)
 		printf("\n");
+
+		buf  += b2c;
+		num  -= b2c;
+		n    += b2c;
+        }
 }
 
 void ascii_dump(int level, struct frame *frm, int num)

  reply	other threads:[~2004-08-26 18:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-05 12:45 [Bluez-devel] Bluez on Axis DevBoard 82 Peter Kjellerstedt
2004-08-26 16:44 ` [Bluez-devel] Little Hexdump-Patch for hcidump Till Harbaum
2004-08-26 17:03   ` Marcel Holtmann
2004-08-26 18:35     ` Till Harbaum [this message]
2004-08-26 19:20       ` Marcel Holtmann
     [not found]         ` <200408262230.37213.till@harbaum.org>
2004-08-26 22:26           ` Marcel Holtmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200408262035.25412.till@harbaum.org \
    --to=till@harbaum.org \
    --cc=bluez-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox