6 WWW home page: http://www.fourmilab.ch/
8 This program is in the public domain.
19 static char addrformat[80] = "%6X";
20 static char dataformat1[80] = "%02X";
21 static int bytesperline = 16, doublechar = 0,
23 static unsigned long fileaddr;
24 static unsigned char lineecho[32];
26 /* OUTLINE -- Edit a line of binary data into the selected output
29 static void outline(FILE *out, unsigned char *dat, int len)
34 sprintf(oline, addrformat, fileaddr);
36 for (i = 0; i < len; i++) {
39 sprintf(outedit, dataformat1, dat[i]);
40 strcat(oline, (i == (bytesperline / 2)) ? " " : " ");
41 strcat(oline, outedit);
46 int shortfall = ((bytesperline - len) * (dflen + 1)) +
47 (len <= (bytesperline / 2) ? 1 : 0);
49 while (shortfall-- > 0) {
54 for (i = 0; i < len; i++) {
57 /* Map non-printing characters to "." according to the
58 definitions for ISO 8859/1 Latin-1. */
60 if (b < ' ' || (b > '~' && b < 145)
61 || (b > 146 && b < 160)) {
72 /* XD -- Dump a buffer.
74 xd(out, buf, bufl, dochar);
76 out FILE * to which output is sent.
77 buf Address of buffer to dump.
78 bufl Buffer length in bytes.
79 dochar If nonzero, show ASCII/ISO characters
80 as well as hexadecimal.
84 void xd(FILE *out, void *bub, int bufl, int dochar)
87 unsigned char *buf = (unsigned char *) bub;
95 if (bp >= bytesperline) {
96 outline(out, lineecho, bp);
98 fileaddr += bytesperline;
104 outline(out, lineecho, bp);