14 #include "inputfiles.h"
16 static int probe(FILE *file,
const char *fname, cbmcopy_message_cb msg_cb)
20 msg_cb( sev_debug,
"checking for pc64" );
22 if(fread( sig,
sizeof(sig), 1, file ) == 1 &&
23 strncmp( sig,
"C64File", 8 ) == 0)
25 msg_cb( sev_debug,
"PC64 file detected: %s", fname );
33 static int read(FILE *file,
const char *fname,
int entry,
34 char *cbmname,
char *type,
35 unsigned char **data,
size_t *size,
36 cbmcopy_message_cb msg_cb)
43 unsigned char cbmname[16];
52 msg_cb( sev_warning,
"invalid PC64 entry" );
56 if(fread( &pc64header,
sizeof(pc64header), 1, file ) != 1)
58 msg_cb( sev_warning,
"could not read PC64 header" );
62 if(strlen( fname ) > 4)
64 ext = fname + strlen(fname) - 3;
65 if(isdigit(ext[1]) && isdigit(ext[2]) &&
66 strchr(
"PSDU", toupper(*ext)))
68 *type = (char) toupper(*ext);
72 msg_cb( sev_warning,
"could not guess PC64 filetype: %s", fname );
79 "name too short to guess PC64 filetype: %s", fname );
82 memcpy(cbmname, pc64header.cbmname, 16 );
85 if(fseek(file, 0L, SEEK_END) == 0)
87 *size = ftell(file) -
sizeof(pc64header);
90 *data = malloc(*size);
93 if(fseek(file,
sizeof(pc64header), SEEK_SET) == 0 &&
94 fread(*data, *size, 1, file) == 1)
109 DECLARE_INPUT_READER(pc64);