File:  [Research Unix] / researchv10no / cmd / worm / oscsi / scsi / xd.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, 1 month ago) by root
Branches: belllabs, MAIN
CVS tags: researchv10, HEAD
researchv10 Norman

#include	<stdio.h>
#include	"../scsi.h"
#include	"../scsish.h"

#define	WIDTH	32

void
xd(uchar *p, int n, FILE *fp)
{
	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)
				fprintf(fp, "*\n");
			continue;
		}
		memcpy(buf, p, l);
		didstar = 0;
		fprintf(fp, "%5.5d", nd);
		s = p;
		for(i = 0; i < l; i++){
			if((i%4) == 0) putc(' ', fp);
			fprintf(fp, "%2.2x", *p++);
		}
		putc('\n', fp);
		fprintf(fp, "     ");
		for(i = 0; i < l; i++){
			if((i%4) == 0) putc(' ', fp);
			if((*s >= ' ') && (*s < 0177))
				fprintf(fp, " %c", *s++);
			else switch(*s++)
			{
			case '\n':	fprintf(fp, "\\n"); break;
			case '\t':	fprintf(fp, "\\t"); break;
			default:	fprintf(fp, ".."); break;
			}
		}
		putc('\n', fp);
	}
	fprintf(fp, "%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.