File:  [Research Unix] / researchv10dc / cmd / oworm / scsi / odump.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:21:34 2018 UTC (8 years, 3 months ago) by root
Branches: belllabs, MAIN
CVS tags: researchv10, HEAD
researchv10 Dan Cross

#include	<fio.h>

#define	WIDTH	32

scsiodump(p, n)
	register unsigned char *p;
{
	register i, nd, l;
	unsigned char buf[WIDTH];
	int didstar;
	unsigned char *s;

	for(nd = 0; n > 0; n -= l, nd += l){
		l = min(WIDTH, n);
		if(nd && (l == WIDTH) && (memcmp(buf, p, l) == 0)){
			p += WIDTH;
			if(didstar++ == 0)
				Fprint(1, "*\n");
			continue;
		}
		memcpy(buf, p, l);
		didstar = 0;
		Fprint(1, "%5.5d", nd);
		s = p;
		for(i = 0; i < l; i++){
			if((i%4) == 0) Fputc(1, ' ');
			Fprint(1, "%2.2ux", *p++);
		}
		Fputc(1, '\n');
		Fprint(1, "     ");
		for(i = 0; i < l; i++){
			if((i%4) == 0) Fputc(1, ' ');
			if((*s >= ' ') && (*s < 0177))
				Fprint(1, " %c", *s++);
			else switch(*s++)
			{
			case '\n':	Fprint(1, "\\n"); break;
			case '\t':	Fprint(1, "\\t"); break;
			default:	Fprint(1, ".."); break;
			}
		}
		Fputc(1, '\n');
	}
	Fprint(1, "%5.5d\n", nd);
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.