Cleaned up byteorder-safe reading functions. Use internal Physfs stricmp.

This commit is contained in:
Ryan C. Gordon 2002-04-05 18:07:18 +00:00
parent 0cc9d27961
commit 4fc4185b58
1 changed files with 37 additions and 40 deletions

View File

@ -145,7 +145,7 @@ local int unzlocal_getByte(fin,pi)
int *pi; int *pi;
{ {
PHYSFS_uint8 c; 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) if (err==1)
{ {
*pi = (int)c; *pi = (int)c;
@ -161,7 +161,6 @@ local int unzlocal_getByte(fin,pi)
} }
/* !!! FIXME: Use PhysFS byteswap routines. */
/* =========================================================================== /* ===========================================================================
Reads a long in LSB order from the given gz_stream. Sets Reads a long in LSB order from the given gz_stream. Sets
*/ */
@ -169,57 +168,55 @@ local int unzlocal_getShort (fin,pX)
void* fin; void* fin;
uLong *pX; uLong *pX;
{ {
uLong x ; PHYSFS_uint16 val;
int i; PHYSFS_sint64 err = __PHYSFS_platformRead(fin, &val, sizeof (val), 1);
int err; if (err==1)
{
err = unzlocal_getByte(fin,&i); *pX = (uLong) PHYSFS_swapULE16(val);
x = (uLong)i; return UNZ_OK;
}
if (err==UNZ_OK)
err = unzlocal_getByte(fin,&i);
x += ((uLong)i)<<8;
if (err==UNZ_OK)
*pX = x;
else else
{
*pX = 0; *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) local int unzlocal_getLong (fin,pX)
void* fin; void* fin;
uLong *pX; uLong *pX;
{ {
uLong x ; PHYSFS_uint32 val;
int i; PHYSFS_sint64 err = __PHYSFS_platformRead(fin, &val, sizeof (val), 1);
int err; if (err==1)
{
err = unzlocal_getByte(fin,&i); *pX = (uLong) PHYSFS_swapULE32(val);
x = (uLong)i; return UNZ_OK;
}
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;
else else
{
*pX = 0; *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 */ /* My own strcmpi / strcasecmp */
#if 1
#define strcmpcasenosensitive_internal(x,y) __PHYSFS_platformStricmp(x,y)
#else
local int strcmpcasenosensitive_internal (fileName1,fileName2) local int strcmpcasenosensitive_internal (fileName1,fileName2)
const char* fileName1; const char* fileName1;
const char* fileName2; const char* fileName2;
@ -242,7 +239,7 @@ local int strcmpcasenosensitive_internal (fileName1,fileName2)
return 1; return 1;
} }
} }
#endif
#ifdef CASESENSITIVITYDEFAULT_NO #ifdef CASESENSITIVITYDEFAULT_NO
#define CASESENSITIVITYDEFAULTVALUE 2 #define CASESENSITIVITYDEFAULTVALUE 2