view libcommon/hexdump.c @ 187:36e7fc58f065

GrcardSIM2 ADM5 setting command is now grcard2-set-adm5
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 06 Mar 2021 21:03:45 +0000
parents f1836c8d36cb
children
line wrap: on
line source

#include <sys/types.h>
#include <stdio.h>
#include "simresp.h"

display_sim_resp_in_hex(outf)
	FILE *outf;
{
	unsigned off, cc, n, c;

	for (off = 0; off < sim_resp_data_len; off += cc) {
		fprintf(outf, "%02X:", off);
		cc = 16;
		if (sim_resp_data_len - off < cc)
			cc = sim_resp_data_len - off;
		for (n = 0; n < 16; n++) {
			if (n == 0 || n == 8)
				putc(' ', outf);
			putc(' ', outf);
			if (n < cc)
				fprintf(outf, "%02X", sim_resp_data[off + n]);
			else {
				putc(' ', outf);
				putc(' ', outf);
			}
		}
		putc(' ', outf);
		putc(' ', outf);
		for (n = 0; n < cc; n++) {
			c = sim_resp_data[off + n];
			if (c < 0x20 || c > 0x7E)
				c = '.';
			putc(c, outf);
		}
		putc('\n', outf);
	}
	return(0);
}

cmd_sim_resp(argc, argv, outf)
	char **argv;
	FILE *outf;
{
	return display_sim_resp_in_hex(outf);
}