Updated Copyright year to 2013
[getmangos.git] / contrib / extractor / loadlib / loadlib.h
blobc19700bc2222f36fcab851220ac5e89df35d5b0c
1 /*
2 * Copyright (C) 2005-2013 MaNGOS <http://getmangos.com/>
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.
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.
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
19 #ifndef LOAD_LIB_H
20 #define LOAD_LIB_H
22 #ifdef _DLL
23 #undef _DLL
24 #endif
26 #include "StormLib.h"
27 #include <deque>
29 #ifdef WIN32
30 typedef __int64 int64;
31 typedef __int32 int32;
32 typedef __int16 int16;
33 typedef __int8 int8;
34 typedef unsigned __int64 uint64;
35 typedef unsigned __int32 uint32;
36 typedef unsigned __int16 uint16;
37 typedef unsigned __int8 uint8;
38 #else
39 #include <stdint.h>
40 #ifndef uint64_t
41 #ifdef __linux__
42 #include <linux/types.h>
43 #endif
44 #endif
45 typedef int64_t int64;
46 typedef int32_t int32;
47 typedef int16_t int16;
48 typedef int8_t int8;
49 typedef uint64_t uint64;
50 typedef uint32_t uint32;
51 typedef uint16_t uint16;
52 typedef uint8_t uint8;
53 #endif
55 typedef std::deque<HANDLE> ArchiveSet;
56 typedef std::pair<ArchiveSet::const_iterator, ArchiveSet::const_iterator> ArchiveSetBounds;
58 bool OpenArchive(char const* mpqFileName, HANDLE* mpqHandlePtr = NULL);
59 bool OpenNewestFile(char const* filename, HANDLE* fileHandlerPtr);
60 ArchiveSetBounds GetArchivesBounds();
61 bool ExtractFile(char const* mpq_name, std::string const& filename);
62 void CloseArchives();
64 #define FILE_FORMAT_VERSION 18
67 // File version chunk
69 struct file_MVER
71 union
73 uint32 fcc;
74 char fcc_txt[4];
76 uint32 size;
77 uint32 ver;
80 class FileLoader
82 uint8* data;
83 uint32 data_size;
84 public:
85 virtual bool prepareLoadedData();
86 uint8* GetData() {return data;}
87 uint32 GetDataSize() {return data_size;}
89 file_MVER* version;
90 FileLoader();
91 ~FileLoader();
92 bool loadFile(char* filename, bool log = true);
93 virtual void free();
95 #endif