FreeCalypso > hg > fc-pcsc-tools
comparison simtool/writecmd.c @ 202:3f6f50103dd3
fc-simtool: update-rec-prev separate command eliminated,
absorbed into regular update-rec
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Sun, 07 Mar 2021 04:06:39 +0000 |
| parents | a1aa8ee2da85 |
| children | 647267e39c21 |
comparison
equal
deleted
inserted
replaced
| 201:fc1635333d81 | 202:3f6f50103dd3 |
|---|---|
| 1 #include <sys/types.h> | 1 #include <sys/types.h> |
| 2 #include <stdio.h> | 2 #include <stdio.h> |
| 3 #include <stdlib.h> | 3 #include <stdlib.h> |
| 4 #include <string.h> | |
| 5 #include <strings.h> | |
| 4 #include "curfile.h" | 6 #include "curfile.h" |
| 5 | 7 |
| 6 cmd_update_bin(argc, argv) | 8 cmd_update_bin(argc, argv) |
| 7 char **argv; | 9 char **argv; |
| 8 { | 10 { |
| 42 } | 44 } |
| 43 | 45 |
| 44 cmd_update_rec(argc, argv) | 46 cmd_update_rec(argc, argv) |
| 45 char **argv; | 47 char **argv; |
| 46 { | 48 { |
| 47 unsigned recno; | 49 unsigned recno, mode; |
| 48 u_char data[255]; | 50 u_char data[255]; |
| 49 int rc; | 51 int rc; |
| 50 | 52 |
| 51 recno = strtoul(argv[1], 0, 0); | 53 if (!strcmp(argv[1], "prev")) { |
| 52 if (recno < 1 || recno > 255) { | 54 recno = 0; |
| 53 fprintf(stderr, | 55 mode = 0x03; |
| 56 } else { | |
| 57 recno = strtoul(argv[1], 0, 0); | |
| 58 if (recno < 1 || recno > 255) { | |
| 59 fprintf(stderr, | |
| 54 "error: record number argument is out of range\n"); | 60 "error: record number argument is out of range\n"); |
| 55 return(-1); | 61 return(-1); |
| 62 } | |
| 63 mode = 0x04; | |
| 56 } | 64 } |
| 57 rc = read_hex_data_file(argv[2], data, 255); | 65 rc = read_hex_data_file(argv[2], data, 255); |
| 58 if (rc < 0) | 66 if (rc < 0) |
| 59 return(rc); | 67 return(rc); |
| 60 if (rc != curfile_record_len) { | 68 if (rc != curfile_record_len) { |
| 61 fprintf(stderr, "error: hex data length != EF record length\n"); | 69 fprintf(stderr, "error: hex data length != EF record length\n"); |
| 62 return(-1); | 70 return(-1); |
| 63 } | 71 } |
| 64 return update_rec_op(recno, 0x04, data, curfile_record_len); | 72 return update_rec_op(recno, mode, data, curfile_record_len); |
| 65 } | 73 } |
| 66 | |
| 67 cmd_update_rec_prev(argc, argv) | |
| 68 char **argv; | |
| 69 { | |
| 70 u_char data[255]; | |
| 71 int rc; | |
| 72 | |
| 73 rc = read_hex_data_file(argv[1], data, 255); | |
| 74 if (rc < 0) | |
| 75 return(rc); | |
| 76 if (rc != curfile_record_len) { | |
| 77 fprintf(stderr, "error: hex data length != EF record length\n"); | |
| 78 return(-1); | |
| 79 } | |
| 80 return update_rec_op(0, 0x03, data, curfile_record_len); | |
| 81 } |
