Esempio n. 1
0
File: stdio.c Progetto: esxgx/uofw
// 0244
void printf_char(void *ctx, int ch)
{   
    dbg_printf("Calling %s\n", __FUNCTION__);
    if (ch == 0x200) {
        *(short*)(ctx + 2) = 0;
        return;
    }
    if (ch == 0x201)
    {   
        // 031C
        short cnt = *(short*)(ctx + 2);
        if (cnt <= 0)
            return;

        if (sceKernelDipsw(59) == 1)
            sceKernelDebugWrite(*(short*)(ctx + 0), ctx + 4, *(short*)(ctx + 2));
        else
        {   
            short fd = *(short*)(ctx + 0);
            if (fd == STDOUT)
                fd = g_stdout;
            // 0348
            if (fd == STDERR)
                fd = g_stderr;
            // 0354
            sceIoWrite(fd, ctx + 4, *(short*)(ctx + 2));
        }
        return;
    }
    if (ch == '\n') {
        // 030C
        printf_char(ctx, '\r');
    }
    // 027C
    (*(short*)(ctx + 2))++;
    *(char*)(ctx + 3 + *(short*)(ctx + 2)) = ch;
    if (ch == '\200')
    {   
        short fd = *(short*)(ctx + 0);
        // 02AC
        if (sceKernelDipsw(59) == 1)
        {   
            // 02F8
            sceKernelDebugWrite(fd, ctx + 4, *(short*)(ctx + 2));
        }
        else
        {   
            if (fd == STDOUT)
                fd = g_stdout;
            // 02C8
            if (fd == STDERR)
                fd = g_stderr;
            // 02D4
            sceIoWrite(fd, ctx + 4, *(short*)(ctx + 2));
        }
        *(short*)(ctx + 2) = 0;
    }
}
Esempio n. 2
0
static int	printf_type(t_printf *p, const int flag)
{
	if (flag & C_WCHAR)
		return (printf_wchar(p));
	if (flag & C_WSTRING)
		return (printf_wstring(p));
	if (flag & C_STRING)
		return (printf_string(p));
	if (flag & C_CHAR)
		return (printf_char(p));
	if (flag & (C_INT | C_LONG))
		return (printf_long(p, p->arg));
	if (flag & C_UINT)
		return (printf_ulong_base(p, p->arg, 10));
	if (flag & C_ULONG)
		return (printf_ulong_base(p, p->arg, 10));
	if (flag & (C_HEXA | C_MHEXA))
		return (printf_ulong_base(p, p->arg, 16));
	if (flag & (C_LOCTAL | C_OCTAL))
		return (printf_ulong_base(p, p->arg, 8));
	if (flag & C_BIN)
		return (printf_ulong_base(p, p->arg, 2));
	return (1);
}