Skip to content

Commit

Permalink
Renamed readuiXX() to match fileio.h naming conventions.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Apr 24, 2010
1 parent c0019ec commit 2c58d79
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
6 changes: 3 additions & 3 deletions archive_pck.c
Expand Up @@ -118,7 +118,7 @@ static boolean MojoArchive_pck_enumerate(MojoArchive *ar)
br = io->read(io, fileEntry.filename, sizeof (fileEntry.filename));
if (br != sizeof (fileEntry.filename))
return false;
else if (!readui32(io, &fileEntry.filesize))
else if (!MojoInput_readui32(io, &fileEntry.filesize))
return false;

dotdot = (strcmp(fileEntry.filename, "..") == 0);
Expand Down Expand Up @@ -243,9 +243,9 @@ MojoArchive *MojoArchive_createPCK(MojoInput *io)
PCKinfo *pckInfo = NULL;
PCKheader pckHeader;

if (!readui32(io, &pckHeader.Magic))
if (!MojoInput_readui32(io, &pckHeader.Magic))
return NULL;
else if (!readui32(io, &pckHeader.StartOfBinaryData))
else if (!MojoInput_readui32(io, &pckHeader.StartOfBinaryData))
return NULL;

// Check if this is a *.pck file.
Expand Down
12 changes: 6 additions & 6 deletions archive_uz2.c
Expand Up @@ -93,9 +93,9 @@ static int64 MojoInput_uz2_read(MojoInput *io, void *_buf, uint32 bufsize)
{
if (input->position == input->fsize)
return 0;
else if (!readui32(input->io, &input->compsize))
else if (!MojoInput_readui32(input->io, &input->compsize))
return (retval == 0) ? -1 : retval;
else if (!readui32(input->io, &input->uncompsize))
else if (!MojoInput_readui32(input->io, &input->uncompsize))
return (retval == 0) ? -1 : retval;
else if (!unpack(input))
return (retval == 0) ? -1 : retval;
Expand Down Expand Up @@ -125,9 +125,9 @@ static boolean MojoInput_uz2_seek(MojoInput *io, uint64 pos)
{
if (!input->io->seek(input->io, seekpos))
return false;
else if (!readui32(io, &input->compsize))
else if (!MojoInput_readui32(io, &input->compsize))
return false;
else if (!readui32(io, &input->uncompsize))
else if (!MojoInput_readui32(io, &input->uncompsize))
return false;

// we checked these formally elsewhere.
Expand Down Expand Up @@ -275,9 +275,9 @@ static int64 calculate_uz2_outsize(MojoInput *io)
if (!io->seek(io, 0))
return -1;

while (readui32(io, &compsize))
while (MojoInput_readui32(io, &compsize))
{
if (!readui32(io, &uncompsize))
if (!MojoInput_readui32(io, &uncompsize))
return -1;
else if ((compsize > MAXCOMPSIZE) || (uncompsize > MAXUNCOMPSIZE))
return -1;
Expand Down
3 changes: 3 additions & 0 deletions archive_zip.c
Expand Up @@ -61,6 +61,9 @@ static PHYSFS_Allocator allocator = { 0, 0, mallocWrap, reallocWrap, freeWrap };
#define fvoid void
#define dvoid void

#define readui16(io, ptr) MojoInput_readui16((MojoInput *) (io), ptr)
#define readui32(io, ptr) MojoInput_readui32((MojoInput *) (io), ptr)

static PHYSFS_sint64 __PHYSFS_platformRead(void *opaque, void *buffer,
PHYSFS_uint32 size, PHYSFS_uint32 count)
{
Expand Down
8 changes: 4 additions & 4 deletions fileio.c
Expand Up @@ -1060,26 +1060,26 @@ MojoArchive *MojoArchive_newFromDirectory(const char *dirname)
} // MojoArchive_newFromDirectory


boolean readui16(MojoInput *io, uint16 *ui16)
boolean MojoInput_readui16(MojoInput *io, uint16 *ui16)
{
uint8 buf[sizeof (uint16)];
if (io->read(io, buf, sizeof (buf)) != sizeof (buf))
return false;

*ui16 = (buf[0] | (buf[1] << 8));
return true;
} // readui16
} // MojoInput_readui16


boolean readui32(MojoInput *io, uint32 *ui32)
boolean MojoInput_readui32(MojoInput *io, uint32 *ui32)
{
uint8 buf[sizeof (uint32)];
if (io->read(io, buf, sizeof (buf)) != sizeof (buf))
return false;

*ui32 = (buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24));
return true;
} // readui32
} // MojoInput_readui32


MojoArchive *GBaseArchive = NULL;
Expand Down
4 changes: 2 additions & 2 deletions fileio.h
Expand Up @@ -118,8 +118,8 @@ boolean MojoInput_toPhysicalFile(MojoInput *in, const char *fname, uint16 perms,

MojoInput *MojoInput_newFromURL(const char *url);

boolean readui16(MojoInput *io, uint16 *ui16);
boolean readui32(MojoInput *io, uint32 *ui32);
boolean MojoInput_readui16(MojoInput *io, uint16 *ui16);
boolean MojoInput_readui32(MojoInput *io, uint32 *ui32);

#ifdef __cplusplus
}
Expand Down

0 comments on commit 2c58d79

Please sign in to comment.