| 39 |
|
/* enter main loop */ |
| 40 |
|
do { |
| 41 |
|
rdy = disp_wait(); |
| 42 |
< |
if (rdy & DEV_READY) { |
| 42 |
> |
while (rdy & DEV_READY) { |
| 43 |
|
inp = dev_input(); /* take residual action here */ |
| 44 |
+ |
if (inp & DEV_NEWVIEW) |
| 45 |
+ |
new_view(&odev.v); |
| 46 |
|
if (inp & DEV_SHUTDOWN) |
| 47 |
|
serv_request(DR_SHUTDOWN, 0, NULL); |
| 48 |
< |
else if (inp & DEV_NEWVIEW) |
| 49 |
< |
new_view(&odev.v); |
| 48 |
> |
if (inp & DEV_WAIT) |
| 49 |
> |
serv_request(DR_ATTEN, 0, NULL); |
| 50 |
> |
else |
| 51 |
> |
rdy &= ~DEV_READY; |
| 52 |
|
} |
| 53 |
< |
if (rdy & SERV_READY) |
| 53 |
> |
if (rdy & SERV_READY) { |
| 54 |
|
res = serv_result(); /* processes result, also */ |
| 55 |
+ |
if (res == DS_ACKNOW) |
| 56 |
+ |
serv_request(DR_NOOP, 0, NULL); |
| 57 |
+ |
} |
| 58 |
|
} while (res != DS_SHUTDOWN); |
| 59 |
|
/* all done */ |
| 60 |
|
quit(0); |
| 236 |
|
fwrite(p, 1, nbytes, stdout); |
| 237 |
|
if (fflush(stdout) < 0) |
| 238 |
|
error(SYSTEM, "write error in serv_request"); |
| 239 |
+ |
} |
| 240 |
+ |
|
| 241 |
+ |
|
| 242 |
+ |
eputs(s) /* put error message to stderr */ |
| 243 |
+ |
register char *s; |
| 244 |
+ |
{ |
| 245 |
+ |
static int midline = 0; |
| 246 |
+ |
|
| 247 |
+ |
if (!*s) |
| 248 |
+ |
return; |
| 249 |
+ |
if (!midline++) { /* prepend line with program name */ |
| 250 |
+ |
fputs(progname, stderr); |
| 251 |
+ |
fputs(": ", stderr); |
| 252 |
+ |
} |
| 253 |
+ |
fputs(s, stderr); |
| 254 |
+ |
if (s[strlen(s)-1] == '\n') { |
| 255 |
+ |
fflush(stderr); |
| 256 |
+ |
midline = 0; |
| 257 |
+ |
} |
| 258 |
|
} |
| 259 |
|
|
| 260 |
|
|