FreeCalypso > hg > freecalypso-hwlab
annotate simtool/pberase.c @ 118:b563ff1c1a2a
simtool/saverestore.c: rm unused variable
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 28 Jan 2021 04:11:28 +0000 |
parents | 0dcd666292e4 |
children | 87b34a244901 |
rev | line source |
---|---|
112
87d459d9797a
fc-simtool: pb-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
87d459d9797a
fc-simtool: pb-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This module implements the pb-erase command. |
87d459d9797a
fc-simtool: pb-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
87d459d9797a
fc-simtool: pb-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
87d459d9797a
fc-simtool: pb-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <sys/types.h> |
87d459d9797a
fc-simtool: pb-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <string.h> |
87d459d9797a
fc-simtool: pb-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <strings.h> |
87d459d9797a
fc-simtool: pb-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <stdio.h> |
87d459d9797a
fc-simtool: pb-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <stdlib.h> |
87d459d9797a
fc-simtool: pb-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <pcsclite.h> |
87d459d9797a
fc-simtool: pb-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <winscard.h> |
87d459d9797a
fc-simtool: pb-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include "globals.h" |
87d459d9797a
fc-simtool: pb-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 |
87d459d9797a
fc-simtool: pb-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 cmd_pb_erase(argc, argv) |
87d459d9797a
fc-simtool: pb-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 char **argv; |
87d459d9797a
fc-simtool: pb-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 { |
87d459d9797a
fc-simtool: pb-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 int rc; |
87d459d9797a
fc-simtool: pb-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 unsigned recno; |
87d459d9797a
fc-simtool: pb-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 u_char record[255]; |
87d459d9797a
fc-simtool: pb-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 |
87d459d9797a
fc-simtool: pb-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 rc = phonebook_op_common(argv[1]); |
87d459d9797a
fc-simtool: pb-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 if (rc < 0) |
87d459d9797a
fc-simtool: pb-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 return(rc); |
87d459d9797a
fc-simtool: pb-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 memset(record, 0xFF, curfile_record_len); |
87d459d9797a
fc-simtool: pb-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 for (recno = 1; recno <= curfile_record_count; recno++) { |
87d459d9797a
fc-simtool: pb-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 rc = update_rec_op(recno, 0x04, record, curfile_record_len); |
87d459d9797a
fc-simtool: pb-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 if (rc < 0) |
87d459d9797a
fc-simtool: pb-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 return(rc); |
87d459d9797a
fc-simtool: pb-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 } |
87d459d9797a
fc-simtool: pb-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 return(0); |
87d459d9797a
fc-simtool: pb-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 } |
115
0dcd666292e4
fc-simtool: pb-erase-one command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
32 |
0dcd666292e4
fc-simtool: pb-erase-one command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
33 cmd_pb_erase_one(argc, argv) |
0dcd666292e4
fc-simtool: pb-erase-one command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
34 char **argv; |
0dcd666292e4
fc-simtool: pb-erase-one command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
35 { |
0dcd666292e4
fc-simtool: pb-erase-one command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
36 int rc; |
0dcd666292e4
fc-simtool: pb-erase-one command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
37 unsigned recno; |
0dcd666292e4
fc-simtool: pb-erase-one command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
38 u_char record[255]; |
0dcd666292e4
fc-simtool: pb-erase-one command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
39 |
0dcd666292e4
fc-simtool: pb-erase-one command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
40 rc = phonebook_op_common(argv[1]); |
0dcd666292e4
fc-simtool: pb-erase-one command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
41 if (rc < 0) |
0dcd666292e4
fc-simtool: pb-erase-one command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
42 return(rc); |
0dcd666292e4
fc-simtool: pb-erase-one command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
43 recno = strtoul(argv[2], 0, 0); |
0dcd666292e4
fc-simtool: pb-erase-one command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
44 if (recno < 1 || recno > curfile_record_count) { |
0dcd666292e4
fc-simtool: pb-erase-one command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
45 fprintf(stderr, "error: specified record number is invalid\n"); |
0dcd666292e4
fc-simtool: pb-erase-one command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
46 return(-1); |
0dcd666292e4
fc-simtool: pb-erase-one command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
47 } |
0dcd666292e4
fc-simtool: pb-erase-one command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
48 memset(record, 0xFF, curfile_record_len); |
0dcd666292e4
fc-simtool: pb-erase-one command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
49 return update_rec_op(recno, 0x04, record, curfile_record_len); |
0dcd666292e4
fc-simtool: pb-erase-one command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
50 } |