FreeCalypso > hg > fc-pcsc-tools
comparison simtool/pbrestore.c @ 130:9c10afbb745a
fc-simtool: search added to file-reading commands
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Sat, 20 Feb 2021 21:54:12 +0000 |
| parents | ae831b21ef77 |
| children |
comparison
equal
deleted
inserted
replaced
| 129:94d87d05f6c5 | 130:9c10afbb745a |
|---|---|
| 8 #include <strings.h> | 8 #include <strings.h> |
| 9 #include <stdio.h> | 9 #include <stdio.h> |
| 10 #include <stdlib.h> | 10 #include <stdlib.h> |
| 11 #include "curfile.h" | 11 #include "curfile.h" |
| 12 | 12 |
| 13 extern FILE *open_script_input_file(); | |
| 14 | |
| 13 extern char *alpha_from_file_qstring(); | 15 extern char *alpha_from_file_qstring(); |
| 14 extern char *alpha_from_file_hex(); | 16 extern char *alpha_from_file_hex(); |
| 15 | 17 |
| 16 static | 18 static |
| 17 process_record(line, bin_file_buf, filename_for_errs, lineno_for_errs) | 19 process_record(line, bin_file_buf, filename_for_errs, lineno_for_errs) |
| 132 databuf = malloc(curfile_total_size); | 134 databuf = malloc(curfile_total_size); |
| 133 if (!databuf) { | 135 if (!databuf) { |
| 134 perror("malloc for full phonebook EF"); | 136 perror("malloc for full phonebook EF"); |
| 135 return(-1); | 137 return(-1); |
| 136 } | 138 } |
| 137 inf = fopen(argv[2], "r"); | 139 inf = open_script_input_file(argv[2]); |
| 138 if (!inf) { | 140 if (!inf) { |
| 139 perror(argv[2]); | 141 perror(argv[2]); |
| 140 free(databuf); | 142 free(databuf); |
| 141 return(-1); | 143 return(-1); |
| 142 } | 144 } |
| 174 char linebuf[1024]; | 176 char linebuf[1024]; |
| 175 | 177 |
| 176 rc = phonebook_op_common(argv[1]); | 178 rc = phonebook_op_common(argv[1]); |
| 177 if (rc < 0) | 179 if (rc < 0) |
| 178 return(rc); | 180 return(rc); |
| 179 inf = fopen(argv[2], "r"); | 181 inf = open_script_input_file(argv[2]); |
| 180 if (!inf) { | 182 if (!inf) { |
| 181 perror(argv[2]); | 183 perror(argv[2]); |
| 182 return(-1); | 184 return(-1); |
| 183 } | 185 } |
| 184 for (lineno = 1; fgets(linebuf, sizeof linebuf, inf); lineno++) { | 186 for (lineno = 1; fgets(linebuf, sizeof linebuf, inf); lineno++) { |
| 216 databuf = malloc(curfile_total_size); | 218 databuf = malloc(curfile_total_size); |
| 217 if (!databuf) { | 219 if (!databuf) { |
| 218 perror("malloc for full EF_LND"); | 220 perror("malloc for full EF_LND"); |
| 219 return(-1); | 221 return(-1); |
| 220 } | 222 } |
| 221 inf = fopen(argv[1], "r"); | 223 inf = open_script_input_file(argv[1]); |
| 222 if (!inf) { | 224 if (!inf) { |
| 223 perror(argv[1]); | 225 perror(argv[1]); |
| 224 free(databuf); | 226 free(databuf); |
| 225 return(-1); | 227 return(-1); |
| 226 } | 228 } |
