"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/drvcpcem.c" between
libdsk-1.5.15.tar.gz and libdsk-1.5.17.tar.gz

About: LIBDSK is a library for accessing discs and disc image files. Development version.

drvcpcem.c  (libdsk-1.5.15):drvcpcem.c  (libdsk-1.5.17)
skipping to change at line 319 skipping to change at line 319
* block. This comes after the last track, so count the * block. This comes after the last track, so count the
* number of tracks and sectors. */ * number of tracks and sectors. */
if (extended) /* Only extended DSKs have offset info */ if (extended) /* Only extended DSKs have offset info */
{ {
dsk_report("Checking for Offset-Info extension"); dsk_report("Checking for Offset-Info extension");
for (t = 0, c = 0; c < dskhead[0x30]; c++) for (t = 0, c = 0; c < dskhead[0x30]; c++)
for (h = 0; h < dskhead[0x31]; h++) for (h = 0; h < dskhead[0x31]; h++)
{ {
/* Load each track header in turn... */ /* Load each track header in turn... */
if (!dskhead[0x34 + t])
{
/* Unformatted track, skip */
++t;
continue;
}
if (fseek(cpc_self->cpc_fp, filepos, SEEK_SET)) if (fseek(cpc_self->cpc_fp, filepos, SEEK_SET))
{ {
fclose(cpc_self->cpc_fp); fclose(cpc_self->cpc_fp);
return DSK_ERR_SYSERR; return DSK_ERR_SYSERR;
} }
if (fread(trkhead, 1, 256, cpc_self->cpc_fp) < 256) if (fread(trkhead, 1, 256, cpc_self->cpc_fp) < 256)
{ {
#ifndef WIN16
fprintf(stderr, "%s: Unexpected EOF reading track header for "
"cylinder %d head %d\n", filename, c, h);
#endif
fclose(cpc_self->cpc_fp); fclose(cpc_self->cpc_fp);
return DSK_ERR_CORRUPT; return DSK_ERR_CORRUPT;
} }
/* Track header not found where expected */ /* Track header not found where expected */
if (memcmp(trkhead, "Track-Info\r\n", 12)) if (memcmp(trkhead, "Track-Info\r\n", 12))
{ {
#ifndef WIN16
fprintf(stderr, "%s: Track header signature not found for "
"cylinder %d head %d\n", filename, c, h);
#endif
fclose(cpc_self->cpc_fp); fclose(cpc_self->cpc_fp);
return DSK_ERR_CORRUPT; return DSK_ERR_CORRUPT;
} }
/* The offset table has one entry for the track, and one for each sector /* The offset table has one entry for the track, and one for each sector
* within the track */ * within the track */
offs_count += (trkhead[0x15] + 1); offs_count += (trkhead[0x15] + 1);
filepos += 256L * dskhead[0x34 + t]; filepos += 256L * dskhead[0x34 + t];
++t; ++t;
} }
skipping to change at line 367 skipping to change at line 382
!memcmp(buf, "Offset-Info\r\n", 13)) !memcmp(buf, "Offset-Info\r\n", 13))
{ {
t = 0; t = 0;
/* Read the offsets */ /* Read the offsets */
while (offs_count) while (offs_count)
{ {
if (fread(buf, 1, 2, cpc_self->cpc_fp) < 2) if (fread(buf, 1, 2, cpc_self->cpc_fp) < 2)
{ {
fclose(cpc_self->cpc_fp); fclose(cpc_self->cpc_fp);
dsk_free(offsets); dsk_free(offsets);
#ifndef WIN16
fprintf(stderr, "%s: Unexpected end of file reading offset info",
filename);
#endif
return DSK_ERR_CORRUPT; return DSK_ERR_CORRUPT;
} }
offsets[t++] = ldbs_peek2(buf); offsets[t++] = ldbs_peek2(buf);
--offs_count; --offs_count;
} }
} }
else /* No Offset-Info block */ else /* No Offset-Info block */
{ {
dsk_free(offsets); dsk_free(offsets);
offsets = NULL; offsets = NULL;
skipping to change at line 395 skipping to change at line 414
if (offsets) dsk_free(offsets); if (offsets) dsk_free(offsets);
fclose(cpc_self->cpc_fp); fclose(cpc_self->cpc_fp);
return err; return err;
} }
filepos = 0x100; filepos = 0x100;
dsk_report("Loading DSK file "); dsk_report("Loading DSK file ");
for (t = 0, c = 0; c < dskhead[0x30]; c++) for (t = 0, c = 0; c < dskhead[0x30]; c++)
for (h = 0; h < dskhead[0x31]; h++) for (h = 0; h < dskhead[0x31]; h++)
{ {
if (extended && !dskhead[0x34 + t])
{
/* Unformatted track, skip */
++t;
continue;
}
if (fseek(cpc_self->cpc_fp, filepos, SEEK_SET)) if (fseek(cpc_self->cpc_fp, filepos, SEEK_SET))
{ {
ldbs_close(&cpc_self->cpc_super.ld_store); ldbs_close(&cpc_self->cpc_super.ld_store);
if (offsets) dsk_free(offsets); if (offsets) dsk_free(offsets);
fclose(cpc_self->cpc_fp); fclose(cpc_self->cpc_fp);
return DSK_ERR_SYSERR; return DSK_ERR_SYSERR;
} }
err = track_to_ldbs(cpc_self, c, h, dskhead, &off_ptr); err = track_to_ldbs(cpc_self, c, h, dskhead, &off_ptr);
if (err) if (err)
{ {
skipping to change at line 509 skipping to change at line 534
/* Initialise the trackinfo block */ /* Initialise the trackinfo block */
memset(trackinfo, 0, sizeof(trackinfo)); memset(trackinfo, 0, sizeof(trackinfo));
strcpy((char *)trackinfo, "Track-Info\r\n"); strcpy((char *)trackinfo, "Track-Info\r\n");
trackinfo[0x10] = cyl; trackinfo[0x10] = cyl;
trackinfo[0x11] = head; trackinfo[0x11] = head;
trackinfo[0x17] = 0xE5; trackinfo[0x17] = 0xE5;
err = ldbs_get_trackhead(infile, &ldbs_track, cyl, head); err = ldbs_get_trackhead(infile, &ldbs_track, cyl, head);
if (err && err != DSK_ERR_NOADDR) return err; if (err && err != DSK_ERR_NOADDR) return err;
if (err == DSK_ERR_NOADDR) if (err == DSK_ERR_NOADDR || ldbs_track == NULL)
{ {
/* Track not found. Write an empty track-info block */ /* Track not found. Write an empty track-info block */
if (dskhead[0] == 'E') if (dskhead[0] == 'E')
{ {
dskhead[0x34 + track] = 1; dskhead[0x34 + track] = 1;
} }
if (fwrite(trackinfo, 1, 256, cpc_self->cpc_fp) < 256) if (fwrite(trackinfo, 1, 256, cpc_self->cpc_fp) < 256)
{ {
ldbs_free(ldbs_track); ldbs_free(ldbs_track);
return DSK_ERR_SYSERR; return DSK_ERR_SYSERR;
 End of changes. 6 change blocks. 
1 lines changed or deleted 26 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)