mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-23 18:45:36 +00:00
sprintf implementation
This commit is contained in:
parent
9b8615e99b
commit
49090c1ba5
@ -441,7 +441,7 @@ void libcSymbolsRegister(Loader::SymbolsResolver* sym) {
|
|||||||
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);
|
LIB_FUNCTION("fffwELXNVFA", "libc", 1, "libc", 1, 1, fprintf);
|
||||||
LIB_FUNCTION("eLdDw6l0-bU", "libc", 1, "libc", 1, 1, snprintf);
|
LIB_FUNCTION("eLdDw6l0-bU", "libc", 1, "libc", 1, 1, snprintf);
|
||||||
|
LIB_FUNCTION("tcVi5SivF7Q", "libc", 1, "libc", 1, 1, sprintf);
|
||||||
// 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("2sWzhYqFH4E","libc", 1, "libc", 1, 1,stdout);
|
||||||
|
@ -27,6 +27,11 @@ int PS4_SYSV_ABI snprintf(char* s, size_t n, VA_ARGS) {
|
|||||||
return snprintf_ctx(s, n, &ctx);
|
return snprintf_ctx(s, n, &ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int PS4_SYSV_ABI sprintf(char* s,VA_ARGS) {
|
||||||
|
VA_CTX(ctx);
|
||||||
|
return sprintf_ctx(s,&ctx);
|
||||||
|
}
|
||||||
|
|
||||||
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) {
|
||||||
return vsnprintf_ctx(s, n, format, arg);
|
return vsnprintf_ctx(s, n, format, arg);
|
||||||
}
|
}
|
||||||
|
@ -10,4 +10,5 @@ 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);
|
int PS4_SYSV_ABI fprintf(FILE* file, VA_ARGS);
|
||||||
int PS4_SYSV_ABI snprintf(char* s, size_t n, VA_ARGS);
|
int PS4_SYSV_ABI snprintf(char* s, size_t n, VA_ARGS);
|
||||||
} // namespace Core::Libraries::LibC
|
int PS4_SYSV_ABI sprintf(char* s, VA_ARGS);
|
||||||
|
} // namespace Core::Libraries::LibC
|
||||||
|
@ -702,6 +702,14 @@ static int snprintf_ctx(char* s, size_t n,VaCtx* ctx) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int sprintf_ctx(char* s, VaCtx* ctx) {
|
||||||
|
const char* format = vaArgPtr<const char>(&ctx->va_list);
|
||||||
|
char buffer[256]; // it is big enough?
|
||||||
|
int result = _vsnprintf(_out_buffer, buffer, format, &ctx->va_list);
|
||||||
|
std::strcpy(s, buffer);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
static int vsnprintf_ctx(char* s, size_t n, const char* format, VaList* arg) {
|
static int vsnprintf_ctx(char* s, size_t n, const char* format, VaList* arg) {
|
||||||
char buffer[n];
|
char buffer[n];
|
||||||
int result = _vsnprintf(_out_buffer, buffer, format, arg);
|
int result = _vsnprintf(_out_buffer, buffer, format, arg);
|
||||||
|
Loading…
Reference in New Issue
Block a user