libc fprintf implementation for stdout,stderr case (needed from undertale)
This commit is contained in:
parent
7b276e0a08
commit
c126925dd9
|
@ -109,9 +109,12 @@ void libcSymbolsRegister(SymbolsResolver* sym) {
|
||||||
LIB_FUNCTION("hcuQgD53UxM", "libc", 1, "libc", 1, 1, printf);
|
LIB_FUNCTION("hcuQgD53UxM", "libc", 1, "libc", 1, 1, printf);
|
||||||
LIB_FUNCTION("Q2V+iqvjgC0", "libc", 1, "libc", 1, 1, vsnprintf);
|
LIB_FUNCTION("Q2V+iqvjgC0", "libc", 1, "libc", 1, 1, vsnprintf);
|
||||||
LIB_FUNCTION("YQ0navp+YIc", "libc", 1, "libc", 1, 1, puts);
|
LIB_FUNCTION("YQ0navp+YIc", "libc", 1, "libc", 1, 1, puts);
|
||||||
|
LIB_FUNCTION("fffwELXNVFA", "libc", 1, "libc", 1, 1, fprintf);
|
||||||
|
|
||||||
// misc
|
// misc
|
||||||
LIB_OBJ("P330P3dFF68", "libc", 1, "libc", 1, 1, &g_need_sceLibc);
|
LIB_OBJ("P330P3dFF68", "libc", 1, "libc", 1, 1, &g_need_sceLibc);
|
||||||
|
LIB_OBJ("2sWzhYqFH4E","libc", 1, "libc", 1, 1,stdout);
|
||||||
|
LIB_OBJ("H8AprKeZtNg", "libc", 1, "libc", 1, 1, stderr);
|
||||||
LIB_FUNCTION("bzQExy189ZI", "libc", 1, "libc", 1, 1, init_env);
|
LIB_FUNCTION("bzQExy189ZI", "libc", 1, "libc", 1, 1, init_env);
|
||||||
LIB_FUNCTION("XKRegsFpEpk", "libc", 1, "libc", 1, 1, catchReturnFromMain);
|
LIB_FUNCTION("XKRegsFpEpk", "libc", 1, "libc", 1, 1, catchReturnFromMain);
|
||||||
LIB_FUNCTION("-QgqOT5u2Vk", "libc", 1, "libc", 1, 1, _Assert);
|
LIB_FUNCTION("-QgqOT5u2Vk", "libc", 1, "libc", 1, 1, _Assert);
|
||||||
|
|
|
@ -1,10 +1,25 @@
|
||||||
#include "libc_stdio.h"
|
#include "libc_stdio.h"
|
||||||
|
|
||||||
|
#include <debug.h>
|
||||||
|
#include <Util/log.h>
|
||||||
|
|
||||||
namespace Core::Libraries::LibC {
|
namespace Core::Libraries::LibC {
|
||||||
|
constexpr bool log_file_libc = true; // disable it to disable logging
|
||||||
|
|
||||||
int PS4_SYSV_ABI printf(VA_ARGS) {
|
int PS4_SYSV_ABI printf(VA_ARGS) {
|
||||||
VA_CTX(ctx);
|
VA_CTX(ctx);
|
||||||
return printf_ctx(&ctx);
|
return printf_ctx(&ctx);
|
||||||
}
|
}
|
||||||
|
int PS4_SYSV_ABI fprintf(FILE* file, VA_ARGS) {
|
||||||
|
int fd = _fileno(file);
|
||||||
|
if (fd == 1 || fd == 2) { // output stdout and stderr to console
|
||||||
|
VA_CTX(ctx);
|
||||||
|
return printf_ctx(&ctx);
|
||||||
|
}
|
||||||
|
LOG_ERROR_IF(log_file_libc, "libc:Unimplemented fprintf case\n");
|
||||||
|
BREAKPOINT();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI vsnprintf(char* s, size_t n, const char* format, VaList* arg) { return vsnprintf_ctx(s, n, format, arg); }
|
int PS4_SYSV_ABI vsnprintf(char* s, size_t n, const char* format, VaList* arg) { return vsnprintf_ctx(s, n, format, arg); }
|
||||||
|
|
||||||
|
|
|
@ -8,4 +8,5 @@ namespace Core::Libraries::LibC {
|
||||||
int PS4_SYSV_ABI printf(VA_ARGS);
|
int PS4_SYSV_ABI printf(VA_ARGS);
|
||||||
int PS4_SYSV_ABI vsnprintf(char* s, size_t n, const char* format, VaList* arg);
|
int PS4_SYSV_ABI vsnprintf(char* s, size_t n, const char* format, VaList* arg);
|
||||||
int PS4_SYSV_ABI puts(const char* s);
|
int PS4_SYSV_ABI puts(const char* s);
|
||||||
|
int PS4_SYSV_ABI fprintf(FILE* file, VA_ARGS);
|
||||||
} // namespace Core::Libraries::LibC
|
} // namespace Core::Libraries::LibC
|
Loading…
Reference in New Issue