Skip to content

Commit

Permalink
Patched to compile with OpenWatcom.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Jul 6, 2017
1 parent 9ca88e3 commit 062bdc2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
24 changes: 15 additions & 9 deletions src/archiver_iso9660.c
Expand Up @@ -256,7 +256,8 @@ static int iso_atoi4(char *text)
} /* iso_atoi4 */

static PHYSFS_sint64 iso_volume_mktime(ISO9660VolumeTimestamp *timestamp)
{
{
PHYSFS_sint64 value;
struct tm tm;
tm.tm_year = iso_atoi4(timestamp->year);
tm.tm_mon = iso_atoi2(timestamp->month) - 1;
Expand All @@ -265,7 +266,7 @@ static PHYSFS_sint64 iso_volume_mktime(ISO9660VolumeTimestamp *timestamp)
tm.tm_min = iso_atoi2(timestamp->minute);
tm.tm_sec = iso_atoi2(timestamp->second);
/* this allows values outside the range of a unix timestamp... sanitize them */
PHYSFS_sint64 value = mktime(&tm);
value = mktime(&tm);
return value == -1 ? 0 : value;
} /* iso_volume_mktime */

Expand Down Expand Up @@ -343,9 +344,9 @@ static int iso_extractfilename(ISO9660Handle *handle,

static int iso_readimage(ISO9660Handle *handle, PHYSFS_uint64 where,
void *buffer, PHYSFS_uint64 len)
{
{
int rc = -1;
BAIL_IF_MACRO(!__PHYSFS_platformGrabMutex(handle->mutex), ERRPASS, -1);
int rc = -1;
if (where != handle->currpos)
GOTO_IF_MACRO(!handle->io->seek(handle->io,where), ERRPASS, unlockme);
rc = handle->io->read(handle->io, buffer, len);
Expand Down Expand Up @@ -689,12 +690,14 @@ static void iso_file_close_mem(ISO9660FileHandle *fhandle)
static PHYSFS_uint32 iso_file_read_foreign(ISO9660FileHandle *filehandle,
void *buffer, PHYSFS_uint64 len)
{
PHYSFS_sint64 rc;

/* check remaining bytes & max obj which can be fetched */
const PHYSFS_sint64 bytesleft = filehandle->filesize - filehandle->currpos;
if (bytesleft < len)
len = bytesleft;

const PHYSFS_sint64 rc = filehandle->io->read(filehandle->io, buffer, len);
rc = filehandle->io->read(filehandle->io, buffer, len);
BAIL_IF_MACRO(rc == -1, ERRPASS, -1);

filehandle->currpos += rc; /* i trust my internal book keeping */
Expand All @@ -705,11 +708,13 @@ static PHYSFS_uint32 iso_file_read_foreign(ISO9660FileHandle *filehandle,

static int iso_file_seek_foreign(ISO9660FileHandle *fhandle,
PHYSFS_sint64 offset)
{
{
PHYSFS_sint64 pos;

BAIL_IF_MACRO(offset < 0, PHYSFS_ERR_INVALID_ARGUMENT, 0);
BAIL_IF_MACRO(offset >= fhandle->filesize, PHYSFS_ERR_PAST_EOF, 0);

PHYSFS_sint64 pos = fhandle->startblock * 2048 + offset;
pos = fhandle->startblock * 2048 + offset;
BAIL_IF_MACRO(!fhandle->io->seek(fhandle->io, pos), ERRPASS, -1);

fhandle->currpos = offset;
Expand All @@ -725,10 +730,11 @@ static void iso_file_close_foreign(ISO9660FileHandle *fhandle)


static int iso_file_open_mem(ISO9660Handle *handle, ISO9660FileHandle *fhandle)
{
{
int rc;
fhandle->cacheddata = allocator.Malloc(fhandle->filesize);
BAIL_IF_MACRO(!fhandle->cacheddata, PHYSFS_ERR_OUT_OF_MEMORY, -1);
int rc = iso_readimage(handle, fhandle->startblock * 2048,
rc = iso_readimage(handle, fhandle->startblock * 2048,
fhandle->cacheddata, fhandle->filesize);
GOTO_IF_MACRO(rc < 0, ERRPASS, freemem);
GOTO_IF_MACRO(rc == 0, PHYSFS_ERR_CORRUPT, freemem);
Expand Down
2 changes: 1 addition & 1 deletion src/physfs.c
Expand Up @@ -2768,7 +2768,7 @@ int PHYSFS_setBuffer(PHYSFS_File *handle, PHYSFS_uint64 _bufsize)

/* !!! FIXME: actually, why use 32 bits here? */
/*BAIL_IF_MACRO(_bufsize > 0xFFFFFFFF, "buffer must fit in 32-bits", 0);*/
BAIL_IF_MACRO(_bufsize > 0xFFFFFFFF, PHYSFS_ERR_INVALID_ARGUMENT, 0);
BAIL_IF_MACRO(_bufsize > __PHYSFS_UI64(0xFFFFFFFF), PHYSFS_ERR_INVALID_ARGUMENT, 0);
bufsize = (PHYSFS_uint32) _bufsize;

BAIL_IF_MACRO(!PHYSFS_flush(handle), ERRPASS, 0);
Expand Down

0 comments on commit 062bdc2

Please sign in to comment.