| 14 |
|
|
| 15 |
|
#include <stdio.h> |
| 16 |
|
|
| 17 |
– |
#include <signal.h> |
| 18 |
– |
|
| 17 |
|
#include "color.h" |
| 18 |
|
|
| 19 |
|
#include "driver.h" |
| 24 |
|
|
| 25 |
|
FILE *devin, *devout; /* communications channels */ |
| 26 |
|
|
| 29 |
– |
int notified = 0; /* notified parent of input? */ |
| 30 |
– |
|
| 27 |
|
char *progname; /* driver name */ |
| 28 |
|
|
| 29 |
|
int r_clear(), r_paintr(), r_getcur(), r_comout(), r_comin(), r_flush(); |
| 57 |
|
if ((dev = dinit(argv[0], argv[3])) == NULL) |
| 58 |
|
quit(1); |
| 59 |
|
putw(COM_RECVM, devout); /* verify initialization */ |
| 64 |
– |
fwrite((char *)&dev->pixaspect, sizeof(dev->pixaspect), 1, devout); |
| 65 |
– |
putw(dev->xsiz, devout); |
| 66 |
– |
putw(dev->ysiz, devout); |
| 60 |
|
fflush(devout); |
| 61 |
|
/* loop on requests */ |
| 62 |
|
while ((com = getc(devin)) != EOF) { |
| 98 |
|
xmin = getw(devin); ymin = getw(devin); |
| 99 |
|
xmax = getw(devin); ymax = getw(devin); |
| 100 |
|
(*dev->paintr)(col, xmin, ymin, xmax, ymax); |
| 108 |
– |
/* check for input */ |
| 109 |
– |
if (!notified && dev->inpready > 0) { |
| 110 |
– |
notified = 1; |
| 111 |
– |
kill(getppid(), SIGIO); |
| 112 |
– |
} |
| 101 |
|
} |
| 102 |
|
|
| 103 |
|
|
| 105 |
|
{ |
| 106 |
|
if (dev->flush != NULL) |
| 107 |
|
(*dev->flush)(); |
| 108 |
+ |
putc(COM_FLUSH, devout); |
| 109 |
+ |
fwrite((char *)&dev->pixaspect, sizeof(dev->pixaspect), 1, devout); |
| 110 |
+ |
putw(dev->xsiz, devout); |
| 111 |
+ |
putw(dev->ysiz, devout); |
| 112 |
+ |
putw(dev->inpready, devout); |
| 113 |
+ |
fflush(devout); |
| 114 |
|
} |
| 115 |
|
|
| 116 |
|
|
| 156 |
|
/* reply */ |
| 157 |
|
putc(COM_COMIN, devout); |
| 158 |
|
myputs(buf, devout); |
| 159 |
+ |
putw(dev->inpready, devout); |
| 160 |
|
fflush(devout); |
| 166 |
– |
/* reset notify */ |
| 167 |
– |
notified = 0; |
| 161 |
|
} |
| 162 |
|
|
| 163 |
|
|