FreeCalypso > hg > fc-pcsc-tools
comparison simtool/smsp_dump.c @ 115:f1ea981ab225
fc-simtool smsp-dump: support output redirection
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Fri, 19 Feb 2021 07:26:15 +0000 |
| parents | f5a26c1d0b93 |
| children |
comparison
equal
deleted
inserted
replaced
| 114:2c07684a3980 | 115:f1ea981ab225 |
|---|---|
| 108 fprintf(outf, "VP=%u ", fixp[27]); | 108 fprintf(outf, "VP=%u ", fixp[27]); |
| 109 print_alpha_field(sim_resp_data, textlen, outf); | 109 print_alpha_field(sim_resp_data, textlen, outf); |
| 110 putc('\n', outf); | 110 putc('\n', outf); |
| 111 } | 111 } |
| 112 | 112 |
| 113 cmd_smsp_dump(argc, argv) | 113 cmd_smsp_dump(argc, argv, outf) |
| 114 char **argv; | 114 char **argv; |
| 115 FILE *outf; | |
| 115 { | 116 { |
| 116 int rc; | 117 int rc; |
| 117 FILE *outf; | |
| 118 unsigned recno; | 118 unsigned recno; |
| 119 | 119 |
| 120 rc = select_ef_smsp(); | 120 rc = select_ef_smsp(); |
| 121 if (rc < 0) | 121 if (rc < 0) |
| 122 return(rc); | 122 return(rc); |
| 123 if (argv[1]) { | |
| 124 outf = fopen(argv[1], "w"); | |
| 125 if (!outf) { | |
| 126 perror(argv[1]); | |
| 127 return(-1); | |
| 128 } | |
| 129 } else | |
| 130 outf = stdout; | |
| 131 for (recno = 1; recno <= curfile_record_count; recno++) { | 123 for (recno = 1; recno <= curfile_record_count; recno++) { |
| 132 rc = readrec_op(recno, 0x04, curfile_record_len); | 124 rc = readrec_op(recno, 0x04, curfile_record_len); |
| 133 if (rc < 0) { | 125 if (rc < 0) |
| 134 if (argv[1]) | |
| 135 fclose(outf); | |
| 136 return(rc); | 126 return(rc); |
| 137 } | |
| 138 dump_record(recno, outf); | 127 dump_record(recno, outf); |
| 139 } | 128 } |
| 140 if (argv[1]) | |
| 141 fclose(outf); | |
| 142 return(0); | 129 return(0); |
| 143 } | 130 } |
