2 Copyright (c) 2001, Loki software, inc.
5 Redistribution and use in source and binary forms, with or without modification,
6 are permitted provided that the following conditions are met:
8 Redistributions of source code must retain the above copyright notice, this list
9 of conditions and the following disclaimer.
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.
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
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.
32 // Image loading plugin
34 // Leonardo Zide (leo@lokigames.com)
40 // =============================================================================
43 _QERFuncTable_1 g_FuncTable; // Radiant function table
44 _QERFileSystemTable g_FileSystemTable;
46 // =============================================================================
49 CSynapseServer* g_pSynapseServer = NULL;
50 CSynapseClientImage g_SynapseClient;
53 #pragma GCC visibility push(default)
55 extern "C" CSynapseClient* SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces( const char *version, CSynapseServer *pServer ) {
57 #pragma GCC visibility pop
59 if (strcmp(version, SYNAPSE_VERSION))
61 Syn_Printf("ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version);
64 g_pSynapseServer = pServer;
65 g_pSynapseServer->IncRef();
66 Set_Syn_Printf(g_pSynapseServer->Get_Syn_Printf());
68 g_SynapseClient.AddAPI(IMAGE_MAJOR, "m8", sizeof(_QERPlugImageTable));
69 g_SynapseClient.AddAPI(IMAGE_MAJOR, "m32", sizeof(_QERPlugImageTable));
70 g_SynapseClient.AddAPI(RADIANT_MAJOR, NULL, sizeof(_QERFuncTable_1), SYN_REQUIRE, &g_FuncTable);
72 Syn_Printf("Dynamic APIs for client '%s'\n", g_SynapseClient.GetInfo());
73 if (!g_pSynapseServer->SelectClientConfig(g_SynapseClient.GetName()))
75 Syn_Printf("ERROR: Failed to select synapse client config in '%s'\n", g_SynapseClient.GetInfo());
79 while(g_pSynapseServer->GetNextConfig(&api, &minor))
81 Syn_Printf("api: '%s' minor: '%s'\n", api, minor);
82 if (!strcmp(api, VFS_MAJOR))
84 g_SynapseClient.AddAPI(VFS_MAJOR, minor, sizeof(_QERFileSystemTable), SYN_REQUIRE, &g_FileSystemTable);
88 Syn_Printf("WARNING: unknown API node '%s' in synapse config from module '%s'\n", api, g_SynapseClient.GetInfo());
91 return &g_SynapseClient;
94 bool CSynapseClientImage::RequestAPI(APIDescriptor_t *pAPI)
96 if (!strcmp(pAPI->major_name, IMAGE_MAJOR ))
98 _QERPlugImageTable* pTable= static_cast<_QERPlugImageTable*>(pAPI->mpTable);
99 if (!strcmp(pAPI->minor_name, "m8"))
101 pTable->m_pfnLoadImage = &LoadM8;
104 if (!strcmp(pAPI->minor_name, "m32"))
106 pTable->m_pfnLoadImage = &LoadM32;
111 Syn_Printf("ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo());
115 bool CSynapseClientImage::OnActivate() {
116 if (!g_FileSystemTable.m_nSize) {
117 Syn_Printf("ERROR: VFS_MAJOR table was not initialized before OnActivate in '%s' - incomplete synapse.config?\n", GetInfo());
125 const char* CSynapseClientImage::GetInfo()
127 return "M8 M32 formats module built " __DATE__ " " RADIANT_VERSION;