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 2.4 by greg, Thu Nov 18 09:42:58 1993 UTC vs.
Revision 2.9 by greg, Thu Jul 3 15:00:19 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1988 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   *  devcomm.c - communication routines for separate drivers.
6   *
7 < *      10/5/88
7 > *  External symbols declared in driver.h
8   */
9  
10 + #include "copyright.h"
11 +
12 + #include  "platform.h"
13 +
14   #include "standard.h"
15  
16   #include "color.h"
# Line 22 | Line 23 | static char SCCSid[] = "$SunId$ LBL";
23   #define DEVPATH         getenv("PATH")  /* device search path */
24   #endif
25  
26 < static int      comm_close(), comm_clear(), comm_paintr(),
27 <                comm_getcur(), comm_comout(), comm_comin(), comm_flush();
26 > static int      comm_getcur();
27 > static void     comm_close(), comm_clear(), comm_paintr(),
28 >                comm_comin(), comm_comout(), comm_flush();
29  
30   struct driver   comm_driver = {
31          comm_close, comm_clear, comm_paintr, comm_getcur,
32          comm_comout, comm_comin, comm_flush
33   };
34  
35 < static int      mygets(), myputs(), reply_error(), getstate();
35 > static void     mygets(), myputs(), reply_error(), getstate();
36  
37   FILE    *devin, *devout;
38  
# Line 47 | Line 49 | final_connect()                                /* verify and initialize connection
49                                                  /* get driver parameters */
50          getstate();
51                                                  /* set error vectors */
52 <        cmdvec = comm_comout;
53 <        if (wrnvec != NULL)
54 <                wrnvec = comm_comout;
52 >        erract[COMMAND].pf = comm_comout;
53 >        if (erract[WARNING].pf != NULL)
54 >                erract[WARNING].pf = comm_comout;
55          return(&comm_driver);
56   }
57  
# Line 69 | Line 71 | struct driver *
71   comm_init(dname, id)                    /* set up and execute driver */
72   char    *dname, *id;
73   {
74 <        char    *devname;
74 >        char    *dvcname;
75          int     p1[2], p2[2];
76          char    pin[16], pout[16];
77                                                  /* find driver program */
78 <        if ((devname = getpath(dname, DEVPATH, X_OK)) == NULL) {
79 <                stderr_v(dname);
80 <                stderr_v(": not found\n");
78 >        if ((dvcname = getpath(dname, DEVPATH, X_OK)) == NULL) {
79 >                eputs(dname);
80 >                eputs(": not found\n");
81                  return(NULL);
82          }
83 + #ifdef RHAS_FORK_EXEC
84                                                  /* open communication pipes */
85          if (pipe(p1) == -1 || pipe(p2) == -1)
86                  goto syserr;
# Line 86 | Line 89 | char   *dname, *id;
89                  close(p2[0]);
90                  sprintf(pin, "%d", p1[0]);
91                  sprintf(pout, "%d", p2[1]);
92 <                execl(devname, dname, pin, pout, id, 0);
93 <                perror(devname);
92 >                execl(dvcname, dname, pin, pout, id, 0);
93 >                perror(dvcname);
94                  _exit(127);
95          }
96          if (devchild == -1)
# Line 102 | Line 105 | char   *dname, *id;
105   syserr:
106          perror(dname);
107          return(NULL);
108 +
109 + #else   /* ! RHAS_FORK_EXEC */
110 +
111 +        eputs(dname);
112 +        eputs(": no fork/exec\n");
113 +        return(NULL);
114 +
115 + #endif  /* ! RHAS_FORK_EXEC */
116   }
117  
118  
119 < static
119 > static void
120   comm_close()                    /* done with driver */
121   {
122          int     pid;
123  
124 <        cmdvec = NULL;                          /* reset error vectors */
125 <        if (wrnvec != NULL)
126 <                wrnvec = stderr_v;
124 >        erract[COMMAND].pf = NULL;              /* reset error vectors */
125 >        if (erract[WARNING].pf != NULL)
126 >                erract[WARNING].pf = wputs;
127          fclose(devout);
128          fclose(devin);
129          if (devchild < 0)
# Line 122 | Line 133 | comm_close()                   /* done with driver */
133   }
134  
135  
136 < static
136 > static void
137   comm_clear(xres, yres)                          /* clear screen */
138   int     xres, yres;
139   {
# Line 133 | Line 144 | int    xres, yres;
144   }
145  
146  
147 < static
147 > static void
148   comm_paintr(col, xmin, ymin, xmax, ymax)        /* paint a rectangle */
149   COLOR   col;
150   int     xmin, ymin, xmax, ymax;
# Line 147 | Line 158 | int    xmin, ymin, xmax, ymax;
158   }
159  
160  
161 < static
161 > static void
162   comm_flush()                            /* flush output to driver */
163   {
164          putc(COM_FLUSH, devout);
# Line 175 | Line 186 | int    *xp, *yp;
186   }
187  
188  
189 < static
189 > static void
190   comm_comout(str)                        /* print string to command line */
191   char    *str;
192   {
# Line 186 | Line 197 | char   *str;
197   }
198  
199  
200 < static
200 > static void
201   comm_comin(buf, prompt)                 /* read string from command line */
202   char    *buf;
203   char    *prompt;
# Line 206 | Line 217 | char   *prompt;
217   }
218  
219  
220 < static
220 > static void
221   mygets(s, fp)                           /* get string from file (with nul) */
222   register char   *s;
223   register FILE   *fp;
# Line 220 | Line 231 | register FILE  *fp;
231   }
232  
233  
234 < static
234 > static void
235   myputs(s, fp)                           /* put string to file (with nul) */
236   register char   *s;
237   register FILE   *fp;
# Line 231 | Line 242 | register FILE  *fp;
242   }
243  
244  
245 < static
245 > static void
246   reply_error(routine)                    /* what should we do here? */
247   char    *routine;
248   {
249 <        stderr_v(routine);
250 <        stderr_v(": driver reply error\n");
249 >        eputs(routine);
250 >        eputs(": driver reply error\n");
251          quit(1);
252   }
253  
254  
255 < static
255 > static void
256   getstate()                              /* get driver state variables */
257   {
258          fread((char *)&comm_driver.pixaspect,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines