view uicc/hexdump.c @ 145:14dee03e9675

fc-uicc-tool: low-level write commands ported over
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 06 Feb 2021 02:17:51 +0000
parents f691a19f191d
children
line wrap: on
line source

#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <pcsclite.h>
#include <winscard.h>
#include "globals.h"

display_sim_resp_in_hex()
{
	unsigned off, cc, n, c;

	for (off = 0; off < sim_resp_data_len; off += cc) {
		printf("%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)
				putchar(' ');
			putchar(' ');
			if (n < cc)
				printf("%02X", sim_resp_data[off + n]);
			else {
				putchar(' ');
				putchar(' ');
			}
		}
		putchar(' ');
		putchar(' ');
		for (n = 0; n < cc; n++) {
			c = sim_resp_data[off + n];
			if (c < 0x20 || c > 0x7E)
				c = '.';
			putchar(c);
		}
		putchar('\n');
	}
	return(0);
}