12 |
|
|
13 |
|
#include "standard.h" |
14 |
|
|
15 |
– |
#include <signal.h> |
16 |
– |
|
15 |
|
#include "color.h" |
16 |
|
|
17 |
|
#include "driver.h" |
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(); |
32 |
|
|
33 |
< |
int onsigio(); |
32 |
< |
|
33 |
< |
int comm_close(), comm_clear(), comm_paintr(), comm_errout(), |
33 |
> |
static int comm_close(), comm_clear(), comm_paintr(), comm_errout(), |
34 |
|
comm_getcur(), comm_comout(), comm_comin(), comm_flush(); |
35 |
|
|
36 |
|
struct driver comm_driver = { |
76 |
|
goto syserr; |
77 |
|
if ((devin = fdopen(p2[0], "r")) == NULL) |
78 |
|
goto syserr; |
79 |
< |
/* verify & get resolution */ |
79 |
> |
/* verify initialization */ |
80 |
|
putw(COM_SENDM, devout); |
81 |
|
fflush(devout); |
82 |
|
if (getw(devin) != COM_RECVM) |
83 |
|
return(NULL); |
84 |
< |
fread((char *)&comm_driver.pixaspect, |
85 |
< |
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); |
84 |
> |
/* get driver parameters */ |
85 |
> |
getstate(); |
86 |
|
/* set error vectors */ |
87 |
|
cmdvec = comm_comout; |
88 |
|
if (wrnvec != NULL) |
102 |
|
cmdvec = NULL; /* reset error vectors */ |
103 |
|
if (wrnvec != NULL) |
104 |
|
wrnvec = stderr_v; |
109 |
– |
signal(SIGIO, SIG_DFL); |
105 |
|
fclose(devout); |
106 |
|
fclose(devin); |
107 |
|
while ((pid = wait(0)) != -1 && pid != devchild) |
139 |
|
{ |
140 |
|
putc(COM_FLUSH, devout); |
141 |
|
fflush(devout); |
142 |
+ |
if (getc(devin) != COM_FLUSH) |
143 |
+ |
reply_error("flush"); |
144 |
+ |
getstate(); |
145 |
|
} |
146 |
|
|
147 |
|
|
168 |
|
{ |
169 |
|
putc(COM_COMOUT, devout); |
170 |
|
myputs(str, devout); |
173 |
– |
fflush(devout); |
171 |
|
} |
172 |
|
|
173 |
|
|
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 |
|
|
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 |
|
} |