--- ray/src/rt/devcomm.c 1990/01/19 00:00:08 1.10 +++ ray/src/rt/devcomm.c 1990/02/22 12:45:27 1.13 @@ -12,8 +12,6 @@ static char SCCSid[] = "$SunId$ LBL"; #include "standard.h" -#include - #include "color.h" #include "driver.h" @@ -26,20 +24,16 @@ static char SCCSid[] = "$SunId$ LBL"; #define vfork fork #endif -#ifndef WFLUSH -#define WFLUSH 30 /* flush after this many rays */ -#endif - extern char *getpath(), *getenv(); int onsigio(); int comm_close(), comm_clear(), comm_paintr(), comm_errout(), - comm_getcur(), comm_comout(), comm_comin(); + comm_getcur(), comm_comout(), comm_comin(), comm_flush(); -struct driver comm_driver, comm_default = { +struct driver comm_driver = { comm_close, comm_clear, comm_paintr, comm_getcur, - comm_comout, comm_comin + comm_comout, comm_comin, comm_flush }; FILE *devin, *devout; @@ -80,7 +74,6 @@ char *dname, *id; goto syserr; if ((devin = fdopen(p2[0], "r")) == NULL) goto syserr; - copystruct(&comm_driver, &comm_default); /* verify & get resolution */ putw(COM_SENDM, devout); fflush(devout); @@ -90,8 +83,6 @@ char *dname, *id; sizeof(comm_driver.pixaspect), 1, devin); comm_driver.xsiz = getw(devin); comm_driver.ysiz = getw(devin); - /* input handling */ - signal(SIGIO, onsigio); /* set error vectors */ cmdvec = comm_comout; if (wrnvec != NULL) @@ -111,7 +102,6 @@ comm_close() /* done with driver */ cmdvec = NULL; /* reset error vectors */ if (wrnvec != NULL) wrnvec = stderr_v; - signal(SIGIO, SIG_DFL); fclose(devout); fclose(devin); while ((pid = wait(0)) != -1 && pid != devchild) @@ -135,22 +125,26 @@ comm_paintr(col, xmin, ymin, xmax, ymax) /* paint a re COLOR col; int xmin, ymin, xmax, ymax; { - extern long nrays; /* number of rays traced */ - static long lastflush = 0; /* ray count at last flush */ - putc(COM_PAINTR, devout); fwrite((char *)col, sizeof(COLOR), 1, devout); putw(xmin, devout); putw(ymin, devout); putw(xmax, devout); putw(ymax, devout); - if (nrays - lastflush >= WFLUSH) { - fflush(devout); - lastflush = nrays; - } } +static +comm_flush() /* flush output to driver */ +{ + putc(COM_FLUSH, devout); + fflush(devout); + if (getc(devin) != COM_FLUSH) + reply_error("flush"); + comm_driver.inpready = getw(devin); +} + + static int comm_getcur(xp, yp) /* get and return cursor position */ int *xp, *yp; @@ -179,16 +173,22 @@ char *str; static -comm_comin(buf) /* read string from command line */ +comm_comin(buf, prompt) /* read string from command line */ char *buf; +char *prompt; { putc(COM_COMIN, devout); + if (prompt == NULL) + putc(0, devout); + else { + putc(1, devout); + myputs(prompt, devout); + } fflush(devout); if (getc(devin) != COM_COMIN) reply_error("comin"); mygets(buf, devin); - if (comm_driver.inpready > 0) - comm_driver.inpready--; + comm_driver.inpready = getw(devin); } @@ -233,11 +233,4 @@ char *routine; stderr_v(routine); stderr_v(": driver reply error\n"); quit(1); -} - - -static -onsigio() /* input ready */ -{ - comm_driver.inpready++; }