view simtool/writecmd.c @ 101:454ff8bd0b83

fc-simtool: update-bin command implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 25 Jan 2021 01:54:43 +0000
parents
children 29cc5612797a
line wrap: on
line source

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

cmd_update_bin(argc, argv)
	char **argv;
{
	unsigned offset, len;
	u_char data[255];
	int rc;

	offset = strtoul(argv[1], 0, 0);
	if (offset > 0xFFFF) {
		fprintf(stderr, "error: offset argument is out of range\n");
		return(-1);
	}
	rc = read_hex_data_file(argv[2], data);
	if (rc < 0)
		return(rc);
	len = rc;
	return update_bin_op(offset, data, len);
}