|
|
1.1 root 1: #include <stdio.h>
2: #include "../scsi.h"
3: #include "../scsish.h"
4:
5: #define WIDTH 32
6:
7: void
8: xd(uchar *p, int n, FILE *fp)
9: {
10: register i, nd, l;
11: unsigned char buf[WIDTH];
12: int didstar;
13: unsigned char *s;
14:
15: for(nd = 0; n > 0; n -= l, nd += l){
16: l = min(WIDTH, n);
17: if(nd && (l == WIDTH) && (memcmp(buf, p, l) == 0)){
18: p += WIDTH;
19: if(didstar++ == 0)
20: fprintf(fp, "*\n");
21: continue;
22: }
23: memcpy(buf, p, l);
24: didstar = 0;
25: fprintf(fp, "%5.5d", nd);
26: s = p;
27: for(i = 0; i < l; i++){
28: if((i%4) == 0) putc(' ', fp);
29: fprintf(fp, "%2.2x", *p++);
30: }
31: putc('\n', fp);
32: fprintf(fp, " ");
33: for(i = 0; i < l; i++){
34: if((i%4) == 0) putc(' ', fp);
35: if((*s >= ' ') && (*s < 0177))
36: fprintf(fp, " %c", *s++);
37: else switch(*s++)
38: {
39: case '\n': fprintf(fp, "\\n"); break;
40: case '\t': fprintf(fp, "\\t"); break;
41: default: fprintf(fp, ".."); break;
42: }
43: }
44: putc('\n', fp);
45: }
46: fprintf(fp, "%5.5d\n", nd);
47: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.