Removed "dvoid" typedef.

This commit is contained in:
Ryan C. Gordon 2012-03-25 14:52:24 -04:00
parent 716ea0522f
commit b3fbba7af0
7 changed files with 78 additions and 79 deletions

View File

@ -47,7 +47,6 @@ From old TODO.txt...
- fscanf and fprintf support in extras dir.
- Sanity check byte order at runtime.
- Memory locking?
- Find a better name than dvoid and fvoid.
- General code audit.
- Multiple write dirs with mount points?
- Replace code from SDL...

View File

@ -66,7 +66,7 @@ static void *DIR_openArchive(PHYSFS_Io *io, const char *name, int forWriting)
} /* DIR_openArchive */
static void DIR_enumerateFiles(dvoid *opaque, const char *dname,
static void DIR_enumerateFiles(PHYSFS_Dir *opaque, const char *dname,
int omitSymLinks, PHYSFS_EnumFilesCallback cb,
const char *origdir, void *callbackdata)
{
@ -82,7 +82,7 @@ static void DIR_enumerateFiles(dvoid *opaque, const char *dname,
} /* DIR_enumerateFiles */
static PHYSFS_Io *doOpen(dvoid *opaque, const char *name,
static PHYSFS_Io *doOpen(PHYSFS_Dir *opaque, const char *name,
const int mode, int *fileExists)
{
char *f;
@ -114,25 +114,25 @@ static PHYSFS_Io *doOpen(dvoid *opaque, const char *name,
} /* doOpen */
static PHYSFS_Io *DIR_openRead(dvoid *opaque, const char *fnm, int *exist)
static PHYSFS_Io *DIR_openRead(PHYSFS_Dir *opaque, const char *fnm, int *exist)
{
return doOpen(opaque, fnm, 'r', exist);
} /* DIR_openRead */
static PHYSFS_Io *DIR_openWrite(dvoid *opaque, const char *filename)
static PHYSFS_Io *DIR_openWrite(PHYSFS_Dir *opaque, const char *filename)
{
return doOpen(opaque, filename, 'w', NULL);
} /* DIR_openWrite */
static PHYSFS_Io *DIR_openAppend(dvoid *opaque, const char *filename)
static PHYSFS_Io *DIR_openAppend(PHYSFS_Dir *opaque, const char *filename)
{
return doOpen(opaque, filename, 'a', NULL);
} /* DIR_openAppend */
static int DIR_remove(dvoid *opaque, const char *name)
static int DIR_remove(PHYSFS_Dir *opaque, const char *name)
{
int retval;
char *f;
@ -145,7 +145,7 @@ static int DIR_remove(dvoid *opaque, const char *name)
} /* DIR_remove */
static int DIR_mkdir(dvoid *opaque, const char *name)
static int DIR_mkdir(PHYSFS_Dir *opaque, const char *name)
{
int retval;
char *f;
@ -158,14 +158,14 @@ static int DIR_mkdir(dvoid *opaque, const char *name)
} /* DIR_mkdir */
static void DIR_closeArchive(dvoid *opaque)
static void DIR_closeArchive(PHYSFS_Dir *opaque)
{
allocator.Free(opaque);
} /* DIR_closeArchive */
static int DIR_stat(dvoid *opaque, const char *name, int *exists,
PHYSFS_Stat *stat)
static int DIR_stat(PHYSFS_Dir *opaque, const char *name,
int *exists, PHYSFS_Stat *stat)
{
int retval = 0;
char *d;

View File

@ -638,7 +638,7 @@ errorcleanup:
} /* ISO9660_openArchive */
static void ISO9660_closeArchive(dvoid *opaque)
static void ISO9660_closeArchive(PHYSFS_Dir *opaque)
{
ISO9660Handle *handle = (ISO9660Handle*) opaque;
handle->io->destroy(handle->io);
@ -766,7 +766,8 @@ closefile:
} /* iso_file_open_foreign */
static PHYSFS_Io *ISO9660_openRead(dvoid *opaque, const char *filename, int *exists)
static PHYSFS_Io *ISO9660_openRead(PHYSFS_Dir *opaque, const char *filename,
int *exists)
{
PHYSFS_Io *retval = NULL;
ISO9660Handle *handle = (ISO9660Handle*) opaque;
@ -815,7 +816,7 @@ errorhandling:
* Information gathering functions
******************************************************************************/
static void ISO9660_enumerateFiles(dvoid *opaque, const char *dname,
static void ISO9660_enumerateFiles(PHYSFS_Dir *opaque, const char *dname,
int omitSymLinks,
PHYSFS_EnumFilesCallback cb,
const char *origdir, void *callbackdata)
@ -872,7 +873,7 @@ static void ISO9660_enumerateFiles(dvoid *opaque, const char *dname,
} /* ISO9660_enumerateFiles */
static int ISO9660_stat(dvoid *opaque, const char *name, int *exists,
static int ISO9660_stat(PHYSFS_Dir *opaque, const char *name, int *exists,
PHYSFS_Stat *stat)
{
ISO9660Handle *handle = (ISO9660Handle*) opaque;
@ -919,25 +920,25 @@ static int ISO9660_stat(dvoid *opaque, const char *name, int *exists,
* Not supported functions
******************************************************************************/
static PHYSFS_Io *ISO9660_openWrite(dvoid *opaque, const char *name)
static PHYSFS_Io *ISO9660_openWrite(PHYSFS_Dir *opaque, const char *name)
{
BAIL_MACRO(PHYSFS_ERR_READ_ONLY, NULL);
} /* ISO9660_openWrite */
static PHYSFS_Io *ISO9660_openAppend(dvoid *opaque, const char *name)
static PHYSFS_Io *ISO9660_openAppend(PHYSFS_Dir *opaque, const char *name)
{
BAIL_MACRO(PHYSFS_ERR_READ_ONLY, NULL);
} /* ISO9660_openAppend */
static int ISO9660_remove(dvoid *opaque, const char *name)
static int ISO9660_remove(PHYSFS_Dir *opaque, const char *name)
{
BAIL_MACRO(PHYSFS_ERR_READ_ONLY, 0);
} /* ISO9660_remove */
static int ISO9660_mkdir(dvoid *opaque, const char *name)
static int ISO9660_mkdir(PHYSFS_Dir *opaque, const char *name)
{
BAIL_MACRO(PHYSFS_ERR_READ_ONLY, 0);
} /* ISO9660_mkdir */

View File

@ -531,7 +531,7 @@ static void doEnumCallback(PHYSFS_EnumFilesCallback cb, void *callbackdata,
} /* doEnumCallback */
static void LZMA_enumerateFiles(dvoid *opaque, const char *dname,
static void LZMA_enumerateFiles(PHYSFS_Dir *opaque, const char *dname,
int omitSymLinks, PHYSFS_EnumFilesCallback cb,
const char *origdir, void *callbackdata)
{
@ -575,7 +575,8 @@ static void LZMA_enumerateFiles(dvoid *opaque, const char *dname,
} /* LZMA_enumerateFiles */
static PHYSFS_Io *LZMA_openRead(dvoid *opaque, const char *name, int *fileExists)
static PHYSFS_Io *LZMA_openRead(PHYSFS_Dir *opaque, const char *name,
int *fileExists)
{
LZMAarchive *archive = (LZMAarchive *) opaque;
LZMAfile *file = lzma_find_file(archive, name);
@ -597,19 +598,19 @@ static PHYSFS_Io *LZMA_openRead(dvoid *opaque, const char *name, int *fileExists
} /* LZMA_openRead */
static PHYSFS_Io *LZMA_openWrite(dvoid *opaque, const char *filename)
static PHYSFS_Io *LZMA_openWrite(PHYSFS_Dir *opaque, const char *filename)
{
BAIL_MACRO(PHYSFS_ERR_READ_ONLY, NULL);
} /* LZMA_openWrite */
static PHYSFS_Io *LZMA_openAppend(dvoid *opaque, const char *filename)
static PHYSFS_Io *LZMA_openAppend(PHYSFS_Dir *opaque, const char *filename)
{
BAIL_MACRO(PHYSFS_ERR_READ_ONLY, NULL);
} /* LZMA_openAppend */
static void LZMA_closeArchive(dvoid *opaque)
static void LZMA_closeArchive(PHYSFS_Dir *opaque)
{
LZMAarchive *archive = (LZMAarchive *) opaque;
@ -627,19 +628,19 @@ static void LZMA_closeArchive(dvoid *opaque)
} /* LZMA_closeArchive */
static int LZMA_remove(dvoid *opaque, const char *name)
static int LZMA_remove(PHYSFS_Dir *opaque, const char *name)
{
BAIL_MACRO(PHYSFS_ERR_READ_ONLY, 0);
} /* LZMA_remove */
static int LZMA_mkdir(dvoid *opaque, const char *name)
static int LZMA_mkdir(PHYSFS_Dir *opaque, const char *name)
{
BAIL_MACRO(PHYSFS_ERR_READ_ONLY, 0);
} /* LZMA_mkdir */
static int LZMA_stat(dvoid *opaque, const char *filename, int *exists,
PHYSFS_Stat *stat)
static int LZMA_stat(PHYSFS_Dir *opaque, const char *filename,
int *exists, PHYSFS_Stat *stat)
{
const LZMAarchive *archive = (const LZMAarchive *) opaque;
const LZMAfile *file = lzma_find_file(archive, filename);

View File

@ -34,7 +34,7 @@ typedef struct
} UNPKfileinfo;
void UNPK_closeArchive(dvoid *opaque)
void UNPK_closeArchive(PHYSFS_Dir *opaque)
{
UNPKinfo *info = ((UNPKinfo *) opaque);
info->io->destroy(info->io);
@ -242,9 +242,9 @@ static void doEnumCallback(PHYSFS_EnumFilesCallback cb, void *callbackdata,
} /* doEnumCallback */
void UNPK_enumerateFiles(dvoid *opaque, const char *dname,
int omitSymLinks, PHYSFS_EnumFilesCallback cb,
const char *origdir, void *callbackdata)
void UNPK_enumerateFiles(PHYSFS_Dir *opaque, const char *dname,
int omitSymLinks, PHYSFS_EnumFilesCallback cb,
const char *origdir, void *callbackdata)
{
UNPKinfo *info = ((UNPKinfo *) opaque);
PHYSFS_sint32 dlen, dlen_inc, max, i;
@ -344,7 +344,7 @@ static UNPKentry *findEntry(const UNPKinfo *info, const char *path, int *isDir)
} /* findEntry */
PHYSFS_Io *UNPK_openRead(dvoid *opaque, const char *fnm, int *fileExists)
PHYSFS_Io *UNPK_openRead(PHYSFS_Dir *opaque, const char *fnm, int *fileExists)
{
PHYSFS_Io *retval = NULL;
UNPKinfo *info = (UNPKinfo *) opaque;
@ -390,32 +390,32 @@ UNPK_openRead_failed:
} /* UNPK_openRead */
PHYSFS_Io *UNPK_openWrite(dvoid *opaque, const char *name)
PHYSFS_Io *UNPK_openWrite(PHYSFS_Dir *opaque, const char *name)
{
BAIL_MACRO(PHYSFS_ERR_READ_ONLY, NULL);
} /* UNPK_openWrite */
PHYSFS_Io *UNPK_openAppend(dvoid *opaque, const char *name)
PHYSFS_Io *UNPK_openAppend(PHYSFS_Dir *opaque, const char *name)
{
BAIL_MACRO(PHYSFS_ERR_READ_ONLY, NULL);
} /* UNPK_openAppend */
int UNPK_remove(dvoid *opaque, const char *name)
int UNPK_remove(PHYSFS_Dir *opaque, const char *name)
{
BAIL_MACRO(PHYSFS_ERR_READ_ONLY, 0);
} /* UNPK_remove */
int UNPK_mkdir(dvoid *opaque, const char *name)
int UNPK_mkdir(PHYSFS_Dir *opaque, const char *name)
{
BAIL_MACRO(PHYSFS_ERR_READ_ONLY, 0);
} /* UNPK_mkdir */
int UNPK_stat(dvoid *opaque, const char *filename, int *exists,
PHYSFS_Stat *stat)
int UNPK_stat(PHYSFS_Dir *opaque, const char *filename,
int *exists, PHYSFS_Stat *stat)
{
int isDir = 0;
const UNPKinfo *info = (const UNPKinfo *) opaque;
@ -448,7 +448,8 @@ int UNPK_stat(dvoid *opaque, const char *filename, int *exists,
} /* UNPK_stat */
dvoid *UNPK_openArchive(PHYSFS_Io *io, UNPKentry *e, const PHYSFS_uint32 num)
PHYSFS_Dir *UNPK_openArchive(PHYSFS_Io *io, UNPKentry *e,
const PHYSFS_uint32 num)
{
UNPKinfo *info = (UNPKinfo *) allocator.Malloc(sizeof (UNPKinfo));
if (info == NULL)

View File

@ -1193,7 +1193,7 @@ static void doEnumCallback(PHYSFS_EnumFilesCallback cb, void *callbackdata,
} /* doEnumCallback */
static void ZIP_enumerateFiles(dvoid *opaque, const char *dname,
static void ZIP_enumerateFiles(PHYSFS_Dir *opaque, const char *dname,
int omitSymLinks, PHYSFS_EnumFilesCallback cb,
const char *origdir, void *callbackdata)
{
@ -1265,7 +1265,8 @@ static PHYSFS_Io *zip_get_io(PHYSFS_Io *io, ZIPinfo *inf, ZIPentry *entry)
} /* zip_get_io */
static PHYSFS_Io *ZIP_openRead(dvoid *opaque, const char *fnm, int *fileExists)
static PHYSFS_Io *ZIP_openRead(PHYSFS_Dir *opaque, const char *fnm,
int *fileExists)
{
PHYSFS_Io *retval = NULL;
ZIPinfo *info = (ZIPinfo *) opaque;
@ -1323,19 +1324,19 @@ ZIP_openRead_failed:
} /* ZIP_openRead */
static PHYSFS_Io *ZIP_openWrite(dvoid *opaque, const char *filename)
static PHYSFS_Io *ZIP_openWrite(PHYSFS_Dir *opaque, const char *filename)
{
BAIL_MACRO(PHYSFS_ERR_READ_ONLY, NULL);
} /* ZIP_openWrite */
static PHYSFS_Io *ZIP_openAppend(dvoid *opaque, const char *filename)
static PHYSFS_Io *ZIP_openAppend(PHYSFS_Dir *opaque, const char *filename)
{
BAIL_MACRO(PHYSFS_ERR_READ_ONLY, NULL);
} /* ZIP_openAppend */
static void ZIP_closeArchive(dvoid *opaque)
static void ZIP_closeArchive(PHYSFS_Dir *opaque)
{
ZIPinfo *zi = (ZIPinfo *) (opaque);
zi->io->destroy(zi->io);
@ -1344,19 +1345,19 @@ static void ZIP_closeArchive(dvoid *opaque)
} /* ZIP_closeArchive */
static int ZIP_remove(dvoid *opaque, const char *name)
static int ZIP_remove(PHYSFS_Dir *opaque, const char *name)
{
BAIL_MACRO(PHYSFS_ERR_READ_ONLY, 0);
} /* ZIP_remove */
static int ZIP_mkdir(dvoid *opaque, const char *name)
static int ZIP_mkdir(PHYSFS_Dir *opaque, const char *name)
{
BAIL_MACRO(PHYSFS_ERR_READ_ONLY, 0);
} /* ZIP_mkdir */
static int ZIP_stat(dvoid *opaque, const char *filename, int *exists,
static int ZIP_stat(PHYSFS_Dir *opaque, const char *filename, int *exists,
PHYSFS_Stat *stat)
{
int isDir = 0;

View File

@ -119,10 +119,8 @@ void __PHYSFS_smallFree(void *ptr);
#endif
/* !!! FIXME: find something better than "dvoid" and "fvoid" ... */
/* Opaque data for file and dir handlers... */
typedef void dvoid;
typedef void PHYSFS_Dir;
typedef struct
{
@ -135,7 +133,7 @@ typedef struct
/*
* DIRECTORY ROUTINES:
* These functions are for dir handles. Generate a handle with the
* openArchive() method, then pass it as the "opaque" dvoid to the
* openArchive() method, then pass it as the "opaque" PHYSFS_Dir to the
* others.
*
* Symlinks should always be followed (except in stat()); PhysicsFS will
@ -148,33 +146,30 @@ typedef struct
* (name) is a filename associated with (io), but doesn't necessarily
* map to anything, let alone a real filename. This possibly-
* meaningless name is in platform-dependent notation.
* (forWriting) is non-zero if this is to be used for
* (forWrite) is non-zero if this is to be used for
* the write directory, and zero if this is to be used for an
* element of the search path.
* Returns NULL on failure. We ignore any error code you set here.
* Returns non-NULL on success. The pointer returned will be
* passed as the "opaque" parameter for later calls.
*/
dvoid *(*openArchive)(PHYSFS_Io *io, const char *name, int forWriting);
PHYSFS_Dir *(*openArchive)(PHYSFS_Io *io, const char *name, int forWrite);
/*
* List all files in (dirname). Each file is passed to (callback),
* List all files in (dirname). Each file is passed to (cb),
* where a copy is made if appropriate, so you should dispose of
* it properly upon return from the callback.
* You should omit symlinks if (omitSymLinks) is non-zero.
* If you have a failure, report as much as you can.
* (dirname) is in platform-independent notation.
*/
void (*enumerateFiles)(dvoid *opaque,
const char *dirname,
int omitSymLinks,
PHYSFS_EnumFilesCallback callback,
const char *origdir,
void *callbackdata);
void (*enumerateFiles)(PHYSFS_Dir *opaque, const char *dirname,
int omitSymLinks, PHYSFS_EnumFilesCallback cb,
const char *origdir, void *callbackdata);
/*
* Open file for reading.
* This filename is in platform-independent notation.
* This filename, (fnm), is in platform-independent notation.
* If you can't handle multiple opens of the same file,
* you can opt to fail for the second call.
* Fail if the file does not exist.
@ -182,11 +177,11 @@ typedef struct
* Returns non-NULL on success. The pointer returned will be
* passed as the "opaque" parameter for later file calls.
*
* Regardless of success or failure, please set *fileExists to
* Regardless of success or failure, please set *exists to
* non-zero if the file existed (even if it's a broken symlink!),
* zero if it did not.
*/
PHYSFS_Io *(*openRead)(dvoid *opaque, const char *fname, int *fileExists);
PHYSFS_Io *(*openRead)(PHYSFS_Dir *opaque, const char *fnm, int *exists);
/*
* Open file for writing.
@ -200,7 +195,7 @@ typedef struct
* Returns non-NULL on success. The pointer returned will be
* passed as the "opaque" parameter for later file calls.
*/
PHYSFS_Io *(*openWrite)(dvoid *opaque, const char *filename);
PHYSFS_Io *(*openWrite)(PHYSFS_Dir *opaque, const char *filename);
/*
* Open file for appending.
@ -213,7 +208,7 @@ typedef struct
* Returns non-NULL on success. The pointer returned will be
* passed as the "opaque" parameter for later file calls.
*/
PHYSFS_Io *(*openAppend)(dvoid *opaque, const char *filename);
PHYSFS_Io *(*openAppend)(PHYSFS_Dir *opaque, const char *filename);
/*
* Delete a file in the archive/directory.
@ -222,7 +217,7 @@ typedef struct
* This method may be NULL.
* On failure, call __PHYSFS_setError().
*/
int (*remove)(dvoid *opaque, const char *filename);
int (*remove)(PHYSFS_Dir *opaque, const char *filename);
/*
* Create a directory in the archive/directory.
@ -234,7 +229,7 @@ typedef struct
* This method may be NULL.
* On failure, call __PHYSFS_setError().
*/
int (*mkdir)(dvoid *opaque, const char *filename);
int (*mkdir)(PHYSFS_Dir *opaque, const char *filename);
/*
* Close directories/archives, and free any associated memory,
@ -242,14 +237,15 @@ typedef struct
* applicable. Implementation can assume that it won't be called if
* there are still files open from this archive.
*/
void (*closeArchive)(dvoid *opaque);
void (*closeArchive)(PHYSFS_Dir *opaque);
/*
* Obtain basic file metadata.
* Returns non-zero on success, zero on failure.
* On failure, call __PHYSFS_setError().
*/
int (*stat)(dvoid *opaque, const char *fn, int *exists, PHYSFS_Stat *stat);
int (*stat)(PHYSFS_Dir *opaque, const char *fn,
int *exists, PHYSFS_Stat *stat);
} PHYSFS_Archiver;
@ -424,17 +420,17 @@ typedef struct
PHYSFS_uint32 size;
} UNPKentry;
void UNPK_closeArchive(dvoid *opaque);
dvoid *UNPK_openArchive(PHYSFS_Io *io, UNPKentry *e, const PHYSFS_uint32 num);
void UNPK_enumerateFiles(dvoid *opaque, const char *dname,
void UNPK_closeArchive(PHYSFS_Dir *opaque);
PHYSFS_Dir *UNPK_openArchive(PHYSFS_Io *io,UNPKentry *e,const PHYSFS_uint32 n);
void UNPK_enumerateFiles(PHYSFS_Dir *opaque, const char *dname,
int omitSymLinks, PHYSFS_EnumFilesCallback cb,
const char *origdir, void *callbackdata);
PHYSFS_Io *UNPK_openRead(dvoid *opaque, const char *fnm, int *fileExists);
PHYSFS_Io *UNPK_openWrite(dvoid *opaque, const char *name);
PHYSFS_Io *UNPK_openAppend(dvoid *opaque, const char *name);
int UNPK_remove(dvoid *opaque, const char *name);
int UNPK_mkdir(dvoid *opaque, const char *name);
int UNPK_stat(dvoid *opaque, const char *fn, int *exists, PHYSFS_Stat *stat);
PHYSFS_Io *UNPK_openRead(PHYSFS_Dir *opaque, const char *fnm, int *fileExists);
PHYSFS_Io *UNPK_openWrite(PHYSFS_Dir *opaque, const char *name);
PHYSFS_Io *UNPK_openAppend(PHYSFS_Dir *opaque, const char *name);
int UNPK_remove(PHYSFS_Dir *opaque, const char *name);
int UNPK_mkdir(PHYSFS_Dir *opaque, const char *name);
int UNPK_stat(PHYSFS_Dir *opaque, const char *fn, int *exist, PHYSFS_Stat *st);
/*--------------------------------------------------------------------------*/