3
typedef unsigned char byte;
9
if (read_exact(buf, 2) != 2)
11
len = (buf[0] << 8) | buf[1];
12
return read_exact(buf, len);
15
write_cmd(byte *buf, int len)
19
li = (len >> 8) & 0xff;
25
return write_exact(buf, len);
28
read_exact(byte *buf, int len)
33
if ((i = read(0, buf+got, len-got)) <= 0)
41
write_exact(byte *buf, int len)
46
if ((i = write(1, buf+wrote, len-wrote)) <= 0)