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.1 by greg, Wed Oct 25 15:37:42 1989 UTC vs.
Revision 1.12 by greg, Thu Mar 22 20:58:09 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"
# Line 26 | Line 24 | struct driver  *dev = NULL;                    /* output device */
24  
25   FILE    *devin, *devout;                        /* communications channels */
26  
29 int     notified = 0;                           /* notified parent of input? */
30
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 57 | Line 54 | char   *argv[];
54                  quit(1);
55          }
56                                                  /* open device */
57 <        if ((dev = dinit(argv[0], argv[3])) == NULL) {
61 <                stderr_v("initialization failure\n");
57 >        if ((dev = dinit(argv[0], argv[3])) == NULL)
58                  quit(1);
63        }
59          putw(COM_RECVM, devout);                /* verify initialization */
60 <        putw(dev->xsiz, devout);
66 <        putw(dev->ysiz, devout);
60 >        sendstate();
61          fflush(devout);
62                                                  /* loop on requests */
63          while ((com = getc(devin)) != EOF) {
# Line 101 | Line 95 | r_paintr()                             /* paint a rectangle */
95          COLOR   col;
96          int     xmin, ymin, xmax, ymax;
97  
98 <        fread(col, sizeof(COLOR), 1, devin);
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);
108                                        /* check for input */
109        if (dev->inpready > notified) {
110                kill(getppid(), SIGIO);
111                notified = dev->inpready;
112        }
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 143 | 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);
153                                        /* reset notify */
154        notified = 0;
159   }
160  
161  
# Line 178 | Line 182 | register FILE  *fp;
182   }
183  
184  
181 repaint(xmin, ymin, xmax, ymax)         /* repaint section of display */
182 int     xmin, ymin, xmax, ymax;
183 {
184        stderr_v("repaint called!\n");          /* no can do! */
185 }
186
187
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 (!midline++) {
191                  fputs(progname, stderr);
192                  fputs(": ", stderr);
193          }
194          fputs(s, stderr);
195          if (*s && s[strlen(s)-1] == '\n') {
196                  fflush(stderr);
197 <                inline = 0;
197 >                midline = 0;
198          }
199 + }
200 +
201 +
202 + sendstate()                             /* send driver state variables */
203 + {
204 +        fwrite((char *)&dev->pixaspect, sizeof(dev->pixaspect), 1, devout);
205 +        putw(dev->xsiz, devout);
206 +        putw(dev->ysiz, devout);
207 +        putw(dev->inpready, devout);
208   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines