ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/rholo4.c
(Generate patch)

Comparing ray/src/hd/rholo4.c (file contents):
Revision 3.29 by greg, Tue May 13 17:58:33 2003 UTC vs.
Revision 3.30 by schorsch, Thu Jun 26 00:58:10 2003 UTC

# Line 5 | Line 5 | static const char      RCSid[] = "$Id$";
5   * Holodeck display process communication
6   */
7  
8 + #include <sys/uio.h>
9 +
10   #include "rholo.h"
11   #include "rhdisp.h"
12 < #include <sys/uio.h>
12 > #include "rtprocess.h"
13  
14   #ifndef HDSUF
15   #define HDSUF           ".hdi"
# Line 21 | Line 23 | static const char      RCSid[] = "$Id$";
23   #endif
24  
25   static int      inp_flags;
26 < static int      dpd[3];
26 > static SUBPROC  dpd;
27   static FILE     *dpout;
28  
29  
# Line 32 | Line 34 | char   *dname;
34          int     i, n, len;
35  
36          if (!strcmp(dname, SLAVENAME)) {
37 <                dpd[0] = 0;             /* read from stdin */
37 >                dpd.r = 0;              /* read from stdin */
38                  dpout = stdout;         /* write to stdout */
39 <                dpd[2] = -1;            /* we're the slave process */
39 >                dpd.running = 0; /* we're the slave procees */
40          } else {
41                                          /* get full display program name */
42   #ifdef DEVPATH
# Line 52 | Line 54 | char   *dname;
54                  cmd[0] = buf;
55                  cmd[1] = froot; cmd[2] = fd1; cmd[3] = fd0;
56                  cmd[4] = NULL;
57 <                i = open_process(dpd, cmd);
57 >                i = open_process(&dpd, cmd);
58                  if (i <= 0)
59                          error(USER, "cannot start display process");
60 <                if ((dpout = fdopen(dpd[1], "w")) == NULL)
60 >                if ((dpout = fdopen(dpd.w, "w")) == NULL)
61                          error(SYSTEM, "problem opening display pipe");
62                                          /* close dup'ed stdin and stdout */
63                  if (readinp)
64                          close(atoi(fd0));
65                  close(atoi(fd1));
66          }
67 <        dpd[1] = -1;            /* causes ignored error in close_process() */
67 >        dpd.w = -1;             /* causes ignored error in close_process() */
68          inp_flags = 0;
69                                  /* check if outside */
70          if (vdef(OBSTRUCTIONS) && vbool(OBSTRUCTIONS))
# Line 112 | Line 114 | int    block;
114                                          /* check read blocking */
115          if (block != (inp_flags == 0)) {
116                  inp_flags = block ? 0 : FNONBLK;
117 <                if (fcntl(dpd[0], F_SETFL, inp_flags) < 0)
117 >                if (fcntl(dpd.r, F_SETFL, inp_flags) < 0)
118                          goto fcntlerr;
119          }
120                                          /* read message header */
121 <        n = read(dpd[0], (char *)&msg, sizeof(MSGHEAD));
121 >        n = read(dpd.r, (char *)&msg, sizeof(MSGHEAD));
122          if (n != sizeof(MSGHEAD)) {
123                  if (n >= 0) {
124                          dpout = NULL;
# Line 132 | Line 134 | int    block;
134                  buf = (char *)malloc(msg.nbytes);
135                  if (buf == NULL)
136                          error(SYSTEM, "out of memory in disp_check");
137 <                if (inp_flags != 0 && fcntl(dpd[0], F_SETFL, inp_flags=0) < 0)
137 >                if (inp_flags != 0 && fcntl(dpd.r, F_SETFL, inp_flags=0) < 0)
138                          goto fcntlerr;
139 <                if (readbuf(dpd[0], buf, msg.nbytes) != msg.nbytes)
139 >                if (readbuf(dpd.r, buf, msg.nbytes) != msg.nbytes)
140                          goto readerr;
141          }
142          switch (msg.type) {             /* take appropriate action */
# Line 250 | Line 252 | disp_close()                   /* close our display process */
252          disp_result(DS_SHUTDOWN, 0, NULL);
253          fclose(dpout);
254          dpout = NULL;
255 <        return(dpd[2]<0 ? 0 : close_process(dpd));
255 >        return(dpd.running ? close_process(&dpd) : 0);
256 >
257   }
258  
259  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines