Core commit. Compile and run on the OpenPandora
[mupen64plus-pandora.git] / source / mupen64plus-core / src / api / common.c
CommitLineData
451ab91e 1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2 * Mupen64plus-core - api/common.c *
3 * Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
4 * Copyright (C) 2009 Richard Goedeken *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
20 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
21
22/* This file contains the Core common functions which will be exported
23 * outside of the core library.
24 */
25
26#include <stdlib.h>
27
28#define M64P_CORE_PROTOTYPES 1
29#include "m64p_types.h"
30#include "m64p_common.h"
31#include "../main/version.h"
32
33EXPORT m64p_error CALL PluginGetVersion(m64p_plugin_type *PluginType, int *PluginVersion, int *APIVersion, const char **PluginNamePtr, int *Capabilities)
34{
35 /* set version info */
36 if (PluginType != NULL)
37 *PluginType = M64PLUGIN_CORE;
38
39 if (PluginVersion != NULL)
40 *PluginVersion = MUPEN_CORE_VERSION;
41
42 if (APIVersion != NULL)
43 *APIVersion = FRONTEND_API_VERSION;
44
45 if (PluginNamePtr != NULL)
46 *PluginNamePtr = MUPEN_CORE_NAME;
47
48 if (Capabilities != NULL)
49 {
50 *Capabilities = 0;
51#if defined(DBG)
52 *Capabilities |= M64CAPS_DEBUGGER;
53#endif
54#if defined(DYNAREC)
55 *Capabilities |= M64CAPS_DYNAREC;
56#endif
57#if defined(COMPARE_CORE)
58 *Capabilities |= M64CAPS_CORE_COMPARE;
59#endif
60 }
61
62 return M64ERR_SUCCESS;
63}
64
65EXPORT m64p_error CALL CoreGetAPIVersions(int *ConfigVersion, int *DebugVersion, int *VidextVersion, int *ExtraVersion)
66{
67 /* set version info */
68 if (ConfigVersion != NULL)
69 *ConfigVersion = CONFIG_API_VERSION;
70
71 if (DebugVersion != NULL)
72 *DebugVersion = DEBUG_API_VERSION;
73
74 if (VidextVersion != NULL)
75 *VidextVersion = VIDEXT_API_VERSION;
76
77 if (ExtraVersion != NULL)
78 *ExtraVersion = 0;
79
80 return M64ERR_SUCCESS;
81}
82
83static const char *ErrorMessages[] = {
84 "SUCCESS: No error",
85 "NOT_INIT: A function was called before it's associated module was initialized",
86 "ALREADY_INIT: Initialization function called twice",
87 "INCOMPATIBLE: API versions between components are incompatible",
88 "INPUT_ASSERT: Invalid function parameters, such as a NULL pointer",
89 "INPUT_INVALID: An input function parameter is logically invalid",
90 "INPUT_NOT_FOUND: The input parameter(s) specified a particular item which was not found",
91 "NO_MEMORY: Memory allocation failed",
92 "FILES: Error opening, creating, reading, or writing to a file",
93 "INTERNAL: logical inconsistency in program code. Probably a bug.",
94 "INVALID_STATE: An operation was requested which is not allowed in the current state",
95 "PLUGIN_FAIL: A plugin function returned a fatal error",
96 "SYSTEM_FAIL: A system function call, such as an SDL or file operation, failed",
97 "UNSUPPORTED: Function call is not supported (ie, core not built with debugger)",
98 "WRONG_TYPE: A given input type parameter cannot be used for desired operation" };
99
100EXPORT const char * CALL CoreErrorMessage(m64p_error ReturnCode)
101{
102 int i = (int) ReturnCode;
103
104 if (i < 0 || i > (sizeof(ErrorMessages) / sizeof(char *)))
105 return "ERROR: Invalid m64p_error code given to CoreErrorMessage()";
106
107 return ErrorMessages[i];
108}
109