Пример #1
0
NCURSES_SP_NAME(_nc_outch) (NCURSES_SP_DCLx int ch)
{
    int rc = OK;

    COUNT_OUTCHARS(1);

    if (HasTInfoTerminal(SP_PARM)
	&& SP_PARM != 0) {
	if (SP_PARM->out_buffer != 0) {
	    if (SP_PARM->out_inuse + 1 >= SP_PARM->out_limit)
		NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);
	    SP_PARM->out_buffer[SP_PARM->out_inuse++] = (char) ch;
	} else {
	    char tmp = (char) ch;
	    /*
	     * POSIX says write() is safe in a signal handler, but the
	     * buffered I/O is not.
	     */
	    if (write(fileno(NC_OUTPUT(SP_PARM)), &tmp, (size_t) 1) == -1)
		rc = ERR;
	}
    } else {
	char tmp = (char) ch;
	if (write(fileno(stdout), &tmp, (size_t) 1) == -1)
	    rc = ERR;
    }
    return rc;
}
Пример #2
0
_nc_outch(int ch)
{
    COUNT_OUTCHARS(1);

    if (SP != 0
	&& SP->_cleanup) {
	char tmp = ch;
	/*
	 * POSIX says write() is safe in a signal handler, but the
	 * buffered I/O is not.
	 */
	write(fileno(NC_OUTPUT), &tmp, 1);
    } else {
	putc(ch, NC_OUTPUT);
    }
    return OK;
}
Пример #3
0
NCURSES_SP_NAME(_nc_outch) (NCURSES_SP_DCLx int ch)
{
    int rc = OK;

    COUNT_OUTCHARS(1);

    if (HasTInfoTerminal(SP_PARM)
	&& SP_PARM != 0
	&& SP_PARM->_cleanup) {
	char tmp = (char) ch;
	/*
	 * POSIX says write() is safe in a signal handler, but the
	 * buffered I/O is not.
	 */
	if (write(fileno(NC_OUTPUT(SP_PARM)), &tmp, 1) == -1)
	    rc = ERR;
    } else {
	if (putc(ch, NC_OUTPUT(SP_PARM)) == EOF)
	    rc = ERR;
    }
    return rc;
}