forked from balika011/prxtool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
output.C
51 lines (42 loc) · 974 Bytes
/
output.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/***************************************************************
* PRXTool : Utility for PSP executables.
* (c) TyRaNiD 2k5
*
* Output.C - Static class to handle information and debug
* textual output.
***************************************************************/
#include <stdio.h>
#include <stdarg.h>
#include "output.h"
bool COutput::m_blDebug = false;
OutputHandler COutput::m_fnOutput = NULL;
void COutput::SetDebug(bool blDebug)
{
m_blDebug = blDebug;
}
bool COutput::GetDebug()
{
return m_blDebug;
}
void COutput::SetOutputHandler(OutputHandler fn)
{
m_fnOutput = fn;
}
void COutput::Puts(OutputLevel level, const char *str)
{
Printf(level, "%s\n", str);
}
void COutput::Printf(OutputLevel level, const char *str, ...)
{
va_list opt;
char buff[2048];
va_start(opt, str);
(void) vsnprintf(buff, (size_t) sizeof(buff), str, opt);
if(m_fnOutput != NULL)
{
if((level != LEVEL_DEBUG) || (m_blDebug))
{
m_fnOutput(level, buff);
}
}
}