--- ray/src/rt/devcomm.c 1990/01/08 15:07:31 1.9 +++ ray/src/rt/devcomm.c 1990/02/22 11:46:13 1.12 @@ -10,7 +10,7 @@ static char SCCSid[] = "$SunId$ LBL"; * 10/5/88 */ -#include +#include "standard.h" #include @@ -26,20 +26,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,13 +76,13 @@ char *dname, *id; goto syserr; if ((devin = fdopen(p2[0], "r")) == NULL) goto syserr; - bcopy(&comm_default, &comm_driver, sizeof(comm_driver)); /* verify & get resolution */ putw(COM_SENDM, devout); fflush(devout); if (getw(devin) != COM_RECVM) return(NULL); - fread(&comm_driver.pixaspect, sizeof(comm_driver.pixaspect), 1, devin); + fread((char *)&comm_driver.pixaspect, + sizeof(comm_driver.pixaspect), 1, devin); comm_driver.xsiz = getw(devin); comm_driver.ysiz = getw(devin); /* input handling */ @@ -134,22 +130,23 @@ 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(col, sizeof(COLOR), 1, 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); +} + + static int comm_getcur(xp, yp) /* get and return cursor position */ int *xp, *yp; @@ -178,10 +175,17 @@ 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");