]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - libs/pakstuff.h
fix unzip code
[xonotic/netradiant.git] / libs / pakstuff.h
index 4c709cae27abd4a16013cc20a334d819812ee6bb..a2ace159f04d2ad60b0a13f9b08bd8adcead8944 100644 (file)
-/*\r
-Copyright (C) 1999-2007 id Software, Inc. and contributors.\r
-For a list of contributors, see the accompanying CONTRIBUTORS file.\r
-\r
-This file is part of GtkRadiant.\r
-\r
-GtkRadiant is free software; you can redistribute it and/or modify\r
-it under the terms of the GNU General Public License as published by\r
-the Free Software Foundation; either version 2 of the License, or\r
-(at your option) any later version.\r
-\r
-GtkRadiant is distributed in the hope that it will be useful,\r
-but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-GNU General Public License for more details.\r
-\r
-You should have received a copy of the GNU General Public License\r
-along with GtkRadiant; if not, write to the Free Software\r
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\r
-*/\r
-\r
-#ifndef _PAKSTUFF_H_\r
-#define _PAKSTUFF_H_\r
-\r
-#ifndef _WIN32\r
-#define WINAPI\r
-#else\r
-#include <windows.h>\r
-#endif\r
-\r
-#ifndef __cplusplus\r
-typedef int bool; // leo\r
-#endif\r
-\r
-#ifdef __cplusplus\r
-extern "C"\r
-{\r
-#endif\r
-\r
-typedef char           Int8;\r
-typedef short          Int16;\r
-typedef long           Int32;\r
-typedef unsigned char  UInt8;\r
-typedef unsigned short UInt16;\r
-typedef unsigned long  UInt32;\r
-typedef float          Float32;\r
-typedef double         Float64;\r
-#define MAX(a, b)              (((a) > (b)) ? (a) : (b))\r
-#define MIN(a, b)              (((a) < (b)) ? (a) : (b))\r
-#define RANDOM(x)              (random() % (x))\r
-#define RANDOMIZE()             srand((int) time(NULL))\r
-\r
-#define FTYPE_UNKNOWN 0\r
-#define FTYPE_IWAD    1    /* .wad  "IWAD" */\r
-#define FTYPE_PWAD    2    /* .wad  "PWAD" */\r
-#define FTYPE_PACK    3    /* .pak  "PACK" */\r
-#define FTYPE_WAD2    4    /* .wad  "WAD2" */\r
-#define FTYPE_BSP     10   /* .bsp  (0x17 0x00 0x00 0x00) */\r
-#define FTYPE_MODEL   11   /* .mdl  "IDPO" */\r
-#define FTYPE_SPRITE  12   /* .spr  "IDSP" */\r
-#define FTYPE_WAV     20   /* .wav  "RIFF" */\r
-#define FTYPE_AU      21   /* .au   ".snd" */\r
-#define FTYPE_VOC     22   /* .voc  ?      */\r
-#define FTYPE_PBM_ASC 30   /* .pbm  "P1"   */\r
-#define FTYPE_PGM_ASC 31   /* .pgm  "P2"   */\r
-#define FTYPE_PPM_ASC 32   /* .ppm  "P3"   */\r
-#define FTYPE_PBM_RAW 33   /* .pbm  "P4"   */\r
-#define FTYPE_PGM_RAW 34   /* .pgm  "P5"   */\r
-#define FTYPE_PPM_RAW 35   /* .ppm  "P6"   */\r
-#define FTYPE_BMP     36   /* .bmp  "BM"   */\r
-#define FTYPE_GIF     37   /* .gif  "GIF8" */\r
-#define FTYPE_PCX     38   /* .pcx  (0x0a 0x05 0x01 0x08) */\r
-#define FTYPE_ERROR   -1\r
-\r
-#ifdef FAT_ENDIAN\r
-Bool   ReadInt16               (FILE *file, UInt16 huge *x);\r
-Bool   ReadInt32               (FILE *file, UInt32 huge *x);\r
-Bool   ReadFloat32             (FILE *file, Float32 huge *x);\r
-Bool   WriteInt16              (FILE *file, UInt16 huge *x);\r
-Bool   WriteInt32              (FILE *file, UInt32 huge *x);\r
-Bool   WriteFloat32    (FILE *file, Float32 huge *x);\r
-UInt16 SwapInt16               (UInt16 x);\r
-UInt32 SwapInt32               (UInt32 x);\r
-Float32        SwapFloat32             (Float32 x);\r
-#else\r
-#define ReadInt16(f, p)                ReadBytes((f), (p), 2L)\r
-#define ReadInt32(f, p)                ReadBytes((f), (p), 4L)\r
-#define ReadFloat32(f, p)      ReadBytes((f), (p), 4L)\r
-#define WriteInt16(f, p)       WriteBytes((f), (p), 2L)\r
-#define WriteInt32(f, p)       WriteBytes((f), (p), 4L)\r
-#define WriteFloat32(f, p)     WriteBytes((f), (p), 4L)\r
-#define SwapInt16(x)           (x)\r
-#define SwapInt32(x)           (x)\r
-#define SwapFloat32(x)         (x)\r
-#endif /* FAT_ENDIAN */\r
-\r
-#define FROMDISK       -1\r
-struct PACKDirectory\r
-{\r
-   char   name[56];             /* name of file */\r
-   UInt32 offset;               /* offset to start of data */\r
-   UInt32 size;                 /* byte size of data */\r
-};\r
-typedef struct PACKDirectory *PACKDirPtr;\r
-\r
-typedef struct DirListStruct\r
-{\r
-       char                                    dirname[1024];\r
-       int                                             from;\r
-       struct  DirListStruct   *next;\r
-} DIRLIST;\r
-\r
-typedef struct FileListStruct\r
-{\r
-       char                                    filename[1024];\r
-       UInt32                                  offset;\r
-       UInt32                                  size;\r
-       struct  FileListStruct  *next;\r
-} FILELIST;\r
-\r
-typedef struct DirStruct\r
-{\r
-       char                            name[1024];\r
-       FILELIST                        *files;\r
-       struct DirStruct        *next;\r
-} DIRECTORY;\r
-\r
-\r
-extern int m_nPAKIndex;\r
-extern FILE* pakfile[16];\r
-extern bool pakopen;\r
-extern DIRECTORY       *paktextures;\r
-\r
-void ClearFileList                             (FILELIST **);\r
-void ClearDirList                              (DIRLIST **);\r
-bool GetPackFileList                           (FILELIST **, char *);\r
-bool GetPackTextureDirs                        (DIRLIST **);\r
-bool AddToDirListAlphabetized  (DIRLIST **, char *, int);\r
-bool AddToFileListAlphabetized (FILELIST **t, char *, UInt32, UInt32, bool);\r
-bool PakLoadFile                                       (const char *, void **);\r
-void OpenPakFile                                       (const char *);\r
-void ClosePakFile                              (void);\r
-int  PakLoadAnyFile(const char *filename, void **bufferptr);\r
-void WINAPI InitPakFile(const char * pBasePath, const char *pName);\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-#endif\r
+/*
+   Copyright (C) 1999-2007 id Software, Inc. and contributors.
+   For a list of contributors, see the accompanying CONTRIBUTORS file.
+
+   This file is part of GtkRadiant.
+
+   GtkRadiant is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   GtkRadiant is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GtkRadiant; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef _PAKSTUFF_H_
+#define _PAKSTUFF_H_
+
+#ifndef _WIN32
+#define WINAPI
+#else
+#include <windows.h>
+#endif
+
+#ifndef __cplusplus
+typedef int bool; // leo
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+typedef char Int8;
+typedef short Int16;
+typedef long Int32;
+typedef unsigned char UInt8;
+typedef unsigned short UInt16;
+typedef unsigned long UInt32;
+typedef float Float32;
+typedef double Float64;
+#define MAX( a, b )              ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) )
+#define MIN( a, b )              ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) )
+#define RANDOM( x )              ( random() % ( x ) )
+#define RANDOMIZE()             srand( (int) time( NULL ) )
+
+#define FTYPE_UNKNOWN 0
+#define FTYPE_IWAD    1    /* .wad  "IWAD" */
+#define FTYPE_PWAD    2    /* .wad  "PWAD" */
+#define FTYPE_PACK    3    /* .pak  "PACK" */
+#define FTYPE_WAD2    4    /* .wad  "WAD2" */
+#define FTYPE_BSP     10   /* .bsp  (0x17 0x00 0x00 0x00) */
+#define FTYPE_MODEL   11   /* .mdl  "IDPO" */
+#define FTYPE_SPRITE  12   /* .spr  "IDSP" */
+#define FTYPE_WAV     20   /* .wav  "RIFF" */
+#define FTYPE_AU      21   /* .au   ".snd" */
+#define FTYPE_VOC     22   /* .voc  ?      */
+#define FTYPE_PBM_ASC 30   /* .pbm  "P1"   */
+#define FTYPE_PGM_ASC 31   /* .pgm  "P2"   */
+#define FTYPE_PPM_ASC 32   /* .ppm  "P3"   */
+#define FTYPE_PBM_RAW 33   /* .pbm  "P4"   */
+#define FTYPE_PGM_RAW 34   /* .pgm  "P5"   */
+#define FTYPE_PPM_RAW 35   /* .ppm  "P6"   */
+#define FTYPE_BMP     36   /* .bmp  "BM"   */
+#define FTYPE_GIF     37   /* .gif  "GIF8" */
+#define FTYPE_PCX     38   /* .pcx  (0x0a 0x05 0x01 0x08) */
+#define FTYPE_ERROR   -1
+
+#ifdef FAT_ENDIAN
+Bool    ReadInt16( FILE *file, UInt16 huge *x );
+Bool    ReadInt32( FILE *file, UInt32 huge *x );
+Bool    ReadFloat32( FILE *file, Float32 huge *x );
+Bool    WriteInt16( FILE *file, UInt16 huge *x );
+Bool    WriteInt32( FILE *file, UInt32 huge *x );
+Bool    WriteFloat32( FILE *file, Float32 huge *x );
+UInt16  SwapInt16( UInt16 x );
+UInt32  SwapInt32( UInt32 x );
+Float32 SwapFloat32( Float32 x );
+#else
+#define ReadInt16( f, p )     ReadBytes( ( f ), ( p ), 2L )
+#define ReadInt32( f, p )     ReadBytes( ( f ), ( p ), 4L )
+#define ReadFloat32( f, p )   ReadBytes( ( f ), ( p ), 4L )
+#define WriteInt16( f, p )    WriteBytes( ( f ), ( p ), 2L )
+#define WriteInt32( f, p )    WriteBytes( ( f ), ( p ), 4L )
+#define WriteFloat32( f, p )  WriteBytes( ( f ), ( p ), 4L )
+#define SwapInt16( x )        ( x )
+#define SwapInt32( x )        ( x )
+#define SwapFloat32( x )      ( x )
+#endif /* FAT_ENDIAN */
+
+#define FROMDISK    -1
+struct PACKDirectory
+{
+       char name[56];              /* name of file */
+       UInt32 offset;              /* offset to start of data */
+       UInt32 size;                /* byte size of data */
+};
+typedef struct PACKDirectory *PACKDirPtr;
+
+typedef struct DirListStruct
+{
+       char dirname[1024];
+       int from;
+       struct  DirListStruct   *next;
+} DIRLIST;
+
+typedef struct FileListStruct
+{
+       char filename[1024];
+       UInt32 offset;
+       UInt32 size;
+       struct  FileListStruct  *next;
+} FILELIST;
+
+typedef struct DirStruct
+{
+       char name[1024];
+       FILELIST            *files;
+       struct DirStruct    *next;
+} DIRECTORY;
+
+
+extern int m_nPAKIndex;
+extern FILE* pakfile[16];
+extern bool pakopen;
+extern DIRECTORY    *paktextures;
+
+void ClearFileList( FILELIST ** );
+void ClearDirList( DIRLIST ** );
+bool GetPackFileList( FILELIST **, char * );
+bool GetPackTextureDirs( DIRLIST ** );
+bool AddToDirListAlphabetized( DIRLIST **, char *, int );
+bool AddToFileListAlphabetized( FILELIST * *t, char *, UInt32, UInt32, bool );
+bool PakLoadFile( const char *, void ** );
+void OpenPakFile( const char * );
+void ClosePakFile( void );
+int  PakLoadAnyFile( const char *filename, void **bufferptr );
+void WINAPI InitPakFile( const char * pBasePath, const char *pName );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif