2 #include "slip_common.h"
5 int slip_proto_read(int fd, void *buf, int len, struct slip_proto *slip)
11 while(i < slip->more){
12 size = slip_unesc(slip->ibuf[i++], slip->ibuf,
13 &slip->pos, &slip->esc);
15 memcpy(buf, slip->ibuf, size);
16 memmove(slip->ibuf, &slip->ibuf[i],
18 slip->more = slip->more - i;
25 n = net_read(fd, &slip->ibuf[slip->pos],
26 sizeof(slip->ibuf) - slip->pos);
31 for(i = 0; i < n; i++){
32 size = slip_unesc(slip->ibuf[start + i], slip->ibuf,&slip->pos,
35 memcpy(buf, slip->ibuf, size);
36 memmove(slip->ibuf, &slip->ibuf[start+i+1],
38 slip->more = n - (i + 1);
45 int slip_proto_write(int fd, void *buf, int len, struct slip_proto *slip)
49 actual = slip_esc(buf, slip->obuf, len);
50 n = net_write(fd, slip->obuf, actual);