1 /* 2 * Copyright (C) 2005 Janusz Dziemidowicz (rraptorr@nails.eu.org) 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 */ 18 19 /*! 20 * \file wad2.h 21 * \author Janusz Dziemidowicz 22 * \brief WAD2 file support header file. 23 */ 24 25 #ifndef _WAD2_H_ 26 #define _WAD2_H_ 27 28 #define _GNU_SOURCE 29 30 #include <string.h> 31 #include <unistd.h> 32 #include <stdlib.h> 33 #include <stdio.h> 34 #include <errno.h> 35 36 #include <pthread.h> 37 #include <sys/types.h> 38 #include <sys/stat.h> 39 #include <fcntl.h> 40 41 #include "fusepak.h" 42 43 /*! 44 * \brief Header of the WAD2 file. 45 * 46 * This structures describes the header that can be found on the 47 * beginning of every WAD2 file. WAD2 files are simple archives (no 48 * compression at all) used by many games using idSoftware's engine 49 * (Quake). 50 */ 51 struct wad2_header { 52 /*! 53 * \brief WAD2 file identification. 54 * 55 * Legitimate WAD2 file should contain string "WAD2" here. 56 */ 57 char magic[4]; 58 59 /*! 60 * \brief Number of entries. 61 * 62 * This is the number of \c wad2_entry structures under \c 63 * dir_offset offset in the WAD2 file. 64 */ 65 uint32_t dir_size; 66 67 /*! 68 * \brief Position of directory from start of file 69 * 70 * This is the offset from beginning of the WAD2 file. Under 71 * this offset there will be \a dir_size \c wad2_entry 72 * structures. 73 */ 74 uint32_t dir_offset; 75 }; 76 77 /*! 78 * \brief One entry (file) inside of WAD2 file. 79 * 80 * This structures describes one entry inside of WAD2 file. In fact 81 * this entry should be considered as a file (although it is also 82 * called a lump). 83 */ 84 struct wad2_entry { 85 /*! 86 * \brief Offset of file inside of WAD2 file. 87 * 88 * This field defines at what offset the file described by \c 89 * wad2_entry can be found inside of WAD2 file. 90 */ 91 uint32_t offset; 92 93 /*! 94 * \brief Size of file in WAD2 file. 95 * 96 * This field describes size of the file described in \c 97 * wad2_entry inside of WAD2 file. 98 */ 99 uint32_t dsize; 100 101 /*! 102 * \brief Size of file in memory. 103 */ 104 uint32_t size; 105 106 /*! 107 * \brief Type of file. 108 */ 109 char type; 110 111 /*! 112 * \brief Compression type. 113 */ 114 char compression; 115 116 /*! 117 * \brief Unused. 118 */ 119 uint16_t dummy; 120 121 /*! 122 * \brief Filename. 123 124 * Name of the file. Padded with zeroes. Maximum filename 125 * length is 16. There is no directory structure (implicit or 126 * explicit) in WAD2 files. 127 */ 128 char filename[16]; 129 }; 130 131 /*! 132 * \brief Structure \c fusepak_format describing WAD2 format. 133 */ 134 extern struct fusepak_format fusepak_wad2; 135 136 #endif // _WAD2_H_ 137