Killed MIX archiver.
authorRyan C. Gordon <icculus@icculus.org>
Sat, 10 Mar 2007 06:41:26 +0000
changeset 799 7012c0e130d0
parent 798 18455baab480
child 800 ce3d59cd8430
Killed MIX archiver.
CHANGELOG
CMakeLists.txt
TODO
archivers/mix.c
physfs.c
physfs.h
physfsMPW.make
--- a/CHANGELOG	Sat Mar 10 06:32:52 2007 +0000
+++ b/CHANGELOG	Sat Mar 10 06:41:26 2007 +0000
@@ -6,7 +6,8 @@
            Cleaned up whitespace/formatting in pocketpc.c. Updated PocketPC
            code to expect UTF-8 strings from the higher level. Changed
            PHYSFS_SUPPORTS_LZMA to PHYSFS_SUPPORTS_7Z. Killed some #ifdefs
-           in physfs.c. Moved to CMake...so long, autotools!
+           in physfs.c. Moved to CMake...so long, autotools! Killed MIX
+           archiver, too.
 11052006 - More 7zip archiver work (thanks, Dennis!). Initial Unicode work.
            Minor BeOS realpath tweak.
 09272006 - Reworked 7zip archiver (thanks, Dennis!).
--- a/CMakeLists.txt	Sat Mar 10 06:32:52 2007 +0000
+++ b/CMakeLists.txt	Sat Mar 10 06:41:26 2007 +0000
@@ -202,12 +202,6 @@
     SET(PHYSFS_SRCS ${PHYSFS_SRCS} archivers/qpak.c)
 ENDIF(PHYSFS_ARCHIVE_QPAK)
 
-OPTION(PHYSFS_ARCHIVE_MIX "Enable Westwood MIX support" FALSE)
-IF(PHYSFS_ARCHIVE_MIX)
-    ADD_DEFINITIONS(-DPHYSFS_SUPPORTS_MIX=1)
-    SET(PHYSFS_SRCS ${PHYSFS_SRCS} archivers/mix.c)
-ENDIF(PHYSFS_ARCHIVE_MIX)
-
 
 # See if some archiver required zlib, and see about using system version.
 
@@ -283,7 +277,6 @@
 MESSAGE_BOOL_OPTION("HOG support" PHYSFS_ARCHIVE_HOG)
 MESSAGE_BOOL_OPTION("MVL support" PHYSFS_ARCHIVE_MVL)
 MESSAGE_BOOL_OPTION("QPAK support" PHYSFS_ARCHIVE_QPAK)
-MESSAGE_BOOL_OPTION("MIX support" PHYSFS_ARCHIVE_MIX)
 MESSAGE_BOOL_OPTION("CD-ROM drive support" PHYSFS_HAVE_CDROM_SUPPORT)
 MESSAGE_BOOL_OPTION("Thread safety" PHYSFS_HAVE_THREAD_SUPPORT)
 MESSAGE_BOOL_OPTION("Build own zlib" PHYSFS_INTERNAL_ZLIB)
--- a/TODO	Sat Mar 10 06:32:52 2007 +0000
+++ b/TODO	Sat Mar 10 06:41:26 2007 +0000
@@ -49,8 +49,6 @@
 - Deprecate PHYSFS_setSaneConfig and move it to extras?
 - Why is physfsrwops.c cut-and-pasted into the ruby bindings?
 - Replace code from SDL...
-- MIX grabs all archives that no other archivers claim.
-- MIX enumerates files as hash values.
 - Should file enumeration return an error or set error state?
 - Update internal zlib?
 - Need "getmountpoint" command in test_physfs.c ...
--- a/archivers/mix.c	Sat Mar 10 06:32:52 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,452 +0,0 @@
-/*
- * MIX support routines for PhysicsFS.
- *
- * This driver handles old archives used in the famous games
- * Command&Conquer Tiberium Dawn and Command&Conquer Red Alert.
- *
- * Newer MIX files as they are used in C&C Tiberium Sun and C&C Red Alert 2
- * aren't supported yet. Keep your eyes open for future updates.
- *
- * A MIX file has three parts:
- *   (1) Header
- *        16bit integer  -> number of files stored in this MIX
- *        32bit integer  -> filesize
- *   (2) "Directory"
- *        32bit integer  -> hash of the filename
- *        32bit integer  -> starting offset in the MIX
- *        32bit integer  -> end offset in the MIX
- *   (3) Data (BODY)
- *        All data comes here
- *
- * NOTES:
- *  The offsets are relative to the body. So offset 0 is directly after
- *  the directory.
- *
- *  Filenames only exist as hashes. So enumerate_files() will only report all
- *  hashes. Searching a filename in hashes is extremly quick so I decided not
- *  to include any sorting routines after then opening of the archive.
- *
- *
- * I found the structure of MIX files here: 
- * http://www.geocities.com/SiliconValley/8682/cncmap1f.txt
- *
- *
- * Please see the file LICENSE in the source's root directory.
- *
- *  This file written by Sebastian Steinhauer <steini@steini-welt.de>
- */
- 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif
-
-#if (defined PHYSFS_SUPPORTS_MIX)
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "physfs.h"
-
-#define __PHYSICSFS_INTERNAL__
-#include "physfs_internal.h"
-
-typedef struct
-{
-    PHYSFS_uint16 num_files;
-    PHYSFS_uint32 filesize;
-} MIXheader;
-
-typedef struct
-{
-    PHYSFS_uint32 hash;
-    PHYSFS_uint32 start_offset;
-    PHYSFS_uint32 end_offset;
-} MIXentry;
-
-typedef struct
-{
-    char *filename; /* filename of the archive */
-    MIXentry *entry; /* list of entries */
-    MIXheader header; /* the header of the MIX file */
-    PHYSFS_uint32 delta; /* size of header + entries */
-} MIXinfo;
-
-typedef struct
-{
-    PHYSFS_uint64 size; /* filesize */
-    PHYSFS_uint64 cur_pos; /* position in this file */
-    MIXentry *entry; /* pointer to the MIX entry */
-    MIXinfo *info; /* pointer to our MIXinfo */
-    void *handle; /* filehandle */
-} MIXfileinfo;
-
-
-static PHYSFS_uint32 MIX_hash(const char *name)
-{
-    PHYSFS_uint32 id = 0;
-    PHYSFS_uint32 a = 0;
-    PHYSFS_uint32 i = 0;
-    PHYSFS_uint32 l;
-    PHYSFS_uint32 j;
-    
-    l = strlen(name);
-    while (i < l)
-    {
-        a = 0;
-        for(j = 0; j < 4; j++)
-        {
-            a >>= 8;
-            if (i < l)
-            {
-                a += (unsigned int) (name[i]) << 24;
-                i++;
-            } /* if */
-        } /* for */
-
-        id = (id << 1 | id >> 31) + a;
-    } /* while */
-
-    /* a bit debuggin :)
-    /printf("Filename %s -> %X\n",name,id); */
-
-    return(id);
-} /* MIX_hash */
-
-
-static void MIX_dirClose(dvoid *opaque)
-{
-    MIXinfo *info = ((MIXinfo *) opaque);
-    allocator.Free(info->entry);
-    allocator.Free(info->filename);
-} /* MIX_dirClose */
-
-
-static PHYSFS_sint64 MIX_read(fvoid *opaque, void *buffer,
-                              PHYSFS_uint32 objSize, PHYSFS_uint32 objCount)
-{
-    MIXfileinfo *finfo = (MIXfileinfo *) opaque;
-    MIXentry *entry = finfo->entry;
-    PHYSFS_uint32 read;
-    
-    /* set position in the archive */
-    __PHYSFS_platformSeek(finfo->handle,
-                             finfo->info->delta +
-                             entry->start_offset +
-                             finfo->cur_pos);
-    
-    /* read n bytes */
-    read = __PHYSFS_platformRead(finfo->handle, buffer, objSize, objCount);
-    
-    /* keep filepointer up to date */
-    if (read)
-        finfo->cur_pos += read * objSize;
-    
-    return(read);
-} /* MIX_read */
-
-
-static PHYSFS_sint64 MIX_write(fvoid *opaque, const void *buffer,
-                               PHYSFS_uint32 objSize, PHYSFS_uint32 objCount)
-{
-    BAIL_MACRO(ERR_NOT_SUPPORTED, -1);
-} /* MIX_write */
-
-
-static int MIX_eof(fvoid *opaque)
-{
-    MIXfileinfo *fifo = (MIXfileinfo *) opaque;
-    return(fifo->cur_pos >= fifo->size);
-} /* MIX_eof */
-
-
-static PHYSFS_sint64 MIX_tell(fvoid *opaque)
-{
-    return(((MIXfileinfo *) opaque)->cur_pos);
-} /* MIX_tell */
-
-
-static int MIX_seek(fvoid *opaque, PHYSFS_uint64 offset)
-{
-    MIXfileinfo *h = (MIXfileinfo *) opaque;
-    
-    BAIL_IF_MACRO(offset < 0, ERR_INVALID_ARGUMENT, 0);
-    BAIL_IF_MACRO(offset >= h->size, ERR_PAST_EOF, 0);
-    h->cur_pos = offset;
-    return(1);
-} /* MIX_seek */
-
-
-static PHYSFS_sint64 MIX_fileLength(fvoid *opaque)
-{
-    return (((MIXfileinfo *) opaque)->size);
-} /* MIX_fileLength */
-
-
-static int MIX_fileClose(fvoid *opaque)
-{
-    MIXfileinfo *finfo = (MIXfileinfo *) opaque;
-    __PHYSFS_platformClose(finfo->handle);
-    allocator.Free(finfo);
-    return(1);
-} /* MIX_fileClose */
-
-
-static int MIX_isArchive(const char *filename, int forWriting)
-{
-    /* !!! FIXME:
-            write a simple detection routine for MIX files.
-            Unfortunaly MIX files have no ID in the header.
-    */
-    return(1);
-} /* MIX_isArchive */
-
-
-/*
- * Read an unsigned 32-bit int and swap to native byte order.
- */
-static int readui32(void *in, PHYSFS_uint32 *val)
-{
-    PHYSFS_uint32 v;
-    BAIL_IF_MACRO(__PHYSFS_platformRead(in, &v, sizeof (v), 1) != 1, NULL, 0);
-    *val = PHYSFS_swapULE32(v);
-    return(1);
-} /* readui32 */
-
-
-/*
- * Read an unsigned 16-bit int and swap to native byte order.
- */
-static int readui16(void *in, PHYSFS_uint16 *val)
-{
-    PHYSFS_uint16 v;
-    BAIL_IF_MACRO(__PHYSFS_platformRead(in, &v, sizeof (v), 1) != 1, NULL, 0);
-    *val = PHYSFS_swapULE16(v);
-    return(1);
-} /* readui16 */
-
-
-static void *MIX_openArchive(const char *name, int forWriting)
-{
-    PHYSFS_uint32 i = 0;
-    MIXinfo *info = NULL;
-    void *handle = NULL;
-
-    info = (MIXinfo *) allocator.Malloc(sizeof (MIXinfo));
-    BAIL_IF_MACRO(info == NULL, ERR_OUT_OF_MEMORY, 0);
-    memset(info, '\0', sizeof (MIXinfo));
-
-    info->filename = (char *) allocator.Malloc(strlen(name) + 1);
-    GOTO_IF_MACRO(!info->filename, ERR_OUT_OF_MEMORY, MIX_openArchive_failed);
-
-    /* store filename */
-    strcpy(info->filename, name);
-    
-    /* open the file */
-    handle = __PHYSFS_platformOpenRead(name);
-    if (!handle)
-        goto MIX_openArchive_failed;
-
-    /* read the MIX header */
-    if ( (!readui16(handle, &info->header.num_files)) ||
-         (!readui32(handle, &info->header.filesize)) )
-        goto MIX_openArchive_failed;
-
-    info->delta = 6 + (info->header.num_files * 12);
-
-    /* allocate space for the entries and read the entries */
-    info->entry = allocator.Malloc(sizeof (MIXentry) * info->header.num_files);
-    GOTO_IF_MACRO(!info->entry, ERR_OUT_OF_MEMORY, MIX_openArchive_failed);
-
-    /* read the directory list */
-    for (i = 0; i < header.num_files; i++)
-    {
-        if ( (!readui32(handle, &info->entry[i].hash)) ||
-             (!readui32(handle, &info->entry[i].start_offset)) ||
-             (!readui32(handle, &info->entry[i].end_offset)) )
-            goto MIX_openArchive_failed;
-    } /* for */
-
-    __PHYSFS_platformClose(handle);
-
-    return(info);
-
-MIX_openArchive_failed:
-    if (info != NULL)
-    {
-        if (info->filename != NULL)
-            allocator.Free(info->filename);
-        if (info->entry != NULL)
-            allocator.Free(info->entry);
-        allocator.Free(info);
-    } /* if */
-
-    if (handle != NULL)
-        __PHYSFS_platformClose(handle);
-
-    return(NULL);
-} /* MIX_openArchive */
-
-
-static void MIX_enumerateFiles(dvoid *opaque, const char *dname,
-                               int omitSymLinks, PHYSFS_EnumFilesCallback cb,
-                               const char *origdir, void *callbackdata)
-{
-    /* no directories in MIX files. */
-    if (*dirname != '\0')
-    {
-        MIXinfo *info = (MIXinfo*) opaque;
-        MIXentry *entry = info->entry;
-        int i;
-        char buffer[32];
-    
-        for (i = 0; i < info->header.num_files; i++, entry++)
-        {
-            sprintf(buffer, "%X", entry->hash);
-            cb(callbackdata, origdir, buffer);
-        } /* for */
-    } /* if */
-} /* MIX_enumerateFiles */
-
-
-static MIXentry *MIX_find_entry(MIXinfo *info, const char *name)
-{
-    MIXentry *entry = info->entry;
-    PHYSFS_uint32 i, id;
-    
-    /* create hash */
-    id = MIX_hash(name);
-    
-    /* look for this hash */
-    for (i = 0; i < info->header.num_files; i++, entry++)
-    {
-        if (entry->hash == id)
-            return(entry);
-    } /* for */
-
-    /* nothing found... :( */
-    return(NULL);
-} /* MIX_find_entry */
-
-
-static int MIX_exists(dvoid *opaque, const char *name)
-{
-    return(MIX_find_entry(((MIXinfo *) opaque), name) != NULL);
-} /* MIX_exists */
-
-
-static int MIX_isDirectory(dvoid *opaque, const char *name, int *fileExists)
-{
-    *fileExists = MIX_exists(opaque, name);
-    return(0);  /* never directories in a MIX */
-} /* MIX_isDirectory */
-
-
-static int MIX_isSymLink(dvoid *opaque, const char *name, int *fileExists)
-{
-    *fileExists = MIX_exists(opaque, name);
-    return(0);  /* never symlinks in a MIX. */
-} /* MIX_isSymLink */
-
-
-static PHYSFS_sint64 MIX_getLastModTime(dvoid *opaque,
-                                        const char *name,
-                                        int *fileExists)
-{
-    BAIL_MACRO(ERR_NOT_SUPPORTED, 0);  /* !!! FIXME: return .MIX's modtime. */
-} /* MIX_getLastModTime */
-
-
-static fvoid *MIX_openRead(dvoid *opaque, const char *fnm, int *fileExists)
-{
-    MIXinfo *info = ((MIXinfo*) opaque);
-    MIXfileinfo *finfo;
-    MIXentry *entry;
-    
-    /* try to find this file */
-    entry = MIX_find_entry(info,fnm);
-    BAIL_IF_MACRO(entry == NULL, ERR_NO_SUCH_FILE, NULL);
-    
-    /* allocate a MIX handle */
-    finfo = (MIXfileinfo *) allocator.Malloc(sizeof (MIXfileinfo));
-    BAIL_IF_MACRO(finfo == NULL, ERR_OUT_OF_MEMORY, NULL);
-
-    /* open the archive */
-    finfo->handle = __PHYSFS_platformOpenRead(info->filename);
-    if(!finfo->handle)
-    {
-        allocator.Free(finfo);
-        return(NULL);
-    } /* if */
-    
-    /* setup structures */
-    finfo->cur_pos = 0;
-    finfo->info = info;
-    finfo->entry = entry;
-    finfo->size = entry->end_offset - entry->start_offset;
-
-    return(finfo);
-} /* MIX_openRead */
-
-
-static fvoid *MIX_openWrite(dvoid *opaque, const char *name)
-{
-    BAIL_MACRO(ERR_NOT_SUPPORTED, NULL);
-} /* MIX_openWrite */
-
-
-static fvoid *MIX_openAppend(dvoid *opaque, const char *name)
-{
-    BAIL_MACRO(ERR_NOT_SUPPORTED, NULL);
-} /* MIX_openAppend */
-
-
-static int MIX_remove(dvoid *opaque, const char *name)
-{
-    BAIL_MACRO(ERR_NOT_SUPPORTED, 0);
-} /* MIX_remove */
-
-
-static int MIX_mkdir(dvoid *opaque, const char *name)
-{
-    BAIL_MACRO(ERR_NOT_SUPPORTED, 0);
-} /* MIX_mkdir */
-
-
-const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_MIX =
-{
-    "MIX",
-    "Westwood archive (Tiberian Dawn / Red Alert)",
-    "Sebastian Steinhauer <steini@steini-welt.de>",
-    "http://icculus.org/physfs/",
-};
-
-
-const PHYSFS_Archiver __PHYSFS_Archiver_MIX =
-{
-    &__PHYSFS_ArchiveInfo_MIX,
-    MIX_isArchive,          /* isArchive() method      */
-    MIX_openArchive,        /* openArchive() method    */
-    MIX_enumerateFiles,     /* enumerateFiles() method */
-    MIX_exists,             /* exists() method         */
-    MIX_isDirectory,        /* isDirectory() method    */
-    MIX_isSymLink,          /* isSymLink() method      */
-    MIX_getLastModTime,     /* getLastModTime() method */
-    MIX_openRead,           /* openRead() method       */
-    MIX_openWrite,          /* openWrite() method      */
-    MIX_openAppend,         /* openAppend() method     */
-    MIX_remove,             /* remove() method         */
-    MIX_mkdir,              /* mkdir() method          */
-    MIX_dirClose,           /* dirClose() method       */
-    MIX_read,               /* read() method           */
-    MIX_write,              /* write() method          */
-    MIX_eof,                /* eof() method            */
-    MIX_tell,               /* tell() method           */
-    MIX_seek,               /* seek() method           */
-    MIX_fileLength,         /* fileLength() method     */
-    MIX_fileClose           /* fileClose() method      */
-};
-
-#endif  /* defined PHYSFS_SUPPORTS_MIX */
-
-/* end of mix.c ... */
-
--- a/physfs.c	Sat Mar 10 06:32:52 2007 +0000
+++ b/physfs.c	Sat Mar 10 06:41:26 2007 +0000
@@ -69,8 +69,6 @@
 extern const PHYSFS_Archiver       __PHYSFS_Archiver_MVL;
 extern const PHYSFS_ArchiveInfo    __PHYSFS_ArchiveInfo_WAD;
 extern const PHYSFS_Archiver       __PHYSFS_Archiver_WAD;
-extern const PHYSFS_ArchiveInfo    __PHYSFS_ArchiveInfo_MIX;
-extern const PHYSFS_Archiver       __PHYSFS_Archiver_MIX;
 extern const PHYSFS_Archiver       __PHYSFS_Archiver_DIR;
 
 
@@ -97,9 +95,6 @@
 #if (defined PHYSFS_SUPPORTS_WAD)
     &__PHYSFS_ArchiveInfo_WAD,
 #endif
-#if (defined PHYSFS_SUPPORTS_MIX)
-    &__PHYSFS_ArchiveInfo_MIX,
-#endif
     NULL
 };
 
@@ -126,9 +121,6 @@
 #if (defined PHYSFS_SUPPORTS_WAD)
     &__PHYSFS_Archiver_WAD,
 #endif
-#if (defined PHYSFS_SUPPORTS_MIX)
-    &__PHYSFS_Archiver_MIX,
-#endif
     &__PHYSFS_Archiver_DIR,
     NULL
 };
--- a/physfs.h	Sat Mar 10 06:32:52 2007 +0000
+++ b/physfs.h	Sat Mar 10 06:41:26 2007 +0000
@@ -145,7 +145,6 @@
  *   - .HOG (Descent I/II HOG file archives)
  *   - .MVL (Descent II movielib archives)
  *   - .WAD (DOOM engine archives)
- *   - .MIX (Older Westwood games archives)
  *
  *
  * String policy for PhysicsFS 2.0 and later:
--- a/physfsMPW.make	Sat Mar 10 06:32:52 2007 +0000
+++ b/physfsMPW.make	Sat Mar 10 06:41:26 2007 +0000
@@ -21,7 +21,6 @@
 				  :archivers:dir.c 
 				  :archivers:grp.c 
 				  :archivers:hog.c 
-				  :archivers:mix.c 
 				  :archivers:mvl.c 
 				  :archivers:qpak.c 
 				  :archivers:wad.c 
@@ -50,7 +49,6 @@
 				  "{ObjDir}dir.c.x" 
 				  "{ObjDir}grp.c.x" 
 				  "{ObjDir}hog.c.x" 
-				  "{ObjDir}mix.c.x" 
 				  "{ObjDir}mvl.c.x" 
 				  "{ObjDir}qpak.c.x" 
 				  "{ObjDir}wad.c.x" 
@@ -110,7 +108,6 @@
 "{ObjDir}dir.c.x"    :archivers:dir.c
 "{ObjDir}grp.c.x"    :archivers:grp.c
 "{ObjDir}hog.c.x"    :archivers:hog.c
-"{ObjDir}mix.c.x"    :archivers:mix.c
 "{ObjDir}mvl.c.x"    :archivers:mvl.c
 "{ObjDir}qpak.c.x"    :archivers:qpak.c
 "{ObjDir}wad.c.x"    :archivers:wad.c