Skip to content

Commit

Permalink
Removed all the forward declaration cruft from the archivers.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Sep 29, 2004
1 parent c2765f8 commit 0492580
Show file tree
Hide file tree
Showing 9 changed files with 288 additions and 489 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Expand Up @@ -9,6 +9,10 @@
build the lists, too. The callback functionality goes all the way
down to the archivers and platform drivers where appropriate, which
cleans things up and simplifies some internal tasks very nicely.
Got rid of all the annoying forward declarations in all the
archivers and moved their PHYSFS_Archiver data to the end of the
file, since this was annoying me and I was getting sick of updating
function signatures in two places when the internal API changed.
09262004 - Did the same thing to FileHandles than I did to DirHandles, but
this triggered massive tweaking in physfs.c. A lot of code got
little cleanups, which was nice. Less malloc pressure, too, since
Expand Down
99 changes: 37 additions & 62 deletions archivers/dir.c
Expand Up @@ -18,68 +18,6 @@
#define __PHYSICSFS_INTERNAL__
#include "physfs_internal.h"

static PHYSFS_sint64 DIR_read(fvoid *opaque, void *buffer,
PHYSFS_uint32 objSize, PHYSFS_uint32 objCount);
static PHYSFS_sint64 DIR_write(fvoid *opaque, const void *buffer,
PHYSFS_uint32 objSize, PHYSFS_uint32 objCount);
static int DIR_eof(fvoid *opaque);
static PHYSFS_sint64 DIR_tell(fvoid *opaque);
static int DIR_seek(fvoid *opaque, PHYSFS_uint64 offset);
static PHYSFS_sint64 DIR_fileLength(fvoid *opaque);
static int DIR_fileClose(fvoid *opaque);
static int DIR_isArchive(const char *filename, int forWriting);
static void *DIR_openArchive(const char *name, int forWriting);
static void DIR_enumerateFiles(dvoid *opaque, const char *dname,
int omitSymLinks, PHYSFS_StringCallback cb,
void *callbackdata);
static int DIR_exists(dvoid *opaque, const char *name);
static int DIR_isDirectory(dvoid *opaque, const char *name, int *fileExists);
static int DIR_isSymLink(dvoid *opaque, const char *name, int *fileExists);
static fvoid *DIR_openRead(dvoid *opaque, const char *fnm, int *exist);
static PHYSFS_sint64 DIR_getLastModTime(dvoid *opaque, const char *f, int *e);
static fvoid *DIR_openWrite(dvoid *opaque, const char *filename);
static fvoid *DIR_openAppend(dvoid *opaque, const char *filename);
static int DIR_remove(dvoid *opaque, const char *name);
static int DIR_mkdir(dvoid *opaque, const char *name);
static void DIR_dirClose(dvoid *opaque);


const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_DIR =
{
"",
DIR_ARCHIVE_DESCRIPTION,
"Ryan C. Gordon <icculus@clutteredmind.org>",
"http://icculus.org/physfs/",
};



const PHYSFS_Archiver __PHYSFS_Archiver_DIR =
{
&__PHYSFS_ArchiveInfo_DIR,
DIR_isArchive, /* isArchive() method */
DIR_openArchive, /* openArchive() method */
DIR_enumerateFiles, /* enumerateFiles() method */
DIR_exists, /* exists() method */
DIR_isDirectory, /* isDirectory() method */
DIR_isSymLink, /* isSymLink() method */
DIR_getLastModTime, /* getLastModTime() method */
DIR_openRead, /* openRead() method */
DIR_openWrite, /* openWrite() method */
DIR_openAppend, /* openAppend() method */
DIR_remove, /* remove() method */
DIR_mkdir, /* mkdir() method */
DIR_dirClose, /* dirClose() method */
DIR_read, /* read() method */
DIR_write, /* write() method */
DIR_eof, /* eof() method */
DIR_tell, /* tell() method */
DIR_seek, /* seek() method */
DIR_fileLength, /* fileLength() method */
DIR_fileClose /* fileClose() method */
};


static PHYSFS_sint64 DIR_read(fvoid *opaque, void *buffer,
PHYSFS_uint32 objSize, PHYSFS_uint32 objCount)
{
Expand Down Expand Up @@ -307,5 +245,42 @@ static void DIR_dirClose(dvoid *opaque)
free(opaque);
} /* DIR_dirClose */



const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_DIR =
{
"",
DIR_ARCHIVE_DESCRIPTION,
"Ryan C. Gordon <icculus@clutteredmind.org>",
"http://icculus.org/physfs/",
};



const PHYSFS_Archiver __PHYSFS_Archiver_DIR =
{
&__PHYSFS_ArchiveInfo_DIR,
DIR_isArchive, /* isArchive() method */
DIR_openArchive, /* openArchive() method */
DIR_enumerateFiles, /* enumerateFiles() method */
DIR_exists, /* exists() method */
DIR_isDirectory, /* isDirectory() method */
DIR_isSymLink, /* isSymLink() method */
DIR_getLastModTime, /* getLastModTime() method */
DIR_openRead, /* openRead() method */
DIR_openWrite, /* openWrite() method */
DIR_openAppend, /* openAppend() method */
DIR_remove, /* remove() method */
DIR_mkdir, /* mkdir() method */
DIR_dirClose, /* dirClose() method */
DIR_read, /* read() method */
DIR_write, /* write() method */
DIR_eof, /* eof() method */
DIR_tell, /* tell() method */
DIR_seek, /* seek() method */
DIR_fileLength, /* fileLength() method */
DIR_fileClose /* fileClose() method */
};

