[mupen64plus-ui-console] 109/172: Imported Upstream version 1.99.5+6+a10c576ef396
Sven Eckelmann
ecsv-guest at moszumanska.debian.org
Thu Nov 26 06:07:38 UTC 2015
This is an automated email from the git hooks/post-receive script.
ecsv-guest pushed a commit to branch armhf_test
in repository mupen64plus-ui-console.
commit 203effbeb415d7c76f5d4a7fe8d7496e8b8ddc8b
Author: Sven Eckelmann <sven at narfation.org>
Date: Tue Sep 11 09:20:24 2012 +0200
Imported Upstream version 1.99.5+6+a10c576ef396
---
src/cheat.c | 40 +++++++++++-----------
src/compare_core.c | 9 +++--
src/core_interface.c | 23 +++++++------
src/main.c | 82 ++++++++++++++++++++++++++++-----------------
src/main.h | 1 +
src/osal_dynamiclib_unix.c | 5 +--
src/osal_dynamiclib_win32.c | 5 +--
src/osal_files_unix.c | 3 +-
src/osal_files_win32.c | 5 +--
src/plugin.c | 17 +++++-----
10 files changed, 108 insertions(+), 82 deletions(-)
diff --git a/src/cheat.c b/src/cheat.c
index ab26073..9a9cd2a 100644
--- a/src/cheat.c
+++ b/src/cheat.c
@@ -25,6 +25,8 @@
#include <stdio.h>
#include "m64p_types.h"
+
+#include "main.h"
#include "cheat.h"
#include "core_interface.h"
@@ -88,7 +90,7 @@ static void CheatActivate(sCheatInfo *pCheat)
m64p_cheat_code * code = (m64p_cheat_code*) calloc(pCheat->Count, sizeof(m64p_cheat_code));
if (code == NULL)
{
- printf("UI-Console Warning: could not allocate memory for code '%s'\n", pCheat->Name);
+ DebugMessage(M64MSG_WARNING, "could not allocate memory for code '%s'", pCheat->Name);
return;
}
/* Fill in members */
@@ -100,13 +102,13 @@ static void CheatActivate(sCheatInfo *pCheat)
/* Enable cheat */
if (CoreAddCheat(pCheat->Name, code, pCheat->Count) != M64ERR_SUCCESS)
{
- printf("UI-Console Warning: CoreAddCheat() failed for cheat code %i (%s)\n", pCheat->Number, pCheat->Name);
+ DebugMessage(M64MSG_WARNING, "CoreAddCheat() failed for cheat code %i (%s)", pCheat->Number, pCheat->Name);
free(code);
return;
}
free(code);
- printf("UI-Console: activated cheat code %i: %s\n", pCheat->Number, pCheat->Name);
+ DebugMessage(M64MSG_STATUS, "activated cheat code %i: %s", pCheat->Number, pCheat->Name);
}
static void CheatFreeAll(void)
@@ -204,7 +206,7 @@ static void ReadCheats(char *RomSection)
const char *romdbpath = ConfigGetSharedDataFilepath(CHEAT_FILE);
if (romdbpath == NULL)
{
- printf("UI-Console: cheat code database file '%s' not found.\n", CHEAT_FILE);
+ DebugMessage(M64MSG_WARNING, "cheat code database file '%s' not found.", CHEAT_FILE);
return;
}
@@ -213,7 +215,7 @@ static void ReadCheats(char *RomSection)
fPtr = fopen(romdbpath, "rb");
if (fPtr == NULL)
{
- printf("UI-Console: Couldn't open cheat code database file '%s'.\n", romdbpath);
+ DebugMessage(M64MSG_WARNING, "Couldn't open cheat code database file '%s'.", romdbpath);
return;
}
fseek(fPtr, 0L, SEEK_END);
@@ -222,13 +224,13 @@ static void ReadCheats(char *RomSection)
l_IniText = (char *) malloc(IniLength + 1);
if (l_IniText == NULL)
{
- printf("UI-Console: Couldn't allocate %li bytes of memory to read cheat file.\n", IniLength);
+ DebugMessage(M64MSG_WARNING, "Couldn't allocate %li bytes of memory to read cheat file.", IniLength);
fclose(fPtr);
return;
}
if (fread(l_IniText, 1, IniLength, fPtr) != IniLength)
{
- printf("UI-Console: Couldn't read %li bytes from cheat file.\n", IniLength);
+ DebugMessage(M64MSG_WARNING, "Couldn't read %li bytes from cheat file.", IniLength);
free(l_IniText);
l_IniText = NULL;
fclose(fPtr);
@@ -289,7 +291,7 @@ static void ReadCheats(char *RomSection)
{
curr_code = NewCode(curline + 3, l_CheatCodesFound);
if (curr_code == NULL)
- printf("UI-Console error: error getting new code (%s)\n", curline+3);
+ DebugMessage(M64MSG_WARNING, "error getting new code (%s)", curline+3);
continue;
}
@@ -322,7 +324,7 @@ static void ReadCheats(char *RomSection)
curr_code->Codes[curr_code->Count].variables = (int*) malloc(sizeof(int));
if(curr_code->Codes[curr_code->Count].variables == NULL)
{
- printf("UI-Console Error: error allocating memory; ignoring line: '%s'\n", curline);
+ DebugMessage(M64MSG_WARNING, "couldn't allocate memory; ignoring line: '%s'", curline);
continue;
}
if (sscanf(curline+9, "%04X", &var) != 1)
@@ -337,7 +339,7 @@ static void ReadCheats(char *RomSection)
}
/* otherwise we don't know what this line is */
- printf("UI-Console Warning: unrecognized line in cheat file: '%s'\n", curline);
+ DebugMessage(M64MSG_WARNING, "unrecognized line in cheat file: '%s'", curline);
}
}
@@ -347,14 +349,14 @@ void CheatStart(eCheatMode CheatMode, char *CheatNumList)
/* if cheat codes are disabled, then we don't have to do anything */
if (CheatMode == CHEAT_DISABLE || (CheatMode == CHEAT_LIST && strlen(CheatNumList) == 0))
{
- printf("UI-Console: Cheat codes disabled.\n");
+ DebugMessage(M64MSG_STATUS, "Cheat codes disabled.");
return;
}
/* get the ROM header for the currently loaded ROM image from the core */
if ((*CoreDoCommand)(M64CMD_ROM_GET_HEADER, sizeof(l_RomHeader), &l_RomHeader) != M64ERR_SUCCESS)
{
- printf("UI-Console: couldn't get ROM header information from core library\n");
+ DebugMessage(M64MSG_WARNING, "couldn't get ROM header information from core library");
return;
}
@@ -366,7 +368,7 @@ void CheatStart(eCheatMode CheatMode, char *CheatNumList)
ReadCheats(RomSection);
if (!l_RomFound || l_CheatCodesFound == 0)
{
- printf("UI-Console: no cheat codes found for ROM image '%.20s'\n", l_RomHeader.Name);
+ DebugMessage(M64MSG_WARNING, "no cheat codes found for ROM image '%.20s'", l_RomHeader.Name);
CheatFreeAll();
return;
}
@@ -374,19 +376,19 @@ void CheatStart(eCheatMode CheatMode, char *CheatNumList)
/* handle the list command */
if (CheatMode == CHEAT_SHOW_LIST)
{
- printf("UI-Console: %i cheat code(s) found for ROM '%s'\n", l_CheatCodesFound, l_CheatGameName);
+ DebugMessage(M64MSG_INFO, "%i cheat code(s) found for ROM '%s'", l_CheatCodesFound, l_CheatGameName);
sCheatInfo *pCur = l_CheatList;
while (pCur != NULL)
{
if (pCur->Description == NULL)
- printf(" %i: %s\n", pCur->Number, pCur->Name);
+ DebugMessage(M64MSG_INFO, " %i: %s", pCur->Number, pCur->Name);
else
- printf(" %i: %s (%s)\n", pCur->Number, pCur->Name, pCur->Description);
+ DebugMessage(M64MSG_INFO, " %i: %s (%s)", pCur->Number, pCur->Name, pCur->Description);
if(pCur->VariableLine != -1)
{
int i;
for (i = 0; i < pCur->Codes[pCur->VariableLine].var_count; i++)
- printf(" %i: %s\n", i, pCur->Codes[pCur->VariableLine].variable_names[i]);
+ DebugMessage(M64MSG_INFO, " %i: %s", i, pCur->Codes[pCur->VariableLine].variable_names[i]);
}
pCur = pCur->Next;
}
@@ -433,7 +435,7 @@ void CheatStart(eCheatMode CheatMode, char *CheatNumList)
pCheat = CheatFindCode(number);
if (pCheat == NULL)
- printf("UI-Console Warning: invalid cheat code number %i\n", number);
+ DebugMessage(M64MSG_WARNING, "invalid cheat code number %i", number);
else
{
if (pCheat->VariableLine != -1 && pCheat->Count > pCheat->VariableLine && option < pCheat->Codes[pCheat->VariableLine].var_count)
@@ -449,7 +451,7 @@ void CheatStart(eCheatMode CheatMode, char *CheatNumList)
}
/* otherwise the mode is invalid */
- printf("UI-Console: internal error; invalid CheatMode in CheatStart()\n");
+ DebugMessage(M64MSG_WARNING, "internal error; invalid CheatMode in CheatStart()");
return;
}
diff --git a/src/compare_core.c b/src/compare_core.c
index 6b214c3..bdc4f87 100644
--- a/src/compare_core.c
+++ b/src/compare_core.c
@@ -197,8 +197,7 @@ static void compare_core_check(unsigned int cur_opcode)
void compare_core_init(int mode)
{
#if defined(WIN32)
- if (g_Verbose)
- printf("UI-console: core comparison feature not supported on Windows platform.\n");
+ DebugMessage(M64MSG_VERBOSE, "core comparison feature not supported on Windows platform.");
return;
#else
/* set mode */
@@ -207,7 +206,7 @@ void compare_core_init(int mode)
if (DebugSetCoreCompare(compare_core_check, compare_core_sync_data) != M64ERR_SUCCESS)
{
l_CoreCompareMode = CORE_COMPARE_DISABLE;
- printf("UI-console: DebugSetCoreCompare() failed, core comparison disabled.\n");
+ DebugMessage(M64MSG_WARNING, "DebugSetCoreCompare() failed, core comparison disabled.");
return;
}
/* get pointers to emulated R4300 CPU registers */
@@ -218,12 +217,12 @@ void compare_core_init(int mode)
if (l_CoreCompareMode == CORE_COMPARE_RECV)
{
mkfifo("compare_pipe", 0600);
- printf("UI-console: Core Comparison Waiting to read pipe.\n");
+ DebugMessage(M64MSG_INFO, "Core Comparison Waiting to read pipe.");
fPipe = fopen("compare_pipe", "r");
}
else if (l_CoreCompareMode == CORE_COMPARE_SEND)
{
- printf("UI-console: Core Comparison Waiting to write pipe.\n");
+ DebugMessage(M64MSG_INFO, "Core Comparison Waiting to write pipe.");
fPipe = fopen("compare_pipe", "w");
}
#endif
diff --git a/src/core_interface.c b/src/core_interface.c
index d15d179..09dd817 100644
--- a/src/core_interface.c
+++ b/src/core_interface.c
@@ -34,6 +34,7 @@
#include "osal_preproc.h"
#include "osal_dynamiclib.h"
+#include "main.h"
#include "version.h"
#include "core_interface.h"
@@ -141,7 +142,7 @@ m64p_error AttachCoreLib(const char *CoreLibFilepath)
/* if we haven't found a good core library by now, then we're screwed */
if (rval != M64ERR_SUCCESS || CoreHandle == NULL)
{
- fprintf(stderr, "AttachCoreLib() Error: failed to find Mupen64Plus Core library\n");
+ DebugMessage(M64MSG_ERROR, "AttachCoreLib() Error: failed to find Mupen64Plus Core library");
CoreHandle = NULL;
return M64ERR_INPUT_NOT_FOUND;
}
@@ -151,7 +152,7 @@ m64p_error AttachCoreLib(const char *CoreLibFilepath)
CoreVersionFunc = (ptr_PluginGetVersion) osal_dynlib_getproc(CoreHandle, "PluginGetVersion");
if (CoreVersionFunc == NULL)
{
- fprintf(stderr, "AttachCoreLib() Error: Shared library '%s' invalid; no PluginGetVersion() function found.\n", CoreLibFilepath);
+ DebugMessage(M64MSG_ERROR, "AttachCoreLib() Error: Shared library '%s' invalid; no PluginGetVersion() function found.", CoreLibFilepath);
osal_dynlib_close(CoreHandle);
CoreHandle = NULL;
return M64ERR_INPUT_INVALID;
@@ -162,12 +163,12 @@ m64p_error AttachCoreLib(const char *CoreLibFilepath)
const char *CoreName = NULL;
(*CoreVersionFunc)(&PluginType, &CoreVersion, &g_CoreAPIVersion, &CoreName, &g_CoreCapabilities);
if (PluginType != M64PLUGIN_CORE)
- fprintf(stderr, "AttachCoreLib() Error: Shared library '%s' invalid; this is not the emulator core.\n", CoreLibFilepath);
+ DebugMessage(M64MSG_ERROR, "AttachCoreLib() Error: Shared library '%s' invalid; this is not the emulator core.", CoreLibFilepath);
else if (CoreVersion < MINIMUM_CORE_VERSION)
- fprintf(stderr, "AttachCoreLib() Error: Shared library '%s' incompatible; core version %i.%i.%i is below minimum supported %i.%i.%i\n",
+ DebugMessage(M64MSG_ERROR, "AttachCoreLib() Error: Shared library '%s' incompatible; core version %i.%i.%i is below minimum supported %i.%i.%i",
CoreLibFilepath, VERSION_PRINTF_SPLIT(CoreVersion), VERSION_PRINTF_SPLIT(MINIMUM_CORE_VERSION));
else if ((g_CoreAPIVersion & 0xffff0000) != (CORE_API_VERSION & 0xffff0000))
- fprintf(stderr, "AttachCoreLib() Error: Shared library '%s' incompatible; core API major version %i.%i.%i doesn't match with this application (%i.%i.%i)\n",
+ DebugMessage(M64MSG_ERROR, "AttachCoreLib() Error: Shared library '%s' incompatible; core API major version %i.%i.%i doesn't match with this application (%i.%i.%i)",
CoreLibFilepath, VERSION_PRINTF_SPLIT(g_CoreAPIVersion), VERSION_PRINTF_SPLIT(CORE_API_VERSION));
else
Compatible = 1;
@@ -184,7 +185,7 @@ m64p_error AttachCoreLib(const char *CoreLibFilepath)
CoreAPIVersionFunc = (ptr_CoreGetAPIVersions) osal_dynlib_getproc(CoreHandle, "CoreGetAPIVersions");
if (CoreAPIVersionFunc == NULL)
{
- fprintf(stderr, "AttachCoreLib() Error: Library '%s' broken; no CoreAPIVersionFunc() function found.\n", CoreLibFilepath);
+ DebugMessage(M64MSG_ERROR, "AttachCoreLib() Error: Library '%s' broken; no CoreAPIVersionFunc() function found.", CoreLibFilepath);
osal_dynlib_close(CoreHandle);
CoreHandle = NULL;
return M64ERR_INPUT_INVALID;
@@ -193,7 +194,7 @@ m64p_error AttachCoreLib(const char *CoreLibFilepath)
(*CoreAPIVersionFunc)(&ConfigAPIVersion, &DebugAPIVersion, &VidextAPIVersion, NULL);
if ((ConfigAPIVersion & 0xffff0000) != (CONFIG_API_VERSION & 0xffff0000))
{
- fprintf(stderr, "AttachCoreLib() Error: Emulator core '%s' incompatible; Config API major version %i.%i.%i doesn't match application: %i.%i.%i\n",
+ DebugMessage(M64MSG_ERROR, "AttachCoreLib() Error: Emulator core '%s' incompatible; Config API major version %i.%i.%i doesn't match application: %i.%i.%i",
CoreLibFilepath, VERSION_PRINTF_SPLIT(ConfigAPIVersion), VERSION_PRINTF_SPLIT(CONFIG_API_VERSION));
osal_dynlib_close(CoreHandle);
CoreHandle = NULL;
@@ -201,13 +202,13 @@ m64p_error AttachCoreLib(const char *CoreLibFilepath)
}
/* print some information about the core library */
- printf("UI-console: attached to core library '%s' version %i.%i.%i\n", CoreName, VERSION_PRINTF_SPLIT(CoreVersion));
+ DebugMessage(M64MSG_INFO, "attached to core library '%s' version %i.%i.%i", CoreName, VERSION_PRINTF_SPLIT(CoreVersion));
if (g_CoreCapabilities & M64CAPS_DYNAREC)
- printf(" Includes support for Dynamic Recompiler.\n");
+ DebugMessage(M64MSG_INFO, " Includes support for Dynamic Recompiler.");
if (g_CoreCapabilities & M64CAPS_DEBUGGER)
- printf(" Includes support for MIPS r4300 Debugger.\n");
+ DebugMessage(M64MSG_INFO, " Includes support for MIPS r4300 Debugger.");
if (g_CoreCapabilities & M64CAPS_CORE_COMPARE)
- printf(" Includes support for r4300 Core Comparison.\n");
+ DebugMessage(M64MSG_INFO, " Includes support for r4300 Core Comparison.");
/* get function pointers to the common and front-end functions */
CoreErrorMessage = (ptr_CoreErrorMessage) osal_dynlib_getproc(CoreHandle, "CoreErrorMessage");
diff --git a/src/main.c b/src/main.c
index d7191da..82c4323 100644
--- a/src/main.c
+++ b/src/main.c
@@ -28,6 +28,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+#include <stdarg.h>
// The mac version of SDL requires inclusion of SDL_main in the executable
#ifdef __APPLE__
@@ -75,17 +76,36 @@ static char *l_CheatNumList = NULL;
* Callback functions from the core
*/
+void DebugMessage(int level, const char *message, ...)
+{
+ char msgbuf[1024];
+ va_list args;
+
+ va_start(args, message);
+ vsnprintf(msgbuf, 1024, message, args);
+
+ DebugCallback("UI-Console", level, msgbuf);
+
+ va_end(args);
+}
+
void DebugCallback(void *Context, int level, const char *message)
{
- if (level <= 1)
+ if (level == M64MSG_ERROR)
printf("%s Error: %s\n", (const char *) Context, message);
- else if (level == 2)
+ else if (level == M64MSG_WARNING)
printf("%s Warning: %s\n", (const char *) Context, message);
- else if (level == 3 || (level == 5 && g_Verbose))
+ else if (level == M64MSG_INFO)
printf("%s: %s\n", (const char *) Context, message);
- else if (level == 4)
+ else if (level == M64MSG_STATUS)
printf("%s Status: %s\n", (const char *) Context, message);
- /* ignore the verbose info for now */
+ else if (level == M64MSG_VERBOSE)
+ {
+ if (g_Verbose)
+ printf("%s: %s\n", (const char *) Context, message);
+ }
+ else
+ printf("%s Unknown: %s\n", (const char *) Context, message);
}
static void FrameCallback(unsigned int FrameIndex)
@@ -122,34 +142,34 @@ static m64p_error OpenConfigurationHandles(void)
rval = (*ConfigOpenSection)("Core", &l_ConfigCore);
if (rval != M64ERR_SUCCESS)
{
- fprintf(stderr, "Error: failed to open 'Core' configuration section\n");
+ DebugMessage(M64MSG_ERROR, "failed to open 'Core' configuration section");
return rval;
}
rval = (*ConfigOpenSection)("Video-General", &l_ConfigVideo);
if (rval != M64ERR_SUCCESS)
{
- fprintf(stderr, "Error: failed to open 'Video-General' configuration section\n");
+ DebugMessage(M64MSG_ERROR, "failed to open 'Video-General' configuration section");
return rval;
}
rval = (*ConfigOpenSection)("UI-Console", &l_ConfigUI);
if (rval != M64ERR_SUCCESS)
{
- fprintf(stderr, "Error: failed to open 'UI-Console' configuration section\n");
+ DebugMessage(M64MSG_ERROR, "failed to open 'UI-Console' configuration section");
return rval;
}
if ((*ConfigGetParameter)(l_ConfigUI, "Version", M64TYPE_FLOAT, &fConfigParamsVersion, sizeof(float)) != M64ERR_SUCCESS)
{
- fprintf(stderr, "Warning: No version number in 'UI-Console' config section. Setting defaults.\n");
+ DebugMessage(M64MSG_WARNING, "No version number in 'UI-Console' config section. Setting defaults.");
(*ConfigDeleteSection)("UI-Console");
(*ConfigOpenSection)("UI-Console", &l_ConfigUI);
bSaveConfig = 1;
}
else if (((int) fConfigParamsVersion) != ((int) CONFIG_PARAM_VERSION))
{
- fprintf(stderr, "Warning: Incompatible version %.2f in 'UI-Console' config section: current is %.2f. Setting defaults.\n", fConfigParamsVersion, (float) CONFIG_PARAM_VERSION);
+ DebugMessage(M64MSG_WARNING, "Incompatible version %.2f in 'UI-Console' config section: current is %.2f. Setting defaults.", fConfigParamsVersion, (float) CONFIG_PARAM_VERSION);
(*ConfigDeleteSection)("UI-Console");
(*ConfigOpenSection)("UI-Console", &l_ConfigUI);
bSaveConfig = 1;
@@ -159,7 +179,7 @@ static m64p_error OpenConfigurationHandles(void)
/* handle upgrades */
float fVersion = CONFIG_PARAM_VERSION;
ConfigSetParameter(l_ConfigUI, "Version", M64TYPE_FLOAT, &fVersion);
- fprintf(stderr, "Info: Updating parameter set version in 'UI-Console' config section to %.2f\n", fVersion);
+ DebugMessage(M64MSG_INFO, "Updating parameter set version in 'UI-Console' config section to %.2f", fVersion);
bSaveConfig = 1;
}
@@ -254,7 +274,7 @@ static int SetConfigParameter(const char *ParamSpec)
if (ParamSpec == NULL)
{
- fprintf(stderr, "UI-Console Error: ParamSpec is NULL in SetConfigParameter()\n");
+ DebugMessage(M64MSG_ERROR, "ParamSpec is NULL in SetConfigParameter()");
return 1;
}
@@ -262,7 +282,7 @@ static int SetConfigParameter(const char *ParamSpec)
ParsedString = (char *) malloc(strlen(ParamSpec) + 1);
if (ParsedString == NULL)
{
- fprintf(stderr, "UI-Console Error: SetConfigParameter() couldn't allocate memory for temporary string.\n");
+ DebugMessage(M64MSG_ERROR, "SetConfigParameter() couldn't allocate memory for temporary string.");
return 2;
}
strcpy(ParsedString, ParamSpec);
@@ -280,7 +300,7 @@ static int SetConfigParameter(const char *ParamSpec)
}
if (VarName == NULL || VarValue == NULL || *VarValue != '=')
{
- fprintf(stderr, "UI-Console Error: invalid (param-spec) '%s'\n", ParamSpec);
+ DebugMessage(M64MSG_ERROR, "invalid (param-spec) '%s'", ParamSpec);
free(ParsedString);
return 3;
}
@@ -290,7 +310,7 @@ static int SetConfigParameter(const char *ParamSpec)
rval = (*ConfigOpenSection)(ParsedString, &ConfigSection);
if (rval != M64ERR_SUCCESS)
{
- fprintf(stderr, "UI-Console Error: SetConfigParameter failed to open config section '%s'\n", ParsedString);
+ DebugMessage(M64MSG_ERROR, "SetConfigParameter failed to open config section '%s'", ParsedString);
free(ParsedString);
return 4;
}
@@ -316,7 +336,7 @@ static int SetConfigParameter(const char *ParamSpec)
ConfigSetParameter(ConfigSection, VarName, M64TYPE_STRING, VarValue);
break;
default:
- fprintf(stderr, "UI-Console Error: invalid VarType in SetConfigParameter()\n");
+ DebugMessage(M64MSG_ERROR, "invalid VarType in SetConfigParameter()");
return 5;
}
}
@@ -428,11 +448,11 @@ static m64p_error ParseCommandLineFinal(int argc, const char **argv)
{
int EnableSpeedLimit = 0;
if (g_CoreAPIVersion < 0x020001)
- fprintf(stderr, "Warning: core library doesn't support --nospeedlimit\n");
+ DebugMessage(M64MSG_WARNING, "core library doesn't support --nospeedlimit");
else
{
if ((*CoreDoCommand)(M64CMD_CORE_STATE_SET, M64CORE_SPEED_LIMITER, &EnableSpeedLimit) != M64ERR_SUCCESS)
- fprintf(stderr, "Error: core gave error while setting --nospeedlimit option\n");
+ DebugMessage(M64MSG_ERROR, "core gave error while setting --nospeedlimit option");
}
}
else if ((strcmp(argv[i], "--corelib") == 0 || strcmp(argv[i], "--configdir") == 0 ||
@@ -446,7 +466,7 @@ static m64p_error ParseCommandLineFinal(int argc, const char **argv)
int xres, yres;
i++;
if (sscanf(res, "%ix%i", &xres, &yres) != 2)
- fprintf(stderr, "Warning: couldn't parse resolution '%s'\n", res);
+ DebugMessage(M64MSG_WARNING, "couldn't parse resolution '%s'", res);
else
{
(*ConfigSetParameter)(l_ConfigVideo, "ScreenWidth", M64TYPE_INT, &xres);
@@ -502,12 +522,12 @@ static m64p_error ParseCommandLineFinal(int argc, const char **argv)
i++;
if (emumode < 0 || emumode > 2)
{
- fprintf(stderr, "Warning: invalid --emumode value '%i'\n", emumode);
+ DebugMessage(M64MSG_WARNING, "invalid --emumode value '%i'", emumode);
continue;
}
if (emumode == 2 && !(g_CoreCapabilities & M64CAPS_DYNAREC))
{
- fprintf(stderr, "Warning: Emulator core doesn't support Dynamic Recompiler.\n");
+ DebugMessage(M64MSG_WARNING, "Emulator core doesn't support Dynamic Recompiler.");
emumode = 1;
}
(*ConfigSetParameter)(l_ConfigCore, "R4300Emulator", M64TYPE_INT, &emumode);
@@ -547,13 +567,13 @@ static m64p_error ParseCommandLineFinal(int argc, const char **argv)
}
else
{
- fprintf(stderr, "Warning: unrecognized command-line parameter '%s'\n", argv[i]);
+ DebugMessage(M64MSG_WARNING, "unrecognized command-line parameter '%s'", argv[i]);
}
/* continue argv loop */
}
/* missing ROM filepath */
- fprintf(stderr, "Error: no ROM filepath given\n");
+ DebugMessage(M64MSG_ERROR, "no ROM filepath given");
return M64ERR_INPUT_INVALID;
}
@@ -584,7 +604,7 @@ int main(int argc, char *argv[])
m64p_error rval = (*CoreStartup)(CORE_API_VERSION, l_ConfigDirPath, l_DataDirPath, "Core", DebugCallback, NULL, NULL);
if (rval != M64ERR_SUCCESS)
{
- printf("UI-console: error starting Mupen64Plus core library.\n");
+ DebugMessage(M64MSG_ERROR, "couldn't start Mupen64Plus core library.");
DetachCoreLib();
return 3;
}
@@ -610,7 +630,7 @@ int main(int argc, char *argv[])
/* Handle the core comparison feature */
if (l_CoreCompareMode != 0 && !(g_CoreCapabilities & M64CAPS_CORE_COMPARE))
{
- printf("UI-console: can't use --core-compare feature with this Mupen64Plus core library.\n");
+ DebugMessage(M64MSG_ERROR, "can't use --core-compare feature with this Mupen64Plus core library.");
DetachCoreLib();
return 6;
}
@@ -624,7 +644,7 @@ int main(int argc, char *argv[])
FILE *fPtr = fopen(l_ROMFilepath, "rb");
if (fPtr == NULL)
{
- fprintf(stderr, "Error: couldn't open ROM file '%s' for reading.\n", l_ROMFilepath);
+ DebugMessage(M64MSG_ERROR, "couldn't open ROM file '%s' for reading.", l_ROMFilepath);
(*CoreShutdown)();
DetachCoreLib();
return 7;
@@ -638,7 +658,7 @@ int main(int argc, char *argv[])
unsigned char *ROM_buffer = (unsigned char *) malloc(romlength);
if (ROM_buffer == NULL)
{
- fprintf(stderr, "Error: couldn't allocate %li-byte buffer for ROM image file '%s'.\n", romlength, l_ROMFilepath);
+ DebugMessage(M64MSG_ERROR, "couldn't allocate %li-byte buffer for ROM image file '%s'.", romlength, l_ROMFilepath);
fclose(fPtr);
(*CoreShutdown)();
DetachCoreLib();
@@ -646,7 +666,7 @@ int main(int argc, char *argv[])
}
else if (fread(ROM_buffer, 1, romlength, fPtr) != romlength)
{
- fprintf(stderr, "Error: couldn't read %li bytes from ROM image file '%s'.\n", romlength, l_ROMFilepath);
+ DebugMessage(M64MSG_ERROR, "couldn't read %li bytes from ROM image file '%s'.", romlength, l_ROMFilepath);
free(ROM_buffer);
fclose(fPtr);
(*CoreShutdown)();
@@ -658,7 +678,7 @@ int main(int argc, char *argv[])
/* Try to load the ROM image into the core */
if ((*CoreDoCommand)(M64CMD_ROM_OPEN, (int) romlength, ROM_buffer) != M64ERR_SUCCESS)
{
- fprintf(stderr, "Error: core failed to open ROM image file '%s'.\n", l_ROMFilepath);
+ DebugMessage(M64MSG_ERROR, "core failed to open ROM image file '%s'.", l_ROMFilepath);
free(ROM_buffer);
(*CoreShutdown)();
DetachCoreLib();
@@ -691,7 +711,7 @@ int main(int argc, char *argv[])
{
if ((*CoreAttachPlugin)(g_PluginMap[i].type, g_PluginMap[i].handle) != M64ERR_SUCCESS)
{
- fprintf(stderr, "UI-Console: error from core while attaching %s plugin.\n", g_PluginMap[i].name);
+ DebugMessage(M64MSG_ERROR, "core error while attaching %s plugin.", g_PluginMap[i].name);
(*CoreDoCommand)(M64CMD_ROM_CLOSE, 0, NULL);
(*CoreShutdown)();
DetachCoreLib();
@@ -704,7 +724,7 @@ int main(int argc, char *argv[])
{
if ((*CoreDoCommand)(M64CMD_SET_FRAME_CALLBACK, 0, FrameCallback) != M64ERR_SUCCESS)
{
- fprintf(stderr, "UI-Console: warning: couldn't set frame callback, so --testshots won't work.\n");
+ DebugMessage(M64MSG_WARNING, "couldn't set frame callback, so --testshots won't work.");
}
}
diff --git a/src/main.h b/src/main.h
index edf2dfc..5ab3752 100644
--- a/src/main.h
+++ b/src/main.h
@@ -22,6 +22,7 @@
#ifndef __MAIN_H__
#define __MAIN_H__
+extern void DebugMessage(int level, const char *message, ...);
extern void DebugCallback(void *Context, int level, const char *message);
extern int g_Verbose;
diff --git a/src/osal_dynamiclib_unix.c b/src/osal_dynamiclib_unix.c
index 67eea2b..870db48 100644
--- a/src/osal_dynamiclib_unix.c
+++ b/src/osal_dynamiclib_unix.c
@@ -24,6 +24,7 @@
#include <stdio.h>
#include <dlfcn.h>
+#include "main.h"
#include "m64p_types.h"
#include "osal_dynamiclib.h"
@@ -39,7 +40,7 @@ m64p_error osal_dynlib_open(m64p_dynlib_handle *pLibHandle, const char *pccLibra
/* only print an error message if there is a directory separator (/) in the pathname */
/* this prevents us from throwing an error for the use case where Mupen64Plus is not installed */
if (strchr(pccLibraryPath, '/') != NULL)
- fprintf(stderr, "dlopen('%s') error: %s\n", pccLibraryPath, dlerror());
+ DebugMessage(M64MSG_ERROR, "dlopen('%s') failed: %s", pccLibraryPath, dlerror());
return M64ERR_INPUT_NOT_FOUND;
}
@@ -60,7 +61,7 @@ m64p_error osal_dynlib_close(m64p_dynlib_handle LibHandle)
if (rval != 0)
{
- fprintf(stderr, "dlclose() error: %s\n", dlerror());
+ DebugMessage(M64MSG_ERROR, "dlclose() failed: %s", dlerror());
return M64ERR_INTERNAL;
}
diff --git a/src/osal_dynamiclib_win32.c b/src/osal_dynamiclib_win32.c
index 4455cee..052fd79 100644
--- a/src/osal_dynamiclib_win32.c
+++ b/src/osal_dynamiclib_win32.c
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <stdio.h>
+#include "main.h"
#include "m64p_types.h"
#include "osal_dynamiclib.h"
@@ -39,7 +40,7 @@ m64p_error osal_dynlib_open(m64p_dynlib_handle *pLibHandle, const char *pccLibra
DWORD dwErr = GetLastError();
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwErr,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &pchErrMsg, 0, NULL);
- fprintf(stderr, "LoadLibrary('%s') error: %s\n", pccLibraryPath, pchErrMsg);
+ DebugMessage(M64MSG_ERROR, "LoadLibrary('%s') error: %s", pccLibraryPath, pchErrMsg);
LocalFree(pchErrMsg);
return M64ERR_INPUT_NOT_FOUND;
}
@@ -65,7 +66,7 @@ m64p_error osal_dynlib_close(m64p_dynlib_handle LibHandle)
DWORD dwErr = GetLastError();
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwErr,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &pchErrMsg, 0, NULL);
- fprintf(stderr, "FreeLibrary() error: %s\n", pchErrMsg);
+ DebugMessage(M64MSG_ERROR, "FreeLibrary() error: %s", pchErrMsg);
LocalFree(pchErrMsg);
return M64ERR_INTERNAL;
}
diff --git a/src/osal_files_unix.c b/src/osal_files_unix.c
index 60377fb..2199271 100644
--- a/src/osal_files_unix.c
+++ b/src/osal_files_unix.c
@@ -29,6 +29,7 @@
#include <sys/types.h>
#include <dirent.h> // for opendir(), readdir(), closedir()
+#include "main.h"
#include "m64p_types.h"
#include "osal_preproc.h"
#include "osal_files.h"
@@ -68,7 +69,7 @@ osal_lib_search *osal_library_search(const char *searchpath)
newlib = malloc(sizeof(osal_lib_search));
if (newlib == NULL)
{
- fprintf(stderr, "Memory allocation error in osal_library_search()!\n");
+ DebugMessage(M64MSG_ERROR, "Memory allocation error in osal_library_search()!");
osal_free_lib_list(head);
closedir(dir);
return NULL;
diff --git a/src/osal_files_win32.c b/src/osal_files_win32.c
index acd112e..0cd3f2c 100644
--- a/src/osal_files_win32.c
+++ b/src/osal_files_win32.c
@@ -28,6 +28,7 @@
#include <string.h>
#include <windows.h>
+#include "main.h"
#include "m64p_types.h"
#include "osal_preproc.h"
#include "osal_files.h"
@@ -45,7 +46,7 @@ osal_lib_search *osal_library_search(const char *searchpath)
char *pchSearchPath = (char *) malloc(strlen(searchpath) + 16);
if (pchSearchPath == NULL)
{
- fprintf(stderr, "Couldn't allocate memory for file search path in osal_library_search()!\n");
+ DebugMessage(M64MSG_ERROR, "Couldn't allocate memory for file search path in osal_library_search()!");
return NULL;
}
sprintf(pchSearchPath, "%s\\*.dll", searchpath);
@@ -62,7 +63,7 @@ osal_lib_search *osal_library_search(const char *searchpath)
newlib = (osal_lib_search *) malloc(sizeof(osal_lib_search));
if (newlib == NULL)
{
- fprintf(stderr, "Memory allocation error in osal_library_search()!\n");
+ DebugMessage(M64MSG_ERROR, "Memory allocation error in osal_library_search()!");
osal_free_lib_list(head);
FindClose(hDir);
return NULL;
diff --git a/src/plugin.c b/src/plugin.c
index 671a5e6..a8edb78 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -58,7 +58,7 @@ static m64p_error PluginLoadTry(const char *filepath, int MapIndex)
if (PluginGetVersion == NULL)
{
if (g_Verbose)
- fprintf(stderr, "Error: library '%s' is not a Mupen64Plus library.\n", filepath);
+ DebugMessage(M64MSG_ERROR, "library '%s' is not a Mupen64Plus library.", filepath);
osal_dynlib_close(handle);
return M64ERR_INCOMPATIBLE;
}
@@ -78,14 +78,14 @@ static m64p_error PluginLoadTry(const char *filepath, int MapIndex)
ptr_PluginStartup PluginStartup = (ptr_PluginStartup) osal_dynlib_getproc(handle, "PluginStartup");
if (PluginStartup == NULL)
{
- fprintf(stderr, "Error: library '%s' broken. No PluginStartup() function found.\n", filepath);
+ DebugMessage(M64MSG_ERROR, "library '%s' broken. No PluginStartup() function found.", filepath);
osal_dynlib_close(handle);
return M64ERR_INCOMPATIBLE;
}
rval = (*PluginStartup)(CoreHandle, g_PluginMap[MapIndex].name, DebugCallback); /* DebugCallback is in main.c */
if (rval != M64ERR_SUCCESS)
{
- fprintf(stderr, "Error: %s plugin library '%s' failed to start.\n", g_PluginMap[MapIndex].name, filepath);
+ DebugMessage(M64MSG_ERROR, "Error: %s plugin library '%s' failed to start.", g_PluginMap[MapIndex].name, filepath);
osal_dynlib_close(handle);
return rval;
}
@@ -111,7 +111,7 @@ m64p_error PluginSearchLoad(m64p_handle ConfigUI)
lib_filelist = osal_library_search(g_PluginDir);
if (lib_filelist == NULL)
{
- fprintf(stderr, "Error: No plugins found in --plugindir path: %s\n", g_PluginDir);
+ DebugMessage(M64MSG_ERROR, "No plugins found in --plugindir path: %s", g_PluginDir);
return M64ERR_INPUT_NOT_FOUND;
}
}
@@ -174,7 +174,7 @@ m64p_error PluginSearchLoad(m64p_handle ConfigUI)
/* exit with error if we couldn't find the specified plugin */
if (!use_dummy && g_PluginMap[i].handle == NULL)
{
- fprintf(stderr, "Error: Specified %s plugin not found: %s\n", g_PluginMap[i].name, cmdline_path);
+ DebugMessage(M64MSG_ERROR, "Specified %s plugin not found: %s", g_PluginMap[i].name, cmdline_path);
osal_free_lib_list(lib_filelist);
return M64ERR_INPUT_NOT_FOUND;
}
@@ -218,14 +218,13 @@ m64p_error PluginSearchLoad(m64p_handle ConfigUI)
/* print out the particular plugin used */
if (g_PluginMap[i].handle == NULL)
{
- printf("UI-console: using %s plugin: <dummy>\n", g_PluginMap[i].name);
+ DebugMessage(M64MSG_INFO, "using %s plugin: <dummy>", g_PluginMap[i].name);
}
else
{
- printf("UI-console: using %s plugin: '%s' v%i.%i.%i\n", g_PluginMap[i].name,
+ DebugMessage(M64MSG_INFO, "using %s plugin: '%s' v%i.%i.%i", g_PluginMap[i].name,
g_PluginMap[i].libname, VERSION_PRINTF_SPLIT(g_PluginMap[i].libversion));
- if (g_Verbose)
- printf("UI-console: %s plugin library: %s\n", g_PluginMap[i].name, g_PluginMap[i].filename);
+ DebugMessage(M64MSG_VERBOSE, "%s plugin library: %s", g_PluginMap[i].name, g_PluginMap[i].filename);
}
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/mupen64plus-ui-console.git
More information about the Pkg-games-commits
mailing list