1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2 * Mupen64plus-core - m64p_config.h *
3 * Mupen64Plus homepage: https://mupen64plus.org/ *
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 header file defines typedefs for function pointers to the Core's
23 * configuration handling functions.
24 */
25
26#if !defined(M64P_CONFIG_H)
27#define M64P_CONFIG_H
28
29#include "m64p_types.h"
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35/* ConfigListSections()
36 *
37 * This function is called to enumerate the list of Sections in the Mupen64Plus
38 * configuration file. It is expected that there will be a section named "Core"
39 * for core-specific configuration data, "Graphics" for common graphics options,
40 * and one or more sections for each plugin library.
41 */
42typedef m64p_error (*ptr_ConfigListSections)(void *, void (*)(void *, const char *));
43#if defined(M64P_CORE_PROTOTYPES)
44EXPORT m64p_error CALL ConfigListSections(void *, void (*)(void *, const char *));
45#endif
46
47/* ConfigOpenSection()
48 *
49 * This function is used to give a configuration section handle to the front-end
50 * which may be used to read or write configuration parameter values in a given
51 * section of the configuration file.
52 */
53typedef m64p_error (*ptr_ConfigOpenSection)(const char *, m64p_handle *);
54#if defined(M64P_CORE_PROTOTYPES)
55EXPORT m64p_error CALL ConfigOpenSection(const char *, m64p_handle *);
56#endif
57
58/* ConfigListParameters()
59 *
60 * This function is called to enumerate the list of Parameters in a given
61 * Section of the Mupen64Plus configuration file.
62 */
63typedef m64p_error (*ptr_ConfigListParameters)(m64p_handle, void *, void (*)(void *, const char *, m64p_type));
64#if defined(M64P_CORE_PROTOTYPES)
65EXPORT m64p_error CALL ConfigListParameters(m64p_handle, void *, void (*)(void *, const char *, m64p_type));
66#endif
67
68/* ConfigSaveFile()
69 *
70 * This function saves the entire current Mupen64Plus configuration to disk.
71 */
72typedef m64p_error (*ptr_ConfigSaveFile)(void);
73#if defined(M64P_CORE_PROTOTYPES)
74EXPORT m64p_error CALL ConfigSaveFile(void);
75#endif
76
77/* ConfigSaveSection()
78 *
79 * This function saves one section of the current Mupen64Plus configuration to disk.
80 */
81typedef m64p_error (*ptr_ConfigSaveSection)(const char *);
82#if defined(M64P_CORE_PROTOTYPES)
83EXPORT m64p_error CALL ConfigSaveSection(const char *);
84#endif
85
86/* ConfigHasUnsavedChanges()
87 *
88 * This function determines if a given Section (or all sections) of the Mupen64Plus Core configuration file has been modified since it was last saved or loaded.
89 */
90typedef int (*ptr_ConfigHasUnsavedChanges)(const char *);
91#if defined(M64P_CORE_PROTOTYPES)
92EXPORT int CALL ConfigHasUnsavedChanges(const char *);
93#endif
94
95/* ConfigDeleteSection()
96 *
97 * This function deletes a section from the Mupen64Plus configuration data.
98 */
99typedef m64p_error (*ptr_ConfigDeleteSection)(const char *SectionName);
100#if defined(M64P_CORE_PROTOTYPES)
101EXPORT m64p_error CALL ConfigDeleteSection(const char *SectionName);
102#endif
103
104/* ConfigRevertChanges()
105 *
106 * This function reverts changes previously made to one section of the configuration file, so that it will match with the configuration at the last time that it was loaded from or saved to disk.
107 */
108typedef m64p_error (*ptr_ConfigRevertChanges)(const char *SectionName);
109#if defined(M64P_CORE_PROTOTYPES)
110EXPORT m64p_error CALL ConfigRevertChanges(const char *SectionName);
111#endif
112
113/* ConfigSetParameter()
114 *
115 * This function sets the value of one of the emulator's configuration
116 * parameters.
117 */
118typedef m64p_error (*ptr_ConfigSetParameter)(m64p_handle, const char *, m64p_type, const void *);
119#if defined(M64P_CORE_PROTOTYPES)
120EXPORT m64p_error CALL ConfigSetParameter(m64p_handle, const char *, m64p_type, const void *);
121#endif
122
123/* ConfigSetParameterHelp()
124 *
125 * This function sets the help string of one of the emulator's configuration
126 * parameters.
127 */
128typedef m64p_error (*ptr_ConfigSetParameterHelp)(m64p_handle, const char *, const char *);
129#if defined(M64P_CORE_PROTOTYPES)
130EXPORT m64p_error CALL ConfigSetParameterHelp(m64p_handle, const char *, const char *);
131#endif
132
133/* ConfigGetParameter()
134 *
135 * This function retrieves the value of one of the emulator's parameters.
136 */
137typedef m64p_error (*ptr_ConfigGetParameter)(m64p_handle, const char *, m64p_type, void *, int);
138#if defined(M64P_CORE_PROTOTYPES)
139EXPORT m64p_error CALL ConfigGetParameter(m64p_handle, const char *, m64p_type, void *, int);
140#endif
141
142/* ConfigGetParameterType()
143 *
144 * This function retrieves the type of one of the emulator's parameters.
145 */
146typedef m64p_error (*ptr_ConfigGetParameterType)(m64p_handle, const char *, m64p_type *);
147#if defined(M64P_CORE_PROTOTYPES)
148EXPORT m64p_error CALL ConfigGetParameterType(m64p_handle, const char *, m64p_type *);
149#endif
150
151/* ConfigGetParameterHelp()
152 *
153 * This function retrieves the help information about one of the emulator's
154 * parameters.
155 */
156typedef const char * (*ptr_ConfigGetParameterHelp)(m64p_handle, const char *);
157#if defined(M64P_CORE_PROTOTYPES)
158EXPORT const char * CALL ConfigGetParameterHelp(m64p_handle, const char *);
159#endif
160
161/* ConfigSetDefault***()
162 *
163 * These functions are used to set the value of a configuration parameter if it
164 * is not already present in the configuration file. This may happen if a new
165 * user runs the emulator, or an upgraded module uses a new parameter, or the
166 * user deletes his or her configuration file. If the parameter is already
167 * present in the given section of the configuration file, then no action will
168 * be taken and this function will return successfully.
169 */
170typedef m64p_error (*ptr_ConfigSetDefaultInt)(m64p_handle, const char *, int, const char *);
171typedef m64p_error (*ptr_ConfigSetDefaultFloat)(m64p_handle, const char *, float, const char *);
172typedef m64p_error (*ptr_ConfigSetDefaultBool)(m64p_handle, const char *, int, const char *);
173typedef m64p_error (*ptr_ConfigSetDefaultString)(m64p_handle, const char *, const char *, const char *);
174#if defined(M64P_CORE_PROTOTYPES)
175EXPORT m64p_error CALL ConfigSetDefaultInt(m64p_handle, const char *, int, const char *);
176EXPORT m64p_error CALL ConfigSetDefaultFloat(m64p_handle, const char *, float, const char *);
177EXPORT m64p_error CALL ConfigSetDefaultBool(m64p_handle, const char *, int, const char *);
178EXPORT m64p_error CALL ConfigSetDefaultString(m64p_handle, const char *, const char *, const char *);
179#endif
180
181/* ConfigGetParam***()
182 *
183 * These functions retrieve the value of one of the emulator's parameters in
184 * the given section, and return the value directly to the calling function. If
185 * an errors occurs (such as an invalid Section handle, or invalid
186 * configuration parameter name), then an error will be sent to the front-end
187 * via the DebugCallback() function, and either a 0 (zero) or an empty string
188 * will be returned.
189 */
190typedef int (*ptr_ConfigGetParamInt)(m64p_handle, const char *);
191typedef float (*ptr_ConfigGetParamFloat)(m64p_handle, const char *);
192typedef int (*ptr_ConfigGetParamBool)(m64p_handle, const char *);
193typedef const char * (*ptr_ConfigGetParamString)(m64p_handle, const char *);
194#if defined(M64P_CORE_PROTOTYPES)
195EXPORT int CALL ConfigGetParamInt(m64p_handle, const char *);
196EXPORT float CALL ConfigGetParamFloat(m64p_handle, const char *);
197EXPORT int CALL ConfigGetParamBool(m64p_handle, const char *);
198EXPORT const char * CALL ConfigGetParamString(m64p_handle, const char *);
199#endif
200
201/* ConfigGetSharedDataFilepath()
202 *
203 * This function is provided to allow a plugin to retrieve a full pathname to a
204 * given shared data file. This type of file is intended to be shared among
205 * multiple users on a system, so it is likely to be read-only.
206 */
207typedef const char * (*ptr_ConfigGetSharedDataFilepath)(const char *);
208#if defined(M64P_CORE_PROTOTYPES)
209EXPORT const char * CALL ConfigGetSharedDataFilepath(const char *);
210#endif
211
212/* ConfigGetUserConfigPath()
213 *
214 * This function may be used by the plugins or front-end to get a path to the
215 * directory for storing user-specific configuration files. This will be the
216 * directory where "mupen64plus.cfg" is located.
217 */
218typedef const char * (*ptr_ConfigGetUserConfigPath)(void);
219#if defined(M64P_CORE_PROTOTYPES)
220EXPORT const char * CALL ConfigGetUserConfigPath(void);
221#endif
222
223/* ConfigGetUserDataPath()
224 *
225 * This function may be used by the plugins or front-end to get a path to the
226 * directory for storing user-specific data files. This may be used to store
227 * files such as screenshots, saved game states, or hi-res textures.
228 */
229typedef const char * (*ptr_ConfigGetUserDataPath)(void);
230#if defined(M64P_CORE_PROTOTYPES)
231EXPORT const char * CALL ConfigGetUserDataPath(void);
232#endif
233
234/* ConfigGetUserCachePath()
235 *
236 * This function may be used by the plugins or front-end to get a path to the
237 * directory for storing cached user-specific data files. Files in this
238 * directory may be deleted by the user to save space, so critical information
239 * should not be stored here. This directory may be used to store files such
240 * as the ROM browser cache.
241 */
242typedef const char * (*ptr_ConfigGetUserCachePath)(void);
243#if defined(M64P_CORE_PROTOTYPES)
244EXPORT const char * CALL ConfigGetUserCachePath(void);
245#endif
246
247/* ConfigExternalOpen()
248 *
249 * This function reads the contents of the config file into memory
250 * and returns M64ERR_SUCCESS if successful.
251 */
252typedef m64p_error (*ptr_ConfigExternalOpen)(const char *, m64p_handle *);
253#if defined(M64P_CORE_PROTOTYPES)
254EXPORT m64p_error CALL ConfigExternalOpen(const char *, m64p_handle *);
255#endif
256
257/* ConfigExternalClose()
258 *
259 * Frees the memory pointer created by ConfigExternalOpen.
260 */
261typedef m64p_error (*ptr_ConfigExternalClose)(m64p_handle);
262#if defined(M64P_CORE_PROTOTYPES)
263EXPORT m64p_error CALL ConfigExternalClose(m64p_handle);
264#endif
265
266/* ConfigExternalGetParameter()
267 *
268 * This functions allows a plugin to leverage the built-in ini parser to read
269 * any cfg/ini file. It will return M64ERR_SUCCESS if the item was found.
270 */
271typedef m64p_error (*ptr_ConfigExternalGetParameter)(m64p_handle, const char *, const char *, char *, int);
272#if defined(M64P_CORE_PROTOTYPES)
273EXPORT m64p_error CALL ConfigExternalGetParameter(m64p_handle, const char *, const char *, char *, int);
274#endif
275
276#ifdef __cplusplus
277}
278#endif
279
280#endif /* #define M64P_CONFIG_H */
281