/* end of dir.c ... */

96 changes: 35 additions & 61 deletions archivers/grp.c
Expand Up @@ -61,67 +61,6 @@ typedef struct
} GRPfileinfo;


static PHYSFS_sint64 GRP_read(fvoid *opaque, void *buffer,
PHYSFS_uint32 objSize, PHYSFS_uint32 objCount);
static PHYSFS_sint64 GRP_write(fvoid *opaque, const void *buffer,
PHYSFS_uint32 objSize, PHYSFS_uint32 objCount);
static int GRP_eof(fvoid *opaque);
static PHYSFS_sint64 GRP_tell(fvoid *opaque);
static int GRP_seek(fvoid *opaque, PHYSFS_uint64 offset);
static PHYSFS_sint64 GRP_fileLength(fvoid *opaque);
static int GRP_fileClose(fvoid *opaque);
static int GRP_isArchive(const char *filename, int forWriting);
static void *GRP_openArchive(const char *name, int forWriting);
static void GRP_enumerateFiles(dvoid *opaque, const char *dname,
int omitSymLinks, PHYSFS_StringCallback cb,
void *callbackdata);
static int GRP_exists(dvoid *opaque, const char *name);
static int GRP_isDirectory(dvoid *opaque, const char *name, int *fileExists);
static int GRP_isSymLink(dvoid *opaque, const char *name, int *fileExists);
static PHYSFS_sint64 GRP_getLastModTime(dvoid *opaque, const char *n, int *e);
static fvoid *GRP_openRead(dvoid *opaque, const char *name, int *exist);
static fvoid *GRP_openWrite(dvoid *opaque, const char *name);
static fvoid *GRP_openAppend(dvoid *opaque, const char *name);
static int GRP_remove(dvoid *opaque, const char *name);
static int GRP_mkdir(dvoid *opaque, const char *name);
static void GRP_dirClose(dvoid *opaque);

const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_GRP =
{
"GRP",
GRP_ARCHIVE_DESCRIPTION,
"Ryan C. Gordon <icculus@clutteredmind.org>",
"http://icculus.org/physfs/",
};


const PHYSFS_Archiver __PHYSFS_Archiver_GRP =
{
&__PHYSFS_ArchiveInfo_GRP,
GRP_isArchive, /* isArchive() method */
GRP_openArchive, /* openArchive() method */
GRP_enumerateFiles, /* enumerateFiles() method */
GRP_exists, /* exists() method */
GRP_isDirectory, /* isDirectory() method */
GRP_isSymLink, /* isSymLink() method */
GRP_getLastModTime, /* getLastModTime() method */
GRP_openRead, /* openRead() method */
GRP_openWrite, /* openWrite() method */
GRP_openAppend, /* openAppend() method */
GRP_remove, /* remove() method */
GRP_mkdir, /* mkdir() method */
GRP_dirClose, /* dirClose() method */
GRP_read, /* read() method */
GRP_write, /* write() method */
GRP_eof, /* eof() method */
GRP_tell, /* tell() method */
GRP_seek, /* seek() method */
GRP_fileLength, /* fileLength() method */
GRP_fileClose /* fileClose() method */
};



static void GRP_dirClose(dvoid *opaque)
{
GRPinfo *info = ((GRPinfo *) opaque);
Expand Down Expand Up @@ -495,6 +434,41 @@ static int GRP_mkdir(dvoid *opaque, const char *name)
BAIL_MACRO(ERR_NOT_SUPPORTED, 0);
} /* GRP_mkdir */


const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_GRP =
{
"GRP",
GRP_ARCHIVE_DESCRIPTION,
"Ryan C. Gordon <icculus@clutteredmind.org>",
"http://icculus.org/physfs/",
};


const PHYSFS_Archiver __PHYSFS_Archiver_GRP =
{
&__PHYSFS_ArchiveInfo_GRP,
GRP_isArchive, /* isArchive() method */
GRP_openArchive, /* openArchive() method */
GRP_enumerateFiles, /* enumerateFiles() method */
GRP_exists, /* exists() method */
GRP_isDirectory, /* isDirectory() method */
GRP_isSymLink, /* isSymLink() method */
GRP_getLastModTime, /* getLastModTime() method */
GRP_openRead, /* openRead() method */
GRP_openWrite, /* openWrite() method */
GRP_openAppend, /* openAppend() method */
GRP_remove, /* remove() method */
GRP_mkdir, /* mkdir() method */
GRP_dirClose, /* dirClose() method */
GRP_read, /* read() method */
GRP_write, /* write() method */
GRP_eof, /* eof() method */
GRP_tell, /* tell() method */
GRP_seek, /* seek() method */
GRP_fileLength, /* fileLength() method */
GRP_fileClose /* fileClose() method */
};

#endif /* defined PHYSFS_SUPPORTS_GRP */

/* end of grp.c ... */
Expand Down
96 changes: 35 additions & 61 deletions archivers/hog.c
Expand Up @@ -75,67 +75,6 @@ typedef struct
} HOGfileinfo;


static PHYSFS_sint64 HOG_read(fvoid *opaque, void *buffer,
PHYSFS_uint32 objSize, PHYSFS_uint32 objCount);
static PHYSFS_sint64 HOG_write(fvoid *opaque, const void *buffer,
PHYSFS_uint32 objSize, PHYSFS_uint32 objCount);
static int HOG_eof(fvoid *opaque);
static PHYSFS_sint64 HOG_tell(fvoid *opaque);
static int HOG_seek(fvoid *opaque, PHYSFS_uint64 offset);
static PHYSFS_sint64 HOG_fileLength(fvoid *opaque);
static int HOG_fileClose(fvoid *opaque);
static int HOG_isArchive(const char *filename, int forWriting);
static void *HOG_openArchive(const char *name, int forWriting);
static void HOG_enumerateFiles(dvoid *opaque, const char *dname,
int omitSymLinks, PHYSFS_StringCallback cb,
void *callbackdata);
static int HOG_exists(dvoid *opaque, const char *name);
static int HOG_isDirectory(dvoid *opaque, const char *name, int *fileExists);
static int HOG_isSymLink(dvoid *opaque, const char *name, int *fileExists);
static PHYSFS_sint64 HOG_getLastModTime(dvoid *opaque, const char *n, int *e);
static fvoid *HOG_openRead(dvoid *opaque, const char *name, int *exist);
static fvoid *HOG_openWrite(dvoid *opaque, const char *name);
static fvoid *HOG_openAppend(dvoid *opaque, const char *name);
static int HOG_remove(dvoid *opaque, const char *name);
static int HOG_mkdir(dvoid *opaque, const char *name);
static void HOG_dirClose(dvoid *opaque);

const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_HOG =
{
"HOG",
HOG_ARCHIVE_DESCRIPTION,
"Bradley Bell <btb@icculus.org>",
"http://icculus.org/physfs/",
};


const PHYSFS_Archiver __PHYSFS_Archiver_HOG =
{
&__PHYSFS_ArchiveInfo_HOG,
HOG_isArchive, /* isArchive() method */
HOG_openArchive, /* openArchive() method */
HOG_enumerateFiles, /* enumerateFiles() method */
HOG_exists, /* exists() method */
HOG_isDirectory, /* isDirectory() method */
HOG_isSymLink, /* isSymLink() method */
HOG_getLastModTime, /* getLastModTime() method */
HOG_openRead, /* openRead() method */
HOG_openWrite, /* openWrite() method */
HOG_openAppend, /* openAppend() method */
HOG_remove, /* remove() method */
HOG_mkdir, /* mkdir() method */
HOG_dirClose, /* dirClose() method */
HOG_read, /* read() method */
HOG_write, /* write() method */
HOG_eof, /* eof() method */
HOG_tell, /* tell() method */
HOG_seek, /* seek() method */
HOG_fileLength, /* fileLength() method */
HOG_fileClose /* fileClose() method */
};



static void HOG_dirClose(dvoid *opaque)
{
HOGinfo *info = ((HOGinfo *) opaque);
Expand Down Expand Up @@ -534,6 +473,41 @@ static int HOG_mkdir(dvoid *opaque, const char *name)
BAIL_MACRO(ERR_NOT_SUPPORTED, 0);
} /* HOG_mkdir */


const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_HOG =
{
"HOG",
HOG_ARCHIVE_DESCRIPTION,
"Bradley Bell <btb@icculus.org>",
"http://icculus.org/physfs/",
};


const PHYSFS_Archiver __PHYSFS_Archiver_HOG =
{
&__PHYSFS_ArchiveInfo_HOG,
HOG_isArchive, /* isArchive() method */
HOG_openArchive, /* openArchive() method */
HOG_enumerateFiles, /* enumerateFiles() method */
HOG_exists, /* exists() method */
HOG_isDirectory, /* isDirectory() method */
HOG_isSymLink, /* isSymLink() method */
HOG_getLastModTime, /* getLastModTime() method */
HOG_openRead, /* openRead() method */
HOG_openWrite, /* openWrite() method */
HOG_openAppend, /* openAppend() method */
HOG_remove, /* remove() method */
HOG_mkdir, /* mkdir() method */
HOG_dirClose, /* dirClose() method */
HOG_read, /* read() method */
HOG_write, /* write() method */
HOG_eof, /* eof() method */
HOG_tell, /* tell() method */
HOG_seek, /* seek() method */
HOG_fileLength, /* fileLength() method */
HOG_fileClose /* fileClose() method */
};

#endif /* defined PHYSFS_SUPPORTS_HOG */

/* end of hog.c ... */
Expand Down

0 comments on commit 0492580

Please sign in to comment.