+NCURSES_EXPORT(int)
+NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_DCLx TTY * buf)
+{
+ int result = OK;
+
+ if (buf == 0 || SP_PARM == 0) {
+ result = ERR;
+ } else {
+ TERMINAL *termp = TerminalOf(SP_PARM);
+
+ if (0 == termp) {
+ result = ERR;
+ } else {
+#ifdef USE_TERM_DRIVER
+ result = CallDriver_2(SP_PARM, sgmode, TRUE, buf);
+#else
+ for (;;) {
+ if ((SET_TTY(termp->Filedes, buf) != 0)
+#if USE_KLIBC_KBD
+ && !isatty(termp->Filedes)
+#endif
+ ) {
+ if (errno == EINTR)
+ continue;
+ if ((errno == ENOTTY) && (SP_PARM != 0))
+ SP_PARM->_notty = TRUE;
+ result = ERR;
+ }
+ break;
+ }
+#endif
+ }
+ TR(TRACE_BITS, ("_nc_set_tty_mode(%d): %s",
+ termp ? termp->Filedes : -1,
+ _nc_trace_ttymode(buf)));
+ }
+ return (result);
+}
+
+#if NCURSES_SP_FUNCS