12 |
|
|
13 |
|
#include "standard.h" |
14 |
|
|
15 |
– |
#include <signal.h> |
16 |
– |
|
15 |
|
#include "color.h" |
16 |
|
|
17 |
|
#include "driver.h" |
83 |
|
sizeof(comm_driver.pixaspect), 1, devin); |
84 |
|
comm_driver.xsiz = getw(devin); |
85 |
|
comm_driver.ysiz = getw(devin); |
88 |
– |
/* input handling */ |
89 |
– |
signal(SIGIO, onsigio); |
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 |
+ |
comm_driver.inpready = getw(devin); |
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 |
> |
comm_driver.inpready = getw(devin); |
191 |
|
} |
192 |
|
|
193 |
|
|
232 |
|
stderr_v(routine); |
233 |
|
stderr_v(": driver reply error\n"); |
234 |
|
quit(1); |
239 |
– |
} |
240 |
– |
|
241 |
– |
|
242 |
– |
static |
243 |
– |
onsigio() /* input ready */ |
244 |
– |
{ |
245 |
– |
comm_driver.inpready++; |
235 |
|
} |