mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-04-20 03:24:49 +00:00
snprintf implementation
This commit is contained in:
parent
7631ebb76f
commit
9b8615e99b
4 changed files with 15 additions and 1 deletions
|
@ -440,6 +440,7 @@ void libcSymbolsRegister(Loader::SymbolsResolver* sym) {
|
|||
LIB_FUNCTION("Q2V+iqvjgC0", "libc", 1, "libc", 1, 1, vsnprintf);
|
||||
LIB_FUNCTION("YQ0navp+YIc", "libc", 1, "libc", 1, 1, puts);
|
||||
LIB_FUNCTION("fffwELXNVFA", "libc", 1, "libc", 1, 1, fprintf);
|
||||
LIB_FUNCTION("eLdDw6l0-bU", "libc", 1, "libc", 1, 1, snprintf);
|
||||
|
||||
// misc
|
||||
LIB_OBJ("P330P3dFF68", "libc", 1, "libc", 1, 1, &g_need_sceLibc);
|
||||
|
|
|
@ -22,6 +22,11 @@ int PS4_SYSV_ABI fprintf(FILE* file, VA_ARGS) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI snprintf(char* s, size_t n, VA_ARGS) {
|
||||
VA_CTX(ctx);
|
||||
return snprintf_ctx(s, n, &ctx);
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI vsnprintf(char* s, size_t n, const char* format, VaList* arg) {
|
||||
return vsnprintf_ctx(s, n, format, arg);
|
||||
}
|
||||
|
|
|
@ -9,5 +9,5 @@ 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 puts(const char* s);
|
||||
int PS4_SYSV_ABI fprintf(FILE* file, VA_ARGS);
|
||||
|
||||
int PS4_SYSV_ABI snprintf(char* s, size_t n, VA_ARGS);
|
||||
} // namespace Core::Libraries::LibC
|
||||
|
|
|
@ -694,6 +694,14 @@ static int printf_ctx(VaCtx* ctx) {
|
|||
return result;
|
||||
}
|
||||
|
||||
static int snprintf_ctx(char* s, size_t n,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::strncpy(s, buffer,n);
|
||||
return result;
|
||||
}
|
||||
|
||||
static int vsnprintf_ctx(char* s, size_t n, const char* format, VaList* arg) {
|
||||
char buffer[n];
|
||||
int result = _vsnprintf(_out_buffer, buffer, format, arg);
|
||||
|
|
Loading…
Add table
Reference in a new issue