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