Blame src/internal/ntux_ntaio_impl.c
|
|
26e14f |
/***********************************************************/
|
|
|
26e14f |
/* ntux: native translation und extension */
|
|
|
db57dd |
/* Copyright (C) 2016--2018 Z. Gilboa */
|
|
|
26e14f |
/* Released under GPLv2 and GPLv3; see COPYING.NTUX. */
|
|
|
26e14f |
/***********************************************************/
|
|
|
26e14f |
|
|
|
26e14f |
#include <ntapi/ntapi.h>
|
|
|
26e14f |
#include <psxabi/sys_sysapi.h>
|
|
|
26e14f |
#include <psxabi/sys_errno.h>
|
|
|
26e14f |
|
|
|
26e14f |
extern const ntapi_vtbl * ntux_ntapi;
|
|
|
26e14f |
|
|
|
26e14f |
int ntux_sprintf(char * str, const char * fmt, ...)
|
|
|
26e14f |
{
|
|
|
26e14f |
int ret;
|
|
|
26e14f |
va_list ap;
|
|
|
26e14f |
|
|
|
26e14f |
va_start(ap, fmt);
|
|
|
26e14f |
ret = ntux_ntapi->vsprintf(str, fmt, ap);
|
|
|
26e14f |
va_end(ap);
|
|
|
26e14f |
|
|
|
26e14f |
return ret;
|
|
|
26e14f |
}
|
|
|
26e14f |
|
|
|
26e14f |
int ntux_snprintf(char * str, size_t n, const char * fmt, ...)
|
|
|
26e14f |
{
|
|
|
26e14f |
int ret;
|
|
|
26e14f |
va_list ap;
|
|
|
26e14f |
|
|
|
26e14f |
va_start(ap, fmt);
|
|
|
26e14f |
ret = ntux_ntapi->vsnprintf(str, n, fmt, ap);
|
|
|
26e14f |
va_end(ap);
|
|
|
26e14f |
|
|
|
26e14f |
return ret;
|
|
|
26e14f |
}
|
|
|
26e14f |
|
|
|
26e14f |
int ntux_isatty(int fildes)
|
|
|
26e14f |
{
|
|
|
26e14f |
nt_runtime_data * rtdata;
|
|
|
26e14f |
|
|
|
26e14f |
if ((ntux_ntapi->tt_get_runtime_data(&rtdata,0)))
|
|
|
26e14f |
return 0;
|
|
|
26e14f |
|
|
|
26e14f |
if (fildes == 0)
|
|
|
26e14f |
return (rtdata->stdin_type == NT_FILE_TYPE_PTY);
|
|
|
26e14f |
|
|
|
26e14f |
else if (fildes == 1)
|
|
|
26e14f |
return (rtdata->stdout_type == NT_FILE_TYPE_PTY);
|
|
|
26e14f |
|
|
|
26e14f |
else if (fildes == 2)
|
|
|
26e14f |
return (rtdata->stderr_type == NT_FILE_TYPE_PTY);
|
|
|
26e14f |
|
|
|
26e14f |
else
|
|
|
26e14f |
return 0;
|
|
|
26e14f |
}
|