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.3 by greg, Wed Nov 1 16:12:22 1989 UTC vs.
Revision 1.8 by greg, Thu Feb 22 11:46:24 1990 UTC

# Line 22 | Line 22 | static char SCCSid[] = "$SunId$ LBL";
22  
23   int     (*wrnvec)(), (*errvec)(), (*cmdvec)();  /* error vectors, unused */
24  
25 long    nrays = 0;                              /* fake it */
26
25   struct driver   *dev = NULL;                    /* output device */
26  
27   FILE    *devin, *devout;                        /* communications channels */
# Line 32 | Line 30 | int    notified = 0;                           /* notified parent of input? */
30  
31   char    *progname;                              /* driver name */
32  
33 < int     r_clear(), r_paintr(), r_getcur(), r_comout(), r_comin(), r_mycomin();
33 > int     r_clear(), r_paintr(), r_getcur(), r_comout(), r_comin(), r_flush();
34  
35   int     (*dev_func[NREQUESTS])() = {            /* request handlers */
36                  r_clear, r_paintr,
37 <                r_getcur, r_comout, r_comin
37 >                r_getcur, r_comout,
38 >                r_comin, r_flush
39          };
40  
42 char    mybuf[512] = "";
41  
44 char    *mybufp();
45
46
42   main(argc, argv)                /* set up communications and main loop */
43   int     argc;
44   char    *argv[];
# Line 66 | Line 61 | char   *argv[];
61          if ((dev = dinit(argv[0], argv[3])) == NULL)
62                  quit(1);
63          putw(COM_RECVM, devout);                /* verify initialization */
64 +        fwrite((char *)&dev->pixaspect, sizeof(dev->pixaspect), 1, devout);
65          putw(dev->xsiz, devout);
66          putw(dev->ysiz, devout);
67          fflush(devout);
# Line 105 | Line 101 | r_paintr()                             /* paint a rectangle */
101          COLOR   col;
102          int     xmin, ymin, xmax, ymax;
103  
104 <        nrays += 5;                     /* pretend */
109 <        fread(col, sizeof(COLOR), 1, devin);
104 >        fread((char *)col, sizeof(COLOR), 1, devin);
105          xmin = getw(devin); ymin = getw(devin);
106          xmax = getw(devin); ymax = getw(devin);
107          (*dev->paintr)(col, xmin, ymin, xmax, ymax);
# Line 118 | Line 113 | r_paintr()                             /* paint a rectangle */
113   }
114  
115  
116 + r_flush()                               /* flush output */
117 + {
118 +        if (dev->flush != NULL)
119 +                (*dev->flush)();
120 + }
121 +
122 +
123   r_getcur()                              /* get and return cursor position */
124   {
125          int     c;
# Line 148 | Line 150 | r_comout()                             /* print string to command line */
150  
151   r_comin()                               /* read string from command line */
152   {
153 <        char    buf[256];
153 >        char    buf[256], *prompt;
154 >                                        /* get prompt */
155 >        if (getc(devin)) {
156 >                mygets(buf, devin);
157 >                prompt = buf;
158 >        } else
159 >                prompt = NULL;
160                                          /* get string */
161 <        (*dev->comin)(buf);
161 >        (*dev->comin)(buf, prompt);
162                                          /* reply */
163          putc(COM_COMIN, devout);
164          myputs(buf, devout);
# Line 183 | Line 191 | register FILE  *fp;
191   }
192  
193  
186 r_mycomin()                             /* get command from my buffer */
187 {
188        register char   *cp;
189                                                /* get next command */
190        for (cp = mybuf; *cp != '\n'; cp++)
191                ;
192        *cp++ = '\0';
193        (*dev->comout)(mybuf);                  /* echo my command */
194                                                /* send it as reply */
195        putc(COM_COMIN, devout);
196        myputs(mybuf, devout);
197        fflush(devout);
198                                                /* get next command */
199        (*dev->comout)("\n");
200        strcpy(mybuf, cp);
201        if (mybuf[0])
202                kill(getppid(), SIGIO);                 /* signal more */
203        else
204                dev_func[COM_COMIN] = r_comin;          /* else reset */
205 }
206
207
194   stderr_v(s)                             /* put string to stderr */
195   register char  *s;
196   {
# Line 219 | Line 205 | register char  *s;
205                  fflush(stderr);
206                  inline = 0;
207          }
222 }
223
224
225 char *
226 mybufp()                                /* return buffer for my command */
227 {
228        if (dev_func[COM_COMIN] != r_mycomin) {
229                dev_func[COM_COMIN] = r_mycomin;
230                kill(getppid(), SIGIO);
231        }
232        return(mybuf+strlen(mybuf));
233 }
234
235
236 repaint(xmin, ymin, xmax, ymax)         /* repaint section of display */
237 int     xmin, ymin, xmax, ymax;
238 {
239        sprintf(mybufp(), "repaint %d %d %d %d\n",
240                        xmin, ymin, xmax, ymax);
208   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines