From 1c3d7dcc7cec61b9907f902f8f1f5051727b6f5a Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 11 Apr 2006 15:01:15 +0000 Subject: [PATCH] Some minor fixes and cleanups. --- archivers/lzma.c | 2 +- archivers/zip.c | 12 ++--- configure.in | 2 +- lzma/7zAlloc.h | 21 ++++++++ lzma/7zDecode.c | 4 +- lzma/LzmaStateDecode.h | 2 +- physfs_internal.h | 118 ++++++++++++++++++++++------------------- 7 files changed, 96 insertions(+), 65 deletions(-) create mode 100644 lzma/7zAlloc.h diff --git a/archivers/lzma.c b/archivers/lzma.c index a470f7c7..873a5c9c 100644 --- a/archivers/lzma.c +++ b/archivers/lzma.c @@ -543,7 +543,7 @@ static fvoid *LZMA_openRead(dvoid *opaque, const char *name, int *fileExists) if ((folder->NumPackStreams != 1) || (folder->NumCoders != 1)) { LZMA_fileClose(entry); - BAIL_MACRO(ERR_LZMA_NOTIMPL, NULL); + BAIL_MACRO(ERR_NOT_IMPLEMENTED, NULL); } /* if */ if (lzma_err(LzmaDecodeProperties(&entry->state.Properties, coder->Properties.Items, coder->Properties.Capacity)) != LZMA_RESULT_OK) diff --git a/archivers/zip.c b/archivers/zip.c index cae91b39..c2d5ea79 100644 --- a/archivers/zip.c +++ b/archivers/zip.c @@ -154,12 +154,12 @@ static const char *zlib_error_string(int rc) #ifndef _WIN32_WCE case Z_ERRNO: return(strerror(errno)); #endif - case Z_NEED_DICT: return(ERR_ZLIB_NEED_DICT); - case Z_DATA_ERROR: return(ERR_ZLIB_DATA_ERROR); - case Z_MEM_ERROR: return(ERR_ZLIB_MEMORY_ERROR); - case Z_BUF_ERROR: return(ERR_ZLIB_BUFFER_ERROR); - case Z_VERSION_ERROR: return(ERR_ZLIB_VERSION_ERROR); - default: return(ERR_ZLIB_UNKNOWN_ERROR); + case Z_NEED_DICT: return(ERR_NEED_DICT); + case Z_DATA_ERROR: return(ERR_DATA_ERROR); + case Z_MEM_ERROR: return(ERR_MEMORY_ERROR); + case Z_BUF_ERROR: return(ERR_BUFFER_ERROR); + case Z_VERSION_ERROR: return(ERR_VERSION_ERROR); + default: return(ERR_UNKNOWN_ERROR); } /* switch */ return(NULL); diff --git a/configure.in b/configure.in index c037eeb3..1b7ad40e 100644 --- a/configure.in +++ b/configure.in @@ -143,7 +143,7 @@ require_lzma="no" dnl Check for lzma archiver inclusion... AC_ARG_ENABLE(lzma, -[ --enable-lzma enable lzma support [default=yes]], +[ --enable-lzma enable lzma support [default=yes]], , enable_lzma=yes) if test x$enable_lzma = xyes; then AC_DEFINE([PHYSFS_SUPPORTS_LZMA], 1, [define if lzma support is enabled]) diff --git a/lzma/7zAlloc.h b/lzma/7zAlloc.h new file mode 100644 index 00000000..fc8ebe8a --- /dev/null +++ b/lzma/7zAlloc.h @@ -0,0 +1,21 @@ +/* 7zAlloc.h */ + +#ifndef __7Z_ALLOC_H +#define __7Z_ALLOC_H + +#include + +typedef struct _ISzAlloc +{ + void *(*Alloc)(size_t size); + void (*Free)(void *address); /* address can be 0 */ +} ISzAlloc; + +void *SzAlloc(size_t size); +void SzFree(void *address); + +void *SzAllocTemp(size_t size); +void SzFreeTemp(void *address); + +#endif + diff --git a/lzma/7zDecode.c b/lzma/7zDecode.c index 73a14602..328d100d 100644 --- a/lzma/7zDecode.c +++ b/lzma/7zDecode.c @@ -1,7 +1,7 @@ /* 7zDecode.c */ #include "7zDecode.h" -#include "LzmaStateDecode.h" // NOTE : Modified to use LzmaStateDecode(.c,.h) instead of LzmaDecode(.c,.h) and hardcoded _SZ_ONE_DIRECTORY behaviour +#include "LzmaStateDecode.h" /* NOTE : Modified to use LzmaStateDecode(.c,.h) instead of LzmaDecode(.c,.h) and hardcoded _SZ_ONE_DIRECTORY behaviour */ CMethodID k_Copy = { { 0x0 }, 1 }; CMethodID k_LZMA = { { 0x3, 0x1, 0x1 }, 3 }; @@ -131,7 +131,7 @@ SZ_RESULT SzDecode(const CFileSize *packSizes, const CFolder *folder, inBuffer, (size_t)inSize, &inProcessed, #endif outBuffer, (size_t)outSize, &outSizeProcessedLoc, - 1); // NOTE : Added by Dennis Schridde to make SzDecode be compatible with LzmaStateDecode(.c,.h) + 1); /* NOTE : Added by Dennis Schridde to make SzDecode be compatible with LzmaStateDecode(.c,.h) */ *outSizeProcessed = (size_t)outSizeProcessedLoc; allocMain->Free(state.Probs); #ifdef _LZMA_OUT_READ diff --git a/lzma/LzmaStateDecode.h b/lzma/LzmaStateDecode.h index 52464d9a..87f8b2ec 100644 --- a/lzma/LzmaStateDecode.h +++ b/lzma/LzmaStateDecode.h @@ -38,7 +38,7 @@ #endif #endif -// NOTE : Hardcoded _LZMA_SYSTEM_SIZE_T behaviour by Dennis Schridde +/* NOTE : Hardcoded _LZMA_SYSTEM_SIZE_T behaviour by Dennis Schridde */ #include #ifdef _LZMA_PROB32 diff --git a/physfs_internal.h b/physfs_internal.h index d07ce497..c12dab8b 100644 --- a/physfs_internal.h +++ b/physfs_internal.h @@ -56,8 +56,8 @@ extern "C" { #define MVL_ARCHIVE_DESCRIPTION "Descent II Movielib format" #define QPAK_ARCHIVE_DESCRIPTION "Quake I/II format" #define ZIP_ARCHIVE_DESCRIPTION "PkZip/WinZip/Info-Zip compatible" - #define LZMA_ARCHIVE_DESCRIPTION "LZMA (7zip) format" #define WAD_ARCHIVE_DESCRIPTION "DOOM engine format" + #define LZMA_ARCHIVE_DESCRIPTION "LZMA (7zip) format" #define ERR_IS_INITIALIZED "Already initialized" #define ERR_NOT_INITIALIZED "Not initialized" @@ -155,7 +155,8 @@ extern "C" { #define MVL_ARCHIVE_DESCRIPTION "Descent II Movielib format" #define QPAK_ARCHIVE_DESCRIPTION "Quake I/II format" #define ZIP_ARCHIVE_DESCRIPTION "PkZip/WinZip/Info-Zip kompatibel" - #define WAD_ARCHIVE_DESCRIPTION "DOOM engine format" + #define WAD_ARCHIVE_DESCRIPTION "DOOM engine format" /* !!! FIXME: translate this line if needed */ + #define LZMA_ARCHIVE_DESCRIPTION "LZMA (7zip) format" /* !!! FIXME: translate this line if needed */ #define ERR_IS_INITIALIZED "Bereits initialisiert" #define ERR_NOT_INITIALIZED "Nicht initialisiert" @@ -190,12 +191,12 @@ extern "C" { #define ERR_BAD_FILENAME "Unzulssiger Dateiname" #define ERR_PHYSFS_BAD_OS_CALL "(BUG) PhysicsFS verursachte einen ungltigen Systemaufruf" #define ERR_ARGV0_IS_NULL "argv0 ist NULL" - #define ERR_NEED_DICT "brauche Wrterbuch" - #define ERR_DATA_ERROR "Datenfehler" - #define ERR_MEMORY_ERROR "Speicherfehler" - #define ERR_BUFFER_ERROR "Bufferfehler" - #define ERR_VERSION_ERROR "Versionskonflikt" - #define ERR_UNKNOWN_ERROR "Unbekannter Fehler" + #define ERR_NEED_DICT "brauche Wrterbuch" + #define ERR_DATA_ERROR "Datenfehler" + #define ERR_MEMORY_ERROR "Speicherfehler" + #define ERR_BUFFER_ERROR "Bufferfehler" + #define ERR_VERSION_ERROR "Versionskonflikt" + #define ERR_UNKNOWN_ERROR "Unbekannter Fehler" #define ERR_SEARCHPATH_TRUNC "Suchpfad war abgeschnitten" #define ERR_GETMODFN_TRUNC "GetModuleFileName() war abgeschnitten" #define ERR_GETMODFN_NO_DIR "GetModuleFileName() bekam kein Verzeichnis" @@ -252,7 +253,8 @@ extern "C" { #define HOG_ARCHIVE_DESCRIPTION "Descent I/II HOG file format" #define MVL_ARCHIVE_DESCRIPTION "Descent II Movielib format" #define ZIP_ARCHIVE_DESCRIPTION "PkZip/WinZip/Info-Zip " - #define WAD_ARCHIVE_DESCRIPTION "DOOM engine format" // !!! FIXME: translate this line if needed + #define WAD_ARCHIVE_DESCRIPTION "DOOM engine format" /* !!! FIXME: translate this line if needed */ + #define LZMA_ARCHIVE_DESCRIPTION "LZMA (7zip) format" /* !!! FIXME: translate this line if needed */ #define ERR_IS_INITIALIZED " " #define ERR_NOT_INITIALIZED " " @@ -287,12 +289,12 @@ extern "C" { #define ERR_BAD_FILENAME " " #define ERR_PHYSFS_BAD_OS_CALL "(BUG) PhysicsFS " #define ERR_ARGV0_IS_NULL "argv0 is NULL" - #define ERR_NEED_DICT " " - #define ERR_DATA_ERROR " " - #define ERR_MEMORY_ERROR " " - #define ERR_BUFFER_ERROR " " - #define ERR_VERSION_ERROR " " - #define ERR_UNKNOWN_ERROR " " + #define ERR_NEED_DICT " " + #define ERR_DATA_ERROR " " + #define ERR_MEMORY_ERROR " " + #define ERR_BUFFER_ERROR " " + #define ERR_VERSION_ERROR " " + #define ERR_UNKNOWN_ERROR " " #define ERR_SEARCHPATH_TRUNC " " #define ERR_GETMODFN_TRUNC "GetModuleFileName() " #define ERR_GETMODFN_NO_DIR "GetModuleFileName() " @@ -349,7 +351,8 @@ extern "C" { #define HOG_ARCHIVE_DESCRIPTION "Descent I/II HOG file format" #define MVL_ARCHIVE_DESCRIPTION "Descent II Movielib format" #define ZIP_ARCHIVE_DESCRIPTION "PkZip/WinZip/Info-Zip " - #define WAD_ARCHIVE_DESCRIPTION "DOOM engine format" // FIXME: translate this line if needed + #define WAD_ARCHIVE_DESCRIPTION "DOOM engine format" /* !!! FIXME: translate this line if needed */ + #define LZMA_ARCHIVE_DESCRIPTION "LZMA (7zip) format" /* !!! FIXME: translate this line if needed */ #define ERR_IS_INITIALIZED " " #define ERR_NOT_INITIALIZED " " @@ -384,12 +387,12 @@ extern "C" { #define ERR_BAD_FILENAME " " #define ERR_PHYSFS_BAD_OS_CALL "(BUG) PhysicsFS " #define ERR_ARGV0_IS_NULL "argv0 is NULL" - #define ERR_NEED_DICT " " - #define ERR_DATA_ERROR " " - #define ERR_MEMORY_ERROR " " - #define ERR_BUFFER_ERROR " " - #define ERR_VERSION_ERROR " " - #define ERR_UNKNOWN_ERROR " " + #define ERR_NEED_DICT " " + #define ERR_DATA_ERROR " " + #define ERR_MEMORY_ERROR " " + #define ERR_BUFFER_ERROR " " + #define ERR_VERSION_ERROR " " + #define ERR_UNKNOWN_ERROR " " #define ERR_SEARCHPATH_TRUNC " " #define ERR_GETMODFN_TRUNC "GetModuleFileName() " #define ERR_GETMODFN_NO_DIR "GetModuleFileName() " @@ -446,7 +449,8 @@ extern "C" { #define HOG_ARCHIVE_DESCRIPTION "Descent I/II HOG file format" #define MVL_ARCHIVE_DESCRIPTION "Descent II Movielib format" #define ZIP_ARCHIVE_DESCRIPTION "PkZip/WinZip/Info-Zip ᮢ⨬" - #define WAD_ARCHIVE_DESCRIPTION "DOOM engine format" // FIXME: Translate this line if needed + #define WAD_ARCHIVE_DESCRIPTION "DOOM engine format" /* !!! FIXME: translate this line if needed */ + #define LZMA_ARCHIVE_DESCRIPTION "LZMA (7zip) format" /* !!! FIXME: translate this line if needed */ #define ERR_IS_INITIALIZED " 樠஢" #define ERR_NOT_INITIALIZED " 樠஢" @@ -481,12 +485,12 @@ extern "C" { #define ERR_BAD_FILENAME "୮ 䠩" #define ERR_PHYSFS_BAD_OS_CALL "(BUG) PhysicsFS 믮 ⥬ 맮" #define ERR_ARGV0_IS_NULL "argv0 is NULL" - #define ERR_NEED_DICT "㦥 ᫮" - #define ERR_DATA_ERROR "訡 " - #define ERR_MEMORY_ERROR "訡 " - #define ERR_BUFFER_ERROR "訡 " - #define ERR_VERSION_ERROR "訡 ᨨ" - #define ERR_UNKNOWN_ERROR "⭠ 訡" + #define ERR_NEED_DICT "㦥 ᫮" + #define ERR_DATA_ERROR "訡 " + #define ERR_MEMORY_ERROR "訡 " + #define ERR_BUFFER_ERROR "訡 " + #define ERR_VERSION_ERROR "訡 ᨨ" + #define ERR_UNKNOWN_ERROR "⭠ 訡" #define ERR_SEARCHPATH_TRUNC " ᪠ १" #define ERR_GETMODFN_TRUNC "GetModuleFileName() १" #define ERR_GETMODFN_NO_DIR "GetModuleFileName() 稫 ⠫" @@ -543,7 +547,8 @@ extern "C" { #define HOG_ARCHIVE_DESCRIPTION "Descent I/II HOG file format" #define MVL_ARCHIVE_DESCRIPTION "Descent II Movielib format" #define ZIP_ARCHIVE_DESCRIPTION "PkZip/WinZip/Info-Zip " - #define WAD_ARCHIVE_DESCRIPTION "DOOM engine format" // FIXME: translate this line if needed + #define WAD_ARCHIVE_DESCRIPTION "DOOM engine format" /* !!! FIXME: translate this line if needed */ + #define LZMA_ARCHIVE_DESCRIPTION "LZMA (7zip) format" /* !!! FIXME: translate this line if needed */ #define ERR_IS_INITIALIZED " " #define ERR_NOT_INITIALIZED " " @@ -578,12 +583,12 @@ extern "C" { #define ERR_BAD_FILENAME " " #define ERR_PHYSFS_BAD_OS_CALL "(BUG) PhysicsFS " #define ERR_ARGV0_IS_NULL "argv0 is NULL" - #define ERR_NEED_DICT " " - #define ERR_DATA_ERROR " " - #define ERR_MEMORY_ERROR " " - #define ERR_BUFFER_ERROR " " - #define ERR_VERSION_ERROR " " - #define ERR_UNKNOWN_ERROR " " + #define ERR_NEED_DICT " " + #define ERR_DATA_ERROR " " + #define ERR_MEMORY_ERROR " " + #define ERR_BUFFER_ERROR " " + #define ERR_VERSION_ERROR " " + #define ERR_UNKNOWN_ERROR " " #define ERR_SEARCHPATH_TRUNC " " #define ERR_GETMODFN_TRUNC "GetModuleFileName() " #define ERR_GETMODFN_NO_DIR "GetModuleFileName() " @@ -643,6 +648,7 @@ extern "C" { #define QPAK_ARCHIVE_DESCRIPTION "Quake I/II format" #define ZIP_ARCHIVE_DESCRIPTION "Compatible PkZip/WinZip/Info-Zip" #define WAD_ARCHIVE_DESCRIPTION "Format WAD du moteur DOOM" + #define LZMA_ARCHIVE_DESCRIPTION "LZMA (7zip) format" /* !!! FIXME: translate this line if needed */ #define ERR_IS_INITIALIZED "Dj initialis" #define ERR_NOT_INITIALIZED "Non initialis" @@ -677,12 +683,12 @@ extern "C" { #define ERR_BAD_FILENAME "Mauvais nom de fichier" #define ERR_PHYSFS_BAD_OS_CALL "(BOGUE) PhysicsFS a fait un mauvais appel systme, le salaud" #define ERR_ARGV0_IS_NULL "argv0 est NULL" - #define ERR_NEED_DICT "a besoin du dico" - #define ERR_DATA_ERROR "erreur de donnes" - #define ERR_MEMORY_ERROR "erreur mmoire" - #define ERR_BUFFER_ERROR "erreur tampon" - #define ERR_VERSION_ERROR "erreur de version" - #define ERR_UNKNOWN_ERROR "erreur inconnue" + #define ERR_NEED_DICT "a besoin du dico" + #define ERR_DATA_ERROR "erreur de donnes" + #define ERR_MEMORY_ERROR "erreur mmoire" + #define ERR_BUFFER_ERROR "erreur tampon" + #define ERR_VERSION_ERROR "erreur de version" + #define ERR_UNKNOWN_ERROR "erreur inconnue" #define ERR_SEARCHPATH_TRUNC "Le chemin de recherche a t tronqu" #define ERR_GETMODFN_TRUNC "GetModuleFileName() a t tronqu" #define ERR_GETMODFN_NO_DIR "GetModuleFileName() n'a pas de rpertoire" @@ -741,6 +747,8 @@ extern "C" { #define QPAK_ARCHIVE_DESCRIPTION "Formato Quake I/II" #define ZIP_ARCHIVE_DESCRIPTION "Formato compatvel PkZip/WinZip/Info-Zip" #define WAD_ARCHIVE_DESCRIPTION "Formato WAD do engine DOOM" + #define WAD_ARCHIVE_DESCRIPTION "DOOM engine format" /* !!! FIXME: translate this line if needed */ + #define LZMA_ARCHIVE_DESCRIPTION "LZMA (7zip) format" /* !!! FIXME: translate this line if needed */ #define ERR_IS_INITIALIZED "J inicializado" #define ERR_NOT_INITIALIZED "No inicializado" @@ -775,12 +783,12 @@ extern "C" { #define ERR_BAD_FILENAME "Nome de arquivo invlido" #define ERR_PHYSFS_BAD_OS_CALL "(BUG) PhysicsFS realizou uma chamada de sistema invlida" #define ERR_ARGV0_IS_NULL "argv0 NULL" - #define ERR_NEED_DICT "precisa de diretrio" - #define ERR_DATA_ERROR "erro nos dados" - #define ERR_MEMORY_ERROR "erro de memria" - #define ERR_BUFFER_ERROR "erro de buffer" - #define ERR_VERSION_ERROR "erro na version" - #define ERR_UNKNOWN_ERROR "erro desconhecido" + #define ERR_NEED_DICT "precisa de diretrio" + #define ERR_DATA_ERROR "erro nos dados" + #define ERR_MEMORY_ERROR "erro de memria" + #define ERR_BUFFER_ERROR "erro de buffer" + #define ERR_VERSION_ERROR "erro na version" + #define ERR_UNKNOWN_ERROR "erro desconhecido" #define ERR_SEARCHPATH_TRUNC "Caminho de procura quebrado" #define ERR_GETMODFN_TRUNC "GetModuleFileName() foi quebrado" #define ERR_GETMODFN_NO_DIR "GetModuleFileName() nao teve diretrio" @@ -838,6 +846,8 @@ extern "C" { #define MVL_ARCHIVE_DESCRIPTION "Formato Descent II Movielib" #define QPAK_ARCHIVE_DESCRIPTION "Formato Quake I/II" #define ZIP_ARCHIVE_DESCRIPTION "Compatible con PkZip/WinZip/Info-Zip" + #define WAD_ARCHIVE_DESCRIPTION "DOOM engine format" /* !!! FIXME: translate this line if needed */ + #define LZMA_ARCHIVE_DESCRIPTION "LZMA (7zip) format" /* !!! FIXME: translate this line if needed */ #define ERR_IS_INITIALIZED "Ya estaba inicializado" #define ERR_NOT_INITIALIZED "No est inicializado" @@ -872,12 +882,12 @@ extern "C" { #define ERR_BAD_FILENAME "Nombre de archivo incorrecto" #define ERR_PHYSFS_BAD_OS_CALL "(BUG) PhysicsFS ha hecho una llamada incorrecta al sistema" #define ERR_ARGV0_IS_NULL "argv0 es NULL" - #define ERR_NEED_DICT "necesito diccionario" - #define ERR_DATA_ERROR "error de datos" - #define ERR_MEMORY_ERROR "error de memoria" - #define ERR_BUFFER_ERROR "error de buffer" - #define ERR_VERSION_ERROR "error de versin" - #define ERR_UNKNOWN_ERROR "error desconocido" + #define ERR_NEED_DICT "necesito diccionario" + #define ERR_DATA_ERROR "error de datos" + #define ERR_MEMORY_ERROR "error de memoria" + #define ERR_BUFFER_ERROR "error de buffer" + #define ERR_VERSION_ERROR "error de versin" + #define ERR_UNKNOWN_ERROR "error desconocido" #define ERR_SEARCHPATH_TRUNC "La ruta de bsqueda ha sido truncada" #define ERR_GETMODFN_TRUNC "GetModuleFileName() ha sido truncado" #define ERR_GETMODFN_NO_DIR "GetModuleFileName() no tenia directorio"