Skip to content
Permalink
Browse files
Natural language #defines and build system support.
  • Loading branch information
icculus committed Jul 28, 2002
1 parent 2086e0e commit 42be0046aabd350901d9bc97e13de857ced43b48
Showing with 262 additions and 281 deletions.
  1. +1 −1 archivers/dir.c
  2. +1 −1 archivers/grp.c
  3. +22 −35 archivers/zip.c
  4. +28 −1 configure.in
  5. +1 −1 physfs.c
  6. +111 −32 physfs_internal.h
  7. +46 −46 platform/macclassic.c
  8. +48 −160 platform/os2.c
  9. +4 −4 platform/win32.c
@@ -49,7 +49,7 @@ static void DIR_dirClose(DirHandle *h);
const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_DIR =
{
"",
"non-archive directory I/O",
DIR_ARCHIVE_DESCRIPTION,
"Ryan C. Gordon <icculus@clutteredmind.org>",
"http://icculus.org/physfs/",
};
@@ -93,7 +93,7 @@ static FileHandle *GRP_openRead(DirHandle *h, const char *name);
const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_GRP =
{
"GRP",
"Build engine Groupfile format",
GRP_ARCHIVE_DESCRIPTION,
"Ryan C. Gordon <icculus@clutteredmind.org>",
"http://icculus.org/physfs/",
};
@@ -147,7 +147,7 @@ static int zip_resolve(void *in, ZIPinfo *info, ZIPentry *entry);
const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_ZIP =
{
"ZIP",
"PkZip/WinZip/Info-Zip compatible",
ZIP_ARCHIVE_DESCRIPTION,
"Ryan C. Gordon <icculus@clutteredmind.org>",
"http://icculus.org/physfs/",
};
@@ -183,46 +183,33 @@ const DirFunctions __PHYSFS_DirFunctions_ZIP =
};


/*
* Wrap all zlib calls in this, so the physfs error state is set appropriately.
*/
static int zlib_err(int rc)
static const char *zlib_error_string(int rc)
{
const char *err = NULL;

switch (rc)
{
case Z_OK:
case Z_STREAM_END:
break; /* not errors. */

case Z_ERRNO:
err = strerror(errno);
break;

case Z_NEED_DICT:
err = "zlib: need dictionary";
break;
case Z_DATA_ERROR:
err = "zlib: need dictionary";
break;
case Z_MEM_ERROR:
err = "zlib: memory error";
break;
case Z_BUF_ERROR:
err = "zlib: buffer error";
break;
case Z_VERSION_ERROR:
err = "zlib: version error";
break;
default:
err = "unknown zlib error";
break;
case Z_OK: return(NULL); /* not an error. */
case Z_STREAM_END: return(NULL); /* not an error. */
case Z_ERRNO: return(strerror(errno));
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);
} /* switch */

if (err != NULL)
__PHYSFS_setError(err);
return(NULL);
} /* zlib_error_string */


/*
* Wrap all zlib calls in this, so the physfs error state is set appropriately.
*/
static int zlib_err(int rc)
{
const char *str = zlib_error_string(rc);
if (str != NULL)
__PHYSFS_setError(str);
return(rc);
} /* zlib_err */

@@ -229,9 +229,36 @@ if test x$enable_cdrom = xyes; then
fi
fi

dnl determine language.
physfslang=english
AC_ARG_ENABLE(language,
[ --enable-language=lang English, currently. [default=english]],
physfslang=`echo $enable_language |tr A-Z a-z`)

AC_MSG_CHECKING([if language choice is supported])
physfs_valid_lang=no
if test x$physfslang = xenglish; then
physfs_valid_lang=yes
AC_DEFINE([PHYSFS_LANG], PHYSFS_LANG_ENGLISH, [define desired natural language])
fi

dnl Add other language checks here...

