14 |
|
|
15 |
|
#include <stdio.h> |
16 |
|
|
17 |
– |
#include <signal.h> |
18 |
– |
|
17 |
|
#include "color.h" |
18 |
|
|
19 |
|
#include "driver.h" |
20 |
|
|
21 |
|
int (*wrnvec)(), (*errvec)(), (*cmdvec)(); /* error vectors, unused */ |
22 |
|
|
25 |
– |
long nrays = 0; /* fake it */ |
26 |
– |
|
23 |
|
struct driver *dev = NULL; /* output device */ |
24 |
|
|
25 |
|
FILE *devin, *devout; /* communications channels */ |
26 |
|
|
31 |
– |
int notified = 0; /* notified parent of input? */ |
32 |
– |
|
27 |
|
char *progname; /* driver name */ |
28 |
|
|
29 |
< |
int r_clear(), r_paintr(), r_getcur(), r_comout(), r_comin(); |
29 |
> |
int r_clear(), r_paintr(), r_getcur(), r_comout(), r_comin(), r_flush(); |
30 |
|
|
31 |
|
int (*dev_func[NREQUESTS])() = { /* request handlers */ |
32 |
|
r_clear, r_paintr, |
33 |
< |
r_getcur, r_comout, r_comin |
33 |
> |
r_getcur, r_comout, |
34 |
> |
r_comin, r_flush |
35 |
|
}; |
36 |
|
|
37 |
|
|
97 |
|
COLOR col; |
98 |
|
int xmin, ymin, xmax, ymax; |
99 |
|
|
105 |
– |
nrays += 5; /* pretend */ |
100 |
|
fread((char *)col, sizeof(COLOR), 1, devin); |
101 |
|
xmin = getw(devin); ymin = getw(devin); |
102 |
|
xmax = getw(devin); ymax = getw(devin); |
103 |
|
(*dev->paintr)(col, xmin, ymin, xmax, ymax); |
110 |
– |
/* check for input */ |
111 |
– |
if (!notified && dev->inpready > 0) { |
112 |
– |
notified = 1; |
113 |
– |
kill(getppid(), SIGIO); |
114 |
– |
} |
104 |
|
} |
105 |
|
|
106 |
|
|
107 |
+ |
r_flush() /* flush output */ |
108 |
+ |
{ |
109 |
+ |
if (dev->flush != NULL) |
110 |
+ |
(*dev->flush)(); |
111 |
+ |
putc(COM_FLUSH, devout); |
112 |
+ |
putw(dev->inpready, devout); |
113 |
+ |
fflush(devout); |
114 |
+ |
} |
115 |
+ |
|
116 |
+ |
|
117 |
|
r_getcur() /* get and return cursor position */ |
118 |
|
{ |
119 |
|
int c; |
156 |
|
/* reply */ |
157 |
|
putc(COM_COMIN, devout); |
158 |
|
myputs(buf, devout); |
159 |
+ |
putw(dev->inpready, devout); |
160 |
|
fflush(devout); |
161 |
– |
/* reset notify */ |
162 |
– |
notified = 0; |
161 |
|
} |
162 |
|
|
163 |
|
|