/* fdump.c - dump out a file to screen. */ /* ABZ 16/03/1990, 20/04/1990. Start offset added 12/06/1990. */ #include #define STDERR 2 FILE *f_ptr; int count=16; int buffer[16]=0; eof_flg=0; main(ac,av) unsigned ac; char *av[]; { int addr=0; int here=1; int base=16; int pt=0; if (ac < 2 | ac > 6) err_exit(av[0]); /* Wrong num. params */ if (av[1][0]=='-') { if (av[1][1] != 'c') err_exit(av[0]); /* Not -c option */ /* Check for -c for count */ pt=2; if (av[1][2]==0) { here++; pt=0; } count=hex(av[here][pt]); pt++; count=count==0 ? 16 : count; if (count==1 & av[here][pt] != 0) { count= 10+(av[here][pt]-48); count=(count>16 ? 16 : count); } here++; pt=0; } if (av[here][0]==0 | av[here][0]=='-') err_exit(av[0]); /* Bad filename */ f_ptr=fopen(av[here],"r"); if (f_ptr==NULL) { perror(av[here]); /* report error */ exit(1); } here++; if (ac != here) { if (av[here][0] == '-') { if (av[here][1] != 'd') err_exit(av[0]); base=10; pt=2; if (av[here][pt] == 0) { here++; pt=0; } } while(av[here][pt] != 0) addr= addr*base+hex(av[here][pt++],base); pt=0; here++; while(eof_flg != 1 && pt++] [[-d] ]\n"); exit(1); } get_a_line() { int l=0; while (l65535) pr_addr(a/65536); a=a & 65535; pr_hex(a/256); pr_hex(a & 255); } pr_hex(a) int a; { pr_nybble(a/16); pr_nybble(a & 15); } pr_nybble(a) int a; { putchar(a>9 ? a+55 : a+48); } int hex(c,base) char c; int base; { if (c>='a') c=c-32; /* if (base<11 && c >= '0'+base) err_exit(); */ /* if (c > '0'+base+6) err_exit(); */ /* if (c>'F') err_exit(); */ c=c-48; return(c>9 ? c-7 : c); }