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.12 by greg, Thu Feb 22 11:46:13 1990 UTC vs.
Revision 1.19 by greg, Thu Oct 18 13:33:09 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 22 | Line 20 | static char SCCSid[] = "$SunId$ LBL";
20   #define DEVPATH         getenv("PATH")  /* device search path */
21   #endif
22  
23 + #ifndef DELAY
24 + #define DELAY           20              /* seconds to wait for response */
25 + #endif
26 +
27   #ifndef BSD
28   #define vfork           fork
29   #endif
30  
31 < extern char     *getpath(), *getenv();
30 <
31 < int     onsigio();
32 <
33 < int     comm_close(), comm_clear(), comm_paintr(), comm_errout(),
31 > static int      comm_close(), comm_clear(), comm_paintr(), comm_errout(),
32                  comm_getcur(), comm_comout(), comm_comin(), comm_flush();
33  
34   struct driver   comm_driver = {
# Line 51 | Line 49 | char   *dname, *id;
49          int     p1[2], p2[2];
50          char    pin[16], pout[16];
51                                                  /* find driver program */
52 <        if ((devname = getpath(dname, DEVPATH, 1)) == NULL) {
52 >        if ((devname = getpath(dname, DEVPATH, X_OK)) == NULL) {
53                  stderr_v(dname);
54                  stderr_v(": not found\n");
55                  return(NULL);
# Line 76 | Line 74 | char   *dname, *id;
74                  goto syserr;
75          if ((devin = fdopen(p2[0], "r")) == NULL)
76                  goto syserr;
77 <                                                /* verify & get resolution */
77 >                                                /* verify initialization */
78          putw(COM_SENDM, devout);
79          fflush(devout);
80          if (getw(devin) != COM_RECVM)
81                  return(NULL);
82 <        fread((char *)&comm_driver.pixaspect,
83 <                        sizeof(comm_driver.pixaspect), 1, devin);
86 <        comm_driver.xsiz = getw(devin);
87 <        comm_driver.ysiz = getw(devin);
88 <                                                /* input handling */
89 <        signal(SIGIO, onsigio);
82 >                                                /* get driver parameters */
83 >        getstate();
84                                                  /* set error vectors */
85          cmdvec = comm_comout;
86          if (wrnvec != NULL)
# Line 106 | Line 100 | comm_close()                   /* done with driver */
100          cmdvec = NULL;                          /* reset error vectors */
101          if (wrnvec != NULL)
102                  wrnvec = stderr_v;
109        signal(SIGIO, SIG_DFL);
103          fclose(devout);
104          fclose(devin);
105          while ((pid = wait(0)) != -1 && pid != devchild)
# Line 144 | Line 137 | comm_flush()                           /* flush output to driver */
137   {
138          putc(COM_FLUSH, devout);
139          fflush(devout);
140 +        if (getc(devin) != COM_FLUSH)
141 +                reply_error("flush");
142 +        getstate();
143   }
144  
145  
# Line 170 | Line 166 | char   *str;
166   {
167          putc(COM_COMOUT, devout);
168          myputs(str, devout);
169 <        fflush(devout);
169 >        if (str[strlen(str)-1] == '\n')
170 >                fflush(devout);
171   }
172  
173  
# Line 190 | Line 187 | char   *prompt;
187          if (getc(devin) != COM_COMIN)
188                  reply_error("comin");
189          mygets(buf, devin);
190 <        if (comm_driver.inpready > 0)
194 <                comm_driver.inpready--;
190 >        getstate();
191   }
192  
193  
# Line 240 | Line 236 | char   *routine;
236  
237  
238   static
239 < onsigio()                               /* input ready */
239 > getstate()                              /* get driver state variables */
240   {
241 <        comm_driver.inpready++;
241 >        fread((char *)&comm_driver.pixaspect,
242 >                        sizeof(comm_driver.pixaspect), 1, devin);
243 >        comm_driver.xsiz = getw(devin);
244 >        comm_driver.ysiz = getw(devin);
245 >        comm_driver.inpready = getw(devin);
246   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines