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.10 by greg, Tue Mar 6 17:44:44 1990 UTC vs.
Revision 2.2 by gregl, Tue Nov 11 20:02:59 1997 UTC

# Line 12 | Line 12 | static char SCCSid[] = "$SunId$ LBL";
12   *      10/25/89
13   */
14  
15 < #include <stdio.h>
15 > #include "standard.h"
16  
17   #include "color.h"
18  
19   #include "driver.h"
20  
21 int     (*wrnvec)(), (*errvec)(), (*cmdvec)();  /* error vectors, unused */
22
21   struct driver   *dev = NULL;                    /* output device */
22  
23   FILE    *devin, *devout;                        /* communications channels */
# Line 44 | Line 42 | char   *argv[];
42                                                  /* set up I/O */
43          progname = argv[0];
44          if (argc < 3) {
45 <                stderr_v("arg count\n");
45 >                eputs("arg count\n");
46                  quit(1);
47          }
48          devin = fdopen(atoi(argv[1]), "r");
49          devout = fdopen(atoi(argv[2]), "w");
50          if (devin == NULL || devout == NULL || getw(devin) != COM_SENDM) {
51 <                stderr_v("connection failure\n");
51 >                eputs("connection failure\n");
52                  quit(1);
53          }
54                                                  /* open device */
55          if ((dev = dinit(argv[0], argv[3])) == NULL)
56                  quit(1);
57          putw(COM_RECVM, devout);                /* verify initialization */
58 +        sendstate();
59          fflush(devout);
60                                                  /* loop on requests */
61          while ((com = getc(devin)) != EOF) {
62                  if (com >= NREQUESTS || dev_func[com] == NULL) {
63 <                        stderr_v("invalid request\n");
63 >                        eputs("invalid request\n");
64                          quit(1);
65                  }
66                  (*dev_func[com])();             /* process request */
# Line 106 | Line 105 | r_flush()                              /* flush output */
105          if (dev->flush != NULL)
106                  (*dev->flush)();
107          putc(COM_FLUSH, devout);
108 <        fwrite((char *)&dev->pixaspect, sizeof(dev->pixaspect), 1, devout);
110 <        putw(dev->xsiz, devout);
111 <        putw(dev->ysiz, devout);
112 <        putw(dev->inpready, devout);
108 >        sendstate();
109          fflush(devout);
110   }
111  
# Line 156 | Line 152 | r_comin()                              /* read string from command line */
152                                          /* reply */
153          putc(COM_COMIN, devout);
154          myputs(buf, devout);
155 <        putw(dev->inpready, devout);
155 >        sendstate();
156          fflush(devout);
157   }
158  
# Line 184 | Line 180 | register FILE  *fp;
180   }
181  
182  
183 < stderr_v(s)                             /* put string to stderr */
183 > eputs(s)                                /* put string to stderr */
184   register char  *s;
185   {
186 <        static int  inline = 0;
186 >        static int  midline = 0;
187  
188 <        if (!inline++) {
188 >        if (!*s)
189 >                return;
190 >        if (!midline++) {
191                  fputs(progname, stderr);
192                  fputs(": ", stderr);
193          }
194          fputs(s, stderr);
195 <        if (*s && s[strlen(s)-1] == '\n') {
195 >        if (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