Skip to content
Permalink
Browse files
Cleaned up byteorder-safe reading functions. Use internal Physfs stri…
…cmp.
  • Loading branch information
icculus committed Apr 5, 2002
1 parent 0cc9d27 commit 4fc4185b582b4df0ddae7411bfc2c631cfafebbf
Showing with 37 additions and 40 deletions.
  1. +37 −40 archivers/unzip.c
@@ -145,7 +145,7 @@ local int unzlocal_getByte(fin,pi)
int *pi;
{
PHYSFS_uint8 c;
PHYSFS_sint64 err = __PHYSFS_platformRead(fin, &c, 1, 1);
PHYSFS_sint64 err = __PHYSFS_platformRead(fin, &c, sizeof (c), 1);
if (err==1)
{
*pi = (int)c;
@@ -161,65 +161,62 @@ local int unzlocal_getByte(fin,pi)
}


/* !!! FIXME: Use PhysFS byteswap routines. */
/* ===========================================================================
Reads a long in LSB order from the given gz_stream. Sets
*/
local int unzlocal_getShort (fin,pX)
void* fin;
uLong *pX;
{
uLong x ;
int i;
int err;

err = unzlocal_getByte(fin,&i);
x = (uLong)i;

if (err==UNZ_OK)
err = unzlocal_getByte(fin,&i);
x += ((uLong)i)<<8;

if (err==UNZ_OK)
*pX = x;
PHYSFS_uint16 val;
PHYSFS_sint64 err = __PHYSFS_platformRead(fin, &val, sizeof (val), 1);
if (err==1)
{
*pX = (uLong) PHYSFS_swapULE16(val);
return UNZ_OK;
}
else
{
*pX = 0;
return err;
if (__PHYSFS_platformEOF(fin))
return UNZ_EOF;
else
return UNZ_ERRNO;
}

return(UNZ_ERRNO); /* shouldn't ever hit this. */
}

/* !!! FIXME: Use PhysFS byteswap routines. */
local int unzlocal_getLong (fin,pX)
void* fin;
uLong *pX;
{
uLong x ;
int i;
int err;

err = unzlocal_getByte(fin,&i);
x = (uLong)i;

if (err==UNZ_OK)
err = unzlocal_getByte(fin,&i);
x += ((uLong)i)<<8;

if (err==UNZ_OK)
err = unzlocal_getByte(fin,&i);
x += ((uLong)i)<<16;

if (err==UNZ_OK)
err = unzlocal_getByte(fin,&i);
x += ((uLong)i)<<24;

if (err==UNZ_OK)
*pX = x;
PHYSFS_uint32 val;
PHYSFS_sint64 err = __PHYSFS_platformRead(fin, &val, sizeof (val), 1);
if (err==1)
{
*pX = (uLong) PHYSFS_swapULE32(val);
return UNZ_OK;
}
else
{
*pX = 0;
return err;
if (__PHYSFS_platformEOF(fin))
return UNZ_EOF;
else
return UNZ_ERRNO;
}

return(UNZ_ERRNO); /* shouldn't ever hit this. */
}


/* My own strcmpi / strcasecmp */
#if 1

#define strcmpcasenosensitive_internal(x,y) __PHYSFS_platformStricmp(x,y)

#else
local int strcmpcasenosensitive_internal (fileName1,fileName2)
const char* fileName1;
const char* fileName2;
@@ -242,7 +239,7 @@ local int strcmpcasenosensitive_internal (fileName1,fileName2)
return 1;
}
}

#endif

#ifdef CASESENSITIVITYDEFAULT_NO
#define CASESENSITIVITYDEFAULTVALUE 2

0 comments on commit 4fc4185

Please sign in to comment.