annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
101
454ff8bd0b83 fc-simtool: update-bin command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 #include <sys/types.h>
454ff8bd0b83 fc-simtool: update-bin command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 #include <stdio.h>
454ff8bd0b83 fc-simtool: update-bin command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 #include <stdlib.h>
454ff8bd0b83 fc-simtool: update-bin command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 #include <pcsclite.h>
454ff8bd0b83 fc-simtool: update-bin command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <winscard.h>
454ff8bd0b83 fc-simtool: update-bin command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include "globals.h"
454ff8bd0b83 fc-simtool: update-bin command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7
454ff8bd0b83 fc-simtool: update-bin command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 cmd_update_bin(argc, argv)
454ff8bd0b83 fc-simtool: update-bin command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 char **argv;
454ff8bd0b83 fc-simtool: update-bin command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 {
454ff8bd0b83 fc-simtool: update-bin command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 unsigned offset, len;
454ff8bd0b83 fc-simtool: update-bin command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 u_char data[255];
454ff8bd0b83 fc-simtool: update-bin command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 int rc;
454ff8bd0b83 fc-simtool: update-bin command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
454ff8bd0b83 fc-simtool: update-bin command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 offset = strtoul(argv[1], 0, 0);
454ff8bd0b83 fc-simtool: update-bin command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 if (offset > 0xFFFF) {
454ff8bd0b83 fc-simtool: update-bin command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 fprintf(stderr, "error: offset argument is out of range\n");
454ff8bd0b83 fc-simtool: update-bin command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 return(-1);
454ff8bd0b83 fc-simtool: update-bin command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 }
454ff8bd0b83 fc-simtool: update-bin command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 rc = read_hex_data_file(argv[2], data);
454ff8bd0b83 fc-simtool: update-bin command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 if (rc < 0)
454ff8bd0b83 fc-simtool: update-bin command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 return(rc);
454ff8bd0b83 fc-simtool: update-bin command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 len = rc;
454ff8bd0b83 fc-simtool: update-bin command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 return update_bin_op(offset, data, len);
454ff8bd0b83 fc-simtool: update-bin command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 }