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

Comparing ray/src/rt/devmain.c (file contents):
Revision 1.6 by greg, Fri Jan 19 00:00:33 1990 UTC vs.
Revision 1.13 by greg, Thu Aug 2 13:40:23 1990 UTC

# Line 14 | Line 14 | static char SCCSid[] = "$SunId$ LBL";
14  
15   #include <stdio.h>
16  
17 #include <signal.h>
18
17   #include "color.h"
18  
19   #include "driver.h"
20  
21   int     (*wrnvec)(), (*errvec)(), (*cmdvec)();  /* error vectors, unused */
22  
25 long    nrays = 0;                              /* fake it */
26
23   struct driver   *dev = NULL;                    /* output device */
24  
25   FILE    *devin, *devout;                        /* communications channels */
26  
31 int     notified = 0;                           /* notified parent of input? */
32
27   char    *progname;                              /* driver name */
28  
29 < int     r_clear(), r_paintr(), r_getcur(), r_comout(), r_comin();
29 > int     r_clear(), r_paintr(), r_getcur(), r_comout(), r_comin(), r_flush();
30  
31   int     (*dev_func[NREQUESTS])() = {            /* request handlers */
32                  r_clear, r_paintr,
33 <                r_getcur, r_comout, r_comin
33 >                r_getcur, r_comout,
34 >                r_comin, r_flush
35          };
36  
37  
# Line 62 | Line 57 | char   *argv[];
57          if ((dev = dinit(argv[0], argv[3])) == NULL)
58                  quit(1);
59          putw(COM_RECVM, devout);                /* verify initialization */
60 <        fwrite((char *)&dev->pixaspect, sizeof(dev->pixaspect), 1, devout);
66 <        putw(dev->xsiz, devout);
67 <        putw(dev->ysiz, devout);
60 >        sendstate();
61          fflush(devout);
62                                                  /* loop on requests */
63          while ((com = getc(devin)) != EOF) {
# Line 102 | Line 95 | r_paintr()                             /* paint a rectangle */
95          COLOR   col;
96          int     xmin, ymin, xmax, ymax;
97  
105        nrays += 5;                     /* pretend */
98          fread((char *)col, sizeof(COLOR), 1, devin);
99          xmin = getw(devin); ymin = getw(devin);
100          xmax = getw(devin); ymax = getw(devin);
101          (*dev->paintr)(col, xmin, ymin, xmax, ymax);
110                                        /* check for input */
111        if (!notified && dev->inpready > 0) {
112                notified = 1;
113                kill(getppid(), SIGIO);
114        }
102   }
103  
104  
105 + r_flush()                               /* flush output */
106 + {
107 +        if (dev->flush != NULL)
108 +                (*dev->flush)();
109 +        putc(COM_FLUSH, devout);
110 +        sendstate();
111 +        fflush(devout);
112 + }
113 +
114 +
115   r_getcur()                              /* get and return cursor position */
116   {
117          int     c;
# Line 145 | Line 142 | r_comout()                             /* print string to command line */
142  
143   r_comin()                               /* read string from command line */
144   {
145 <        char    buf[256];
145 >        char    buf[256], *prompt;
146 >                                        /* get prompt */
147 >        if (getc(devin)) {
148 >                mygets(buf, devin);
149 >                prompt = buf;
150 >        } else
151 >                prompt = NULL;
152                                          /* get string */
153 <        (*dev->comin)(buf);
153 >        (*dev->comin)(buf, prompt);
154                                          /* reply */
155          putc(COM_COMIN, devout);
156          myputs(buf, devout);
157 +        sendstate();
158          fflush(devout);
155                                        /* reset notify */
156        notified = 0;
159   }
160  
161  
# Line 183 | Line 185 | register FILE  *fp;
185   stderr_v(s)                             /* put string to stderr */
186   register char  *s;
187   {
188 <        static int  inline = 0;
188 >        static int  midline = 0;
189  
190 <        if (!inline++) {
190 >        if (!*s)
191 >                return;
192 >        if (!midline++) {
193                  fputs(progname, stderr);
194                  fputs(": ", stderr);
195          }
196          fputs(s, stderr);
197 <        if (*s && s[strlen(s)-1] == '\n') {
197 >        if (s[strlen(s)-1] == '\n') {
198                  fflush(stderr);
199 <                inline = 0;
199 >                midline = 0;
200          }
201 + }
202 +
203 +
204 + sendstate()                             /* send driver state variables */
205 + {
206 +        fwrite((char *)&dev->pixaspect, sizeof(dev->pixaspect), 1, devout);
207 +        putw(dev->xsiz, devout);
208 +        putw(dev->ysiz, devout);
209 +        putw(dev->inpready, devout);
210   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines