]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - plugins/vfswad/vfswad.cpp
more eol-style
[xonotic/netradiant.git] / plugins / vfswad / vfswad.cpp
1 /*
2 Copyright (c) 2001, Loki software, inc.
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without modification,
6 are permitted provided that the following conditions are met:
7
8 Redistributions of source code must retain the above copyright notice, this list
9 of conditions and the following disclaimer.
10
11 Redistributions in binary form must reproduce the above copyright notice, this
12 list of conditions and the following disclaimer in the documentation and/or
13 other materials provided with the distribution.
14
15 Neither the name of Loki software nor the names of its contributors may be used
16 to endorse or promote products derived from this software without specific prior
17 written permission.
18
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
20 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
23 DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 //
32 // HalfLife Virtual FileSystem - reads files from different dirs and inside wad files
33 //
34 // Coding by Dominic Clifton - Hydra - hydra@hydras-world.com
35 //
36 // based on code by Leonardo Zide (leo@lokigames.com)
37 //
38
39 #ifdef _WIN32
40 #include <wtypes.h>
41 #endif
42
43 #include <stdio.h>
44 #include "vfswad.h"
45 #include "vfs.h"
46
47 // =============================================================================
48 // SYNAPSE
49
50 _QERFuncTable_1 g_FuncTable;
51
52 CSynapseServer* g_pSynapseServer = NULL;
53 CSynapseClientVFS g_SynapseClient;
54
55 extern "C" CSynapseClient* SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces (const char *version, CSynapseServer *pServer)
56 {
57   if (strcmp(version, SYNAPSE_VERSION))
58   {
59     Syn_Printf("ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version);
60     return NULL;
61   }
62   g_pSynapseServer = pServer;
63   g_pSynapseServer->IncRef();
64   Set_Syn_Printf(g_pSynapseServer->Get_Syn_Printf());
65   
66   g_SynapseClient.AddAPI(VFS_MAJOR, "wad", sizeof(_QERFileSystemTable));  
67   g_SynapseClient.AddAPI(RADIANT_MAJOR, NULL, sizeof(_QERFuncTable_1), SYN_REQUIRE, &g_FuncTable);
68
69   return &g_SynapseClient;
70 }
71
72 bool CSynapseClientVFS::RequestAPI(APIDescriptor_t *pAPI)
73 {
74   if (!strcmp(pAPI->major_name, VFS_MAJOR))
75   {
76     _QERFileSystemTable* pTable= static_cast<_QERFileSystemTable*>(pAPI->mpTable);
77     pTable->m_pfnInitDirectory = &vfsInitDirectory;
78     pTable->m_pfnShutdown = &vfsShutdown;
79     pTable->m_pfnFreeFile = &vfsFreeFile;
80     pTable->m_pfnGetDirList = &vfsGetDirList;
81     pTable->m_pfnGetFileList = &vfsGetFileList;
82     pTable->m_pfnClearFileDirList = &vfsClearFileDirList;
83     pTable->m_pfnGetFileCount = &vfsGetFileCount;
84     pTable->m_pfnLoadFile = &vfsLoadFile;
85     pTable->m_pfnLoadFullPathFile = &vfsLoadFullPathFile;
86     pTable->m_pfnExtractRelativePath = &vfsExtractRelativePath;
87     pTable->m_pfnGetFullPath = &vfsGetFullPath;
88     pTable->m_pfnBasePromptPath = &vfsBasePromptPath;
89     return true;
90   }
91
92   Syn_Printf("ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo());
93   return false;
94 }
95
96 #include "version.h"
97
98 const char* CSynapseClientVFS::GetInfo()
99 {
100   return "WAD VFS module built " __DATE__ " " RADIANT_VERSION;
101 }