src/mess/tools/messtest/testimgt.c
| r2642 | r2643 | |
| 181 | 181 | const char *filename; |
| 182 | 182 | const char *fork; |
| 183 | 183 | filter_getinfoproc filter; |
| 184 | | imgtool_stream *stream; |
| 184 | imgtool_stream *stream = NULL; |
| 185 | 185 | mess_pile pile; |
| 186 | 186 | |
| 187 | | if (!state->partition) |
| 187 | if (state->partition == NULL) |
| 188 | 188 | { |
| 189 | 189 | state->failed = 1; |
| 190 | 190 | report_message(MSG_FAILURE, "Partition not loaded"); |
| 191 | | return; |
| 191 | goto done; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | get_file_params(node, &filename, &fork, &filter); |
| 195 | | if (!filename) |
| 196 | | return; |
| 195 | if (filename == NULL) |
| 196 | goto done; |
| 197 | 197 | |
| 198 | 198 | pile_init(&pile); |
| 199 | 199 | messtest_get_data(node, &pile); |
| 200 | 200 | |
| 201 | 201 | stream = stream_open_mem(NULL, 0); |
| 202 | | if (!stream) |
| 202 | if (stream == NULL) |
| 203 | 203 | { |
| 204 | 204 | state->failed = 1; |
| 205 | 205 | error_outofmemory(); |
| 206 | | return; |
| 206 | goto done; |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | stream_write(stream, pile_getptr(&pile), pile_size(&pile)); |
| r2642 | r2643 | |
| 215 | 215 | { |
| 216 | 216 | state->failed = 1; |
| 217 | 217 | report_imgtoolerr(err); |
| 218 | | return; |
| 218 | goto done; |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | if (VERBOSE_FILECHAIN) |
| r2642 | r2643 | |
| 225 | 225 | if (err == IMGTOOLERR_SUCCESS) |
| 226 | 226 | report_message(MSG_INFO, "Filechain '%s': %s", filename, buf); |
| 227 | 227 | } |
| 228 | |
| 229 | done: |
| 230 | if (stream != NULL) |
| 231 | stream_close(stream); |
| 228 | 232 | } |
| 229 | 233 | |
| 230 | 234 | |
| r2642 | r2643 | |
| 235 | 239 | const char *filename; |
| 236 | 240 | const char *fork; |
| 237 | 241 | filter_getinfoproc filter; |
| 238 | | imgtool_stream *stream; |
| 242 | imgtool_stream *stream = NULL; |
| 239 | 243 | UINT64 stream_sz; |
| 240 | 244 | const void *stream_ptr; |
| 241 | 245 | mess_pile pile; |
| r2642 | r2643 | |
| 244 | 248 | { |
| 245 | 249 | state->failed = 1; |
| 246 | 250 | report_message(MSG_FAILURE, "Partition not loaded"); |
| 247 | | return; |
| 251 | goto done; |
| 248 | 252 | } |
| 249 | 253 | |
| 250 | 254 | get_file_params(node, &filename, &fork, &filter); |
| 251 | 255 | if (!filename) |
| 252 | | return; |
| 256 | goto done; |
| 253 | 257 | |
| 254 | 258 | stream = stream_open_mem(NULL, 0); |
| 255 | 259 | if (!stream) |
| 256 | 260 | { |
| 257 | 261 | state->failed = 1; |
| 258 | 262 | error_outofmemory(); |
| 259 | | return; |
| 263 | goto done; |
| 260 | 264 | } |
| 261 | 265 | |
| 262 | 266 | err = imgtool_partition_read_file(state->partition, filename, fork, stream, filter); |
| r2642 | r2643 | |
| 264 | 268 | { |
| 265 | 269 | state->failed = 1; |
| 266 | 270 | report_imgtoolerr(err); |
| 267 | | return; |
| 271 | goto done; |
| 268 | 272 | } |
| 269 | 273 | |
| 270 | 274 | pile_init(&pile); |
| r2642 | r2643 | |
| 276 | 280 | if ((pile_size(&pile) != stream_sz) || (memcmp(stream_ptr, pile_getptr(&pile), pile_size(&pile)))) |
| 277 | 281 | { |
| 278 | 282 | report_message(MSG_FAILURE, "Failed file verification"); |
| 279 | | return; |
| 283 | goto done; |
| 280 | 284 | } |
| 281 | 285 | |
| 282 | 286 | pile_delete(&pile); |
| 287 | |
| 288 | done: |
| 289 | if (stream != NULL) |
| 290 | stream_close(stream); |
| 283 | 291 | } |
| 284 | 292 | |
| 285 | 293 | |