ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/devcomm.c
(Generate patch)

Comparing ray/src/rt/devcomm.c (file contents):
Revision 1.10 by greg, Fri Jan 19 00:00:08 1990 UTC vs.
Revision 1.14 by greg, Wed Feb 28 16:03:57 1990 UTC

# Line 12 | Line 12 | static char SCCSid[] = "$SunId$ LBL";
12  
13   #include "standard.h"
14  
15 #include <signal.h>
16
15   #include "color.h"
16  
17   #include "driver.h"
# Line 26 | Line 24 | static char SCCSid[] = "$SunId$ LBL";
24   #define vfork           fork
25   #endif
26  
29 #ifndef WFLUSH
30 #define WFLUSH          30              /* flush after this many rays */
31 #endif
32
27   extern char     *getpath(), *getenv();
28  
29   int     onsigio();
30  
31   int     comm_close(), comm_clear(), comm_paintr(), comm_errout(),
32 <                comm_getcur(), comm_comout(), comm_comin();
32 >                comm_getcur(), comm_comout(), comm_comin(), comm_flush();
33  
34 < struct driver   comm_driver, comm_default = {
34 > struct driver   comm_driver = {
35          comm_close, comm_clear, comm_paintr, comm_getcur,
36 <        comm_comout, comm_comin
36 >        comm_comout, comm_comin, comm_flush
37   };
38  
39   FILE    *devin, *devout;
# Line 80 | Line 74 | char   *dname, *id;
74                  goto syserr;
75          if ((devin = fdopen(p2[0], "r")) == NULL)
76                  goto syserr;
83        copystruct(&comm_driver, &comm_default);
77                                                  /* verify & get resolution */
78          putw(COM_SENDM, devout);
79          fflush(devout);
# Line 90 | Line 83 | char   *dname, *id;
83                          sizeof(comm_driver.pixaspect), 1, devin);
84          comm_driver.xsiz = getw(devin);
85          comm_driver.ysiz = getw(devin);
93                                                /* input handling */
94        signal(SIGIO, onsigio);
86                                                  /* set error vectors */
87          cmdvec = comm_comout;
88          if (wrnvec != NULL)
# Line 111 | Line 102 | comm_close()                   /* done with driver */
102          cmdvec = NULL;                          /* reset error vectors */
103          if (wrnvec != NULL)
104                  wrnvec = stderr_v;
114        signal(SIGIO, SIG_DFL);
105          fclose(devout);
106          fclose(devin);
107          while ((pid = wait(0)) != -1 && pid != devchild)
# Line 135 | Line 125 | comm_paintr(col, xmin, ymin, xmax, ymax)       /* paint a re
125   COLOR   col;
126   int     xmin, ymin, xmax, ymax;
127   {
138        extern long     nrays;          /* number of rays traced */
139        static long     lastflush = 0;  /* ray count at last flush */
140
128          putc(COM_PAINTR, devout);
129          fwrite((char *)col, sizeof(COLOR), 1, devout);
130          putw(xmin, devout);
131          putw(ymin, devout);
132          putw(xmax, devout);
133          putw(ymax, devout);
147        if (nrays - lastflush >= WFLUSH) {
148                fflush(devout);
149                lastflush = nrays;
150        }
134   }
135  
136  
137 + static
138 + comm_flush()                            /* flush output to driver */
139 + {
140 +        putc(COM_FLUSH, devout);
141 +        fflush(devout);
142 +        if (getc(devin) != COM_FLUSH)
143 +                reply_error("flush");
144 +        comm_driver.inpready = getw(devin);
145 + }
146 +
147 +
148   static int
149   comm_getcur(xp, yp)                     /* get and return cursor position */
150   int     *xp, *yp;
# Line 174 | Line 168 | char   *str;
168   {
169          putc(COM_COMOUT, devout);
170          myputs(str, devout);
177        fflush(devout);
171   }
172  
173  
174   static
175 < comm_comin(buf)                         /* read string from command line */
175 > comm_comin(buf, prompt)                 /* read string from command line */
176   char    *buf;
177 + char    *prompt;
178   {
179          putc(COM_COMIN, devout);
180 +        if (prompt == NULL)
181 +                putc(0, devout);
182 +        else {
183 +                putc(1, devout);
184 +                myputs(prompt, devout);
185 +        }
186          fflush(devout);
187          if (getc(devin) != COM_COMIN)
188                  reply_error("comin");
189          mygets(buf, devin);
190 <        if (comm_driver.inpready > 0)
191 <                comm_driver.inpready--;
190 >        comm_driver.inpready = getw(devin);
191   }
192  
193  
# Line 233 | Line 232 | char   *routine;
232          stderr_v(routine);
233          stderr_v(": driver reply error\n");
234          quit(1);
236 }
237
238
239 static
240 onsigio()                               /* input ready */
241 {
242        comm_driver.inpready++;
235   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines