| 506 |
|
static int bufsiz = 0; |
| 507 |
|
MSGHEAD msg; |
| 508 |
|
/* read message header */ |
| 509 |
< |
if (fread((char *)&msg, sizeof(MSGHEAD), 1, stdin) != 1) |
| 509 |
> |
if (getbinary(&msg, sizeof(MSGHEAD), 1, stdin) != 1) |
| 510 |
|
goto readerr; |
| 511 |
|
if (msg.nbytes > 0) { /* get the message body */ |
| 512 |
|
if (msg.nbytes > bufsiz) { |
| 518 |
|
if (buf == NULL) |
| 519 |
|
error(SYSTEM, "out of memory in serv_result"); |
| 520 |
|
} |
| 521 |
< |
if (fread(buf, 1, msg.nbytes, stdin) != msg.nbytes) |
| 521 |
> |
if (getbinary(buf, 1, msg.nbytes, stdin) != msg.nbytes) |
| 522 |
|
goto readerr; |
| 523 |
|
} |
| 524 |
|
switch (msg.type) { /* process results */ |
| 543 |
|
break; |
| 544 |
|
case DS_STARTIMM: |
| 545 |
|
case DS_ENDIMM: |
| 546 |
< |
if (!(imm_mode = msg.type==DS_STARTIMM)) |
| 546 |
> |
if (!(imm_mode = (msg.type==DS_STARTIMM))) |
| 547 |
|
dev_flush(); |
| 548 |
|
#ifdef DEBUG |
| 549 |
|
{ |
| 597 |
|
} |
| 598 |
|
msg.type = type; /* write and flush the message */ |
| 599 |
|
msg.nbytes = nbytes; |
| 600 |
< |
fwrite((char *)&msg, sizeof(MSGHEAD), 1, stdout); |
| 600 |
> |
putbinary(&msg, sizeof(MSGHEAD), 1, stdout); |
| 601 |
|
if (nbytes > 0) |
| 602 |
< |
fwrite(p, 1, nbytes, stdout); |
| 602 |
> |
putbinary(p, 1, nbytes, stdout); |
| 603 |
|
if (fflush(stdout) < 0) |
| 604 |
|
error(SYSTEM, "write error in serv_request"); |
| 605 |
|
} |