AC_MSG_RESULT([$physfs_valid_lang])
if test x$physfs_valid_lang = xno; then
AC_MSG_WARN([***])
AC_MSG_WARN([*** You've asked for "$physfslang" language support...])
AC_MSG_WARN([*** ...but we don't support that.])
AC_MSG_WARN([*** You could choose another language,])
AC_MSG_WARN([*** but is this what you REALLY wanted?])
AC_MSG_WARN([*** Please see the LANG section of physfs_internal.h])
AC_MSG_WARN([*** for info on writing a translation.])
AC_MSG_WARN([***])
AC_MSG_ERROR([*** unsupported language. stop.])
fi

have_non_posix_threads=no

dnl AC_CHECK_HEADER(be/kernel/OS.h, this_is_beos=yes)
AC_MSG_CHECKING([if this is BeOS])
if test x$build_os = xbeos; then
this_is_beos=yes
@@ -824,7 +824,7 @@ int PHYSFS_setSaneConfig(const char *organization, const char *appName,
/* Root out archives, and add them to search path... */
if (archiveExt != NULL)
{
char **rc = PHYSFS_enumerateFiles("");
char **rc = PHYSFS_enumerateFiles("/");
char **i;
size_t extlen = strlen(archiveExt);
char *ext;
@@ -20,6 +20,117 @@
extern "C" {
#endif


/* The LANG section. */
/* please send questions/translations to Ryan: icculus@clutteredmind.org. */

#if (!defined PHYSFS_LANG)
# define PHYSFS_LANG PHYSFS_LANG_ENGLISH
#endif

#define PHYSFS_LANG_ENGLISH 1 /* English text by Ryan C. Gordon */


#if (PHYSFS_LANG == PHYSFS_LANG_ENGLISH)
#define DIR_ARCHIVE_DESCRIPTION "Non-archive, direct filesystem I/O"
#define GRP_ARCHIVE_DESCRIPTION "Build engine Groupfile format"
#define ZIP_ARCHIVE_DESCRIPTION "PkZip/WinZip/Info-Zip compatible"

#define ERR_IS_INITIALIZED "Already initialized"
#define ERR_NOT_INITIALIZED "Not initialized"
#define ERR_INVALID_ARGUMENT "Invalid argument"
#define ERR_FILES_STILL_OPEN "Files still open"
#define ERR_NO_DIR_CREATE "Failed to create directories"
#define ERR_OUT_OF_MEMORY "Out of memory"
#define ERR_NOT_IN_SEARCH_PATH "No such entry in search path"
#define ERR_NOT_SUPPORTED "Operation not supported"
#define ERR_UNSUPPORTED_ARCHIVE "Archive type unsupported"
#define ERR_NOT_A_HANDLE "Not a file handle"
#define ERR_INSECURE_FNAME "Insecure filename"
#define ERR_SYMLINK_DISALLOWED "Symbolic links are disabled"
#define ERR_NO_WRITE_DIR "Write directory is not set"
#define ERR_NO_SUCH_FILE "File not found"
#define ERR_NO_SUCH_PATH "Path not found"
#define ERR_NO_SUCH_VOLUME "Volume not found"
#define ERR_PAST_EOF "Past end of file"
#define ERR_ARC_IS_READ_ONLY "Archive is read-only"
#define ERR_IO_ERROR "I/O error"
#define ERR_CANT_SET_WRITE_DIR "Can't set write directory"
#define ERR_SYMLINK_LOOP "Infinite symbolic link loop"
#define ERR_COMPRESSION "(De)compression error"
#define ERR_NOT_IMPLEMENTED "Not implemented"
#define ERR_OS_ERROR "Operating system reported error"
#define ERR_FILE_EXISTS "File already exists"
#define ERR_NOT_A_FILE "Not a file"
#define ERR_NOT_A_DIR "Not a directory"
#define ERR_NOT_AN_ARCHIVE "Not an archive"
#define ERR_CORRUPTED "Corrupted archive"
#define ERR_SEEK_OUT_OF_RANGE "Seek out of range"
#define ERR_BAD_FILENAME "Bad filename"
#define ERR_PHYSFS_BAD_OS_CALL "(BUG) PhysicsFS made a bad system call"
#define ERR_ARGV0_IS_NULL "argv0 is NULL"
#define ERR_ZLIB_NEED_DICT "zlib: need dictionary"
#define ERR_ZLIB_DATA_ERROR "zlib: data error"
#define ERR_ZLIB_MEMORY_ERROR "zlib: memory error"
#define ERR_ZLIB_BUFFER_ERROR "zlib: buffer error"
#define ERR_ZLIB_VERSION_ERROR "zlib: version error"
#define ERR_ZLIB_UNKNOWN_ERROR "zlib: unknown error"
#define ERR_SEARCHPATH_TRUNC "Search path was truncated"
#define ERR_GETMODFN_TRUNC "GetModuleFileName() was truncated"
#define ERR_GETMODFN_NO_DIR "GetModuleFileName() had no dir"
#define ERR_DISK_FULL "Disk is full"
#define ERR_DIRECTORY_FULL "Directory full"
#define ERR_MACOS_GENERIC "MacOS reported error (%d)"
#define ERR_OS2_GENERIC "OS/2 reported error (%d)"
#define ERR_VOL_LOCKED_HW "Volume is locked through hardware"
#define ERR_VOL_LOCKED_SW "Volume is locked through software"
#define ERR_FILE_LOCKED "File is locked"
#define ERR_FILE_OR_DIR_BUSY "File/directory is busy"
#define ERR_FILE_ALREADY_OPEN_W "File already open for writing"
#define ERR_FILE_ALREADY_OPEN_R "File already open for reading"
#define ERR_INVALID_REFNUM "Invalid reference number"
#define ERR_GETTING_FILE_POS "Error getting file position"
#define ERR_VOLUME_OFFLINE "Volume is offline"
#define ERR_PERMISSION_DENIED "Permission denied"
#define ERR_VOL_ALREADY_ONLINE "Volume already online"
#define ERR_NO_SUCH_DRIVE "No such drive"
#define ERR_NOT_MAC_DISK "Not a Macintosh disk"
#define ERR_VOL_EXTERNAL_FS "Volume belongs to an external filesystem"
#define ERR_PROBLEM_RENAME "Problem during rename"
#define ERR_BAD_MASTER_BLOCK "Bad master directory block"
#define ERR_CANT_MOVE_FORBIDDEN "Attempt to move forbidden"
#define ERR_WRONG_VOL_TYPE "Wrong volume type"
#define ERR_SERVER_VOL_LOST "Server volume has been disconnected"
#define ERR_FILE_ID_NOT_FOUND "File ID not found"
#define ERR_FILE_ID_EXISTS "File ID already exists"
#define ERR_SERVER_NO_RESPOND "Server not responding"
#define ERR_USER_AUTH_FAILED "User authentication failed"
#define ERR_PWORD_EXPIRED "Password has expired on server"
#define ERR_ACCESS_DENIED "Access denied"
#define ERR_NOT_A_DOS_DISK "Not a DOS disk"
#define ERR_SHARING_VIOLATION "Sharing violation"
#define ERR_CANNOT_MAKE "Cannot make"
#define ERR_DEV_IN_USE "Device already in use"
#define ERR_OPEN_FAILED "Open failed"
#define ERR_PIPE_BUSY "Pipe is busy"
#define ERR_SHARING_BUF_EXCEEDED "Sharing buffer exceeded"
#define ERR_TOO_MANY_HANDLES "Too many open handles"
#define ERR_SEEK_ERROR "Seek error"
#define ERR_DEL_CWD "Trying to delete current working directory"
#define ERR_WRITE_PROTECT_ERROR "Write protect error"
#define ERR_WRITE_FAULT "Write fault"
#define ERR_LOCK_VIOLATION "Lock violation"
#define ERR_GEN_FAILURE "General failure"
#define ERR_UNCERTAIN_MEDIA "Uncertain media"
#define ERR_PROT_VIOLATION "Protection violation"
#define ERR_BROKEN_PIPE "Broken pipe"
#else
#error Please define PHYSFS_LANG.
#endif

/* end LANG section. */


struct __PHYSFS_DIRHANDLE__;
struct __PHYSFS_FILEFUNCTIONS__;

@@ -252,38 +363,6 @@ typedef struct __PHYSFS_DIRFUNCTIONS__
} DirFunctions;


/* error messages... */
#define ERR_IS_INITIALIZED "Already initialized"
#define ERR_NOT_INITIALIZED "Not initialized"
#define ERR_INVALID_ARGUMENT "Invalid argument"
#define ERR_FILES_STILL_OPEN "Files still open"
#define ERR_NO_DIR_CREATE "Failed to create directories"
#define ERR_OUT_OF_MEMORY "Out of memory"
#define ERR_NOT_IN_SEARCH_PATH "No such entry in search path"
#define ERR_NOT_SUPPORTED "Operation not supported"
#define ERR_UNSUPPORTED_ARCHIVE "Archive type unsupported"
#define ERR_NOT_A_HANDLE "Not a file handle"
#define ERR_INSECURE_FNAME "Insecure filename"
#define ERR_SYMLINK_DISALLOWED "Symbolic links are disabled"
#define ERR_NO_WRITE_DIR "Write directory is not set"
#define ERR_NO_SUCH_FILE "No such file"
#define ERR_PAST_EOF "Past end of file"
#define ERR_ARC_IS_READ_ONLY "Archive is read-only"
#define ERR_IO_ERROR "I/O error"
#define ERR_CANT_SET_WRITE_DIR "Can't set write directory"
#define ERR_SYMLINK_LOOP "Infinite symbolic link loop"
#define ERR_COMPRESSION "(De)compression error"
#define ERR_NOT_IMPLEMENTED "Not implemented"
#define ERR_OS_ERROR "Operating system reported error"
#define ERR_FILE_EXISTS "File already exists"
#define ERR_NOT_A_DIR "Not a directory"
#define ERR_FILE_NOT_FOUND "File not found"
#define ERR_NOT_AN_ARCHIVE "Not an archive"
#define ERR_CORRUPTED "Corrupted archive"
#define ERR_SEEK_OUT_OF_RANGE "Seek out of range"
#define ERR_BAD_FILENAME "Bad filename"


/*
* Call this to set the message returned by PHYSFS_getLastError().
* Please only use the ERR_* constants above, or add new constants to the

0 comments on commit 42be004

Please sign in to comment.