- nullcount = (ms * _nc_baudrate(ospeed)) / 10000;
- for (_nc_nulls_sent += nullcount; nullcount > 0; nullcount--)
- my_outch(PC);
- if (my_outch == _nc_outch)
- _nc_flush();
+ nullcount = (ms * _nc_baudrate(ospeed)) / (BAUDBYTE * 1000);
+ for (_nc_nulls_sent += nullcount; nullcount > 0; nullcount--)
+ my_outch(NCURSES_SP_ARGx PC);
+ if (my_outch == NCURSES_SP_NAME(_nc_outch))
+ NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);
+ }
+
+ returnCode(OK);
+}
+
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(int)
+delay_output(int ms)
+{
+ return NCURSES_SP_NAME(delay_output) (CURRENT_SCREEN, ms);
+}
+#endif
+
+NCURSES_EXPORT(void)
+NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_DCL0)
+{
+ if (SP_PARM != 0 && SP_PARM->_ofd >= 0) {
+ if (SP_PARM->out_inuse) {
+ char *buf = SP_PARM->out_buffer;
+ size_t amount = SP->out_inuse;
+
+ SP->out_inuse = 0;
+ TR(TRACE_CHARPUT, ("flushing %ld bytes", (unsigned long) amount));
+ while (amount) {
+ ssize_t res = write(SP_PARM->_ofd, buf, amount);
+
+ if (res > 0) {
+ /* if the write was incomplete, try again */
+ amount -= (size_t) res;
+ buf += res;
+ } else if (errno == EAGAIN) {
+ continue;
+ } else if (errno == EINTR) {
+ continue;
+ } else {
+ break; /* an error we can not recover from */
+ }
+ }