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.6 by greg, Thu Jul 27 22:25:12 1989 UTC vs.
Revision 1.7 by greg, Wed Nov 1 17:33:03 1989 UTC

# Line 49 | Line 49 | int    devchild;
49  
50  
51   struct driver *
52 < comm_init(argv)                 /* set up and execute driver */
53 < char    *argv[];
52 > comm_init(dname, id)                    /* set up and execute driver */
53 > char    *dname, *id;
54   {
55          char    *devname;
56          int     p1[2], p2[2];
57 <
58 <        if ((devname = getpath(argv[0], DEVPATH, 1)) == NULL) {
59 <                stderr_v(argv[0]);
57 >        char    pin[16], pout[16];
58 >                                                /* find driver program */
59 >        if ((devname = getpath(dname, DEVPATH, 1)) == NULL) {
60 >                stderr_v(dname);
61                  stderr_v(": not found\n");
62                  return(NULL);
63          }
64 +                                                /* open communication pipes */
65          if (pipe(p1) == -1 || pipe(p2) == -1)
66                  goto syserr;
67 <        if ((devchild = vfork()) == 0) {
67 >        if ((devchild = vfork()) == 0) {        /* fork driver process */
68                  close(p1[1]);
69                  close(p2[0]);
70 <                if (p1[0] != 0) {
71 <                        dup2(p1[0], 0);
72 <                        close(p1[0]);
73 <                }
72 <                if (p2[1] != 1) {
73 <                        dup2(p2[1], 1);
74 <                        close(p2[1]);
75 <                }
76 <                execv(devname, argv);
77 <                stderr_v(devname);
78 <                stderr_v(": cannot execute\n");
70 >                sprintf(pin, "%d", p1[0]);
71 >                sprintf(pout, "%d", p2[1]);
72 >                execl(devname, dname, pin, pout, id, 0);
73 >                perror(devname);
74                  _exit(127);
75          }
76          if (devchild == -1)
# Line 87 | Line 82 | char   *argv[];
82          if ((devin = fdopen(p2[0], "r")) == NULL)
83                  goto syserr;
84          bcopy(&comm_default, &comm_driver, sizeof(comm_driver));
85 +                                                /* verify & get resolution */
86 +        putw(COM_SENDM, devout);
87 +        fflush(devout);
88 +        if (getw(devin) != COM_RECVM)
89 +                return(NULL);
90 +        comm_driver.xsiz = getw(devin);
91 +        comm_driver.ysiz = getw(devin);
92 +                                                /* input handling */
93          signal(SIGIO, onsigio);
94 <        cmdvec = comm_comout;                   /* set error vectors */
94 >                                                /* set error vectors */
95 >        cmdvec = comm_comout;
96          if (wrnvec != NULL)
97                  wrnvec = comm_comout;
98          return(&comm_driver);
99   syserr:
100 <        perror(argv[0]);
100 >        perror(dname);
101          return(NULL);
102   }
103  
# Line 182 | Line 186 | char   *buf;
186          if (getc(devin) != COM_COMIN)
187                  reply_error("comin");
188          mygets(buf, devin);
189 <        comm_driver.inpready = 0;
189 >        if (comm_driver.inpready > 0)
190 >                comm_driver.inpready--;
191   }
192  
193  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines