Blob Blame History Raw
/***********************************************************/
/*  ntux: native translation und extension                 */
/*  Copyright (C) 2016--2018  Z. Gilboa                    */
/*  Released under GPLv2 and GPLv3; see COPYING.NTUX.      */
/***********************************************************/

#include <ntapi/ntapi.h>
#include <psxabi/sys_sysapi.h>
#include <psxabi/sys_errno.h>

extern const ntapi_vtbl * ntux_ntapi;

int ntux_sprintf(char * str, const char * fmt, ...)
{
	int     ret;
	va_list ap;

	va_start(ap, fmt);
	ret = ntux_ntapi->vsprintf(str, fmt, ap);
	va_end(ap);

	return ret;
}

int ntux_snprintf(char * str, size_t n, const char * fmt, ...)
{
	int     ret;
	va_list ap;

	va_start(ap, fmt);
	ret = ntux_ntapi->vsnprintf(str, n, fmt, ap);
	va_end(ap);

	return ret;
}

int ntux_isatty(int fildes)
{
	nt_runtime_data * rtdata;

	if ((ntux_ntapi->tt_get_runtime_data(&rtdata,0)))
		return 0;

	if (fildes == 0)
		return (rtdata->stdin_type == NT_FILE_TYPE_PTY);

	else if (fildes == 1)
		return (rtdata->stdout_type == NT_FILE_TYPE_PTY);

	else if (fildes == 2)
		return (rtdata->stderr_type == NT_FILE_TYPE_PTY);

	else
		return 0;
}