1+ /* *
2+ * =============================================================================
3+ * Source Python
4+ * Copyright (C) 2012-2015 Source Python Development Team. All rights reserved.
5+ * =============================================================================
6+ *
7+ * This program is free software; you can redistribute it and/or modify it under
8+ * the terms of the GNU General Public License, version 3.0, as published by the
9+ * Free Software Foundation.
10+ *
11+ * This program is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14+ * details.
15+ *
16+ * You should have received a copy of the GNU General Public License along with
17+ * this program. If not, see <http://www.gnu.org/licenses/>.
18+ *
19+ * As a special exception, the Source Python Team gives you permission
20+ * to link the code of this program (as well as its derivative works) to
21+ * "Half-Life 2," the "Source Engine," and any Game MODs that run on software
22+ * by the Valve Corporation. You must obey the GNU General Public License in
23+ * all respects for all other code used. Additionally, the Source.Python
24+ * Development Team grants this exception to all derivative works.
25+ */
26+
27+ // -----------------------------------------------------------------------------
28+ // Includes.
29+ // -----------------------------------------------------------------------------
30+ #include " core.h"
31+ #include " export_main.h"
32+
33+
34+ void ConsoleMessage (const char * msg)
35+ {
36+ char * pMsg = (char *) msg;
37+ int iLen = strlen (msg);
38+
39+ while (iLen > 0 ) {
40+ ConMsg (pMsg);
41+ pMsg += MAX_CON_MSG-1 ;
42+ iLen -= MAX_CON_MSG-1 ;
43+ }
44+ }
45+
46+ void * GetInterface (const char * library, const char * interface_name)
47+ {
48+ DLLib* lib = dlLoadLibrary (library);
49+ if (!lib)
50+ BOOST_RAISE_EXCEPTION (PyExc_ValueError, " Unable to load library '%s'." , library)
51+
52+ CreateInterfaceFn pCreateInterface = (CreateInterfaceFn) dlFindSymbol (lib, CREATEINTERFACE_PROCNAME);
53+ dlFreeLibrary (lib);
54+
55+ if (!pCreateInterface)
56+ BOOST_RAISE_EXCEPTION (PyExc_ValueError, " Unable to retrieve interface function '%s'." , CREATEINTERFACE_PROCNAME)
57+
58+ int return_code;
59+ void * result = pCreateInterface (interface_name, &return_code);
60+ if (!result)
61+ BOOST_RAISE_EXCEPTION (PyExc_ValueError, " Unable to find interface '%s'. Return code: %i." , interface_name, return_code)
62+
63+ return result;
64+ }
65+
66+ list GetCoreModules ()
67+ {
68+ list result;
69+
70+ for (int i=0 ; i < MAX_SOURCEPYTHON_MODULES; ++i)
71+ {
72+ const char * module = g_SourcePythonModules[i].szName ;
73+ if (!module )
74+ break ;
75+
76+ result.append (module );
77+ }
78+
79+ return result;
80+ }
0 commit comments